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