@cervio/cli 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +32 -14
  2. package/dist/cli.js +18 -0
  3. package/package.json +3 -3
package/README.md CHANGED
@@ -1,7 +1,8 @@
1
1
  # @cervio/cli
2
2
 
3
- Developer CLI for Cervio route plugins - login, validate, pack, push, and manage releases,
4
- built on top of `@cervio/plugin-core`.
3
+ Developer CLI for Cervio plugins: login, validate, pack, push and manage releases, built
4
+ on [`@cervio/plugin-core`](https://www.npmjs.com/package/@cervio/plugin-core), the same
5
+ validation the Cervio host applies to uploads.
5
6
 
6
7
  The binary is `cervio`. This document is the **command reference** (source of truth for flags
7
8
  and behaviour). Partner-facing install and multi-instance auth also live on
@@ -9,12 +10,11 @@ and behaviour). Partner-facing install and multi-instance auth also live on
9
10
 
10
11
  ## Install
11
12
 
12
- Inside this monorepo it's already a workspace package. To use it as a standalone tool once published:
13
+ Requires Node.js 26 or later.
13
14
 
14
15
  ```bash
15
- npm install -g @cervio/cli
16
- # or as a project dependency
17
- pnpm add -D @cervio/cli
16
+ npm install --save-dev @cervio/cli # per project (the templates already include it)
17
+ npm install -g @cervio/cli # or globally
18
18
  ```
19
19
 
20
20
  ## Typical workflow
@@ -31,8 +31,8 @@ cervio push --changelog "…" --expect-host https://your-instance.cervio.app
31
31
  ```
32
32
 
33
33
  **First stable push before `--dev`.** The first upload must be a release-channel push
34
- (`cervio push` without `--dev`) so the host creates the `installed_plugins` row. Only then
35
- can `cervio push --dev` upsert a scratch artifact on that plugin.
34
+ (`cervio push` without `--dev`) so the host creates the plugin. Only then can
35
+ `cervio push --dev` upload a scratch build of it.
36
36
 
37
37
  ## Configuration
38
38
 
@@ -56,8 +56,7 @@ Do not duplicate multi-instance guidance here - use the auth-instances docs (or
56
56
 
57
57
  ## PAT scopes
58
58
 
59
- The plugin admin API is scope-gated (`lib/auth/api-scope-guard.ts`). A personal access token
60
- used with this CLI needs:
59
+ The plugin admin API is scope-gated. A personal access token used with this CLI needs:
61
60
 
62
61
  | Scope | Commands |
63
62
  |---|---|
@@ -148,7 +147,7 @@ Flow:
148
147
  5. Packs the plugin (or validates `--file`) and `POST`s it to `/api/v1/admin/plugins/upload` as
149
148
  `multipart/form-data` - see "Upload request format" below. **`--dev` requires the plugin
150
149
  to already exist on the host** (i.e. at least one prior non-dev push) - the dev channel
151
- upserts a scratch artifact for an existing `installed_plugins` row and cannot create one.
150
+ updates a scratch build of an existing plugin and cannot create one.
152
151
  6. On success, updates `lastHost` in `~/.cervio/state.json`.
153
152
 
154
153
  Together with `cervio download`, `--file` lets you round-trip a host artifact
@@ -159,7 +158,7 @@ Together with `cervio download`, `--file` lets you round-trip a host artifact
159
158
  |---|---|
160
159
  | `--host <url>` | Override resolved host |
161
160
  | `--release <semver>` | Download that release label (default: current active release) |
162
- | `--dev` | Download the scratch `plugin_dev_channel` ZIP instead |
161
+ | `--dev` | Download the dev-channel ZIP instead |
163
162
  | `-o, --output <path>` | Destination file (default: `.cervio/out/<plugin_key>-vX.zip` or `…-dev.zip`) |
164
163
  | `--json` | Machine-readable output |
165
164
 
@@ -193,8 +192,8 @@ scaffolder as `npm create @cervio/plugin`. The optional positional `name` is pas
193
192
  | `--dev` | With `--push`, push to the dev channel |
194
193
  | `--host <url>` | Override host for the push |
195
194
 
196
- Watches `src/` with `chokidar`; on any change, rebuilds and validates. Without `--push`,
197
- only build + validate run.
195
+ Watches `src/` (Node's recursive `fs.watch`, changes coalesced); on any change, rebuilds
196
+ and validates. Without `--push`, only build + validate run.
198
197
 
199
198
  ### `cervio doctor [--host <url>] [--json]`
200
199
 
@@ -269,6 +268,11 @@ Response shape depends on `channel`:
269
268
  - `dev`: `{ channel: "dev", plugin, dev_channel: { content_sha256, artifact_sha256, artifact_size_bytes, updated_at } }`.
270
269
  Fails with `plugin_not_found` if the plugin doesn't exist yet (see `push` flow above).
271
270
 
271
+ ## Requests
272
+
273
+ Every request sends `User-Agent: cervio-cli/<version> node/<version>`, so a Cervio host can
274
+ see which CLI versions are still in use.
275
+
272
276
  ## Known gaps
273
277
 
274
278
  - `GET /api/v1/me` does not return an organization display name (only `organization_id`), so
@@ -284,3 +288,17 @@ pnpm --filter @cervio/cli build # tsup → dist/cli.js
284
288
  pnpm --filter @cervio/cli typecheck
285
289
  node packages/cli/dist/cli.js --help
286
290
  ```
291
+
292
+ ## License
293
+
294
+ MIT, see [LICENSE](LICENSE).
295
+
296
+ **Trademark.** "Cervio" and the Cervio logo are trademarks of Cervio S.r.l. This license
297
+ does not grant permission to use them. You may say that a plugin "works with Cervio"; you
298
+ may not imply endorsement or ship a product named Cervio.
299
+
300
+ **Platform.** Using a Cervio organization is governed by your partner or customer
301
+ agreement, not by this license.
302
+
303
+ **Your plugins.** Plugins you write are yours: using this package gives Cervio no rights
304
+ over your plugin, and does not require you to open-source it.
package/dist/cli.js CHANGED
@@ -297,6 +297,10 @@ async function readProjectConfig(cwd = process.cwd()) {
297
297
  throw err;
298
298
  }
299
299
  }
300
+ async function writeProjectConfig(config, cwd = process.cwd()) {
301
+ await promises.writeFile(projectConfigPath(cwd), `${JSON.stringify(config, null, 2)}
302
+ `);
303
+ }
300
304
  function resolveHost(opts) {
301
305
  const host = opts.cliHost || process.env.CERVIO_URL || opts.projectConfig?.host;
302
306
  return host ? normalizeHost(host) : void 0;
@@ -525,10 +529,14 @@ async function loginCommand(opts) {
525
529
  const client = createApiClient({ host, token });
526
530
  const me = await client.getMe();
527
531
  await saveToken(host, token);
532
+ const project = await readProjectConfig().catch(() => null);
533
+ const projectHostSet = !!project?.host?.trim();
534
+ if (project && !projectHostSet) await writeProjectConfig({ ...project, host });
528
535
  log.success(`Logged in to ${host}`);
529
536
  log.info(` user: ${me.email ?? me.user_id}`);
530
537
  log.info(` org: ${me.organization_name ?? me.organization_id}`);
531
538
  log.info(` auth: ${me.auth_method}`);
539
+ if (project && !projectHostSet) log.dim(` cervio.json host set to ${host}`);
532
540
  }
533
541
 
534
542
  // src/commands/open.ts
@@ -731,6 +739,16 @@ async function pushCommand(opts) {
731
739
  log.info(` content_sha256: ${upload.version.content_sha256 ?? "(n/a)"}`);
732
740
  if (upload.reason) log.dim(` ${upload.reason}`);
733
741
  }
742
+ if (upload.plugin.plugin_type === "route") await hintMissingRouteConfig(client, upload.plugin.id);
743
+ }
744
+ async function hintMissingRouteConfig(client, pluginId) {
745
+ try {
746
+ const { route_config } = await client.getRouteConfig(pluginId);
747
+ if (route_config) return;
748
+ } catch {
749
+ return;
750
+ }
751
+ log.step('Not reachable yet: run "cervio route set" to publish it at /r/<route_slug> (or set it in Admin \u2192 Plugins).');
734
752
  }
735
753
  async function safeMe(client) {
736
754
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cervio/cli",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Developer CLI for Cervio plugins: login, validate, pack, push and manage releases.",
5
5
  "keywords": [
6
6
  "cervio",
@@ -30,8 +30,8 @@
30
30
  "dependencies": {
31
31
  "commander": "^15.0.0",
32
32
  "prompts": "^2.4.2",
33
- "@cervio/create-plugin": "^1.0.0",
34
- "@cervio/plugin-core": "^1.0.0"
33
+ "@cervio/create-plugin": "^1.1.1",
34
+ "@cervio/plugin-core": "^1.0.1"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@types/node": "^26.0.0",