@mondaydotcomorg/z2h-cli 0.4.0 → 0.5.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 (65) hide show
  1. package/dist/commands/create-workspace.d.ts.map +1 -1
  2. package/dist/commands/create-workspace.js +3 -30
  3. package/dist/commands/migrate.d.ts +6 -0
  4. package/dist/commands/migrate.d.ts.map +1 -0
  5. package/dist/commands/migrate.js +13 -0
  6. package/dist/constants.d.ts +0 -1
  7. package/dist/constants.d.ts.map +1 -1
  8. package/dist/constants.js +0 -7
  9. package/dist/esm/commands/create-workspace.d.ts.map +1 -1
  10. package/dist/esm/commands/create-workspace.mjs +5 -32
  11. package/dist/esm/commands/migrate.d.ts +6 -0
  12. package/dist/esm/commands/migrate.d.ts.map +1 -0
  13. package/dist/esm/commands/migrate.mjs +11 -0
  14. package/dist/esm/constants.d.ts +0 -1
  15. package/dist/esm/constants.d.ts.map +1 -1
  16. package/dist/esm/constants.mjs +1 -7
  17. package/dist/esm/index.mjs +14 -0
  18. package/dist/esm/migrations/001-remove-per-consumer-yarnrc.d.ts +3 -0
  19. package/dist/esm/migrations/001-remove-per-consumer-yarnrc.d.ts.map +1 -0
  20. package/dist/esm/migrations/001-remove-per-consumer-yarnrc.mjs +15 -0
  21. package/dist/esm/migrations/002-remove-z2h-cli-from-workspace-deps.d.ts +3 -0
  22. package/dist/esm/migrations/002-remove-z2h-cli-from-workspace-deps.d.ts.map +1 -0
  23. package/dist/esm/migrations/002-remove-z2h-cli-from-workspace-deps.mjs +41 -0
  24. package/dist/esm/migrations/auto-migrate.d.ts +2 -0
  25. package/dist/esm/migrations/auto-migrate.d.ts.map +1 -0
  26. package/dist/esm/migrations/auto-migrate.mjs +166 -0
  27. package/dist/esm/shadow/prepare.d.ts.map +1 -1
  28. package/dist/esm/shadow/prepare.mjs +0 -2
  29. package/dist/esm/templates/workspace/nx.mjs +5 -0
  30. package/dist/index.js +14 -0
  31. package/dist/migrations/001-remove-per-consumer-yarnrc.d.ts +3 -0
  32. package/dist/migrations/001-remove-per-consumer-yarnrc.d.ts.map +1 -0
  33. package/dist/migrations/001-remove-per-consumer-yarnrc.js +17 -0
  34. package/dist/migrations/002-remove-z2h-cli-from-workspace-deps.d.ts +3 -0
  35. package/dist/migrations/002-remove-z2h-cli-from-workspace-deps.d.ts.map +1 -0
  36. package/dist/migrations/002-remove-z2h-cli-from-workspace-deps.js +43 -0
  37. package/dist/migrations/auto-migrate.d.ts +2 -0
  38. package/dist/migrations/auto-migrate.d.ts.map +1 -0
  39. package/dist/migrations/auto-migrate.js +174 -0
  40. package/dist/shadow/prepare.d.ts.map +1 -1
  41. package/dist/shadow/prepare.js +0 -2
  42. package/dist/templates/workspace/nx.js +7 -0
  43. package/migrations.json +14 -0
  44. package/package.json +6 -2
  45. package/src/commands/__tests__/create-workspace.test.ts +2 -4
  46. package/src/commands/__tests__/create.test.ts +0 -1
  47. package/src/commands/create-workspace.ts +5 -33
  48. package/src/commands/migrate.ts +15 -0
  49. package/src/constants.ts +0 -7
  50. package/src/index.ts +14 -0
  51. package/src/migrations/001-remove-per-consumer-yarnrc.ts +15 -0
  52. package/src/migrations/002-remove-z2h-cli-from-workspace-deps.ts +47 -0
  53. package/src/migrations/auto-migrate.ts +214 -0
  54. package/src/shadow/prepare.ts +0 -2
  55. package/src/templates/app/package.json.tmpl +1 -4
  56. package/src/templates/workspace/nx.json +3 -0
  57. package/src/templates/workspace/package.json.tmpl +4 -1
  58. package/src/util/__tests__/workspace-templates-shipped.test.ts +1 -0
  59. package/dist/esm/shadow/yarnrc.d.ts +0 -10
  60. package/dist/esm/shadow/yarnrc.d.ts.map +0 -1
  61. package/dist/esm/shadow/yarnrc.mjs +0 -27
  62. package/dist/shadow/yarnrc.d.ts +0 -10
  63. package/dist/shadow/yarnrc.d.ts.map +0 -1
  64. package/dist/shadow/yarnrc.js +0 -33
  65. package/src/shadow/yarnrc.ts +0 -29
@@ -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;AAiBD,wBAAsB,sBAAsB,CAAC,IAAI,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CA0DxF"}
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"}
@@ -12,20 +12,6 @@ const _interopDefault = e => e && e.__esModule ? e : { default: e };
12
12
 
13
13
  const path__default = /*#__PURE__*/_interopDefault(path);
14
14
 
15
- /**
16
- * Read the current z2h-cli version from its own package.json — the version
17
- * that gets pinned into the workspace's devDependencies. That way the
18
- * workspace's `@mondaydotcomorg/z2h-cli` always matches the version that
19
- * bootstrapped it.
20
- */
21
- async function readCurrentCliVersion() {
22
- // util/templates.ts already locates `<package-root>/src/templates`. The
23
- // package's own package.json sits two levels above templates/.
24
- const templatesDir = util_templates.getTemplatesDir();
25
- const pkgPath = path__default.default.resolve(templatesDir, '..', '..', 'package.json');
26
- const pkg = (await fsExtra.readJson(pkgPath));
27
- return `^${pkg.version}`;
28
- }
29
15
  async function createWorkspaceCommand(opts) {
30
16
  if (opts.json) {
31
17
  util_logger.setOutputMode('json');
@@ -33,7 +19,6 @@ async function createWorkspaceCommand(opts) {
33
19
  const home = util_workspace.getWorkspaceHome();
34
20
  const templatesDir = util_templates.getTemplatesDir();
35
21
  const wsTemplatesDir = path__default.default.join(templatesDir, 'workspace');
36
- // Refuse non-empty target.
37
22
  if (await fsExtra.pathExists(home)) {
38
23
  const entries = await fsExtra.readdir(home);
39
24
  if (entries.length > 0) {
@@ -43,23 +28,12 @@ async function createWorkspaceCommand(opts) {
43
28
  else {
44
29
  await fsExtra.ensureDir(home);
45
30
  }
46
- const [cliVersion, pkgRaw] = await Promise.all([
47
- readCurrentCliVersion(),
48
- promises.readFile(path__default.default.join(wsTemplatesDir, 'package.json.tmpl'), 'utf8'),
49
- ]);
50
- // Sources have plain names (gitignore, yarnrc.yml, nvmrc, npmrc) so they
51
- // aren't interpreted as the active config files of *this* package; we
52
- // rename to dotfiles at the destination.
53
- //
54
- // Yarn berry ships inline at .yarn/releases/. The workspace's .yarnrc.yml
55
- // sets `yarnPath` to point here, so any `yarn` invocation (system classic
56
- // or otherwise) reads the rc, delegates to this binary, and runs as 4.5.1
57
- // — no corepack, no global pin needed. Mirrors how bigbrain-z2h ships its
58
- // own yarn release.
31
+ const pkgRaw = await promises.readFile(path__default.default.join(wsTemplatesDir, 'package.json.tmpl'), 'utf8');
59
32
  await Promise.all([
60
- fsExtra.writeFile(path__default.default.join(home, 'package.json'), util_templates.renderTemplate(pkgRaw, { __Z2H_CLI_VERSION__: cliVersion })),
33
+ fsExtra.writeFile(path__default.default.join(home, 'package.json'), pkgRaw),
61
34
  fsExtra.copy(path__default.default.join(wsTemplatesDir, 'gitignore'), path__default.default.join(home, '.gitignore')),
62
35
  fsExtra.copy(path__default.default.join(wsTemplatesDir, 'yarnrc.yml'), path__default.default.join(home, '.yarnrc.yml')),
36
+ fsExtra.copy(path__default.default.join(wsTemplatesDir, 'nx.json'), path__default.default.join(home, 'nx.json')),
63
37
  fsExtra.copy(path__default.default.join(wsTemplatesDir, 'yarnlock'), path__default.default.join(home, 'yarn.lock')),
64
38
  fsExtra.copy(path__default.default.join(wsTemplatesDir, 'nvmrc'), path__default.default.join(home, '.nvmrc')),
65
39
  fsExtra.copy(path__default.default.join(wsTemplatesDir, 'npmrc'), path__default.default.join(home, '.npmrc')),
@@ -74,7 +48,6 @@ async function createWorkspaceCommand(opts) {
74
48
  util_logger.output(`Your workspace is ready! 🚀 Apps will live at ${home}`, {
75
49
  ok: true,
76
50
  workspace: home,
77
- z2hCliVersion: cliVersion,
78
51
  });
79
52
  }
80
53
 
@@ -0,0 +1,6 @@
1
+ export interface MigrateOptions {
2
+ dryRun?: boolean;
3
+ json?: boolean;
4
+ }
5
+ export declare function migrateCommand(cliVersion: string, opts: MigrateOptions): Promise<void>;
6
+ //# sourceMappingURL=migrate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../../src/commands/migrate.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,wBAAsB,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAM5F"}
@@ -0,0 +1,13 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const util_logger = require('../util/logger.js');
4
+ const migrations_autoMigrate = require('../migrations/auto-migrate.js');
5
+
6
+ async function migrateCommand(cliVersion, opts) {
7
+ if (opts.json) {
8
+ util_logger.setOutputMode('json');
9
+ }
10
+ await migrations_autoMigrate.autoMigrate(cliVersion, opts.dryRun);
11
+ }
12
+
13
+ exports.migrateCommand = migrateCommand;
@@ -8,7 +8,6 @@ export declare const SHADOW_DEV_DEPS: Record<string, string>;
8
8
  export declare const MIN_PORT = 13000;
9
9
  export declare const MAX_PORT = 19999;
10
10
  export declare const GITIGNORE_ENTRIES: string[];
11
- export declare const YARNRC_LINES: string[];
12
11
  export declare const BUCKET_WRITE_NAME = "prod-use1-bigbrain-zth-mf-assets";
13
12
  export declare const REGION = "us-east-1";
14
13
  export declare const BUCKET_WRITE_URL = "https://prod-use1-bigbrain-zth-mf-assets.s3.us-east-1.amazonaws.com";
@@ -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;AAG3C,eAAO,MAAM,YAAY,UAIxB,CAAC;AAQF,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"}
package/dist/constants.js CHANGED
@@ -28,12 +28,6 @@ const MIN_PORT = 13000;
28
28
  const MAX_PORT = 19999;
29
29
  // ─────────── Gitignore entries auto-appended to the consumer's file ────
30
30
  const GITIGNORE_ENTRIES = ['.zth/'];
31
- // ─────────── .yarnrc.yml written to new consumer apps ────
32
- const YARNRC_LINES = [
33
- 'nodeLinker: node-modules',
34
- "npmAuthToken: '${NPM_TOKEN}'",
35
- "npmRegistryServer: 'https://registry.npmjs.org/'",
36
- ];
37
31
  // ─────────── Z2H deploy bucket / contract ─────────
38
32
  // Source of truth for the bucket layout. The CLI uses these when configuring
39
33
  // the S3 client + uploading; bigbrain-zth's STS broker imports them via
@@ -69,4 +63,3 @@ exports.REGION = REGION;
69
63
  exports.SHADOW_DEV_DEPS = SHADOW_DEV_DEPS;
70
64
  exports.SHADOW_DIR_NAME = SHADOW_DIR_NAME;
71
65
  exports.SHADOW_SCRIPTS = SHADOW_SCRIPTS;
72
- exports.YARNRC_LINES = YARNRC_LINES;
@@ -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;AAiBD,wBAAsB,sBAAsB,CAAC,IAAI,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CA0DxF"}
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,25 +1,11 @@
1
1
  import path from 'node:path';
2
2
  import { readFile } from 'node:fs/promises';
3
- import { pathExists, readdir, ensureDir, writeFile, copy, readJson } from 'fs-extra';
3
+ import { pathExists, readdir, ensureDir, writeFile, copy } from 'fs-extra';
4
4
  import { execa } from 'execa';
5
5
  import { setOutputMode, info, output } from '../util/logger.mjs';
6
6
  import { getWorkspaceHome } from '../util/workspace.mjs';
7
- import { getTemplatesDir, renderTemplate } from '../util/templates.mjs';
7
+ import { getTemplatesDir } from '../util/templates.mjs';
8
8
 
9
- /**
10
- * Read the current z2h-cli version from its own package.json — the version
11
- * that gets pinned into the workspace's devDependencies. That way the
12
- * workspace's `@mondaydotcomorg/z2h-cli` always matches the version that
13
- * bootstrapped it.
14
- */
15
- async function readCurrentCliVersion() {
16
- // util/templates.ts already locates `<package-root>/src/templates`. The
17
- // package's own package.json sits two levels above templates/.
18
- const templatesDir = getTemplatesDir();
19
- const pkgPath = path.resolve(templatesDir, '..', '..', 'package.json');
20
- const pkg = (await readJson(pkgPath));
21
- return `^${pkg.version}`;
22
- }
23
9
  async function createWorkspaceCommand(opts) {
24
10
  if (opts.json) {
25
11
  setOutputMode('json');
@@ -27,7 +13,6 @@ async function createWorkspaceCommand(opts) {
27
13
  const home = getWorkspaceHome();
28
14
  const templatesDir = getTemplatesDir();
29
15
  const wsTemplatesDir = path.join(templatesDir, 'workspace');
30
- // Refuse non-empty target.
31
16
  if (await pathExists(home)) {
32
17
  const entries = await readdir(home);
33
18
  if (entries.length > 0) {
@@ -37,23 +22,12 @@ async function createWorkspaceCommand(opts) {
37
22
  else {
38
23
  await ensureDir(home);
39
24
  }
40
- const [cliVersion, pkgRaw] = await Promise.all([
41
- readCurrentCliVersion(),
42
- readFile(path.join(wsTemplatesDir, 'package.json.tmpl'), 'utf8'),
43
- ]);
44
- // Sources have plain names (gitignore, yarnrc.yml, nvmrc, npmrc) so they
45
- // aren't interpreted as the active config files of *this* package; we
46
- // rename to dotfiles at the destination.
47
- //
48
- // Yarn berry ships inline at .yarn/releases/. The workspace's .yarnrc.yml
49
- // sets `yarnPath` to point here, so any `yarn` invocation (system classic
50
- // or otherwise) reads the rc, delegates to this binary, and runs as 4.5.1
51
- // — no corepack, no global pin needed. Mirrors how bigbrain-z2h ships its
52
- // own yarn release.
25
+ const pkgRaw = await readFile(path.join(wsTemplatesDir, 'package.json.tmpl'), 'utf8');
53
26
  await Promise.all([
54
- writeFile(path.join(home, 'package.json'), renderTemplate(pkgRaw, { __Z2H_CLI_VERSION__: cliVersion })),
27
+ writeFile(path.join(home, 'package.json'), pkgRaw),
55
28
  copy(path.join(wsTemplatesDir, 'gitignore'), path.join(home, '.gitignore')),
56
29
  copy(path.join(wsTemplatesDir, 'yarnrc.yml'), path.join(home, '.yarnrc.yml')),
30
+ copy(path.join(wsTemplatesDir, 'nx.json'), path.join(home, 'nx.json')),
57
31
  copy(path.join(wsTemplatesDir, 'yarnlock'), path.join(home, 'yarn.lock')),
58
32
  copy(path.join(wsTemplatesDir, 'nvmrc'), path.join(home, '.nvmrc')),
59
33
  copy(path.join(wsTemplatesDir, 'npmrc'), path.join(home, '.npmrc')),
@@ -68,7 +42,6 @@ async function createWorkspaceCommand(opts) {
68
42
  output(`Your workspace is ready! 🚀 Apps will live at ${home}`, {
69
43
  ok: true,
70
44
  workspace: home,
71
- z2hCliVersion: cliVersion,
72
45
  });
73
46
  }
74
47
 
@@ -0,0 +1,6 @@
1
+ export interface MigrateOptions {
2
+ dryRun?: boolean;
3
+ json?: boolean;
4
+ }
5
+ export declare function migrateCommand(cliVersion: string, opts: MigrateOptions): Promise<void>;
6
+ //# sourceMappingURL=migrate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../../../src/commands/migrate.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,wBAAsB,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAM5F"}
@@ -0,0 +1,11 @@
1
+ import { setOutputMode } from '../util/logger.mjs';
2
+ import { autoMigrate } from '../migrations/auto-migrate.mjs';
3
+
4
+ async function migrateCommand(cliVersion, opts) {
5
+ if (opts.json) {
6
+ setOutputMode('json');
7
+ }
8
+ await autoMigrate(cliVersion, opts.dryRun);
9
+ }
10
+
11
+ export { migrateCommand };
@@ -8,7 +8,6 @@ export declare const SHADOW_DEV_DEPS: Record<string, string>;
8
8
  export declare const MIN_PORT = 13000;
9
9
  export declare const MAX_PORT = 19999;
10
10
  export declare const GITIGNORE_ENTRIES: string[];
11
- export declare const YARNRC_LINES: string[];
12
11
  export declare const BUCKET_WRITE_NAME = "prod-use1-bigbrain-zth-mf-assets";
13
12
  export declare const REGION = "us-east-1";
14
13
  export declare const BUCKET_WRITE_URL = "https://prod-use1-bigbrain-zth-mf-assets.s3.us-east-1.amazonaws.com";
@@ -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;AAG3C,eAAO,MAAM,YAAY,UAIxB,CAAC;AAQF,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"}
@@ -26,12 +26,6 @@ const MIN_PORT = 13000;
26
26
  const MAX_PORT = 19999;
27
27
  // ─────────── Gitignore entries auto-appended to the consumer's file ────
28
28
  const GITIGNORE_ENTRIES = ['.zth/'];
29
- // ─────────── .yarnrc.yml written to new consumer apps ────
30
- const YARNRC_LINES = [
31
- 'nodeLinker: node-modules',
32
- "npmAuthToken: '${NPM_TOKEN}'",
33
- "npmRegistryServer: 'https://registry.npmjs.org/'",
34
- ];
35
29
  // ─────────── Z2H deploy bucket / contract ─────────
36
30
  // Source of truth for the bucket layout. The CLI uses these when configuring
37
31
  // the S3 client + uploading; bigbrain-zth's STS broker imports them via
@@ -53,4 +47,4 @@ const MANIFEST_READ_URL = `${BUCKET_READ_DNS_URL}/${MANIFEST_KEY}`;
53
47
  // upfront for friendlier errors.
54
48
  const APP_NAME_PATTERN = /^[a-z][a-z0-9-]{1,49}$/;
55
49
 
56
- 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, YARNRC_LINES };
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 };
@@ -7,6 +7,7 @@ import { deployCommand } from './commands/deploy.mjs';
7
7
  import { createWorkspaceCommand } from './commands/create-workspace.mjs';
8
8
  import { createCommand } from './commands/create.mjs';
9
9
  import { generateZ2HTokenCommand } from './commands/generate-z2h-token.mjs';
10
+ import { migrateCommand } from './commands/migrate.mjs';
10
11
  import { errorLog, fail } from './util/logger.mjs';
11
12
 
12
13
  const { version } = createRequire(import.meta.url)('../package.json');
@@ -119,6 +120,19 @@ async function main() {
119
120
  fail(`create failed: ${err.message}`, { command: 'create' }, 1);
120
121
  }
121
122
  });
123
+ program
124
+ .command('migrate')
125
+ .description('Run pending workspace migrations')
126
+ .option('--dry-run', 'show pending migrations without applying any changes')
127
+ .option('--json', 'emit structured JSON on stdout')
128
+ .action(async (opts) => {
129
+ try {
130
+ await migrateCommand(version, opts);
131
+ }
132
+ catch (err) {
133
+ fail(`migrate failed: ${err.message}`, { command: 'migrate' }, 1);
134
+ }
135
+ });
122
136
  await program.parseAsync(process.argv);
123
137
  }
124
138
  void main()
@@ -0,0 +1,3 @@
1
+ import type { Tree } from '@nx/devkit';
2
+ export default function removePerConsumerYarnrc(tree: Tree): void;
3
+ //# sourceMappingURL=001-remove-per-consumer-yarnrc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"001-remove-per-consumer-yarnrc.d.ts","sourceRoot":"","sources":["../../../src/migrations/001-remove-per-consumer-yarnrc.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEvC,MAAM,CAAC,OAAO,UAAU,uBAAuB,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAYhE"}
@@ -0,0 +1,15 @@
1
+ function removePerConsumerYarnrc(tree) {
2
+ for (const entry of tree.children('.')) {
3
+ if (entry.startsWith('.')) {
4
+ continue;
5
+ }
6
+ const pkgPath = `${entry}/package.json`;
7
+ const yarnrcPath = `${entry}/.yarnrc.yml`;
8
+ if (!tree.exists(pkgPath) || !tree.exists(yarnrcPath)) {
9
+ continue;
10
+ }
11
+ tree.delete(yarnrcPath);
12
+ }
13
+ }
14
+
15
+ export { removePerConsumerYarnrc as default };
@@ -0,0 +1,3 @@
1
+ import type { Tree } from '@nx/devkit';
2
+ export default function removeZ2hCliFromWorkspaceDeps(tree: Tree): void;
3
+ //# sourceMappingURL=002-remove-z2h-cli-from-workspace-deps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"002-remove-z2h-cli-from-workspace-deps.d.ts","sourceRoot":"","sources":["../../../src/migrations/002-remove-z2h-cli-from-workspace-deps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEvC,MAAM,CAAC,OAAO,UAAU,6BAA6B,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CA4CtE"}
@@ -0,0 +1,41 @@
1
+ function removeZ2hCliFromWorkspaceDeps(tree) {
2
+ // Clean workspace root package.json
3
+ if (tree.exists('package.json')) {
4
+ const pkg = JSON.parse(tree.read('package.json', 'utf-8'));
5
+ let changed = false;
6
+ if (pkg.devDependencies?.['@mondaydotcomorg/z2h-cli']) {
7
+ delete pkg.devDependencies['@mondaydotcomorg/z2h-cli'];
8
+ changed = true;
9
+ }
10
+ if (pkg.resolutions?.['@mondaydotcomorg/z2h-cli']) {
11
+ delete pkg.resolutions['@mondaydotcomorg/z2h-cli'];
12
+ if (Object.keys(pkg.resolutions).length === 0) {
13
+ delete pkg.resolutions;
14
+ }
15
+ changed = true;
16
+ }
17
+ if (changed) {
18
+ tree.write('package.json', JSON.stringify(pkg, null, 2) + '\n');
19
+ }
20
+ }
21
+ // Clean each consumer app's package.json (remove devDep, keep scripts)
22
+ for (const entry of tree.children('.')) {
23
+ if (entry.startsWith('.')) {
24
+ continue;
25
+ }
26
+ const pkgPath = `${entry}/package.json`;
27
+ if (!tree.exists(pkgPath)) {
28
+ continue;
29
+ }
30
+ const pkg = JSON.parse(tree.read(pkgPath, 'utf-8'));
31
+ if (pkg.devDependencies?.['@mondaydotcomorg/z2h-cli']) {
32
+ delete pkg.devDependencies['@mondaydotcomorg/z2h-cli'];
33
+ if (Object.keys(pkg.devDependencies).length === 0) {
34
+ delete pkg.devDependencies;
35
+ }
36
+ tree.write(pkgPath, JSON.stringify(pkg, null, 2) + '\n');
37
+ }
38
+ }
39
+ }
40
+
41
+ export { removeZ2hCliFromWorkspaceDeps as default };
@@ -0,0 +1,2 @@
1
+ export declare function autoMigrate(cliVersion: string, dryRun?: boolean): Promise<void>;
2
+ //# sourceMappingURL=auto-migrate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auto-migrate.d.ts","sourceRoot":"","sources":["../../../src/migrations/auto-migrate.ts"],"names":[],"mappings":"AAsHA,wBAAsB,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,UAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CA+FnF"}
@@ -0,0 +1,166 @@
1
+ import path from 'node:path';
2
+ import { createRequire } from 'node:module';
3
+ import { fileURLToPath } from 'node:url';
4
+ import { pathExists, readJson, writeJson, writeFile } from 'fs-extra';
5
+ import { execa } from 'execa';
6
+ import semver from 'semver';
7
+ import { warn, info } from '../util/logger.mjs';
8
+ import { getWorkspaceHome, isZ2hWorkspace } from '../util/workspace.mjs';
9
+
10
+ const STATE_FILE = '.z2h-migrations-state.json';
11
+ const NX_JSON_CONTENT = '{\n "extends": "@mondaydotcomorg/trident-monorepo/presets/nx.json"\n}\n';
12
+ // ─── Helpers ───
13
+ async function readState(workspaceHome) {
14
+ const statePath = path.join(workspaceHome, STATE_FILE);
15
+ if (!(await pathExists(statePath))) {
16
+ return null;
17
+ }
18
+ try {
19
+ return (await readJson(statePath));
20
+ }
21
+ catch {
22
+ return null;
23
+ }
24
+ }
25
+ async function writeState(workspaceHome, state) {
26
+ const statePath = path.join(workspaceHome, STATE_FILE);
27
+ await writeJson(statePath, state, { spaces: 2 });
28
+ }
29
+ async function yarnInstall(workspaceHome, context) {
30
+ info(`${context} — running yarn install...`);
31
+ try {
32
+ await execa('yarn', ['install'], { cwd: workspaceHome, stdio: 'pipe' });
33
+ return true;
34
+ }
35
+ catch (err) {
36
+ const stderr = err.stderr || err.message;
37
+ warn(`yarn install failed: ${stderr}`);
38
+ return false;
39
+ }
40
+ }
41
+ async function getLatestTrientMonorepoVersion() {
42
+ try {
43
+ const { stdout } = await execa('npm', ['view', '@mondaydotcomorg/trident-monorepo', 'version']);
44
+ return `^${stdout.trim()}`;
45
+ }
46
+ catch {
47
+ return '*';
48
+ }
49
+ }
50
+ // ─── Workspace bootstrap ───
51
+ function isNxAvailable(workspaceHome) {
52
+ try {
53
+ const wsRequire = createRequire(path.join(workspaceHome, 'package.json'));
54
+ wsRequire.resolve('nx/src/generators/tree');
55
+ return true;
56
+ }
57
+ catch {
58
+ return false;
59
+ }
60
+ }
61
+ async function ensureWorkspaceNx(workspaceHome) {
62
+ const nxJsonPath = path.join(workspaceHome, 'nx.json');
63
+ const pkgPath = path.join(workspaceHome, 'package.json');
64
+ if (!(await pathExists(nxJsonPath))) {
65
+ await writeFile(nxJsonPath, NX_JSON_CONTENT);
66
+ info('added nx.json to workspace');
67
+ }
68
+ const pkg = (await readJson(pkgPath));
69
+ if (!pkg.devDependencies?.['@mondaydotcomorg/trident-monorepo']) {
70
+ pkg.devDependencies = pkg.devDependencies ?? {};
71
+ pkg.devDependencies['@mondaydotcomorg/trident-monorepo'] = await getLatestTrientMonorepoVersion();
72
+ }
73
+ if (!pkg.scripts?.nx) {
74
+ pkg.scripts = pkg.scripts ?? {};
75
+ pkg.scripts.nx = 'nx';
76
+ }
77
+ await writeJson(pkgPath, pkg, { spaces: 2 });
78
+ // Only install if NX isn't already importable from the workspace
79
+ if (!isNxAvailable(workspaceHome)) {
80
+ const ok = await yarnInstall(workspaceHome, 'NX not found, installing');
81
+ if (!ok) {
82
+ warn('workspace migrations require NX. Fix the install error and run "z2h-cli migrate" to retry.');
83
+ return false;
84
+ }
85
+ }
86
+ return true;
87
+ }
88
+ // ─── Main ───
89
+ async function autoMigrate(cliVersion, dryRun = false) {
90
+ const workspaceHome = getWorkspaceHome();
91
+ if (!(await isZ2hWorkspace(workspaceHome))) {
92
+ warn('no Z2H workspace found');
93
+ return;
94
+ }
95
+ const state = await readState(workspaceHome);
96
+ const lastVersion = state?.lastMigratedVersion ?? '0.0.0';
97
+ if (!semver.gt(cliVersion, lastVersion)) {
98
+ info('workspace is up to date — no migrations pending');
99
+ return;
100
+ }
101
+ info(`migrating workspace from v${lastVersion} → v${cliVersion}...`);
102
+ // migrations.json is at the package root — two dirs up from dist/migrations/
103
+ const thisDir = path.dirname(fileURLToPath(import.meta.url));
104
+ const migrationsJsonPath = path.resolve(thisDir, '..', '..', 'migrations.json');
105
+ if (!(await pathExists(migrationsJsonPath))) {
106
+ warn('migrations.json not found — skipping migrations');
107
+ return;
108
+ }
109
+ const migrationsJson = (await readJson(migrationsJsonPath));
110
+ // Filter to pending migrations (version > lastVersion AND <= cliVersion)
111
+ const pending = Object.entries(migrationsJson.migrations)
112
+ .filter(([, entry]) => semver.gt(entry.version, lastVersion) && semver.lte(entry.version, cliVersion))
113
+ .sort(([, a], [, b]) => semver.compare(a.version, b.version));
114
+ if (dryRun) {
115
+ info(`${pending.length} pending migration(s) (dry-run — no changes will be applied):`);
116
+ for (const [, entry] of pending) {
117
+ info(` - ${entry.description} (v${entry.version})`);
118
+ }
119
+ return;
120
+ }
121
+ if (pending.length === 0) {
122
+ await writeState(workspaceHome, { lastMigratedVersion: cliVersion });
123
+ return;
124
+ }
125
+ const nxReady = await ensureWorkspaceNx(workspaceHome);
126
+ if (!nxReady) {
127
+ return;
128
+ }
129
+ info(`applying ${pending.length} workspace migration(s)...`);
130
+ // Resolve NX from the workspace's node_modules (not from CLI's own deps)
131
+ const wsRequire = createRequire(path.join(workspaceHome, 'package.json'));
132
+ const { FsTree, flushChanges } = wsRequire('nx/src/generators/tree');
133
+ let needsInstall = false;
134
+ for (const [name, entry] of pending) {
135
+ const tree = new FsTree(workspaceHome, false);
136
+ try {
137
+ const factoryPath = path.resolve(path.dirname(migrationsJsonPath), entry.migrate);
138
+ const mod = require(factoryPath);
139
+ const fn = mod.default || mod;
140
+ fn(tree);
141
+ const changes = tree.listChanges();
142
+ if (changes.length > 0) {
143
+ if (changes.some(c => c.path.endsWith('package.json'))) {
144
+ needsInstall = true;
145
+ }
146
+ flushChanges(workspaceHome, changes);
147
+ info(` ✓ ${entry.description}`);
148
+ }
149
+ else {
150
+ info(` ○ ${entry.description} (no changes needed)`);
151
+ }
152
+ }
153
+ catch (err) {
154
+ warn(` ✗ migration "${name}" failed: ${err.message}`);
155
+ warn(' skipping remaining migrations. Run "z2h-cli migrate" to retry.');
156
+ return;
157
+ }
158
+ }
159
+ if (needsInstall) {
160
+ await yarnInstall(workspaceHome, 'package.json changed');
161
+ }
162
+ await writeState(workspaceHome, { lastMigratedVersion: cliVersion });
163
+ info('workspace migrations complete.');
164
+ }
165
+
166
+ export { autoMigrate };
@@ -1 +1 @@
1
- {"version":3,"file":"prepare.d.ts","sourceRoot":"","sources":["../../../src/shadow/prepare.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAA8B,cAAc,EAAkB,MAAM,UAAU,CAAC;AAE3F,wBAAsB,aAAa,IAAI,OAAO,CAAC,cAAc,CAAC,CAiC7D"}
1
+ {"version":3,"file":"prepare.d.ts","sourceRoot":"","sources":["../../../src/shadow/prepare.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAA8B,cAAc,EAAkB,MAAM,UAAU,CAAC;AAE3F,wBAAsB,aAAa,IAAI,OAAO,CAAC,cAAc,CAAC,CAgC7D"}
@@ -3,7 +3,6 @@ import { info } from '../util/logger.mjs';
3
3
  import { cleanAppName } from '../util/app-name.mjs';
4
4
  import { resolveConsumerPaths } from './paths.mjs';
5
5
  import { ensureGitignore } from './gitignore.mjs';
6
- import { ensureYarnRc } from './yarnrc.mjs';
7
6
  import { ensureConsumerPkg } from './consumer-pkg.mjs';
8
7
  import { scaffoldShadow } from './scaffold.mjs';
9
8
  import { readMetadata, writeMetadata } from './metadata.mjs';
@@ -28,7 +27,6 @@ async function prepareShadow() {
28
27
  info(`ensured consumer pkg shape at ${paths.consumerPkg}`);
29
28
  }
30
29
  await ensureGitignore(paths.consumerDir);
31
- await ensureYarnRc(paths.consumerDir);
32
30
  await ensureDir(paths.shadowDir);
33
31
  const metadata = await resolvePortAndMetadata(paths, appName);
34
32
  const port = metadata.port;
@@ -0,0 +1,5 @@
1
+ const nx = {
2
+ "extends": "@mondaydotcomorg/trident-monorepo/presets/nx.json"
3
+ };
4
+
5
+ export { nx as default };
package/dist/index.js CHANGED
@@ -7,6 +7,7 @@ const commands_deploy = require('./commands/deploy.js');
7
7
  const commands_createWorkspace = require('./commands/create-workspace.js');
8
8
  const commands_create = require('./commands/create.js');
9
9
  const commands_generateZ2hToken = require('./commands/generate-z2h-token.js');
10
+ const commands_migrate = require('./commands/migrate.js');
10
11
  const util_logger = require('./util/logger.js');
11
12
 
12
13
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
@@ -120,6 +121,19 @@ async function main() {
120
121
  util_logger.fail(`create failed: ${err.message}`, { command: 'create' }, 1);
121
122
  }
122
123
  });
124
+ program
125
+ .command('migrate')
126
+ .description('Run pending workspace migrations')
127
+ .option('--dry-run', 'show pending migrations without applying any changes')
128
+ .option('--json', 'emit structured JSON on stdout')
129
+ .action(async (opts) => {
130
+ try {
131
+ await commands_migrate.migrateCommand(version, opts);
132
+ }
133
+ catch (err) {
134
+ util_logger.fail(`migrate failed: ${err.message}`, { command: 'migrate' }, 1);
135
+ }
136
+ });
123
137
  await program.parseAsync(process.argv);
124
138
  }
125
139
  void main()
@@ -0,0 +1,3 @@
1
+ import type { Tree } from '@nx/devkit';
2
+ export default function removePerConsumerYarnrc(tree: Tree): void;
3
+ //# sourceMappingURL=001-remove-per-consumer-yarnrc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"001-remove-per-consumer-yarnrc.d.ts","sourceRoot":"","sources":["../../src/migrations/001-remove-per-consumer-yarnrc.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEvC,MAAM,CAAC,OAAO,UAAU,uBAAuB,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAYhE"}
@@ -0,0 +1,17 @@
1
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
2
+
3
+ function removePerConsumerYarnrc(tree) {
4
+ for (const entry of tree.children('.')) {
5
+ if (entry.startsWith('.')) {
6
+ continue;
7
+ }
8
+ const pkgPath = `${entry}/package.json`;
9
+ const yarnrcPath = `${entry}/.yarnrc.yml`;
10
+ if (!tree.exists(pkgPath) || !tree.exists(yarnrcPath)) {
11
+ continue;
12
+ }
13
+ tree.delete(yarnrcPath);
14
+ }
15
+ }
16
+
17
+ exports.default = removePerConsumerYarnrc;
@@ -0,0 +1,3 @@
1
+ import type { Tree } from '@nx/devkit';
2
+ export default function removeZ2hCliFromWorkspaceDeps(tree: Tree): void;
3
+ //# sourceMappingURL=002-remove-z2h-cli-from-workspace-deps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"002-remove-z2h-cli-from-workspace-deps.d.ts","sourceRoot":"","sources":["../../src/migrations/002-remove-z2h-cli-from-workspace-deps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEvC,MAAM,CAAC,OAAO,UAAU,6BAA6B,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CA4CtE"}