@bleedingdev/modern-js-create 3.4.0-ultramodern.9 → 3.5.0-ultramodern.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 (135) hide show
  1. package/README.md +49 -23
  2. package/dist/cjs/index.cjs +37 -4
  3. package/dist/cjs/locale/en.cjs +12 -2
  4. package/dist/cjs/locale/zh.cjs +12 -2
  5. package/dist/cjs/ultramodern-tooling/commands.cjs +431 -0
  6. package/dist/cjs/ultramodern-tooling/config.cjs +172 -0
  7. package/dist/cjs/ultramodern-workspace/add-vertical.cjs +87 -75
  8. package/dist/cjs/ultramodern-workspace/{effect-api.cjs → api.cjs} +207 -208
  9. package/dist/cjs/ultramodern-workspace/bridge-config.cjs +327 -0
  10. package/dist/cjs/ultramodern-workspace/codesmith.cjs +1 -0
  11. package/dist/cjs/ultramodern-workspace/contracts.cjs +128 -657
  12. package/dist/cjs/ultramodern-workspace/demo-components.cjs +12 -12
  13. package/dist/cjs/ultramodern-workspace/descriptors.cjs +25 -25
  14. package/dist/cjs/ultramodern-workspace/fs-io.cjs +117 -0
  15. package/dist/cjs/ultramodern-workspace/generation-result.cjs +5 -5
  16. package/dist/cjs/ultramodern-workspace/index.cjs +4 -0
  17. package/dist/cjs/ultramodern-workspace/mf-validation.cjs +571 -0
  18. package/dist/cjs/ultramodern-workspace/module-federation.cjs +39 -12
  19. package/dist/cjs/ultramodern-workspace/overlays.cjs +2 -2
  20. package/dist/cjs/ultramodern-workspace/package-json.cjs +58 -41
  21. package/dist/cjs/ultramodern-workspace/policy.cjs +4 -4
  22. package/dist/cjs/ultramodern-workspace/public-api.cjs +4 -0
  23. package/dist/cjs/ultramodern-workspace/public-surface.cjs +2 -2
  24. package/dist/cjs/ultramodern-workspace/versions.cjs +15 -0
  25. package/dist/cjs/ultramodern-workspace/workspace-scripts.cjs +120 -50
  26. package/dist/cjs/ultramodern-workspace/write-workspace.cjs +64 -21
  27. package/dist/esm/index.js +37 -4
  28. package/dist/esm/locale/en.js +12 -2
  29. package/dist/esm/locale/zh.js +12 -2
  30. package/dist/esm/ultramodern-tooling/commands.js +378 -0
  31. package/dist/esm/ultramodern-tooling/config.js +120 -0
  32. package/dist/esm/ultramodern-workspace/add-vertical.js +88 -79
  33. package/dist/esm/ultramodern-workspace/{effect-api.js → api.js} +146 -147
  34. package/dist/esm/ultramodern-workspace/bridge-config.js +270 -0
  35. package/dist/esm/ultramodern-workspace/codesmith.js +1 -0
  36. package/dist/esm/ultramodern-workspace/contracts.js +130 -611
  37. package/dist/esm/ultramodern-workspace/demo-components.js +13 -13
  38. package/dist/esm/ultramodern-workspace/descriptors.js +11 -11
  39. package/dist/esm/ultramodern-workspace/fs-io.js +116 -2
  40. package/dist/esm/ultramodern-workspace/generation-result.js +6 -6
  41. package/dist/esm/ultramodern-workspace/index.js +1 -0
  42. package/dist/esm/ultramodern-workspace/mf-validation.js +516 -0
  43. package/dist/esm/ultramodern-workspace/module-federation.js +40 -13
  44. package/dist/esm/ultramodern-workspace/overlays.js +2 -2
  45. package/dist/esm/ultramodern-workspace/package-json.js +57 -40
  46. package/dist/esm/ultramodern-workspace/policy.js +5 -5
  47. package/dist/esm/ultramodern-workspace/public-api.js +1 -0
  48. package/dist/esm/ultramodern-workspace/public-surface.js +2 -2
  49. package/dist/esm/ultramodern-workspace/versions.js +7 -1
  50. package/dist/esm/ultramodern-workspace/workspace-scripts.js +108 -34
  51. package/dist/esm/ultramodern-workspace/write-workspace.js +66 -26
  52. package/dist/esm-node/index.js +37 -4
  53. package/dist/esm-node/locale/en.js +12 -2
  54. package/dist/esm-node/locale/zh.js +12 -2
  55. package/dist/esm-node/ultramodern-tooling/commands.js +379 -0
  56. package/dist/esm-node/ultramodern-tooling/config.js +121 -0
  57. package/dist/esm-node/ultramodern-workspace/add-vertical.js +88 -79
  58. package/dist/esm-node/ultramodern-workspace/{effect-api.js → api.js} +146 -147
  59. package/dist/esm-node/ultramodern-workspace/bridge-config.js +271 -0
  60. package/dist/esm-node/ultramodern-workspace/codesmith.js +1 -0
  61. package/dist/esm-node/ultramodern-workspace/contracts.js +130 -611
  62. package/dist/esm-node/ultramodern-workspace/demo-components.js +13 -13
  63. package/dist/esm-node/ultramodern-workspace/descriptors.js +11 -11
  64. package/dist/esm-node/ultramodern-workspace/fs-io.js +116 -2
  65. package/dist/esm-node/ultramodern-workspace/generation-result.js +6 -6
  66. package/dist/esm-node/ultramodern-workspace/index.js +1 -0
  67. package/dist/esm-node/ultramodern-workspace/mf-validation.js +517 -0
  68. package/dist/esm-node/ultramodern-workspace/module-federation.js +40 -13
  69. package/dist/esm-node/ultramodern-workspace/overlays.js +2 -2
  70. package/dist/esm-node/ultramodern-workspace/package-json.js +57 -40
  71. package/dist/esm-node/ultramodern-workspace/policy.js +5 -5
  72. package/dist/esm-node/ultramodern-workspace/public-api.js +1 -0
  73. package/dist/esm-node/ultramodern-workspace/public-surface.js +2 -2
  74. package/dist/esm-node/ultramodern-workspace/versions.js +7 -1
  75. package/dist/esm-node/ultramodern-workspace/workspace-scripts.js +108 -34
  76. package/dist/esm-node/ultramodern-workspace/write-workspace.js +66 -26
  77. package/dist/types/locale/en.d.ts +10 -0
  78. package/dist/types/locale/index.d.ts +20 -0
  79. package/dist/types/locale/zh.d.ts +10 -0
  80. package/dist/types/ultramodern-tooling/commands.d.ts +1 -0
  81. package/dist/types/ultramodern-tooling/config.d.ts +43 -0
  82. package/dist/types/ultramodern-workspace/add-vertical.d.ts +5 -2
  83. package/dist/types/ultramodern-workspace/api.d.ts +73 -0
  84. package/dist/types/ultramodern-workspace/bridge-config.d.ts +64 -0
  85. package/dist/types/ultramodern-workspace/codesmith.d.ts +1 -0
  86. package/dist/types/ultramodern-workspace/contracts.d.ts +2 -17
  87. package/dist/types/ultramodern-workspace/descriptors.d.ts +10 -10
  88. package/dist/types/ultramodern-workspace/fs-io.d.ts +1 -0
  89. package/dist/types/ultramodern-workspace/index.d.ts +2 -0
  90. package/dist/types/ultramodern-workspace/mf-validation.d.ts +27 -0
  91. package/dist/types/ultramodern-workspace/package-json.d.ts +5 -4
  92. package/dist/types/ultramodern-workspace/public-api.d.ts +2 -0
  93. package/dist/types/ultramodern-workspace/types.d.ts +9 -7
  94. package/dist/types/ultramodern-workspace/versions.d.ts +6 -0
  95. package/dist/types/ultramodern-workspace/workspace-scripts.d.ts +2 -7
  96. package/dist/types/ultramodern-workspace/write-workspace.d.ts +4 -2
  97. package/package.json +5 -3
  98. package/template-workspace/{.agents → .codex}/skills-lock.json +12 -12
  99. package/template-workspace/.github/workflows/ultramodern-workspace-gates.yml.handlebars +2 -0
  100. package/template-workspace/.gitignore.handlebars +3 -0
  101. package/template-workspace/AGENTS.md.handlebars +11 -5
  102. package/template-workspace/README.md.handlebars +55 -13
  103. package/template-workspace/oxfmt.config.ts +1 -0
  104. package/template-workspace/oxlint.config.ts +1 -0
  105. package/template-workspace/patches/@tanstack__router-core@1.171.13.patch +51 -0
  106. package/template-workspace/pnpm-workspace.yaml.handlebars +7 -0
  107. package/template-workspace/scripts/bootstrap-agent-skills.mjs +77 -67
  108. package/templates/workspace-scripts/assert-mf-types.mjs.handlebars +51 -8
  109. package/templates/workspace-scripts/check-ultramodern-api-boundaries.mts +366 -0
  110. package/templates/workspace-scripts/{check-ultramodern-i18n-boundaries.mjs → check-ultramodern-i18n-boundaries.mts} +1 -1
  111. package/templates/workspace-scripts/generate-public-surface-assets.mjs +246 -9
  112. package/templates/workspace-scripts/proof-cloudflare-version.mjs +277 -9
  113. package/templates/workspace-scripts/ultramodern-cloudflare-proof.mjs +35 -10
  114. package/templates/workspace-scripts/ultramodern-performance-readiness.mjs +165 -2
  115. package/templates/workspace-scripts/ultramodern-typecheck.mjs +4 -2
  116. package/templates/workspace-scripts/validate-ultramodern-workspace.mjs.handlebars +842 -84
  117. package/dist/types/ultramodern-workspace/effect-api.d.ts +0 -73
  118. /package/template-workspace/{.agents → .codex}/rstackjs-agent-skills-LICENSE +0 -0
  119. /package/template-workspace/{.agents → .codex}/skills/rsbuild-best-practices/SKILL.md +0 -0
  120. /package/template-workspace/{.agents → .codex}/skills/rsdoctor-analysis/SKILL.md +0 -0
  121. /package/template-workspace/{.agents → .codex}/skills/rsdoctor-analysis/references/command-map.md +0 -0
  122. /package/template-workspace/{.agents → .codex}/skills/rsdoctor-analysis/references/common-analysis-patterns.md +0 -0
  123. /package/template-workspace/{.agents → .codex}/skills/rsdoctor-analysis/references/install-rsdoctor-common.md +0 -0
  124. /package/template-workspace/{.agents → .codex}/skills/rsdoctor-analysis/references/install-rsdoctor-rspack.md +0 -0
  125. /package/template-workspace/{.agents → .codex}/skills/rsdoctor-analysis/references/install-rsdoctor-webpack.md +0 -0
  126. /package/template-workspace/{.agents → .codex}/skills/rsdoctor-analysis/references/install-rsdoctor.md +0 -0
  127. /package/template-workspace/{.agents → .codex}/skills/rsdoctor-analysis/references/rsdoctor-data-types.md +0 -0
  128. /package/template-workspace/{.agents → .codex}/skills/rslib-best-practices/SKILL.md +0 -0
  129. /package/template-workspace/{.agents → .codex}/skills/rslib-modern-package/SKILL.md +0 -0
  130. /package/template-workspace/{.agents → .codex}/skills/rspack-best-practices/SKILL.md +0 -0
  131. /package/template-workspace/{.agents → .codex}/skills/rspack-tracing/SKILL.md +0 -0
  132. /package/template-workspace/{.agents → .codex}/skills/rspack-tracing/references/bottlenecks.md +0 -0
  133. /package/template-workspace/{.agents → .codex}/skills/rspack-tracing/references/tracing-guide.md +0 -0
  134. /package/template-workspace/{.agents → .codex}/skills/rspack-tracing/scripts/analyze_trace.js +0 -0
  135. /package/template-workspace/{.agents → .codex}/skills/rstest-best-practices/SKILL.md +0 -0
@@ -7,7 +7,9 @@ import { fileURLToPath } from "node:url";
7
7
  import { resolveCreatePackageRoot } from "./create-package-root.js";
8
8
  import { i18n, localeKeys } from "./locale/index.js";
9
9
  import { BLEEDINGDEV_CREATE_PACKAGE, BLEEDINGDEV_FRAMEWORK_VERSION_ENV, BLEEDINGDEV_PACKAGE_NAME_PREFIX, BLEEDINGDEV_PACKAGE_SCOPE, WORKSPACE_PACKAGE_VERSION } from "./ultramodern-package-source.js";
10
+ import { runUltramodernToolingCli } from "./ultramodern-tooling/commands.js";
10
11
  import { addUltramodernVertical, generateUltramodernWorkspace, planUltramodernVertical } from "./ultramodern-workspace/index.js";
12
+ import { hasUltramodernBridgeCliOptions, parseUltramodernBridgeCliOptions, ultramodernBridgeCliBooleanFlags, ultramodernBridgeCliValueFlags } from "./ultramodern-workspace/bridge-config.js";
11
13
  const src_dirname = node_path.dirname(fileURLToPath(import.meta.url));
12
14
  const createPackageRoot = resolveCreatePackageRoot(src_dirname);
13
15
  const semverPattern = /^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/;
@@ -85,6 +87,16 @@ function showHelp() {
85
87
  console.log(i18n.t(localeKeys.help.optionUltramodernPackageRegistry));
86
88
  console.log(i18n.t(localeKeys.help.optionUltramodernPackageScope));
87
89
  console.log(i18n.t(localeKeys.help.optionUltramodernPackageNamePrefix));
90
+ console.log(i18n.t(localeKeys.help.optionBridge));
91
+ console.log(i18n.t(localeKeys.help.optionBridgeParentRoot));
92
+ console.log(i18n.t(localeKeys.help.optionBridgeWorkspacePackage));
93
+ console.log(i18n.t(localeKeys.help.optionBridgeWorkspacePackageName));
94
+ console.log(i18n.t(localeKeys.help.optionBridgeTestAlias));
95
+ console.log(i18n.t(localeKeys.help.optionBridgeDependency));
96
+ console.log(i18n.t(localeKeys.help.optionBridgeLockfilePolicy));
97
+ console.log(i18n.t(localeKeys.help.optionBridgeGate));
98
+ console.log(i18n.t(localeKeys.help.optionBridgeGateCwd));
99
+ console.log(i18n.t(localeKeys.help.optionBridgeReactSingleton));
88
100
  console.log(i18n.t(localeKeys.help.optionVertical));
89
101
  console.log(i18n.t(localeKeys.help.optionVerticalName));
90
102
  console.log(i18n.t(localeKeys.help.optionDryRun));
@@ -173,7 +185,7 @@ function detectBffRuntime(args) {
173
185
  process.exit(1);
174
186
  }
175
187
  if (!SUPPORTED_BFF_RUNTIMES.includes(runtime)) {
176
- console.error(`Unsupported BFF runtime "${runtime}". UltraModern workspaces scaffold an Effect BFF for every MicroVertical (supported: ${SUPPORTED_BFF_RUNTIMES.join(', ')}).`);
188
+ console.error(`Unsupported BFF runtime "${runtime}". UltraModern workspaces scaffold a strict Effect API runtime for every MicroVertical (supported: ${SUPPORTED_BFF_RUNTIMES.join(', ')}).`);
177
189
  process.exit(1);
178
190
  }
179
191
  return runtime;
@@ -198,7 +210,8 @@ function collectPositionalArgs(args) {
198
210
  '--ultramodern-package-scope',
199
211
  '--ultramodern-package-name-prefix',
200
212
  VERTICAL_NAME_FLAG,
201
- CODESMITH_OVERLAY_FLAG
213
+ CODESMITH_OVERLAY_FLAG,
214
+ ...ultramodernBridgeCliValueFlags
202
215
  ]);
203
216
  const optionWithoutValue = new Set([
204
217
  '--help',
@@ -211,7 +224,8 @@ function collectPositionalArgs(args) {
211
224
  WORKSPACE_PROTOCOL_FLAG,
212
225
  DRY_RUN_FLAG,
213
226
  VERTICAL_FLAG,
214
- LEGACY_MODERN_JS_FLAG
227
+ LEGACY_MODERN_JS_FLAG,
228
+ ...ultramodernBridgeCliBooleanFlags
215
229
  ]);
216
230
  const positionalArgs = [];
217
231
  for(let i = 0; i < args.length; i++){
@@ -221,7 +235,7 @@ function collectPositionalArgs(args) {
221
235
  i += 1;
222
236
  continue;
223
237
  }
224
- if (!(arg.startsWith('--lang=') || arg.startsWith(`${BFF_RUNTIME_OPTION}=`) || arg.startsWith('--ultramodern-package-source=') || arg.startsWith('--ultramodern-package-version=') || arg.startsWith('--ultramodern-package-registry=') || arg.startsWith('--ultramodern-package-scope=') || arg.startsWith('--ultramodern-package-name-prefix=') || arg.startsWith(`${VERTICAL_FLAG}=`) || arg.startsWith(`${VERTICAL_NAME_FLAG}=`) || arg.startsWith(`${CODESMITH_OVERLAY_FLAG}=`))) positionalArgs.push(arg);
238
+ if (!(arg.startsWith('--lang=') || arg.startsWith(`${BFF_RUNTIME_OPTION}=`) || arg.startsWith('--ultramodern-package-source=') || arg.startsWith('--ultramodern-package-version=') || arg.startsWith('--ultramodern-package-registry=') || arg.startsWith('--ultramodern-package-scope=') || arg.startsWith('--ultramodern-package-name-prefix=') || arg.startsWith(`${VERTICAL_FLAG}=`) || arg.startsWith(`${VERTICAL_NAME_FLAG}=`) || arg.startsWith(`${CODESMITH_OVERLAY_FLAG}=`) || ultramodernBridgeCliBooleanFlags.some((flag)=>arg.startsWith(`${flag}=`)) || ultramodernBridgeCliValueFlags.some((flag)=>arg.startsWith(`${flag}=`)))) positionalArgs.push(arg);
225
239
  }
226
240
  }
227
241
  return positionalArgs;
@@ -337,6 +351,14 @@ function detectCodeSmithOverlays(args) {
337
351
  }
338
352
  return overlays.length > 0 ? overlays : void 0;
339
353
  }
354
+ function readBridgeCliOptions(args) {
355
+ try {
356
+ return parseUltramodernBridgeCliOptions(args);
357
+ } catch (error) {
358
+ console.error(error instanceof Error ? error.message : String(error));
359
+ process.exit(1);
360
+ }
361
+ }
340
362
  function detectUltramodernPackageSource(args, defaultPackageVersion, createPackage) {
341
363
  const bleedingDevDefaults = isBleedingDevCreatePackage(createPackage);
342
364
  const strategy = getOptionValue(args, [
@@ -546,6 +568,10 @@ async function getProjectName() {
546
568
  }
547
569
  async function main() {
548
570
  const args = process.argv.slice(2);
571
+ if ('ultramodern' === args[0]) {
572
+ process.exitCode = await runUltramodernToolingCli(args.slice(1));
573
+ return;
574
+ }
549
575
  if (args.includes('--help') || args.includes('-h')) return void showHelp();
550
576
  if (args.includes('--version') || args.includes('-v')) return void showVersion();
551
577
  if (detectLegacyModernJsFlag(args)) {
@@ -557,10 +583,16 @@ async function main() {
557
583
  const dryRun = detectDryRunFlag(args);
558
584
  const verticalInput = resolveVerticalCliInput(args);
559
585
  const overlays = detectCodeSmithOverlays(args);
586
+ const bridgeRequested = hasUltramodernBridgeCliOptions(args);
560
587
  if (dryRun && !verticalInput.addVertical) {
561
588
  console.error(`${DRY_RUN_FLAG} is currently supported only with ${VERTICAL_FLAG}`);
562
589
  process.exit(1);
563
590
  }
591
+ if (verticalInput.addVertical && bridgeRequested) {
592
+ console.error('Bridge options are supported only when creating a new UltraModern workspace.');
593
+ process.exit(1);
594
+ }
595
+ const bridge = readBridgeCliOptions(args);
564
596
  if (!dryRun) console.log(`\n${i18n.t(localeKeys.message.welcome)}\n`);
565
597
  const createPackage = readCreatePackageJson();
566
598
  const version = createPackage.version || 'latest';
@@ -601,6 +633,7 @@ async function main() {
601
633
  packageName: generatedPackageName,
602
634
  modernVersion: version,
603
635
  enableTailwind: detectTailwindFlag(),
636
+ bridge,
604
637
  overlays,
605
638
  packageSource
606
639
  });
@@ -19,7 +19,7 @@ const EN_LOCALE = {
19
19
  step1: 'cd {projectName}',
20
20
  step2: 'pnpm install',
21
21
  step3: 'pnpm dev',
22
- legacyModernJsWarning: "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\nBRUTAL WARNING: YOU ARE OPTING OUT OF ULTRAMODERN.JS DEFAULTS.\nThe unattended default is the best UltraModern.js configuration:\na structured SuperApp workspace, presetUltramodern, TanStack Router,\nEffect BFF, Tailwind CSS v4, and the BleedingDev package cohort.\nThe original Modern.js setup is a dangerous opt-in path.\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
22
+ legacyModernJsWarning: "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\nBRUTAL WARNING: YOU ARE OPTING OUT OF ULTRAMODERN.JS DEFAULTS.\nThe unattended default is the best UltraModern.js configuration:\na structured SuperApp workspace, presetUltramodern, TanStack Router,\na strict Effect API runtime, Tailwind CSS v4, and the BleedingDev package cohort.\nThe original Modern.js setup is a dangerous opt-in path.\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
23
23
  },
24
24
  help: {
25
25
  title: '🚀 UltraModern.js Project Creator',
@@ -31,7 +31,7 @@ const EN_LOCALE = {
31
31
  optionVersion: ' -v, --version Display version information',
32
32
  optionLang: ' -l, --lang Set the language (en default; zh opt-in)',
33
33
  optionTailwind: ' --no-tailwind Disable default Tailwind CSS v4 workspace styling',
34
- optionBff: ' --bff Keep the default Effect BFF scaffolding (every MicroVertical ships an Effect BFF)',
34
+ optionBff: ' --bff Keep the default strict Effect API runtime (every MicroVertical ships one)',
35
35
  optionBffRuntime: ' --bff-runtime Select the BFF runtime for scaffolded MicroVerticals (supported: effect; default: effect)',
36
36
  optionWorkspace: ' --workspace Use workspace protocol for @modern-js dependencies (for local monorepo testing)',
37
37
  optionUltramodernPackageSource: ' --ultramodern-package-source Select UltraModern package source (workspace or install; BleedingDev defaults to install aliases)',
@@ -39,6 +39,16 @@ const EN_LOCALE = {
39
39
  optionUltramodernPackageRegistry: ' --ultramodern-package-registry npm registry URL used for install package sources',
40
40
  optionUltramodernPackageScope: ' --ultramodern-package-scope Publish scope for npm alias installs (for example bleedingdev)',
41
41
  optionUltramodernPackageNamePrefix: ' --ultramodern-package-name-prefix Prefix for npm alias package names (default: modern-js-)',
42
+ optionBridge: ' --bridge Enable explicit nested parent-monorepo bridge mode for new workspaces',
43
+ optionBridgeParentRoot: ' --bridge-parent-root <path> Parent monorepo root for bridge mode',
44
+ optionBridgeWorkspacePackage: ' --bridge-workspace-package <glob> Parent workspace package glob consumed by generated apps',
45
+ optionBridgeWorkspacePackageName: ' --bridge-workspace-package-name <glob=package[,package]> Package names covered by a bridge workspace glob',
46
+ optionBridgeTestAlias: ' --bridge-test-alias <glob:alias=target> Test/source alias for a bridge workspace package glob',
47
+ optionBridgeDependency: ' --bridge-dependency <package[,package]> Explicit parent package dependency consumed by generated apps',
48
+ optionBridgeLockfilePolicy: ' --bridge-lockfile-policy <nested|parent> Bridge lockfile ownership policy (default: nested)',
49
+ optionBridgeGate: ' --bridge-gate <name=command> Delegated parent workspace gate command for bridge packages',
50
+ optionBridgeGateCwd: ' --bridge-gate-cwd <name=cwd> Working directory for a named bridge gate',
51
+ optionBridgeReactSingleton: ' --bridge-react-singleton <package[,package]> React singleton package expectation (default: react,react-dom)',
42
52
  optionVertical: ' --vertical[=<name>] Mutate the current existing UltraModern workspace and wire a MicroVertical',
43
53
  optionVerticalName: ' --vertical-name <name> Explicit MicroVertical name for automation-friendly workspace mutation',
44
54
  optionDryRun: ' --dry-run Preview a MicroVertical mutation plan without writing files (supported with --vertical)',
@@ -19,7 +19,7 @@ const ZH_LOCALE = {
19
19
  step1: 'cd {projectName}',
20
20
  step2: 'pnpm install',
21
21
  step3: 'pnpm dev',
22
- legacyModernJsWarning: "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n严重警告:你正在退出 ULTRAMODERN.JS 默认配置。\n免交互默认值是最佳 UltraModern.js 配置:\n结构化 SuperApp 工作区、presetUltramodern、TanStack Router、\nEffect BFF、Tailwind CSS v4,以及 BleedingDev 包版本队列。\n原始 Modern.js 初始化是危险的显式选择路径。\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
22
+ legacyModernJsWarning: "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n严重警告:你正在退出 ULTRAMODERN.JS 默认配置。\n免交互默认值是最佳 UltraModern.js 配置:\n结构化 SuperApp 工作区、presetUltramodern、TanStack Router、\n严格 Effect API 运行时、Tailwind CSS v4,以及 BleedingDev 包版本队列。\n原始 Modern.js 初始化是危险的显式选择路径。\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
23
23
  },
24
24
  help: {
25
25
  title: '🚀 UltraModern.js 项目创建工具',
@@ -31,7 +31,7 @@ const ZH_LOCALE = {
31
31
  optionVersion: ' -v, --version 显示版本信息',
32
32
  optionLang: ' -l, --lang 设置语言 (默认 en;zh 需显式选择)',
33
33
  optionTailwind: ' --no-tailwind 禁用默认 Tailwind CSS v4 工作区样式',
34
- optionBff: ' --bff 保留默认的 Effect BFF 脚手架(每个 MicroVertical 自带 Effect BFF)',
34
+ optionBff: ' --bff 保留默认的严格 Effect API 运行时(每个 MicroVertical 自带一个)',
35
35
  optionBffRuntime: ' --bff-runtime 选择 MicroVertical 脚手架的 BFF 运行时(支持: effect;默认: effect)',
36
36
  optionWorkspace: ' --workspace 对 @modern-js 依赖使用 workspace 协议(用于本地 monorepo 联调)',
37
37
  optionUltramodernPackageSource: ' --ultramodern-package-source 选择 UltraModern 依赖来源(workspace 或 install;BleedingDev 默认使用 install alias)',
@@ -39,6 +39,16 @@ const ZH_LOCALE = {
39
39
  optionUltramodernPackageRegistry: ' --ultramodern-package-registry install 依赖来源使用的 npm registry 地址',
40
40
  optionUltramodernPackageScope: ' --ultramodern-package-scope npm alias 安装使用的发布 scope(例如 bleedingdev)',
41
41
  optionUltramodernPackageNamePrefix: ' --ultramodern-package-name-prefix npm alias 包名前缀(默认:modern-js-)',
42
+ optionBridge: ' --bridge 为新工作区启用显式的嵌套父 monorepo 桥接模式',
43
+ optionBridgeParentRoot: ' --bridge-parent-root <路径> 桥接模式使用的父 monorepo 根目录',
44
+ optionBridgeWorkspacePackage: ' --bridge-workspace-package <glob> 生成应用消费的父工作区包 glob',
45
+ optionBridgeWorkspacePackageName: ' --bridge-workspace-package-name <glob=包名[,包名]> 桥接工作区 glob 覆盖的包名',
46
+ optionBridgeTestAlias: ' --bridge-test-alias <glob:别名=目标> 桥接工作区包 glob 的测试/源码 alias',
47
+ optionBridgeDependency: ' --bridge-dependency <包名[,包名]> 生成应用显式消费的父包依赖',
48
+ optionBridgeLockfilePolicy: ' --bridge-lockfile-policy <nested|parent> 桥接 lockfile 归属策略(默认:nested)',
49
+ optionBridgeGate: ' --bridge-gate <名称=命令> 桥接包委托给父工作区执行的 gate 命令',
50
+ optionBridgeGateCwd: ' --bridge-gate-cwd <名称=目录> 指定桥接 gate 的工作目录',
51
+ optionBridgeReactSingleton: ' --bridge-react-singleton <包名[,包名]> React 单例包预期(默认:react,react-dom)',
42
52
  optionVertical: ' --vertical[=<名称>] 修改当前已有的 UltraModern 工作区,并接入 MicroVertical',
43
53
  optionVerticalName: ' --vertical-name <名称> 为自动化工作流显式指定 MicroVertical 名称',
44
54
  optionDryRun: ' --dry-run 预览 MicroVertical 修改计划但不写入文件(与 --vertical 一起使用)',
@@ -0,0 +1,379 @@
1
+ import "node:module";
2
+ import { spawnSync } from "node:child_process";
3
+ import node_fs from "node:fs";
4
+ import node_os from "node:os";
5
+ import node_path from "node:path";
6
+ import { fileURLToPath } from "node:url";
7
+ import { resolveCreatePackageRoot } from "../create-package-root.js";
8
+ import { BLEEDINGDEV_PACKAGE_NAME_PREFIX, BLEEDINGDEV_PACKAGE_SCOPE, ULTRAMODERN_SINGLE_APP_MODERN_PACKAGES, ULTRAMODERN_WORKSPACE_MODERN_PACKAGES, WORKSPACE_PACKAGE_VERSION, modernPackageSpecifier } from "../ultramodern-package-source.js";
9
+ import { validateModuleFederationTypes } from "../ultramodern-workspace/mf-validation.js";
10
+ import { createWorkspaceValidationScript } from "../ultramodern-workspace/workspace-scripts.js";
11
+ import { readUltramodernConfig, workspaceAppsFromToolingConfig } from "./config.js";
12
+ const commands_dirname = node_path.dirname(fileURLToPath(import.meta.url));
13
+ const createPackageRoot = resolveCreatePackageRoot(commands_dirname);
14
+ function printHelp() {
15
+ process.stdout.write(`Usage:
16
+ modern-js-create ultramodern <command> [args]
17
+
18
+ Commands:
19
+ validate
20
+ typecheck
21
+ mf-types
22
+ migrate-strict-effect
23
+ public-surface
24
+ cloudflare-proof
25
+ performance-readiness
26
+ skills install
27
+ skills check
28
+ `);
29
+ }
30
+ function spawnNodeScript(relativeScriptPath, args, context, options = {}) {
31
+ const scriptPath = node_path.join(createPackageRoot, relativeScriptPath);
32
+ const result = spawnSync(process.execPath, [
33
+ scriptPath,
34
+ ...args
35
+ ], {
36
+ cwd: options.cwd ?? context.workspaceRoot,
37
+ env: {
38
+ ...process.env,
39
+ ULTRAMODERN_WORKSPACE_ROOT: context.workspaceRoot
40
+ },
41
+ stdio: 'inherit'
42
+ });
43
+ if (result.error) throw result.error;
44
+ return result.status ?? 1;
45
+ }
46
+ function runRenderedModule(source, context) {
47
+ const tempDir = node_fs.mkdtempSync(node_path.join(node_os.tmpdir(), 'ultramodern-tool-'));
48
+ const tempFile = node_path.join(tempDir, 'command.mjs');
49
+ try {
50
+ node_fs.writeFileSync(tempFile, source, 'utf-8');
51
+ const result = spawnSync(process.execPath, [
52
+ tempFile
53
+ ], {
54
+ cwd: context.workspaceRoot,
55
+ stdio: 'inherit'
56
+ });
57
+ if (result.error) throw result.error;
58
+ return result.status ?? 1;
59
+ } finally{
60
+ node_fs.rmSync(tempDir, {
61
+ force: true,
62
+ recursive: true
63
+ });
64
+ }
65
+ }
66
+ function runValidate(context) {
67
+ const config = readUltramodernConfig(context.workspaceRoot);
68
+ const apps = workspaceAppsFromToolingConfig(config);
69
+ const remotes = apps.filter((app)=>'shell' !== app.kind);
70
+ const source = createWorkspaceValidationScript(config.workspace.packageScope, config.features.tailwind, remotes);
71
+ return runRenderedModule(source, context);
72
+ }
73
+ function runMfTypes(args, context) {
74
+ if (args.includes('--help') || args.includes('-h')) {
75
+ process.stdout.write(`Usage:
76
+ modern-js-create ultramodern mf-types [app-dir...]
77
+
78
+ Checks real Module Federation config files and DTS archives for exposed apps.
79
+ `);
80
+ return 0;
81
+ }
82
+ validateModuleFederationTypes({
83
+ workspaceRoot: context.workspaceRoot,
84
+ appDirs: args.length > 0 ? args : void 0
85
+ });
86
+ return 0;
87
+ }
88
+ const modernPackageNames = new Set([
89
+ ...ULTRAMODERN_SINGLE_APP_MODERN_PACKAGES,
90
+ ...ULTRAMODERN_WORKSPACE_MODERN_PACKAGES
91
+ ]);
92
+ function readJsonFile(filePath) {
93
+ return JSON.parse(node_fs.readFileSync(filePath, 'utf-8'));
94
+ }
95
+ function writeJsonFile(filePath, value) {
96
+ node_fs.writeFileSync(filePath, `${JSON.stringify(value, null, 2)}\n`, 'utf-8');
97
+ }
98
+ function readOption(args, name) {
99
+ const prefix = `${name}=`;
100
+ const inline = args.find((arg)=>arg.startsWith(prefix));
101
+ if (inline) {
102
+ const value = inline.slice(prefix.length);
103
+ if (!value) throw new Error(`${name} needs a value.`);
104
+ return value;
105
+ }
106
+ const index = args.indexOf(name);
107
+ if (-1 === index) return;
108
+ const value = args[index + 1];
109
+ if (!value || value.startsWith('--')) throw new Error(`${name} needs a value.`);
110
+ return value;
111
+ }
112
+ function hasFlag(args, name) {
113
+ return args.includes(name);
114
+ }
115
+ function listWorkspacePackageFiles(workspaceRoot) {
116
+ const packageFiles = [
117
+ 'package.json'
118
+ ];
119
+ for (const directory of [
120
+ 'apps',
121
+ 'verticals',
122
+ 'packages'
123
+ ]){
124
+ const absoluteDirectory = node_path.join(workspaceRoot, directory);
125
+ if (node_fs.existsSync(absoluteDirectory)) for (const entry of node_fs.readdirSync(absoluteDirectory, {
126
+ withFileTypes: true
127
+ })){
128
+ if (!entry.isDirectory()) continue;
129
+ const packageFile = node_path.join(directory, entry.name, 'package.json');
130
+ if (node_fs.existsSync(node_path.join(workspaceRoot, packageFile))) packageFiles.push(packageFile);
131
+ }
132
+ }
133
+ return packageFiles;
134
+ }
135
+ function updateModernDependencies(packageJson, packageSource) {
136
+ let changed = false;
137
+ for (const section of [
138
+ 'dependencies',
139
+ 'devDependencies',
140
+ 'peerDependencies',
141
+ 'optionalDependencies'
142
+ ]){
143
+ const dependencies = packageJson[section];
144
+ if (!(!dependencies || 'object' != typeof dependencies || Array.isArray(dependencies))) for (const packageName of Object.keys(dependencies)){
145
+ if (!modernPackageNames.has(packageName)) continue;
146
+ const nextSpecifier = modernPackageSpecifier(packageName, packageSource);
147
+ if (dependencies[packageName] !== nextSpecifier) {
148
+ dependencies[packageName] = nextSpecifier;
149
+ changed = true;
150
+ }
151
+ }
152
+ }
153
+ return changed;
154
+ }
155
+ function normalizeStrictEffectApiMetadata(value) {
156
+ const api = value.api;
157
+ if (!api || 'object' != typeof api || Array.isArray(api)) return false;
158
+ let changed = false;
159
+ const oldEffect = api.effect;
160
+ if (oldEffect && 'object' == typeof oldEffect && !Array.isArray(oldEffect)) {
161
+ if (void 0 === api.stem && 'string' == typeof oldEffect.stem) {
162
+ api.stem = oldEffect.stem;
163
+ changed = true;
164
+ }
165
+ if (void 0 === api.prefix && 'string' == typeof oldEffect.prefix) {
166
+ api.prefix = oldEffect.prefix;
167
+ changed = true;
168
+ }
169
+ if (void 0 === api.consumedBy && Array.isArray(oldEffect.consumedBy)) {
170
+ api.consumedBy = oldEffect.consumedBy;
171
+ changed = true;
172
+ }
173
+ delete api.effect;
174
+ changed = true;
175
+ }
176
+ if (void 0 !== api.runtime && 'effect' !== api.runtime) {
177
+ api.runtime = 'effect';
178
+ changed = true;
179
+ }
180
+ if (api.bff && 'object' == typeof api.bff && !Array.isArray(api.bff)) {
181
+ if (true !== api.bff.strictEffectApproach) {
182
+ api.bff.strictEffectApproach = true;
183
+ changed = true;
184
+ }
185
+ }
186
+ if ('string' == typeof value.path) {
187
+ const directServerEntry = `${value.path}/api/index.ts`;
188
+ if ('string' == typeof api.serverEntry && /\/api\/effect\/index\.[cm]?[jt]sx?$/u.test(api.serverEntry)) {
189
+ api.serverEntry = directServerEntry;
190
+ changed = true;
191
+ }
192
+ if (api.contract && 'object' == typeof api.contract && !Array.isArray(api.contract)) {
193
+ if ('./shared/effect/api' === api.contract.export) {
194
+ api.contract.export = './api';
195
+ changed = true;
196
+ }
197
+ if ('string' == typeof api.contract.path && /\/shared\/effect\/api\.[cm]?[jt]sx?$/u.test(api.contract.path)) {
198
+ api.contract.path = `${value.path}/shared/api.ts`;
199
+ changed = true;
200
+ }
201
+ }
202
+ if (api.client && 'object' == typeof api.client && !Array.isArray(api.client)) {
203
+ if ('./effect/client' === api.client.export) {
204
+ api.client.export = './api/client';
205
+ changed = true;
206
+ }
207
+ if ('string' == typeof api.client.path && /\/src\/effect\/[^/]+-client\.[cm]?ts$/u.test(api.client.path)) {
208
+ const basename = node_path.basename(api.client.path);
209
+ api.client.path = `${value.path}/src/api/${basename}`;
210
+ changed = true;
211
+ }
212
+ }
213
+ if (void 0 === api.serverEntry && 'effect' === api.runtime) {
214
+ api.serverEntry = directServerEntry;
215
+ changed = true;
216
+ }
217
+ }
218
+ return changed;
219
+ }
220
+ function updateUltramodernConfig(workspaceRoot, packageSource) {
221
+ const configPath = node_path.join(workspaceRoot, '.modernjs/ultramodern.json');
222
+ const config = readJsonFile(configPath);
223
+ config.packageSource = {
224
+ strategy: packageSource.strategy,
225
+ modernPackageVersion: packageSource.modernPackageVersion,
226
+ ...packageSource.registry ? {
227
+ registry: packageSource.registry
228
+ } : {},
229
+ ...packageSource.aliasScope ? {
230
+ aliasScope: packageSource.aliasScope
231
+ } : {},
232
+ ...packageSource.aliasPackageNamePrefix ? {
233
+ aliasPackageNamePrefix: packageSource.aliasPackageNamePrefix
234
+ } : {}
235
+ };
236
+ for (const app of config.topology?.apps ?? [])if (app && 'object' == typeof app && !Array.isArray(app)) normalizeStrictEffectApiMetadata(app);
237
+ writeJsonFile(configPath, config);
238
+ }
239
+ function updateReferenceTopology(workspaceRoot) {
240
+ const topologyPath = node_path.join(workspaceRoot, 'topology/reference-topology.json');
241
+ if (!node_fs.existsSync(topologyPath)) return false;
242
+ const topology = readJsonFile(topologyPath);
243
+ let changed = false;
244
+ for (const vertical of topology.verticals ?? [])if (vertical && 'object' == typeof vertical && !Array.isArray(vertical)) changed = normalizeStrictEffectApiMetadata(vertical) || changed;
245
+ if (changed) writeJsonFile(topologyPath, topology);
246
+ return changed;
247
+ }
248
+ function createMigrationPackageSource(args, current) {
249
+ const strategy = hasFlag(args, '--workspace') ? 'workspace' : 'install';
250
+ const registry = readOption(args, '--registry') ?? readOption(args, '--ultramodern-package-registry');
251
+ const explicitAliasScope = readOption(args, '--alias-scope') ?? readOption(args, '--ultramodern-package-scope');
252
+ const aliasScope = explicitAliasScope ?? ('install' === strategy && void 0 === registry ? current.packageSource?.aliasScope ?? BLEEDINGDEV_PACKAGE_SCOPE : current.packageSource?.aliasScope);
253
+ const aliasPackageNamePrefix = readOption(args, '--alias-package-name-prefix') ?? readOption(args, '--ultramodern-package-name-prefix') ?? current.packageSource?.aliasPackageNamePrefix ?? (aliasScope ? BLEEDINGDEV_PACKAGE_NAME_PREFIX : void 0);
254
+ if ('workspace' === strategy) return {
255
+ strategy,
256
+ modernPackageVersion: WORKSPACE_PACKAGE_VERSION,
257
+ ...registry ? {
258
+ registry
259
+ } : {},
260
+ ...aliasScope ? {
261
+ aliasScope
262
+ } : {},
263
+ ...aliasPackageNamePrefix ? {
264
+ aliasPackageNamePrefix
265
+ } : {}
266
+ };
267
+ const version = readOption(args, '--version') ?? readOption(args, '--ultramodern-package-version') ?? current.packageSource?.modernPackageVersion;
268
+ if (!version || version === WORKSPACE_PACKAGE_VERSION) throw new Error('migrate-strict-effect needs --version <published-ultramodern-version> for install package source.');
269
+ return {
270
+ strategy,
271
+ modernPackageVersion: version,
272
+ ...registry ? {
273
+ registry
274
+ } : {},
275
+ ...aliasScope ? {
276
+ aliasScope
277
+ } : {},
278
+ ...aliasPackageNamePrefix ? {
279
+ aliasPackageNamePrefix
280
+ } : {}
281
+ };
282
+ }
283
+ function runPnpmLockfileRefresh(context) {
284
+ const result = spawnSync('pnpm', [
285
+ 'install',
286
+ '--lockfile-only',
287
+ "--ignore-scripts"
288
+ ], {
289
+ cwd: context.workspaceRoot,
290
+ stdio: 'inherit'
291
+ });
292
+ if (result.error) throw result.error;
293
+ return result.status ?? 1;
294
+ }
295
+ function runMigrateStrictEffect(args, context) {
296
+ if (args.includes('--help') || args.includes('-h')) {
297
+ process.stdout.write(`Usage:
298
+ modern-js-create ultramodern migrate-strict-effect --version <version> [--skip-install]
299
+
300
+ Updates generated UltraModern package-source metadata, Modern package aliases,
301
+ direct Effect API topology metadata, and the pnpm lockfile for strict Effect
302
+ workspaces. Source code still has to pass pnpm api:check and pnpm contract:check.
303
+ `);
304
+ return 0;
305
+ }
306
+ const current = readUltramodernConfig(context.workspaceRoot);
307
+ const packageSource = createMigrationPackageSource(args, current);
308
+ updateUltramodernConfig(context.workspaceRoot, packageSource);
309
+ updateReferenceTopology(context.workspaceRoot);
310
+ for (const relativePackageFile of listWorkspacePackageFiles(context.workspaceRoot)){
311
+ const packageFile = node_path.join(context.workspaceRoot, relativePackageFile);
312
+ const packageJson = readJsonFile(packageFile);
313
+ if ('package.json' === relativePackageFile) {
314
+ packageJson.modernjs ??= {};
315
+ packageJson.modernjs.packageSource = {
316
+ strategy: packageSource.strategy,
317
+ config: './.modernjs/ultramodern.json'
318
+ };
319
+ }
320
+ if (updateModernDependencies(packageJson, packageSource)) writeJsonFile(packageFile, packageJson);
321
+ else if ('package.json' === relativePackageFile) writeJsonFile(packageFile, packageJson);
322
+ }
323
+ if (!hasFlag(args, '--skip-install')) {
324
+ const status = runPnpmLockfileRefresh(context);
325
+ if (0 !== status) return status;
326
+ }
327
+ process.stdout.write(`UltraModern strict Effect metadata migrated to ${packageSource.modernPackageVersion}. Run pnpm api:check && pnpm contract:check next.\n`);
328
+ return 0;
329
+ }
330
+ function runSkills(args, context) {
331
+ const [subcommand, ...rest] = args;
332
+ if ('install' === subcommand) return spawnNodeScript("template-workspace/scripts/bootstrap-agent-skills.mjs", rest, context);
333
+ if ('check' === subcommand) return spawnNodeScript("template-workspace/scripts/bootstrap-agent-skills.mjs", [
334
+ '--check',
335
+ ...rest
336
+ ], context);
337
+ throw new Error('Usage: modern-js-create ultramodern skills <install|check>');
338
+ }
339
+ async function runUltramodernToolingCli(args, workspaceRoot = process.env.ULTRAMODERN_WORKSPACE_ROOT ?? process.cwd()) {
340
+ try {
341
+ const [command, ...rest] = args;
342
+ const context = {
343
+ workspaceRoot: node_path.resolve(workspaceRoot),
344
+ invocationCwd: process.cwd()
345
+ };
346
+ switch(command){
347
+ case void 0:
348
+ case '--help':
349
+ case '-h':
350
+ printHelp();
351
+ return 0;
352
+ case 'validate':
353
+ return runValidate(context);
354
+ case 'typecheck':
355
+ return spawnNodeScript("templates/workspace-scripts/ultramodern-typecheck.mjs", rest, context, {
356
+ cwd: context.invocationCwd
357
+ });
358
+ case 'mf-types':
359
+ return runMfTypes(rest, context);
360
+ case 'migrate-strict-effect':
361
+ return runMigrateStrictEffect(rest, context);
362
+ case 'public-surface':
363
+ return spawnNodeScript("templates/workspace-scripts/generate-public-surface-assets.mjs", rest, context);
364
+ case 'cloudflare-proof':
365
+ return spawnNodeScript("templates/workspace-scripts/proof-cloudflare-version.mjs", rest, context);
366
+ case 'performance-readiness':
367
+ return spawnNodeScript("templates/workspace-scripts/ultramodern-performance-readiness.mjs", rest, context);
368
+ case 'skills':
369
+ return runSkills(rest, context);
370
+ default:
371
+ throw new Error(`Unknown UltraModern command: ${command}`);
372
+ }
373
+ } catch (error) {
374
+ const message = error instanceof Error ? error.message : String(error);
375
+ process.stderr.write(`[ultramodern] ${message}\n`);
376
+ return 1;
377
+ }
378
+ }
379
+ export { runUltramodernToolingCli };