@bleedingdev/modern-js-create 3.2.0-ultramodern.117 → 3.2.0-ultramodern.118
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 +35 -125
- package/dist/cjs/create-package-root.cjs +1 -1
- package/dist/cjs/index.cjs +11 -602
- package/dist/cjs/locale/en.cjs +12 -19
- package/dist/cjs/locale/zh.cjs +12 -19
- package/dist/cjs/ultramodern-workspace.cjs +16 -19
- package/dist/esm/create-package-root.js +1 -1
- package/dist/esm/index.js +13 -603
- package/dist/esm/locale/en.js +12 -19
- package/dist/esm/locale/zh.js +12 -19
- package/dist/esm/ultramodern-workspace.js +17 -17
- package/dist/esm-node/create-package-root.js +1 -1
- package/dist/esm-node/index.js +13 -603
- package/dist/esm-node/locale/en.js +12 -19
- package/dist/esm-node/locale/zh.js +12 -19
- package/dist/esm-node/ultramodern-workspace.js +17 -17
- package/dist/types/locale/en.d.ts +0 -7
- package/dist/types/locale/index.d.ts +0 -14
- package/dist/types/locale/zh.d.ts +0 -7
- package/dist/types/ultramodern-workspace.d.ts +0 -1
- package/package.json +4 -5
- package/template-workspace/.github/workflows/ultramodern-workspace-gates.yml.handlebars +22 -6
- package/template-workspace/AGENTS.md +7 -3
- package/template-workspace/README.md.handlebars +5 -1
- package/template-workspace/lefthook.yml +18 -4
- package/template/.agents/skills-lock.json +0 -34
- package/template/.browserslistrc +0 -4
- package/template/.codex/hooks.json +0 -16
- package/template/.github/renovate.json +0 -53
- package/template/.github/workflows/ultramodern-gates.yml.handlebars +0 -54
- package/template/.gitignore.handlebars +0 -30
- package/template/.mise.toml.handlebars +0 -2
- package/template/.nvmrc +0 -2
- package/template/AGENTS.md +0 -23
- package/template/README.md +0 -111
- package/template/api/effect/index.ts.handlebars +0 -34
- package/template/api/lambda/hello.ts.handlebars +0 -6
- package/template/config/favicon.svg +0 -5
- package/template/config/public/assets/ultramodern-logo.svg +0 -6
- package/template/config/public/locales/cs/translation.json +0 -44
- package/template/config/public/locales/en/translation.json +0 -44
- package/template/lefthook.yml +0 -10
- package/template/modern.config.ts.handlebars +0 -78
- package/template/oxfmt.config.ts +0 -15
- package/template/oxlint.config.ts +0 -19
- package/template/package.json.handlebars +0 -69
- package/template/pnpm-workspace.yaml +0 -34
- package/template/postcss.config.mjs.handlebars +0 -6
- package/template/rstest.config.mts +0 -5
- package/template/scripts/bootstrap-agent-skills.mjs +0 -228
- package/template/scripts/check-i18n-strings.mjs +0 -3
- package/template/scripts/validate-ultramodern.mjs.handlebars +0 -658
- package/template/shared/effect/api.ts.handlebars +0 -17
- package/template/src/modern-app-env.d.ts +0 -3
- package/template/src/modern.runtime.ts.handlebars +0 -23
- package/template/src/routes/[lang]/page.tsx.handlebars +0 -209
- package/template/src/routes/index.css.handlebars +0 -266
- package/template/src/routes/layout.tsx.handlebars +0 -10
- package/template/tailwind.config.ts.handlebars +0 -10
- package/template/tests/tsconfig.json +0 -7
- package/template/tests/ultramodern.contract.test.ts.handlebars +0 -163
- package/template/tsconfig.json +0 -121
package/dist/cjs/index.cjs
CHANGED
|
@@ -29,8 +29,6 @@ var __webpack_require__ = {};
|
|
|
29
29
|
})();
|
|
30
30
|
var __webpack_exports__ = {};
|
|
31
31
|
const external_node_child_process_namespaceObject = require("node:child_process");
|
|
32
|
-
const external_node_crypto_namespaceObject = require("node:crypto");
|
|
33
|
-
var external_node_crypto_default = /*#__PURE__*/ __webpack_require__.n(external_node_crypto_namespaceObject);
|
|
34
32
|
const external_node_fs_namespaceObject = require("node:fs");
|
|
35
33
|
var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
|
|
36
34
|
const external_node_path_namespaceObject = require("node:path");
|
|
@@ -44,48 +42,7 @@ const external_ultramodern_package_source_cjs_namespaceObject = require("./ultra
|
|
|
44
42
|
const external_ultramodern_workspace_cjs_namespaceObject = require("./ultramodern-workspace.cjs");
|
|
45
43
|
const src_dirname = external_node_path_default().dirname((0, external_node_url_namespaceObject.fileURLToPath)(__rslib_import_meta_url__));
|
|
46
44
|
const createPackageRoot = (0, external_create_package_root_cjs_namespaceObject.resolveCreatePackageRoot)(src_dirname);
|
|
47
|
-
const templateDir = external_node_path_default().join(createPackageRoot, 'template');
|
|
48
45
|
const semverPattern = /^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/;
|
|
49
|
-
const semverTagPattern = /^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(?:-[0-9A-Za-z.-]+)?$/;
|
|
50
|
-
const sha1Pattern = /^[0-9a-f]{40}$/;
|
|
51
|
-
const sha256Pattern = /^[0-9a-f]{64}$/;
|
|
52
|
-
const templateIdPattern = /^[a-z0-9][a-z0-9._-]*$/;
|
|
53
|
-
const packageNamePattern = /^(?:@[a-z0-9._-]+\/)?[a-z0-9._-]+$/;
|
|
54
|
-
const TANSTACK_ROUTER_VERSION = '1.170.15';
|
|
55
|
-
const TAILWIND_VERSION = '4.3.0';
|
|
56
|
-
const TAILWIND_POSTCSS_VERSION = '4.3.0';
|
|
57
|
-
const PNPM_VERSION = '11.5.2';
|
|
58
|
-
const I18NEXT_VERSION = '26.3.1';
|
|
59
|
-
const REACT_VERSION = '^19.2.7';
|
|
60
|
-
const REACT_DOM_VERSION = '^19.2.7';
|
|
61
|
-
const REACT_I18NEXT_VERSION = '17.0.8';
|
|
62
|
-
const EFFECT_TSGO_VERSION = '0.14.0';
|
|
63
|
-
const TYPESCRIPT_NATIVE_PREVIEW_VERSION = '7.0.0-dev.20260606.1';
|
|
64
|
-
const HAPPY_DOM_VERSION = '^20.10.1';
|
|
65
|
-
const RSTEST_CORE_VERSION = '0.10.3';
|
|
66
|
-
const OXFMT_VERSION = '0.53.0';
|
|
67
|
-
const OXLINT_VERSION = '1.68.0';
|
|
68
|
-
const POSTCSS_VERSION = '^8.5.15';
|
|
69
|
-
const ULTRACITE_VERSION = '7.8.1';
|
|
70
|
-
const TYPES_REACT_VERSION = '^19.2.17';
|
|
71
|
-
const TYPES_REACT_DOM_VERSION = '^19.2.3';
|
|
72
|
-
const requiredDeniedPaths = [
|
|
73
|
-
'.git/**',
|
|
74
|
-
'.npmrc',
|
|
75
|
-
'.yarnrc',
|
|
76
|
-
'.env',
|
|
77
|
-
'.env.*',
|
|
78
|
-
'node_modules/**',
|
|
79
|
-
'dist/**'
|
|
80
|
-
];
|
|
81
|
-
const requiredLifecycleDeniedScripts = [
|
|
82
|
-
'preinstall',
|
|
83
|
-
'install',
|
|
84
|
-
'prepare'
|
|
85
|
-
];
|
|
86
|
-
const requiredLifecycleAllowedScripts = [
|
|
87
|
-
'postinstall'
|
|
88
|
-
];
|
|
89
46
|
const LEGACY_MODERN_JS_FLAG = '--legacy-modern-js';
|
|
90
47
|
const LEGACY_MODERN_JS_CONFIRMATION = 'USE LEGACY MODERN.JS';
|
|
91
48
|
function getOptionValue(args, names) {
|
|
@@ -108,319 +65,6 @@ const detectLanguage = ()=>{
|
|
|
108
65
|
index_cjs_namespaceObject.i18n.changeLanguage({
|
|
109
66
|
locale: detectLanguage()
|
|
110
67
|
});
|
|
111
|
-
function detectRouterFramework() {
|
|
112
|
-
const args = process.argv.slice(2);
|
|
113
|
-
if (args.includes('--tanstack')) return 'tanstack';
|
|
114
|
-
const routerValue = getOptionValue(args, [
|
|
115
|
-
'--router',
|
|
116
|
-
'-r'
|
|
117
|
-
]);
|
|
118
|
-
if (!routerValue || 'tanstack' === routerValue) return 'tanstack';
|
|
119
|
-
if ('react-router' === routerValue) return 'react-router';
|
|
120
|
-
console.error(index_cjs_namespaceObject.i18n.t(index_cjs_namespaceObject.localeKeys.error.invalidRouter, {
|
|
121
|
-
router: routerValue
|
|
122
|
-
}));
|
|
123
|
-
process.exit(1);
|
|
124
|
-
}
|
|
125
|
-
function detectBffRuntime() {
|
|
126
|
-
const args = process.argv.slice(2);
|
|
127
|
-
const runtimeValue = getOptionValue(args, [
|
|
128
|
-
'--bff-runtime'
|
|
129
|
-
]);
|
|
130
|
-
if (!runtimeValue) return 'effect';
|
|
131
|
-
if ('hono' === runtimeValue || 'effect' === runtimeValue) return runtimeValue;
|
|
132
|
-
console.error(index_cjs_namespaceObject.i18n.t(index_cjs_namespaceObject.localeKeys.error.invalidBffRuntime, {
|
|
133
|
-
runtime: runtimeValue
|
|
134
|
-
}));
|
|
135
|
-
process.exit(1);
|
|
136
|
-
}
|
|
137
|
-
function renderTemplate(template, data) {
|
|
138
|
-
const tagRegex = /\{\{(~?)(#if|#unless|\/if|\/unless)(?:\s+(\w+))?(~?)\}\}/g;
|
|
139
|
-
function renderConditionals(startIndex, expectedClose) {
|
|
140
|
-
let rendered = '';
|
|
141
|
-
let cursor = startIndex;
|
|
142
|
-
tagRegex.lastIndex = startIndex;
|
|
143
|
-
while(true){
|
|
144
|
-
const match = tagRegex.exec(template);
|
|
145
|
-
if (!match) return {
|
|
146
|
-
rendered: rendered + template.slice(cursor),
|
|
147
|
-
nextIndex: template.length
|
|
148
|
-
};
|
|
149
|
-
const [raw, , tag, condition, rightTrim] = match;
|
|
150
|
-
const tagIndex = match.index;
|
|
151
|
-
rendered += template.slice(cursor, tagIndex);
|
|
152
|
-
cursor = tagIndex + raw.length;
|
|
153
|
-
if ('#if' === tag || '#unless' === tag) {
|
|
154
|
-
const kind = '#if' === tag ? 'if' : 'unless';
|
|
155
|
-
const innerResult = renderConditionals(cursor, kind);
|
|
156
|
-
cursor = innerResult.nextIndex;
|
|
157
|
-
tagRegex.lastIndex = cursor;
|
|
158
|
-
const conditionValue = Boolean(data[condition ?? '']);
|
|
159
|
-
const shouldInclude = 'if' === kind ? conditionValue : !conditionValue;
|
|
160
|
-
if (shouldInclude) rendered += innerResult.rendered;
|
|
161
|
-
continue;
|
|
162
|
-
}
|
|
163
|
-
if ('/if' === tag || '/unless' === tag) {
|
|
164
|
-
const kind = '/if' === tag ? 'if' : 'unless';
|
|
165
|
-
if (expectedClose === kind) {
|
|
166
|
-
let nextIndex = cursor;
|
|
167
|
-
if ('~' === rightTrim) {
|
|
168
|
-
const trailingWhitespace = /^\s*/u.exec(template.slice(nextIndex));
|
|
169
|
-
nextIndex += trailingWhitespace?.[0].length ?? 0;
|
|
170
|
-
}
|
|
171
|
-
return {
|
|
172
|
-
rendered,
|
|
173
|
-
nextIndex
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
rendered += raw;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
let result = renderConditionals(0).rendered;
|
|
181
|
-
const varRegex = /\{\{(\w+)\}\}/g;
|
|
182
|
-
result = result.replace(varRegex, (match, key)=>{
|
|
183
|
-
const value = data[key];
|
|
184
|
-
return null != value ? String(value) : match;
|
|
185
|
-
});
|
|
186
|
-
return result;
|
|
187
|
-
}
|
|
188
|
-
function normalizePathForManifest(filePath) {
|
|
189
|
-
return filePath.split(external_node_path_default().sep).join('/');
|
|
190
|
-
}
|
|
191
|
-
function isUnsafeRelativePath(filePath) {
|
|
192
|
-
return 0 === filePath.length || external_node_path_default().isAbsolute(filePath) || filePath.startsWith('/') || /^[A-Za-z]:[\\/]/.test(filePath) || filePath.split(/[\\/]+/).includes('..');
|
|
193
|
-
}
|
|
194
|
-
function hashFile(filePath) {
|
|
195
|
-
return external_node_crypto_default().createHash('sha256').update(external_node_fs_default().readFileSync(filePath)).digest('hex');
|
|
196
|
-
}
|
|
197
|
-
function getTemplateFiles(dir) {
|
|
198
|
-
const files = [];
|
|
199
|
-
function collect(currentDir) {
|
|
200
|
-
const entries = external_node_fs_default().readdirSync(currentDir, {
|
|
201
|
-
withFileTypes: true
|
|
202
|
-
}).sort((a, b)=>a.name.localeCompare(b.name));
|
|
203
|
-
for (const entry of entries){
|
|
204
|
-
const entryPath = external_node_path_default().join(currentDir, entry.name);
|
|
205
|
-
if (entry.isDirectory()) collect(entryPath);
|
|
206
|
-
else if (entry.isFile()) files.push(normalizePathForManifest(external_node_path_default().relative(dir, entryPath)));
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
collect(dir);
|
|
210
|
-
return files;
|
|
211
|
-
}
|
|
212
|
-
function hashTemplateTree(dir) {
|
|
213
|
-
const hash = external_node_crypto_default().createHash('sha256');
|
|
214
|
-
for (const relativePath of getTemplateFiles(dir)){
|
|
215
|
-
const fileHash = hashFile(external_node_path_default().join(dir, relativePath));
|
|
216
|
-
hash.update(relativePath);
|
|
217
|
-
hash.update('\0');
|
|
218
|
-
hash.update(fileHash);
|
|
219
|
-
hash.update('\0');
|
|
220
|
-
}
|
|
221
|
-
return hash.digest('hex');
|
|
222
|
-
}
|
|
223
|
-
function createBuiltinTemplateManifest(version) {
|
|
224
|
-
return {
|
|
225
|
-
schemaVersion: 1,
|
|
226
|
-
template: {
|
|
227
|
-
id: 'modernjs-ultramodern-app',
|
|
228
|
-
version,
|
|
229
|
-
displayName: 'Modern.js Ultramodern App',
|
|
230
|
-
description: 'Repository-owned Modern.js application scaffold with UltraModern preset defaults.',
|
|
231
|
-
compatibilityLane: 'ultramodern-mv',
|
|
232
|
-
minimumModernVersion: version
|
|
233
|
-
},
|
|
234
|
-
source: {
|
|
235
|
-
type: 'builtin',
|
|
236
|
-
name: 'modernjs-ultramodern-app',
|
|
237
|
-
repositoryPath: 'packages/toolkit/create/template'
|
|
238
|
-
},
|
|
239
|
-
integrity: {
|
|
240
|
-
checksums: [
|
|
241
|
-
{
|
|
242
|
-
algorithm: 'sha256',
|
|
243
|
-
value: hashTemplateTree(templateDir),
|
|
244
|
-
scope: 'source-tree'
|
|
245
|
-
}
|
|
246
|
-
],
|
|
247
|
-
provenance: {
|
|
248
|
-
kind: 'repo-local',
|
|
249
|
-
issuer: '@modern-js/create',
|
|
250
|
-
subject: 'packages/toolkit/create/template'
|
|
251
|
-
}
|
|
252
|
-
},
|
|
253
|
-
materialization: {
|
|
254
|
-
targetRoot: 'generated-project-root',
|
|
255
|
-
allowedPaths: [
|
|
256
|
-
'.agents/**',
|
|
257
|
-
'.browserslistrc',
|
|
258
|
-
'.codex/**',
|
|
259
|
-
'.github/**',
|
|
260
|
-
'.gitignore',
|
|
261
|
-
'.mise.toml',
|
|
262
|
-
'.modernjs/**',
|
|
263
|
-
'.nvmrc',
|
|
264
|
-
'AGENTS.md',
|
|
265
|
-
'README.md',
|
|
266
|
-
'api/**',
|
|
267
|
-
'config/**',
|
|
268
|
-
'lefthook.yml',
|
|
269
|
-
'modern.config.ts',
|
|
270
|
-
'oxfmt.config.ts',
|
|
271
|
-
'oxlint.config.ts',
|
|
272
|
-
'package.json',
|
|
273
|
-
'pnpm-workspace.yaml',
|
|
274
|
-
'postcss.config.mjs',
|
|
275
|
-
'rstest.config.mts',
|
|
276
|
-
"scripts/**",
|
|
277
|
-
'shared/**',
|
|
278
|
-
'src/**',
|
|
279
|
-
'tailwind.config.ts',
|
|
280
|
-
'tests/**',
|
|
281
|
-
'tsconfig.json'
|
|
282
|
-
],
|
|
283
|
-
deniedPaths: requiredDeniedPaths,
|
|
284
|
-
overwritePolicy: 'deny-existing'
|
|
285
|
-
},
|
|
286
|
-
lifecyclePolicy: {
|
|
287
|
-
denyByDefault: true,
|
|
288
|
-
deniedScripts: requiredLifecycleDeniedScripts,
|
|
289
|
-
allowedScripts: requiredLifecycleAllowedScripts,
|
|
290
|
-
requiresExplicitOptIn: true
|
|
291
|
-
},
|
|
292
|
-
validation: {
|
|
293
|
-
schemaValidation: true,
|
|
294
|
-
sourceValidation: [
|
|
295
|
-
'source-type-supported',
|
|
296
|
-
'checksum-verified',
|
|
297
|
-
'provenance-present'
|
|
298
|
-
],
|
|
299
|
-
materializationValidation: [
|
|
300
|
-
'path-boundary-allowlist',
|
|
301
|
-
'path-boundary-denylist',
|
|
302
|
-
'no-path-traversal',
|
|
303
|
-
'no-absolute-paths',
|
|
304
|
-
'overwrite-policy-enforced'
|
|
305
|
-
],
|
|
306
|
-
postMaterializationValidation: [
|
|
307
|
-
'ultramodern-contract-check',
|
|
308
|
-
'agent-skill-postinstall-allowed',
|
|
309
|
-
'github-workflow-security-enforced',
|
|
310
|
-
'package-source-retained',
|
|
311
|
-
'pnpm-11-policy-enforced',
|
|
312
|
-
'rstest-smoke-tests',
|
|
313
|
-
'template-manifest-retained'
|
|
314
|
-
],
|
|
315
|
-
expectedCommands: [
|
|
316
|
-
'mise install',
|
|
317
|
-
'pnpm install',
|
|
318
|
-
'pnpm test',
|
|
319
|
-
'pnpm run ultramodern:check'
|
|
320
|
-
]
|
|
321
|
-
}
|
|
322
|
-
};
|
|
323
|
-
}
|
|
324
|
-
function assertTemplateManifest(condition, message) {
|
|
325
|
-
if (!condition) throw new Error(`Template manifest validation failed: ${message}`);
|
|
326
|
-
}
|
|
327
|
-
function assertSafeManifestPath(filePath, label) {
|
|
328
|
-
assertTemplateManifest(!isUnsafeRelativePath(filePath), `${label} is unsafe`);
|
|
329
|
-
}
|
|
330
|
-
function validateTemplateSource(source) {
|
|
331
|
-
const sourceType = source.type;
|
|
332
|
-
assertTemplateManifest('builtin' === sourceType || 'npm' === sourceType || 'git' === sourceType || 'local' === sourceType, `unsupported source type "${source.type}"`);
|
|
333
|
-
if ('builtin' === source.type) {
|
|
334
|
-
assertTemplateManifest(templateIdPattern.test(source.name), 'builtin source name must be a template id');
|
|
335
|
-
if (source.repositoryPath) assertSafeManifestPath(source.repositoryPath, 'builtin repositoryPath');
|
|
336
|
-
}
|
|
337
|
-
if ('npm' === source.type) {
|
|
338
|
-
assertTemplateManifest(packageNamePattern.test(source.packageName), 'npm packageName must be exact package metadata');
|
|
339
|
-
assertTemplateManifest(semverPattern.test(source.version), 'npm source version must be an exact semver');
|
|
340
|
-
assertTemplateManifest(sha256Pattern.test(source.tarballSha256), 'npm source tarballSha256 must be sha256 hex');
|
|
341
|
-
}
|
|
342
|
-
if ('git' === source.type) {
|
|
343
|
-
assertTemplateManifest(sha1Pattern.test(source.checkoutSha), 'git checkoutSha must pin a commit');
|
|
344
|
-
if ('sha' === source.ref.kind) assertTemplateManifest(sha1Pattern.test(source.ref.sha), 'git sha ref must be pinned to a commit');
|
|
345
|
-
else {
|
|
346
|
-
assertTemplateManifest(semverTagPattern.test(source.ref.tag), 'git tag ref must be a semver tag');
|
|
347
|
-
assertTemplateManifest(sha1Pattern.test(source.ref.tagSha), 'git tag ref must include the resolved tag sha');
|
|
348
|
-
}
|
|
349
|
-
if (source.subdirectory) assertSafeManifestPath(source.subdirectory, 'git subdirectory');
|
|
350
|
-
}
|
|
351
|
-
if ('local' === source.type) {
|
|
352
|
-
assertSafeManifestPath(source.path, 'local source path');
|
|
353
|
-
assertTemplateManifest(true !== source.allowOutsideWorkspace, 'local source cannot allow outside workspace materialization');
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
function validateTemplateManifest(manifest) {
|
|
357
|
-
assertTemplateManifest(1 === manifest.schemaVersion, 'schemaVersion must be 1');
|
|
358
|
-
assertTemplateManifest(templateIdPattern.test(manifest.template.id), 'template.id must be a template id');
|
|
359
|
-
assertTemplateManifest(semverPattern.test(manifest.template.version), 'template.version must be exact semver');
|
|
360
|
-
assertTemplateManifest('ultramodern-mv' === manifest.template.compatibilityLane || 'ultramodern-shell' === manifest.template.compatibilityLane || 'ultramodern-remote' === manifest.template.compatibilityLane, 'template.compatibilityLane is unsupported');
|
|
361
|
-
if (manifest.template.minimumModernVersion) assertTemplateManifest(semverPattern.test(manifest.template.minimumModernVersion), 'template.minimumModernVersion must be exact semver');
|
|
362
|
-
validateTemplateSource(manifest.source);
|
|
363
|
-
assertTemplateManifest(manifest.integrity.checksums.length > 0, 'integrity.checksums must not be empty');
|
|
364
|
-
for (const checksum of manifest.integrity.checksums){
|
|
365
|
-
assertTemplateManifest('sha256' === checksum.algorithm, 'checksum algorithm must be sha256');
|
|
366
|
-
assertTemplateManifest(sha256Pattern.test(checksum.value), 'checksum value must be sha256 hex');
|
|
367
|
-
assertTemplateManifest('manifest' === checksum.scope || 'source-archive' === checksum.scope || 'source-tree' === checksum.scope || 'lockfile' === checksum.scope, 'checksum scope is unsupported');
|
|
368
|
-
}
|
|
369
|
-
assertTemplateManifest(manifest.integrity.provenance.kind && manifest.integrity.provenance.issuer && manifest.integrity.provenance.subject, 'provenance kind, issuer, and subject are required');
|
|
370
|
-
if (manifest.integrity.lockfile) {
|
|
371
|
-
assertSafeManifestPath(manifest.integrity.lockfile.path, 'lockfile path');
|
|
372
|
-
assertTemplateManifest(sha256Pattern.test(manifest.integrity.lockfile.sha256), 'lockfile sha256 must be sha256 hex');
|
|
373
|
-
}
|
|
374
|
-
assertTemplateManifest('generated-project-root' === manifest.materialization.targetRoot || 'workspace-package-root' === manifest.materialization.targetRoot, 'materialization.targetRoot is unsupported');
|
|
375
|
-
assertTemplateManifest(manifest.materialization.allowedPaths.length > 0, 'materialization.allowedPaths must not be empty');
|
|
376
|
-
for (const allowedPath of manifest.materialization.allowedPaths)assertSafeManifestPath(allowedPath.replace(/\/\*\*$/, '/placeholder'), 'allowed path');
|
|
377
|
-
for (const deniedPath of manifest.materialization.deniedPaths)assertSafeManifestPath(deniedPath.replace(/\/\*\*$/, '/placeholder'), 'denied path');
|
|
378
|
-
for (const deniedPath of requiredDeniedPaths)assertTemplateManifest(manifest.materialization.deniedPaths.includes(deniedPath), `materialization.deniedPaths must include ${deniedPath}`);
|
|
379
|
-
assertTemplateManifest(!manifest.materialization.overwritePolicy || 'deny-existing' === manifest.materialization.overwritePolicy || 'allow-generated-only' === manifest.materialization.overwritePolicy, 'materialization.overwritePolicy is unsupported');
|
|
380
|
-
assertTemplateManifest(true === manifest.lifecyclePolicy.denyByDefault, 'lifecyclePolicy.denyByDefault must be true');
|
|
381
|
-
for (const scriptName of requiredLifecycleDeniedScripts)assertTemplateManifest(manifest.lifecyclePolicy.deniedScripts.includes(scriptName), `lifecyclePolicy.deniedScripts must include ${scriptName}`);
|
|
382
|
-
assertTemplateManifest(JSON.stringify(manifest.lifecyclePolicy.allowedScripts) === JSON.stringify(requiredLifecycleAllowedScripts), 'lifecyclePolicy.allowedScripts must only allow generated postinstall');
|
|
383
|
-
assertTemplateManifest(true === manifest.validation.schemaValidation, 'validation.schemaValidation must be true');
|
|
384
|
-
for (const token of [
|
|
385
|
-
'source-type-supported',
|
|
386
|
-
'checksum-verified',
|
|
387
|
-
'provenance-present'
|
|
388
|
-
])assertTemplateManifest(manifest.validation.sourceValidation.includes(token), `validation.sourceValidation must include ${token}`);
|
|
389
|
-
for (const token of [
|
|
390
|
-
'path-boundary-allowlist',
|
|
391
|
-
'path-boundary-denylist',
|
|
392
|
-
'no-path-traversal',
|
|
393
|
-
'no-absolute-paths',
|
|
394
|
-
'overwrite-policy-enforced'
|
|
395
|
-
])assertTemplateManifest(manifest.validation.materializationValidation.includes(token), `validation.materializationValidation must include ${token}`);
|
|
396
|
-
assertTemplateManifest(manifest.validation.postMaterializationValidation.includes('template-manifest-retained'), 'validation.postMaterializationValidation must retain manifest evidence');
|
|
397
|
-
}
|
|
398
|
-
function matchesManifestPattern(pattern, relativePath) {
|
|
399
|
-
if (pattern.endsWith('/**')) {
|
|
400
|
-
const prefix = pattern.slice(0, -3);
|
|
401
|
-
return relativePath === prefix || relativePath.startsWith(`${prefix}/`);
|
|
402
|
-
}
|
|
403
|
-
if (pattern.endsWith('.*')) {
|
|
404
|
-
const prefix = pattern.slice(0, -1);
|
|
405
|
-
return relativePath.startsWith(prefix);
|
|
406
|
-
}
|
|
407
|
-
return relativePath === pattern;
|
|
408
|
-
}
|
|
409
|
-
function canMaterializePath(manifest, relativePath) {
|
|
410
|
-
if (isUnsafeRelativePath(relativePath)) throw new Error(`Unsafe template path rejected: ${relativePath}`);
|
|
411
|
-
if (manifest.materialization.deniedPaths.some((pattern)=>matchesManifestPattern(pattern, relativePath))) return false;
|
|
412
|
-
if (!manifest.materialization.allowedPaths.some((pattern)=>matchesManifestPattern(pattern, relativePath))) throw new Error(`Template path is not allowed by manifest: ${relativePath}`);
|
|
413
|
-
return true;
|
|
414
|
-
}
|
|
415
|
-
function writeTemplateManifestEvidence(targetDir, manifest) {
|
|
416
|
-
const evidencePath = external_node_path_default().join(targetDir, '.modernjs', 'mv-template-manifest.json');
|
|
417
|
-
const evidenceRelativePath = normalizePathForManifest(external_node_path_default().relative(targetDir, evidencePath));
|
|
418
|
-
if (!canMaterializePath(manifest, evidenceRelativePath)) throw new Error('Template manifest evidence path is denied by manifest');
|
|
419
|
-
external_node_fs_default().mkdirSync(external_node_path_default().dirname(evidencePath), {
|
|
420
|
-
recursive: true
|
|
421
|
-
});
|
|
422
|
-
external_node_fs_default().writeFileSync(evidencePath, `${JSON.stringify(manifest, null, 2)}\n`);
|
|
423
|
-
}
|
|
424
68
|
function readCreatePackageJson() {
|
|
425
69
|
const createPackageJson = external_node_path_default().join(createPackageRoot, 'package.json');
|
|
426
70
|
return JSON.parse(external_node_fs_default().readFileSync(createPackageJson, 'utf-8'));
|
|
@@ -451,31 +95,19 @@ function showHelp() {
|
|
|
451
95
|
console.log(index_cjs_namespaceObject.i18n.t(index_cjs_namespaceObject.localeKeys.help.optionHelp));
|
|
452
96
|
console.log(index_cjs_namespaceObject.i18n.t(index_cjs_namespaceObject.localeKeys.help.optionVersion));
|
|
453
97
|
console.log(index_cjs_namespaceObject.i18n.t(index_cjs_namespaceObject.localeKeys.help.optionLang));
|
|
454
|
-
console.log(index_cjs_namespaceObject.i18n.t(index_cjs_namespaceObject.localeKeys.help.optionRouter));
|
|
455
|
-
if (index_cjs_namespaceObject.localeKeys.help.optionBff) console.log(index_cjs_namespaceObject.i18n.t(index_cjs_namespaceObject.localeKeys.help.optionBff));
|
|
456
|
-
if (index_cjs_namespaceObject.localeKeys.help.optionBffRuntime) console.log(index_cjs_namespaceObject.i18n.t(index_cjs_namespaceObject.localeKeys.help.optionBffRuntime));
|
|
457
98
|
if (index_cjs_namespaceObject.localeKeys.help.optionTailwind) console.log(index_cjs_namespaceObject.i18n.t(index_cjs_namespaceObject.localeKeys.help.optionTailwind));
|
|
458
|
-
if (index_cjs_namespaceObject.localeKeys.help.optionWorkspace) console.log(index_cjs_namespaceObject.i18n.t(index_cjs_namespaceObject.localeKeys.help.optionWorkspace));
|
|
459
|
-
if (index_cjs_namespaceObject.localeKeys.help.optionUltramodernWorkspace) console.log(index_cjs_namespaceObject.i18n.t(index_cjs_namespaceObject.localeKeys.help.optionUltramodernWorkspace));
|
|
460
99
|
if (index_cjs_namespaceObject.localeKeys.help.optionUltramodernPackageSource) console.log(index_cjs_namespaceObject.i18n.t(index_cjs_namespaceObject.localeKeys.help.optionUltramodernPackageSource));
|
|
461
100
|
if (index_cjs_namespaceObject.localeKeys.help.optionUltramodernPackageScope) console.log(index_cjs_namespaceObject.i18n.t(index_cjs_namespaceObject.localeKeys.help.optionUltramodernPackageScope));
|
|
462
101
|
if (index_cjs_namespaceObject.localeKeys.help.optionUltramodernPackageNamePrefix) console.log(index_cjs_namespaceObject.i18n.t(index_cjs_namespaceObject.localeKeys.help.optionUltramodernPackageNamePrefix));
|
|
463
102
|
if (index_cjs_namespaceObject.localeKeys.help.optionVertical) console.log(index_cjs_namespaceObject.i18n.t(index_cjs_namespaceObject.localeKeys.help.optionVertical));
|
|
464
103
|
if (index_cjs_namespaceObject.localeKeys.help.optionLegacyModernJs) console.log(index_cjs_namespaceObject.i18n.t(index_cjs_namespaceObject.localeKeys.help.optionLegacyModernJs));
|
|
465
|
-
console.log(index_cjs_namespaceObject.i18n.t(index_cjs_namespaceObject.localeKeys.help.optionSub));
|
|
466
104
|
console.log('');
|
|
467
105
|
console.log(index_cjs_namespaceObject.i18n.t(index_cjs_namespaceObject.localeKeys.help.examples));
|
|
468
106
|
console.log(index_cjs_namespaceObject.i18n.t(index_cjs_namespaceObject.localeKeys.help.example1));
|
|
469
107
|
console.log(index_cjs_namespaceObject.i18n.t(index_cjs_namespaceObject.localeKeys.help.example2));
|
|
470
|
-
console.log(index_cjs_namespaceObject.i18n.t(index_cjs_namespaceObject.localeKeys.help.example3));
|
|
471
108
|
if (index_cjs_namespaceObject.localeKeys.help.example4) console.log(index_cjs_namespaceObject.i18n.t(index_cjs_namespaceObject.localeKeys.help.example4));
|
|
472
109
|
if (index_cjs_namespaceObject.localeKeys.help.example5) console.log(index_cjs_namespaceObject.i18n.t(index_cjs_namespaceObject.localeKeys.help.example5));
|
|
473
110
|
if (index_cjs_namespaceObject.localeKeys.help.example6) console.log(index_cjs_namespaceObject.i18n.t(index_cjs_namespaceObject.localeKeys.help.example6));
|
|
474
|
-
if (index_cjs_namespaceObject.localeKeys.help.example7) console.log(index_cjs_namespaceObject.i18n.t(index_cjs_namespaceObject.localeKeys.help.example7));
|
|
475
|
-
if (index_cjs_namespaceObject.localeKeys.help.example8) console.log(index_cjs_namespaceObject.i18n.t(index_cjs_namespaceObject.localeKeys.help.example8));
|
|
476
|
-
if (index_cjs_namespaceObject.localeKeys.help.example9) console.log(index_cjs_namespaceObject.i18n.t(index_cjs_namespaceObject.localeKeys.help.example9));
|
|
477
|
-
if (index_cjs_namespaceObject.localeKeys.help.example10) console.log(index_cjs_namespaceObject.i18n.t(index_cjs_namespaceObject.localeKeys.help.example10));
|
|
478
|
-
if (index_cjs_namespaceObject.localeKeys.help.example11) console.log(index_cjs_namespaceObject.i18n.t(index_cjs_namespaceObject.localeKeys.help.example11));
|
|
479
111
|
if (index_cjs_namespaceObject.localeKeys.help.example12) console.log(index_cjs_namespaceObject.i18n.t(index_cjs_namespaceObject.localeKeys.help.example12));
|
|
480
112
|
console.log('');
|
|
481
113
|
console.log(index_cjs_namespaceObject.i18n.t(index_cjs_namespaceObject.localeKeys.help.moreInfo));
|
|
@@ -533,12 +165,6 @@ function delegateLegacyModernJsSetup(args) {
|
|
|
533
165
|
});
|
|
534
166
|
throw new Error('Legacy Modern.js setup requires pnpm or npx to run @modern-js/create.');
|
|
535
167
|
}
|
|
536
|
-
function detectSubprojectFlag() {
|
|
537
|
-
const args = process.argv.slice(2);
|
|
538
|
-
if (args.includes('--sub') || args.includes('-s')) return true;
|
|
539
|
-
if (args.includes('--no-sub')) return false;
|
|
540
|
-
return null;
|
|
541
|
-
}
|
|
542
168
|
function detectTailwindFlag() {
|
|
543
169
|
const args = process.argv.slice(2);
|
|
544
170
|
return !args.includes('--no-tailwind');
|
|
@@ -548,10 +174,6 @@ function detectExplicitTailwindFlag() {
|
|
|
548
174
|
if (args.includes('--no-tailwind')) return false;
|
|
549
175
|
if (args.includes('--tailwind')) return true;
|
|
550
176
|
}
|
|
551
|
-
function detectWorkspaceProtocolFlag() {
|
|
552
|
-
const args = process.argv.slice(2);
|
|
553
|
-
return args.includes('--workspace');
|
|
554
|
-
}
|
|
555
177
|
function detectVerticalFlag() {
|
|
556
178
|
const args = process.argv.slice(2);
|
|
557
179
|
if (args.some((arg)=>arg.startsWith('--vertical='))) {
|
|
@@ -560,10 +182,6 @@ function detectVerticalFlag() {
|
|
|
560
182
|
}
|
|
561
183
|
return args.includes('--vertical');
|
|
562
184
|
}
|
|
563
|
-
function detectUltramodernWorkspaceFlag() {
|
|
564
|
-
const args = process.argv.slice(2);
|
|
565
|
-
return args.includes(external_ultramodern_workspace_cjs_namespaceObject.ULTRAMODERN_WORKSPACE_FLAG);
|
|
566
|
-
}
|
|
567
185
|
function detectUltramodernPackageSource(args, defaultPackageVersion, createPackage) {
|
|
568
186
|
const bleedingDevDefaults = isBleedingDevCreatePackage(createPackage);
|
|
569
187
|
const strategy = getOptionValue(args, [
|
|
@@ -644,14 +262,6 @@ function resolveInstallBackedPackageSource(args, createPackage, packageSource) {
|
|
|
644
262
|
]) ?? packageSource.aliasPackageNamePrefix ?? (aliasScope ? external_ultramodern_package_source_cjs_namespaceObject.BLEEDINGDEV_PACKAGE_NAME_PREFIX : void 0)
|
|
645
263
|
};
|
|
646
264
|
}
|
|
647
|
-
function resolveSingleAppPackageSource(args, createPackage, packageSource, useWorkspaceProtocol) {
|
|
648
|
-
if (useWorkspaceProtocol) return {
|
|
649
|
-
...packageSource,
|
|
650
|
-
strategy: 'workspace',
|
|
651
|
-
modernPackageVersion: external_ultramodern_package_source_cjs_namespaceObject.WORKSPACE_PACKAGE_VERSION
|
|
652
|
-
};
|
|
653
|
-
return resolveInstallBackedPackageSource(args, createPackage, packageSource);
|
|
654
|
-
}
|
|
655
265
|
function resolveWorkspacePackageSource(args, createPackage, packageSource) {
|
|
656
266
|
if (hasExplicitUltramodernPackageSource(args, 'workspace')) return {
|
|
657
267
|
...packageSource,
|
|
@@ -660,23 +270,6 @@ function resolveWorkspacePackageSource(args, createPackage, packageSource) {
|
|
|
660
270
|
};
|
|
661
271
|
return resolveInstallBackedPackageSource(args, createPackage, packageSource);
|
|
662
272
|
}
|
|
663
|
-
function createSingleAppPackageSourceEvidence(packageSource) {
|
|
664
|
-
return {
|
|
665
|
-
schemaVersion: 1,
|
|
666
|
-
preset: 'presetUltramodern',
|
|
667
|
-
strategy: packageSource.strategy,
|
|
668
|
-
modernPackages: (0, external_ultramodern_package_source_cjs_namespaceObject.createModernPackagesMetadata)(external_ultramodern_package_source_cjs_namespaceObject.ULTRAMODERN_SINGLE_APP_MODERN_PACKAGES, packageSource, {
|
|
669
|
-
includeAliases: 'install' === packageSource.strategy
|
|
670
|
-
})
|
|
671
|
-
};
|
|
672
|
-
}
|
|
673
|
-
function writeSingleAppPackageSourceEvidence(targetDir, packageSource) {
|
|
674
|
-
const evidencePath = external_node_path_default().join(targetDir, '.modernjs', 'ultramodern-package-source.json');
|
|
675
|
-
external_node_fs_default().mkdirSync(external_node_path_default().dirname(evidencePath), {
|
|
676
|
-
recursive: true
|
|
677
|
-
});
|
|
678
|
-
external_node_fs_default().writeFileSync(evidencePath, `${JSON.stringify(createSingleAppPackageSourceEvidence(packageSource), null, 2)}\n`);
|
|
679
|
-
}
|
|
680
273
|
function runSetupCommand(command, args, options = {}) {
|
|
681
274
|
return (0, external_node_child_process_namespaceObject.execFileSync)(command, args, {
|
|
682
275
|
cwd: options.cwd,
|
|
@@ -776,9 +369,6 @@ async function getProjectName() {
|
|
|
776
369
|
const optionWithValue = new Set([
|
|
777
370
|
'--lang',
|
|
778
371
|
'-l',
|
|
779
|
-
'--router',
|
|
780
|
-
'-r',
|
|
781
|
-
'--bff-runtime',
|
|
782
372
|
'--ultramodern-package-source',
|
|
783
373
|
'--ultramodern-package-version',
|
|
784
374
|
'--ultramodern-package-registry',
|
|
@@ -790,17 +380,11 @@ async function getProjectName() {
|
|
|
790
380
|
'-h',
|
|
791
381
|
'--version',
|
|
792
382
|
'-v',
|
|
793
|
-
'--sub',
|
|
794
|
-
'-s',
|
|
795
|
-
'--no-sub',
|
|
796
|
-
'--tanstack',
|
|
797
|
-
'--bff',
|
|
798
383
|
'--tailwind',
|
|
799
384
|
'--no-tailwind',
|
|
800
385
|
'--workspace',
|
|
801
386
|
'--vertical',
|
|
802
|
-
LEGACY_MODERN_JS_FLAG
|
|
803
|
-
external_ultramodern_workspace_cjs_namespaceObject.ULTRAMODERN_WORKSPACE_FLAG
|
|
387
|
+
LEGACY_MODERN_JS_FLAG
|
|
804
388
|
]);
|
|
805
389
|
const positionalArgs = [];
|
|
806
390
|
for(let i = 0; i < args.length; i++){
|
|
@@ -810,7 +394,7 @@ async function getProjectName() {
|
|
|
810
394
|
i += 1;
|
|
811
395
|
continue;
|
|
812
396
|
}
|
|
813
|
-
if (!(arg.startsWith('--lang=') || arg.startsWith('--
|
|
397
|
+
if (!(arg.startsWith('--lang=') || arg.startsWith('--ultramodern-package-source=') || arg.startsWith('--ultramodern-package-version=') || arg.startsWith('--ultramodern-package-registry=') || arg.startsWith('--ultramodern-package-scope=') || arg.startsWith('--ultramodern-package-name-prefix='))) positionalArgs.push(arg);
|
|
814
398
|
}
|
|
815
399
|
}
|
|
816
400
|
if (positionalArgs.length > 1) {
|
|
@@ -872,7 +456,7 @@ async function main() {
|
|
|
872
456
|
const dim = '\x1b[2m\x1b[3m';
|
|
873
457
|
const reset = '\x1b[0m';
|
|
874
458
|
console.log(`${index_cjs_namespaceObject.i18n.t(index_cjs_namespaceObject.localeKeys.message.success)}\n`);
|
|
875
|
-
console.log(`${dim} pnpm
|
|
459
|
+
console.log(`${dim} pnpm check${reset}\n`);
|
|
876
460
|
return;
|
|
877
461
|
}
|
|
878
462
|
if (external_node_fs_default().existsSync(targetDir)) {
|
|
@@ -884,111 +468,15 @@ async function main() {
|
|
|
884
468
|
process.exit(1);
|
|
885
469
|
}
|
|
886
470
|
}
|
|
887
|
-
const
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
(0, external_ultramodern_workspace_cjs_namespaceObject.generateUltramodernWorkspace)({
|
|
891
|
-
targetDir,
|
|
892
|
-
packageName: generatedPackageName,
|
|
893
|
-
modernVersion: version,
|
|
894
|
-
enableTailwind: detectTailwindFlag(),
|
|
895
|
-
packageSource
|
|
896
|
-
});
|
|
897
|
-
initializeGeneratedGitRepository(targetDir);
|
|
898
|
-
const dim = '\x1b[2m\x1b[3m';
|
|
899
|
-
const reset = '\x1b[0m';
|
|
900
|
-
console.log(`${index_cjs_namespaceObject.i18n.t(index_cjs_namespaceObject.localeKeys.message.success)}\n`);
|
|
901
|
-
console.log(index_cjs_namespaceObject.i18n.t(index_cjs_namespaceObject.localeKeys.message.nextSteps));
|
|
902
|
-
if (!useCurrentDir) console.log(`${dim} ${index_cjs_namespaceObject.i18n.t(index_cjs_namespaceObject.localeKeys.message.step1, {
|
|
903
|
-
projectName
|
|
904
|
-
})}${reset}`);
|
|
905
|
-
console.log(`${dim} ${index_cjs_namespaceObject.i18n.t(index_cjs_namespaceObject.localeKeys.message.step2)}${reset}`);
|
|
906
|
-
console.log(`${dim} pnpm ultramodern:check${reset}`);
|
|
907
|
-
console.log(`${dim} ${index_cjs_namespaceObject.i18n.t(index_cjs_namespaceObject.localeKeys.message.step3)}${reset}\n`);
|
|
908
|
-
return;
|
|
909
|
-
}
|
|
910
|
-
const subprojectFlag = detectSubprojectFlag();
|
|
911
|
-
const isSubproject = true === subprojectFlag;
|
|
912
|
-
const routerFramework = detectRouterFramework();
|
|
913
|
-
const bffRuntime = detectBffRuntime();
|
|
914
|
-
const enableTailwind = detectTailwindFlag();
|
|
915
|
-
const useWorkspaceProtocol = detectWorkspaceProtocolFlag();
|
|
916
|
-
const packageSource = resolveSingleAppPackageSource(args, createPackage, detectUltramodernPackageSource(args, ultramodernPackageVersion, createPackage), useWorkspaceProtocol);
|
|
917
|
-
const templateManifest = createBuiltinTemplateManifest('install' === packageSource.strategy ? packageSource.modernPackageVersion : version);
|
|
918
|
-
validateTemplateManifest(templateManifest);
|
|
919
|
-
copyTemplate(templateDir, targetDir, {
|
|
471
|
+
const packageSource = resolveWorkspacePackageSource(args, createPackage, detectUltramodernPackageSource(args, ultramodernPackageVersion, createPackage));
|
|
472
|
+
(0, external_ultramodern_workspace_cjs_namespaceObject.generateUltramodernWorkspace)({
|
|
473
|
+
targetDir,
|
|
920
474
|
packageName: generatedPackageName,
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
adapterRstestVersion: (0, external_ultramodern_package_source_cjs_namespaceObject.modernPackageSpecifier)('@modern-js/adapter-rstest', packageSource),
|
|
925
|
-
codeToolsVersion: (0, external_ultramodern_package_source_cjs_namespaceObject.modernPackageSpecifier)('@modern-js/code-tools', packageSource),
|
|
926
|
-
createVersion: (0, external_ultramodern_package_source_cjs_namespaceObject.modernPackageSpecifier)('@modern-js/create', packageSource),
|
|
927
|
-
tsconfigVersion: (0, external_ultramodern_package_source_cjs_namespaceObject.modernPackageSpecifier)('@modern-js/tsconfig', packageSource),
|
|
928
|
-
pluginTanstackVersion: (0, external_ultramodern_package_source_cjs_namespaceObject.modernPackageSpecifier)('@modern-js/plugin-tanstack', packageSource),
|
|
929
|
-
pluginBffVersion: (0, external_ultramodern_package_source_cjs_namespaceObject.modernPackageSpecifier)('@modern-js/plugin-bff', packageSource),
|
|
930
|
-
pluginI18nVersion: (0, external_ultramodern_package_source_cjs_namespaceObject.modernPackageSpecifier)('@modern-js/plugin-i18n', packageSource),
|
|
931
|
-
tanstackRouterVersion: TANSTACK_ROUTER_VERSION,
|
|
932
|
-
i18nextVersion: I18NEXT_VERSION,
|
|
933
|
-
reactVersion: REACT_VERSION,
|
|
934
|
-
reactDomVersion: REACT_DOM_VERSION,
|
|
935
|
-
reactI18nextVersion: REACT_I18NEXT_VERSION,
|
|
936
|
-
effectTsgoVersion: EFFECT_TSGO_VERSION,
|
|
937
|
-
typescriptNativePreviewVersion: TYPESCRIPT_NATIVE_PREVIEW_VERSION,
|
|
938
|
-
rstestCoreVersion: RSTEST_CORE_VERSION,
|
|
939
|
-
happyDomVersion: HAPPY_DOM_VERSION,
|
|
940
|
-
oxfmtVersion: OXFMT_VERSION,
|
|
941
|
-
oxlintVersion: OXLINT_VERSION,
|
|
942
|
-
postcssVersion: POSTCSS_VERSION,
|
|
943
|
-
ultraciteVersion: ULTRACITE_VERSION,
|
|
944
|
-
typesReactVersion: TYPES_REACT_VERSION,
|
|
945
|
-
typesReactDomVersion: TYPES_REACT_DOM_VERSION,
|
|
946
|
-
tailwindVersion: TAILWIND_VERSION,
|
|
947
|
-
tailwindPostcssVersion: TAILWIND_POSTCSS_VERSION,
|
|
948
|
-
pnpmVersion: PNPM_VERSION,
|
|
949
|
-
isSubproject,
|
|
950
|
-
routerFramework,
|
|
951
|
-
bffRuntime,
|
|
952
|
-
enableTailwind,
|
|
953
|
-
templateManifest
|
|
475
|
+
modernVersion: version,
|
|
476
|
+
enableTailwind: detectTailwindFlag(),
|
|
477
|
+
packageSource
|
|
954
478
|
});
|
|
955
|
-
|
|
956
|
-
const packageJson = JSON.parse(external_node_fs_default().readFileSync(targetPackageJson, 'utf-8'));
|
|
957
|
-
packageJson.name = generatedPackageName;
|
|
958
|
-
packageJson.modernjs = {
|
|
959
|
-
...packageJson.modernjs ?? {},
|
|
960
|
-
preset: 'presetUltramodern',
|
|
961
|
-
packageSource: {
|
|
962
|
-
strategy: packageSource.strategy,
|
|
963
|
-
config: './.modernjs/ultramodern-package-source.json'
|
|
964
|
-
}
|
|
965
|
-
};
|
|
966
|
-
if (isSubproject) {
|
|
967
|
-
delete packageJson['lint-staged'];
|
|
968
|
-
delete packageJson['simple-git-hooks'];
|
|
969
|
-
if (packageJson.scripts) {
|
|
970
|
-
delete packageJson.scripts.prepare;
|
|
971
|
-
delete packageJson.scripts['skills:install'];
|
|
972
|
-
delete packageJson.scripts['skills:check'];
|
|
973
|
-
delete packageJson.scripts.postinstall;
|
|
974
|
-
}
|
|
975
|
-
if (packageJson.devDependencies) {
|
|
976
|
-
delete packageJson.devDependencies['lint-staged'];
|
|
977
|
-
delete packageJson.devDependencies.lefthook;
|
|
978
|
-
delete packageJson.devDependencies['simple-git-hooks'];
|
|
979
|
-
}
|
|
980
|
-
external_node_fs_default().rmSync(external_node_path_default().join(targetDir, '.codex'), {
|
|
981
|
-
recursive: true,
|
|
982
|
-
force: true
|
|
983
|
-
});
|
|
984
|
-
external_node_fs_default().rmSync(external_node_path_default().join(targetDir, 'lefthook.yml'), {
|
|
985
|
-
force: true
|
|
986
|
-
});
|
|
987
|
-
}
|
|
988
|
-
external_node_fs_default().writeFileSync(targetPackageJson, `${JSON.stringify(packageJson, null, 2)}\n`);
|
|
989
|
-
writeTemplateManifestEvidence(targetDir, templateManifest);
|
|
990
|
-
writeSingleAppPackageSourceEvidence(targetDir, packageSource);
|
|
991
|
-
if (!isSubproject) initializeGeneratedGitRepository(targetDir);
|
|
479
|
+
initializeGeneratedGitRepository(targetDir);
|
|
992
480
|
const dim = '\x1b[2m\x1b[3m';
|
|
993
481
|
const reset = '\x1b[0m';
|
|
994
482
|
console.log(`${index_cjs_namespaceObject.i18n.t(index_cjs_namespaceObject.localeKeys.message.success)}\n`);
|
|
@@ -997,88 +485,9 @@ async function main() {
|
|
|
997
485
|
projectName
|
|
998
486
|
})}${reset}`);
|
|
999
487
|
console.log(`${dim} ${index_cjs_namespaceObject.i18n.t(index_cjs_namespaceObject.localeKeys.message.step2)}${reset}`);
|
|
488
|
+
console.log(`${dim} pnpm check${reset}`);
|
|
1000
489
|
console.log(`${dim} ${index_cjs_namespaceObject.i18n.t(index_cjs_namespaceObject.localeKeys.message.step3)}${reset}\n`);
|
|
1001
490
|
}
|
|
1002
|
-
function copyTemplate(src, dest, options) {
|
|
1003
|
-
external_node_fs_default().mkdirSync(dest, {
|
|
1004
|
-
recursive: true
|
|
1005
|
-
});
|
|
1006
|
-
const excludeInSubproject = [
|
|
1007
|
-
'.agents',
|
|
1008
|
-
'.github',
|
|
1009
|
-
'.gitignore.handlebars',
|
|
1010
|
-
'AGENTS.md',
|
|
1011
|
-
'.npmrc',
|
|
1012
|
-
'.nvmrc'
|
|
1013
|
-
];
|
|
1014
|
-
function copyRecursive(srcDir, destDir) {
|
|
1015
|
-
const entries = external_node_fs_default().readdirSync(srcDir, {
|
|
1016
|
-
withFileTypes: true
|
|
1017
|
-
});
|
|
1018
|
-
for (const entry of entries){
|
|
1019
|
-
if (options.isSubproject && excludeInSubproject.includes(entry.name)) continue;
|
|
1020
|
-
const srcPath = external_node_path_default().join(srcDir, entry.name);
|
|
1021
|
-
let destPath = external_node_path_default().join(destDir, entry.name);
|
|
1022
|
-
const sourceRelativePath = normalizePathForManifest(external_node_path_default().relative(src, srcPath));
|
|
1023
|
-
const finalRelativePath = normalizePathForManifest(sourceRelativePath.replace(/\.handlebars$/, ''));
|
|
1024
|
-
if (!(!canMaterializePath(options.templateManifest, finalRelativePath) || entry.isDirectory() && options.templateManifest.materialization.deniedPaths.some((pattern)=>matchesManifestPattern(pattern, finalRelativePath)))) if (entry.isDirectory()) {
|
|
1025
|
-
external_node_fs_default().mkdirSync(destPath, {
|
|
1026
|
-
recursive: true
|
|
1027
|
-
});
|
|
1028
|
-
copyRecursive(srcPath, destPath);
|
|
1029
|
-
} else if (entry.name.endsWith('.handlebars')) {
|
|
1030
|
-
const templateContent = external_node_fs_default().readFileSync(srcPath, 'utf-8');
|
|
1031
|
-
const rendered = renderTemplate(templateContent, {
|
|
1032
|
-
packageName: options.packageName,
|
|
1033
|
-
version: options.version,
|
|
1034
|
-
runtimeVersion: options.runtimeVersion,
|
|
1035
|
-
appToolsVersion: options.appToolsVersion,
|
|
1036
|
-
adapterRstestVersion: options.adapterRstestVersion,
|
|
1037
|
-
codeToolsVersion: options.codeToolsVersion,
|
|
1038
|
-
createVersion: options.createVersion,
|
|
1039
|
-
tsconfigVersion: options.tsconfigVersion,
|
|
1040
|
-
pluginTanstackVersion: options.pluginTanstackVersion,
|
|
1041
|
-
pluginBffVersion: options.pluginBffVersion,
|
|
1042
|
-
pluginI18nVersion: options.pluginI18nVersion,
|
|
1043
|
-
tanstackRouterVersion: options.tanstackRouterVersion,
|
|
1044
|
-
i18nextVersion: options.i18nextVersion,
|
|
1045
|
-
reactVersion: options.reactVersion,
|
|
1046
|
-
reactDomVersion: options.reactDomVersion,
|
|
1047
|
-
reactI18nextVersion: options.reactI18nextVersion,
|
|
1048
|
-
effectTsgoVersion: options.effectTsgoVersion,
|
|
1049
|
-
typescriptNativePreviewVersion: options.typescriptNativePreviewVersion,
|
|
1050
|
-
rstestCoreVersion: options.rstestCoreVersion,
|
|
1051
|
-
happyDomVersion: options.happyDomVersion,
|
|
1052
|
-
oxfmtVersion: options.oxfmtVersion,
|
|
1053
|
-
oxlintVersion: options.oxlintVersion,
|
|
1054
|
-
postcssVersion: options.postcssVersion,
|
|
1055
|
-
ultraciteVersion: options.ultraciteVersion,
|
|
1056
|
-
typesReactVersion: options.typesReactVersion,
|
|
1057
|
-
typesReactDomVersion: options.typesReactDomVersion,
|
|
1058
|
-
tailwindVersion: options.tailwindVersion,
|
|
1059
|
-
tailwindPostcssVersion: options.tailwindPostcssVersion,
|
|
1060
|
-
pnpmVersion: options.pnpmVersion,
|
|
1061
|
-
isSubproject: options.isSubproject,
|
|
1062
|
-
isTanstackRouter: 'tanstack' === options.routerFramework,
|
|
1063
|
-
enableBff: 'none' !== options.bffRuntime,
|
|
1064
|
-
useEffectBff: 'effect' === options.bffRuntime,
|
|
1065
|
-
useHonoBff: 'hono' === options.bffRuntime,
|
|
1066
|
-
bffRuntime: options.bffRuntime,
|
|
1067
|
-
enableTailwind: options.enableTailwind,
|
|
1068
|
-
routerRuntimeImport: 'tanstack' === options.routerFramework ? '@modern-js/plugin-tanstack/runtime' : '@modern-js/runtime/router'
|
|
1069
|
-
});
|
|
1070
|
-
if (0 === rendered.trim().length) continue;
|
|
1071
|
-
destPath = destPath.replace(/\.handlebars$/, '');
|
|
1072
|
-
if ('deny-existing' === options.templateManifest.materialization.overwritePolicy && external_node_fs_default().existsSync(destPath)) throw new Error(`Template refused to overwrite existing file: ${finalRelativePath}`);
|
|
1073
|
-
external_node_fs_default().writeFileSync(destPath, rendered, 'utf-8');
|
|
1074
|
-
} else {
|
|
1075
|
-
if ('deny-existing' === options.templateManifest.materialization.overwritePolicy && external_node_fs_default().existsSync(destPath)) throw new Error(`Template refused to overwrite existing file: ${finalRelativePath}`);
|
|
1076
|
-
external_node_fs_default().copyFileSync(srcPath, destPath);
|
|
1077
|
-
}
|
|
1078
|
-
}
|
|
1079
|
-
}
|
|
1080
|
-
copyRecursive(src, dest);
|
|
1081
|
-
}
|
|
1082
491
|
main().catch((error)=>{
|
|
1083
492
|
console.error(index_cjs_namespaceObject.i18n.t(index_cjs_namespaceObject.localeKeys.error.createFailed), error);
|
|
1084
493
|
process.exit(1);
|