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