@cimplify/cli 0.11.0 → 0.11.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.
@@ -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-PQUWRUVT.mjs';
4
+ import { package_default } from './chunk-YRP3RWYA.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.11.0",
5
+ version: "0.11.2",
6
6
  description: "Cimplify CLI \u2014 deploy, manage env vars, link projects, and scaffold storefronts",
7
7
  keywords: [
8
8
  "cimplify",
@@ -128,7 +128,7 @@ var TunnelClient = class {
128
128
  socket.addEventListener("message", (event) => this.handleMessage(event.data));
129
129
  socket.addEventListener(
130
130
  "close",
131
- (event) => this.teardown(`connection closed (${event.code ?? "unknown"})`)
131
+ (event) => this.teardown(`connection closed (${event.code ?? "unknown"})`, event.code)
132
132
  );
133
133
  socket.addEventListener("error", () => this.teardown("connection error"));
134
134
  }
@@ -140,7 +140,7 @@ var TunnelClient = class {
140
140
  }
141
141
  this.teardown("stopped");
142
142
  }
143
- teardown(reason) {
143
+ teardown(reason, closeCode) {
144
144
  if (this.closed) return;
145
145
  this.closed = true;
146
146
  for (const handler of this.streams.values()) {
@@ -148,7 +148,7 @@ var TunnelClient = class {
148
148
  }
149
149
  this.streams.clear();
150
150
  this.socket = null;
151
- this.options.events?.onClosed?.(reason);
151
+ this.options.events?.onClosed?.(reason, closeCode);
152
152
  }
153
153
  handleMessage(data) {
154
154
  if (this.closed) return;
@@ -369,7 +369,7 @@ var WsProxyStream = class {
369
369
  this.local.addEventListener("close", (event) => {
370
370
  if (this.done) return;
371
371
  this.done = true;
372
- this.ctx.fail({ code: event.code, reason: event.reason || void 0 });
372
+ this.ctx.fail({ code: sendableCloseCode(event.code), reason: event.reason || void 0 });
373
373
  });
374
374
  this.local.addEventListener("error", () => {
375
375
  if (this.done || this.opened) return;
@@ -465,6 +465,11 @@ function sanitizeCloseCode(code) {
465
465
  if (code === void 0) return void 0;
466
466
  return code === WS_CLOSE_NORMAL || code >= 3e3 && code <= 4999 ? code : void 0;
467
467
  }
468
+ function sendableCloseCode(code) {
469
+ if (code === void 0) return void 0;
470
+ const legal = code >= 1e3 && code <= 1003 || code >= 1007 && code <= 1014 || code >= 3e3 && code <= 4999;
471
+ return legal ? code : void 0;
472
+ }
468
473
  var TUNNEL_URL_ENV = "CIMPLIFY_TUNNEL_URL";
469
474
  var TUNNEL_TOKEN_ENV = "CIMPLIFY_TUNNEL_TOKEN";
470
475
  var TUNNEL_LOCAL_PORT_ENV = "CIMPLIFY_TUNNEL_LOCAL_PORT";
@@ -512,11 +517,15 @@ function sameTunnelConfig(a, b) {
512
517
  if (a === null || b === null) return a === b;
513
518
  return a.url === b.url && a.token === b.token && a.localPort === b.localPort;
514
519
  }
520
+ function sameTunnelEndpoint(a, b) {
521
+ return a.url === b.url && a.localPort === b.localPort;
522
+ }
515
523
 
516
524
  // src/tunnel/manager.ts
517
525
  var CONFIG_POLL_MS = 2e3;
518
526
  var RECONNECT_MIN_MS = 1e3;
519
527
  var RECONNECT_MAX_MS = 3e4;
528
+ var CLOSE_CODE_REPLACED = 4e3;
520
529
  function defaultCreateClient(config, events) {
521
530
  return new TunnelClient({
522
531
  url: config.url,
@@ -536,6 +545,8 @@ function startTunnelRuntime(cwd, options = {}) {
536
545
  let reconnectDelay = RECONNECT_MIN_MS;
537
546
  let reconnectTimer = null;
538
547
  let polling = false;
548
+ let connected = false;
549
+ let standDown = false;
539
550
  const clearReconnect = () => {
540
551
  if (reconnectTimer !== null) {
541
552
  clearTimeout(reconnectTimer);
@@ -544,15 +555,23 @@ function startTunnelRuntime(cwd, options = {}) {
544
555
  };
545
556
  const startClient = (config) => {
546
557
  generation += 1;
558
+ standDown = false;
547
559
  const myGeneration = generation;
548
560
  const client = createClient(config, {
549
561
  onConnected: () => {
550
562
  if (stopped || myGeneration !== generation) return;
563
+ connected = true;
551
564
  reconnectDelay = RECONNECT_MIN_MS;
552
565
  onStatus("(preview tunnel: connected)");
553
566
  },
554
- onClosed: (reason) => {
567
+ onClosed: (reason, closeCode) => {
555
568
  if (stopped || myGeneration !== generation) return;
569
+ connected = false;
570
+ if (closeCode === CLOSE_CODE_REPLACED) {
571
+ standDown = true;
572
+ onStatus("(preview tunnel: replaced by a newer agent; standing down)");
573
+ return;
574
+ }
556
575
  onStatus(`(preview tunnel: disconnected \u2014 ${reason})`);
557
576
  scheduleReconnect();
558
577
  }
@@ -581,6 +600,7 @@ function startTunnelRuntime(cwd, options = {}) {
581
600
  clearReconnect();
582
601
  retireClient();
583
602
  activeConfig = null;
603
+ connected = false;
584
604
  };
585
605
  const poll = async () => {
586
606
  if (polling || stopped) return;
@@ -588,14 +608,19 @@ function startTunnelRuntime(cwd, options = {}) {
588
608
  try {
589
609
  const config = await readTunnelConfig(cwd, options.env);
590
610
  if (stopped || sameTunnelConfig(config, activeConfig)) return;
591
- stopClient();
592
- if (config) {
593
- onStatus("(preview tunnel: credentials found, connecting)");
594
- reconnectDelay = RECONNECT_MIN_MS;
595
- startClient(config);
596
- } else {
611
+ if (config === null) {
612
+ stopClient();
597
613
  onStatus("(preview tunnel: credentials removed, stopped)");
614
+ return;
598
615
  }
616
+ if (activeConfig && sameTunnelEndpoint(config, activeConfig) && connected && !standDown) {
617
+ activeConfig = config;
618
+ return;
619
+ }
620
+ stopClient();
621
+ onStatus("(preview tunnel: credentials found, connecting)");
622
+ reconnectDelay = RECONNECT_MIN_MS;
623
+ startClient(config);
599
624
  } finally {
600
625
  polling = false;
601
626
  }
@@ -619,10 +644,12 @@ var ENV_LOCAL_FILE = ".env.local";
619
644
  var PUBLIC_API_URL_KEY = "NEXT_PUBLIC_CIMPLIFY_API_URL";
620
645
  var SCRIPT_DEV = "dev";
621
646
  var PREVIEW_ORIGIN_ENV = "CIMPLIFY_PREVIEW_ORIGIN";
622
- async function applyPreviewOrigin(cwd, origin) {
623
- const { ensurePreviewOrigin } = await import('./preview-config-CHDYYWUY.mjs');
647
+ async function applyPreviewOrigin(cwd, originList) {
648
+ const { ensurePreviewOrigin } = await import('./preview-config-344CUZLO.mjs');
649
+ const origins = originList.split(",").map((origin) => origin.trim()).filter((origin) => origin.length > 0);
650
+ if (origins.length === 0) return;
624
651
  try {
625
- const result = await ensurePreviewOrigin(cwd, origin);
652
+ const result = await ensurePreviewOrigin(cwd, origins);
626
653
  if (result.status === "unrecognized") {
627
654
  info(
628
655
  dim(
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { package_default } from './chunk-PQUWRUVT.mjs';
2
+ import { package_default } from './chunk-YRP3RWYA.mjs';
3
3
  import { TEMPLATES } from './chunk-W3WLADJP.mjs';
4
4
 
5
5
  // src/dispatcher.ts
@@ -142,18 +142,18 @@ var COMMANDS = {
142
142
  domains: () => import('./domains-H3K2WW55.mjs'),
143
143
  logs: () => import('./logs-2ECJQ3MU.mjs'),
144
144
  status: () => import('./status-IA7PJ4TV.mjs'),
145
- dev: () => import('./dev-OF335HZZ.mjs'),
145
+ dev: () => import('./dev-JAIAEQFS.mjs'),
146
146
  mock: () => import('./mock-TSUKCLWU.mjs'),
147
- introspect: () => import('./introspect-P3BJ7WQL.mjs'),
147
+ introspect: () => import('./introspect-HYNDDYSR.mjs'),
148
148
  inspect: () => import('./inspect-CGYX4DDF.mjs'),
149
- doctor: () => import('./doctor-O2XLOCBB.mjs'),
150
- explain: () => import('./explain-327PXAY6.mjs'),
149
+ doctor: () => import('./doctor-Z3AXZUPV.mjs'),
150
+ explain: () => import('./explain-OLMEQJDY.mjs'),
151
151
  assets: () => import('./assets-4D7VXRUE.mjs'),
152
152
  repo: () => import('./repo-WSUAHXWO.mjs'),
153
153
  list: () => import('./list-27TS2L47.mjs'),
154
154
  add: () => import('./add-5ODVFWVR.mjs'),
155
- update: () => import('./update-TEHVCICJ.mjs'),
156
- upgrade: () => import('./update-TEHVCICJ.mjs'),
155
+ update: () => import('./update-JWRQQYTM.mjs'),
156
+ upgrade: () => import('./update-JWRQQYTM.mjs'),
157
157
  "auth-step-up": () => import('./auth-step-up-NOSM4PUR.mjs')
158
158
  };
159
159
  var COMMAND_PREFIXES = {
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
- import { gatherIntrospection } from './chunk-WF5HX2WB.mjs';
2
+ import { gatherIntrospection } from './chunk-DL2YLGFV.mjs';
3
3
  import './chunk-K5464A3L.mjs';
4
4
  import './chunk-DBZ3UOQ2.mjs';
5
- import './chunk-PQUWRUVT.mjs';
5
+ import './chunk-YRP3RWYA.mjs';
6
6
  import { parseArgs, flagBool } from './chunk-C4M3DXKC.mjs';
7
7
  import { SDK_ENV_API_URL, DEFAULT_API_BASE_URL, ApiClient, ENV_API_BASE_URL } from './chunk-F4S5KETY.mjs';
8
8
  import { readAuthOrNull } from './chunk-UBAI443T.mjs';
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { package_default } from './chunk-PQUWRUVT.mjs';
2
+ import { package_default } from './chunk-YRP3RWYA.mjs';
3
3
  import { parseArgs } from './chunk-C4M3DXKC.mjs';
4
4
  import { bold, dim, info, result, CliError, CLI_ERROR_CODE } from './chunk-E2T2SBP5.mjs';
5
5
 
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
- export { run as default, extractMockSeed, gatherIntrospection, renderIntrospection } from './chunk-WF5HX2WB.mjs';
2
+ export { run as default, extractMockSeed, gatherIntrospection, renderIntrospection } from './chunk-DL2YLGFV.mjs';
3
3
  import './chunk-K5464A3L.mjs';
4
4
  import './chunk-DBZ3UOQ2.mjs';
5
- import './chunk-PQUWRUVT.mjs';
5
+ import './chunk-YRP3RWYA.mjs';
6
6
  import './chunk-C4M3DXKC.mjs';
7
7
  import './chunk-UBAI443T.mjs';
8
8
  import './chunk-E2T2SBP5.mjs';
@@ -85,21 +85,25 @@ function upsertOrigin(config, origin) {
85
85
  );
86
86
  return true;
87
87
  }
88
- function injectAllowedDevOrigins(source, origin) {
88
+ function injectAllowedDevOrigins(source, origins) {
89
89
  const ast = parse(source, {
90
90
  sourceType: "module",
91
91
  plugins: ["typescript"]
92
92
  });
93
93
  const config = findConfigObject(ast);
94
94
  if (!config) return { code: source, changed: false, resolved: false };
95
- if (!upsertOrigin(config, origin)) return { code: source, changed: false, resolved: true };
95
+ let changed = false;
96
+ for (const origin of origins) {
97
+ if (upsertOrigin(config, origin)) changed = true;
98
+ }
99
+ if (!changed) return { code: source, changed: false, resolved: true };
96
100
  return {
97
101
  code: generate(ast, { retainLines: true }, source).code,
98
102
  changed: true,
99
103
  resolved: true
100
104
  };
101
105
  }
102
- async function ensurePreviewOrigin(cwd, origin) {
106
+ async function ensurePreviewOrigin(cwd, origins) {
103
107
  for (const filename of CONFIG_FILENAMES) {
104
108
  const file = path.join(cwd, filename);
105
109
  let source;
@@ -109,7 +113,7 @@ async function ensurePreviewOrigin(cwd, origin) {
109
113
  if (err.code === "ENOENT") continue;
110
114
  throw err;
111
115
  }
112
- const { code, changed, resolved } = injectAllowedDevOrigins(source, origin);
116
+ const { code, changed, resolved } = injectAllowedDevOrigins(source, origins);
113
117
  if (!resolved) return { status: "unrecognized", file: filename };
114
118
  if (changed) await promises.writeFile(file, code, "utf8");
115
119
  return { status: changed ? "injected" : "already-present", file: filename };
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { package_default } from './chunk-PQUWRUVT.mjs';
2
+ import { package_default } from './chunk-YRP3RWYA.mjs';
3
3
  import { promptYesNo } from './chunk-ITAFAORS.mjs';
4
4
  import { parseArgs, flagBool, flagString } from './chunk-C4M3DXKC.mjs';
5
5
  import { success, bold, info, dim, result, failure, CliError, CLI_ERROR_CODE, step, isJsonMode } from './chunk-E2T2SBP5.mjs';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cimplify/cli",
3
- "version": "0.11.0",
3
+ "version": "0.11.2",
4
4
  "description": "Cimplify CLI — deploy, manage env vars, link projects, and scaffold storefronts",
5
5
  "keywords": [
6
6
  "cimplify",