Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Linking multi projects update #138

Merged
merged 12 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 86 additions & 7 deletions docs/cli/commands/link.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Link a project to Globe
---

The `link` command links a local Dart project to a Globe project. Linking is required to deploy a project to Globe.
The `link` command links a local Dart project to Globe. Linking is required to deploy a project.

Project linking is carried out automatically if the project is not yet linked when running the [`deploy`](/cli/commands/deploy) command.

Expand All @@ -12,16 +12,95 @@ Project linking is carried out automatically if the project is not yet linked wh
globe link
```

The `link` command will first prompt, asking whether you wish to continue linking the local project. If you continue, you will be further prompted to:

1. Select an account you wish to link this local project to.
2. Select, or create a new project to link this local project to.
```bash
❓ Please select a project you want to link:
❯ ◉ Create a new project
◯ blog-frontend
◯ blog-backend-369d
```

Upon completion, the local project will be linked to your Globe account and you will be able to deploy it.
Upon completion, the local project will be linked to your Globe account and you will be able to deploy.

## How it works

A linked project stores metadata about the project in the local `.dart_tool/dart_globe` directory on your machine. This metadata is used to identify the project when deploying to Globe. If not already,
Globe stores metadata about projects in the `.dart_tool/dart_globe` directory on your machine. This metadata is used to identify projects when deploying to Globe. If not already,
the `.dart_tool` directory should not be committed to your Git repository. You can add this directory to your `.gitignore` file to ensure it is not committed.

If you accidentally delete this directory or run the [`unlink`](/cli/commands/unlink) command, you will need to re-link the project before you can deploy again.

## Linking Multiple Projects (e.g: Mono-Repos)

For directories containing multiple projects, the `link` command supports linking and managing multiple Globe projects.

Run the following command in your workspace directory:

```bash
globe link
```

The CLI displays a list of projects in the directory:

```
❓ Please select a project you want to link:
◯ Create a new project
◯ blog-frontend
❯ ◉ blog-backend-369d
```

Select an existing project to link or create a new one.

## Viewing Linked Projects

To view all projects linked in the workspace, run:

```bash
globe link --show-all
```

This displays a table of all linked projects:

```bash
┌──────────────────────────────┬──────────────────────────────┬──────────────────────────────┐
│ Project │ Project ID │ Organization ID │
├──────────────────────────────┼──────────────────────────────┼──────────────────────────────┤
│ blog-backend-369d │ bd239097-1b68-43e6-a887-466… │ eecbc0fb-ee17-4d87-9b74-0ce… │
├──────────────────────────────┼──────────────────────────────┼──────────────────────────────┤
│ blog-frontend │ 2e8e0149-db61-4883-b734-4d6… │ eecbc0fb-ee17-4d87-9b74-0ce… │
└──────────────────────────────┴──────────────────────────────┴──────────────────────────────┘
```

## Project-Specific Commands

In multi-project setups, you can run commands specific to a project by passing either **project name** or **ID** as argument.

Alternatively, if no argument is specified, the CLI will prompt you to select a project interactively.

### Examples

- Deploy a specific project:

```bash
globe deploy --project="blog-frontend"
```

```bash
globe deploy --project="2e8e0149-db61-4883-b734-4d6832824ca5""
```

- Check tokens for a specific project

Alternatively, if no project is specified, the CLI will prompt you to select a project interactively.

```bash
glober token list --project="blog-backend-369d"
```

- Deploy project interactively

```
~/Projects/OpenSource/website globe deploy ok
🔺 Select project:
❯ ◉ blog-backend-369d
◯ blog-frontend
◯ link new project +
```
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# Dart + Rust FFI Project
---
name: Dart + Rust FFI
description: Building a simple Dart+FFI API backend
tags: ["dart", "dart-ffi"]
username: Invertase
---

This project demonstrates how to integrate Rust with Dart using the Foreign Function Interface (FFI). The Rust code has to be compiled for the x86_64 architecture to ensure compatibility with the Globe runtime.
# Dart + Rust FFI

## Getting Started
## Overview

Requirements

- Dart SDK
- Rust (with the [`cross`](https://github.com/cross-rs/cross) tool for cross-compilation)
- Globe CLI
This project shows how to integrate **Dart** with **Rust** using the [Foreign Function Interface](https://dart.dev/interop/c-interop) (FFI). The Rust code has to be compiled for the `x86_64` architecture to ensure compatibility with the Globe runtime.

## Project Structure

Expand Down Expand Up @@ -37,7 +38,7 @@ cargo install cross

2. Compile for `x86_64-unknown-linux-gnu`

Navigate to the rust_library directory and run:
Navigate to the `native_hello` directory and run:

```sh
cross build --release --target x86_64-unknown-linux-gnu
Expand Down
2 changes: 1 addition & 1 deletion templates/ffi_hello_world/bin/server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const kReleaseMode = bool.fromEnvironment('dart.vm.product');
String get libPath {
final p = kReleaseMode
? 'static/libnative_hello.so'
: 'native_hello/target/debug/libnative_hello.dylib';
: 'native_hello/target/debug/libnative_hello.${Platform.isMacOS ? 'dylib' : 'so'}';
return path.join(Directory.current.path, p);
}

Expand Down
16 changes: 0 additions & 16 deletions templates/ffi_hello_world/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.2"
http_methods:
dependency: transitive
description:
name: http_methods
sha256: "6bccce8f1ec7b5d701e7921dca35e202d425b57e317ba1a37f2638590e29e566"
url: "https://pub.dev"
source: hosted
version: "1.1.1"
http_multi_server:
dependency: transitive
description:
Expand Down Expand Up @@ -241,14 +233,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "3.0.2"
shelf_router:
dependency: "direct main"
description:
name: shelf_router
sha256: f5e5d492440a7fb165fe1e2e1a623f31f734d3370900070b2b1e0d0428d59864
url: "https://pub.dev"
source: hosted
version: "1.1.4"
shelf_static:
dependency: transitive
description:
Expand Down
Loading