@mondaydotcomorg/z2h-cli 0.5.2 → 0.6.1

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 (105) hide show
  1. package/dist/commands/create-workspace.d.ts.map +1 -1
  2. package/dist/commands/create-workspace.js +2 -5
  3. package/dist/commands/create.d.ts.map +1 -1
  4. package/dist/commands/create.js +2 -5
  5. package/dist/constants.d.ts +18 -0
  6. package/dist/constants.d.ts.map +1 -1
  7. package/dist/constants.js +41 -0
  8. package/dist/esm/commands/create-workspace.d.ts.map +1 -1
  9. package/dist/esm/commands/create-workspace.mjs +2 -5
  10. package/dist/esm/commands/create.d.ts.map +1 -1
  11. package/dist/esm/commands/create.mjs +2 -5
  12. package/dist/esm/constants.d.ts +18 -0
  13. package/dist/esm/constants.d.ts.map +1 -1
  14. package/dist/esm/constants.mjs +35 -1
  15. package/dist/esm/index.mjs +18 -6
  16. package/dist/esm/migrations/003-npm-broker-scope-split.d.ts +14 -0
  17. package/dist/esm/migrations/003-npm-broker-scope-split.d.ts.map +1 -0
  18. package/dist/esm/migrations/003-npm-broker-scope-split.mjs +49 -0
  19. package/dist/esm/migrations/__tests__/003-npm-broker-scope-split.test.d.ts +2 -0
  20. package/dist/esm/migrations/__tests__/003-npm-broker-scope-split.test.d.ts.map +1 -0
  21. package/dist/esm/migrations/auto-migrate.mjs +4 -4
  22. package/dist/esm/shadow/sync.d.ts.map +1 -1
  23. package/dist/esm/shadow/sync.mjs +4 -6
  24. package/dist/esm/util/auth/auth-store.d.ts +10 -0
  25. package/dist/esm/util/auth/auth-store.d.ts.map +1 -1
  26. package/dist/esm/util/auth/auth-store.mjs +20 -2
  27. package/dist/esm/util/auth/broker-credential-provider.d.ts +0 -1
  28. package/dist/esm/util/auth/broker-credential-provider.d.ts.map +1 -1
  29. package/dist/esm/util/auth/broker-credential-provider.mjs +2 -5
  30. package/dist/esm/util/logger.d.ts.map +1 -1
  31. package/dist/esm/util/logger.mjs +2 -0
  32. package/dist/esm/util/npm/__tests__/broker-config.test.d.ts +2 -0
  33. package/dist/esm/util/npm/__tests__/broker-config.test.d.ts.map +1 -0
  34. package/dist/esm/util/npm/__tests__/install.test.d.ts +2 -0
  35. package/dist/esm/util/npm/__tests__/install.test.d.ts.map +1 -0
  36. package/dist/esm/util/npm/broker-config.d.ts +20 -0
  37. package/dist/esm/util/npm/broker-config.d.ts.map +1 -0
  38. package/dist/esm/util/npm/broker-config.mjs +59 -0
  39. package/dist/esm/util/npm/ensure-token.d.ts +19 -0
  40. package/dist/esm/util/npm/ensure-token.d.ts.map +1 -0
  41. package/dist/esm/util/npm/ensure-token.mjs +22 -0
  42. package/dist/esm/util/npm/install.d.ts +18 -0
  43. package/dist/esm/util/npm/install.d.ts.map +1 -0
  44. package/dist/esm/util/npm/install.mjs +74 -0
  45. package/dist/esm/util/tracker.d.ts +3 -0
  46. package/dist/esm/util/tracker.d.ts.map +1 -0
  47. package/dist/esm/util/tracker.mjs +20 -0
  48. package/dist/index.js +18 -6
  49. package/dist/migrations/003-npm-broker-scope-split.d.ts +14 -0
  50. package/dist/migrations/003-npm-broker-scope-split.d.ts.map +1 -0
  51. package/dist/migrations/003-npm-broker-scope-split.js +51 -0
  52. package/dist/migrations/__tests__/003-npm-broker-scope-split.test.d.ts +2 -0
  53. package/dist/migrations/__tests__/003-npm-broker-scope-split.test.d.ts.map +1 -0
  54. package/dist/migrations/auto-migrate.js +3 -3
  55. package/dist/shadow/sync.d.ts.map +1 -1
  56. package/dist/shadow/sync.js +4 -6
  57. package/dist/util/auth/auth-store.d.ts +10 -0
  58. package/dist/util/auth/auth-store.d.ts.map +1 -1
  59. package/dist/util/auth/auth-store.js +19 -0
  60. package/dist/util/auth/broker-credential-provider.d.ts +0 -1
  61. package/dist/util/auth/broker-credential-provider.d.ts.map +1 -1
  62. package/dist/util/auth/broker-credential-provider.js +2 -6
  63. package/dist/util/logger.d.ts.map +1 -1
  64. package/dist/util/logger.js +2 -0
  65. package/dist/util/npm/__tests__/broker-config.test.d.ts +2 -0
  66. package/dist/util/npm/__tests__/broker-config.test.d.ts.map +1 -0
  67. package/dist/util/npm/__tests__/install.test.d.ts +2 -0
  68. package/dist/util/npm/__tests__/install.test.d.ts.map +1 -0
  69. package/dist/util/npm/broker-config.d.ts +20 -0
  70. package/dist/util/npm/broker-config.d.ts.map +1 -0
  71. package/dist/util/npm/broker-config.js +63 -0
  72. package/dist/util/npm/ensure-token.d.ts +19 -0
  73. package/dist/util/npm/ensure-token.d.ts.map +1 -0
  74. package/dist/util/npm/ensure-token.js +24 -0
  75. package/dist/util/npm/install.d.ts +18 -0
  76. package/dist/util/npm/install.d.ts.map +1 -0
  77. package/dist/util/npm/install.js +76 -0
  78. package/dist/util/tracker.d.ts +3 -0
  79. package/dist/util/tracker.d.ts.map +1 -0
  80. package/dist/util/tracker.js +27 -0
  81. package/migrations.json +5 -0
  82. package/package.json +1 -1
  83. package/src/commands/__tests__/create-workspace.test.ts +9 -11
  84. package/src/commands/__tests__/create.test.ts +9 -6
  85. package/src/commands/create-workspace.ts +2 -5
  86. package/src/commands/create.ts +2 -5
  87. package/src/constants.ts +41 -0
  88. package/src/index.ts +18 -6
  89. package/src/migrations/003-npm-broker-scope-split.ts +52 -0
  90. package/src/migrations/__tests__/003-npm-broker-scope-split.test.ts +99 -0
  91. package/src/migrations/auto-migrate.ts +4 -4
  92. package/src/shadow/sync.ts +4 -6
  93. package/src/templates/workspace/npmrc +3 -2
  94. package/src/templates/workspace/yarnrc.yml +6 -2
  95. package/src/util/__tests__/workspace-templates-shipped.test.ts +19 -0
  96. package/src/util/auth/__tests__/broker-credential-provider.test.ts +2 -1
  97. package/src/util/auth/auth-store.ts +19 -1
  98. package/src/util/auth/broker-credential-provider.ts +1 -5
  99. package/src/util/logger.ts +2 -0
  100. package/src/util/npm/__tests__/broker-config.test.ts +48 -0
  101. package/src/util/npm/__tests__/install.test.ts +94 -0
  102. package/src/util/npm/broker-config.ts +63 -0
  103. package/src/util/npm/ensure-token.ts +28 -0
  104. package/src/util/npm/install.ts +84 -0
  105. package/src/util/tracker.ts +25 -0
@@ -1 +1 @@
1
- {"version":3,"file":"create-workspace.d.ts","sourceRoot":"","sources":["../../src/commands/create-workspace.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,sBAAsB;IACrC,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,wBAAsB,sBAAsB,CAAC,IAAI,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CA6CxF"}
1
+ {"version":3,"file":"create-workspace.d.ts","sourceRoot":"","sources":["../../src/commands/create-workspace.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,sBAAsB;IACrC,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,wBAAsB,sBAAsB,CAAC,IAAI,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CA0CxF"}
@@ -3,10 +3,10 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
3
3
  const path = require('node:path');
4
4
  const promises = require('node:fs/promises');
5
5
  const fsExtra = require('fs-extra');
6
- const execa = require('execa');
7
6
  const util_logger = require('../util/logger.js');
8
7
  const util_workspace = require('../util/workspace.js');
9
8
  const util_templates = require('../util/templates.js');
9
+ const util_npm_install = require('../util/npm/install.js');
10
10
 
11
11
  const _interopDefault = e => e && e.__esModule ? e : { default: e };
12
12
 
@@ -41,10 +41,7 @@ async function createWorkspaceCommand(opts) {
41
41
  fsExtra.copy(path__default.default.join(wsTemplatesDir, 'yarn-releases', 'yarn-4.5.1.cjs'), path__default.default.join(home, '.yarn', 'releases', 'yarn-4.5.1.cjs')),
42
42
  ]);
43
43
  util_logger.info(`setting up your Z2H workspace — this may take a minute...`);
44
- await execa.execa('yarn', ['install'], {
45
- cwd: home,
46
- stdio: 'inherit',
47
- });
44
+ await util_npm_install.runYarnInstall({ cwd: home });
48
45
  util_logger.output(`Your workspace is ready! 🚀 Apps will live at ${home}`, {
49
46
  ok: true,
50
47
  workspace: home,
@@ -1 +1 @@
1
- {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/commands/create.ts"],"names":[],"mappings":"AAWA,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AA6BD,wBAAsB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAqFvF"}
1
+ {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/commands/create.ts"],"names":[],"mappings":"AAWA,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AA6BD,wBAAsB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAkFvF"}
@@ -3,13 +3,13 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
3
3
  const path = require('node:path');
4
4
  const promises = require('node:fs/promises');
5
5
  const fsExtra = require('fs-extra');
6
- const execa = require('execa');
7
6
  const util_logger = require('../util/logger.js');
8
7
  const util_workspace = require('../util/workspace.js');
9
8
  const util_templates = require('../util/templates.js');
10
9
  const util_manifest = require('../util/manifest.js');
11
10
  const util_appName = require('../util/app-name.js');
12
11
  const constants = require('../constants.js');
12
+ const util_npm_install = require('../util/npm/install.js');
13
13
 
14
14
  const _interopDefault = e => e && e.__esModule ? e : { default: e };
15
15
 
@@ -96,10 +96,7 @@ async function createCommand(appName, opts) {
96
96
  await fsExtra.copy(opts.htmlFile, path__default.default.join(appDir, 'src', 'page.html'));
97
97
  }
98
98
  util_logger.info(`installing dependencies for ${appName}...`);
99
- await execa.execa('yarn', ['install'], {
100
- cwd: workspace,
101
- stdio: 'inherit',
102
- });
99
+ await util_npm_install.runYarnInstall({ cwd: workspace });
103
100
  util_logger.output(`[z2h-cli] app ready at ${appDir}`, {
104
101
  ok: true,
105
102
  appDir,
@@ -16,4 +16,22 @@ export declare const BUCKET_READ_DNS_URL = "https://bigbrain-zth-mf-assets.bigbr
16
16
  export declare const MANIFEST_KEY = "mf-assets";
17
17
  export declare const MANIFEST_READ_URL = "https://bigbrain-zth-mf-assets.bigbrain.me/mf-assets";
18
18
  export declare const APP_NAME_PATTERN: RegExp;
19
+ export declare const DEFAULT_BROKER_BASE_URL = "https://bigbrain-zth.bigbrain.me";
20
+ /**
21
+ * Resolves the broker origin (no trailing slash). Honors
22
+ * `Z2H_BROKER_BASE_URL` (tests/staging), else the prod default. Shared by the
23
+ * STS credential provider and the npm-broker registry URL.
24
+ */
25
+ export declare function brokerBaseUrl(): string;
26
+ export declare const NPM_BROKER_PATH = "/z2h-cli/npm";
27
+ export declare const BROKER_NPM_SCOPE = "@mondaydotcomorg";
28
+ export declare const PUBLIC_NPM_REGISTRY_URL = "https://registry.npmjs.org/";
29
+ export declare const Z2H_NPM_TOKEN_ENV: "Z2H_NPM_TOKEN";
30
+ /**
31
+ * Broker npm registry URL (no trailing slash), e.g. prod
32
+ * `https://bigbrain-zth.bigbrain.me/z2h-cli/npm`. Built on `brokerBaseUrl()`
33
+ * so the staging override flows through. The trailing-slash forms required by
34
+ * the `.npmrc`/`.yarnrc.yml` configs are added where those files are written.
35
+ */
36
+ export declare function brokerNpmRegistryUrl(): string;
19
37
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,eAAO,MAAM,eAAe,SAAS,CAAC;AAGtC,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAGjD,CAAC;AAQF,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAElD,CAAC;AAMF,eAAO,MAAM,QAAQ,QAAQ,CAAC;AAC9B,eAAO,MAAM,QAAQ,QAAQ,CAAC;AAG9B,eAAO,MAAM,iBAAiB,UAAY,CAAC;AAQ3C,eAAO,MAAM,iBAAiB,qCAAqC,CAAC;AACpE,eAAO,MAAM,MAAM,cAAc,CAAC;AAClC,eAAO,MAAM,gBAAgB,wEAA4D,CAAC;AAE1F,eAAO,MAAM,oBAAoB,2BAA2B,CAAC;AAC7D,eAAO,MAAM,mBAAmB,+CAAgD,CAAC;AAKjF,eAAO,MAAM,YAAY,cAAc,CAAC;AACxC,eAAO,MAAM,iBAAiB,yDAA2C,CAAC;AAM1E,eAAO,MAAM,gBAAgB,QAA2B,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,eAAO,MAAM,eAAe,SAAS,CAAC;AAGtC,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAGjD,CAAC;AAQF,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAElD,CAAC;AAMF,eAAO,MAAM,QAAQ,QAAQ,CAAC;AAC9B,eAAO,MAAM,QAAQ,QAAQ,CAAC;AAG9B,eAAO,MAAM,iBAAiB,UAAY,CAAC;AAQ3C,eAAO,MAAM,iBAAiB,qCAAqC,CAAC;AACpE,eAAO,MAAM,MAAM,cAAc,CAAC;AAClC,eAAO,MAAM,gBAAgB,wEAA4D,CAAC;AAE1F,eAAO,MAAM,oBAAoB,2BAA2B,CAAC;AAC7D,eAAO,MAAM,mBAAmB,+CAAgD,CAAC;AAKjF,eAAO,MAAM,YAAY,cAAc,CAAC;AACxC,eAAO,MAAM,iBAAiB,yDAA2C,CAAC;AAM1E,eAAO,MAAM,gBAAgB,QAA2B,CAAC;AAKzD,eAAO,MAAM,uBAAuB,qCAAqC,CAAC;AAE1E;;;;GAIG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAKD,eAAO,MAAM,eAAe,iBAAiB,CAAC;AAG9C,eAAO,MAAM,gBAAgB,qBAAqB,CAAC;AAGnD,eAAO,MAAM,uBAAuB,gCAAgC,CAAC;AAMrE,eAAO,MAAM,iBAAiB,EAAG,eAAwB,CAAC;AAE1D;;;;;GAKG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAE7C"}
package/dist/constants.js CHANGED
@@ -48,18 +48,59 @@ const MANIFEST_READ_URL = `${BUCKET_READ_DNS_URL}/${MANIFEST_KEY}`;
48
48
  // backend STS broker rejects anything else with 400; the CLI can validate
49
49
  // upfront for friendlier errors.
50
50
  const APP_NAME_PATTERN = /^[a-z][a-z0-9-]{1,49}$/;
51
+ // ─────────── Broker origin + npm registry (shared §3 contract) ─────
52
+ // The bigbrain-zth broker fronts both the STS credential route and the npm
53
+ // proxy. `Z2H_BROKER_BASE_URL` overrides the origin for tests/staging.
54
+ const DEFAULT_BROKER_BASE_URL = 'https://bigbrain-zth.bigbrain.me';
55
+ /**
56
+ * Resolves the broker origin (no trailing slash). Honors
57
+ * `Z2H_BROKER_BASE_URL` (tests/staging), else the prod default. Shared by the
58
+ * STS credential provider and the npm-broker registry URL.
59
+ */
60
+ function brokerBaseUrl() {
61
+ return process.env.Z2H_BROKER_BASE_URL || DEFAULT_BROKER_BASE_URL;
62
+ }
63
+ // The authenticated npm reverse-proxy is mounted here on the broker. Only the
64
+ // `@mondaydotcomorg` scope is served; everything else resolves from npmjs
65
+ // directly. See docs/superpowers/specs/2026-06-03-npm-brokering-design.md §3.
66
+ const NPM_BROKER_PATH = '/z2h-cli/npm';
67
+ // The scope brokered through the proxy — the ONLY scope it serves.
68
+ const BROKER_NPM_SCOPE = '@mondaydotcomorg';
69
+ // Public registry for everything outside the brokered scope (unchanged speed).
70
+ const PUBLIC_NPM_REGISTRY_URL = 'https://registry.npmjs.org/';
71
+ // Env var the client config (`~/.npmrc`, `.yarnrc.yml`) interpolates at
72
+ // invocation time; its value is the z2h JWT, injected per-spawn by the CLI.
73
+ // Deliberately NOT `NPM_TOKEN` — avoids colliding with the monorepo's own dev
74
+ // token and makes clear it is the z2h JWT, not a real npm token.
75
+ const Z2H_NPM_TOKEN_ENV = 'Z2H_NPM_TOKEN';
76
+ /**
77
+ * Broker npm registry URL (no trailing slash), e.g. prod
78
+ * `https://bigbrain-zth.bigbrain.me/z2h-cli/npm`. Built on `brokerBaseUrl()`
79
+ * so the staging override flows through. The trailing-slash forms required by
80
+ * the `.npmrc`/`.yarnrc.yml` configs are added where those files are written.
81
+ */
82
+ function brokerNpmRegistryUrl() {
83
+ return `${brokerBaseUrl()}${NPM_BROKER_PATH}`;
84
+ }
51
85
 
52
86
  exports.APP_NAME_PATTERN = APP_NAME_PATTERN;
87
+ exports.BROKER_NPM_SCOPE = BROKER_NPM_SCOPE;
53
88
  exports.BUCKET_READ_DNS_NAME = BUCKET_READ_DNS_NAME;
54
89
  exports.BUCKET_READ_DNS_URL = BUCKET_READ_DNS_URL;
55
90
  exports.BUCKET_WRITE_NAME = BUCKET_WRITE_NAME;
56
91
  exports.BUCKET_WRITE_URL = BUCKET_WRITE_URL;
92
+ exports.DEFAULT_BROKER_BASE_URL = DEFAULT_BROKER_BASE_URL;
57
93
  exports.GITIGNORE_ENTRIES = GITIGNORE_ENTRIES;
58
94
  exports.MANIFEST_KEY = MANIFEST_KEY;
59
95
  exports.MANIFEST_READ_URL = MANIFEST_READ_URL;
60
96
  exports.MAX_PORT = MAX_PORT;
61
97
  exports.MIN_PORT = MIN_PORT;
98
+ exports.NPM_BROKER_PATH = NPM_BROKER_PATH;
99
+ exports.PUBLIC_NPM_REGISTRY_URL = PUBLIC_NPM_REGISTRY_URL;
62
100
  exports.REGION = REGION;
63
101
  exports.SHADOW_DEV_DEPS = SHADOW_DEV_DEPS;
64
102
  exports.SHADOW_DIR_NAME = SHADOW_DIR_NAME;
65
103
  exports.SHADOW_SCRIPTS = SHADOW_SCRIPTS;
104
+ exports.Z2H_NPM_TOKEN_ENV = Z2H_NPM_TOKEN_ENV;
105
+ exports.brokerBaseUrl = brokerBaseUrl;
106
+ exports.brokerNpmRegistryUrl = brokerNpmRegistryUrl;
@@ -1 +1 @@
1
- {"version":3,"file":"create-workspace.d.ts","sourceRoot":"","sources":["../../../src/commands/create-workspace.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,sBAAsB;IACrC,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,wBAAsB,sBAAsB,CAAC,IAAI,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CA6CxF"}
1
+ {"version":3,"file":"create-workspace.d.ts","sourceRoot":"","sources":["../../../src/commands/create-workspace.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,sBAAsB;IACrC,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,wBAAsB,sBAAsB,CAAC,IAAI,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CA0CxF"}
@@ -1,10 +1,10 @@
1
1
  import path from 'node:path';
2
2
  import { readFile } from 'node:fs/promises';
3
3
  import { pathExists, readdir, ensureDir, writeFile, copy } from 'fs-extra';
4
- import { execa } from 'execa';
5
4
  import { setOutputMode, info, output } from '../util/logger.mjs';
6
5
  import { getWorkspaceHome } from '../util/workspace.mjs';
7
6
  import { getTemplatesDir } from '../util/templates.mjs';
7
+ import { runYarnInstall } from '../util/npm/install.mjs';
8
8
 
9
9
  async function createWorkspaceCommand(opts) {
10
10
  if (opts.json) {
@@ -35,10 +35,7 @@ async function createWorkspaceCommand(opts) {
35
35
  copy(path.join(wsTemplatesDir, 'yarn-releases', 'yarn-4.5.1.cjs'), path.join(home, '.yarn', 'releases', 'yarn-4.5.1.cjs')),
36
36
  ]);
37
37
  info(`setting up your Z2H workspace — this may take a minute...`);
38
- await execa('yarn', ['install'], {
39
- cwd: home,
40
- stdio: 'inherit',
41
- });
38
+ await runYarnInstall({ cwd: home });
42
39
  output(`Your workspace is ready! 🚀 Apps will live at ${home}`, {
43
40
  ok: true,
44
41
  workspace: home,
@@ -1 +1 @@
1
- {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/commands/create.ts"],"names":[],"mappings":"AAWA,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AA6BD,wBAAsB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAqFvF"}
1
+ {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/commands/create.ts"],"names":[],"mappings":"AAWA,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AA6BD,wBAAsB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAkFvF"}
@@ -1,13 +1,13 @@
1
1
  import path from 'node:path';
2
2
  import { readFile } from 'node:fs/promises';
3
3
  import { pathExists, ensureDir, writeFile, copy, readdir } from 'fs-extra';
4
- import { execa } from 'execa';
5
4
  import { setOutputMode, info, output } from '../util/logger.mjs';
6
5
  import { assertWorkspace } from '../util/workspace.mjs';
7
6
  import { APP_TEMPLATES, getTemplatesDir, renderTemplate } from '../util/templates.mjs';
8
7
  import { readManifest } from '../util/manifest.mjs';
9
8
  import { mfAppName } from '../util/app-name.mjs';
10
9
  import { APP_NAME_PATTERN } from '../constants.mjs';
10
+ import { runYarnInstall } from '../util/npm/install.mjs';
11
11
 
12
12
  // Names reserved by the host MF (mf-bigbrain-zth) for platform pages under
13
13
  // /bigbrain-vibe/<name>. Creating an app with one of these would shadow the
@@ -90,10 +90,7 @@ async function createCommand(appName, opts) {
90
90
  await copy(opts.htmlFile, path.join(appDir, 'src', 'page.html'));
91
91
  }
92
92
  info(`installing dependencies for ${appName}...`);
93
- await execa('yarn', ['install'], {
94
- cwd: workspace,
95
- stdio: 'inherit',
96
- });
93
+ await runYarnInstall({ cwd: workspace });
97
94
  output(`[z2h-cli] app ready at ${appDir}`, {
98
95
  ok: true,
99
96
  appDir,
@@ -16,4 +16,22 @@ export declare const BUCKET_READ_DNS_URL = "https://bigbrain-zth-mf-assets.bigbr
16
16
  export declare const MANIFEST_KEY = "mf-assets";
17
17
  export declare const MANIFEST_READ_URL = "https://bigbrain-zth-mf-assets.bigbrain.me/mf-assets";
18
18
  export declare const APP_NAME_PATTERN: RegExp;
19
+ export declare const DEFAULT_BROKER_BASE_URL = "https://bigbrain-zth.bigbrain.me";
20
+ /**
21
+ * Resolves the broker origin (no trailing slash). Honors
22
+ * `Z2H_BROKER_BASE_URL` (tests/staging), else the prod default. Shared by the
23
+ * STS credential provider and the npm-broker registry URL.
24
+ */
25
+ export declare function brokerBaseUrl(): string;
26
+ export declare const NPM_BROKER_PATH = "/z2h-cli/npm";
27
+ export declare const BROKER_NPM_SCOPE = "@mondaydotcomorg";
28
+ export declare const PUBLIC_NPM_REGISTRY_URL = "https://registry.npmjs.org/";
29
+ export declare const Z2H_NPM_TOKEN_ENV: "Z2H_NPM_TOKEN";
30
+ /**
31
+ * Broker npm registry URL (no trailing slash), e.g. prod
32
+ * `https://bigbrain-zth.bigbrain.me/z2h-cli/npm`. Built on `brokerBaseUrl()`
33
+ * so the staging override flows through. The trailing-slash forms required by
34
+ * the `.npmrc`/`.yarnrc.yml` configs are added where those files are written.
35
+ */
36
+ export declare function brokerNpmRegistryUrl(): string;
19
37
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,eAAO,MAAM,eAAe,SAAS,CAAC;AAGtC,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAGjD,CAAC;AAQF,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAElD,CAAC;AAMF,eAAO,MAAM,QAAQ,QAAQ,CAAC;AAC9B,eAAO,MAAM,QAAQ,QAAQ,CAAC;AAG9B,eAAO,MAAM,iBAAiB,UAAY,CAAC;AAQ3C,eAAO,MAAM,iBAAiB,qCAAqC,CAAC;AACpE,eAAO,MAAM,MAAM,cAAc,CAAC;AAClC,eAAO,MAAM,gBAAgB,wEAA4D,CAAC;AAE1F,eAAO,MAAM,oBAAoB,2BAA2B,CAAC;AAC7D,eAAO,MAAM,mBAAmB,+CAAgD,CAAC;AAKjF,eAAO,MAAM,YAAY,cAAc,CAAC;AACxC,eAAO,MAAM,iBAAiB,yDAA2C,CAAC;AAM1E,eAAO,MAAM,gBAAgB,QAA2B,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,eAAO,MAAM,eAAe,SAAS,CAAC;AAGtC,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAGjD,CAAC;AAQF,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAElD,CAAC;AAMF,eAAO,MAAM,QAAQ,QAAQ,CAAC;AAC9B,eAAO,MAAM,QAAQ,QAAQ,CAAC;AAG9B,eAAO,MAAM,iBAAiB,UAAY,CAAC;AAQ3C,eAAO,MAAM,iBAAiB,qCAAqC,CAAC;AACpE,eAAO,MAAM,MAAM,cAAc,CAAC;AAClC,eAAO,MAAM,gBAAgB,wEAA4D,CAAC;AAE1F,eAAO,MAAM,oBAAoB,2BAA2B,CAAC;AAC7D,eAAO,MAAM,mBAAmB,+CAAgD,CAAC;AAKjF,eAAO,MAAM,YAAY,cAAc,CAAC;AACxC,eAAO,MAAM,iBAAiB,yDAA2C,CAAC;AAM1E,eAAO,MAAM,gBAAgB,QAA2B,CAAC;AAKzD,eAAO,MAAM,uBAAuB,qCAAqC,CAAC;AAE1E;;;;GAIG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAKD,eAAO,MAAM,eAAe,iBAAiB,CAAC;AAG9C,eAAO,MAAM,gBAAgB,qBAAqB,CAAC;AAGnD,eAAO,MAAM,uBAAuB,gCAAgC,CAAC;AAMrE,eAAO,MAAM,iBAAiB,EAAG,eAAwB,CAAC;AAE1D;;;;;GAKG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAE7C"}
@@ -46,5 +46,39 @@ const MANIFEST_READ_URL = `${BUCKET_READ_DNS_URL}/${MANIFEST_KEY}`;
46
46
  // backend STS broker rejects anything else with 400; the CLI can validate
47
47
  // upfront for friendlier errors.
48
48
  const APP_NAME_PATTERN = /^[a-z][a-z0-9-]{1,49}$/;
49
+ // ─────────── Broker origin + npm registry (shared §3 contract) ─────
50
+ // The bigbrain-zth broker fronts both the STS credential route and the npm
51
+ // proxy. `Z2H_BROKER_BASE_URL` overrides the origin for tests/staging.
52
+ const DEFAULT_BROKER_BASE_URL = 'https://bigbrain-zth.bigbrain.me';
53
+ /**
54
+ * Resolves the broker origin (no trailing slash). Honors
55
+ * `Z2H_BROKER_BASE_URL` (tests/staging), else the prod default. Shared by the
56
+ * STS credential provider and the npm-broker registry URL.
57
+ */
58
+ function brokerBaseUrl() {
59
+ return process.env.Z2H_BROKER_BASE_URL || DEFAULT_BROKER_BASE_URL;
60
+ }
61
+ // The authenticated npm reverse-proxy is mounted here on the broker. Only the
62
+ // `@mondaydotcomorg` scope is served; everything else resolves from npmjs
63
+ // directly. See docs/superpowers/specs/2026-06-03-npm-brokering-design.md §3.
64
+ const NPM_BROKER_PATH = '/z2h-cli/npm';
65
+ // The scope brokered through the proxy — the ONLY scope it serves.
66
+ const BROKER_NPM_SCOPE = '@mondaydotcomorg';
67
+ // Public registry for everything outside the brokered scope (unchanged speed).
68
+ const PUBLIC_NPM_REGISTRY_URL = 'https://registry.npmjs.org/';
69
+ // Env var the client config (`~/.npmrc`, `.yarnrc.yml`) interpolates at
70
+ // invocation time; its value is the z2h JWT, injected per-spawn by the CLI.
71
+ // Deliberately NOT `NPM_TOKEN` — avoids colliding with the monorepo's own dev
72
+ // token and makes clear it is the z2h JWT, not a real npm token.
73
+ const Z2H_NPM_TOKEN_ENV = 'Z2H_NPM_TOKEN';
74
+ /**
75
+ * Broker npm registry URL (no trailing slash), e.g. prod
76
+ * `https://bigbrain-zth.bigbrain.me/z2h-cli/npm`. Built on `brokerBaseUrl()`
77
+ * so the staging override flows through. The trailing-slash forms required by
78
+ * the `.npmrc`/`.yarnrc.yml` configs are added where those files are written.
79
+ */
80
+ function brokerNpmRegistryUrl() {
81
+ return `${brokerBaseUrl()}${NPM_BROKER_PATH}`;
82
+ }
49
83
 
50
- export { APP_NAME_PATTERN, BUCKET_READ_DNS_NAME, BUCKET_READ_DNS_URL, BUCKET_WRITE_NAME, BUCKET_WRITE_URL, GITIGNORE_ENTRIES, MANIFEST_KEY, MANIFEST_READ_URL, MAX_PORT, MIN_PORT, REGION, SHADOW_DEV_DEPS, SHADOW_DIR_NAME, SHADOW_SCRIPTS };
84
+ export { APP_NAME_PATTERN, BROKER_NPM_SCOPE, BUCKET_READ_DNS_NAME, BUCKET_READ_DNS_URL, BUCKET_WRITE_NAME, BUCKET_WRITE_URL, DEFAULT_BROKER_BASE_URL, GITIGNORE_ENTRIES, MANIFEST_KEY, MANIFEST_READ_URL, MAX_PORT, MIN_PORT, NPM_BROKER_PATH, PUBLIC_NPM_REGISTRY_URL, REGION, SHADOW_DEV_DEPS, SHADOW_DIR_NAME, SHADOW_SCRIPTS, Z2H_NPM_TOKEN_ENV, brokerBaseUrl, brokerNpmRegistryUrl };
@@ -1,4 +1,5 @@
1
1
  import { createRequire } from 'node:module';
2
+ import { readFileSync } from 'node:fs';
2
3
  import { Command } from 'commander';
3
4
  import { devCommand } from './commands/dev.mjs';
4
5
  import { buildCommand } from './commands/build.mjs';
@@ -9,8 +10,17 @@ import { createCommand } from './commands/create.mjs';
9
10
  import { generateZ2HTokenCommand } from './commands/generate-z2h-token.mjs';
10
11
  import { migrateCommand } from './commands/migrate.mjs';
11
12
  import { errorLog, fail } from './util/logger.mjs';
13
+ import { trackDuration } from './util/tracker.mjs';
12
14
 
13
15
  const { version } = createRequire(import.meta.url)('../package.json');
16
+ function getCwdAppName() {
17
+ try {
18
+ return JSON.parse(readFileSync('package.json', 'utf8')).name;
19
+ }
20
+ catch {
21
+ return undefined;
22
+ }
23
+ }
14
24
  async function main() {
15
25
  const program = new Command();
16
26
  program
@@ -34,12 +44,9 @@ async function main() {
34
44
  .option('--json', 'emit structured JSON on stdout')
35
45
  .action(async (opts) => {
36
46
  try {
37
- await buildCommand(opts);
47
+ await trackDuration('z2h_app_build_success', () => buildCommand(opts), { app_name: getCwdAppName() });
38
48
  }
39
49
  catch (err) {
40
- // fail() emits a structured JSON error on stdout in --json mode and
41
- // a red line on stderr in human mode, then exits. errorLog alone is
42
- // silent in JSON mode, which leaves machine consumers with no signal.
43
50
  fail(`build failed: ${err.message}`, { command: 'build' }, 2);
44
51
  }
45
52
  });
@@ -74,7 +81,9 @@ async function main() {
74
81
  .option('--json', 'emit structured JSON on stdout')
75
82
  .action(async (opts) => {
76
83
  try {
77
- await deployCommand(opts);
84
+ await trackDuration('z2h_app_deploy_success', () => deployCommand(opts), {
85
+ app_name: getCwdAppName(),
86
+ });
78
87
  }
79
88
  catch (err) {
80
89
  fail(`deploy failed: ${err.message}`, { command: 'deploy' }, 2);
@@ -114,7 +123,10 @@ async function main() {
114
123
  .option('--json', 'emit structured JSON on stdout')
115
124
  .action(async (appName, opts) => {
116
125
  try {
117
- await createCommand(appName, opts);
126
+ await trackDuration('z2h_app_created', () => createCommand(appName, opts), {
127
+ app_name: appName,
128
+ template: opts.template ?? 'default',
129
+ });
118
130
  }
119
131
  catch (err) {
120
132
  fail(`create failed: ${err.message}`, { command: 'create' }, 1);
@@ -0,0 +1,14 @@
1
+ import type { Tree } from '@nx/devkit';
2
+ /**
3
+ * Migrate the workspace npm/yarn config from the legacy single-registry
4
+ * `${NPM_TOKEN}` form to the `@mondaydotcomorg`→broker scope-split
5
+ * (`${Z2H_NPM_TOKEN}` placeholder). Rewrites the workspace-root `.yarnrc.yml`
6
+ * and `.npmrc`, plus any consumer-app copies that still carry the legacy
7
+ * placeholder (migration 001 normally removes per-consumer `.yarnrc.yml`, so
8
+ * this is just defensive cleanup).
9
+ *
10
+ * The global `~/.npmrc` broker block is written separately by `migrateCommand`
11
+ * (it lives outside the workspace Tree).
12
+ */
13
+ export default function npmBrokerScopeSplit(tree: Tree): void;
14
+ //# sourceMappingURL=003-npm-broker-scope-split.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"003-npm-broker-scope-split.d.ts","sourceRoot":"","sources":["../../../src/migrations/003-npm-broker-scope-split.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAuBvC;;;;;;;;;;GAUG;AACH,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAgB5D"}
@@ -0,0 +1,49 @@
1
+ import { workspaceYarnrcContents, workspaceNpmrcContents } from '../util/npm/broker-config.mjs';
2
+
3
+ // Legacy marker: the old configs interpolated a real npm token via
4
+ // `${NPM_TOKEN}`. Its presence means the file predates npm brokering and must
5
+ // be rewritten to the scope-split. Once rewritten (placeholder is now
6
+ // `${Z2H_NPM_TOKEN}`) this no longer matches, so the migration is idempotent.
7
+ const LEGACY_TOKEN_PLACEHOLDER = '${NPM_TOKEN}';
8
+ /**
9
+ * Rewrite a single rc file to `contents` iff it exists and still carries the
10
+ * legacy `${NPM_TOKEN}` placeholder. Returns nothing; mutates the Tree.
11
+ */
12
+ function rewriteIfLegacy(tree, filePath, contents) {
13
+ if (!tree.exists(filePath)) {
14
+ return;
15
+ }
16
+ const current = tree.read(filePath, 'utf-8') ?? '';
17
+ if (!current.includes(LEGACY_TOKEN_PLACEHOLDER)) {
18
+ return; // already migrated (or never legacy) — leave untouched
19
+ }
20
+ tree.write(filePath, contents);
21
+ }
22
+ /**
23
+ * Migrate the workspace npm/yarn config from the legacy single-registry
24
+ * `${NPM_TOKEN}` form to the `@mondaydotcomorg`→broker scope-split
25
+ * (`${Z2H_NPM_TOKEN}` placeholder). Rewrites the workspace-root `.yarnrc.yml`
26
+ * and `.npmrc`, plus any consumer-app copies that still carry the legacy
27
+ * placeholder (migration 001 normally removes per-consumer `.yarnrc.yml`, so
28
+ * this is just defensive cleanup).
29
+ *
30
+ * The global `~/.npmrc` broker block is written separately by `migrateCommand`
31
+ * (it lives outside the workspace Tree).
32
+ */
33
+ function npmBrokerScopeSplit(tree) {
34
+ const yarnrc = workspaceYarnrcContents();
35
+ const npmrc = workspaceNpmrcContents();
36
+ // Workspace root.
37
+ rewriteIfLegacy(tree, '.yarnrc.yml', yarnrc);
38
+ rewriteIfLegacy(tree, '.npmrc', npmrc);
39
+ // Any consumer apps that still carry their own legacy rc files.
40
+ for (const entry of tree.children('.')) {
41
+ if (entry.startsWith('.')) {
42
+ continue;
43
+ }
44
+ rewriteIfLegacy(tree, `${entry}/.yarnrc.yml`, yarnrc);
45
+ rewriteIfLegacy(tree, `${entry}/.npmrc`, npmrc);
46
+ }
47
+ }
48
+
49
+ export { npmBrokerScopeSplit as default };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=003-npm-broker-scope-split.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"003-npm-broker-scope-split.test.d.ts","sourceRoot":"","sources":["../../../../src/migrations/__tests__/003-npm-broker-scope-split.test.ts"],"names":[],"mappings":""}
@@ -4,7 +4,7 @@ import { fileURLToPath } from 'node:url';
4
4
  import { pathExists, readJson, writeJson, writeFile } from 'fs-extra';
5
5
  import { execa } from 'execa';
6
6
  import semver from 'semver';
7
- import { warn, info } from '../util/logger.mjs';
7
+ import { warn, info, errorLog } from '../util/logger.mjs';
8
8
  import { getWorkspaceHome, isZ2hWorkspace } from '../util/workspace.mjs';
9
9
 
10
10
  const STATE_FILE = '.z2h-migrations-state.json';
@@ -151,9 +151,9 @@ async function autoMigrate(cliVersion, dryRun = false) {
151
151
  }
152
152
  }
153
153
  catch (err) {
154
- warn(` ✗ migration "${name}" failed: ${err.message}`);
155
- warn(' skipping remaining migrations. Run "z2h-cli migrate" to retry.');
156
- return;
154
+ const errorMessage = `migration "${name}" failed: ${err.message}`;
155
+ errorLog(`${errorMessage}\nSkipping remaining migrations — run "z2h-cli migrate" to retry.`);
156
+ throw new Error(errorMessage);
157
157
  }
158
158
  }
159
159
  if (needsInstall) {
@@ -1 +1 @@
1
- {"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../../src/shadow/sync.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE3D;;;;;GAKG;AACH,wBAAsB,UAAU,CAAC,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAiB9F"}
1
+ {"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../../src/shadow/sync.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE3D;;;;;GAKG;AACH,wBAAsB,UAAU,CAAC,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAe9F"}
@@ -1,6 +1,6 @@
1
1
  import { pathExists, readFile, writeFile } from 'fs-extra';
2
- import { execa } from 'execa';
3
2
  import { info } from '../util/logger.mjs';
3
+ import { runYarnInstall } from '../util/npm/install.mjs';
4
4
  import { buildShadowPkg, writeShadowPkg, hashConsumerDeps } from './merge-package-json.mjs';
5
5
 
6
6
  /**
@@ -17,11 +17,9 @@ async function syncShadow(paths, consumerPkg) {
17
17
  if (oldHash !== newHash) {
18
18
  info(oldHash ? 'consumer deps changed — yarn install' : 'first run — yarn install');
19
19
  // Yarn 4 is cache-first and non-interactive by default in non-TTY
20
- // contexts, so plain `yarn install` is all we need.
21
- await execa('yarn', ['install'], {
22
- cwd: paths.consumerDir,
23
- stdio: 'inherit',
24
- });
20
+ // contexts, so plain `yarn install` is all we need. runYarnInstall injects
21
+ // the npm-broker token, preflights auth, and re-auths on a broker 401.
22
+ await runYarnInstall({ cwd: paths.consumerDir });
25
23
  await writeFile(paths.shadowDepsHash, newHash);
26
24
  }
27
25
  }
@@ -8,4 +8,14 @@ export declare class Z2hAuthMissingError extends Error {
8
8
  constructor(authFilePath: string);
9
9
  }
10
10
  export declare function readZthAuth(): Promise<ZthAuth>;
11
+ /**
12
+ * Synchronous, never-throws read of the z2h JWT from `~/.zth/auth.json`.
13
+ * Returns the token string, or `null` when the file is absent, unreadable,
14
+ * malformed, or missing the `token` field.
15
+ *
16
+ * Used when building the env for a spawned package-manager process, where a
17
+ * missing token must degrade gracefully (best-effort self-update) rather than
18
+ * blow up — and where an inline sync read keeps the spawn call site simple.
19
+ */
20
+ export declare function tryReadAuthTokenSync(): string | null;
11
21
  //# sourceMappingURL=auth-store.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth-store.d.ts","sourceRoot":"","sources":["../../../../src/util/auth/auth-store.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,YAAY,QAAkC,CAAC;AAC5D,eAAO,MAAM,aAAa,QAAuC,CAAC;AAElE,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,qBAAa,mBAAoB,SAAQ,KAAK;aAChB,YAAY,EAAE,MAAM;gBAApB,YAAY,EAAE,MAAM;CAIjD;AAED,wBAAsB,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC,CASpD"}
1
+ {"version":3,"file":"auth-store.d.ts","sourceRoot":"","sources":["../../../../src/util/auth/auth-store.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,YAAY,QAAkC,CAAC;AAC5D,eAAO,MAAM,aAAa,QAAuC,CAAC;AAElE,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,qBAAa,mBAAoB,SAAQ,KAAK;aAChB,YAAY,EAAE,MAAM;gBAApB,YAAY,EAAE,MAAM;CAIjD;AAED,wBAAsB,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC,CASpD;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,GAAG,IAAI,CAOpD"}
@@ -1,6 +1,6 @@
1
1
  import path from 'node:path';
2
2
  import os from 'node:os';
3
- import { pathExists, readJson } from 'fs-extra';
3
+ import { pathExists, readJson, readJsonSync } from 'fs-extra';
4
4
 
5
5
  // npm-style convention: per-user config under ~/.zth (mirrors ~/.npmrc, ~/.aws/).
6
6
  // Kept out of the workspace dir so accidental `git init` in ~/zth-projects can't
@@ -25,5 +25,23 @@ async function readZthAuth() {
25
25
  }
26
26
  return { token: parsed.token };
27
27
  }
28
+ /**
29
+ * Synchronous, never-throws read of the z2h JWT from `~/.zth/auth.json`.
30
+ * Returns the token string, or `null` when the file is absent, unreadable,
31
+ * malformed, or missing the `token` field.
32
+ *
33
+ * Used when building the env for a spawned package-manager process, where a
34
+ * missing token must degrade gracefully (best-effort self-update) rather than
35
+ * blow up — and where an inline sync read keeps the spawn call site simple.
36
+ */
37
+ function tryReadAuthTokenSync() {
38
+ try {
39
+ const parsed = readJsonSync(Z2H_AUTH_FILE);
40
+ return parsed?.token ?? null;
41
+ }
42
+ catch {
43
+ return null;
44
+ }
45
+ }
28
46
 
29
- export { Z2H_AUTH_DIR, Z2H_AUTH_FILE, Z2hAuthMissingError, readZthAuth };
47
+ export { Z2H_AUTH_DIR, Z2H_AUTH_FILE, Z2hAuthMissingError, readZthAuth, tryReadAuthTokenSync };
@@ -1,5 +1,4 @@
1
1
  import type { AwsCredentialIdentityProvider } from '@aws-sdk/types';
2
- export declare const DEFAULT_BROKER_BASE_URL = "https://bigbrain-zth.bigbrain.me";
3
2
  export declare const STS_BROKER_PATH = "/z2h-cli/sts/credentials";
4
3
  /**
5
4
  * AWS SDK credential provider that fetches short-lived deploy credentials
@@ -1 +1 @@
1
- {"version":3,"file":"broker-credential-provider.d.ts","sourceRoot":"","sources":["../../../../src/util/auth/broker-credential-provider.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAyB,6BAA6B,EAAE,MAAM,gBAAgB,CAAC;AAE3F,eAAO,MAAM,uBAAuB,qCAAqC,CAAC;AAC1E,eAAO,MAAM,eAAe,6BAA6B,CAAC;AA4D1D;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,EAAE,OAAO,EAAE,EAAE;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG,6BAA6B,CAuBxG"}
1
+ {"version":3,"file":"broker-credential-provider.d.ts","sourceRoot":"","sources":["../../../../src/util/auth/broker-credential-provider.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAyB,6BAA6B,EAAE,MAAM,gBAAgB,CAAC;AAE3F,eAAO,MAAM,eAAe,6BAA6B,CAAC;AAwD1D;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,EAAE,OAAO,EAAE,EAAE;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG,6BAA6B,CAuBxG"}
@@ -1,13 +1,10 @@
1
+ import { brokerBaseUrl } from '../../constants.mjs';
1
2
  import { readZthAuth } from './auth-store.mjs';
2
3
 
3
- const DEFAULT_BROKER_BASE_URL = 'https://bigbrain-zth.bigbrain.me';
4
4
  const STS_BROKER_PATH = '/z2h-cli/sts/credentials';
5
5
  // Refresh the cached credentials this many ms before they expire so the next
6
6
  // AWS API call doesn't race the broker round-trip against a hard expiry.
7
7
  const REFRESH_BUFFER_MS = 5 * 60 * 1000;
8
- function brokerBaseUrl() {
9
- return process.env.Z2H_BROKER_BASE_URL || DEFAULT_BROKER_BASE_URL;
10
- }
11
8
  async function fetchCredentialsOnce(appName) {
12
9
  const { token } = await readZthAuth();
13
10
  const url = `${brokerBaseUrl()}${STS_BROKER_PATH}`;
@@ -73,4 +70,4 @@ function brokerCredentialProvider({ appName }) {
73
70
  };
74
71
  }
75
72
 
76
- export { DEFAULT_BROKER_BASE_URL, STS_BROKER_PATH, brokerCredentialProvider };
73
+ export { STS_BROKER_PATH, brokerCredentialProvider };
@@ -1 +1 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../src/util/logger.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,MAAM,CAAC;AAI1C,wBAAgB,aAAa,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,CAEpD;AAED,wBAAgB,aAAa,IAAI,UAAU,CAE1C;AAED;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAItC;AAED,wBAAgB,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAItC;AAED,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAI1C;AAED;;;GAGG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI,CAMzD;AAED;;;GAGG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,QAAQ,SAAI,GAAG,KAAK,CAU3F"}
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../src/util/logger.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,MAAM,CAAC;AAI1C,wBAAgB,aAAa,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,CAEpD;AAED,wBAAgB,aAAa,IAAI,UAAU,CAE1C;AAED;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAItC;AAED,wBAAgB,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAItC;AAED,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAI1C;AAED;;;GAGG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI,CAMzD;AAED;;;GAGG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,QAAQ,SAAI,GAAG,KAAK,CAW3F"}
@@ -1,4 +1,5 @@
1
1
  import pc from 'picocolors';
2
+ import { trackEvent } from './tracker.mjs';
2
3
 
3
4
  let mode = 'human';
4
5
  function setOutputMode(next) {
@@ -53,6 +54,7 @@ function fail(message, payload, exitCode = 1) {
53
54
  process.stderr.write(pc.dim(` → ${payload.suggestedCommand}\n`));
54
55
  }
55
56
  }
57
+ trackEvent('z2h_cli_error', { action: payload.command ?? 'unknown', error: message });
56
58
  process.exit(exitCode);
57
59
  }
58
60
 
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=broker-config.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"broker-config.test.d.ts","sourceRoot":"","sources":["../../../../../src/util/npm/__tests__/broker-config.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=install.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install.test.d.ts","sourceRoot":"","sources":["../../../../../src/util/npm/__tests__/install.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * The two npm config lines (§3.1 / §3.3) that route the brokered scope to the
3
+ * proxy and supply the `${Z2H_NPM_TOKEN}` placeholder. No literal token — npm
4
+ * interpolates the placeholder from the env at invocation time.
5
+ */
6
+ export declare function brokerNpmrcLines(): string[];
7
+ /**
8
+ * Full contents for a **workspace** `.npmrc` (§3.3): broker scope-split plus an
9
+ * explicit public default registry and always-auth. Used by the template and
10
+ * the migration so both stay byte-identical.
11
+ */
12
+ export declare function workspaceNpmrcContents(): string;
13
+ /**
14
+ * Full contents for a **workspace** `.yarnrc.yml` (§3.2): the brokered scope
15
+ * points at the proxy with the `${Z2H_NPM_TOKEN}` placeholder + always-auth;
16
+ * the default `npmRegistryServer` stays the public registry (direct, unchanged
17
+ * speed). `yarnPath` keeps the bundled Berry release so any `yarn` runs 4.x.
18
+ */
19
+ export declare function workspaceYarnrcContents(): string;
20
+ //# sourceMappingURL=broker-config.d.ts.map