@cervio/cli 1.0.1 → 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 (2) hide show
  1. package/dist/cli.js +18 -0
  2. package/package.json +2 -2
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.1",
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,7 +30,7 @@
30
30
  "dependencies": {
31
31
  "commander": "^15.0.0",
32
32
  "prompts": "^2.4.2",
33
- "@cervio/create-plugin": "^1.1.0",
33
+ "@cervio/create-plugin": "^1.1.1",
34
34
  "@cervio/plugin-core": "^1.0.1"
35
35
  },
36
36
  "devDependencies": {