@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.
- package/README.md +49 -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 +431 -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 +128 -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 +39 -12
- package/dist/cjs/ultramodern-workspace/overlays.cjs +2 -2
- package/dist/cjs/ultramodern-workspace/package-json.cjs +58 -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 +15 -0
- package/dist/cjs/ultramodern-workspace/workspace-scripts.cjs +120 -50
- package/dist/cjs/ultramodern-workspace/write-workspace.cjs +64 -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 +378 -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 +130 -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 +40 -13
- package/dist/esm/ultramodern-workspace/overlays.js +2 -2
- package/dist/esm/ultramodern-workspace/package-json.js +57 -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 +7 -1
- package/dist/esm/ultramodern-workspace/workspace-scripts.js +108 -34
- package/dist/esm/ultramodern-workspace/write-workspace.js +66 -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 +379 -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 +130 -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 +40 -13
- package/dist/esm-node/ultramodern-workspace/overlays.js +2 -2
- package/dist/esm-node/ultramodern-workspace/package-json.js +57 -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 +7 -1
- package/dist/esm-node/ultramodern-workspace/workspace-scripts.js +108 -34
- package/dist/esm-node/ultramodern-workspace/write-workspace.js +66 -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 +6 -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 +55 -13
- 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 +7 -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 +366 -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 +842 -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
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
import node_fs from "node:fs";
|
|
3
|
+
import node_os from "node:os";
|
|
4
|
+
import node_path from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
import { resolveCreatePackageRoot } from "../create-package-root.js";
|
|
7
|
+
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";
|
|
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
|
+
migrate-strict-effect
|
|
22
|
+
public-surface
|
|
23
|
+
cloudflare-proof
|
|
24
|
+
performance-readiness
|
|
25
|
+
skills install
|
|
26
|
+
skills check
|
|
27
|
+
`);
|
|
28
|
+
}
|
|
29
|
+
function spawnNodeScript(relativeScriptPath, args, context, options = {}) {
|
|
30
|
+
const scriptPath = node_path.join(createPackageRoot, relativeScriptPath);
|
|
31
|
+
const result = spawnSync(process.execPath, [
|
|
32
|
+
scriptPath,
|
|
33
|
+
...args
|
|
34
|
+
], {
|
|
35
|
+
cwd: options.cwd ?? context.workspaceRoot,
|
|
36
|
+
env: {
|
|
37
|
+
...process.env,
|
|
38
|
+
ULTRAMODERN_WORKSPACE_ROOT: context.workspaceRoot
|
|
39
|
+
},
|
|
40
|
+
stdio: 'inherit'
|
|
41
|
+
});
|
|
42
|
+
if (result.error) throw result.error;
|
|
43
|
+
return result.status ?? 1;
|
|
44
|
+
}
|
|
45
|
+
function runRenderedModule(source, context) {
|
|
46
|
+
const tempDir = node_fs.mkdtempSync(node_path.join(node_os.tmpdir(), 'ultramodern-tool-'));
|
|
47
|
+
const tempFile = node_path.join(tempDir, 'command.mjs');
|
|
48
|
+
try {
|
|
49
|
+
node_fs.writeFileSync(tempFile, source, 'utf-8');
|
|
50
|
+
const result = spawnSync(process.execPath, [
|
|
51
|
+
tempFile
|
|
52
|
+
], {
|
|
53
|
+
cwd: context.workspaceRoot,
|
|
54
|
+
stdio: 'inherit'
|
|
55
|
+
});
|
|
56
|
+
if (result.error) throw result.error;
|
|
57
|
+
return result.status ?? 1;
|
|
58
|
+
} finally{
|
|
59
|
+
node_fs.rmSync(tempDir, {
|
|
60
|
+
force: true,
|
|
61
|
+
recursive: true
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function runValidate(context) {
|
|
66
|
+
const config = readUltramodernConfig(context.workspaceRoot);
|
|
67
|
+
const apps = workspaceAppsFromToolingConfig(config);
|
|
68
|
+
const remotes = apps.filter((app)=>'shell' !== app.kind);
|
|
69
|
+
const source = createWorkspaceValidationScript(config.workspace.packageScope, config.features.tailwind, remotes);
|
|
70
|
+
return runRenderedModule(source, context);
|
|
71
|
+
}
|
|
72
|
+
function runMfTypes(args, context) {
|
|
73
|
+
if (args.includes('--help') || args.includes('-h')) {
|
|
74
|
+
process.stdout.write(`Usage:
|
|
75
|
+
modern-js-create ultramodern mf-types [app-dir...]
|
|
76
|
+
|
|
77
|
+
Checks real Module Federation config files and DTS archives for exposed apps.
|
|
78
|
+
`);
|
|
79
|
+
return 0;
|
|
80
|
+
}
|
|
81
|
+
validateModuleFederationTypes({
|
|
82
|
+
workspaceRoot: context.workspaceRoot,
|
|
83
|
+
appDirs: args.length > 0 ? args : void 0
|
|
84
|
+
});
|
|
85
|
+
return 0;
|
|
86
|
+
}
|
|
87
|
+
const modernPackageNames = new Set([
|
|
88
|
+
...ULTRAMODERN_SINGLE_APP_MODERN_PACKAGES,
|
|
89
|
+
...ULTRAMODERN_WORKSPACE_MODERN_PACKAGES
|
|
90
|
+
]);
|
|
91
|
+
function readJsonFile(filePath) {
|
|
92
|
+
return JSON.parse(node_fs.readFileSync(filePath, 'utf-8'));
|
|
93
|
+
}
|
|
94
|
+
function writeJsonFile(filePath, value) {
|
|
95
|
+
node_fs.writeFileSync(filePath, `${JSON.stringify(value, null, 2)}\n`, 'utf-8');
|
|
96
|
+
}
|
|
97
|
+
function readOption(args, name) {
|
|
98
|
+
const prefix = `${name}=`;
|
|
99
|
+
const inline = args.find((arg)=>arg.startsWith(prefix));
|
|
100
|
+
if (inline) {
|
|
101
|
+
const value = inline.slice(prefix.length);
|
|
102
|
+
if (!value) throw new Error(`${name} needs a value.`);
|
|
103
|
+
return value;
|
|
104
|
+
}
|
|
105
|
+
const index = args.indexOf(name);
|
|
106
|
+
if (-1 === index) return;
|
|
107
|
+
const value = args[index + 1];
|
|
108
|
+
if (!value || value.startsWith('--')) throw new Error(`${name} needs a value.`);
|
|
109
|
+
return value;
|
|
110
|
+
}
|
|
111
|
+
function hasFlag(args, name) {
|
|
112
|
+
return args.includes(name);
|
|
113
|
+
}
|
|
114
|
+
function listWorkspacePackageFiles(workspaceRoot) {
|
|
115
|
+
const packageFiles = [
|
|
116
|
+
'package.json'
|
|
117
|
+
];
|
|
118
|
+
for (const directory of [
|
|
119
|
+
'apps',
|
|
120
|
+
'verticals',
|
|
121
|
+
'packages'
|
|
122
|
+
]){
|
|
123
|
+
const absoluteDirectory = node_path.join(workspaceRoot, directory);
|
|
124
|
+
if (node_fs.existsSync(absoluteDirectory)) for (const entry of node_fs.readdirSync(absoluteDirectory, {
|
|
125
|
+
withFileTypes: true
|
|
126
|
+
})){
|
|
127
|
+
if (!entry.isDirectory()) continue;
|
|
128
|
+
const packageFile = node_path.join(directory, entry.name, 'package.json');
|
|
129
|
+
if (node_fs.existsSync(node_path.join(workspaceRoot, packageFile))) packageFiles.push(packageFile);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return packageFiles;
|
|
133
|
+
}
|
|
134
|
+
function updateModernDependencies(packageJson, packageSource) {
|
|
135
|
+
let changed = false;
|
|
136
|
+
for (const section of [
|
|
137
|
+
'dependencies',
|
|
138
|
+
'devDependencies',
|
|
139
|
+
'peerDependencies',
|
|
140
|
+
'optionalDependencies'
|
|
141
|
+
]){
|
|
142
|
+
const dependencies = packageJson[section];
|
|
143
|
+
if (!(!dependencies || 'object' != typeof dependencies || Array.isArray(dependencies))) for (const packageName of Object.keys(dependencies)){
|
|
144
|
+
if (!modernPackageNames.has(packageName)) continue;
|
|
145
|
+
const nextSpecifier = modernPackageSpecifier(packageName, packageSource);
|
|
146
|
+
if (dependencies[packageName] !== nextSpecifier) {
|
|
147
|
+
dependencies[packageName] = nextSpecifier;
|
|
148
|
+
changed = true;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return changed;
|
|
153
|
+
}
|
|
154
|
+
function normalizeStrictEffectApiMetadata(value) {
|
|
155
|
+
const api = value.api;
|
|
156
|
+
if (!api || 'object' != typeof api || Array.isArray(api)) return false;
|
|
157
|
+
let changed = false;
|
|
158
|
+
const oldEffect = api.effect;
|
|
159
|
+
if (oldEffect && 'object' == typeof oldEffect && !Array.isArray(oldEffect)) {
|
|
160
|
+
if (void 0 === api.stem && 'string' == typeof oldEffect.stem) {
|
|
161
|
+
api.stem = oldEffect.stem;
|
|
162
|
+
changed = true;
|
|
163
|
+
}
|
|
164
|
+
if (void 0 === api.prefix && 'string' == typeof oldEffect.prefix) {
|
|
165
|
+
api.prefix = oldEffect.prefix;
|
|
166
|
+
changed = true;
|
|
167
|
+
}
|
|
168
|
+
if (void 0 === api.consumedBy && Array.isArray(oldEffect.consumedBy)) {
|
|
169
|
+
api.consumedBy = oldEffect.consumedBy;
|
|
170
|
+
changed = true;
|
|
171
|
+
}
|
|
172
|
+
delete api.effect;
|
|
173
|
+
changed = true;
|
|
174
|
+
}
|
|
175
|
+
if (void 0 !== api.runtime && 'effect' !== api.runtime) {
|
|
176
|
+
api.runtime = 'effect';
|
|
177
|
+
changed = true;
|
|
178
|
+
}
|
|
179
|
+
if (api.bff && 'object' == typeof api.bff && !Array.isArray(api.bff)) {
|
|
180
|
+
if (true !== api.bff.strictEffectApproach) {
|
|
181
|
+
api.bff.strictEffectApproach = true;
|
|
182
|
+
changed = true;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
if ('string' == typeof value.path) {
|
|
186
|
+
const directServerEntry = `${value.path}/api/index.ts`;
|
|
187
|
+
if ('string' == typeof api.serverEntry && /\/api\/effect\/index\.[cm]?[jt]sx?$/u.test(api.serverEntry)) {
|
|
188
|
+
api.serverEntry = directServerEntry;
|
|
189
|
+
changed = true;
|
|
190
|
+
}
|
|
191
|
+
if (api.contract && 'object' == typeof api.contract && !Array.isArray(api.contract)) {
|
|
192
|
+
if ('./shared/effect/api' === api.contract.export) {
|
|
193
|
+
api.contract.export = './api';
|
|
194
|
+
changed = true;
|
|
195
|
+
}
|
|
196
|
+
if ('string' == typeof api.contract.path && /\/shared\/effect\/api\.[cm]?[jt]sx?$/u.test(api.contract.path)) {
|
|
197
|
+
api.contract.path = `${value.path}/shared/api.ts`;
|
|
198
|
+
changed = true;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
if (api.client && 'object' == typeof api.client && !Array.isArray(api.client)) {
|
|
202
|
+
if ('./effect/client' === api.client.export) {
|
|
203
|
+
api.client.export = './api/client';
|
|
204
|
+
changed = true;
|
|
205
|
+
}
|
|
206
|
+
if ('string' == typeof api.client.path && /\/src\/effect\/[^/]+-client\.[cm]?ts$/u.test(api.client.path)) {
|
|
207
|
+
const basename = node_path.basename(api.client.path);
|
|
208
|
+
api.client.path = `${value.path}/src/api/${basename}`;
|
|
209
|
+
changed = true;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
if (void 0 === api.serverEntry && 'effect' === api.runtime) {
|
|
213
|
+
api.serverEntry = directServerEntry;
|
|
214
|
+
changed = true;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
return changed;
|
|
218
|
+
}
|
|
219
|
+
function updateUltramodernConfig(workspaceRoot, packageSource) {
|
|
220
|
+
const configPath = node_path.join(workspaceRoot, '.modernjs/ultramodern.json');
|
|
221
|
+
const config = readJsonFile(configPath);
|
|
222
|
+
config.packageSource = {
|
|
223
|
+
strategy: packageSource.strategy,
|
|
224
|
+
modernPackageVersion: packageSource.modernPackageVersion,
|
|
225
|
+
...packageSource.registry ? {
|
|
226
|
+
registry: packageSource.registry
|
|
227
|
+
} : {},
|
|
228
|
+
...packageSource.aliasScope ? {
|
|
229
|
+
aliasScope: packageSource.aliasScope
|
|
230
|
+
} : {},
|
|
231
|
+
...packageSource.aliasPackageNamePrefix ? {
|
|
232
|
+
aliasPackageNamePrefix: packageSource.aliasPackageNamePrefix
|
|
233
|
+
} : {}
|
|
234
|
+
};
|
|
235
|
+
for (const app of config.topology?.apps ?? [])if (app && 'object' == typeof app && !Array.isArray(app)) normalizeStrictEffectApiMetadata(app);
|
|
236
|
+
writeJsonFile(configPath, config);
|
|
237
|
+
}
|
|
238
|
+
function updateReferenceTopology(workspaceRoot) {
|
|
239
|
+
const topologyPath = node_path.join(workspaceRoot, 'topology/reference-topology.json');
|
|
240
|
+
if (!node_fs.existsSync(topologyPath)) return false;
|
|
241
|
+
const topology = readJsonFile(topologyPath);
|
|
242
|
+
let changed = false;
|
|
243
|
+
for (const vertical of topology.verticals ?? [])if (vertical && 'object' == typeof vertical && !Array.isArray(vertical)) changed = normalizeStrictEffectApiMetadata(vertical) || changed;
|
|
244
|
+
if (changed) writeJsonFile(topologyPath, topology);
|
|
245
|
+
return changed;
|
|
246
|
+
}
|
|
247
|
+
function createMigrationPackageSource(args, current) {
|
|
248
|
+
const strategy = hasFlag(args, '--workspace') ? 'workspace' : 'install';
|
|
249
|
+
const registry = readOption(args, '--registry') ?? readOption(args, '--ultramodern-package-registry');
|
|
250
|
+
const explicitAliasScope = readOption(args, '--alias-scope') ?? readOption(args, '--ultramodern-package-scope');
|
|
251
|
+
const aliasScope = explicitAliasScope ?? ('install' === strategy && void 0 === registry ? current.packageSource?.aliasScope ?? BLEEDINGDEV_PACKAGE_SCOPE : current.packageSource?.aliasScope);
|
|
252
|
+
const aliasPackageNamePrefix = readOption(args, '--alias-package-name-prefix') ?? readOption(args, '--ultramodern-package-name-prefix') ?? current.packageSource?.aliasPackageNamePrefix ?? (aliasScope ? BLEEDINGDEV_PACKAGE_NAME_PREFIX : void 0);
|
|
253
|
+
if ('workspace' === strategy) return {
|
|
254
|
+
strategy,
|
|
255
|
+
modernPackageVersion: WORKSPACE_PACKAGE_VERSION,
|
|
256
|
+
...registry ? {
|
|
257
|
+
registry
|
|
258
|
+
} : {},
|
|
259
|
+
...aliasScope ? {
|
|
260
|
+
aliasScope
|
|
261
|
+
} : {},
|
|
262
|
+
...aliasPackageNamePrefix ? {
|
|
263
|
+
aliasPackageNamePrefix
|
|
264
|
+
} : {}
|
|
265
|
+
};
|
|
266
|
+
const version = readOption(args, '--version') ?? readOption(args, '--ultramodern-package-version') ?? current.packageSource?.modernPackageVersion;
|
|
267
|
+
if (!version || version === WORKSPACE_PACKAGE_VERSION) throw new Error('migrate-strict-effect needs --version <published-ultramodern-version> for install package source.');
|
|
268
|
+
return {
|
|
269
|
+
strategy,
|
|
270
|
+
modernPackageVersion: version,
|
|
271
|
+
...registry ? {
|
|
272
|
+
registry
|
|
273
|
+
} : {},
|
|
274
|
+
...aliasScope ? {
|
|
275
|
+
aliasScope
|
|
276
|
+
} : {},
|
|
277
|
+
...aliasPackageNamePrefix ? {
|
|
278
|
+
aliasPackageNamePrefix
|
|
279
|
+
} : {}
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
function runPnpmLockfileRefresh(context) {
|
|
283
|
+
const result = spawnSync('pnpm', [
|
|
284
|
+
'install',
|
|
285
|
+
'--lockfile-only',
|
|
286
|
+
"--ignore-scripts"
|
|
287
|
+
], {
|
|
288
|
+
cwd: context.workspaceRoot,
|
|
289
|
+
stdio: 'inherit'
|
|
290
|
+
});
|
|
291
|
+
if (result.error) throw result.error;
|
|
292
|
+
return result.status ?? 1;
|
|
293
|
+
}
|
|
294
|
+
function runMigrateStrictEffect(args, context) {
|
|
295
|
+
if (args.includes('--help') || args.includes('-h')) {
|
|
296
|
+
process.stdout.write(`Usage:
|
|
297
|
+
modern-js-create ultramodern migrate-strict-effect --version <version> [--skip-install]
|
|
298
|
+
|
|
299
|
+
Updates generated UltraModern package-source metadata, Modern package aliases,
|
|
300
|
+
direct Effect API topology metadata, and the pnpm lockfile for strict Effect
|
|
301
|
+
workspaces. Source code still has to pass pnpm api:check and pnpm contract:check.
|
|
302
|
+
`);
|
|
303
|
+
return 0;
|
|
304
|
+
}
|
|
305
|
+
const current = readUltramodernConfig(context.workspaceRoot);
|
|
306
|
+
const packageSource = createMigrationPackageSource(args, current);
|
|
307
|
+
updateUltramodernConfig(context.workspaceRoot, packageSource);
|
|
308
|
+
updateReferenceTopology(context.workspaceRoot);
|
|
309
|
+
for (const relativePackageFile of listWorkspacePackageFiles(context.workspaceRoot)){
|
|
310
|
+
const packageFile = node_path.join(context.workspaceRoot, relativePackageFile);
|
|
311
|
+
const packageJson = readJsonFile(packageFile);
|
|
312
|
+
if ('package.json' === relativePackageFile) {
|
|
313
|
+
packageJson.modernjs ??= {};
|
|
314
|
+
packageJson.modernjs.packageSource = {
|
|
315
|
+
strategy: packageSource.strategy,
|
|
316
|
+
config: './.modernjs/ultramodern.json'
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
if (updateModernDependencies(packageJson, packageSource)) writeJsonFile(packageFile, packageJson);
|
|
320
|
+
else if ('package.json' === relativePackageFile) writeJsonFile(packageFile, packageJson);
|
|
321
|
+
}
|
|
322
|
+
if (!hasFlag(args, '--skip-install')) {
|
|
323
|
+
const status = runPnpmLockfileRefresh(context);
|
|
324
|
+
if (0 !== status) return status;
|
|
325
|
+
}
|
|
326
|
+
process.stdout.write(`UltraModern strict Effect metadata migrated to ${packageSource.modernPackageVersion}. Run pnpm api:check && pnpm contract:check next.\n`);
|
|
327
|
+
return 0;
|
|
328
|
+
}
|
|
329
|
+
function runSkills(args, context) {
|
|
330
|
+
const [subcommand, ...rest] = args;
|
|
331
|
+
if ('install' === subcommand) return spawnNodeScript("template-workspace/scripts/bootstrap-agent-skills.mjs", rest, context);
|
|
332
|
+
if ('check' === subcommand) return spawnNodeScript("template-workspace/scripts/bootstrap-agent-skills.mjs", [
|
|
333
|
+
'--check',
|
|
334
|
+
...rest
|
|
335
|
+
], context);
|
|
336
|
+
throw new Error('Usage: modern-js-create ultramodern skills <install|check>');
|
|
337
|
+
}
|
|
338
|
+
async function runUltramodernToolingCli(args, workspaceRoot = process.env.ULTRAMODERN_WORKSPACE_ROOT ?? process.cwd()) {
|
|
339
|
+
try {
|
|
340
|
+
const [command, ...rest] = args;
|
|
341
|
+
const context = {
|
|
342
|
+
workspaceRoot: node_path.resolve(workspaceRoot),
|
|
343
|
+
invocationCwd: process.cwd()
|
|
344
|
+
};
|
|
345
|
+
switch(command){
|
|
346
|
+
case void 0:
|
|
347
|
+
case '--help':
|
|
348
|
+
case '-h':
|
|
349
|
+
printHelp();
|
|
350
|
+
return 0;
|
|
351
|
+
case 'validate':
|
|
352
|
+
return runValidate(context);
|
|
353
|
+
case 'typecheck':
|
|
354
|
+
return spawnNodeScript("templates/workspace-scripts/ultramodern-typecheck.mjs", rest, context, {
|
|
355
|
+
cwd: context.invocationCwd
|
|
356
|
+
});
|
|
357
|
+
case 'mf-types':
|
|
358
|
+
return runMfTypes(rest, context);
|
|
359
|
+
case 'migrate-strict-effect':
|
|
360
|
+
return runMigrateStrictEffect(rest, context);
|
|
361
|
+
case 'public-surface':
|
|
362
|
+
return spawnNodeScript("templates/workspace-scripts/generate-public-surface-assets.mjs", rest, context);
|
|
363
|
+
case 'cloudflare-proof':
|
|
364
|
+
return spawnNodeScript("templates/workspace-scripts/proof-cloudflare-version.mjs", rest, context);
|
|
365
|
+
case 'performance-readiness':
|
|
366
|
+
return spawnNodeScript("templates/workspace-scripts/ultramodern-performance-readiness.mjs", rest, context);
|
|
367
|
+
case 'skills':
|
|
368
|
+
return runSkills(rest, context);
|
|
369
|
+
default:
|
|
370
|
+
throw new Error(`Unknown UltraModern command: ${command}`);
|
|
371
|
+
}
|
|
372
|
+
} catch (error) {
|
|
373
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
374
|
+
process.stderr.write(`[ultramodern] ${message}\n`);
|
|
375
|
+
return 1;
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
export { runUltramodernToolingCli };
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import node_fs from "node:fs";
|
|
2
|
+
import node_path from "node:path";
|
|
3
|
+
import { normalizeUltramodernBridgeConfig } from "../ultramodern-workspace/bridge-config.js";
|
|
4
|
+
import { ULTRAMODERN_CONFIG_PATH, createNeutralOwnership, shellApp } from "../ultramodern-workspace/descriptors.js";
|
|
5
|
+
import { toKebabCase } from "../ultramodern-workspace/naming.js";
|
|
6
|
+
function readJsonObject(filePath) {
|
|
7
|
+
const value = JSON.parse(node_fs.readFileSync(filePath, 'utf-8'));
|
|
8
|
+
if (null === value || 'object' != typeof value || Array.isArray(value)) throw new Error(`UltraModern config must contain a JSON object: ${filePath}`);
|
|
9
|
+
return value;
|
|
10
|
+
}
|
|
11
|
+
function readOptionalJsonObject(filePath) {
|
|
12
|
+
return node_fs.existsSync(filePath) ? readJsonObject(filePath) : {};
|
|
13
|
+
}
|
|
14
|
+
function packageScopeFromRoot(workspaceRoot1) {
|
|
15
|
+
const rootPackage = readOptionalJsonObject(node_path.join(workspaceRoot1, 'package.json'));
|
|
16
|
+
return 'string' == typeof rootPackage.name && rootPackage.name.length > 0 ? rootPackage.name : node_path.basename(workspaceRoot1);
|
|
17
|
+
}
|
|
18
|
+
function normalizeCompactConfig(sourcePath, config) {
|
|
19
|
+
const packageSource = config.packageSource && 'object' == typeof config.packageSource ? {
|
|
20
|
+
strategy: 'install' === config.packageSource.strategy ? 'install' : 'workspace',
|
|
21
|
+
modernPackageVersion: 'string' == typeof config.packageSource.modernPackageVersion ? config.packageSource.modernPackageVersion : 'workspace:*',
|
|
22
|
+
registry: 'string' == typeof config.packageSource.registry ? config.packageSource.registry : void 0,
|
|
23
|
+
aliasScope: 'string' == typeof config.packageSource.aliasScope ? config.packageSource.aliasScope : void 0,
|
|
24
|
+
aliasPackageNamePrefix: 'string' == typeof config.packageSource.aliasPackageNamePrefix ? config.packageSource.aliasPackageNamePrefix : void 0
|
|
25
|
+
} : void 0;
|
|
26
|
+
return {
|
|
27
|
+
schemaVersion: 'number' == typeof config.schemaVersion ? config.schemaVersion : 1,
|
|
28
|
+
profile: 'string' == typeof config.profile ? config.profile : void 0,
|
|
29
|
+
source: 'compact',
|
|
30
|
+
sourcePath,
|
|
31
|
+
workspace: {
|
|
32
|
+
packageScope: 'string' == typeof config.workspace?.packageScope ? config.workspace.packageScope : packageScopeFromRoot(workspaceRoot)
|
|
33
|
+
},
|
|
34
|
+
packageSource,
|
|
35
|
+
features: {
|
|
36
|
+
tailwind: config.features?.tailwind !== false
|
|
37
|
+
},
|
|
38
|
+
bridge: normalizeUltramodernBridgeConfig(config.bridge),
|
|
39
|
+
topology: {
|
|
40
|
+
apps: Array.isArray(config.topology?.apps) ? config.topology.apps.map((app)=>({
|
|
41
|
+
id: String(app.id),
|
|
42
|
+
kind: 'vertical' === app.kind ? 'vertical' : 'shell',
|
|
43
|
+
path: 'string' == typeof app.path ? app.path : '.',
|
|
44
|
+
package: 'string' == typeof app.package ? app.package : void 0,
|
|
45
|
+
packageSuffix: 'string' == typeof app.packageSuffix ? app.packageSuffix : void 0,
|
|
46
|
+
displayName: 'string' == typeof app.displayName ? app.displayName : void 0,
|
|
47
|
+
domain: 'string' == typeof app.domain ? app.domain : void 0,
|
|
48
|
+
port: 'number' == typeof app.port ? app.port : void 0,
|
|
49
|
+
portEnv: 'string' == typeof app.portEnv ? app.portEnv : void 0,
|
|
50
|
+
moduleFederation: app.moduleFederation && 'object' == typeof app.moduleFederation ? {
|
|
51
|
+
role: 'remote' === app.moduleFederation.role ? 'remote' : 'host',
|
|
52
|
+
name: 'string' == typeof app.moduleFederation.name ? app.moduleFederation.name : void 0,
|
|
53
|
+
exposes: Array.isArray(app.moduleFederation.exposes) ? app.moduleFederation.exposes.filter((expose)=>'string' == typeof expose) : void 0,
|
|
54
|
+
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])),
|
|
55
|
+
verticalRefs: Array.isArray(app.moduleFederation.verticalRefs) ? app.moduleFederation.verticalRefs.filter((ref)=>'string' == typeof ref) : void 0,
|
|
56
|
+
hostOnly: true === app.moduleFederation.hostOnly,
|
|
57
|
+
noExposes: true === app.moduleFederation.noExposes
|
|
58
|
+
} : void 0,
|
|
59
|
+
api: app.api && 'object' == typeof app.api ? {
|
|
60
|
+
stem: 'string' == typeof app.api.stem ? app.api.stem : String(app.id),
|
|
61
|
+
prefix: 'string' == typeof app.api.prefix ? app.api.prefix : `/${String(app.id)}-api`,
|
|
62
|
+
consumedBy: Array.isArray(app.api.consumedBy) ? app.api.consumedBy.filter((consumer)=>'string' == typeof consumer) : [
|
|
63
|
+
shellApp.id,
|
|
64
|
+
String(app.id)
|
|
65
|
+
]
|
|
66
|
+
} : void 0
|
|
67
|
+
})) : []
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function readUltramodernConfig(workspaceRoot1 = process.cwd()) {
|
|
72
|
+
const compactPath = node_path.join(workspaceRoot1, ULTRAMODERN_CONFIG_PATH);
|
|
73
|
+
if (node_fs.existsSync(compactPath)) return normalizeCompactConfig(compactPath, readJsonObject(compactPath));
|
|
74
|
+
throw new Error(`Missing UltraModern config. Expected ${ULTRAMODERN_CONFIG_PATH}.`);
|
|
75
|
+
}
|
|
76
|
+
function workspaceAppsFromToolingConfig(config) {
|
|
77
|
+
return config.topology.apps.map((app)=>{
|
|
78
|
+
if ('shell' === app.kind) return {
|
|
79
|
+
...shellApp,
|
|
80
|
+
directory: app.path,
|
|
81
|
+
packageSuffix: app.packageSuffix ?? shellApp.packageSuffix,
|
|
82
|
+
displayName: app.displayName ?? shellApp.displayName,
|
|
83
|
+
port: app.port ?? shellApp.port,
|
|
84
|
+
portEnv: app.portEnv ?? shellApp.portEnv,
|
|
85
|
+
mfName: app.moduleFederation?.name ?? shellApp.mfName,
|
|
86
|
+
verticalRefs: app.moduleFederation?.verticalRefs ?? []
|
|
87
|
+
};
|
|
88
|
+
const domain = app.domain ?? app.id;
|
|
89
|
+
const packageSuffix = app.packageSuffix ?? domain;
|
|
90
|
+
const exposePaths = app.moduleFederation?.exposePaths ?? {};
|
|
91
|
+
const exposes = Object.fromEntries((app.moduleFederation?.exposes ?? []).map((expose)=>{
|
|
92
|
+
const configuredPath = exposePaths[expose];
|
|
93
|
+
const inferredPath = './Route' === expose ? './src/federation-entry.tsx' : './Widget' === expose ? `./src/components/${domain}-widget.tsx` : `./src/components/${toKebabCase(expose.replace(/^\.\//u, ''))}.tsx`;
|
|
94
|
+
return [
|
|
95
|
+
expose,
|
|
96
|
+
configuredPath ?? inferredPath
|
|
97
|
+
];
|
|
98
|
+
}));
|
|
99
|
+
return {
|
|
100
|
+
id: app.id,
|
|
101
|
+
directory: app.path,
|
|
102
|
+
packageSuffix,
|
|
103
|
+
displayName: app.displayName ?? `${domain} Vertical`,
|
|
104
|
+
kind: 'vertical',
|
|
105
|
+
domain,
|
|
106
|
+
portEnv: app.portEnv ?? `VERTICAL_${domain.replace(/[^a-zA-Z0-9]+/g, '_').toUpperCase()}_PORT`,
|
|
107
|
+
port: app.port ?? 0,
|
|
108
|
+
mfName: app.moduleFederation?.name ?? app.id,
|
|
109
|
+
exposes,
|
|
110
|
+
...app.moduleFederation?.verticalRefs ? {
|
|
111
|
+
verticalRefs: app.moduleFederation.verticalRefs
|
|
112
|
+
} : {},
|
|
113
|
+
...app.api ? {
|
|
114
|
+
api: app.api
|
|
115
|
+
} : {},
|
|
116
|
+
ownership: createNeutralOwnership(app.id)
|
|
117
|
+
};
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
export { readUltramodernConfig, workspaceAppsFromToolingConfig };
|