@cimplify/cli 0.13.0 → 0.13.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,9 +1,60 @@
1
1
  #!/usr/bin/env node
2
2
  import { info, dim } from './chunk-ZPVN6UXL.mjs';
3
+ import { promises, watch } from 'fs';
4
+ import path2 from 'path';
3
5
  import http from 'http';
4
6
  import { spawn } from 'child_process';
5
- import { promises, watch } from 'fs';
6
- import path from 'path';
7
+
8
+ var TUNNEL_URL_ENV = "CIMPLIFY_TUNNEL_URL";
9
+ var TUNNEL_TOKEN_ENV = "CIMPLIFY_TUNNEL_TOKEN";
10
+ var TUNNEL_LOCAL_PORT_ENV = "CIMPLIFY_TUNNEL_LOCAL_PORT";
11
+ var TUNNEL_CONFIG_DIR = ".cimplify";
12
+ var TUNNEL_CONFIG_FILE = "tunnel.json";
13
+ var DEFAULT_DEV_SERVER_PORT = 3e3;
14
+ function tunnelConfigPath(cwd) {
15
+ return path2.join(cwd, TUNNEL_CONFIG_DIR, TUNNEL_CONFIG_FILE);
16
+ }
17
+ async function readTunnelConfig(cwd, env = process.env) {
18
+ const url = env[TUNNEL_URL_ENV];
19
+ const token = env[TUNNEL_TOKEN_ENV];
20
+ if (url && token) {
21
+ return { url, token, localPort: envPort(env) ?? DEFAULT_DEV_SERVER_PORT };
22
+ }
23
+ return readTunnelConfigFile(cwd);
24
+ }
25
+ function envPort(env) {
26
+ const raw = env[TUNNEL_LOCAL_PORT_ENV];
27
+ if (!raw) return null;
28
+ const port = Number.parseInt(raw, 10);
29
+ return Number.isInteger(port) && port > 0 && port < 65536 ? port : null;
30
+ }
31
+ async function readTunnelConfigFile(cwd) {
32
+ let raw;
33
+ try {
34
+ raw = await promises.readFile(tunnelConfigPath(cwd), "utf8");
35
+ } catch {
36
+ return null;
37
+ }
38
+ let parsed;
39
+ try {
40
+ parsed = JSON.parse(raw);
41
+ } catch {
42
+ return null;
43
+ }
44
+ if (typeof parsed !== "object" || parsed === null) return null;
45
+ const record = parsed;
46
+ if (typeof record.url !== "string" || record.url.length === 0) return null;
47
+ if (typeof record.token !== "string" || record.token.length === 0) return null;
48
+ const localPort = typeof record.port === "number" && Number.isInteger(record.port) && record.port > 0 ? record.port : DEFAULT_DEV_SERVER_PORT;
49
+ return { url: record.url, token: record.token, localPort };
50
+ }
51
+ function sameTunnelConfig(a, b) {
52
+ if (a === null || b === null) return a === b;
53
+ return a.url === b.url && a.token === b.token && a.localPort === b.localPort;
54
+ }
55
+ function sameTunnelEndpoint(a, b) {
56
+ return a.url === b.url && a.localPort === b.localPort;
57
+ }
7
58
 
8
59
  // src/tunnel/v2/codec.ts
9
60
  var HEADER_LEN = 9;
@@ -386,7 +437,6 @@ var CONTROL_ERROR = {
386
437
  IO: "io",
387
438
  UNSUPPORTED: "unsupported"};
388
439
  var WATCH_EVENT = {
389
- ADD: "add",
390
440
  CHANGE: "change",
391
441
  REMOVE: "remove",
392
442
  RESYNC: "resync"
@@ -605,8 +655,8 @@ function execCommand(request) {
605
655
  throw new ControlFsError(CONTROL_ERROR.INVALID_PATH, "exec requires a command");
606
656
  }
607
657
  function resolveInRoot(root, rel) {
608
- const resolved = path.resolve(root, rel);
609
- const rootWithSep = root.endsWith(path.sep) ? root : root + path.sep;
658
+ const resolved = path2.resolve(root, rel);
659
+ const rootWithSep = root.endsWith(path2.sep) ? root : root + path2.sep;
610
660
  if (resolved !== root && !resolved.startsWith(rootWithSep)) {
611
661
  throw new ControlFsError(CONTROL_ERROR.INVALID_PATH, `path escapes workspace: ${rel}`);
612
662
  }
@@ -628,7 +678,7 @@ var NodeControlFs = class {
628
678
  }
629
679
  async write(rel, content, encoding) {
630
680
  const abs = resolveInRoot(this.root, rel);
631
- await promises.mkdir(path.dirname(abs), { recursive: true });
681
+ await promises.mkdir(path2.dirname(abs), { recursive: true });
632
682
  const bytes = encoding === ENCODING.BASE64 ? Buffer.from(content, "base64") : Buffer.from(content, "utf8");
633
683
  await promises.writeFile(abs, bytes).catch(rethrow(rel));
634
684
  }
@@ -644,7 +694,7 @@ var NodeControlFs = class {
644
694
  async listTree() {
645
695
  const out = [];
646
696
  const walk = async (dir) => {
647
- const dirents = await promises.readdir(path.join(this.root, dir), { withFileTypes: true });
697
+ const dirents = await promises.readdir(path2.join(this.root, dir), { withFileTypes: true });
648
698
  for (const dirent of dirents) {
649
699
  if (DEFAULT_IGNORED.has(dirent.name)) continue;
650
700
  const rel = dir ? `${dir}/${dirent.name}` : dirent.name;
@@ -670,7 +720,7 @@ var NodeControlFs = class {
670
720
  async rename(from, to) {
671
721
  const absFrom = resolveInRoot(this.root, from);
672
722
  const absTo = resolveInRoot(this.root, to);
673
- await promises.mkdir(path.dirname(absTo), { recursive: true });
723
+ await promises.mkdir(path2.dirname(absTo), { recursive: true });
674
724
  await promises.rename(absFrom, absTo).catch(rethrow(from));
675
725
  }
676
726
  };
@@ -683,11 +733,20 @@ var NodeControlWatcher = class {
683
733
  start(_relPaths, onEvent, onResync) {
684
734
  let watcher;
685
735
  const pending = /* @__PURE__ */ new Map();
736
+ let stopped = false;
686
737
  const flush = (rel) => {
687
738
  pending.delete(rel);
688
- promises.stat(path.join(this.root, rel)).then(
689
- (stat) => onEvent(stat.isDirectory() ? WATCH_EVENT.ADD : WATCH_EVENT.CHANGE, [rel]),
690
- () => onEvent(WATCH_EVENT.REMOVE, [rel])
739
+ promises.stat(path2.join(this.root, rel)).then(
740
+ // Consumers mirror files, not directory nodes. Forwarding mkdir as
741
+ // `add` made every subscriber attempt a guaranteed file read/404.
742
+ (stat) => {
743
+ if (!stopped && !stat.isDirectory()) onEvent(WATCH_EVENT.CHANGE, [rel]);
744
+ },
745
+ (error) => {
746
+ if (stopped) return;
747
+ if (error.code === "ENOENT") onEvent(WATCH_EVENT.REMOVE, [rel]);
748
+ else onResync();
749
+ }
691
750
  );
692
751
  };
693
752
  try {
@@ -696,7 +755,7 @@ var NodeControlWatcher = class {
696
755
  onResync();
697
756
  return;
698
757
  }
699
- const rel = filename.toString().split(path.sep).join("/");
758
+ const rel = filename.toString().split(path2.sep).join("/");
700
759
  if (isIgnored(rel)) return;
701
760
  const existing = pending.get(rel);
702
761
  if (existing) clearTimeout(existing);
@@ -706,13 +765,17 @@ var NodeControlWatcher = class {
706
765
  );
707
766
  });
708
767
  } catch (error) {
709
- onResync();
710
- return { stop: () => {
711
- } };
768
+ throw new ControlFsError(
769
+ CONTROL_ERROR.IO,
770
+ `failed to start workspace watcher: ${error instanceof Error ? error.message : String(error)}`
771
+ );
712
772
  }
713
- watcher.on("error", () => onResync());
773
+ watcher.on("error", () => {
774
+ if (!stopped) onResync();
775
+ });
714
776
  return {
715
777
  stop: () => {
778
+ stopped = true;
716
779
  for (const timer of pending.values()) clearTimeout(timer);
717
780
  pending.clear();
718
781
  watcher.close();
@@ -760,7 +823,8 @@ function tryDecodeUtf8(bytes) {
760
823
  }
761
824
  function rethrow(rel) {
762
825
  return (error) => {
763
- if (error.code === "ENOENT") throw new ControlFsError(CONTROL_ERROR.NOT_FOUND, `not found: ${rel}`);
826
+ if (error.code === "ENOENT")
827
+ throw new ControlFsError(CONTROL_ERROR.NOT_FOUND, `not found: ${rel}`);
764
828
  if (error.code === "EACCES") throw new ControlFsError(CONTROL_ERROR.PERMISSION_DENIED, rel);
765
829
  throw new ControlFsError(CONTROL_ERROR.IO, error.message);
766
830
  };
@@ -1850,56 +1914,6 @@ function makeAgentContext(localPort, hello, createLocalSocket) {
1850
1914
  createLocalSocket: (url, protocols) => createLocalSocket(url, protocols)
1851
1915
  };
1852
1916
  }
1853
- var TUNNEL_URL_ENV = "CIMPLIFY_TUNNEL_URL";
1854
- var TUNNEL_TOKEN_ENV = "CIMPLIFY_TUNNEL_TOKEN";
1855
- var TUNNEL_LOCAL_PORT_ENV = "CIMPLIFY_TUNNEL_LOCAL_PORT";
1856
- var TUNNEL_CONFIG_DIR = ".cimplify";
1857
- var TUNNEL_CONFIG_FILE = "tunnel.json";
1858
- var DEFAULT_DEV_SERVER_PORT = 3e3;
1859
- function tunnelConfigPath(cwd) {
1860
- return path.join(cwd, TUNNEL_CONFIG_DIR, TUNNEL_CONFIG_FILE);
1861
- }
1862
- async function readTunnelConfig(cwd, env = process.env) {
1863
- const url = env[TUNNEL_URL_ENV];
1864
- const token = env[TUNNEL_TOKEN_ENV];
1865
- if (url && token) {
1866
- return { url, token, localPort: envPort(env) ?? DEFAULT_DEV_SERVER_PORT };
1867
- }
1868
- return readTunnelConfigFile(cwd);
1869
- }
1870
- function envPort(env) {
1871
- const raw = env[TUNNEL_LOCAL_PORT_ENV];
1872
- if (!raw) return null;
1873
- const port = Number.parseInt(raw, 10);
1874
- return Number.isInteger(port) && port > 0 && port < 65536 ? port : null;
1875
- }
1876
- async function readTunnelConfigFile(cwd) {
1877
- let raw;
1878
- try {
1879
- raw = await promises.readFile(tunnelConfigPath(cwd), "utf8");
1880
- } catch {
1881
- return null;
1882
- }
1883
- let parsed;
1884
- try {
1885
- parsed = JSON.parse(raw);
1886
- } catch {
1887
- return null;
1888
- }
1889
- if (typeof parsed !== "object" || parsed === null) return null;
1890
- const record = parsed;
1891
- if (typeof record.url !== "string" || record.url.length === 0) return null;
1892
- if (typeof record.token !== "string" || record.token.length === 0) return null;
1893
- const localPort = typeof record.port === "number" && Number.isInteger(record.port) && record.port > 0 ? record.port : DEFAULT_DEV_SERVER_PORT;
1894
- return { url: record.url, token: record.token, localPort };
1895
- }
1896
- function sameTunnelConfig(a, b) {
1897
- if (a === null || b === null) return a === b;
1898
- return a.url === b.url && a.token === b.token && a.localPort === b.localPort;
1899
- }
1900
- function sameTunnelEndpoint(a, b) {
1901
- return a.url === b.url && a.localPort === b.localPort;
1902
- }
1903
1917
 
1904
1918
  // src/tunnel/manager.ts
1905
1919
  var CONFIG_POLL_MS = 2e3;
@@ -2029,4 +2043,4 @@ function startTunnelRuntime(cwd, options = {}) {
2029
2043
  };
2030
2044
  }
2031
2045
 
2032
- export { startTunnelRuntime };
2046
+ export { TUNNEL_URL_ENV, startTunnelRuntime };
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { startTunnelRuntime } from './chunk-3UV4P4DM.mjs';
2
+ import { startTunnelRuntime, TUNNEL_URL_ENV } from './chunk-YTZ233XM.mjs';
3
3
  import { parseEnvFile, formatEnvFile } from './chunk-5U5OXOPN.mjs';
4
4
  import { ENV_SCOPE, PUBLIC_ENV_PREFIX } from './chunk-MXYUAJEW.mjs';
5
5
  import { parseArgs, flagBool } from './chunk-C4M3DXKC.mjs';
@@ -148,7 +148,11 @@ async function run(argv) {
148
148
  }
149
149
  const pm = await detectPackageManager(cwd);
150
150
  info(dim(`(running: ${pm} run ${SCRIPT_DEV})`));
151
- const child = spawn(pm, ["run", SCRIPT_DEV], { cwd, stdio: "inherit" });
151
+ const hosted = Boolean(process.env[AGENT_EXTERNAL_ENV] || process.env[TUNNEL_URL_ENV]);
152
+ const child = spawn(pm, ["run", SCRIPT_DEV], {
153
+ cwd,
154
+ stdio: [hosted ? "pipe" : "inherit", "inherit", "inherit"]
155
+ });
152
156
  try {
153
157
  await new Promise((resolve, reject) => {
154
158
  child.on("error", (err) => reject(new CliError(CLI_ERROR_CODE.INVALID_INPUT, `Failed to spawn ${pm}: ${err.message}`)));
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { TEMPLATES } from './chunk-W3WLADJP.mjs';
3
- import { package_default } from './chunk-5XXUHANH.mjs';
2
+ import { TEMPLATES } from './chunk-SVJPU4K7.mjs';
3
+ import { package_default } from './chunk-QKRGKFHE.mjs';
4
4
 
5
5
  // src/dispatcher.ts
6
6
  var VERSION = package_default.version ?? "unknown";
@@ -143,19 +143,19 @@ var COMMANDS = {
143
143
  domains: () => import('./domains-OS3DXSDN.mjs'),
144
144
  logs: () => import('./logs-YNXDXAF7.mjs'),
145
145
  status: () => import('./status-RR3GGTVU.mjs'),
146
- dev: () => import('./dev-QC55VHDI.mjs'),
147
- agent: () => import('./agent-3PAQPC7W.mjs'),
146
+ dev: () => import('./dev-3U6WW5D7.mjs'),
147
+ agent: () => import('./agent-24IISIOQ.mjs'),
148
148
  mock: () => import('./mock-HFVAAYK2.mjs'),
149
- introspect: () => import('./introspect-X7GQ7XUE.mjs'),
149
+ introspect: () => import('./introspect-UKSR3JBF.mjs'),
150
150
  inspect: () => import('./inspect-ULWQHT7J.mjs'),
151
- doctor: () => import('./doctor-4BHP3JT7.mjs'),
152
- explain: () => import('./explain-OQZKABWP.mjs'),
151
+ doctor: () => import('./doctor-6NYHQ7YE.mjs'),
152
+ explain: () => import('./explain-O363MCQ2.mjs'),
153
153
  assets: () => import('./assets-Y4JE6MSG.mjs'),
154
154
  repo: () => import('./repo-OK6CVG3G.mjs'),
155
- list: () => import('./list-3OGYEBKV.mjs'),
156
- add: () => import('./add-Q4OFUCNB.mjs'),
157
- update: () => import('./update-6DO57SJN.mjs'),
158
- upgrade: () => import('./update-6DO57SJN.mjs'),
155
+ list: () => import('./list-DZTPWNU3.mjs'),
156
+ add: () => import('./add-F7GKDXAD.mjs'),
157
+ update: () => import('./update-QA5WJ6YL.mjs'),
158
+ upgrade: () => import('./update-QA5WJ6YL.mjs'),
159
159
  "auth-step-up": () => import('./auth-step-up-EHL5PM2L.mjs')
160
160
  };
161
161
  var COMMAND_PREFIXES = {
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
- import { gatherIntrospection } from './chunk-5GYD3EHJ.mjs';
2
+ import { gatherIntrospection } from './chunk-D7DVYTVI.mjs';
3
3
  import './chunk-OVHZV57L.mjs';
4
4
  import './chunk-5U5OXOPN.mjs';
5
- import './chunk-5XXUHANH.mjs';
5
+ import './chunk-QKRGKFHE.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-JPXK5BLA.mjs';
8
8
  import { readAuthOrNull } from './chunk-QA36VSLX.mjs';
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { package_default } from './chunk-5XXUHANH.mjs';
2
+ import { package_default } from './chunk-QKRGKFHE.mjs';
3
3
  import { parseArgs } from './chunk-C4M3DXKC.mjs';
4
4
  import { CliError, CLI_ERROR_CODE } from './chunk-YPC4VU65.mjs';
5
5
  import { bold, dim, info, result } from './chunk-ZPVN6UXL.mjs';
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
- export { run as default, extractMockSeed, gatherIntrospection, renderIntrospection } from './chunk-5GYD3EHJ.mjs';
2
+ export { run as default, extractMockSeed, gatherIntrospection, renderIntrospection } from './chunk-D7DVYTVI.mjs';
3
3
  import './chunk-OVHZV57L.mjs';
4
4
  import './chunk-5U5OXOPN.mjs';
5
- import './chunk-5XXUHANH.mjs';
5
+ import './chunk-QKRGKFHE.mjs';
6
6
  import './chunk-C4M3DXKC.mjs';
7
7
  import './chunk-QA36VSLX.mjs';
8
8
  import './chunk-YPC4VU65.mjs';
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { REGISTRY_INDEX } from './chunk-W3WLADJP.mjs';
2
+ import { REGISTRY_INDEX } from './chunk-SVJPU4K7.mjs';
3
3
  import { parseArgs, flagBool } from './chunk-C4M3DXKC.mjs';
4
4
  import { CliError, CLI_ERROR_CODE } from './chunk-YPC4VU65.mjs';
5
5
  import { info, bold, dim, green, result } from './chunk-ZPVN6UXL.mjs';
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { package_default } from './chunk-5XXUHANH.mjs';
2
+ import { package_default } from './chunk-QKRGKFHE.mjs';
3
3
  import { promptYesNo } from './chunk-4YIFBYBV.mjs';
4
4
  import { parseArgs, flagBool, flagString } from './chunk-C4M3DXKC.mjs';
5
5
  import { CliError, CLI_ERROR_CODE } from './chunk-YPC4VU65.mjs';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cimplify/cli",
3
- "version": "0.13.0",
3
+ "version": "0.13.2",
4
4
  "description": "Cimplify CLI — deploy, manage env vars, link projects, and scaffold storefronts",
5
5
  "keywords": [
6
6
  "cimplify",
@@ -36,6 +36,13 @@
36
36
  "test": "vitest",
37
37
  "test:run": "vitest run"
38
38
  },
39
+ "dependencies": {
40
+ "@babel/generator": "^8.0.0",
41
+ "@babel/parser": "^8.0.4",
42
+ "@babel/traverse": "^8.0.4",
43
+ "@babel/types": "^8.0.4",
44
+ "@cimplify/sdk": "^0.99.2"
45
+ },
39
46
  "devDependencies": {
40
47
  "@aws-sdk/client-s3": "^3.1070.0",
41
48
  "@types/babel__generator": "^7.27.0",
@@ -45,12 +52,5 @@
45
52
  "tsup": "^8.5.1",
46
53
  "typescript": "6.0.3",
47
54
  "vitest": "^4.1.9"
48
- },
49
- "dependencies": {
50
- "@babel/generator": "^8.0.0",
51
- "@babel/parser": "^8.0.4",
52
- "@babel/traverse": "^8.0.4",
53
- "@babel/types": "^8.0.4",
54
- "@cimplify/sdk": "^0.99.1"
55
55
  }
56
56
  }
@@ -17,7 +17,7 @@
17
17
  "check": "bun run typecheck && bun run test:run"
18
18
  },
19
19
  "dependencies": {
20
- "@cimplify/sdk": "^0.99.1",
20
+ "@cimplify/sdk": "^0.99.2",
21
21
  "next": "^16.2.6",
22
22
  "react": "^19.0.0",
23
23
  "react-dom": "^19.0.0"
@@ -17,7 +17,7 @@
17
17
  "check": "bun run typecheck && bun run test:run"
18
18
  },
19
19
  "dependencies": {
20
- "@cimplify/sdk": "^0.99.1",
20
+ "@cimplify/sdk": "^0.99.2",
21
21
  "next": "^16.2.6",
22
22
  "react": "^19.0.0",
23
23
  "react-dom": "^19.0.0"
@@ -19,7 +19,7 @@
19
19
  "check": "bun run typecheck && bun run test:run"
20
20
  },
21
21
  "dependencies": {
22
- "@cimplify/sdk": "^0.99.1",
22
+ "@cimplify/sdk": "^0.99.2",
23
23
  "next": "^16.2.6",
24
24
  "react": "^19.0.0",
25
25
  "react-dom": "^19.0.0"
@@ -17,7 +17,7 @@
17
17
  "check": "bun run typecheck && bun run test:run"
18
18
  },
19
19
  "dependencies": {
20
- "@cimplify/sdk": "^0.99.1",
20
+ "@cimplify/sdk": "^0.99.2",
21
21
  "next": "^16.2.6",
22
22
  "react": "^19.0.0",
23
23
  "react-dom": "^19.0.0"
@@ -17,7 +17,7 @@
17
17
  "check": "bun run typecheck && bun run test:run"
18
18
  },
19
19
  "dependencies": {
20
- "@cimplify/sdk": "^0.99.1",
20
+ "@cimplify/sdk": "^0.99.2",
21
21
  "next": "^16.2.6",
22
22
  "react": "^19.0.0",
23
23
  "react-dom": "^19.0.0"
@@ -17,7 +17,7 @@
17
17
  "check": "bun run typecheck && bun run test:run"
18
18
  },
19
19
  "dependencies": {
20
- "@cimplify/sdk": "^0.99.1",
20
+ "@cimplify/sdk": "^0.99.2",
21
21
  "next": "^16.2.6",
22
22
  "react": "^19.0.0",
23
23
  "react-dom": "^19.0.0"
@@ -17,7 +17,7 @@
17
17
  "check": "bun run typecheck && bun run test:run"
18
18
  },
19
19
  "dependencies": {
20
- "@cimplify/sdk": "^0.99.1",
20
+ "@cimplify/sdk": "^0.99.2",
21
21
  "next": "^16.2.6",
22
22
  "react": "^19.0.0",
23
23
  "react-dom": "^19.0.0"
@@ -17,7 +17,7 @@
17
17
  "check": "bun run typecheck && bun run test:run"
18
18
  },
19
19
  "dependencies": {
20
- "@cimplify/sdk": "^0.99.1",
20
+ "@cimplify/sdk": "^0.99.2",
21
21
  "next": "^16.2.6",
22
22
  "react": "^19.0.0",
23
23
  "react-dom": "^19.0.0"