@cimplify/cli 0.7.25 → 0.8.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.
Files changed (28) hide show
  1. package/dist/{add-DMA7USQR.mjs → add-TCU5T7Q2.mjs} +1 -1
  2. package/dist/{assets-74SK63TR.mjs → assets-EHRFAWZI.mjs} +1 -1
  3. package/dist/{auth-step-up-BIUYQJP6.mjs → auth-step-up-RWBXYJKR.mjs} +1 -1
  4. package/dist/{cancel-HANLRA6Q.mjs → cancel-DAO23NIX.mjs} +1 -1
  5. package/dist/{chunk-5SVTTTD2.mjs → chunk-7DOC7MLJ.mjs} +1 -1
  6. package/dist/{chunk-NUXKAEX5.mjs → chunk-BQ5CWVHQ.mjs} +1 -1
  7. package/dist/{chunk-MAOO6ZZ5.mjs → chunk-CV3ZFCX6.mjs} +33 -9
  8. package/dist/{chunk-CLNS2NBR.mjs → chunk-IV7SOUH3.mjs} +1 -1
  9. package/dist/{chunk-ML6JUUXS.mjs → chunk-MBLJKDCR.mjs} +1 -1
  10. package/dist/{deploy-YVCYHNSS.mjs → deploy-M63QHHOD.mjs} +2 -2
  11. package/dist/{dev-ONW2S77K.mjs → dev-VE6VVDEU.mjs} +1 -1
  12. package/dist/dispatcher.mjs +24 -24
  13. package/dist/{doctor-IOEKC6LJ.mjs → doctor-TBQN7ZSR.mjs} +3 -3
  14. package/dist/{domains-6GJASWJU.mjs → domains-7QM444PU.mjs} +1 -1
  15. package/dist/{env-7ISJ73YI.mjs → env-VKTOPGSZ.mjs} +1 -1
  16. package/dist/{explain-GBKONBB3.mjs → explain-LFL4IXXK.mjs} +1 -1
  17. package/dist/{introspect-PJ6SLINK.mjs → introspect-SHUBKCPY.mjs} +2 -2
  18. package/dist/{link-DZSILT5N.mjs → link-746RR2HY.mjs} +1 -1
  19. package/dist/{list-ZTKE2YVE.mjs → list-BVSFEBG7.mjs} +1 -1
  20. package/dist/{login-3OD4ND2H.mjs → login-EMJ33OD4.mjs} +31 -37
  21. package/dist/{logs-YNN2PQ24.mjs → logs-DSYUOYQJ.mjs} +1 -1
  22. package/dist/{projects-QSUWVTJZ.mjs → projects-QKI6CTCD.mjs} +1 -1
  23. package/dist/{repo-KNQMSPVV.mjs → repo-3BEDOFZX.mjs} +2 -2
  24. package/dist/{rollback-DD4RNRFM.mjs → rollback-ZR6X6IQ5.mjs} +1 -1
  25. package/dist/{status-JSYXM5RT.mjs → status-AIENVHAV.mjs} +1 -1
  26. package/dist/{update-BZ53TKVN.mjs → update-THXRRDNG.mjs} +1 -1
  27. package/dist/{whoami-DNZ7RUTH.mjs → whoami-LPQMPYTE.mjs} +1 -1
  28. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { REGISTRY_INDEX, REGISTRY } from './chunk-ML6JUUXS.mjs';
2
+ import { REGISTRY_INDEX, REGISTRY } from './chunk-MBLJKDCR.mjs';
3
3
  import { promptYesNo } from './chunk-ITAFAORS.mjs';
4
4
  import { parseArgs, flagString, flagBool } from './chunk-C4M3DXKC.mjs';
5
5
  import { CliError, CLI_ERROR_CODE, info, bold, dim, success, result, yellow } from './chunk-E2T2SBP5.mjs';
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { parseArgs, flagString, flagBool } from './chunk-C4M3DXKC.mjs';
3
- import { ApiClient } from './chunk-MAOO6ZZ5.mjs';
3
+ import { ApiClient } from './chunk-CV3ZFCX6.mjs';
4
4
  import { readAuth } from './chunk-UBAI443T.mjs';
5
5
  import { CliError, CLI_ERROR_CODE, step, yellow, dim, success, info, result, bold, green } from './chunk-E2T2SBP5.mjs';
6
6
  import { createHash } from 'crypto';
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { startLoopbackServer, generateState, openBrowser } from './chunk-GLXONXS3.mjs';
3
3
  import { parseArgs, flagString, flagBool } from './chunk-C4M3DXKC.mjs';
4
- import { resolveBaseUrl } from './chunk-MAOO6ZZ5.mjs';
4
+ import { resolveBaseUrl } from './chunk-CV3ZFCX6.mjs';
5
5
  import { readAuth, writeStepUp } from './chunk-UBAI443T.mjs';
6
6
  import { isJsonMode, CliError, CLI_ERROR_CODE, step, info, dim, success, result } from './chunk-E2T2SBP5.mjs';
7
7
 
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { parseArgs } from './chunk-C4M3DXKC.mjs';
3
- import { ApiClient } from './chunk-MAOO6ZZ5.mjs';
3
+ import { ApiClient } from './chunk-CV3ZFCX6.mjs';
4
4
  import { readAuth, readProjectLink } from './chunk-UBAI443T.mjs';
5
5
  import { CliError, CLI_ERROR_CODE, success, result } from './chunk-E2T2SBP5.mjs';
6
6
 
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { gitDetectRoot, gitCurrentBranch, gitCurrentSha, gitStatusPorcelain } from './chunk-K5464A3L.mjs';
3
3
  import { parseEnvFile } from './chunk-DBZ3UOQ2.mjs';
4
- import { package_default } from './chunk-NUXKAEX5.mjs';
4
+ import { package_default } from './chunk-BQ5CWVHQ.mjs';
5
5
  import { parseArgs } from './chunk-C4M3DXKC.mjs';
6
6
  import { readAuthOrNull, readProjectLinkOrNull, readProjectState } from './chunk-UBAI443T.mjs';
7
7
  import { bold, dim, yellow, green, info, result, red } from './chunk-E2T2SBP5.mjs';
@@ -2,7 +2,7 @@
2
2
  // package.json
3
3
  var package_default = {
4
4
  name: "@cimplify/cli",
5
- version: "0.7.25",
5
+ version: "0.8.0",
6
6
  description: "Cimplify CLI \u2014 deploy, manage env vars, link projects, and scaffold storefronts",
7
7
  keywords: [
8
8
  "cimplify",
@@ -28,7 +28,7 @@ var ApiClient = class _ApiClient {
28
28
  apiKey;
29
29
  stepUpToken = null;
30
30
  constructor(baseUrl, apiKey) {
31
- this.baseUrl = baseUrl.replace(/\/+$/, "");
31
+ this.baseUrl = upgradeInsecureUrl(baseUrl).replace(/\/+$/, "");
32
32
  this.apiKey = apiKey;
33
33
  }
34
34
  /** Attach a step-up JWT to subsequent requests via X-Step-Up-Authorization. */
@@ -85,14 +85,24 @@ var ApiClient = class _ApiClient {
85
85
  method,
86
86
  headers,
87
87
  body: payload,
88
- signal: controller.signal
88
+ signal: controller.signal,
89
+ // Don't follow redirects: fetch downgrades a redirected POST to GET and
90
+ // drops the body, which lands on a routeless GET and surfaces as a
91
+ // baffling "HTTP 404". Surface the redirect instead.
92
+ redirect: "manual"
89
93
  });
90
94
  } catch (err) {
91
95
  clearTimeout(timer);
92
96
  throw toNetworkError(err);
93
97
  }
94
98
  clearTimeout(timer);
95
- return parseResponse(response);
99
+ if (response.type === "opaqueredirect" || response.status >= 300 && response.status < 400) {
100
+ throw new CliError(
101
+ CLI_ERROR_CODE.NETWORK_ERROR,
102
+ `${method} ${url} was redirected. Point ${ENV_API_BASE_URL} (or --base-url) at ${DEFAULT_API_BASE_URL}.`
103
+ );
104
+ }
105
+ return parseResponse(response, method, url);
96
106
  }
97
107
  buildUrl(pathname, query) {
98
108
  const base = pathname.startsWith("/") ? pathname : `/${pathname}`;
@@ -107,11 +117,25 @@ var ApiClient = class _ApiClient {
107
117
  }
108
118
  };
109
119
  function resolveBaseUrl(override) {
110
- if (override && override.length > 0) return override;
120
+ if (override && override.length > 0) return upgradeInsecureUrl(override);
111
121
  const fromEnv = process.env[ENV_API_BASE_URL];
112
- return fromEnv && fromEnv.length > 0 ? fromEnv : DEFAULT_API_BASE_URL;
122
+ return upgradeInsecureUrl(fromEnv && fromEnv.length > 0 ? fromEnv : DEFAULT_API_BASE_URL);
123
+ }
124
+ var LOCAL_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "0.0.0.0", "::1"]);
125
+ function upgradeInsecureUrl(raw) {
126
+ let url;
127
+ try {
128
+ url = new URL(raw);
129
+ } catch {
130
+ return raw;
131
+ }
132
+ if (url.protocol === "http:" && !LOCAL_HOSTS.has(url.hostname) && !url.hostname.endsWith(".local")) {
133
+ url.protocol = "https:";
134
+ return url.toString();
135
+ }
136
+ return raw;
113
137
  }
114
- async function parseResponse(response) {
138
+ async function parseResponse(response, method, url) {
115
139
  const text = await response.text();
116
140
  let body = void 0;
117
141
  if (text.length > 0) {
@@ -131,7 +155,7 @@ async function parseResponse(response) {
131
155
  return body;
132
156
  }
133
157
  const code = mapStatusToCode(response.status);
134
- const message = extractErrorMessage(body, response.status);
158
+ const message = extractErrorMessage(body, response.status, method, url);
135
159
  if (response.status === STATUS_UNAUTHORIZED && /step_up_required/i.test(message)) {
136
160
  throw new CliError(
137
161
  CLI_ERROR_CODE.STEP_UP_REQUIRED,
@@ -150,7 +174,7 @@ function mapStatusToCode(status) {
150
174
  if (status >= STATUS_BAD_REQUEST_MIN) return CLI_ERROR_CODE.INVALID_INPUT;
151
175
  return CLI_ERROR_CODE.SERVER_ERROR;
152
176
  }
153
- function extractErrorMessage(body, status) {
177
+ function extractErrorMessage(body, status, method, url) {
154
178
  if (body && typeof body === "object") {
155
179
  const envelope = body;
156
180
  if (envelope.error && typeof envelope.error.error_message === "string") {
@@ -158,7 +182,7 @@ function extractErrorMessage(body, status) {
158
182
  }
159
183
  if (typeof envelope.message === "string") return envelope.message;
160
184
  }
161
- return `HTTP ${status}`;
185
+ return `HTTP ${status} from ${method} ${url}`;
162
186
  }
163
187
  function toNetworkError(err) {
164
188
  if (err instanceof DOMException && err.name === "AbortError") {
@@ -2,7 +2,7 @@
2
2
  import { promptYesNo } from './chunk-ITAFAORS.mjs';
3
3
  import { TOKEN_PURPOSE, REPO_PROVIDER, REPO_PROVIDER_VALUES } from './chunk-MXYUAJEW.mjs';
4
4
  import { parseArgs, flagString, flagBool } from './chunk-C4M3DXKC.mjs';
5
- import { ApiClient } from './chunk-MAOO6ZZ5.mjs';
5
+ import { ApiClient } from './chunk-CV3ZFCX6.mjs';
6
6
  import { readAuth, readProjectLink } from './chunk-UBAI443T.mjs';
7
7
  import { CliError, CLI_ERROR_CODE, isJsonMode, result, dim, success, info, bold } from './chunk-E2T2SBP5.mjs';
8
8