globe_cli 0.0.14 copy "globe_cli: ^0.0.14" to clipboard
globe_cli: ^0.0.14 copied to clipboard

The global deployment platform for Dart & Flutter applications.



The global deployment platform for Dart & Flutter applications.

Melos Chat on Discord

DocumentationLicense


CLI #

The Globe CLI is a command line tool that allows you to interact with your Globe account and deploy from the command line. It is not required to use Globe, but it can be useful for some workflows.

To install the Globe CLI, run the following command:

dart pub global activate globe_cli

Once installed, you can access the globe executable from anywhere on your machine.

To login with your Globe account, run the following command:

globe login

To learn more about the CLI, view the documentation.

Create a new Dart project #

To get started with, we're going to create a simple Dart application which will be deployed to Globe. We'll use Shelf to start a HTTP server which can handle requests and log some information about our application. Let's go ahead and create a basic Dart application. In your terminal, run the following command where you'd like to create a project:

dart create my_shelf_app

Rename the file lib/my_shelf_app.dart to lib/main.dart - this is the entrypoint for our application. Next, install the shelf package via pub:

dart pub add shelf

Copy the following code into lib/main.dart:

import 'dart:io';

import 'package:shelf/shelf.dart';
import 'package:shelf/shelf_io.dart' as shelf_io;

void main() async {
  final handler =
      const Pipeline().addMiddleware(logRequests()).addHandler(_echoRequest);

  final server = await shelf_io.serve(
    handler,
    InternetAddress.anyIPv4,
    int.tryParse(Platform.environment['PORT'] ?? '8080') ?? 8080,
  );

  print('Serving at http://${server.address.host}:${server.port}');
}

Response _echoRequest(Request request) =>
    Response.ok('Request for "${request.url}"... worked!');

To test your application out locally, run dart run lib/main.dart and visit http://0.0.0.0:8080/hello in your browser. You should see the following: Request for "hello"... worked!.

This is a basic HTTP server that will respond to any request with a 200 OK response and the body Request for "${request.url}"... worked!, whilst also logging out information about the request. From here you could build out a full application yourself, adding in routing, database calls, middleware and more. For this example, we'll keep it simple.

Deploying to Globe #

Now that we have a basic application, we can deploy it to Globe. Deploying to Globe is simple; run the globe deploy command from your project root in the terminal:

globe deploy

The first time you deploy, you'll:

  1. Be prompted to continue with setup of the deployment (press Y)
  2. Enter a name for your project: Enter: my-shelf-app

After waiting for a couple of seconds, you'll be shown that your new deployment has been queued and be provided a unique URL for that deployment. You can visit this URL in your browser to view the build logs and deployment status.

Viewing your deployment logs #

Once complete, your deployment will be available via the URL shown in the dashboard. Each deployment has it's own unique URL, with a globeapp.dev domain. Click the URL and you'll be shown the Request for "hello"... worked! message which your saw when running your application locally.

Since our application has both a print statement and and a middleware logger (provided by Shelf), we're able to inspect those logs in realtime from the dashboard. Click the "Logs" tab in the dashboard to view the logs for your deployment. Each time your refresh the deployment URL, a new log will appear in the dashboard! Any errors (which emit to stderr) will be highlighted in red.

Further reading #


Built and maintained with 💛 by Invertase.

13
likes
120
points
623
downloads

Publisher

verified publisherglobe.dev

Weekly Downloads

The global deployment platform for Dart & Flutter applications.

Repository (GitHub)
View/report issues
Contributing

Documentation

API reference

License

Apache-2.0 (license)

Dependencies

archive, args, cli_completion, cli_table, cli_util, collection, get_it, glob, http, mason_logger, meta, path, pool, pub_updater, pubspec_parse

More

Packages that depend on globe_cli