@cimplify/cli 0.3.0 → 0.4.0
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-ZJNXWN2B.mjs → add-KKIYBATR.mjs} +3 -3
- package/dist/{assets-DMK2QOPD.mjs → assets-EBEMMENZ.mjs} +3 -3
- package/dist/auth-step-up-BIUYQJP6.mjs +82 -0
- package/dist/chunk-42PFJBC6.mjs +5707 -0
- package/dist/{chunk-YQVMG62Z.mjs → chunk-ASZVWVMM.mjs} +1 -1
- package/dist/{chunk-YI7UMMM7.mjs → chunk-DBZ3UOQ2.mjs} +1 -1
- package/dist/{chunk-I3XQSSOT.mjs → chunk-E2T2SBP5.mjs} +6 -2
- package/dist/{login-WSAW4BEA.mjs → chunk-GLXONXS3.mjs} +10 -132
- package/dist/{chunk-RZQTHTXX.mjs → chunk-ITAFAORS.mjs} +1 -1
- package/dist/{chunk-RRY3NEZZ.mjs → chunk-K5464A3L.mjs} +1 -1
- package/dist/{chunk-D7WMSGKK.mjs → chunk-MAOO6ZZ5.mjs} +22 -3
- package/dist/{chunk-QGBXGDA5.mjs → chunk-R3FDBXR6.mjs} +4 -4
- package/dist/{chunk-5IAYN7AJ.mjs → chunk-SDSOORT6.mjs} +5 -5
- package/dist/{chunk-LS2VTSMQ.mjs → chunk-UBAI443T.mjs} +9 -2
- package/dist/{chunk-MOZQODQS.mjs → chunk-VTR5R5NQ.mjs} +1 -1
- package/dist/{deploy-UKOOPJAE.mjs → deploy-3IFXUWPM.mjs} +7 -7
- package/dist/{dev-FD4PM3UD.mjs → dev-ONW2S77K.mjs} +4 -4
- package/dist/dispatcher.mjs +39 -26
- package/dist/{doctor-5LBLYT7M.mjs → doctor-BC6CMVRW.mjs} +8 -8
- package/dist/{domains-JQMV6GAP.mjs → domains-AHH56CL7.mjs} +4 -4
- package/dist/{env-EVMYQUIK.mjs → env-7ISJ73YI.mjs} +5 -5
- package/dist/{explain-3KBMWL6M.mjs → explain-MZOCDFZE.mjs} +2 -2
- package/dist/introspect-IVI65FEV.mjs +8 -0
- package/dist/{link-X3E4UZBF.mjs → link-DZSILT5N.mjs} +3 -3
- package/dist/{list-TE54SJIB.mjs → list-JOQRPYX4.mjs} +2 -2
- package/dist/login-3OD4ND2H.mjs +153 -0
- package/dist/{logout-DJDINVDF.mjs → logout-3RLBZ33M.mjs} +2 -2
- package/dist/{logs-KUKGEXR2.mjs → logs-YNN2PQ24.mjs} +3 -3
- package/dist/{projects-364HGWHO.mjs → projects-JSEC2YCX.mjs} +3 -3
- package/dist/repo-WOBWKEAO.mjs +8 -0
- package/dist/{rollback-5YALPQXL.mjs → rollback-DD4RNRFM.mjs} +4 -4
- package/dist/{status-W4HW3CX3.mjs → status-JSYXM5RT.mjs} +3 -3
- package/dist/{unlink-HIIW57OO.mjs → unlink-RFK74SFP.mjs} +2 -2
- package/dist/{update-5MRKRVZC.mjs → update-EDTG73FK.mjs} +3 -3
- package/dist/{whoami-LACWBSNL.mjs → whoami-DNZ7RUTH.mjs} +3 -3
- package/package.json +1 -1
- package/dist/chunk-MHK4WVNF.mjs +0 -5707
- package/dist/introspect-PFBI3JHO.mjs +0 -8
- package/dist/repo-26N2CHF6.mjs +0 -8
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { generatePkcePair, generateState, startLoopbackServer, openBrowser } from './chunk-GLXONXS3.mjs';
|
|
3
|
+
import { parseArgs, flagString, flagBool } from './chunk-C4M3DXKC.mjs';
|
|
4
|
+
import { resolveBaseUrl, ApiClient } from './chunk-MAOO6ZZ5.mjs';
|
|
5
|
+
import { writeAuth } from './chunk-UBAI443T.mjs';
|
|
6
|
+
import { CliError, CLI_ERROR_CODE, success, result, isJsonMode, step, info, dim } from './chunk-E2T2SBP5.mjs';
|
|
7
|
+
import os from 'os';
|
|
8
|
+
|
|
9
|
+
var FLAG_API_KEY = "api-key";
|
|
10
|
+
var FLAG_BASE_URL = "base-url";
|
|
11
|
+
var FLAG_NO_BROWSER = "no-browser";
|
|
12
|
+
var FLAG_SCOPE = "scope";
|
|
13
|
+
var VALID_CLI_SCOPES = /* @__PURE__ */ new Set([
|
|
14
|
+
"cli:read",
|
|
15
|
+
"cli:write",
|
|
16
|
+
"cli:deploy",
|
|
17
|
+
"cli:admin"
|
|
18
|
+
]);
|
|
19
|
+
var ENDPOINT_AUTH_ME = "/v1/auth/me";
|
|
20
|
+
var ENDPOINT_CLI_START = "/v1/auth/cli/start";
|
|
21
|
+
var ENDPOINT_CLI_TOKEN = "/v1/auth/cli/token";
|
|
22
|
+
var KEY_PREFIX_CAK = "cak_";
|
|
23
|
+
var KEY_PREFIX_CSK = "csk_";
|
|
24
|
+
var PRODUCT_NAME = "cimplify-cli";
|
|
25
|
+
async function run(argv) {
|
|
26
|
+
const args = parseArgs(argv);
|
|
27
|
+
const baseUrl = resolveBaseUrl(flagString(args, FLAG_BASE_URL));
|
|
28
|
+
const explicitKey = flagString(args, FLAG_API_KEY);
|
|
29
|
+
if (explicitKey) {
|
|
30
|
+
await loginWithKey(baseUrl, explicitKey);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const scopes = parseScopeFlag(flagString(args, FLAG_SCOPE));
|
|
34
|
+
await loginWithBrowser(baseUrl, flagBool(args, FLAG_NO_BROWSER), scopes);
|
|
35
|
+
}
|
|
36
|
+
function parseScopeFlag(raw) {
|
|
37
|
+
if (!raw) return [];
|
|
38
|
+
const items = raw.split(",").map((s) => s.trim()).filter(Boolean);
|
|
39
|
+
for (const s of items) {
|
|
40
|
+
if (!VALID_CLI_SCOPES.has(s)) {
|
|
41
|
+
throw new CliError(
|
|
42
|
+
CLI_ERROR_CODE.INVALID_INPUT,
|
|
43
|
+
`Unknown scope "${s}". Valid: ${Array.from(VALID_CLI_SCOPES).join(", ")}.`
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return items;
|
|
48
|
+
}
|
|
49
|
+
async function loginWithKey(baseUrl, apiKey) {
|
|
50
|
+
if (!apiKey.startsWith(KEY_PREFIX_CAK) && !apiKey.startsWith(KEY_PREFIX_CSK)) {
|
|
51
|
+
throw new CliError(
|
|
52
|
+
CLI_ERROR_CODE.INVALID_INPUT,
|
|
53
|
+
`API key must start with "${KEY_PREFIX_CAK}" or "${KEY_PREFIX_CSK}".`
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
const client = ApiClient.withKey(apiKey, baseUrl);
|
|
57
|
+
const me = await client.get(ENDPOINT_AUTH_ME);
|
|
58
|
+
await writeAuth({
|
|
59
|
+
apiKey,
|
|
60
|
+
apiBaseUrl: baseUrl,
|
|
61
|
+
accountId: me.id,
|
|
62
|
+
businessId: me.business_id,
|
|
63
|
+
email: me.email,
|
|
64
|
+
name: me.name,
|
|
65
|
+
savedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
66
|
+
});
|
|
67
|
+
success(`Logged in as ${me.email ?? me.name ?? me.id} (business ${me.business_id})`);
|
|
68
|
+
result({
|
|
69
|
+
logged_in: true,
|
|
70
|
+
account: { id: me.id, email: me.email ?? null, name: me.name ?? null },
|
|
71
|
+
business: { id: me.business_id },
|
|
72
|
+
method: "api_key"
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
async function loginWithBrowser(baseUrl, noBrowser, requestedScopes) {
|
|
76
|
+
if (isJsonMode()) {
|
|
77
|
+
throw new CliError(
|
|
78
|
+
CLI_ERROR_CODE.INTERACTIVE_REQUIRED,
|
|
79
|
+
"browser login is not supported in --json mode",
|
|
80
|
+
{ remediation: "pass --api-key dk_\u2026 (create one in the dashboard or via `cimplify auth keys create`)" }
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
const pkce = generatePkcePair();
|
|
84
|
+
const state = generateState();
|
|
85
|
+
const loopback = await startLoopbackServer(baseUrl);
|
|
86
|
+
const startBody = {
|
|
87
|
+
code_challenge: pkce.codeChallenge,
|
|
88
|
+
code_challenge_method: pkce.codeChallengeMethod,
|
|
89
|
+
redirect_uri: loopback.redirectUri,
|
|
90
|
+
state,
|
|
91
|
+
client_meta: {
|
|
92
|
+
hostname: os.hostname(),
|
|
93
|
+
platform: process.platform,
|
|
94
|
+
arch: process.arch,
|
|
95
|
+
node_version: process.version,
|
|
96
|
+
product: PRODUCT_NAME
|
|
97
|
+
},
|
|
98
|
+
requested_scopes: requestedScopes
|
|
99
|
+
};
|
|
100
|
+
const unauthClient = ApiClient.unauthenticated(baseUrl);
|
|
101
|
+
const startResponse = await unauthClient.post(
|
|
102
|
+
ENDPOINT_CLI_START,
|
|
103
|
+
startBody
|
|
104
|
+
);
|
|
105
|
+
step("Opening browser to authorize this CLI...");
|
|
106
|
+
info(dim(startResponse.approval_url));
|
|
107
|
+
if (!noBrowser) {
|
|
108
|
+
openBrowser(startResponse.approval_url);
|
|
109
|
+
} else {
|
|
110
|
+
info("");
|
|
111
|
+
info(dim("Open the URL above in any browser to continue."));
|
|
112
|
+
}
|
|
113
|
+
let callback;
|
|
114
|
+
try {
|
|
115
|
+
callback = await loopback.awaitCallback(startResponse.expires_in_secs * 1e3);
|
|
116
|
+
} catch (err) {
|
|
117
|
+
loopback.close();
|
|
118
|
+
throw err;
|
|
119
|
+
}
|
|
120
|
+
if (callback.state !== state) {
|
|
121
|
+
throw new CliError(
|
|
122
|
+
CLI_ERROR_CODE.UNAUTHORIZED,
|
|
123
|
+
"OAuth state mismatch. Possible CSRF attempt \u2014 try again."
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
if (!callback.code) {
|
|
127
|
+
throw new CliError(
|
|
128
|
+
CLI_ERROR_CODE.UNAUTHORIZED,
|
|
129
|
+
"Login callback missing auth_code."
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
const token = await unauthClient.post(ENDPOINT_CLI_TOKEN, {
|
|
133
|
+
auth_code: callback.code,
|
|
134
|
+
code_verifier: pkce.codeVerifier,
|
|
135
|
+
redirect_uri: loopback.redirectUri
|
|
136
|
+
});
|
|
137
|
+
await writeAuth({
|
|
138
|
+
apiKey: token.access_token,
|
|
139
|
+
apiBaseUrl: baseUrl,
|
|
140
|
+
accountId: token.account_id,
|
|
141
|
+
businessId: token.business_id,
|
|
142
|
+
savedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
143
|
+
});
|
|
144
|
+
success(`Logged in (business ${token.business_id})`);
|
|
145
|
+
result({
|
|
146
|
+
logged_in: true,
|
|
147
|
+
account: { id: token.account_id, email: null, name: null },
|
|
148
|
+
business: { id: token.business_id },
|
|
149
|
+
method: "oauth_pkce"
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export { run as default };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { clearAuth } from './chunk-
|
|
3
|
-
import { success, info, result } from './chunk-
|
|
2
|
+
import { clearAuth } from './chunk-UBAI443T.mjs';
|
|
3
|
+
import { success, info, result } from './chunk-E2T2SBP5.mjs';
|
|
4
4
|
|
|
5
5
|
// src/commands/logout.ts
|
|
6
6
|
async function run(_argv) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { TERMINAL_DEPLOYMENT_STATUSES } from './chunk-MXYUAJEW.mjs';
|
|
3
3
|
import { parseArgs, flagString, flagBool } from './chunk-C4M3DXKC.mjs';
|
|
4
|
-
import { ApiClient } from './chunk-
|
|
5
|
-
import { readAuth, readProjectLink, readProjectState } from './chunk-
|
|
6
|
-
import { CliError, CLI_ERROR_CODE, isJsonMode, failure, result, red } from './chunk-
|
|
4
|
+
import { ApiClient } from './chunk-MAOO6ZZ5.mjs';
|
|
5
|
+
import { readAuth, readProjectLink, readProjectState } from './chunk-UBAI443T.mjs';
|
|
6
|
+
import { CliError, CLI_ERROR_CODE, isJsonMode, failure, result, red } from './chunk-E2T2SBP5.mjs';
|
|
7
7
|
|
|
8
8
|
// src/commands/logs.ts
|
|
9
9
|
var FLAG_DEPLOYMENT = "deployment";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { REPO_PROVIDER } from './chunk-MXYUAJEW.mjs';
|
|
3
3
|
import { parseArgs, flagString, flagBool } from './chunk-C4M3DXKC.mjs';
|
|
4
|
-
import { ApiClient } from './chunk-
|
|
5
|
-
import { readAuth } from './chunk-
|
|
6
|
-
import { CliError, CLI_ERROR_CODE, info, dim, result, bold, success } from './chunk-
|
|
4
|
+
import { ApiClient } from './chunk-MAOO6ZZ5.mjs';
|
|
5
|
+
import { readAuth } from './chunk-UBAI443T.mjs';
|
|
6
|
+
import { CliError, CLI_ERROR_CODE, info, dim, result, bold, success } from './chunk-E2T2SBP5.mjs';
|
|
7
7
|
|
|
8
8
|
// src/commands/projects.ts
|
|
9
9
|
var SUB_LS = "ls";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
export { run as default, fetchCloneToken } from './chunk-R3FDBXR6.mjs';
|
|
3
|
+
import './chunk-ITAFAORS.mjs';
|
|
4
|
+
import './chunk-MXYUAJEW.mjs';
|
|
5
|
+
import './chunk-C4M3DXKC.mjs';
|
|
6
|
+
import './chunk-MAOO6ZZ5.mjs';
|
|
7
|
+
import './chunk-UBAI443T.mjs';
|
|
8
|
+
import './chunk-E2T2SBP5.mjs';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { pollDeployment } from './chunk-
|
|
2
|
+
import { pollDeployment } from './chunk-VTR5R5NQ.mjs';
|
|
3
3
|
import { DEPLOYMENT_STATUS, DEPLOY_TRIGGER } from './chunk-MXYUAJEW.mjs';
|
|
4
4
|
import { parseArgs, flagBool } from './chunk-C4M3DXKC.mjs';
|
|
5
|
-
import { ApiClient } from './chunk-
|
|
6
|
-
import { readAuth, readProjectLink, writeProjectState } from './chunk-
|
|
7
|
-
import { CliError, CLI_ERROR_CODE, step, success, info, dim, result, EXIT_CODE } from './chunk-
|
|
5
|
+
import { ApiClient } from './chunk-MAOO6ZZ5.mjs';
|
|
6
|
+
import { readAuth, readProjectLink, writeProjectState } from './chunk-UBAI443T.mjs';
|
|
7
|
+
import { CliError, CLI_ERROR_CODE, step, success, info, dim, result, EXIT_CODE } from './chunk-E2T2SBP5.mjs';
|
|
8
8
|
|
|
9
9
|
// src/commands/rollback.ts
|
|
10
10
|
var FLAG_NO_POLL = "no-poll";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { DEPLOYMENT_STATUS } from './chunk-MXYUAJEW.mjs';
|
|
3
3
|
import { parseArgs } from './chunk-C4M3DXKC.mjs';
|
|
4
|
-
import { ApiClient } from './chunk-
|
|
5
|
-
import { readAuth, readProjectLink, readProjectState } from './chunk-
|
|
6
|
-
import { bold, dim, info, result } from './chunk-
|
|
4
|
+
import { ApiClient } from './chunk-MAOO6ZZ5.mjs';
|
|
5
|
+
import { readAuth, readProjectLink, readProjectState } from './chunk-UBAI443T.mjs';
|
|
6
|
+
import { bold, dim, info, result } from './chunk-E2T2SBP5.mjs';
|
|
7
7
|
|
|
8
8
|
// src/commands/status.ts
|
|
9
9
|
var QUERY_LIMIT = "limit";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { clearProjectLink } from './chunk-
|
|
3
|
-
import { success, info, result } from './chunk-
|
|
2
|
+
import { clearProjectLink } from './chunk-UBAI443T.mjs';
|
|
3
|
+
import { success, info, result } from './chunk-E2T2SBP5.mjs';
|
|
4
4
|
|
|
5
5
|
// src/commands/unlink.ts
|
|
6
6
|
async function run(_argv) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { package_default } from './chunk-
|
|
3
|
-
import { promptYesNo } from './chunk-
|
|
2
|
+
import { package_default } from './chunk-ASZVWVMM.mjs';
|
|
3
|
+
import { promptYesNo } from './chunk-ITAFAORS.mjs';
|
|
4
4
|
import { parseArgs, flagBool, flagString } from './chunk-C4M3DXKC.mjs';
|
|
5
|
-
import { success, bold, info, dim, result, failure, CliError, CLI_ERROR_CODE, step, isJsonMode } from './chunk-
|
|
5
|
+
import { success, bold, info, dim, result, failure, CliError, CLI_ERROR_CODE, step, isJsonMode } from './chunk-E2T2SBP5.mjs';
|
|
6
6
|
import { spawn } from 'child_process';
|
|
7
7
|
import { basename, dirname } from 'path';
|
|
8
8
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { ApiClient } from './chunk-
|
|
3
|
-
import { readAuth } from './chunk-
|
|
4
|
-
import { info, bold, dim, result } from './chunk-
|
|
2
|
+
import { ApiClient } from './chunk-MAOO6ZZ5.mjs';
|
|
3
|
+
import { readAuth } from './chunk-UBAI443T.mjs';
|
|
4
|
+
import { info, bold, dim, result } from './chunk-E2T2SBP5.mjs';
|
|
5
5
|
|
|
6
6
|
// src/commands/whoami.ts
|
|
7
7
|
var ENDPOINT_AUTH_ME = "/v1/auth/me";
|