@cimplify/cli 0.2.1 → 0.2.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.
- package/dist/{add-FP4UGVGE.mjs → add-YJDP63WM.mjs} +1 -1
- package/dist/{chunk-BXM4AWJQ.mjs → chunk-4SBJVRGM.mjs} +2 -0
- package/dist/chunk-O36TGF2L.mjs +48 -0
- package/dist/{chunk-27QJ5JQI.mjs → chunk-WLLH5HFI.mjs} +1 -1
- package/dist/{deploy-UAPJ35KZ.mjs → deploy-N3GTTUI5.mjs} +2 -2
- package/dist/{dev-OPKFS77L.mjs → dev-ABPRBTPU.mjs} +1 -1
- package/dist/dispatcher.mjs +23 -18
- package/dist/{domains-INY76L24.mjs → domains-7Y23SAEM.mjs} +1 -1
- package/dist/{env-CMNNPAA4.mjs → env-H6M4G4V6.mjs} +1 -1
- package/dist/{link-PDITLRI4.mjs → link-QPWA5Q6Z.mjs} +1 -1
- package/dist/{list-MUARZ6RW.mjs → list-DS4C3JRB.mjs} +1 -1
- package/dist/{login-4OB5ZIR4.mjs → login-JFDAQ7T5.mjs} +1 -1
- package/dist/{logs-VQCYRAHN.mjs → logs-EABEQBEV.mjs} +1 -1
- package/dist/{projects-KBFX4Q3E.mjs → projects-L7JEO3KO.mjs} +1 -1
- package/dist/{repo-J5LZOBZZ.mjs → repo-54HUIBFC.mjs} +2 -2
- package/dist/{rollback-Z74AP6PL.mjs → rollback-YTKRECZ5.mjs} +1 -1
- package/dist/{status-BYHS4SG3.mjs → status-IFJIYWRQ.mjs} +1 -1
- package/dist/update-UH2HKLOK.mjs +196 -0
- package/package.json +1 -1
|
@@ -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-
|
|
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';
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// package.json
|
|
3
|
+
var package_default = {
|
|
4
|
+
name: "@cimplify/cli",
|
|
5
|
+
version: "0.2.2",
|
|
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,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { promptYesNo } from './chunk-L6474RPL.mjs';
|
|
3
3
|
import { TOKEN_PURPOSE, REPO_PROVIDER, REPO_PROVIDER_VALUES } from './chunk-VE74N3YS.mjs';
|
|
4
|
-
import { parseArgs, flagString, flagBool } from './chunk-
|
|
4
|
+
import { parseArgs, flagString, flagBool } from './chunk-4SBJVRGM.mjs';
|
|
5
5
|
import { ApiClient } from './chunk-4ZVTPMUZ.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';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { pollDeployment } from './chunk-2BO4H6VP.mjs';
|
|
3
|
-
import { fetchCloneToken } from './chunk-
|
|
3
|
+
import { fetchCloneToken } from './chunk-WLLH5HFI.mjs';
|
|
4
4
|
import { promptYesNo } from './chunk-L6474RPL.mjs';
|
|
5
5
|
import { TOKEN_PURPOSE, ENV_SCOPE, DEPLOY_TRIGGER, DEPLOYMENT_STATUS } from './chunk-VE74N3YS.mjs';
|
|
6
|
-
import { parseArgs, flagBool, flagString } from './chunk-
|
|
6
|
+
import { parseArgs, flagBool, flagString } from './chunk-4SBJVRGM.mjs';
|
|
7
7
|
import { ApiClient } from './chunk-4ZVTPMUZ.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';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { parseEnvFile, formatEnvFile } from './chunk-4YSOZ6LY.mjs';
|
|
3
3
|
import { ENV_SCOPE, PUBLIC_ENV_PREFIX } from './chunk-VE74N3YS.mjs';
|
|
4
|
-
import { parseArgs, flagBool } from './chunk-
|
|
4
|
+
import { parseArgs, flagBool } from './chunk-4SBJVRGM.mjs';
|
|
5
5
|
import { ApiClient } from './chunk-4ZVTPMUZ.mjs';
|
|
6
6
|
import { readAuth, readProjectLink } from './chunk-JJYWETGA.mjs';
|
|
7
7
|
import { info, CliError, CLI_ERROR_CODE, dim } from './chunk-NZ4RG62Z.mjs';
|
package/dist/dispatcher.mjs
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { package_default } from './chunk-O36TGF2L.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-
|
|
118
|
+
login: () => import('./login-JFDAQ7T5.mjs'),
|
|
116
119
|
logout: () => import('./logout-ZFZLSJ32.mjs'),
|
|
117
120
|
whoami: () => import('./whoami-INHDUHWA.mjs'),
|
|
118
|
-
projects: () => import('./projects-
|
|
119
|
-
link: () => import('./link-
|
|
121
|
+
projects: () => import('./projects-L7JEO3KO.mjs'),
|
|
122
|
+
link: () => import('./link-QPWA5Q6Z.mjs'),
|
|
120
123
|
unlink: () => import('./unlink-5ABCT7B6.mjs'),
|
|
121
|
-
deploy: () => import('./deploy-
|
|
122
|
-
rollback: () => import('./rollback-
|
|
123
|
-
env: () => import('./env-
|
|
124
|
-
domains: () => import('./domains-
|
|
125
|
-
logs: () => import('./logs-
|
|
126
|
-
status: () => import('./status-
|
|
127
|
-
dev: () => import('./dev-
|
|
128
|
-
repo: () => import('./repo-
|
|
129
|
-
list: () => import('./list-
|
|
130
|
-
add: () => import('./add-
|
|
124
|
+
deploy: () => import('./deploy-N3GTTUI5.mjs'),
|
|
125
|
+
rollback: () => import('./rollback-YTKRECZ5.mjs'),
|
|
126
|
+
env: () => import('./env-H6M4G4V6.mjs'),
|
|
127
|
+
domains: () => import('./domains-7Y23SAEM.mjs'),
|
|
128
|
+
logs: () => import('./logs-EABEQBEV.mjs'),
|
|
129
|
+
status: () => import('./status-IFJIYWRQ.mjs'),
|
|
130
|
+
dev: () => import('./dev-ABPRBTPU.mjs'),
|
|
131
|
+
repo: () => import('./repo-54HUIBFC.mjs'),
|
|
132
|
+
list: () => import('./list-DS4C3JRB.mjs'),
|
|
133
|
+
add: () => import('./add-YJDP63WM.mjs'),
|
|
134
|
+
update: () => import('./update-UH2HKLOK.mjs'),
|
|
135
|
+
upgrade: () => import('./update-UH2HKLOK.mjs')
|
|
131
136
|
};
|
|
132
137
|
var GLOBAL_FLAGS = /* @__PURE__ */ new Set(["--json", "--yes", "-y"]);
|
|
133
138
|
function extractGlobalFlags(argv) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { promptYesNo } from './chunk-L6474RPL.mjs';
|
|
3
3
|
import { ENV_SCOPE, DOMAIN_TYPE } from './chunk-VE74N3YS.mjs';
|
|
4
|
-
import { parseArgs, flagBool, flagString } from './chunk-
|
|
4
|
+
import { parseArgs, flagBool, flagString } from './chunk-4SBJVRGM.mjs';
|
|
5
5
|
import { ApiClient } from './chunk-4ZVTPMUZ.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';
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { formatEnvFile, parseEnvFile, parseKeyValueArg } from './chunk-4YSOZ6LY.mjs';
|
|
3
3
|
import { promptYesNo } from './chunk-L6474RPL.mjs';
|
|
4
4
|
import { ENV_SCOPE, PUBLIC_ENV_PREFIX, SECRET_MASK } from './chunk-VE74N3YS.mjs';
|
|
5
|
-
import { parseArgs, flagString, flagBool } from './chunk-
|
|
5
|
+
import { parseArgs, flagString, flagBool } from './chunk-4SBJVRGM.mjs';
|
|
6
6
|
import { ApiClient } from './chunk-4ZVTPMUZ.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';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { parseArgs } from './chunk-
|
|
2
|
+
import { parseArgs } from './chunk-4SBJVRGM.mjs';
|
|
3
3
|
import { ApiClient } from './chunk-4ZVTPMUZ.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';
|
|
@@ -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-
|
|
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,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { parseArgs, flagString, flagBool } from './chunk-
|
|
2
|
+
import { parseArgs, flagString, flagBool } from './chunk-4SBJVRGM.mjs';
|
|
3
3
|
import { resolveBaseUrl, ApiClient } from './chunk-4ZVTPMUZ.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';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { TERMINAL_DEPLOYMENT_STATUSES } from './chunk-VE74N3YS.mjs';
|
|
3
|
-
import { parseArgs, flagString, flagBool } from './chunk-
|
|
3
|
+
import { parseArgs, flagString, flagBool } from './chunk-4SBJVRGM.mjs';
|
|
4
4
|
import { ApiClient } from './chunk-4ZVTPMUZ.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';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { REPO_PROVIDER } from './chunk-VE74N3YS.mjs';
|
|
3
|
-
import { parseArgs, flagString, flagBool } from './chunk-
|
|
3
|
+
import { parseArgs, flagString, flagBool } from './chunk-4SBJVRGM.mjs';
|
|
4
4
|
import { ApiClient } from './chunk-4ZVTPMUZ.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';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
export { run as default, fetchCloneToken } from './chunk-
|
|
2
|
+
export { run as default, fetchCloneToken } from './chunk-WLLH5HFI.mjs';
|
|
3
3
|
import './chunk-L6474RPL.mjs';
|
|
4
4
|
import './chunk-VE74N3YS.mjs';
|
|
5
|
-
import './chunk-
|
|
5
|
+
import './chunk-4SBJVRGM.mjs';
|
|
6
6
|
import './chunk-4ZVTPMUZ.mjs';
|
|
7
7
|
import './chunk-JJYWETGA.mjs';
|
|
8
8
|
import './chunk-NZ4RG62Z.mjs';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { pollDeployment } from './chunk-2BO4H6VP.mjs';
|
|
3
3
|
import { DEPLOYMENT_STATUS, DEPLOY_TRIGGER } from './chunk-VE74N3YS.mjs';
|
|
4
|
-
import { parseArgs, flagBool } from './chunk-
|
|
4
|
+
import { parseArgs, flagBool } from './chunk-4SBJVRGM.mjs';
|
|
5
5
|
import { ApiClient } from './chunk-4ZVTPMUZ.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';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { DEPLOYMENT_STATUS } from './chunk-VE74N3YS.mjs';
|
|
3
|
-
import { parseArgs } from './chunk-
|
|
3
|
+
import { parseArgs } from './chunk-4SBJVRGM.mjs';
|
|
4
4
|
import { ApiClient } from './chunk-4ZVTPMUZ.mjs';
|
|
5
5
|
import { readAuth, readProjectLink, readProjectState } from './chunk-JJYWETGA.mjs';
|
|
6
6
|
import { bold, dim, info, result } from './chunk-NZ4RG62Z.mjs';
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { package_default } from './chunk-O36TGF2L.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 };
|