globe_cli

Last updated:

0 purchases

globe_cli Image
globe_cli Images
Add to Cart

Description:

globe cli

The global deployment platform for Dart & Flutter applications.








Documentation •
License


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
copied to clipboard
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
copied to clipboard
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
copied to clipboard
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
copied to clipboard
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!');
copied to clipboard
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
copied to clipboard
The first time you deploy, you'll:

Be prompted to continue with setup of the deployment (press Y)
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 #

Learn about to manage your deployments
Learn about the Globe CLI
Integrate with GitHub







Built and maintained with 💛 by Invertase.

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.