@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
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { WORKSPACE_PACKAGE_VERSION, modernPackageSpecifier } from "../ultramodern-package-source.js";
|
|
2
|
-
import {
|
|
2
|
+
import { appHasApi, remoteDependencyAlias, resolveRemoteRefs, sharedPackages, shellApp, verticalApiApps, zephyrRemoteDependency } from "./descriptors.js";
|
|
3
3
|
import { readFileTemplate } from "./fs-io.js";
|
|
4
4
|
import { packageName, relativeRootFor } from "./naming.js";
|
|
5
5
|
import { createPublicSurfaceGenerationCommand } from "./public-surface.js";
|
|
6
6
|
import { EFFECT_TSGO_VERSION, I18NEXT_VERSION, LEFTHOOK_VERSION, MODULE_FEDERATION_VERSION, NODE_FETCH_VERSION, OXFMT_VERSION, OXLINT_VERSION, PNPM_VERSION, POSTCSS_VERSION, REACT_DOM_VERSION, REACT_ROUTER_VERSION, REACT_VERSION, TAILWIND_POSTCSS_VERSION, TAILWIND_VERSION, TANSTACK_ROUTER_VERSION, TYPESCRIPT_NATIVE_PREVIEW_VERSION, TYPESCRIPT_VERSION, TYPES_REACT_DOM_VERSION, TYPES_REACT_VERSION, ULTRACITE_VERSION, WRANGLER_VERSION, ZEPHYR_AGENT_VERSION, ZEPHYR_RSPACK_PLUGIN_VERSION } from "./versions.js";
|
|
7
|
-
const
|
|
7
|
+
const createStrictTsgoTypecheckCommand = (packageDir)=>`node ${relativeRootFor(packageDir)}/scripts/ultramodern-typecheck.mts --project tsconfig.json`;
|
|
8
8
|
const effectDiagnostics = [
|
|
9
9
|
'anyUnknownInErrorContext',
|
|
10
10
|
'classSelfMismatch',
|
|
@@ -80,7 +80,7 @@ const effectDiagnostics = [
|
|
|
80
80
|
'unnecessaryPipe',
|
|
81
81
|
'unnecessaryPipeChain'
|
|
82
82
|
];
|
|
83
|
-
function appDependencies(scope, packageSource, app, remotes = []) {
|
|
83
|
+
function appDependencies(scope, packageSource, app, remotes = [], bridge) {
|
|
84
84
|
const dependencies = {
|
|
85
85
|
'@modern-js/plugin-tanstack': modernPackageSpecifier('@modern-js/plugin-tanstack', packageSource),
|
|
86
86
|
'@modern-js/plugin-i18n': modernPackageSpecifier('@modern-js/plugin-i18n', packageSource),
|
|
@@ -95,14 +95,16 @@ function appDependencies(scope, packageSource, app, remotes = []) {
|
|
|
95
95
|
[packageName(scope, 'shared-design-tokens')]: WORKSPACE_PACKAGE_VERSION,
|
|
96
96
|
react: REACT_VERSION,
|
|
97
97
|
'react-dom': REACT_DOM_VERSION,
|
|
98
|
-
'react-router': REACT_ROUTER_VERSION
|
|
98
|
+
'react-router': REACT_ROUTER_VERSION,
|
|
99
|
+
'react-router-dom': REACT_ROUTER_VERSION
|
|
99
100
|
};
|
|
101
|
+
for (const dependency of bridge?.dependencies ?? [])dependencies[dependency] = WORKSPACE_PACKAGE_VERSION;
|
|
100
102
|
if ('shell' === app.kind) {
|
|
101
103
|
dependencies['@modern-js/plugin-bff'] = modernPackageSpecifier('@modern-js/plugin-bff', packageSource);
|
|
102
|
-
for (const remote of
|
|
104
|
+
for (const remote of verticalApiApps(remotes))dependencies[packageName(scope, remote.packageSuffix)] = WORKSPACE_PACKAGE_VERSION;
|
|
103
105
|
}
|
|
104
106
|
for (const remote of resolveRemoteRefs(app, remotes))dependencies[packageName(scope, remote.packageSuffix)] = WORKSPACE_PACKAGE_VERSION;
|
|
105
|
-
if (
|
|
107
|
+
if (appHasApi(app)) dependencies['@modern-js/plugin-bff'] = modernPackageSpecifier('@modern-js/plugin-bff', packageSource);
|
|
106
108
|
return dependencies;
|
|
107
109
|
}
|
|
108
110
|
function appDevDependencies(packageSource, enableTailwind) {
|
|
@@ -123,12 +125,28 @@ function appDevDependencies(packageSource, enableTailwind) {
|
|
|
123
125
|
wrangler: WRANGLER_VERSION
|
|
124
126
|
};
|
|
125
127
|
}
|
|
126
|
-
function createRootPackageJson(scope, packageSource, remotes = []) {
|
|
128
|
+
function createRootPackageJson(scope, packageSource, remotes = [], bridge) {
|
|
127
129
|
const shellFilter = `--filter ${packageName(scope, shellApp.packageSuffix)}`;
|
|
128
130
|
const remoteFilters = remotes.map((remote)=>`--filter ${packageName(scope, remote.packageSuffix)}`);
|
|
129
131
|
const remoteBuildPrefix = remotes.length > 0 ? 'ULTRAMODERN_ZEPHYR=false pnpm -r --filter "./verticals/*" run build && ' : '';
|
|
130
132
|
const remoteCloudflareBuildPrefix = remotes.length > 0 ? 'pnpm -r --filter "./verticals/*" run cloudflare:build && ' : '';
|
|
131
133
|
const remoteCloudflareDeployPrefix = remotes.length > 0 ? 'pnpm -r --filter "./verticals/*" run cloudflare:deploy && ' : '';
|
|
134
|
+
const generatedPackageTypecheck = 'pnpm -r --filter "./apps/*" --filter "./verticals/*" --filter "./packages/*" run typecheck';
|
|
135
|
+
const typecheck = bridge ? generatedPackageTypecheck : "node ./scripts/ultramodern-typecheck.mts --build tsconfig.json";
|
|
136
|
+
const bridgeScripts = bridge ? {
|
|
137
|
+
...Object.fromEntries(bridge.gates.map((gate)=>[
|
|
138
|
+
`bridge:${gate.name}`,
|
|
139
|
+
`${gate.cwd ? `cd ${gate.cwd} && ` : ''}${gate.command}`
|
|
140
|
+
])),
|
|
141
|
+
'bridge:check': bridge.gates.map((gate)=>`pnpm run bridge:${gate.name}`).join(' && ')
|
|
142
|
+
} : {};
|
|
143
|
+
const bridgeCheck = bridge ? ' && pnpm bridge:check' : '';
|
|
144
|
+
const workspacePackages = [
|
|
145
|
+
'apps/*',
|
|
146
|
+
'verticals/*',
|
|
147
|
+
'packages/*',
|
|
148
|
+
...bridge?.workspacePackages.map((entry)=>entry.pattern) ?? []
|
|
149
|
+
];
|
|
132
150
|
return {
|
|
133
151
|
private: true,
|
|
134
152
|
name: scope,
|
|
@@ -150,30 +168,28 @@ function createRootPackageJson(scope, packageSource, remotes = []) {
|
|
|
150
168
|
'format:check': "oxfmt --check . '!repos/**'",
|
|
151
169
|
lint: 'oxlint apps verticals packages',
|
|
152
170
|
'lint:fix': 'oxlint apps verticals packages --fix',
|
|
153
|
-
typecheck
|
|
171
|
+
typecheck,
|
|
154
172
|
'cloudflare:build': `${remoteCloudflareBuildPrefix}pnpm --filter "./apps/shell-super-app" run cloudflare:build && pnpm mf:types`,
|
|
155
173
|
'cloudflare:deploy': `${remoteCloudflareDeployPrefix}pnpm --filter "./apps/shell-super-app" run cloudflare:deploy`,
|
|
156
|
-
'cloudflare:proof': "node ./scripts/proof-cloudflare-version.
|
|
157
|
-
'skills:install': "node ./scripts/bootstrap-agent-skills.
|
|
158
|
-
'skills:check': "node ./scripts/bootstrap-agent-skills.
|
|
159
|
-
'agents:refs:install': "node ./scripts/setup-agent-reference-repos.
|
|
160
|
-
'agents:refs:check': "node ./scripts/setup-agent-reference-repos.
|
|
161
|
-
'mf:types': "node ./scripts/assert-mf-types.
|
|
162
|
-
'performance:readiness': "node ./scripts/ultramodern-performance-readiness.
|
|
163
|
-
'contract:check': "node ./scripts/validate-ultramodern-workspace.
|
|
164
|
-
'
|
|
165
|
-
|
|
166
|
-
|
|
174
|
+
'cloudflare:proof': "node ./scripts/proof-cloudflare-version.mts --out .codex/reports/cloudflare-version-proof/public-url-proof.json",
|
|
175
|
+
'skills:install': "node ./scripts/bootstrap-agent-skills.mts",
|
|
176
|
+
'skills:check': "node ./scripts/bootstrap-agent-skills.mts --check",
|
|
177
|
+
'agents:refs:install': "node ./scripts/setup-agent-reference-repos.mts",
|
|
178
|
+
'agents:refs:check': "node ./scripts/setup-agent-reference-repos.mts --check",
|
|
179
|
+
'mf:types': "node ./scripts/assert-mf-types.mts",
|
|
180
|
+
'performance:readiness': "node ./scripts/ultramodern-performance-readiness.mts",
|
|
181
|
+
'contract:check': "node ./scripts/validate-ultramodern-workspace.mts",
|
|
182
|
+
'api:check': "node ./scripts/check-ultramodern-api-boundaries.mts",
|
|
183
|
+
'i18n:boundaries': "node ./scripts/check-ultramodern-i18n-boundaries.mts",
|
|
184
|
+
...bridgeScripts,
|
|
185
|
+
postinstall: "oxfmt . '!repos/**' && node ./scripts/bootstrap-agent-skills.mts --postinstall",
|
|
186
|
+
check: `pnpm format:check && pnpm lint && pnpm typecheck && pnpm skills:check && pnpm i18n:boundaries && pnpm api:check && pnpm contract:check && pnpm performance:readiness${bridgeCheck}`
|
|
167
187
|
},
|
|
168
188
|
engines: {
|
|
169
189
|
node: '>=26',
|
|
170
190
|
pnpm: '>=11'
|
|
171
191
|
},
|
|
172
|
-
workspaces:
|
|
173
|
-
'apps/*',
|
|
174
|
-
'verticals/*',
|
|
175
|
-
'packages/*'
|
|
176
|
-
],
|
|
192
|
+
workspaces: workspacePackages,
|
|
177
193
|
modernjs: {
|
|
178
194
|
preset: 'presetUltramodern',
|
|
179
195
|
workspace: 'ultramodern-superapp',
|
|
@@ -181,7 +197,7 @@ function createRootPackageJson(scope, packageSource, remotes = []) {
|
|
|
181
197
|
ownership: './topology/ownership.json',
|
|
182
198
|
packageSource: {
|
|
183
199
|
strategy: packageSource.strategy,
|
|
184
|
-
config: './.modernjs/ultramodern
|
|
200
|
+
config: './.modernjs/ultramodern.json'
|
|
185
201
|
}
|
|
186
202
|
},
|
|
187
203
|
devDependencies: {
|
|
@@ -300,10 +316,10 @@ function createPackageTsConfig(packageDir, options = {}) {
|
|
|
300
316
|
function createAppTsConfig(app, remotes = []) {
|
|
301
317
|
const references = [
|
|
302
318
|
...sharedPackages.map((sharedPackage)=>sharedPackage.directory),
|
|
303
|
-
...'shell' === app.kind ?
|
|
319
|
+
...'shell' === app.kind ? verticalApiApps(remotes).map((remote)=>remote.directory) : resolveRemoteRefs(app, remotes).map((remote)=>remote.directory)
|
|
304
320
|
];
|
|
305
321
|
return createPackageTsConfig(app.directory, {
|
|
306
|
-
includeApi:
|
|
322
|
+
includeApi: appHasApi(app),
|
|
307
323
|
references
|
|
308
324
|
});
|
|
309
325
|
}
|
|
@@ -339,7 +355,7 @@ function createRootTsConfig(apps = []) {
|
|
|
339
355
|
]
|
|
340
356
|
};
|
|
341
357
|
}
|
|
342
|
-
function createAppPackage(scope, app, packageSource, enableTailwind, remotes = []) {
|
|
358
|
+
function createAppPackage(scope, app, packageSource, enableTailwind, remotes = [], bridge) {
|
|
343
359
|
const publicSurfaceBuildCommand = createPublicSurfaceGenerationCommand(app, 'dist');
|
|
344
360
|
const publicSurfaceCloudflareBuildCommand = createPublicSurfaceGenerationCommand(app, 'dist');
|
|
345
361
|
const publicSurfaceCloudflareOutputCommand = createPublicSurfaceGenerationCommand(app, 'cloudflare');
|
|
@@ -353,33 +369,33 @@ function createAppPackage(scope, app, packageSource, enableTailwind, remotes = [
|
|
|
353
369
|
version: '0.1.0',
|
|
354
370
|
scripts: {
|
|
355
371
|
dev: 'modern dev',
|
|
356
|
-
build: app.exposes ? `ULTRAMODERN_ZEPHYR=false modern build && ${publicSurfaceBuildCommand} && node ${relativeRootFor(app.directory)}/scripts/assert-mf-types.
|
|
372
|
+
build: app.exposes ? `ULTRAMODERN_ZEPHYR=false modern build && ${publicSurfaceBuildCommand} && node ${relativeRootFor(app.directory)}/scripts/assert-mf-types.mts` : `ULTRAMODERN_ZEPHYR=false modern build && ${publicSurfaceBuildCommand}`,
|
|
357
373
|
'cloudflare:build': `ULTRAMODERN_ZEPHYR=false MODERNJS_DEPLOY=cloudflare modern build && ${publicSurfaceCloudflareBuildCommand} && ULTRAMODERN_ZEPHYR=false MODERNJS_DEPLOY=cloudflare modern deploy && ${publicSurfaceCloudflareOutputCommand}`,
|
|
358
374
|
'cloudflare:deploy': 'ULTRAMODERN_CLOUDFLARE_REQUIRE_PUBLIC_URLS=true pnpm run cloudflare:build && wrangler deploy --config .output/wrangler.json',
|
|
359
375
|
'cloudflare:preview': 'pnpm run cloudflare:build && wrangler dev --config .output/wrangler.json',
|
|
360
|
-
'cloudflare:proof': `node ${relativeRootFor(app.directory)}/scripts/proof-cloudflare-version.
|
|
376
|
+
'cloudflare:proof': `node ${relativeRootFor(app.directory)}/scripts/proof-cloudflare-version.mts --app ${app.id}`,
|
|
361
377
|
serve: 'modern serve',
|
|
362
|
-
typecheck:
|
|
378
|
+
typecheck: createStrictTsgoTypecheckCommand(app.directory)
|
|
363
379
|
},
|
|
364
380
|
modernjs: {
|
|
365
381
|
preset: 'presetUltramodern',
|
|
366
382
|
role: 'shell' === app.kind ? 'shell' : 'module-federation-remote',
|
|
367
383
|
appId: app.id,
|
|
368
384
|
topology: `${relativeRootFor(app.directory)}/topology/reference-topology.json`,
|
|
369
|
-
...
|
|
370
|
-
apiRuntime: 'effect
|
|
385
|
+
...appHasApi(app) ? {
|
|
386
|
+
apiRuntime: 'effect'
|
|
371
387
|
} : {}
|
|
372
388
|
},
|
|
373
389
|
'zephyr:dependencies': createZephyrDependencies(scope, app, remotes),
|
|
374
|
-
dependencies: appDependencies(scope, packageSource, app, remotes),
|
|
390
|
+
dependencies: appDependencies(scope, packageSource, app, remotes, bridge),
|
|
375
391
|
devDependencies: appDevDependencies(packageSource, enableTailwind)
|
|
376
392
|
};
|
|
377
|
-
if (
|
|
378
|
-
'./
|
|
379
|
-
'./
|
|
393
|
+
if (appHasApi(app)) Object.assign(packageExports, {
|
|
394
|
+
'./api': './shared/api.ts',
|
|
395
|
+
'./api/client': `./src/api/${app.api.stem}-client.ts`
|
|
380
396
|
});
|
|
381
397
|
else if ('shell' === app.kind) Object.assign(packageExports, {
|
|
382
|
-
'./
|
|
398
|
+
'./api/clients': './src/api/vertical-clients.ts'
|
|
383
399
|
});
|
|
384
400
|
if (Object.keys(packageExports).length > 0) packageJson.exports = packageExports;
|
|
385
401
|
return packageJson;
|
|
@@ -395,7 +411,7 @@ function createSharedPackage(scope, id, description) {
|
|
|
395
411
|
'.': './src/index.ts'
|
|
396
412
|
},
|
|
397
413
|
scripts: {
|
|
398
|
-
typecheck:
|
|
414
|
+
typecheck: createStrictTsgoTypecheckCommand(`packages/${id}`)
|
|
399
415
|
},
|
|
400
416
|
devDependencies: {
|
|
401
417
|
'@effect/tsgo': EFFECT_TSGO_VERSION,
|
|
@@ -411,4 +427,4 @@ function createSharedPackage(scope, id, description) {
|
|
|
411
427
|
function createSharedContractsIndex() {
|
|
412
428
|
return readFileTemplate('packages/shared-contracts-index.ts');
|
|
413
429
|
}
|
|
414
|
-
export { appDependencies, appDevDependencies, createAppMfTypesTsConfig, createAppPackage, createAppTsConfig,
|
|
430
|
+
export { appDependencies, appDevDependencies, createAppMfTypesTsConfig, createAppPackage, createAppTsConfig, createPackageTsConfig, createRootPackageJson, createRootTsConfig, createSharedContractsIndex, createSharedPackage, createSharedPackageTsConfig, createStrictTsgoTypecheckCommand, createTsConfigBase, createZephyrDependencies, effectDiagnostics };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { appHasApi, appI18nNamespace, createCloudflarePublicUrlEnv, createCloudflareWorkerName, resolveApiPrefix, resolveApiStem } from "./descriptors.js";
|
|
2
2
|
import { createLocalisedUrlsMap } from "./routes.js";
|
|
3
3
|
import { isRecord } from "./types.js";
|
|
4
4
|
import { CLOUDFLARE_COMPATIBILITY_DATE } from "./versions.js";
|
|
@@ -15,8 +15,8 @@ function createCloudflareProofRoute(app) {
|
|
|
15
15
|
ssr: localizedPath ?? '/en',
|
|
16
16
|
mfManifest: '/mf-manifest.json',
|
|
17
17
|
locale: `/locales/en/${appI18nNamespace(app)}.json`,
|
|
18
|
-
...
|
|
19
|
-
|
|
18
|
+
...appHasApi(app) ? {
|
|
19
|
+
apiReadiness: `${resolveApiPrefix(app)}/${resolveApiStem(app)}/readiness`
|
|
20
20
|
} : {}
|
|
21
21
|
};
|
|
22
22
|
}
|
|
@@ -107,7 +107,7 @@ const PUBLIC_WEBSITE_POLICY = {
|
|
|
107
107
|
requireWebManifestWhenPresent: true
|
|
108
108
|
},
|
|
109
109
|
statusCodes: {
|
|
110
|
-
notFoundRoute: '/__ultramodern-smoke-missing',
|
|
110
|
+
notFoundRoute: '/__ultramodern-smoke-missing/nope',
|
|
111
111
|
unknownRouteStatus: 404
|
|
112
112
|
},
|
|
113
113
|
indexing: {
|
|
@@ -175,7 +175,7 @@ function createCloudflareDeployContract(scope, app) {
|
|
|
175
175
|
security: createCloudflareSecurityContract(),
|
|
176
176
|
qualityGates: createPublicWebsiteQualityGateContract(),
|
|
177
177
|
evidence: {
|
|
178
|
-
proofScript: "scripts/proof-cloudflare-version.
|
|
178
|
+
proofScript: "scripts/proof-cloudflare-version.mts",
|
|
179
179
|
reportDefault: '.codex/reports/cloudflare-version-proof/public-url-proof.json'
|
|
180
180
|
}
|
|
181
181
|
};
|
|
@@ -48,7 +48,7 @@ function createPublicSurfaceOutputFiles(app) {
|
|
|
48
48
|
];
|
|
49
49
|
}
|
|
50
50
|
function createPublicSurfaceGenerationCommand(app, target, requirePublicOrigin = false) {
|
|
51
|
-
return `node ${relativeRootFor(app.directory)}/scripts/generate-public-surface-assets.
|
|
51
|
+
return `node ${relativeRootFor(app.directory)}/scripts/generate-public-surface-assets.mts --app ${app.id} --target ${target}${requirePublicOrigin ? ' --require-public-origin' : ''}`;
|
|
52
52
|
}
|
|
53
53
|
function rewriteWorkspaceAssetsForApp(workspaceRoot, app) {
|
|
54
54
|
for (const relativePath of publicSurfaceManagedSourceAssetPaths)node_fs.rmSync(node_path.join(workspaceRoot, app.directory, relativePath), {
|
|
@@ -64,7 +64,7 @@ function createPublicSurfaceContract(app) {
|
|
|
64
64
|
generatedManifest: './src/routes/ultramodern-route-metadata',
|
|
65
65
|
source: 'route-owned-public-routes',
|
|
66
66
|
metadataExport: './src/routes/ultramodern-route-metadata',
|
|
67
|
-
generator: "scripts/generate-public-surface-assets.
|
|
67
|
+
generator: "scripts/generate-public-surface-assets.mts",
|
|
68
68
|
outputRoot: 'dist/public',
|
|
69
69
|
cloudflareOutputRoot: '.output/public',
|
|
70
70
|
privateRoutePolicy: 'omit-from-generated-public-surface',
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const TANSTACK_ROUTER_VERSION = '1.170.16';
|
|
2
|
+
const TANSTACK_ROUTER_CORE_VERSION = '1.171.13';
|
|
2
3
|
const MODULE_FEDERATION_VERSION = '2.6.0';
|
|
3
4
|
const ZEPHYR_RSPACK_PLUGIN_VERSION = '1.1.1';
|
|
4
5
|
const ZEPHYR_AGENT_VERSION = '1.1.1';
|
|
@@ -28,8 +29,9 @@ const RSTACK_AGENT_SKILLS_COMMIT = '61c948b42512e223bad44b83af4080eba48b2677';
|
|
|
28
29
|
const MODULE_FEDERATION_AGENT_SKILLS_COMMIT = '07bb5b6c43ad457609e00c081b72d4c42508ec76';
|
|
29
30
|
const ultramodernWorkspaceVersions = {
|
|
30
31
|
tanstackRouter: TANSTACK_ROUTER_VERSION,
|
|
32
|
+
tanstackRouterCore: TANSTACK_ROUTER_CORE_VERSION,
|
|
31
33
|
moduleFederation: MODULE_FEDERATION_VERSION,
|
|
32
34
|
tailwind: TAILWIND_VERSION,
|
|
33
35
|
tailwindPostcss: TAILWIND_POSTCSS_VERSION
|
|
34
36
|
};
|
|
35
|
-
export { CLOUDFLARE_COMPATIBILITY_DATE, EFFECT_TSGO_VERSION, I18NEXT_VERSION, LEFTHOOK_VERSION, MODULE_FEDERATION_AGENT_SKILLS_COMMIT, MODULE_FEDERATION_VERSION, NODE_FETCH_VERSION, NODE_VERSION, OXFMT_VERSION, OXLINT_VERSION, PNPM_VERSION, POSTCSS_VERSION, REACT_DOM_VERSION, REACT_ROUTER_VERSION, REACT_VERSION, RSTACK_AGENT_SKILLS_COMMIT, TAILWIND_POSTCSS_VERSION, TAILWIND_VERSION, TANSTACK_ROUTER_VERSION, TYPESCRIPT_NATIVE_PREVIEW_VERSION, TYPESCRIPT_STABLE_VERSION, TYPESCRIPT_VERSION, TYPES_REACT_DOM_VERSION, TYPES_REACT_VERSION, ULTRACITE_VERSION, WRANGLER_VERSION, ZEPHYR_AGENT_VERSION, ZEPHYR_RSPACK_PLUGIN_VERSION, ultramodernWorkspaceVersions };
|
|
37
|
+
export { CLOUDFLARE_COMPATIBILITY_DATE, EFFECT_TSGO_VERSION, I18NEXT_VERSION, LEFTHOOK_VERSION, MODULE_FEDERATION_AGENT_SKILLS_COMMIT, MODULE_FEDERATION_VERSION, NODE_FETCH_VERSION, NODE_VERSION, OXFMT_VERSION, OXLINT_VERSION, PNPM_VERSION, POSTCSS_VERSION, REACT_DOM_VERSION, REACT_ROUTER_VERSION, REACT_VERSION, RSTACK_AGENT_SKILLS_COMMIT, TAILWIND_POSTCSS_VERSION, TAILWIND_VERSION, TANSTACK_ROUTER_CORE_VERSION, TANSTACK_ROUTER_VERSION, TYPESCRIPT_NATIVE_PREVIEW_VERSION, TYPESCRIPT_STABLE_VERSION, TYPESCRIPT_VERSION, TYPES_REACT_DOM_VERSION, TYPES_REACT_VERSION, ULTRACITE_VERSION, WRANGLER_VERSION, ZEPHYR_AGENT_VERSION, ZEPHYR_RSPACK_PLUGIN_VERSION, ultramodernWorkspaceVersions };
|
|
@@ -1,27 +1,110 @@
|
|
|
1
|
+
import node_fs from "node:fs";
|
|
2
|
+
import node_path from "node:path";
|
|
3
|
+
import { verticalApiGroupName } from "./api.js";
|
|
1
4
|
import { remoteComponentOutputPath } from "./demo-components.js";
|
|
2
|
-
import {
|
|
3
|
-
import { verticalEffectGroupName } from "./effect-api.js";
|
|
5
|
+
import { appHasApi, appI18nNamespace, remoteDependencyAlias, shellApp } from "./descriptors.js";
|
|
4
6
|
import { readFileTemplate, renderFileTemplate, writeFileReplacing } from "./fs-io.js";
|
|
5
7
|
import { packageName, tailwindPrefixForApp } from "./naming.js";
|
|
6
8
|
import { createCloudflareSecurityContract } from "./policy.js";
|
|
7
9
|
import { publicSurfaceManagedSourceAssetPaths } from "./public-surface.js";
|
|
8
10
|
import { createLocalisedUrlsMap, createRouteMetaFilePath, createRouteOwnedI18nPaths, createRoutePageFilePath } from "./routes.js";
|
|
9
11
|
import { CLOUDFLARE_COMPATIBILITY_DATE, NODE_VERSION, PNPM_VERSION } from "./versions.js";
|
|
10
|
-
function
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
function createToolWrapperScript(command, extraArgs = []) {
|
|
13
|
+
const commandJson = JSON.stringify(command);
|
|
14
|
+
const extraArgsJson = JSON.stringify(extraArgs);
|
|
15
|
+
return `#!/usr/bin/env node
|
|
16
|
+
import { spawnSync } from 'node:child_process';
|
|
17
|
+
import path from 'node:path';
|
|
18
|
+
import { fileURLToPath } from 'node:url';
|
|
19
|
+
|
|
20
|
+
const createBin = process.env.ULTRAMODERN_CREATE_BIN;
|
|
21
|
+
const forwardedArgs = process.argv.slice(2);
|
|
22
|
+
const workspaceRoot =
|
|
23
|
+
process.env.ULTRAMODERN_WORKSPACE_ROOT ??
|
|
24
|
+
path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
25
|
+
const ultramodernArgs = ['ultramodern', ${commandJson}, ...${extraArgsJson}, ...forwardedArgs];
|
|
26
|
+
const result = createBin
|
|
27
|
+
? spawnSync(process.execPath, [createBin, ...ultramodernArgs], {
|
|
28
|
+
env: { ...process.env, ULTRAMODERN_WORKSPACE_ROOT: workspaceRoot },
|
|
29
|
+
stdio: 'inherit',
|
|
30
|
+
})
|
|
31
|
+
: spawnSync('modern-js-create', ultramodernArgs, {
|
|
32
|
+
env: { ...process.env, ULTRAMODERN_WORKSPACE_ROOT: workspaceRoot },
|
|
33
|
+
shell: process.platform === 'win32',
|
|
34
|
+
stdio: 'inherit',
|
|
13
35
|
});
|
|
36
|
+
|
|
37
|
+
if (result.error) {
|
|
38
|
+
console.error(result.error.message);
|
|
39
|
+
process.exit(1);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
process.exit(result.status ?? 1);
|
|
43
|
+
`;
|
|
44
|
+
}
|
|
45
|
+
function createSkillsToolWrapperScript() {
|
|
46
|
+
return `#!/usr/bin/env node
|
|
47
|
+
import { spawnSync } from 'node:child_process';
|
|
48
|
+
import path from 'node:path';
|
|
49
|
+
import { fileURLToPath } from 'node:url';
|
|
50
|
+
|
|
51
|
+
const createBin = process.env.ULTRAMODERN_CREATE_BIN;
|
|
52
|
+
const forwardedArgs = process.argv.slice(2);
|
|
53
|
+
const workspaceRoot =
|
|
54
|
+
process.env.ULTRAMODERN_WORKSPACE_ROOT ??
|
|
55
|
+
path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
56
|
+
const checkOnly = forwardedArgs.includes('--check');
|
|
57
|
+
const skillArgs = checkOnly
|
|
58
|
+
? ['skills', 'check', ...forwardedArgs.filter(arg => arg !== '--check')]
|
|
59
|
+
: ['skills', 'install', ...forwardedArgs];
|
|
60
|
+
const ultramodernArgs = ['ultramodern', ...skillArgs];
|
|
61
|
+
const result = createBin
|
|
62
|
+
? spawnSync(process.execPath, [createBin, ...ultramodernArgs], {
|
|
63
|
+
env: { ...process.env, ULTRAMODERN_WORKSPACE_ROOT: workspaceRoot },
|
|
64
|
+
stdio: 'inherit',
|
|
65
|
+
})
|
|
66
|
+
: spawnSync('modern-js-create', ultramodernArgs, {
|
|
67
|
+
env: { ...process.env, ULTRAMODERN_WORKSPACE_ROOT: workspaceRoot },
|
|
68
|
+
shell: process.platform === 'win32',
|
|
69
|
+
stdio: 'inherit',
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
if (result.error) {
|
|
73
|
+
console.error(result.error.message);
|
|
74
|
+
process.exit(1);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
process.exit(result.status ?? 1);
|
|
78
|
+
`;
|
|
79
|
+
}
|
|
80
|
+
function removeLegacyWorkspaceScript(targetDir, relativePath) {
|
|
81
|
+
node_fs.rmSync(node_path.join(targetDir, relativePath), {
|
|
82
|
+
force: true
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
function writeWorkspaceOwnedMtsScript(targetDir, name, content) {
|
|
86
|
+
writeFileReplacing(targetDir, `scripts/${name}.mts`, content);
|
|
87
|
+
removeLegacyWorkspaceScript(targetDir, `scripts/${name}.mjs`);
|
|
88
|
+
}
|
|
89
|
+
function migrateCopiedWorkspaceScriptToMts(targetDir, name) {
|
|
90
|
+
const legacyPath = node_path.join(targetDir, `scripts/${name}.mjs`);
|
|
91
|
+
const migratedPath = node_path.join(targetDir, `scripts/${name}.mts`);
|
|
92
|
+
if (!node_fs.existsSync(legacyPath)) return;
|
|
93
|
+
if (node_fs.existsSync(migratedPath)) return void node_fs.rmSync(legacyPath, {
|
|
94
|
+
force: true
|
|
95
|
+
});
|
|
96
|
+
node_fs.renameSync(legacyPath, migratedPath);
|
|
14
97
|
}
|
|
15
98
|
function createWorkspaceValidationScript(scope, enableTailwind, remotes = []) {
|
|
16
|
-
const verticals = remotes.filter(
|
|
99
|
+
const verticals = remotes.filter(appHasApi).map((remote)=>({
|
|
17
100
|
id: remote.id,
|
|
18
101
|
domain: remote.domain,
|
|
19
|
-
stem: remote.
|
|
20
|
-
group:
|
|
102
|
+
stem: remote.api.stem,
|
|
103
|
+
group: verticalApiGroupName(remote),
|
|
21
104
|
path: remote.directory,
|
|
22
105
|
port: remote.port,
|
|
23
106
|
mfName: remote.mfName,
|
|
24
|
-
apiPrefix: remote.
|
|
107
|
+
apiPrefix: remote.api.prefix,
|
|
25
108
|
tailwindPrefix: tailwindPrefixForApp(remote),
|
|
26
109
|
zephyrAlias: remoteDependencyAlias(remote),
|
|
27
110
|
packageName: packageName(scope, remote.packageSuffix),
|
|
@@ -62,35 +145,25 @@ function createWorkspaceValidationScript(scope, enableTailwind, remotes = []) {
|
|
|
62
145
|
});
|
|
63
146
|
}
|
|
64
147
|
function createWorkspaceI18nBoundaryValidationScript() {
|
|
65
|
-
return readFileTemplate("workspace-scripts/check-ultramodern-i18n-boundaries.
|
|
66
|
-
}
|
|
67
|
-
function createPublicSurfaceAssetsScript() {
|
|
68
|
-
return readFileTemplate("workspace-scripts/generate-public-surface-assets.mjs");
|
|
148
|
+
return readFileTemplate("workspace-scripts/check-ultramodern-i18n-boundaries.mts");
|
|
69
149
|
}
|
|
70
|
-
function
|
|
71
|
-
return readFileTemplate("workspace-scripts/ultramodern-
|
|
72
|
-
}
|
|
73
|
-
function createCloudflareVersionProofScript() {
|
|
74
|
-
return readFileTemplate("workspace-scripts/proof-cloudflare-version.mjs");
|
|
150
|
+
function createWorkspaceApiBoundaryValidationScript() {
|
|
151
|
+
return readFileTemplate("workspace-scripts/check-ultramodern-api-boundaries.mts");
|
|
75
152
|
}
|
|
76
153
|
function createPerformanceReadinessConfigScript() {
|
|
77
154
|
return readFileTemplate("workspace-scripts/ultramodern-performance-readiness.config.mjs");
|
|
78
155
|
}
|
|
79
|
-
function
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
writeFileReplacing(targetDir, "scripts/assert-mf-types.mjs", createAssertMfTypesScript(remotes));
|
|
87
|
-
writeFileReplacing(targetDir, "scripts/validate-ultramodern-workspace.mjs", createWorkspaceValidationScript(scope, enableTailwind, remotes));
|
|
88
|
-
writeFileReplacing(targetDir, "scripts/check-ultramodern-i18n-boundaries.mjs", createWorkspaceI18nBoundaryValidationScript());
|
|
89
|
-
writeFileReplacing(targetDir, "scripts/generate-public-surface-assets.mjs", createPublicSurfaceAssetsScript());
|
|
90
|
-
writeFileReplacing(targetDir, "scripts/ultramodern-cloudflare-proof.mjs", createCloudflareProofHelperScript());
|
|
91
|
-
writeFileReplacing(targetDir, "scripts/proof-cloudflare-version.mjs", createCloudflareVersionProofScript());
|
|
156
|
+
function writeGeneratedWorkspaceScripts(targetDir, _scope, _enableTailwind, _remotes = []) {
|
|
157
|
+
writeWorkspaceOwnedMtsScript(targetDir, 'assert-mf-types', createToolWrapperScript('mf-types'));
|
|
158
|
+
writeWorkspaceOwnedMtsScript(targetDir, 'validate-ultramodern-workspace', createToolWrapperScript('validate'));
|
|
159
|
+
writeWorkspaceOwnedMtsScript(targetDir, 'check-ultramodern-i18n-boundaries', createWorkspaceI18nBoundaryValidationScript());
|
|
160
|
+
writeWorkspaceOwnedMtsScript(targetDir, 'check-ultramodern-api-boundaries', createWorkspaceApiBoundaryValidationScript());
|
|
161
|
+
writeWorkspaceOwnedMtsScript(targetDir, 'generate-public-surface-assets', createToolWrapperScript('public-surface'));
|
|
162
|
+
writeWorkspaceOwnedMtsScript(targetDir, 'proof-cloudflare-version', createToolWrapperScript('cloudflare-proof'));
|
|
92
163
|
writeFileReplacing(targetDir, "scripts/ultramodern-performance-readiness.config.mjs", createPerformanceReadinessConfigScript());
|
|
93
|
-
|
|
94
|
-
|
|
164
|
+
writeWorkspaceOwnedMtsScript(targetDir, 'ultramodern-performance-readiness', createToolWrapperScript('performance-readiness'));
|
|
165
|
+
writeWorkspaceOwnedMtsScript(targetDir, 'ultramodern-typecheck', createToolWrapperScript('typecheck'));
|
|
166
|
+
writeWorkspaceOwnedMtsScript(targetDir, 'bootstrap-agent-skills', createSkillsToolWrapperScript());
|
|
167
|
+
migrateCopiedWorkspaceScriptToMts(targetDir, 'setup-agent-reference-repos');
|
|
95
168
|
}
|
|
96
|
-
export {
|
|
169
|
+
export { createPerformanceReadinessConfigScript, createWorkspaceApiBoundaryValidationScript, createWorkspaceI18nBoundaryValidationScript, createWorkspaceValidationScript, writeGeneratedWorkspaceScripts };
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import node_fs from "node:fs";
|
|
2
|
+
import { createApiClient, createApiServiceEntry, createSharedApi, createShellApiClient } from "./api.js";
|
|
2
3
|
import { createAppEnvDts, createAppRuntimeConfig, createAppStyles, createPostcssConfig, createSharedDesignTokensCss, createShellFrameComponent, createTailwindConfig } from "./app-files.js";
|
|
3
|
-
import {
|
|
4
|
+
import { normalizeUltramodernBridgeConfig } from "./bridge-config.js";
|
|
5
|
+
import { createDevelopmentOverlay, createOwnership, createTopology, createUltramodernConfig } from "./contracts.js";
|
|
4
6
|
import { createLayout, createRemoteEntry, createRemoteExposeComponent, createRemotePage, createShellPage, createShellRemoteComponents, remoteComponentOutputPath } from "./demo-components.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { copyRootTemplate, writeFile, writeJson } from "./fs-io.js";
|
|
7
|
+
import { ULTRAMODERN_CONFIG_PATH, appHasApi, appI18nNamespace, createShellHost, sharedPackages, shellApp } from "./descriptors.js";
|
|
8
|
+
import { copyRootTemplate, formatGeneratedWorkspaceFiles, writeFile, writeFileReplacing, writeJson } from "./fs-io.js";
|
|
8
9
|
import { createFileSnapshot, createGenerationResult, diffFileSnapshots } from "./generation-result.js";
|
|
9
10
|
import { createAppPublicLocaleMessages } from "./locales.js";
|
|
10
11
|
import { createAppModernConfig, createRemoteModuleFederationConfig, createShellModuleFederationConfig, createUltramodernBuildModule, createUltramodernBuildReexportModule } from "./module-federation.js";
|
|
@@ -13,15 +14,15 @@ import { runCodeSmithOverlays } from "./overlays.js";
|
|
|
13
14
|
import { createAppMfTypesTsConfig, createAppPackage, createAppTsConfig, createRootPackageJson, createRootTsConfig, createSharedContractsIndex, createSharedPackage, createSharedPackageTsConfig, createTsConfigBase } from "./package-json.js";
|
|
14
15
|
import { resolvePackageSource } from "./package-source.js";
|
|
15
16
|
import { createPublicWebAppArtifacts } from "./public-surface.js";
|
|
16
|
-
import { NODE_FETCH_VERSION, NODE_VERSION, PNPM_VERSION, TANSTACK_ROUTER_VERSION, TYPESCRIPT_VERSION } from "./versions.js";
|
|
17
|
+
import { NODE_FETCH_VERSION, NODE_VERSION, PNPM_VERSION, TANSTACK_ROUTER_CORE_VERSION, TANSTACK_ROUTER_VERSION, TYPESCRIPT_VERSION } from "./versions.js";
|
|
17
18
|
import { writeGeneratedWorkspaceScripts } from "./workspace-scripts.js";
|
|
18
|
-
function writeApp(targetDir, scope, app, packageSource, enableTailwind, remotes = []) {
|
|
19
|
+
function writeApp(targetDir, scope, app, packageSource, enableTailwind, remotes = [], bridge) {
|
|
19
20
|
const resolvedApp = 'shell' === app.kind ? createShellHost(remotes) : app;
|
|
20
21
|
const publicWeb = createPublicWebAppArtifacts(resolvedApp);
|
|
21
22
|
const writeAppFile = (relativePath, content)=>{
|
|
22
23
|
writeFile(targetDir, `${resolvedApp.directory}/${relativePath}`, content);
|
|
23
24
|
};
|
|
24
|
-
writeJson(targetDir, `${resolvedApp.directory}/package.json`, createAppPackage(scope, resolvedApp, packageSource, enableTailwind, remotes));
|
|
25
|
+
writeJson(targetDir, `${resolvedApp.directory}/package.json`, createAppPackage(scope, resolvedApp, packageSource, enableTailwind, remotes, bridge));
|
|
25
26
|
writeJson(targetDir, `${resolvedApp.directory}/tsconfig.json`, createAppTsConfig(resolvedApp, remotes));
|
|
26
27
|
writeJson(targetDir, `${resolvedApp.directory}/tsconfig.mf-types.json`, createAppMfTypesTsConfig(resolvedApp));
|
|
27
28
|
writeFile(targetDir, `${resolvedApp.directory}/src/modern-app-env.d.ts`, createAppEnvDts(resolvedApp, remotes));
|
|
@@ -49,12 +50,12 @@ function writeApp(targetDir, scope, app, packageSource, enableTailwind, remotes
|
|
|
49
50
|
if ('shell' === resolvedApp.kind) {
|
|
50
51
|
writeAppFile('src/routes/vertical-components.tsx', createShellRemoteComponents(scope, remotes));
|
|
51
52
|
writeAppFile('src/routes/shell-frame.tsx', createShellFrameComponent());
|
|
52
|
-
writeFile(targetDir, `${resolvedApp.directory}/src/
|
|
53
|
+
writeFile(targetDir, `${resolvedApp.directory}/src/api/vertical-clients.ts`, createShellApiClient(scope, remotes));
|
|
53
54
|
}
|
|
54
|
-
if (
|
|
55
|
-
writeFile(targetDir, `${resolvedApp.directory}/shared/
|
|
56
|
-
writeFile(targetDir, `${resolvedApp.directory}/api/
|
|
57
|
-
writeFile(targetDir, `${resolvedApp.directory}/src/
|
|
55
|
+
if (appHasApi(resolvedApp)) {
|
|
56
|
+
writeFile(targetDir, `${resolvedApp.directory}/shared/api.ts`, createSharedApi(resolvedApp));
|
|
57
|
+
writeFile(targetDir, `${resolvedApp.directory}/api/index.ts`, createApiServiceEntry(resolvedApp, '../shared/api.ts'));
|
|
58
|
+
writeFile(targetDir, `${resolvedApp.directory}/src/api/${resolvedApp.api.stem}-client.ts`, createApiClient(resolvedApp, '../../shared/api'));
|
|
58
59
|
}
|
|
59
60
|
if ('vertical' === resolvedApp.kind) {
|
|
60
61
|
writeAppFile('src/federation-entry.tsx', createRemoteEntry(resolvedApp));
|
|
@@ -80,10 +81,36 @@ function writeSharedPackages(targetDir, scope) {
|
|
|
80
81
|
`);
|
|
81
82
|
writeFile(targetDir, 'packages/shared-design-tokens/src/tokens.css', createSharedDesignTokensCss());
|
|
82
83
|
}
|
|
84
|
+
function createCompactRootPackageJson(scope, packageSource, remotes, bridge) {
|
|
85
|
+
const rootPackage = createRootPackageJson(scope, packageSource, remotes, bridge);
|
|
86
|
+
if (rootPackage.modernjs?.packageSource && 'object' == typeof rootPackage.modernjs.packageSource) rootPackage.modernjs.packageSource.config = `./${ULTRAMODERN_CONFIG_PATH}`;
|
|
87
|
+
return rootPackage;
|
|
88
|
+
}
|
|
89
|
+
function createCompactUltramodernConfig(scope, modernVersion, packageSource, apps = [
|
|
90
|
+
createShellHost()
|
|
91
|
+
], enableTailwind = true, bridge) {
|
|
92
|
+
const config = createUltramodernConfig(scope, modernVersion, packageSource, apps, enableTailwind, bridge);
|
|
93
|
+
if (config.packageSource && 'object' == typeof config.packageSource && !Array.isArray(config.packageSource)) delete config.packageSource.metadata;
|
|
94
|
+
return config;
|
|
95
|
+
}
|
|
96
|
+
function writePnpmWorkspacePackages(targetDir, bridge) {
|
|
97
|
+
if (!bridge) return;
|
|
98
|
+
const pnpmWorkspacePath = `${targetDir}/pnpm-workspace.yaml`;
|
|
99
|
+
const pnpmWorkspace = node_fs.readFileSync(pnpmWorkspacePath, 'utf-8');
|
|
100
|
+
const packages = [
|
|
101
|
+
'apps/*',
|
|
102
|
+
'verticals/*',
|
|
103
|
+
'packages/*',
|
|
104
|
+
...bridge.workspacePackages.map((entry)=>entry.pattern)
|
|
105
|
+
];
|
|
106
|
+
const renderedPackages = packages.map((pattern)=>` - ${pattern}`).join('\n');
|
|
107
|
+
writeFileReplacing(targetDir, 'pnpm-workspace.yaml', pnpmWorkspace.replace(/^packages:\n(?: {2}- .+\n)+/u, `packages:\n${renderedPackages}\n`));
|
|
108
|
+
}
|
|
83
109
|
function generateUltramodernWorkspace(options) {
|
|
84
110
|
const beforeFiles = createFileSnapshot(options.targetDir);
|
|
85
111
|
const scope = toPackageScope(options.packageName);
|
|
86
112
|
const packageSource = resolvePackageSource(options);
|
|
113
|
+
const bridge = normalizeUltramodernBridgeConfig(options.bridge);
|
|
87
114
|
const enableTailwind = false !== options.enableTailwind;
|
|
88
115
|
const initialVerticals = [];
|
|
89
116
|
const createdApps = [
|
|
@@ -103,39 +130,50 @@ function generateUltramodernWorkspace(options) {
|
|
|
103
130
|
nodeVersion: NODE_VERSION,
|
|
104
131
|
pnpmVersion: PNPM_VERSION,
|
|
105
132
|
nodeFetchVersion: NODE_FETCH_VERSION,
|
|
133
|
+
tanstackRouterCoreVersion: TANSTACK_ROUTER_CORE_VERSION,
|
|
106
134
|
tanstackRouterVersion: TANSTACK_ROUTER_VERSION,
|
|
107
135
|
typescriptVersion: TYPESCRIPT_VERSION,
|
|
108
136
|
tailwindEnabled: String(enableTailwind)
|
|
109
137
|
});
|
|
110
|
-
|
|
138
|
+
writePnpmWorkspacePackages(options.targetDir, bridge);
|
|
139
|
+
writeJson(options.targetDir, 'package.json', createCompactRootPackageJson(scope, packageSource, initialVerticals, bridge));
|
|
111
140
|
writeJson(options.targetDir, 'tsconfig.base.json', createTsConfigBase());
|
|
112
141
|
writeJson(options.targetDir, 'tsconfig.json', createRootTsConfig(createdApps));
|
|
113
142
|
writeJson(options.targetDir, 'topology/reference-topology.json', createTopology(scope, initialVerticals));
|
|
114
143
|
writeJson(options.targetDir, 'topology/ownership.json', createOwnership(scope, initialVerticals));
|
|
115
144
|
writeJson(options.targetDir, 'topology/local-overlays/development.json', createDevelopmentOverlay(initialVerticals));
|
|
116
|
-
writeJson(options.targetDir,
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
writeApp(options.targetDir, scope, shellApp, packageSource, enableTailwind, initialVerticals);
|
|
120
|
-
for (const remote of initialVerticals)writeApp(options.targetDir, scope, remote, packageSource, enableTailwind, initialVerticals);
|
|
145
|
+
writeJson(options.targetDir, ULTRAMODERN_CONFIG_PATH, createCompactUltramodernConfig(scope, options.modernVersion, packageSource, createdApps, enableTailwind, bridge));
|
|
146
|
+
writeApp(options.targetDir, scope, shellApp, packageSource, enableTailwind, initialVerticals, bridge);
|
|
147
|
+
for (const remote of initialVerticals)writeApp(options.targetDir, scope, remote, packageSource, enableTailwind, initialVerticals, bridge);
|
|
121
148
|
writeSharedPackages(options.targetDir, scope);
|
|
122
149
|
writeGeneratedWorkspaceScripts(options.targetDir, scope, enableTailwind, initialVerticals);
|
|
123
|
-
const
|
|
124
|
-
const
|
|
125
|
-
const
|
|
150
|
+
const preliminaryAfterFiles = createFileSnapshot(options.targetDir);
|
|
151
|
+
const preliminaryDiff = diffFileSnapshots(beforeFiles, preliminaryAfterFiles);
|
|
152
|
+
const preliminaryResult = createGenerationResult({
|
|
126
153
|
operation: 'workspace',
|
|
127
154
|
workspaceRoot: options.targetDir,
|
|
128
155
|
packageScope: scope,
|
|
129
156
|
packageSource,
|
|
130
157
|
createdApps,
|
|
131
|
-
createdPaths,
|
|
132
|
-
rewrittenPaths
|
|
158
|
+
createdPaths: preliminaryDiff.createdPaths,
|
|
159
|
+
rewrittenPaths: preliminaryDiff.rewrittenPaths
|
|
133
160
|
});
|
|
134
161
|
runCodeSmithOverlays({
|
|
135
162
|
workspaceRoot: options.targetDir,
|
|
136
163
|
overlays: options.overlays,
|
|
137
|
-
result
|
|
164
|
+
result: preliminaryResult
|
|
165
|
+
});
|
|
166
|
+
formatGeneratedWorkspaceFiles(options.targetDir);
|
|
167
|
+
const afterFiles = createFileSnapshot(options.targetDir);
|
|
168
|
+
const { createdPaths, rewrittenPaths } = diffFileSnapshots(beforeFiles, afterFiles);
|
|
169
|
+
return createGenerationResult({
|
|
170
|
+
operation: 'workspace',
|
|
171
|
+
workspaceRoot: options.targetDir,
|
|
172
|
+
packageScope: scope,
|
|
173
|
+
packageSource,
|
|
174
|
+
createdApps,
|
|
175
|
+
createdPaths,
|
|
176
|
+
rewrittenPaths
|
|
138
177
|
});
|
|
139
|
-
return result;
|
|
140
178
|
}
|
|
141
|
-
export { generateUltramodernWorkspace, writeApp, writeSharedPackages };
|
|
179
|
+
export { createCompactUltramodernConfig, generateUltramodernWorkspace, writeApp, writeSharedPackages };
|