@cimplify/cli 0.2.1 → 0.2.3

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.
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { REGISTRY_INDEX, REGISTRY } from './chunk-SN6E73KY.mjs';
3
3
  import { promptYesNo } from './chunk-L6474RPL.mjs';
4
- import { parseArgs, flagString, flagBool } from './chunk-BXM4AWJQ.mjs';
4
+ import { parseArgs, flagString, flagBool } from './chunk-4SBJVRGM.mjs';
5
5
  import { CliError, CLI_ERROR_CODE, info, bold, dim, success, result, yellow } from './chunk-NZ4RG62Z.mjs';
6
6
  import { mkdirSync, existsSync, writeFileSync } from 'fs';
7
7
  import { resolve, join, dirname } from 'path';
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  import { promptYesNo } from './chunk-L6474RPL.mjs';
3
- import { TOKEN_PURPOSE, REPO_PROVIDER, REPO_PROVIDER_VALUES } from './chunk-VE74N3YS.mjs';
4
- import { parseArgs, flagString, flagBool } from './chunk-BXM4AWJQ.mjs';
5
- import { ApiClient } from './chunk-4ZVTPMUZ.mjs';
3
+ import { TOKEN_PURPOSE, REPO_PROVIDER, REPO_PROVIDER_VALUES } from './chunk-MXYUAJEW.mjs';
4
+ import { parseArgs, flagString, flagBool } from './chunk-4SBJVRGM.mjs';
5
+ import { ApiClient } from './chunk-NC3GKHDD.mjs';
6
6
  import { readAuth, readProjectLink } from './chunk-JJYWETGA.mjs';
7
7
  import { CliError, CLI_ERROR_CODE, isJsonMode, result, dim, success, info, bold } from './chunk-NZ4RG62Z.mjs';
8
8
 
@@ -11,6 +11,8 @@ var BOOLEAN_FLAGS = /* @__PURE__ */ new Set([
11
11
  "no-deps",
12
12
  "utilities",
13
13
  "components",
14
+ // Update
15
+ "check",
14
16
  // Deploy / rollback
15
17
  "prod",
16
18
  "no-push",
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { TERMINAL_DEPLOYMENT_STATUSES, DEPLOYMENT_STATUS } from './chunk-VE74N3YS.mjs';
2
+ import { TERMINAL_DEPLOYMENT_STATUSES, DEPLOYMENT_STATUS } from './chunk-MXYUAJEW.mjs';
3
3
  import { dim, CliError, CLI_ERROR_CODE, failure, success, isJsonMode } from './chunk-NZ4RG62Z.mjs';
4
4
 
5
5
  // src/progress.ts
@@ -13,9 +13,11 @@ var DEPLOY_TRIGGER = {
13
13
  SCHEDULE: "schedule"
14
14
  };
15
15
  var DEPLOYMENT_STATUS = {
16
+ PENDING: "pending",
16
17
  QUEUED: "queued",
17
- BUILDING: "building",
18
+ DEPLOYING: "deploying",
18
19
  ACTIVE: "active",
20
+ INACTIVE: "inactive",
19
21
  FAILED: "failed",
20
22
  CANCELLED: "cancelled",
21
23
  SUPERSEDED: "superseded"
@@ -125,7 +125,7 @@ async function parseResponse(response) {
125
125
  function mapStatusToCode(status) {
126
126
  if (status === STATUS_UNAUTHORIZED) return CLI_ERROR_CODE.AUTH_FAILED;
127
127
  if (status === STATUS_FORBIDDEN) return CLI_ERROR_CODE.AUTH_FAILED;
128
- if (status === STATUS_NOT_FOUND) return CLI_ERROR_CODE.PROJECT_NOT_FOUND;
128
+ if (status === STATUS_NOT_FOUND) return CLI_ERROR_CODE.NOT_FOUND;
129
129
  if (status === STATUS_CONFLICT) return CLI_ERROR_CODE.ALREADY_LINKED;
130
130
  if (status >= STATUS_SERVER_ERROR_MIN) return CLI_ERROR_CODE.SERVER_ERROR;
131
131
  if (status >= STATUS_BAD_REQUEST_MIN) return CLI_ERROR_CODE.INVALID_INPUT;
@@ -143,7 +143,7 @@ function extractErrorMessage(body, status) {
143
143
  }
144
144
  function toNetworkError(err) {
145
145
  if (err instanceof DOMException && err.name === "AbortError") {
146
- return new CliError(CLI_ERROR_CODE.NETWORK_ERROR, "Request timed out.");
146
+ return new CliError(CLI_ERROR_CODE.TIMEOUT, "Request timed out.");
147
147
  }
148
148
  const message = err instanceof Error ? err.message : String(err);
149
149
  return new CliError(CLI_ERROR_CODE.NETWORK_ERROR, `Network error: ${message}`);
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env node
2
+ // package.json
3
+ var package_default = {
4
+ name: "@cimplify/cli",
5
+ version: "0.2.3",
6
+ description: "Cimplify CLI \u2014 deploy, manage env vars, link projects, and scaffold storefronts",
7
+ keywords: [
8
+ "cimplify",
9
+ "cli",
10
+ "deploy",
11
+ "storefront"
12
+ ],
13
+ license: "MIT",
14
+ bin: {
15
+ cimplify: "dist/dispatcher.mjs"
16
+ },
17
+ files: [
18
+ "dist",
19
+ "templates"
20
+ ],
21
+ scripts: {
22
+ "bundle-assets": "bun scripts/bundle-assets.ts",
23
+ prebuild: "bun run bundle-assets",
24
+ build: "tsup",
25
+ "build:binary": "bun run bundle-assets && bun scripts/build-binaries.ts",
26
+ "build:binary:local": "bun run bundle-assets && bun scripts/build-binaries.ts --local",
27
+ "sync:template-pins": "bun scripts/sync-template-pins.ts",
28
+ version: "bun scripts/sync-template-pins.ts && git add templates/*/package.json",
29
+ prepublishOnly: "bun scripts/sync-template-pins.ts && bun run build",
30
+ dev: "bun run bundle-assets && tsup --watch",
31
+ typecheck: "bun run bundle-assets && tsgo --noEmit -p tsconfig.json",
32
+ clean: "rm -rf dist bin src/embedded-assets.ts",
33
+ "lint:ox": "oxlint --fix .",
34
+ format: "oxfmt . --write",
35
+ "format:check": "oxfmt . --check",
36
+ test: "vitest",
37
+ "test:run": "vitest run"
38
+ },
39
+ devDependencies: {
40
+ "@types/node": "^25.6.0",
41
+ "@typescript/native-preview": "^7.0.0-dev.20260503.1",
42
+ tsup: "^8.5.1",
43
+ typescript: "5.9.3",
44
+ vitest: "^4.1.5"
45
+ }
46
+ };
47
+
48
+ export { package_default };
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
- import { pollDeployment } from './chunk-2BO4H6VP.mjs';
3
- import { fetchCloneToken } from './chunk-27QJ5JQI.mjs';
2
+ import { pollDeployment } from './chunk-JOUXICGV.mjs';
3
+ import { fetchCloneToken } from './chunk-2Y4JWLPE.mjs';
4
4
  import { promptYesNo } from './chunk-L6474RPL.mjs';
5
- import { TOKEN_PURPOSE, ENV_SCOPE, DEPLOY_TRIGGER, DEPLOYMENT_STATUS } from './chunk-VE74N3YS.mjs';
6
- import { parseArgs, flagBool, flagString } from './chunk-BXM4AWJQ.mjs';
7
- import { ApiClient } from './chunk-4ZVTPMUZ.mjs';
5
+ import { TOKEN_PURPOSE, ENV_SCOPE, DEPLOY_TRIGGER, DEPLOYMENT_STATUS } from './chunk-MXYUAJEW.mjs';
6
+ import { parseArgs, flagBool, flagString } from './chunk-4SBJVRGM.mjs';
7
+ import { ApiClient } from './chunk-NC3GKHDD.mjs';
8
8
  import { readAuth, readProjectLink, writeProjectState } from './chunk-JJYWETGA.mjs';
9
9
  import { CliError, CLI_ERROR_CODE, step, info, dim, success, result, EXIT_CODE } from './chunk-NZ4RG62Z.mjs';
10
10
  import { spawn } from 'child_process';
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  import { parseEnvFile, formatEnvFile } from './chunk-4YSOZ6LY.mjs';
3
- import { ENV_SCOPE, PUBLIC_ENV_PREFIX } from './chunk-VE74N3YS.mjs';
4
- import { parseArgs, flagBool } from './chunk-BXM4AWJQ.mjs';
5
- import { ApiClient } from './chunk-4ZVTPMUZ.mjs';
3
+ import { ENV_SCOPE, PUBLIC_ENV_PREFIX } from './chunk-MXYUAJEW.mjs';
4
+ import { parseArgs, flagBool } from './chunk-4SBJVRGM.mjs';
5
+ import { ApiClient } from './chunk-NC3GKHDD.mjs';
6
6
  import { readAuth, readProjectLink } from './chunk-JJYWETGA.mjs';
7
7
  import { info, CliError, CLI_ERROR_CODE, dim } from './chunk-NZ4RG62Z.mjs';
8
8
  import { spawn } from 'child_process';
@@ -1,12 +1,9 @@
1
1
  #!/usr/bin/env node
2
+ import { package_default } from './chunk-WTFQ3B5E.mjs';
2
3
  import { TEMPLATES } from './chunk-SN6E73KY.mjs';
3
4
 
4
- // package.json
5
- var package_default = {
6
- version: "0.2.1"};
7
-
8
5
  // src/dispatcher.ts
9
- var VERSION = package_default.version;
6
+ var VERSION = package_default.version ?? "unknown";
10
7
  var HELP = `cimplify \u2014 Cimplify CLI
11
8
 
12
9
  Usage:
@@ -74,6 +71,12 @@ Global flags (work with any cloud subcommand):
74
71
  --yes, -y Auto-confirm yes/no prompts (e.g. --allow-dirty).
75
72
  Non-TTY runs throw INTERACTIVE_REQUIRED unless --yes is set.
76
73
 
74
+ Self-update:
75
+ cimplify update [flags] Re-run the installer to upgrade the native binary
76
+ cimplify update --check Compare current version to latest release; don't install
77
+ cimplify update --version cli-v0.2.2 Pin a specific release
78
+ cimplify update --prefix ~/.local Override install location (default: inferred from $0)
79
+
77
80
  Misc:
78
81
  cimplify --help, -h Show this help
79
82
  cimplify --version, -v Show CLI version
@@ -112,22 +115,24 @@ Need the mock storefront server? It ships with @cimplify/sdk:
112
115
  bunx @cimplify/sdk mock [flags] Boot the local Cimplify API mock
113
116
  `;
114
117
  var COMMANDS = {
115
- login: () => import('./login-4OB5ZIR4.mjs'),
118
+ login: () => import('./login-RSKGT6GU.mjs'),
116
119
  logout: () => import('./logout-ZFZLSJ32.mjs'),
117
- whoami: () => import('./whoami-INHDUHWA.mjs'),
118
- projects: () => import('./projects-KBFX4Q3E.mjs'),
119
- link: () => import('./link-PDITLRI4.mjs'),
120
+ whoami: () => import('./whoami-DIJZYZIN.mjs'),
121
+ projects: () => import('./projects-IHDG76PK.mjs'),
122
+ link: () => import('./link-P4K2HRXY.mjs'),
120
123
  unlink: () => import('./unlink-5ABCT7B6.mjs'),
121
- deploy: () => import('./deploy-UAPJ35KZ.mjs'),
122
- rollback: () => import('./rollback-Z74AP6PL.mjs'),
123
- env: () => import('./env-CMNNPAA4.mjs'),
124
- domains: () => import('./domains-INY76L24.mjs'),
125
- logs: () => import('./logs-VQCYRAHN.mjs'),
126
- status: () => import('./status-BYHS4SG3.mjs'),
127
- dev: () => import('./dev-OPKFS77L.mjs'),
128
- repo: () => import('./repo-J5LZOBZZ.mjs'),
129
- list: () => import('./list-MUARZ6RW.mjs'),
130
- add: () => import('./add-FP4UGVGE.mjs')
124
+ deploy: () => import('./deploy-M37L5P6H.mjs'),
125
+ rollback: () => import('./rollback-36O4NOEL.mjs'),
126
+ env: () => import('./env-FDBPGU3W.mjs'),
127
+ domains: () => import('./domains-2ZQ7AG27.mjs'),
128
+ logs: () => import('./logs-E2AGTDCF.mjs'),
129
+ status: () => import('./status-6AT4HF63.mjs'),
130
+ dev: () => import('./dev-AQP6TMYK.mjs'),
131
+ repo: () => import('./repo-XMMLZHLC.mjs'),
132
+ list: () => import('./list-DS4C3JRB.mjs'),
133
+ add: () => import('./add-YJDP63WM.mjs'),
134
+ update: () => import('./update-DBU2HAYG.mjs'),
135
+ upgrade: () => import('./update-DBU2HAYG.mjs')
131
136
  };
132
137
  var GLOBAL_FLAGS = /* @__PURE__ */ new Set(["--json", "--yes", "-y"]);
133
138
  function extractGlobalFlags(argv) {
@@ -152,11 +157,18 @@ async function main() {
152
157
  const [maybeSub, ...rest] = cleaned.args;
153
158
  const TOP_LEVEL_FLAGS = /* @__PURE__ */ new Set(["--help", "-h", "help", "--version", "-v", "version"]);
154
159
  if (!maybeSub) {
155
- console.log(HELP);
160
+ if (cleaned.json) {
161
+ process.stdout.write(
162
+ `${JSON.stringify({ ok: true, data: { help: true, version: VERSION } })}
163
+ `
164
+ );
165
+ } else {
166
+ console.log(HELP);
167
+ }
156
168
  return;
157
169
  }
158
170
  if (TOP_LEVEL_FLAGS.has(maybeSub)) {
159
- return await runDispatcherFlag(maybeSub);
171
+ return await runDispatcherFlag(maybeSub, cleaned.json);
160
172
  }
161
173
  const sub = maybeSub;
162
174
  const args = rest;
@@ -308,8 +320,16 @@ async function emitError(sub, err) {
308
320
  }
309
321
  console.error(`cimplify ${sub}:`, String(err));
310
322
  }
311
- async function runDispatcherFlag(flag) {
312
- if (flag === "-h" || flag === "--help" || flag === "help") {
323
+ async function runDispatcherFlag(flag, json) {
324
+ const isHelp = flag === "-h" || flag === "--help" || flag === "help";
325
+ if (json) {
326
+ process.stdout.write(
327
+ `${JSON.stringify({ ok: true, data: isHelp ? { help: true, version: VERSION } : { version: VERSION } })}
328
+ `
329
+ );
330
+ return;
331
+ }
332
+ if (isHelp) {
313
333
  console.log(HELP);
314
334
  return;
315
335
  }
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  import { promptYesNo } from './chunk-L6474RPL.mjs';
3
- import { ENV_SCOPE, DOMAIN_TYPE } from './chunk-VE74N3YS.mjs';
4
- import { parseArgs, flagBool, flagString } from './chunk-BXM4AWJQ.mjs';
5
- import { ApiClient } from './chunk-4ZVTPMUZ.mjs';
3
+ import { ENV_SCOPE, DOMAIN_TYPE } from './chunk-MXYUAJEW.mjs';
4
+ import { parseArgs, flagBool, flagString } from './chunk-4SBJVRGM.mjs';
5
+ import { ApiClient } from './chunk-NC3GKHDD.mjs';
6
6
  import { readAuth, readProjectLink } from './chunk-JJYWETGA.mjs';
7
7
  import { CliError, CLI_ERROR_CODE, info, dim, result, bold, success } from './chunk-NZ4RG62Z.mjs';
8
8
 
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
  import { formatEnvFile, parseEnvFile, parseKeyValueArg } from './chunk-4YSOZ6LY.mjs';
3
3
  import { promptYesNo } from './chunk-L6474RPL.mjs';
4
- import { ENV_SCOPE, PUBLIC_ENV_PREFIX, SECRET_MASK } from './chunk-VE74N3YS.mjs';
5
- import { parseArgs, flagString, flagBool } from './chunk-BXM4AWJQ.mjs';
6
- import { ApiClient } from './chunk-4ZVTPMUZ.mjs';
4
+ import { ENV_SCOPE, PUBLIC_ENV_PREFIX, SECRET_MASK } from './chunk-MXYUAJEW.mjs';
5
+ import { parseArgs, flagString, flagBool } from './chunk-4SBJVRGM.mjs';
6
+ import { ApiClient } from './chunk-NC3GKHDD.mjs';
7
7
  import { readAuth, readProjectLink } from './chunk-JJYWETGA.mjs';
8
8
  import { CliError, CLI_ERROR_CODE, info, dim, result, bold, success } from './chunk-NZ4RG62Z.mjs';
9
9
  import { promises } from 'fs';
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { parseArgs } from './chunk-BXM4AWJQ.mjs';
3
- import { ApiClient } from './chunk-4ZVTPMUZ.mjs';
2
+ import { parseArgs } from './chunk-4SBJVRGM.mjs';
3
+ import { ApiClient } from './chunk-NC3GKHDD.mjs';
4
4
  import { readAuth, writeProjectLink } from './chunk-JJYWETGA.mjs';
5
5
  import { CliError, CLI_ERROR_CODE, success, info, dim, result } from './chunk-NZ4RG62Z.mjs';
6
6
 
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { REGISTRY_INDEX } from './chunk-SN6E73KY.mjs';
3
- import { parseArgs, flagBool } from './chunk-BXM4AWJQ.mjs';
3
+ import { parseArgs, flagBool } from './chunk-4SBJVRGM.mjs';
4
4
  import { CliError, CLI_ERROR_CODE, info, bold, dim, green, result } from './chunk-NZ4RG62Z.mjs';
5
5
 
6
6
  // src/commands/list.ts
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { parseArgs, flagString, flagBool } from './chunk-BXM4AWJQ.mjs';
3
- import { resolveBaseUrl, ApiClient } from './chunk-4ZVTPMUZ.mjs';
2
+ import { parseArgs, flagString, flagBool } from './chunk-4SBJVRGM.mjs';
3
+ import { resolveBaseUrl, ApiClient } from './chunk-NC3GKHDD.mjs';
4
4
  import { writeAuth } from './chunk-JJYWETGA.mjs';
5
5
  import { CliError, CLI_ERROR_CODE, success, result, isJsonMode, step, info, dim } from './chunk-NZ4RG62Z.mjs';
6
6
  import os from 'os';
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
- import { TERMINAL_DEPLOYMENT_STATUSES } from './chunk-VE74N3YS.mjs';
3
- import { parseArgs, flagString, flagBool } from './chunk-BXM4AWJQ.mjs';
4
- import { ApiClient } from './chunk-4ZVTPMUZ.mjs';
2
+ import { TERMINAL_DEPLOYMENT_STATUSES } from './chunk-MXYUAJEW.mjs';
3
+ import { parseArgs, flagString, flagBool } from './chunk-4SBJVRGM.mjs';
4
+ import { ApiClient } from './chunk-NC3GKHDD.mjs';
5
5
  import { readAuth, readProjectLink, readProjectState } from './chunk-JJYWETGA.mjs';
6
6
  import { CliError, CLI_ERROR_CODE, isJsonMode, failure, result, red } from './chunk-NZ4RG62Z.mjs';
7
7
 
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
- import { REPO_PROVIDER } from './chunk-VE74N3YS.mjs';
3
- import { parseArgs, flagString, flagBool } from './chunk-BXM4AWJQ.mjs';
4
- import { ApiClient } from './chunk-4ZVTPMUZ.mjs';
2
+ import { REPO_PROVIDER } from './chunk-MXYUAJEW.mjs';
3
+ import { parseArgs, flagString, flagBool } from './chunk-4SBJVRGM.mjs';
4
+ import { ApiClient } from './chunk-NC3GKHDD.mjs';
5
5
  import { readAuth } from './chunk-JJYWETGA.mjs';
6
6
  import { CliError, CLI_ERROR_CODE, info, dim, result, bold, success } from './chunk-NZ4RG62Z.mjs';
7
7
 
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env node
2
+ export { run as default, fetchCloneToken } from './chunk-2Y4JWLPE.mjs';
3
+ import './chunk-L6474RPL.mjs';
4
+ import './chunk-MXYUAJEW.mjs';
5
+ import './chunk-4SBJVRGM.mjs';
6
+ import './chunk-NC3GKHDD.mjs';
7
+ import './chunk-JJYWETGA.mjs';
8
+ import './chunk-NZ4RG62Z.mjs';
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
- import { pollDeployment } from './chunk-2BO4H6VP.mjs';
3
- import { DEPLOYMENT_STATUS, DEPLOY_TRIGGER } from './chunk-VE74N3YS.mjs';
4
- import { parseArgs, flagBool } from './chunk-BXM4AWJQ.mjs';
5
- import { ApiClient } from './chunk-4ZVTPMUZ.mjs';
2
+ import { pollDeployment } from './chunk-JOUXICGV.mjs';
3
+ import { DEPLOYMENT_STATUS, DEPLOY_TRIGGER } from './chunk-MXYUAJEW.mjs';
4
+ import { parseArgs, flagBool } from './chunk-4SBJVRGM.mjs';
5
+ import { ApiClient } from './chunk-NC3GKHDD.mjs';
6
6
  import { readAuth, readProjectLink, writeProjectState } from './chunk-JJYWETGA.mjs';
7
7
  import { CliError, CLI_ERROR_CODE, step, success, info, dim, result, EXIT_CODE } from './chunk-NZ4RG62Z.mjs';
8
8
 
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
- import { DEPLOYMENT_STATUS } from './chunk-VE74N3YS.mjs';
3
- import { parseArgs } from './chunk-BXM4AWJQ.mjs';
4
- import { ApiClient } from './chunk-4ZVTPMUZ.mjs';
2
+ import { DEPLOYMENT_STATUS } from './chunk-MXYUAJEW.mjs';
3
+ import { parseArgs } from './chunk-4SBJVRGM.mjs';
4
+ import { ApiClient } from './chunk-NC3GKHDD.mjs';
5
5
  import { readAuth, readProjectLink, readProjectState } from './chunk-JJYWETGA.mjs';
6
6
  import { bold, dim, info, result } from './chunk-NZ4RG62Z.mjs';
7
7
 
@@ -0,0 +1,196 @@
1
+ #!/usr/bin/env node
2
+ import { package_default } from './chunk-WTFQ3B5E.mjs';
3
+ import { promptYesNo } from './chunk-L6474RPL.mjs';
4
+ import { parseArgs, flagBool, flagString } from './chunk-4SBJVRGM.mjs';
5
+ import { success, bold, info, dim, result, failure, CliError, CLI_ERROR_CODE, step, isJsonMode } from './chunk-NZ4RG62Z.mjs';
6
+ import { spawn } from 'child_process';
7
+ import { basename, dirname } from 'path';
8
+
9
+ var CURRENT_VERSION = package_default.version ?? "unknown";
10
+ var INSTALL_URL = "https://cimplify.io/install";
11
+ var RELEASES_API = "https://api.github.com/repos/cimplifylabs/cli/releases/latest";
12
+ function detectContext() {
13
+ const exec = process.execPath;
14
+ const name = basename(exec).replace(/\.exe$/i, "");
15
+ if (name === "cimplify") {
16
+ return { isNative: true, prefix: dirname(dirname(exec)) };
17
+ }
18
+ return { isNative: false, runtime: name };
19
+ }
20
+ async function fetchLatestTag() {
21
+ let res;
22
+ try {
23
+ res = await fetch(RELEASES_API, {
24
+ headers: {
25
+ Accept: "application/vnd.github+json",
26
+ "User-Agent": `@cimplify/cli/${CURRENT_VERSION}`
27
+ }
28
+ });
29
+ } catch (err) {
30
+ throw new CliError(
31
+ CLI_ERROR_CODE.NETWORK_ERROR,
32
+ `GitHub releases request failed: ${err instanceof Error ? err.message : String(err)}`
33
+ );
34
+ }
35
+ if (!res.ok) {
36
+ throw new CliError(
37
+ CLI_ERROR_CODE.NETWORK_ERROR,
38
+ `GitHub releases query failed: ${res.status} ${res.statusText}`
39
+ );
40
+ }
41
+ const body = await res.json();
42
+ if (!body.tag_name) {
43
+ throw new CliError(
44
+ CLI_ERROR_CODE.NETWORK_ERROR,
45
+ "GitHub releases response missing tag_name"
46
+ );
47
+ }
48
+ return body.tag_name;
49
+ }
50
+ function stripTagPrefix(tag) {
51
+ return tag.replace(/^cli-v/, "");
52
+ }
53
+ function compareSemver(a, b) {
54
+ const parse = (v) => {
55
+ const [maj, min, patch] = v.split(/[.+-]/).slice(0, 3).map((p) => Number(p) || 0);
56
+ return [maj, min, patch];
57
+ };
58
+ const [a1, a2, a3] = parse(a);
59
+ const [b1, b2, b3] = parse(b);
60
+ if (a1 !== b1) return a1 < b1 ? -1 : 1;
61
+ if (a2 !== b2) return a2 < b2 ? -1 : 1;
62
+ if (a3 !== b3) return a3 < b3 ? -1 : 1;
63
+ return 0;
64
+ }
65
+ async function runInstall(prefix, versionTag) {
66
+ let scriptRes;
67
+ try {
68
+ scriptRes = await fetch(INSTALL_URL);
69
+ } catch (err) {
70
+ throw new CliError(
71
+ CLI_ERROR_CODE.NETWORK_ERROR,
72
+ `${INSTALL_URL} fetch failed: ${err instanceof Error ? err.message : String(err)}`
73
+ );
74
+ }
75
+ if (!scriptRes.ok) {
76
+ throw new CliError(
77
+ CLI_ERROR_CODE.NETWORK_ERROR,
78
+ `${INSTALL_URL} returned ${scriptRes.status} ${scriptRes.statusText}`
79
+ );
80
+ }
81
+ const script = await scriptRes.text();
82
+ const installArgs = ["-s", "--", "--prefix", prefix, "--version", versionTag];
83
+ const json = isJsonMode();
84
+ const stdoutSink = json ? "pipe" : "inherit";
85
+ const stderrSink = json ? "pipe" : "inherit";
86
+ await new Promise((resolve, reject) => {
87
+ const child = spawn("sh", installArgs, {
88
+ stdio: ["pipe", stdoutSink, stderrSink]
89
+ });
90
+ let captured = "";
91
+ if (json) {
92
+ child.stdout?.on("data", (chunk) => {
93
+ captured += chunk.toString();
94
+ });
95
+ child.stderr?.on("data", (chunk) => {
96
+ captured += chunk.toString();
97
+ });
98
+ }
99
+ if (!child.stdin) {
100
+ reject(new CliError(CLI_ERROR_CODE.INVALID_INPUT, "installer child has no stdin"));
101
+ return;
102
+ }
103
+ child.stdin.write(script);
104
+ child.stdin.end();
105
+ child.on("error", (err) => reject(err));
106
+ child.on("exit", (code) => {
107
+ if (code === 0) resolve();
108
+ else {
109
+ const detail = json && captured ? `
110
+ ${captured.trim()}` : "";
111
+ reject(
112
+ new CliError(
113
+ CLI_ERROR_CODE.INVALID_INPUT,
114
+ `installer exited with code ${code ?? "null"}${detail}`,
115
+ {
116
+ remediation: "Re-run without --json to see live installer output, or with --prefix <writable-path>."
117
+ }
118
+ )
119
+ );
120
+ }
121
+ });
122
+ });
123
+ }
124
+ async function run(argv) {
125
+ const args = parseArgs(argv);
126
+ const check = flagBool(args, "check");
127
+ const targetVersion = flagString(args, "version");
128
+ const prefixOverride = flagString(args, "prefix");
129
+ const ctx = detectContext();
130
+ const latestTag = await fetchLatestTag();
131
+ const latestVersion = stripTagPrefix(latestTag);
132
+ const cmp = compareSemver(CURRENT_VERSION, latestVersion);
133
+ const upToDate = cmp >= 0;
134
+ if (check) {
135
+ if (upToDate) {
136
+ success(`Already on latest: ${bold(CURRENT_VERSION)}`);
137
+ } else {
138
+ info(
139
+ `Update available: ${dim(CURRENT_VERSION)} \u2192 ${bold(latestVersion)} (${latestTag})`
140
+ );
141
+ }
142
+ result({
143
+ current: CURRENT_VERSION,
144
+ latest: latestVersion,
145
+ latest_tag: latestTag,
146
+ up_to_date: upToDate
147
+ });
148
+ return;
149
+ }
150
+ if (!ctx.isNative) {
151
+ failure(
152
+ `cimplify update only updates the native binary; this process is running under ${ctx.runtime}.`
153
+ );
154
+ info(" \u2192 Native install: `curl -fsSL https://cimplify.io/install | sh`");
155
+ info(` \u2192 Or npm install: \`npm i -g @cimplify/cli@${latestVersion}\``);
156
+ throw new CliError(
157
+ CLI_ERROR_CODE.INVALID_INPUT,
158
+ "self-update unsupported under non-native runtime",
159
+ {
160
+ remediation: "Reinstall via cimplify.io/install or your package manager (npm / bun / pnpm)."
161
+ }
162
+ );
163
+ }
164
+ if (upToDate && !targetVersion) {
165
+ success(`Already on latest: ${bold(CURRENT_VERSION)}`);
166
+ result({
167
+ current: CURRENT_VERSION,
168
+ latest: latestVersion,
169
+ latest_tag: latestTag,
170
+ updated: false
171
+ });
172
+ return;
173
+ }
174
+ const versionTag = targetVersion ?? latestTag;
175
+ const prefix = prefixOverride ?? ctx.prefix;
176
+ const targetVer = stripTagPrefix(versionTag);
177
+ info(
178
+ `Updating ${bold("cimplify")}: ${dim(CURRENT_VERSION)} \u2192 ${bold(targetVer)} (${versionTag})`
179
+ );
180
+ info(` prefix: ${dim(prefix)}`);
181
+ const ok = await promptYesNo("Proceed?", true);
182
+ if (!ok) throw new CliError(CLI_ERROR_CODE.ABORTED, "Aborted by user.");
183
+ step("Downloading + verifying\u2026");
184
+ await runInstall(prefix, versionTag);
185
+ success(`Updated to ${targetVer}`);
186
+ result({
187
+ current: CURRENT_VERSION,
188
+ latest: latestVersion,
189
+ latest_tag: latestTag,
190
+ updated: true,
191
+ installed: targetVer,
192
+ prefix
193
+ });
194
+ }
195
+
196
+ export { run as default };
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { ApiClient } from './chunk-4ZVTPMUZ.mjs';
2
+ import { ApiClient } from './chunk-NC3GKHDD.mjs';
3
3
  import { readAuth } from './chunk-JJYWETGA.mjs';
4
4
  import { info, bold, dim, result } from './chunk-NZ4RG62Z.mjs';
5
5
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cimplify/cli",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "Cimplify CLI — deploy, manage env vars, link projects, and scaffold storefronts",
5
5
  "keywords": [
6
6
  "cimplify",
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env node
2
- export { run as default, fetchCloneToken } from './chunk-27QJ5JQI.mjs';
3
- import './chunk-L6474RPL.mjs';
4
- import './chunk-VE74N3YS.mjs';
5
- import './chunk-BXM4AWJQ.mjs';
6
- import './chunk-4ZVTPMUZ.mjs';
7
- import './chunk-JJYWETGA.mjs';
8
- import './chunk-NZ4RG62Z.mjs';