@bleedingdev/modern-js-ultramodern-create 3.9.0-ultramodern.12 → 3.9.0-ultramodern.13
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 +32 -36
- package/dist/cjs/ultramodern-release-cohort.cjs +6 -21
- package/dist/cjs/ultramodern-tooling/commands/context.cjs +2 -1
- package/dist/cjs/ultramodern-tooling/commands/validate.cjs +2 -57
- package/dist/cjs/ultramodern-tooling/commands.cjs +11 -1
- package/dist/cjs/ultramodern-tooling/config/index.cjs +11 -4
- package/dist/cjs/ultramodern-tooling/config/load.cjs +4 -17
- package/dist/cjs/ultramodern-tooling/config/metadata.cjs +41 -2
- package/dist/cjs/ultramodern-tooling/config/normalize.cjs +121 -208
- package/dist/cjs/ultramodern-workspace/add-shell.cjs +51 -18
- package/dist/cjs/ultramodern-workspace/add-vertical/execute.cjs +40 -39
- package/dist/cjs/ultramodern-workspace/add-vertical/plan.cjs +1 -1
- package/dist/cjs/ultramodern-workspace/add-vertical/preflight.cjs +2 -8
- package/dist/cjs/ultramodern-workspace/add-vertical/topology.cjs +0 -32
- package/dist/cjs/ultramodern-workspace/add-vertical/workspace-state.cjs +3 -10
- package/dist/cjs/ultramodern-workspace/api/contracts.cjs +2 -2
- package/dist/cjs/ultramodern-workspace/api/rpc.cjs +16 -14
- package/dist/cjs/ultramodern-workspace/api/service.cjs +4 -8
- package/dist/cjs/ultramodern-workspace/api/shared.cjs +1 -1
- package/dist/cjs/ultramodern-workspace/backend-federation.cjs +3 -3
- package/dist/cjs/ultramodern-workspace/contracts.cjs +14 -183
- package/dist/cjs/ultramodern-workspace/delivery-unit-stamp.cjs +10 -5
- package/dist/cjs/ultramodern-workspace/delivery-unit-sync.cjs +27 -17
- package/dist/cjs/ultramodern-workspace/delivery-unit.cjs +11 -6
- package/dist/cjs/ultramodern-workspace/descriptors.cjs +0 -4
- package/dist/cjs/ultramodern-workspace/generation-result.cjs +1 -1
- package/dist/cjs/ultramodern-workspace/index.cjs +2 -5
- package/dist/cjs/ultramodern-workspace/mf-validation/constants.cjs +0 -6
- package/dist/cjs/ultramodern-workspace/mf-validation/discovery.cjs +6 -6
- package/dist/cjs/ultramodern-workspace/mf-validation/path-utils.cjs +37 -38
- package/dist/cjs/ultramodern-workspace/module-federation/config.cjs +8 -15
- package/dist/cjs/ultramodern-workspace/package-json.cjs +47 -54
- package/dist/cjs/ultramodern-workspace/patch-inventory.cjs +27 -36
- package/dist/cjs/ultramodern-workspace/policy.cjs +6 -354
- package/dist/cjs/ultramodern-workspace/public-surface.cjs +2 -2
- package/dist/cjs/ultramodern-workspace/routes.cjs +11 -7
- package/dist/cjs/ultramodern-workspace/shells.cjs +0 -70
- package/dist/cjs/ultramodern-workspace/tooling-command-catalog.cjs +6 -43
- package/dist/cjs/ultramodern-workspace/tsconfigs.cjs +3 -1
- package/dist/cjs/ultramodern-workspace/validation/architecture.cjs +5 -5
- package/dist/cjs/ultramodern-workspace/validation/workspace.cjs +275 -1249
- package/dist/cjs/ultramodern-workspace/versions.cjs +25 -41
- package/dist/cjs/ultramodern-workspace/workspace-artifact-ownership.cjs +1 -6
- package/dist/cjs/ultramodern-workspace/workspace-script-plan.cjs +7 -7
- package/dist/cjs/ultramodern-workspace/workspace-scripts.cjs +17 -112
- package/dist/cjs/ultramodern-workspace/workspace-validation-contract.cjs +62 -371
- package/dist/cjs/ultramodern-workspace/write-app.cjs +5 -4
- package/dist/cjs/ultramodern-workspace/write-workspace.cjs +10 -50
- package/dist/esm/ultramodern-release-cohort.js +5 -14
- package/dist/esm/ultramodern-tooling/commands/context.js +2 -1
- package/dist/esm/ultramodern-tooling/commands/validate.js +3 -48
- package/dist/esm/ultramodern-tooling/commands.js +10 -1
- package/dist/esm/ultramodern-tooling/config/index.js +1 -0
- package/dist/esm/ultramodern-tooling/config/load.js +5 -17
- package/dist/esm/ultramodern-tooling/config/metadata.js +36 -1
- package/dist/esm/ultramodern-tooling/config/normalize.js +125 -201
- package/dist/esm/ultramodern-workspace/add-shell.js +55 -22
- package/dist/esm/ultramodern-workspace/add-vertical/execute.js +41 -41
- package/dist/esm/ultramodern-workspace/add-vertical/plan.js +2 -2
- package/dist/esm/ultramodern-workspace/add-vertical/preflight.js +3 -6
- package/dist/esm/ultramodern-workspace/add-vertical/topology.js +1 -30
- package/dist/esm/ultramodern-workspace/add-vertical/workspace-state.js +3 -10
- package/dist/esm/ultramodern-workspace/api/contracts.js +2 -2
- package/dist/esm/ultramodern-workspace/api/rpc.js +16 -14
- package/dist/esm/ultramodern-workspace/api/service.js +4 -8
- package/dist/esm/ultramodern-workspace/api/shared.js +1 -1
- package/dist/esm/ultramodern-workspace/backend-federation.js +3 -3
- package/dist/esm/ultramodern-workspace/contracts.js +14 -180
- package/dist/esm/ultramodern-workspace/delivery-unit-stamp.js +10 -5
- package/dist/esm/ultramodern-workspace/delivery-unit-sync.js +28 -18
- package/dist/esm/ultramodern-workspace/delivery-unit.js +11 -6
- package/dist/esm/ultramodern-workspace/descriptors.js +1 -2
- package/dist/esm/ultramodern-workspace/generation-result.js +2 -2
- package/dist/esm/ultramodern-workspace/index.js +1 -1
- package/dist/esm/ultramodern-workspace/mf-validation/constants.js +1 -4
- package/dist/esm/ultramodern-workspace/mf-validation/discovery.js +7 -7
- package/dist/esm/ultramodern-workspace/mf-validation/path-utils.js +36 -34
- package/dist/esm/ultramodern-workspace/module-federation/config.js +9 -16
- package/dist/esm/ultramodern-workspace/package-json.js +48 -55
- package/dist/esm/ultramodern-workspace/patch-inventory.js +27 -36
- package/dist/esm/ultramodern-workspace/policy.js +6 -335
- package/dist/esm/ultramodern-workspace/public-surface.js +2 -2
- package/dist/esm/ultramodern-workspace/routes.js +11 -7
- package/dist/esm/ultramodern-workspace/shells.js +3 -67
- package/dist/esm/ultramodern-workspace/tooling-command-catalog.js +7 -41
- package/dist/esm/ultramodern-workspace/tsconfigs.js +4 -2
- package/dist/esm/ultramodern-workspace/validation/architecture.js +5 -5
- package/dist/esm/ultramodern-workspace/validation/workspace.js +267 -1250
- package/dist/esm/ultramodern-workspace/versions.js +24 -28
- package/dist/esm/ultramodern-workspace/workspace-artifact-ownership.js +3 -8
- package/dist/esm/ultramodern-workspace/workspace-script-plan.js +7 -7
- package/dist/esm/ultramodern-workspace/workspace-scripts.js +18 -107
- package/dist/esm/ultramodern-workspace/workspace-validation-contract.js +64 -373
- package/dist/esm/ultramodern-workspace/write-app.js +4 -3
- package/dist/esm/ultramodern-workspace/write-workspace.js +16 -53
- package/dist/esm-node/ultramodern-release-cohort.js +5 -14
- package/dist/esm-node/ultramodern-tooling/commands/context.js +2 -1
- package/dist/esm-node/ultramodern-tooling/commands/validate.js +3 -48
- package/dist/esm-node/ultramodern-tooling/commands.js +10 -1
- package/dist/esm-node/ultramodern-tooling/config/index.js +1 -0
- package/dist/esm-node/ultramodern-tooling/config/load.js +5 -17
- package/dist/esm-node/ultramodern-tooling/config/metadata.js +36 -1
- package/dist/esm-node/ultramodern-tooling/config/normalize.js +125 -201
- package/dist/esm-node/ultramodern-workspace/add-shell.js +55 -22
- package/dist/esm-node/ultramodern-workspace/add-vertical/execute.js +41 -41
- package/dist/esm-node/ultramodern-workspace/add-vertical/plan.js +2 -2
- package/dist/esm-node/ultramodern-workspace/add-vertical/preflight.js +3 -6
- package/dist/esm-node/ultramodern-workspace/add-vertical/topology.js +1 -30
- package/dist/esm-node/ultramodern-workspace/add-vertical/workspace-state.js +3 -10
- package/dist/esm-node/ultramodern-workspace/api/contracts.js +2 -2
- package/dist/esm-node/ultramodern-workspace/api/rpc.js +16 -14
- package/dist/esm-node/ultramodern-workspace/api/service.js +4 -8
- package/dist/esm-node/ultramodern-workspace/api/shared.js +1 -1
- package/dist/esm-node/ultramodern-workspace/backend-federation.js +3 -3
- package/dist/esm-node/ultramodern-workspace/contracts.js +14 -180
- package/dist/esm-node/ultramodern-workspace/delivery-unit-stamp.js +10 -5
- package/dist/esm-node/ultramodern-workspace/delivery-unit-sync.js +28 -18
- package/dist/esm-node/ultramodern-workspace/delivery-unit.js +11 -6
- package/dist/esm-node/ultramodern-workspace/descriptors.js +1 -2
- package/dist/esm-node/ultramodern-workspace/generation-result.js +2 -2
- package/dist/esm-node/ultramodern-workspace/index.js +1 -1
- package/dist/esm-node/ultramodern-workspace/mf-validation/constants.js +1 -4
- package/dist/esm-node/ultramodern-workspace/mf-validation/discovery.js +7 -7
- package/dist/esm-node/ultramodern-workspace/mf-validation/path-utils.js +36 -34
- package/dist/esm-node/ultramodern-workspace/module-federation/config.js +9 -16
- package/dist/esm-node/ultramodern-workspace/package-json.js +48 -55
- package/dist/esm-node/ultramodern-workspace/patch-inventory.js +27 -36
- package/dist/esm-node/ultramodern-workspace/policy.js +6 -335
- package/dist/esm-node/ultramodern-workspace/public-surface.js +2 -2
- package/dist/esm-node/ultramodern-workspace/routes.js +11 -7
- package/dist/esm-node/ultramodern-workspace/shells.js +3 -67
- package/dist/esm-node/ultramodern-workspace/tooling-command-catalog.js +7 -41
- package/dist/esm-node/ultramodern-workspace/tsconfigs.js +4 -2
- package/dist/esm-node/ultramodern-workspace/validation/architecture.js +5 -5
- package/dist/esm-node/ultramodern-workspace/validation/workspace.js +267 -1250
- package/dist/esm-node/ultramodern-workspace/versions.js +24 -28
- package/dist/esm-node/ultramodern-workspace/workspace-artifact-ownership.js +3 -8
- package/dist/esm-node/ultramodern-workspace/workspace-script-plan.js +7 -7
- package/dist/esm-node/ultramodern-workspace/workspace-scripts.js +18 -107
- package/dist/esm-node/ultramodern-workspace/workspace-validation-contract.js +64 -373
- package/dist/esm-node/ultramodern-workspace/write-app.js +4 -3
- package/dist/esm-node/ultramodern-workspace/write-workspace.js +16 -53
- package/dist/types/ultramodern-release-cohort.d.ts +1 -3
- package/dist/types/ultramodern-tooling/commands/validate.d.ts +2 -2
- package/dist/types/ultramodern-tooling/config/index.d.ts +1 -0
- package/dist/types/ultramodern-tooling/config/load.d.ts +6 -58
- package/dist/types/ultramodern-tooling/config/metadata.d.ts +3 -0
- package/dist/types/ultramodern-tooling/config/normalize.d.ts +9 -90
- package/dist/types/ultramodern-tooling/config/types.d.ts +1 -9
- package/dist/types/ultramodern-workspace/add-vertical/preflight.d.ts +3 -3
- package/dist/types/ultramodern-workspace/add-vertical/topology.d.ts +0 -1
- package/dist/types/ultramodern-workspace/add-vertical/workspace-state.d.ts +1 -1
- package/dist/types/ultramodern-workspace/api/rpc.d.ts +1 -1
- package/dist/types/ultramodern-workspace/contracts.d.ts +1 -3
- package/dist/types/ultramodern-workspace/delivery-unit-stamp.d.ts +2 -2
- package/dist/types/ultramodern-workspace/delivery-unit.d.ts +2 -2
- package/dist/types/ultramodern-workspace/descriptors.d.ts +0 -1
- package/dist/types/ultramodern-workspace/index.d.ts +1 -1
- package/dist/types/ultramodern-workspace/mf-validation/constants.d.ts +0 -1
- package/dist/types/ultramodern-workspace/mf-validation/path-utils.d.ts +2 -3
- package/dist/types/ultramodern-workspace/module-federation/config.d.ts +1 -1
- package/dist/types/ultramodern-workspace/patch-inventory.d.ts +2 -10
- package/dist/types/ultramodern-workspace/policy.d.ts +60 -182
- package/dist/types/ultramodern-workspace/shells.d.ts +1 -14
- package/dist/types/ultramodern-workspace/tooling-command-catalog.d.ts +1 -6
- package/dist/types/ultramodern-workspace/validation/types.d.ts +1 -12
- package/dist/types/ultramodern-workspace/validation/workspace.d.ts +5 -2
- package/dist/types/ultramodern-workspace/versions.d.ts +23 -27
- package/dist/types/ultramodern-workspace/workspace-script-plan.d.ts +1 -1
- package/dist/types/ultramodern-workspace/workspace-scripts.d.ts +7 -14
- package/dist/types/ultramodern-workspace/workspace-validation-contract.d.ts +22 -188
- package/dist/types/ultramodern-workspace/write-workspace.d.ts +1 -3
- package/package.json +17 -16
- package/{template-workspace/.modernjs/release-cohort.json → release-cohort.json} +48 -48
- package/template-workspace/README.md.handlebars +9 -16
- package/template-workspace/pnpm-workspace.yaml.handlebars +0 -24
- package/templates/workspace/apps/modern.config.ts.handlebars +5 -5
- package/templates/workspace/apps/shared/src/routes/ultramodern-route-metadata.ts.handlebars +8 -21
- package/templates/workspace-scripts/generate-node-backend-federation.mjs +39 -49
- package/templates/workspace-scripts/generate-public-surface-assets.mjs +142 -206
- package/templates/workspace-scripts/materialize-zerops-runtime.mjs +3 -11
- package/templates/workspace-scripts/proof-cloudflare-version.mjs +53 -444
- package/templates/workspace-scripts/proof-node-backend-federation.mjs +193 -39
- package/templates/workspace-scripts/proof-workerd-ssr.mjs +126 -66
- package/templates/workspace-scripts/ultramodern-performance-readiness.mjs +45 -147
- package/dist/cjs/ultramodern-workspace/cohort-parity.cjs +0 -129
- package/dist/cjs/ultramodern-workspace/patch-parity.cjs +0 -163
- package/dist/esm/ultramodern-workspace/cohort-parity.js +0 -74
- package/dist/esm/ultramodern-workspace/patch-parity.js +0 -99
- package/dist/esm-node/ultramodern-workspace/cohort-parity.js +0 -75
- package/dist/esm-node/ultramodern-workspace/patch-parity.js +0 -100
- package/dist/types/ultramodern-workspace/cohort-parity.d.ts +0 -31
- package/dist/types/ultramodern-workspace/patch-parity.d.ts +0 -39
- package/template-workspace/patches/@module-federation__bridge-react@2.9.0.patch +0 -47
- package/template-workspace/patches/@module-federation__dts-plugin@2.9.0.patch +0 -132
- package/template-workspace/patches/@module-federation__modern-js-v3@2.9.0.patch +0 -287
- package/template-workspace/patches/@module-federation__runtime-core@2.9.0.patch +0 -13
- package/template-workspace/patches/drizzle-orm-ts7-strict-declarations.patch +0 -471
- package/template-workspace/patches/msgpackr@2.1.0.patch +0 -30
- package/template-workspace/patches/zod@4.5.4.patch +0 -56
- package/templates/packages/effect-bff-runtime.ts +0 -2
|
@@ -2,155 +2,59 @@
|
|
|
2
2
|
import fs from 'node:fs';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
5
|
+
import { format } from 'oxfmt';
|
|
6
|
+
import { tsImport } from 'tsx/esm/api';
|
|
7
|
+
import ultracite from 'ultracite/oxfmt';
|
|
5
8
|
|
|
6
9
|
const workspaceRoot = path.resolve(
|
|
7
10
|
process.env.ULTRAMODERN_WORKSPACE_ROOT ??
|
|
8
11
|
path.join(path.dirname(fileURLToPath(import.meta.url)), '..'),
|
|
9
12
|
);
|
|
10
|
-
const
|
|
13
|
+
const topologyPath = path.join(workspaceRoot, 'topology/reference-topology.json');
|
|
11
14
|
|
|
12
15
|
function readJson(filePath) {
|
|
13
16
|
return JSON.parse(fs.readFileSync(filePath, 'utf-8'));
|
|
14
17
|
}
|
|
15
18
|
|
|
16
|
-
function
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const kind = rawApp.kind === 'vertical' ? 'vertical' : 'shell';
|
|
52
|
-
const appPath =
|
|
53
|
-
typeof rawApp.path === 'string'
|
|
54
|
-
? normalizeRelativePath(rawApp.path)
|
|
55
|
-
: kind === 'shell'
|
|
56
|
-
? 'apps/shell-super-app'
|
|
57
|
-
: `verticals/${toKebabCase(id)}`;
|
|
58
|
-
const packageSuffix =
|
|
59
|
-
typeof rawApp.packageSuffix === 'string'
|
|
60
|
-
? rawApp.packageSuffix
|
|
61
|
-
: appPath.split('/').at(-1) ?? id;
|
|
62
|
-
const domain =
|
|
63
|
-
typeof rawApp.domain === 'string'
|
|
64
|
-
? rawApp.domain
|
|
65
|
-
: kind === 'vertical'
|
|
66
|
-
? packageSuffix
|
|
67
|
-
: undefined;
|
|
68
|
-
const moduleFederation =
|
|
69
|
-
rawApp.moduleFederation && typeof rawApp.moduleFederation === 'object'
|
|
70
|
-
? rawApp.moduleFederation
|
|
71
|
-
: {};
|
|
72
|
-
|
|
73
|
-
return {
|
|
74
|
-
id,
|
|
75
|
-
kind,
|
|
76
|
-
path: appPath,
|
|
77
|
-
packageSuffix,
|
|
78
|
-
domain,
|
|
79
|
-
port:
|
|
80
|
-
typeof rawApp.port === 'number'
|
|
81
|
-
? rawApp.port
|
|
82
|
-
: defaultPort({ id, kind, domain }),
|
|
83
|
-
portEnv:
|
|
84
|
-
typeof rawApp.portEnv === 'string'
|
|
85
|
-
? rawApp.portEnv
|
|
86
|
-
: defaultPortEnv({ id, kind, domain }),
|
|
87
|
-
mfName:
|
|
88
|
-
typeof moduleFederation.name === 'string'
|
|
89
|
-
? moduleFederation.name
|
|
90
|
-
: kind === 'shell'
|
|
91
|
-
? 'shellSuperApp'
|
|
92
|
-
: `vertical${toKebabCase(domain ?? id)
|
|
93
|
-
.split('-')
|
|
94
|
-
.filter(Boolean)
|
|
95
|
-
.map(part => part.charAt(0).toUpperCase() + part.slice(1))
|
|
96
|
-
.join('')}`,
|
|
97
|
-
exposes: Array.isArray(moduleFederation.exposes)
|
|
98
|
-
? moduleFederation.exposes.filter(expose => typeof expose === 'string')
|
|
99
|
-
: [],
|
|
100
|
-
verticalRefs: Array.isArray(moduleFederation.verticalRefs)
|
|
101
|
-
? moduleFederation.verticalRefs.filter(ref => typeof ref === 'string')
|
|
102
|
-
: [],
|
|
103
|
-
marker: {
|
|
104
|
-
appId: id,
|
|
105
|
-
},
|
|
106
|
-
routes:
|
|
107
|
-
rawApp.routes && typeof rawApp.routes === 'object'
|
|
108
|
-
? rawApp.routes
|
|
109
|
-
: undefined,
|
|
110
|
-
api:
|
|
111
|
-
rawApp.api && typeof rawApp.api === 'object'
|
|
112
|
-
? {
|
|
113
|
-
stem:
|
|
114
|
-
typeof rawApp.api.stem === 'string'
|
|
115
|
-
? rawApp.api.stem
|
|
116
|
-
: domain ?? id,
|
|
117
|
-
prefix:
|
|
118
|
-
typeof rawApp.api.prefix === 'string'
|
|
119
|
-
? rawApp.api.prefix
|
|
120
|
-
: `/${domain ?? id}-api`,
|
|
121
|
-
}
|
|
122
|
-
: undefined,
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
function createRouteOwnedEntries(app) {
|
|
127
|
-
const namespace = appNamespace(app);
|
|
128
|
-
const base = {
|
|
129
|
-
descriptionKey: `${namespace}.seo.description`,
|
|
130
|
-
mfBoundaryId: app.mfName,
|
|
131
|
-
namespace,
|
|
132
|
-
ownerAppId: app.id,
|
|
133
|
-
public: false,
|
|
134
|
-
indexable: false,
|
|
135
|
-
publicSurface: 'private-app-screen',
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
return [
|
|
139
|
-
{
|
|
140
|
-
...base,
|
|
141
|
-
canonicalPath: '/',
|
|
142
|
-
id: app.kind === 'shell' ? 'shell-home' : `${app.id}-home`,
|
|
143
|
-
localisedPaths: {
|
|
144
|
-
cs: '/',
|
|
145
|
-
en: '/',
|
|
146
|
-
},
|
|
147
|
-
titleKey: app.kind === 'shell' ? 'shell.title' : `${namespace}.title`,
|
|
148
|
-
},
|
|
149
|
-
];
|
|
19
|
+
async function readRouteOwnedEntries(app) {
|
|
20
|
+
const appRoot = fs.realpathSync(path.join(workspaceRoot, app.path));
|
|
21
|
+
const workspaceReal = fs.realpathSync(workspaceRoot);
|
|
22
|
+
const relativeAppPath = path.relative(workspaceReal, appRoot);
|
|
23
|
+
if (!relativeAppPath || relativeAppPath === '..' ||
|
|
24
|
+
relativeAppPath.startsWith(`..${path.sep}`) || path.isAbsolute(relativeAppPath))
|
|
25
|
+
throw new Error(`${app.id} topology path escapes the workspace`);
|
|
26
|
+
const routesRoot = path.join(appRoot, 'src/routes');
|
|
27
|
+
if (!fs.existsSync(routesRoot)) {
|
|
28
|
+
if (app.surfaceProfile === 'api-only') return [];
|
|
29
|
+
throw new Error(`${app.id} is missing its route-owned metadata directory`);
|
|
30
|
+
}
|
|
31
|
+
const files = [];
|
|
32
|
+
function visit(directory) {
|
|
33
|
+
for (const entry of fs.readdirSync(directory, { withFileTypes: true })) {
|
|
34
|
+
const file = path.join(directory, entry.name);
|
|
35
|
+
if (entry.isSymbolicLink()) throw new Error(`${app.id} route metadata may not be a symbolic link`);
|
|
36
|
+
if (entry.isDirectory()) visit(file);
|
|
37
|
+
else if (entry.name === 'route.meta.ts') files.push(file);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
visit(routesRoot);
|
|
41
|
+
const routes = [];
|
|
42
|
+
for (const file of files.sort()) {
|
|
43
|
+
const module = await tsImport(pathToFileURL(file).href, { parentURL: import.meta.url, tsconfig: false });
|
|
44
|
+
const namedRoute = module.routeMeta ?? module.default?.routeMeta;
|
|
45
|
+
const route = namedRoute ?? module.default?.default ?? module.default;
|
|
46
|
+
if (!route || typeof route !== 'object' || route.ownerAppId !== app.id ||
|
|
47
|
+
typeof route.id !== 'string' || typeof route.canonicalPath !== 'string' ||
|
|
48
|
+
!route.localisedPaths || typeof route.localisedPaths.en !== 'string' ||
|
|
49
|
+
typeof route.localisedPaths.cs !== 'string')
|
|
50
|
+
throw new Error(`${app.id} has invalid route-owned metadata in ${file}`);
|
|
51
|
+
routes.push({ file, route, exportName: namedRoute ? 'routeMeta' : 'default' });
|
|
52
|
+
}
|
|
53
|
+
return routes;
|
|
150
54
|
}
|
|
151
55
|
|
|
152
|
-
function createPublicRoutes(
|
|
153
|
-
return
|
|
56
|
+
function createPublicRoutes(routes) {
|
|
57
|
+
return routes
|
|
154
58
|
.filter(route => route.public && route.indexable)
|
|
155
59
|
.map(route => ({
|
|
156
60
|
canonicalPath: route.canonicalPath,
|
|
@@ -163,15 +67,24 @@ function createPublicRoutes(app) {
|
|
|
163
67
|
}));
|
|
164
68
|
}
|
|
165
69
|
|
|
166
|
-
function createPublicSurface(app) {
|
|
167
|
-
const publicRoutes = createPublicRoutes(
|
|
70
|
+
function createPublicSurface(app, routes) {
|
|
71
|
+
const publicRoutes = createPublicRoutes(routes);
|
|
72
|
+
const routeEntries = publicRoutes.filter(route =>
|
|
73
|
+
Object.values(route.localisedPaths).every(routePath =>
|
|
74
|
+
!/(?:^|\/):[^/]+|\[[^\]]+\]|\*/u.test(routePath),
|
|
75
|
+
),
|
|
76
|
+
).map(route => ({ ...route,
|
|
77
|
+
canonicalUrlPath: createLocalisedPublicPath(route.localisedPaths.en, 'en'),
|
|
78
|
+
localeUrlPaths: Object.fromEntries(['en', 'cs'].map(language =>
|
|
79
|
+
[language, createLocalisedPublicPath(route.localisedPaths[language], language)])),
|
|
80
|
+
}));
|
|
168
81
|
const basePublicSurface = {
|
|
169
82
|
authoring: 'colocated-route-meta',
|
|
170
83
|
artifactLifecycle: 'build-and-deploy-output',
|
|
171
84
|
generatedManifest: './src/routes/ultramodern-route-metadata',
|
|
172
85
|
source: 'route-owned-public-routes',
|
|
173
86
|
metadataExport: './src/routes/ultramodern-route-metadata',
|
|
174
|
-
generator: '
|
|
87
|
+
generator: 'ultramodern-create ultramodern public-surface',
|
|
175
88
|
outputRoot: 'dist/public',
|
|
176
89
|
cloudflareBuildOutputRoot: 'dist-cloudflare/public',
|
|
177
90
|
privateRoutePolicy: 'omit-from-generated-public-surface',
|
|
@@ -192,8 +105,8 @@ function createPublicSurface(app) {
|
|
|
192
105
|
},
|
|
193
106
|
contentSources: [],
|
|
194
107
|
publicRoutes,
|
|
195
|
-
routeEntries
|
|
196
|
-
concreteUrlPaths:
|
|
108
|
+
routeEntries,
|
|
109
|
+
concreteUrlPaths: uniqueSorted(routeEntries.flatMap(route => Object.values(route.localeUrlPaths))),
|
|
197
110
|
};
|
|
198
111
|
|
|
199
112
|
return app.routes?.publicSurface &&
|
|
@@ -205,59 +118,41 @@ function createPublicSurface(app) {
|
|
|
205
118
|
: basePublicSurface;
|
|
206
119
|
}
|
|
207
120
|
|
|
208
|
-
function
|
|
209
|
-
const
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
const
|
|
214
|
-
typeof config.deploy?.worker?.compatibilityDate === 'string'
|
|
215
|
-
? config.deploy.worker.compatibilityDate
|
|
216
|
-
: '2026-06-02';
|
|
217
|
-
return {
|
|
218
|
-
workerName: `${toKebabCase(packageScope)}-${app.packageSuffix}`.slice(0, 63),
|
|
219
|
-
publicUrlEnv: `ULTRAMODERN_PUBLIC_URL_${toEnvSegment(app.id)}`,
|
|
220
|
-
compatibilityDate,
|
|
221
|
-
compatibilityFlags: ['nodejs_compat', 'global_fetch_strictly_public'],
|
|
222
|
-
};
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
function synthesizeContractFromCompactConfig(config) {
|
|
226
|
-
const apps = Array.isArray(config.topology?.apps)
|
|
227
|
-
? config.topology.apps.map(normalizeCompactApp)
|
|
228
|
-
: [];
|
|
229
|
-
|
|
121
|
+
export async function readGeneratedContractView() {
|
|
122
|
+
const topology = readJson(topologyPath);
|
|
123
|
+
if (topology.schemaVersion !== 1 || !topology.shell || !Array.isArray(topology.verticals)) {
|
|
124
|
+
throw new Error('Invalid topology/reference-topology.json');
|
|
125
|
+
}
|
|
126
|
+
const apps = [topology.shell, ...topology.verticals, ...(topology.shells ?? [])];
|
|
230
127
|
return {
|
|
231
|
-
sourcePath:
|
|
232
|
-
apps: apps.map(app =>
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
128
|
+
sourcePath: topologyPath,
|
|
129
|
+
apps: await Promise.all(apps.map(async app => {
|
|
130
|
+
if (typeof app.path !== 'string' || !app.path) {
|
|
131
|
+
throw new Error(`${app.id} topology path is missing`);
|
|
132
|
+
}
|
|
133
|
+
const routeModules = await readRouteOwnedEntries(app);
|
|
134
|
+
return {
|
|
135
|
+
id: app.id,
|
|
136
|
+
kind: app.kind,
|
|
137
|
+
surfaceProfile: app.surfaceProfile,
|
|
138
|
+
path: app.path,
|
|
139
|
+
domain: app.domain,
|
|
140
|
+
mfName: app.moduleFederation?.name,
|
|
141
|
+
marker: { appId: app.id },
|
|
142
|
+
deploy: { cloudflare: app.cloudflare },
|
|
143
|
+
routes: { publicSurface: createPublicSurface(app, routeModules.map(entry => entry.route)) },
|
|
144
|
+
routeModules,
|
|
145
|
+
};
|
|
240
146
|
})),
|
|
241
147
|
};
|
|
242
148
|
}
|
|
243
149
|
|
|
244
|
-
function readGeneratedContractView() {
|
|
245
|
-
if (fs.existsSync(compactConfigPath)) {
|
|
246
|
-
return synthesizeContractFromCompactConfig(readJson(compactConfigPath));
|
|
247
|
-
}
|
|
248
|
-
throw new Error(
|
|
249
|
-
`Missing UltraModern config. Expected ${path.relative(
|
|
250
|
-
workspaceRoot,
|
|
251
|
-
compactConfigPath,
|
|
252
|
-
)}.`,
|
|
253
|
-
);
|
|
254
|
-
}
|
|
255
|
-
|
|
256
150
|
function parseArgs(argv) {
|
|
257
151
|
const parsed = {
|
|
258
152
|
appId: undefined,
|
|
259
153
|
target: 'dist',
|
|
260
154
|
requirePublicOrigin: false,
|
|
155
|
+
syncRouteMetadata: false,
|
|
261
156
|
};
|
|
262
157
|
|
|
263
158
|
for (let index = 0; index < argv.length; index += 1) {
|
|
@@ -270,6 +165,8 @@ function parseArgs(argv) {
|
|
|
270
165
|
index += 1;
|
|
271
166
|
} else if (arg === '--require-public-origin') {
|
|
272
167
|
parsed.requirePublicOrigin = true;
|
|
168
|
+
} else if (arg === '--sync-route-metadata') {
|
|
169
|
+
parsed.syncRouteMetadata = true;
|
|
273
170
|
} else if (arg === '--help' || arg === '-h') {
|
|
274
171
|
parsed.help = true;
|
|
275
172
|
} else {
|
|
@@ -289,7 +186,7 @@ function parseArgs(argv) {
|
|
|
289
186
|
|
|
290
187
|
function printHelp() {
|
|
291
188
|
process.stdout.write(`Usage:
|
|
292
|
-
|
|
189
|
+
ultramodern-create ultramodern public-surface --app shell-super-app [--target dist|cloudflare-dist] [--require-public-origin|--sync-route-metadata]
|
|
293
190
|
|
|
294
191
|
Set each app's production URL using the contract env key, for example:
|
|
295
192
|
ULTRAMODERN_PUBLIC_URL_SHELL_SUPER_APP=https://example.com
|
|
@@ -714,19 +611,55 @@ function writeText(outputDir, fileName, content) {
|
|
|
714
611
|
fs.writeFileSync(path.join(outputDir, fileName), content);
|
|
715
612
|
}
|
|
716
613
|
|
|
717
|
-
async function
|
|
614
|
+
async function syncRouteMetadata(app) {
|
|
615
|
+
if (app.surfaceProfile === 'api-only') return;
|
|
616
|
+
const file = path.join(fs.realpathSync(path.join(workspaceRoot, app.path)),
|
|
617
|
+
'src/routes/ultramodern-route-metadata.ts');
|
|
618
|
+
const imports = app.routeModules.map(({ file: routeFile, exportName }, index) => {
|
|
619
|
+
const relative = path.relative(path.dirname(file), routeFile).replaceAll(path.sep, '/').replace(/\.ts$/u, '');
|
|
620
|
+
const specifier = JSON.stringify(relative.startsWith('.') ? relative : `./${relative}`);
|
|
621
|
+
return exportName === 'routeMeta'
|
|
622
|
+
? `import { routeMeta as route${index} } from ${specifier};`
|
|
623
|
+
: `import route${index} from ${specifier};`;
|
|
624
|
+
});
|
|
625
|
+
const namespace = app.kind === 'shell' ? 'shell' : (app.domain ?? app.id);
|
|
626
|
+
const content = `// @generated by @modern-js/ultramodern-create from route-owned metadata.\n${imports.join('\n')}\n\nexport const ultramodernRouteNamespace = ${JSON.stringify(namespace)} as const;\nexport const ultramodernRouteMetadata = [${app.routeModules.map((_, index) => `route${index}`).join(', ')}] as const;\nexport const ultramodernLocalisedUrls = Object.fromEntries(ultramodernRouteMetadata.filter(route => route.canonicalPath !== '/').map(route => [route.canonicalPath, route.localisedPaths]));\nexport const ultramodernPublicRoutes = ultramodernRouteMetadata.filter(route => route.public && route.indexable).map(route => ({ canonicalPath: route.canonicalPath, descriptionKey: route.descriptionKey, id: route.id, localisedPaths: route.localisedPaths, namespace: route.namespace, ownerAppId: route.ownerAppId, titleKey: route.titleKey, ...('jsonLd' in route ? { jsonLd: route.jsonLd } : {}) }));\nexport const ultramodernRouteConfig = { authoring: 'colocated-route-meta', generatedManifest: true, localisedUrls: ultramodernLocalisedUrls, namespace: ultramodernRouteNamespace, publicRoutes: ultramodernPublicRoutes, routes: ultramodernRouteMetadata, source: 'route-owned' } as const;\n`;
|
|
627
|
+
const formatted = await format(file, content, {
|
|
628
|
+
...ultracite,
|
|
629
|
+
printWidth: 120,
|
|
630
|
+
singleQuote: true,
|
|
631
|
+
trailingComma: 'all',
|
|
632
|
+
});
|
|
633
|
+
if (formatted.errors.length > 0)
|
|
634
|
+
throw new Error(`${app.id} route metadata aggregate could not be formatted`);
|
|
635
|
+
if (!fs.existsSync(file) || fs.readFileSync(file, 'utf8') !== formatted.code)
|
|
636
|
+
fs.writeFileSync(file, formatted.code);
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
export async function resolvePublicSurface(app) {
|
|
718
640
|
const publicSurface = app.routes?.publicSurface ?? {};
|
|
719
641
|
const languages = publicSurface.languages ?? ['en', 'cs'];
|
|
720
|
-
const outputDir = ensureOutputDir(app, target);
|
|
721
|
-
const shouldRequirePublicOrigin =
|
|
722
|
-
requirePublicOrigin ||
|
|
723
|
-
process.env.ULTRAMODERN_CLOUDFLARE_REQUIRE_PUBLIC_URLS === 'true';
|
|
724
642
|
const routeEntries = mergeRouteEntries(
|
|
725
643
|
publicSurface.routeEntries ?? [],
|
|
726
644
|
await expandContentSources(app, publicSurface, languages),
|
|
727
645
|
languages,
|
|
728
646
|
);
|
|
729
|
-
|
|
647
|
+
return {
|
|
648
|
+
...publicSurface,
|
|
649
|
+
routeEntries,
|
|
650
|
+
concreteUrlPaths: createConcreteUrlPaths(routeEntries, languages),
|
|
651
|
+
};
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
async function generatePublicSurfaceAssets(app, target, requirePublicOrigin) {
|
|
655
|
+
const publicSurface = await resolvePublicSurface(app);
|
|
656
|
+
const languages = publicSurface.languages ?? ['en', 'cs'];
|
|
657
|
+
const outputDir = ensureOutputDir(app, target);
|
|
658
|
+
const shouldRequirePublicOrigin =
|
|
659
|
+
requirePublicOrigin ||
|
|
660
|
+
process.env.ULTRAMODERN_CLOUDFLARE_REQUIRE_PUBLIC_URLS === 'true';
|
|
661
|
+
const routeEntries = publicSurface.routeEntries;
|
|
662
|
+
const urlPaths = publicSurface.concreteUrlPaths;
|
|
730
663
|
|
|
731
664
|
if (routeEntries.length === 0) {
|
|
732
665
|
writeText(outputDir, 'robots.txt', renderRobotsTxt([], undefined));
|
|
@@ -748,19 +681,22 @@ async function generatePublicSurfaceAssets(app, target, requirePublicOrigin) {
|
|
|
748
681
|
writeText(outputDir, 'robots.txt', renderRobotsTxt(urlPaths, `${origin}/sitemap.xml`));
|
|
749
682
|
}
|
|
750
683
|
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
684
|
+
if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
|
685
|
+
try {
|
|
686
|
+
const args = parseArgs(process.argv.slice(2));
|
|
687
|
+
if (args.help) {
|
|
688
|
+
printHelp();
|
|
689
|
+
process.exit(0);
|
|
690
|
+
}
|
|
691
|
+
const contract = await readGeneratedContractView();
|
|
692
|
+
const app = contract.apps?.find(candidate => candidate.id === args.appId);
|
|
693
|
+
if (!app) {
|
|
694
|
+
throw new Error(`Unknown app in UltraModern config: ${args.appId}`);
|
|
695
|
+
}
|
|
696
|
+
if (args.syncRouteMetadata) await syncRouteMetadata(app);
|
|
697
|
+
else await generatePublicSurfaceAssets(app, args.target, args.requirePublicOrigin);
|
|
698
|
+
} catch (error) {
|
|
699
|
+
process.stderr.write(`[public-surface] ${error.message}\n`);
|
|
700
|
+
process.exitCode = 1;
|
|
761
701
|
}
|
|
762
|
-
await generatePublicSurfaceAssets(app, args.target, args.requirePublicOrigin);
|
|
763
|
-
} catch (error) {
|
|
764
|
-
process.stderr.write(`[public-surface] ${error.message}\n`);
|
|
765
|
-
process.exitCode = 1;
|
|
766
702
|
}
|
|
@@ -3,6 +3,7 @@ import fs from 'node:fs';
|
|
|
3
3
|
import os from 'node:os';
|
|
4
4
|
import path from 'node:path';
|
|
5
5
|
import execa from '@modern-js/utils/execa';
|
|
6
|
+
import { readWorkspacePackageSource } from '../../dist/esm-node/ultramodern-tooling/config/metadata.js';
|
|
6
7
|
|
|
7
8
|
const workspaceRoot = path.resolve(
|
|
8
9
|
process.env.ULTRAMODERN_WORKSPACE_ROOT ?? process.cwd(),
|
|
@@ -45,10 +46,6 @@ function readJson(filePath) {
|
|
|
45
46
|
return JSON.parse(fs.readFileSync(filePath, 'utf-8'));
|
|
46
47
|
}
|
|
47
48
|
|
|
48
|
-
function readOptionalJson(filePath) {
|
|
49
|
-
return fs.existsSync(filePath) ? readJson(filePath) : undefined;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
49
|
function writeJson(filePath, value) {
|
|
53
50
|
fs.writeFileSync(filePath, `${JSON.stringify(value, null, 2)}\n`, 'utf-8');
|
|
54
51
|
}
|
|
@@ -221,13 +218,8 @@ console.log(
|
|
|
221
218
|
);
|
|
222
219
|
|
|
223
220
|
function normalizeRuntimePackageDependencies(packageJson) {
|
|
224
|
-
const
|
|
225
|
-
|
|
226
|
-
);
|
|
227
|
-
const packageSource = compactConfig?.packageSource;
|
|
228
|
-
const modernPackageVersion = packageSource?.modernPackageVersion;
|
|
229
|
-
const aliasScope = packageSource?.aliasScope;
|
|
230
|
-
const aliasPackageNamePrefix = packageSource?.aliasPackageNamePrefix;
|
|
221
|
+
const { modernPackageVersion, aliasScope, aliasPackageNamePrefix } =
|
|
222
|
+
readWorkspacePackageSource(workspaceRoot);
|
|
231
223
|
|
|
232
224
|
if (!modernPackageVersion || !aliasScope || !aliasPackageNamePrefix) {
|
|
233
225
|
return;
|