Skip to content
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
25 changes: 20 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,8 @@ jobs:
- name: Install dependencies
run: npm ci

- name: Publish @fleetbase/cli
run: npm publish --access public --tag ${{ contains(github.ref_name, '-') && 'next' || 'latest' }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}

# The installer first: @fleetbase/cli depends on it (`flb install-fleetbase`), so the CLI must
# never reach npm while the installer version it needs is missing.
- name: Publish @fleetbase/installer when its version is new
run: |
version=$(node -p "require('./packages/installer/package.json').version")
Expand All @@ -153,6 +150,11 @@ jobs:
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}

- name: Publish @fleetbase/cli
run: npm publish --access public --tag ${{ contains(github.ref_name, '-') && 'next' || 'latest' }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}

github_publish:
needs: [test, e2e]
runs-on: ubuntu-latest
Expand All @@ -172,6 +174,19 @@ jobs:
- name: Install dependencies
run: npm ci

# Same order as npm: with the @fleetbase scope pointed at GitHub Packages, the CLI's
# dependency on the installer is resolved here too.
- name: Publish @fleetbase/installer to GitHub Packages when its version is new
run: |
version=$(node -p "require('./packages/installer/package.json').version")
if npm view "@fleetbase/installer@$version" version >/dev/null 2>&1; then
echo "@fleetbase/installer@$version is already on GitHub Packages"
else
npm publish -w @fleetbase/installer
fi
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Publish to GitHub Packages
run: npm publish
env:
Expand Down
22 changes: 20 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,25 @@ npm install -g @fleetbase/cli
flb --help
```

Requires Node.js 20.10 or later. Installing Fleetbase itself moved to its own package:
`npx @fleetbase/installer` (see [packages/installer](packages/installer)).
Requires Node.js 20.10 or later.

## Install Fleetbase

```bash
npm install -g @fleetbase/cli
flb install-fleetbase
```

The setup wizard clones Fleetbase, asks for the host, environment, database, mail and storage
settings, and starts it with Docker. It needs Docker, Docker Compose v2 and Git. For CI, pass the
flags and `--non-interactive`:

```bash
flb install-fleetbase --directory ./fleetbase --environment production --host fleet.example.com --non-interactive
```

The wizard is the [`@fleetbase/installer`](packages/installer) package, so `npx @fleetbase/installer`
runs the same thing without installing the CLI.

## Quick start: publish an extension

Expand Down Expand Up @@ -51,6 +68,7 @@ price and permissions are published as soon as their checks pass.
| `flb instance register --path <fleetbase>\|--docker` | Registers the instance itself: mints a code and pipes it to `php artisan registry:register --code-stdin`, so the instance token stays in the instance's encrypted settings. Without a target (or with `--store-token`) the CLI exchanges the code and keeps the token in the config file. Registering an instance again rotates it on the service rather than creating a second one: the instance (or, with `--store-token`, the config entry for the same `--path` or `--host`) sends its current token, the service also matches the same host in the same organization, and the instance keeps its id, installs and licence seats with a new token ("Re-registered …"). Under Octane the new registration applies to the running workers without a reload |
| `flb instance status\|updates\|list\|forget` | The instance as the service sees it, its licences and available updates |
| `flb install <ext>[@version]` / `flb update` / `flb uninstall` | Runs `php artisan registry:install\|update\|uninstall` on an instance (`--path` or `--docker [service]`) and follows the job |
| `flb install-fleetbase [--directory] [--environment] [--host] [--app-name] [--non-interactive]` | Installs Fleetbase itself with Docker through the setup wizard ([`@fleetbase/installer`](packages/installer)) |
| `flb doctor [--path\|--docker]` | Config, registry connectivity, token validity and scopes, instances, local tools, the instance's installer |
| `flb config list\|get\|set\|unset\|path` | `registry` and `organization` defaults |

Expand Down
30 changes: 11 additions & 19 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,15 @@
> v2.0.0 ~ "CLI v2 for the Fleetbase Extensions Registry"
> v2.0.1 ~ "flb install-fleetbase is back"

---
## What's New
- Rewritten in TypeScript against the Registry Service API (`/v1`). Same package (`@fleetbase/cli`) and binary (`flb`).
- `flb login` / `logout` / `whoami`, `flb register` / `verify`, `flb token create|list|revoke`: scoped, expiring personal tokens.
- `flb init` scaffolds from fleetbase/starter-extension with your organization's package names, PHP namespace and an `extension.json` with `compat` ranges.
- `flb build` writes the engine tarball, the Composer api archive and, with `--prebuilt --console <path>`, the prebuilt engine dist from ember-core's `build-engine-release`; `flb bump` keeps the three manifests on one version.
- `flb publish [--channel beta] [--submit]` creates the listing, uploads the release and streams the registry checks; `flb release status|submit|withdraw|yank|list` follow it through review.
- Trusted publishing from GitHub Actions: `flb publish` exchanges the job's OIDC token for a short-lived, publish-only token when a trusted publisher is configured on the listing. The composite action `fleetbase/fleetbase-cli/action@v2` installs the CLI, publishes and exposes the release id, version and status.
- `flb search`, `flb info`: the public catalog.
- `flb listing list|show|update|categories`: complete the catalog listing from the terminal.
- `extension.json` can carry the catalog listing in a `listing` block (subtitle, description or a Markdown file, category, tags, languages, icon, hosting, copyright, links). `flb publish` applies it on every publish, trusted publishing included; the registry then shows those fields read-only in Studio. `flb listing pull` writes an existing listing into the block.
- `flb instance code|register|status|updates`: instance registration from a server shell; `register --path|--docker` hands the code to the instance (`registry:register`) so its token never leaves it.
- `flb install|update|uninstall` run registry-bridge's queued installer (`php artisan registry:*`) locally or in a docker compose service and follow the job.
- `flb doctor` checks config, token, connectivity, instances and local tools.
## Fixed
- `flb install-fleetbase` installs Fleetbase again. In 2.0.0 it only printed a pointer to `npx @fleetbase/installer` and exited with an error, which broke the documented install: `npm install -g @fleetbase/cli && flb install-fleetbase`.
- The wizard itself is the `@fleetbase/installer` package, now a dependency of the CLI. `flb install-fleetbase` takes the same flags (`--directory`, `--environment`, `--host`, `--app-name`, `--non-interactive`), and `npx @fleetbase/installer` still runs it without the CLI.

---
## Breaking changes
- `install-fleetbase` moved to its own package: `npx @fleetbase/installer`.
- Removed: `set-auth` (use `flb login --token`), `scaffold` (now `init`), `bundle` / `bundle-upload` (`build` / `publish`), `generate-token` (`token create`), `resend-verification` (`verify --resend`), `unpublish` (`release yank`), `version-bump` (`bump`). The old names print what replaced them.
- Tokens live only in `~/.fleetbase/config.json` (mode 600); nothing is written to `.npmrc` or `auth.json`. Tokens from 0.0.x are not accepted by the Registry Service: run `flb login`.
- Requires Node.js 20.10 or later.
## Release
- `@fleetbase/installer` is published before `@fleetbase/cli`, to npm and to GitHub Packages, so the CLI never points at a version that is not there.

---
## Need help?
- [GitHub Discussions](https://github.com/fleetbase/fleetbase/discussions)
- [Discord](https://discord.gg/HnTqQ6zAVn)
5 changes: 3 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fleetbase/cli",
"version": "2.0.0",
"version": "2.0.1",
"description": "Fleetbase CLI: publish extensions to the Fleetbase Extensions Registry and manage installs on your instances",
"repository": "https://github.com/fleetbase/fleetbase-cli",
"license": "AGPL-3.0-or-later",
Expand Down Expand Up @@ -35,6 +35,7 @@
"prepack": "npm run clean && npm run build"
},
"dependencies": {
"@fleetbase/installer": "^0.1.0",
"commander": "^14.0.3",
"enquirer": "^2.4.1",
"picocolors": "^1.1.1",
Expand Down
3 changes: 1 addition & 2 deletions packages/installer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,4 @@ These match the fleetbase repo's `scripts/docker-install.sh`. To turn authentica
Restart the containers after editing `.env`. The socket's allowed origins (`SOCKETCLUSTER_OPTIONS`) are still written to
`docker-compose.override.yml`.

This was `flb install-fleetbase` in `@fleetbase/cli` up to 0.0.7. The CLI now only covers
the extensions registry; `flb install-fleetbase` prints a pointer here.
`flb install-fleetbase` in `@fleetbase/cli` runs this package with the same flags.
44 changes: 44 additions & 0 deletions src/commands/install-fleetbase.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import type { Command } from 'commander';

/** What `@fleetbase/installer` reads from its options. */
export interface InstallFleetbaseOptions {
host?: string;
environment?: string;
directory?: string;
appName?: string;
nonInteractive?: boolean;
}

type Wizard = (options: InstallFleetbaseOptions) => Promise<void>;

/**
* The wizard lives in `@fleetbase/installer` (also `npx @fleetbase/installer`). It is loaded
* only when the command runs: nothing else in the CLI needs it.
*/
async function loadWizard(): Promise<Wizard> {
const module = (await import('@fleetbase/installer')) as { installFleetbaseCommand?: Wizard; default?: { installFleetbaseCommand?: Wizard } };
const wizard = module.installFleetbaseCommand ?? module.default?.installFleetbaseCommand;
if (typeof wizard !== 'function') {
throw new Error('@fleetbase/installer did not load. Reinstall the CLI, or run `npx @fleetbase/installer`.');
}
return wizard;
}

/**
* `flb install-fleetbase`: installs Fleetbase itself with Docker. The same flags as
* `npx @fleetbase/installer`, which this runs.
*/
export function register(program: Command): void {
program
.command('install-fleetbase')
.description('Install Fleetbase with Docker through the setup wizard (same as `npx @fleetbase/installer`)')
.option('--host <host>', 'Host or IP address to bind to (default: localhost)')
.option('--environment <environment>', 'Environment: development or production (default: development)')
.option('--directory <directory>', 'Installation directory (default: current directory)')
.option('--app-name <name>', 'Application name (default: Fleetbase)')
.option('--non-interactive', 'Skip every prompt; use flags and safe defaults (useful for CI/CD)')
.action(async (options: InstallFleetbaseOptions) => {
const wizard = await loadWizard();
await wizard(options);
});
}
12 changes: 0 additions & 12 deletions src/commands/legacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,6 @@ const MOVED: [string, string][] = [
];

export function register(program: Command): void {
program
.command('install-fleetbase', { hidden: true })
.description('Moved to @fleetbase/installer')
.allowUnknownOption()
.allowExcessArguments()
.action(() => {
log.error('install-fleetbase moved out of the CLI into its own package.');
log.info('Run it with:');
log.info(' npx @fleetbase/installer [--directory <dir>] [--environment development|production] [--non-interactive]');
process.exitCode = 1;
});

for (const [name, replacement] of MOVED) {
program
.command(name, { hidden: true })
Expand Down
9 changes: 9 additions & 0 deletions src/installer-module.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
declare module '@fleetbase/installer' {
export function installFleetbaseCommand(options: {
host?: string;
environment?: string;
directory?: string;
appName?: string;
nonInteractive?: boolean;
}): Promise<void>;
}
3 changes: 2 additions & 1 deletion src/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import * as catalog from './commands/catalog.js';
import * as config from './commands/config.js';
import * as doctor from './commands/doctor.js';
import * as init from './commands/init.js';
import * as installFleetbase from './commands/install-fleetbase.js';
import * as installer from './commands/installer.js';
import * as instance from './commands/instance.js';
import * as legacy from './commands/legacy.js';
Expand All @@ -29,7 +30,7 @@ export function createProgram(): Command {
.showHelpAfterError('(run with --help for usage)')
.configureHelp({ sortSubcommands: false });

for (const module of [auth, token, init, build, bump, publish, release, listing, catalog, instance, installer, doctor, config, legacy]) {
for (const module of [auth, token, init, build, bump, publish, release, listing, catalog, instance, installer, installFleetbase, doctor, config, legacy]) {
module.register(program);
}
return program;
Expand Down
46 changes: 46 additions & 0 deletions test/unit/install-fleetbase.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { beforeEach, describe, expect, it, vi } from 'vitest';

const wizard = vi.fn(async () => {});

vi.mock('@fleetbase/installer', () => ({ installFleetbaseCommand: wizard }));

const { createProgram, main } = await import('../../src/program.js');

describe('flb install-fleetbase', () => {
beforeEach(() => {
wizard.mockClear();
process.exitCode = undefined;
});

it('is a listed command with the installer flags', () => {
const command = createProgram().commands.find((item) => item.name() === 'install-fleetbase');

expect(command).toBeDefined();
expect(createProgram().helpInformation()).toContain('install-fleetbase');
expect(command!.options.map((option) => option.long)).toEqual(['--host', '--environment', '--directory', '--app-name', '--non-interactive']);
});

it('runs the installer wizard with the flags it was given', async () => {
const code = await main(['node', 'flb', 'install-fleetbase', '--directory', './fleetbase', '--environment', 'production', '--host', 'fleet.example.com', '--app-name', 'Acme', '--non-interactive']);

expect(code).toBe(0);
expect(wizard).toHaveBeenCalledTimes(1);
expect(wizard).toHaveBeenCalledWith({ directory: './fleetbase', environment: 'production', host: 'fleet.example.com', appName: 'Acme', nonInteractive: true });
});

it('runs the wizard with no flags, for the interactive install', async () => {
const code = await main(['node', 'flb', 'install-fleetbase']);

expect(code).toBe(0);
expect(wizard).toHaveBeenCalledWith({});
});
});

describe('the real @fleetbase/installer', () => {
it('exports the wizard the command calls', async () => {
const installer = await vi.importActual<Record<string, unknown>>('@fleetbase/installer');
const exported = installer.installFleetbaseCommand ?? (installer.default as Record<string, unknown> | undefined)?.installFleetbaseCommand;

expect(typeof exported).toBe('function');
});
});
Loading