@bleedingdev/modern-js-create 3.4.0-ultramodern.8 → 3.5.0-ultramodern.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.
- package/README.md +25 -23
- package/dist/cjs/index.cjs +37 -4
- package/dist/cjs/locale/en.cjs +12 -2
- package/dist/cjs/locale/zh.cjs +12 -2
- package/dist/cjs/ultramodern-tooling/commands.cjs +185 -0
- package/dist/cjs/ultramodern-tooling/config.cjs +172 -0
- package/dist/cjs/ultramodern-workspace/add-vertical.cjs +87 -75
- package/dist/cjs/ultramodern-workspace/{effect-api.cjs → api.cjs} +207 -208
- package/dist/cjs/ultramodern-workspace/bridge-config.cjs +327 -0
- package/dist/cjs/ultramodern-workspace/codesmith.cjs +1 -0
- package/dist/cjs/ultramodern-workspace/contracts.cjs +127 -657
- package/dist/cjs/ultramodern-workspace/demo-components.cjs +12 -12
- package/dist/cjs/ultramodern-workspace/descriptors.cjs +25 -25
- package/dist/cjs/ultramodern-workspace/fs-io.cjs +117 -0
- package/dist/cjs/ultramodern-workspace/generation-result.cjs +5 -5
- package/dist/cjs/ultramodern-workspace/index.cjs +4 -0
- package/dist/cjs/ultramodern-workspace/mf-validation.cjs +571 -0
- package/dist/cjs/ultramodern-workspace/module-federation.cjs +33 -18
- package/dist/cjs/ultramodern-workspace/overlays.cjs +2 -2
- package/dist/cjs/ultramodern-workspace/package-json.cjs +57 -41
- package/dist/cjs/ultramodern-workspace/policy.cjs +4 -4
- package/dist/cjs/ultramodern-workspace/public-api.cjs +4 -0
- package/dist/cjs/ultramodern-workspace/public-surface.cjs +2 -2
- package/dist/cjs/ultramodern-workspace/versions.cjs +5 -0
- package/dist/cjs/ultramodern-workspace/workspace-scripts.cjs +119 -50
- package/dist/cjs/ultramodern-workspace/write-workspace.cjs +62 -21
- package/dist/esm/index.js +37 -4
- package/dist/esm/locale/en.js +12 -2
- package/dist/esm/locale/zh.js +12 -2
- package/dist/esm/ultramodern-tooling/commands.js +132 -0
- package/dist/esm/ultramodern-tooling/config.js +120 -0
- package/dist/esm/ultramodern-workspace/add-vertical.js +88 -79
- package/dist/esm/ultramodern-workspace/{effect-api.js → api.js} +146 -147
- package/dist/esm/ultramodern-workspace/bridge-config.js +270 -0
- package/dist/esm/ultramodern-workspace/codesmith.js +1 -0
- package/dist/esm/ultramodern-workspace/contracts.js +129 -611
- package/dist/esm/ultramodern-workspace/demo-components.js +13 -13
- package/dist/esm/ultramodern-workspace/descriptors.js +11 -11
- package/dist/esm/ultramodern-workspace/fs-io.js +116 -2
- package/dist/esm/ultramodern-workspace/generation-result.js +6 -6
- package/dist/esm/ultramodern-workspace/index.js +1 -0
- package/dist/esm/ultramodern-workspace/mf-validation.js +516 -0
- package/dist/esm/ultramodern-workspace/module-federation.js +34 -19
- package/dist/esm/ultramodern-workspace/overlays.js +2 -2
- package/dist/esm/ultramodern-workspace/package-json.js +56 -40
- package/dist/esm/ultramodern-workspace/policy.js +5 -5
- package/dist/esm/ultramodern-workspace/public-api.js +1 -0
- package/dist/esm/ultramodern-workspace/public-surface.js +2 -2
- package/dist/esm/ultramodern-workspace/versions.js +3 -1
- package/dist/esm/ultramodern-workspace/workspace-scripts.js +107 -34
- package/dist/esm/ultramodern-workspace/write-workspace.js +64 -26
- package/dist/esm-node/index.js +37 -4
- package/dist/esm-node/locale/en.js +12 -2
- package/dist/esm-node/locale/zh.js +12 -2
- package/dist/esm-node/ultramodern-tooling/commands.js +133 -0
- package/dist/esm-node/ultramodern-tooling/config.js +121 -0
- package/dist/esm-node/ultramodern-workspace/add-vertical.js +88 -79
- package/dist/esm-node/ultramodern-workspace/{effect-api.js → api.js} +146 -147
- package/dist/esm-node/ultramodern-workspace/bridge-config.js +271 -0
- package/dist/esm-node/ultramodern-workspace/codesmith.js +1 -0
- package/dist/esm-node/ultramodern-workspace/contracts.js +129 -611
- package/dist/esm-node/ultramodern-workspace/demo-components.js +13 -13
- package/dist/esm-node/ultramodern-workspace/descriptors.js +11 -11
- package/dist/esm-node/ultramodern-workspace/fs-io.js +116 -2
- package/dist/esm-node/ultramodern-workspace/generation-result.js +6 -6
- package/dist/esm-node/ultramodern-workspace/index.js +1 -0
- package/dist/esm-node/ultramodern-workspace/mf-validation.js +517 -0
- package/dist/esm-node/ultramodern-workspace/module-federation.js +34 -19
- package/dist/esm-node/ultramodern-workspace/overlays.js +2 -2
- package/dist/esm-node/ultramodern-workspace/package-json.js +56 -40
- package/dist/esm-node/ultramodern-workspace/policy.js +5 -5
- package/dist/esm-node/ultramodern-workspace/public-api.js +1 -0
- package/dist/esm-node/ultramodern-workspace/public-surface.js +2 -2
- package/dist/esm-node/ultramodern-workspace/versions.js +3 -1
- package/dist/esm-node/ultramodern-workspace/workspace-scripts.js +107 -34
- package/dist/esm-node/ultramodern-workspace/write-workspace.js +64 -26
- package/dist/types/locale/en.d.ts +10 -0
- package/dist/types/locale/index.d.ts +20 -0
- package/dist/types/locale/zh.d.ts +10 -0
- package/dist/types/ultramodern-tooling/commands.d.ts +1 -0
- package/dist/types/ultramodern-tooling/config.d.ts +43 -0
- package/dist/types/ultramodern-workspace/add-vertical.d.ts +5 -2
- package/dist/types/ultramodern-workspace/api.d.ts +73 -0
- package/dist/types/ultramodern-workspace/bridge-config.d.ts +64 -0
- package/dist/types/ultramodern-workspace/codesmith.d.ts +1 -0
- package/dist/types/ultramodern-workspace/contracts.d.ts +2 -17
- package/dist/types/ultramodern-workspace/descriptors.d.ts +10 -10
- package/dist/types/ultramodern-workspace/fs-io.d.ts +1 -0
- package/dist/types/ultramodern-workspace/index.d.ts +2 -0
- package/dist/types/ultramodern-workspace/mf-validation.d.ts +27 -0
- package/dist/types/ultramodern-workspace/package-json.d.ts +5 -4
- package/dist/types/ultramodern-workspace/public-api.d.ts +2 -0
- package/dist/types/ultramodern-workspace/types.d.ts +9 -7
- package/dist/types/ultramodern-workspace/versions.d.ts +2 -0
- package/dist/types/ultramodern-workspace/workspace-scripts.d.ts +2 -7
- package/dist/types/ultramodern-workspace/write-workspace.d.ts +4 -2
- package/package.json +5 -3
- package/template-workspace/{.agents → .codex}/skills-lock.json +12 -12
- package/template-workspace/.github/workflows/ultramodern-workspace-gates.yml.handlebars +2 -0
- package/template-workspace/.gitignore.handlebars +3 -0
- package/template-workspace/AGENTS.md.handlebars +11 -5
- package/template-workspace/README.md.handlebars +15 -12
- package/template-workspace/oxfmt.config.ts +1 -0
- package/template-workspace/oxlint.config.ts +1 -0
- package/template-workspace/patches/@tanstack__router-core@1.171.13.patch +51 -0
- package/template-workspace/pnpm-workspace.yaml.handlebars +4 -0
- package/template-workspace/scripts/bootstrap-agent-skills.mjs +77 -67
- package/templates/workspace-scripts/assert-mf-types.mjs.handlebars +51 -8
- package/templates/workspace-scripts/check-ultramodern-api-boundaries.mts +344 -0
- package/templates/workspace-scripts/{check-ultramodern-i18n-boundaries.mjs → check-ultramodern-i18n-boundaries.mts} +1 -1
- package/templates/workspace-scripts/generate-public-surface-assets.mjs +246 -9
- package/templates/workspace-scripts/proof-cloudflare-version.mjs +277 -9
- package/templates/workspace-scripts/ultramodern-cloudflare-proof.mjs +35 -10
- package/templates/workspace-scripts/ultramodern-performance-readiness.mjs +165 -2
- package/templates/workspace-scripts/ultramodern-typecheck.mjs +4 -2
- package/templates/workspace-scripts/validate-ultramodern-workspace.mjs.handlebars +840 -84
- package/dist/types/ultramodern-workspace/effect-api.d.ts +0 -73
- /package/template-workspace/{.agents → .codex}/rstackjs-agent-skills-LICENSE +0 -0
- /package/template-workspace/{.agents → .codex}/skills/rsbuild-best-practices/SKILL.md +0 -0
- /package/template-workspace/{.agents → .codex}/skills/rsdoctor-analysis/SKILL.md +0 -0
- /package/template-workspace/{.agents → .codex}/skills/rsdoctor-analysis/references/command-map.md +0 -0
- /package/template-workspace/{.agents → .codex}/skills/rsdoctor-analysis/references/common-analysis-patterns.md +0 -0
- /package/template-workspace/{.agents → .codex}/skills/rsdoctor-analysis/references/install-rsdoctor-common.md +0 -0
- /package/template-workspace/{.agents → .codex}/skills/rsdoctor-analysis/references/install-rsdoctor-rspack.md +0 -0
- /package/template-workspace/{.agents → .codex}/skills/rsdoctor-analysis/references/install-rsdoctor-webpack.md +0 -0
- /package/template-workspace/{.agents → .codex}/skills/rsdoctor-analysis/references/install-rsdoctor.md +0 -0
- /package/template-workspace/{.agents → .codex}/skills/rsdoctor-analysis/references/rsdoctor-data-types.md +0 -0
- /package/template-workspace/{.agents → .codex}/skills/rslib-best-practices/SKILL.md +0 -0
- /package/template-workspace/{.agents → .codex}/skills/rslib-modern-package/SKILL.md +0 -0
- /package/template-workspace/{.agents → .codex}/skills/rspack-best-practices/SKILL.md +0 -0
- /package/template-workspace/{.agents → .codex}/skills/rspack-tracing/SKILL.md +0 -0
- /package/template-workspace/{.agents → .codex}/skills/rspack-tracing/references/bottlenecks.md +0 -0
- /package/template-workspace/{.agents → .codex}/skills/rspack-tracing/references/tracing-guide.md +0 -0
- /package/template-workspace/{.agents → .codex}/skills/rspack-tracing/scripts/analyze_trace.js +0 -0
- /package/template-workspace/{.agents → .codex}/skills/rstest-best-practices/SKILL.md +0 -0
package/dist/esm-node/index.js
CHANGED
|
@@ -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
|
|
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,\
|
|
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
|
|
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、\
|
|
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
|
|
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,133 @@
|
|
|
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 { validateModuleFederationTypes } from "../ultramodern-workspace/mf-validation.js";
|
|
9
|
+
import { createWorkspaceValidationScript } from "../ultramodern-workspace/workspace-scripts.js";
|
|
10
|
+
import { readUltramodernConfig, workspaceAppsFromToolingConfig } from "./config.js";
|
|
11
|
+
const commands_dirname = node_path.dirname(fileURLToPath(import.meta.url));
|
|
12
|
+
const createPackageRoot = resolveCreatePackageRoot(commands_dirname);
|
|
13
|
+
function printHelp() {
|
|
14
|
+
process.stdout.write(`Usage:
|
|
15
|
+
modern-js-create ultramodern <command> [args]
|
|
16
|
+
|
|
17
|
+
Commands:
|
|
18
|
+
validate
|
|
19
|
+
typecheck
|
|
20
|
+
mf-types
|
|
21
|
+
public-surface
|
|
22
|
+
cloudflare-proof
|
|
23
|
+
performance-readiness
|
|
24
|
+
skills install
|
|
25
|
+
skills check
|
|
26
|
+
`);
|
|
27
|
+
}
|
|
28
|
+
function spawnNodeScript(relativeScriptPath, args, context, options = {}) {
|
|
29
|
+
const scriptPath = node_path.join(createPackageRoot, relativeScriptPath);
|
|
30
|
+
const result = spawnSync(process.execPath, [
|
|
31
|
+
scriptPath,
|
|
32
|
+
...args
|
|
33
|
+
], {
|
|
34
|
+
cwd: options.cwd ?? context.workspaceRoot,
|
|
35
|
+
env: {
|
|
36
|
+
...process.env,
|
|
37
|
+
ULTRAMODERN_WORKSPACE_ROOT: context.workspaceRoot
|
|
38
|
+
},
|
|
39
|
+
stdio: 'inherit'
|
|
40
|
+
});
|
|
41
|
+
if (result.error) throw result.error;
|
|
42
|
+
return result.status ?? 1;
|
|
43
|
+
}
|
|
44
|
+
function runRenderedModule(source, context) {
|
|
45
|
+
const tempDir = node_fs.mkdtempSync(node_path.join(node_os.tmpdir(), 'ultramodern-tool-'));
|
|
46
|
+
const tempFile = node_path.join(tempDir, 'command.mjs');
|
|
47
|
+
try {
|
|
48
|
+
node_fs.writeFileSync(tempFile, source, 'utf-8');
|
|
49
|
+
const result = spawnSync(process.execPath, [
|
|
50
|
+
tempFile
|
|
51
|
+
], {
|
|
52
|
+
cwd: context.workspaceRoot,
|
|
53
|
+
stdio: 'inherit'
|
|
54
|
+
});
|
|
55
|
+
if (result.error) throw result.error;
|
|
56
|
+
return result.status ?? 1;
|
|
57
|
+
} finally{
|
|
58
|
+
node_fs.rmSync(tempDir, {
|
|
59
|
+
force: true,
|
|
60
|
+
recursive: true
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function runValidate(context) {
|
|
65
|
+
const config = readUltramodernConfig(context.workspaceRoot);
|
|
66
|
+
const apps = workspaceAppsFromToolingConfig(config);
|
|
67
|
+
const remotes = apps.filter((app)=>'shell' !== app.kind);
|
|
68
|
+
const source = createWorkspaceValidationScript(config.workspace.packageScope, config.features.tailwind, remotes);
|
|
69
|
+
return runRenderedModule(source, context);
|
|
70
|
+
}
|
|
71
|
+
function runMfTypes(args, context) {
|
|
72
|
+
if (args.includes('--help') || args.includes('-h')) {
|
|
73
|
+
process.stdout.write(`Usage:
|
|
74
|
+
modern-js-create ultramodern mf-types [app-dir...]
|
|
75
|
+
|
|
76
|
+
Checks real Module Federation config files and DTS archives for exposed apps.
|
|
77
|
+
`);
|
|
78
|
+
return 0;
|
|
79
|
+
}
|
|
80
|
+
validateModuleFederationTypes({
|
|
81
|
+
workspaceRoot: context.workspaceRoot,
|
|
82
|
+
appDirs: args.length > 0 ? args : void 0
|
|
83
|
+
});
|
|
84
|
+
return 0;
|
|
85
|
+
}
|
|
86
|
+
function runSkills(args, context) {
|
|
87
|
+
const [subcommand, ...rest] = args;
|
|
88
|
+
if ('install' === subcommand) return spawnNodeScript("template-workspace/scripts/bootstrap-agent-skills.mjs", rest, context);
|
|
89
|
+
if ('check' === subcommand) return spawnNodeScript("template-workspace/scripts/bootstrap-agent-skills.mjs", [
|
|
90
|
+
'--check',
|
|
91
|
+
...rest
|
|
92
|
+
], context);
|
|
93
|
+
throw new Error('Usage: modern-js-create ultramodern skills <install|check>');
|
|
94
|
+
}
|
|
95
|
+
async function runUltramodernToolingCli(args, workspaceRoot = process.env.ULTRAMODERN_WORKSPACE_ROOT ?? process.cwd()) {
|
|
96
|
+
try {
|
|
97
|
+
const [command, ...rest] = args;
|
|
98
|
+
const context = {
|
|
99
|
+
workspaceRoot: node_path.resolve(workspaceRoot),
|
|
100
|
+
invocationCwd: process.cwd()
|
|
101
|
+
};
|
|
102
|
+
switch(command){
|
|
103
|
+
case void 0:
|
|
104
|
+
case '--help':
|
|
105
|
+
case '-h':
|
|
106
|
+
printHelp();
|
|
107
|
+
return 0;
|
|
108
|
+
case 'validate':
|
|
109
|
+
return runValidate(context);
|
|
110
|
+
case 'typecheck':
|
|
111
|
+
return spawnNodeScript("templates/workspace-scripts/ultramodern-typecheck.mjs", rest, context, {
|
|
112
|
+
cwd: context.invocationCwd
|
|
113
|
+
});
|
|
114
|
+
case 'mf-types':
|
|
115
|
+
return runMfTypes(rest, context);
|
|
116
|
+
case 'public-surface':
|
|
117
|
+
return spawnNodeScript("templates/workspace-scripts/generate-public-surface-assets.mjs", rest, context);
|
|
118
|
+
case 'cloudflare-proof':
|
|
119
|
+
return spawnNodeScript("templates/workspace-scripts/proof-cloudflare-version.mjs", rest, context);
|
|
120
|
+
case 'performance-readiness':
|
|
121
|
+
return spawnNodeScript("templates/workspace-scripts/ultramodern-performance-readiness.mjs", rest, context);
|
|
122
|
+
case 'skills':
|
|
123
|
+
return runSkills(rest, context);
|
|
124
|
+
default:
|
|
125
|
+
throw new Error(`Unknown UltraModern command: ${command}`);
|
|
126
|
+
}
|
|
127
|
+
} catch (error) {
|
|
128
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
129
|
+
process.stderr.write(`[ultramodern] ${message}\n`);
|
|
130
|
+
return 1;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
export { runUltramodernToolingCli };
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import node_fs from "node:fs";
|
|
3
|
+
import node_path from "node:path";
|
|
4
|
+
import { normalizeUltramodernBridgeConfig } from "../ultramodern-workspace/bridge-config.js";
|
|
5
|
+
import { ULTRAMODERN_CONFIG_PATH, createNeutralOwnership, shellApp } from "../ultramodern-workspace/descriptors.js";
|
|
6
|
+
import { toKebabCase } from "../ultramodern-workspace/naming.js";
|
|
7
|
+
function readJsonObject(filePath) {
|
|
8
|
+
const value = JSON.parse(node_fs.readFileSync(filePath, 'utf-8'));
|
|
9
|
+
if (null === value || 'object' != typeof value || Array.isArray(value)) throw new Error(`UltraModern config must contain a JSON object: ${filePath}`);
|
|
10
|
+
return value;
|
|
11
|
+
}
|
|
12
|
+
function readOptionalJsonObject(filePath) {
|
|
13
|
+
return node_fs.existsSync(filePath) ? readJsonObject(filePath) : {};
|
|
14
|
+
}
|
|
15
|
+
function packageScopeFromRoot(workspaceRoot1) {
|
|
16
|
+
const rootPackage = readOptionalJsonObject(node_path.join(workspaceRoot1, 'package.json'));
|
|
17
|
+
return 'string' == typeof rootPackage.name && rootPackage.name.length > 0 ? rootPackage.name : node_path.basename(workspaceRoot1);
|
|
18
|
+
}
|
|
19
|
+
function normalizeCompactConfig(sourcePath, config) {
|
|
20
|
+
const packageSource = config.packageSource && 'object' == typeof config.packageSource ? {
|
|
21
|
+
strategy: 'install' === config.packageSource.strategy ? 'install' : 'workspace',
|
|
22
|
+
modernPackageVersion: 'string' == typeof config.packageSource.modernPackageVersion ? config.packageSource.modernPackageVersion : 'workspace:*',
|
|
23
|
+
registry: 'string' == typeof config.packageSource.registry ? config.packageSource.registry : void 0,
|
|
24
|
+
aliasScope: 'string' == typeof config.packageSource.aliasScope ? config.packageSource.aliasScope : void 0,
|
|
25
|
+
aliasPackageNamePrefix: 'string' == typeof config.packageSource.aliasPackageNamePrefix ? config.packageSource.aliasPackageNamePrefix : void 0
|
|
26
|
+
} : void 0;
|
|
27
|
+
return {
|
|
28
|
+
schemaVersion: 'number' == typeof config.schemaVersion ? config.schemaVersion : 1,
|
|
29
|
+
profile: 'string' == typeof config.profile ? config.profile : void 0,
|
|
30
|
+
source: 'compact',
|
|
31
|
+
sourcePath,
|
|
32
|
+
workspace: {
|
|
33
|
+
packageScope: 'string' == typeof config.workspace?.packageScope ? config.workspace.packageScope : packageScopeFromRoot(workspaceRoot)
|
|
34
|
+
},
|
|
35
|
+
packageSource,
|
|
36
|
+
features: {
|
|
37
|
+
tailwind: config.features?.tailwind !== false
|
|
38
|
+
},
|
|
39
|
+
bridge: normalizeUltramodernBridgeConfig(config.bridge),
|
|
40
|
+
topology: {
|
|
41
|
+
apps: Array.isArray(config.topology?.apps) ? config.topology.apps.map((app)=>({
|
|
42
|
+
id: String(app.id),
|
|
43
|
+
kind: 'vertical' === app.kind ? 'vertical' : 'shell',
|
|
44
|
+
path: 'string' == typeof app.path ? app.path : '.',
|
|
45
|
+
package: 'string' == typeof app.package ? app.package : void 0,
|
|
46
|
+
packageSuffix: 'string' == typeof app.packageSuffix ? app.packageSuffix : void 0,
|
|
47
|
+
displayName: 'string' == typeof app.displayName ? app.displayName : void 0,
|
|
48
|
+
domain: 'string' == typeof app.domain ? app.domain : void 0,
|
|
49
|
+
port: 'number' == typeof app.port ? app.port : void 0,
|
|
50
|
+
portEnv: 'string' == typeof app.portEnv ? app.portEnv : void 0,
|
|
51
|
+
moduleFederation: app.moduleFederation && 'object' == typeof app.moduleFederation ? {
|
|
52
|
+
role: 'remote' === app.moduleFederation.role ? 'remote' : 'host',
|
|
53
|
+
name: 'string' == typeof app.moduleFederation.name ? app.moduleFederation.name : void 0,
|
|
54
|
+
exposes: Array.isArray(app.moduleFederation.exposes) ? app.moduleFederation.exposes.filter((expose)=>'string' == typeof expose) : void 0,
|
|
55
|
+
exposePaths: null === app.moduleFederation.exposePaths || 'object' != typeof app.moduleFederation.exposePaths || Array.isArray(app.moduleFederation.exposePaths) ? void 0 : Object.fromEntries(Object.entries(app.moduleFederation.exposePaths).filter((entry)=>'string' == typeof entry[0] && 'string' == typeof entry[1])),
|
|
56
|
+
verticalRefs: Array.isArray(app.moduleFederation.verticalRefs) ? app.moduleFederation.verticalRefs.filter((ref)=>'string' == typeof ref) : void 0,
|
|
57
|
+
hostOnly: true === app.moduleFederation.hostOnly,
|
|
58
|
+
noExposes: true === app.moduleFederation.noExposes
|
|
59
|
+
} : void 0,
|
|
60
|
+
api: app.api && 'object' == typeof app.api ? {
|
|
61
|
+
stem: 'string' == typeof app.api.stem ? app.api.stem : String(app.id),
|
|
62
|
+
prefix: 'string' == typeof app.api.prefix ? app.api.prefix : `/${String(app.id)}-api`,
|
|
63
|
+
consumedBy: Array.isArray(app.api.consumedBy) ? app.api.consumedBy.filter((consumer)=>'string' == typeof consumer) : [
|
|
64
|
+
shellApp.id,
|
|
65
|
+
String(app.id)
|
|
66
|
+
]
|
|
67
|
+
} : void 0
|
|
68
|
+
})) : []
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
function readUltramodernConfig(workspaceRoot1 = process.cwd()) {
|
|
73
|
+
const compactPath = node_path.join(workspaceRoot1, ULTRAMODERN_CONFIG_PATH);
|
|
74
|
+
if (node_fs.existsSync(compactPath)) return normalizeCompactConfig(compactPath, readJsonObject(compactPath));
|
|
75
|
+
throw new Error(`Missing UltraModern config. Expected ${ULTRAMODERN_CONFIG_PATH}.`);
|
|
76
|
+
}
|
|
77
|
+
function workspaceAppsFromToolingConfig(config) {
|
|
78
|
+
return config.topology.apps.map((app)=>{
|
|
79
|
+
if ('shell' === app.kind) return {
|
|
80
|
+
...shellApp,
|
|
81
|
+
directory: app.path,
|
|
82
|
+
packageSuffix: app.packageSuffix ?? shellApp.packageSuffix,
|
|
83
|
+
displayName: app.displayName ?? shellApp.displayName,
|
|
84
|
+
port: app.port ?? shellApp.port,
|
|
85
|
+
portEnv: app.portEnv ?? shellApp.portEnv,
|
|
86
|
+
mfName: app.moduleFederation?.name ?? shellApp.mfName,
|
|
87
|
+
verticalRefs: app.moduleFederation?.verticalRefs ?? []
|
|
88
|
+
};
|
|
89
|
+
const domain = app.domain ?? app.id;
|
|
90
|
+
const packageSuffix = app.packageSuffix ?? domain;
|
|
91
|
+
const exposePaths = app.moduleFederation?.exposePaths ?? {};
|
|
92
|
+
const exposes = Object.fromEntries((app.moduleFederation?.exposes ?? []).map((expose)=>{
|
|
93
|
+
const configuredPath = exposePaths[expose];
|
|
94
|
+
const inferredPath = './Route' === expose ? './src/federation-entry.tsx' : './Widget' === expose ? `./src/components/${domain}-widget.tsx` : `./src/components/${toKebabCase(expose.replace(/^\.\//u, ''))}.tsx`;
|
|
95
|
+
return [
|
|
96
|
+
expose,
|
|
97
|
+
configuredPath ?? inferredPath
|
|
98
|
+
];
|
|
99
|
+
}));
|
|
100
|
+
return {
|
|
101
|
+
id: app.id,
|
|
102
|
+
directory: app.path,
|
|
103
|
+
packageSuffix,
|
|
104
|
+
displayName: app.displayName ?? `${domain} Vertical`,
|
|
105
|
+
kind: 'vertical',
|
|
106
|
+
domain,
|
|
107
|
+
portEnv: app.portEnv ?? `VERTICAL_${domain.replace(/[^a-zA-Z0-9]+/g, '_').toUpperCase()}_PORT`,
|
|
108
|
+
port: app.port ?? 0,
|
|
109
|
+
mfName: app.moduleFederation?.name ?? app.id,
|
|
110
|
+
exposes,
|
|
111
|
+
...app.moduleFederation?.verticalRefs ? {
|
|
112
|
+
verticalRefs: app.moduleFederation.verticalRefs
|
|
113
|
+
} : {},
|
|
114
|
+
...app.api ? {
|
|
115
|
+
api: app.api
|
|
116
|
+
} : {},
|
|
117
|
+
ownership: createNeutralOwnership(app.id)
|
|
118
|
+
};
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
export { readUltramodernConfig, workspaceAppsFromToolingConfig };
|