@bleedingdev/modern-js-create 3.2.0-ultramodern.112 → 3.2.0-ultramodern.115
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/dist/cjs/create-package-root.cjs +65 -0
- package/dist/cjs/index.cjs +52 -2
- package/dist/cjs/locale/en.cjs +6 -2
- package/dist/cjs/locale/zh.cjs +6 -2
- package/dist/cjs/ultramodern-workspace.cjs +3 -1
- package/dist/esm/create-package-root.js +16 -0
- package/dist/esm/index.js +52 -2
- package/dist/esm/locale/en.js +6 -2
- package/dist/esm/locale/zh.js +6 -2
- package/dist/esm/ultramodern-workspace.js +3 -1
- package/dist/esm-node/create-package-root.js +17 -0
- package/dist/esm-node/index.js +52 -2
- package/dist/esm-node/locale/en.js +6 -2
- package/dist/esm-node/locale/zh.js +6 -2
- package/dist/esm-node/ultramodern-workspace.js +3 -1
- package/dist/types/create-package-root.d.ts +1 -0
- package/dist/types/locale/en.d.ts +4 -0
- package/dist/types/locale/index.d.ts +8 -0
- package/dist/types/locale/zh.d.ts +4 -0
- package/package.json +5 -3
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.n = (module)=>{
|
|
5
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
+
__webpack_require__.d(getter, {
|
|
7
|
+
a: getter
|
|
8
|
+
});
|
|
9
|
+
return getter;
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
14
|
+
var define = (defs, kind)=>{
|
|
15
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
[kind]: defs[key]
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
define(getters, "get");
|
|
21
|
+
define(values, "value");
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
(()=>{
|
|
25
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
26
|
+
})();
|
|
27
|
+
(()=>{
|
|
28
|
+
__webpack_require__.r = (exports1)=>{
|
|
29
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
30
|
+
value: 'Module'
|
|
31
|
+
});
|
|
32
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
33
|
+
value: true
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
})();
|
|
37
|
+
var __webpack_exports__ = {};
|
|
38
|
+
__webpack_require__.r(__webpack_exports__);
|
|
39
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
40
|
+
resolveCreatePackageRoot: ()=>resolveCreatePackageRoot
|
|
41
|
+
});
|
|
42
|
+
const external_node_fs_namespaceObject = require("node:fs");
|
|
43
|
+
var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
|
|
44
|
+
const external_node_path_namespaceObject = require("node:path");
|
|
45
|
+
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
46
|
+
function resolveCreatePackageRoot(fromDir) {
|
|
47
|
+
const candidates = [
|
|
48
|
+
fromDir,
|
|
49
|
+
external_node_path_default().resolve(fromDir, '..'),
|
|
50
|
+
external_node_path_default().resolve(fromDir, '..', '..')
|
|
51
|
+
];
|
|
52
|
+
const seen = new Set();
|
|
53
|
+
for (const candidate of candidates)if (!seen.has(candidate)) {
|
|
54
|
+
seen.add(candidate);
|
|
55
|
+
if (external_node_fs_default().existsSync(external_node_path_default().join(candidate, 'package.json')) && external_node_fs_default().existsSync(external_node_path_default().join(candidate, 'template'))) return candidate;
|
|
56
|
+
}
|
|
57
|
+
throw new Error('Unable to resolve create package root');
|
|
58
|
+
}
|
|
59
|
+
exports.resolveCreatePackageRoot = __webpack_exports__.resolveCreatePackageRoot;
|
|
60
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
61
|
+
"resolveCreatePackageRoot"
|
|
62
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
63
|
+
Object.defineProperty(exports, '__esModule', {
|
|
64
|
+
value: true
|
|
65
|
+
});
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -39,11 +39,13 @@ const external_node_readline_namespaceObject = require("node:readline");
|
|
|
39
39
|
var external_node_readline_default = /*#__PURE__*/ __webpack_require__.n(external_node_readline_namespaceObject);
|
|
40
40
|
const external_node_url_namespaceObject = require("node:url");
|
|
41
41
|
const language_detector_namespaceObject = require("@modern-js/i18n-utils/language-detector");
|
|
42
|
+
const external_create_package_root_cjs_namespaceObject = require("./create-package-root.cjs");
|
|
42
43
|
const index_cjs_namespaceObject = require("./locale/index.cjs");
|
|
43
44
|
const external_ultramodern_package_source_cjs_namespaceObject = require("./ultramodern-package-source.cjs");
|
|
44
45
|
const external_ultramodern_workspace_cjs_namespaceObject = require("./ultramodern-workspace.cjs");
|
|
45
46
|
const src_dirname = external_node_path_default().dirname((0, external_node_url_namespaceObject.fileURLToPath)(__rslib_import_meta_url__));
|
|
46
|
-
const
|
|
47
|
+
const createPackageRoot = (0, external_create_package_root_cjs_namespaceObject.resolveCreatePackageRoot)(src_dirname);
|
|
48
|
+
const templateDir = external_node_path_default().join(createPackageRoot, 'template');
|
|
47
49
|
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.-]+)?$/;
|
|
48
50
|
const semverTagPattern = /^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(?:-[0-9A-Za-z.-]+)?$/;
|
|
49
51
|
const sha1Pattern = /^[0-9a-f]{40}$/;
|
|
@@ -85,6 +87,8 @@ const requiredLifecycleDeniedScripts = [
|
|
|
85
87
|
const requiredLifecycleAllowedScripts = [
|
|
86
88
|
'postinstall'
|
|
87
89
|
];
|
|
90
|
+
const LEGACY_MODERN_JS_FLAG = '--legacy-modern-js';
|
|
91
|
+
const LEGACY_MODERN_JS_CONFIRMATION = 'USE LEGACY MODERN.JS';
|
|
88
92
|
function getOptionValue(args, names) {
|
|
89
93
|
for (const name of names){
|
|
90
94
|
const prefix = `${name}=`;
|
|
@@ -421,7 +425,7 @@ function writeTemplateManifestEvidence(targetDir, manifest) {
|
|
|
421
425
|
external_node_fs_default().writeFileSync(evidencePath, `${JSON.stringify(manifest, null, 2)}\n`);
|
|
422
426
|
}
|
|
423
427
|
function readCreatePackageJson() {
|
|
424
|
-
const createPackageJson = external_node_path_default().
|
|
428
|
+
const createPackageJson = external_node_path_default().join(createPackageRoot, 'package.json');
|
|
425
429
|
return JSON.parse(external_node_fs_default().readFileSync(createPackageJson, 'utf-8'));
|
|
426
430
|
}
|
|
427
431
|
function isBleedingDevCreatePackage(createPackage) {
|
|
@@ -460,6 +464,7 @@ function showHelp() {
|
|
|
460
464
|
if (index_cjs_namespaceObject.localeKeys.help.optionUltramodernPackageScope) console.log(index_cjs_namespaceObject.i18n.t(index_cjs_namespaceObject.localeKeys.help.optionUltramodernPackageScope));
|
|
461
465
|
if (index_cjs_namespaceObject.localeKeys.help.optionUltramodernPackageNamePrefix) console.log(index_cjs_namespaceObject.i18n.t(index_cjs_namespaceObject.localeKeys.help.optionUltramodernPackageNamePrefix));
|
|
462
466
|
if (index_cjs_namespaceObject.localeKeys.help.optionVertical) console.log(index_cjs_namespaceObject.i18n.t(index_cjs_namespaceObject.localeKeys.help.optionVertical));
|
|
467
|
+
if (index_cjs_namespaceObject.localeKeys.help.optionLegacyModernJs) console.log(index_cjs_namespaceObject.i18n.t(index_cjs_namespaceObject.localeKeys.help.optionLegacyModernJs));
|
|
463
468
|
console.log(index_cjs_namespaceObject.i18n.t(index_cjs_namespaceObject.localeKeys.help.optionSub));
|
|
464
469
|
console.log('');
|
|
465
470
|
console.log(index_cjs_namespaceObject.i18n.t(index_cjs_namespaceObject.localeKeys.help.examples));
|
|
@@ -492,6 +497,45 @@ function promptInput(question) {
|
|
|
492
497
|
});
|
|
493
498
|
});
|
|
494
499
|
}
|
|
500
|
+
function detectLegacyModernJsFlag(args) {
|
|
501
|
+
if (args.some((arg)=>arg.startsWith(`${LEGACY_MODERN_JS_FLAG}=`))) {
|
|
502
|
+
console.error(`${LEGACY_MODERN_JS_FLAG} does not accept a value.`);
|
|
503
|
+
process.exit(1);
|
|
504
|
+
}
|
|
505
|
+
return args.includes(LEGACY_MODERN_JS_FLAG);
|
|
506
|
+
}
|
|
507
|
+
function stripLegacyModernJsArgs(args) {
|
|
508
|
+
return args.filter((arg)=>arg !== LEGACY_MODERN_JS_FLAG);
|
|
509
|
+
}
|
|
510
|
+
async function confirmLegacyModernJsSetup() {
|
|
511
|
+
console.error('');
|
|
512
|
+
console.error(index_cjs_namespaceObject.i18n.t(index_cjs_namespaceObject.localeKeys.message.legacyModernJsWarning));
|
|
513
|
+
console.error('');
|
|
514
|
+
const answer = await promptInput(index_cjs_namespaceObject.i18n.t(index_cjs_namespaceObject.localeKeys.prompt.legacyModernJsConfirmation, {
|
|
515
|
+
confirmation: LEGACY_MODERN_JS_CONFIRMATION
|
|
516
|
+
}));
|
|
517
|
+
if (answer !== LEGACY_MODERN_JS_CONFIRMATION) {
|
|
518
|
+
console.error(index_cjs_namespaceObject.i18n.t(index_cjs_namespaceObject.localeKeys.error.legacyModernJsNotConfirmed));
|
|
519
|
+
process.exit(1);
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
function delegateLegacyModernJsSetup(args) {
|
|
523
|
+
const forwardedArgs = stripLegacyModernJsArgs(args);
|
|
524
|
+
if (commandExists('pnpm')) return void runSetupCommand('pnpm', [
|
|
525
|
+
'dlx',
|
|
526
|
+
'@modern-js/create',
|
|
527
|
+
...forwardedArgs
|
|
528
|
+
], {
|
|
529
|
+
stdio: 'inherit'
|
|
530
|
+
});
|
|
531
|
+
if (commandExists('npx')) return void runSetupCommand('npx', [
|
|
532
|
+
'@modern-js/create',
|
|
533
|
+
...forwardedArgs
|
|
534
|
+
], {
|
|
535
|
+
stdio: 'inherit'
|
|
536
|
+
});
|
|
537
|
+
throw new Error('Legacy Modern.js setup requires pnpm or npx to run @modern-js/create.');
|
|
538
|
+
}
|
|
495
539
|
function detectSubprojectFlag() {
|
|
496
540
|
const args = process.argv.slice(2);
|
|
497
541
|
if (args.includes('--sub') || args.includes('-s')) return true;
|
|
@@ -758,6 +802,7 @@ async function getProjectName() {
|
|
|
758
802
|
'--no-tailwind',
|
|
759
803
|
'--workspace',
|
|
760
804
|
'--vertical',
|
|
805
|
+
LEGACY_MODERN_JS_FLAG,
|
|
761
806
|
external_ultramodern_workspace_cjs_namespaceObject.ULTRAMODERN_WORKSPACE_FLAG
|
|
762
807
|
]);
|
|
763
808
|
const positionalArgs = [];
|
|
@@ -805,6 +850,11 @@ async function main() {
|
|
|
805
850
|
const args = process.argv.slice(2);
|
|
806
851
|
if (args.includes('--help') || args.includes('-h')) return void showHelp();
|
|
807
852
|
if (args.includes('--version') || args.includes('-v')) return void showVersion();
|
|
853
|
+
if (detectLegacyModernJsFlag(args)) {
|
|
854
|
+
await confirmLegacyModernJsSetup();
|
|
855
|
+
delegateLegacyModernJsSetup(args);
|
|
856
|
+
return;
|
|
857
|
+
}
|
|
808
858
|
console.log(`\n${index_cjs_namespaceObject.i18n.t(index_cjs_namespaceObject.localeKeys.message.welcome)}\n`);
|
|
809
859
|
const { name: projectName, useCurrentDir } = await getProjectName();
|
|
810
860
|
const targetDir = useCurrentDir ? process.cwd() : external_node_path_default().isAbsolute(projectName) ? projectName : external_node_path_default().resolve(process.cwd(), projectName);
|
package/dist/cjs/locale/en.cjs
CHANGED
|
@@ -29,13 +29,15 @@ var __webpack_exports__ = {};
|
|
|
29
29
|
__webpack_require__.r(__webpack_exports__);
|
|
30
30
|
const EN_LOCALE = {
|
|
31
31
|
prompt: {
|
|
32
|
-
projectName: 'Please enter project name: '
|
|
32
|
+
projectName: 'Please enter project name: ',
|
|
33
|
+
legacyModernJsConfirmation: 'Type "{confirmation}" to continue with the original Modern.js setup: '
|
|
33
34
|
},
|
|
34
35
|
error: {
|
|
35
36
|
projectNameEmpty: 'Error: Project name cannot be empty',
|
|
36
37
|
directoryExists: 'Error: Directory "{projectName}" already exists and is not empty',
|
|
37
38
|
invalidRouter: 'Error: Unsupported router "{router}". Use "react-router" or "tanstack".',
|
|
38
39
|
invalidBffRuntime: 'Error: Unsupported BFF runtime "{runtime}". Use "hono" or "effect".',
|
|
40
|
+
legacyModernJsNotConfirmed: 'Aborted. UltraModern.js remains the default unattended setup.',
|
|
39
41
|
createFailed: 'Error creating project:'
|
|
40
42
|
},
|
|
41
43
|
message: {
|
|
@@ -44,7 +46,8 @@ const EN_LOCALE = {
|
|
|
44
46
|
nextSteps: '📋 Next steps:',
|
|
45
47
|
step1: 'cd {projectName}',
|
|
46
48
|
step2: 'pnpm install',
|
|
47
|
-
step3: 'pnpm dev'
|
|
49
|
+
step3: 'pnpm dev',
|
|
50
|
+
legacyModernJsWarning: "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\nBRUTAL WARNING: YOU ARE OPTING OUT OF ULTRAMODERN.JS DEFAULTS.\nThe unattended default is the best UltraModern.js configuration:\npresetUltramodern, TanStack Router, Effect BFF, Tailwind CSS v4,\nand the BleedingDev package cohort.\nThe original Modern.js setup is legacy compatibility only.\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
|
48
51
|
},
|
|
49
52
|
help: {
|
|
50
53
|
title: '🚀 UltraModern.js Project Creator',
|
|
@@ -65,6 +68,7 @@ const EN_LOCALE = {
|
|
|
65
68
|
optionUltramodernPackageScope: ' --ultramodern-package-scope Publish scope for npm alias installs (for example bleedingdev)',
|
|
66
69
|
optionUltramodernPackageNamePrefix: ' --ultramodern-package-name-prefix Prefix for npm alias package names (default: modern-js-)',
|
|
67
70
|
optionVertical: ' --vertical Mutate the current existing UltraModern workspace and wire a MicroVertical named <project-name>',
|
|
71
|
+
optionLegacyModernJs: ' --legacy-modern-js Opt into the original Modern.js setup after a large warning and typed confirmation',
|
|
68
72
|
optionSub: ' -s, --sub Mark as a subproject (package in monorepo)',
|
|
69
73
|
examples: '💡 Examples:',
|
|
70
74
|
example1: ' pnpm dlx @bleedingdev/modern-js-create my-app',
|
package/dist/cjs/locale/zh.cjs
CHANGED
|
@@ -29,13 +29,15 @@ var __webpack_exports__ = {};
|
|
|
29
29
|
__webpack_require__.r(__webpack_exports__);
|
|
30
30
|
const ZH_LOCALE = {
|
|
31
31
|
prompt: {
|
|
32
|
-
projectName: '请输入项目名称: '
|
|
32
|
+
projectName: '请输入项目名称: ',
|
|
33
|
+
legacyModernJsConfirmation: '输入 "{confirmation}" 以继续使用原始 Modern.js 初始化: '
|
|
33
34
|
},
|
|
34
35
|
error: {
|
|
35
36
|
projectNameEmpty: '错误: 项目名称不能为空',
|
|
36
37
|
directoryExists: '错误: 目录 "{projectName}" 已存在且不为空',
|
|
37
38
|
invalidRouter: '错误: 不支持的路由器 "{router}",请使用 "react-router" 或 "tanstack"',
|
|
38
39
|
invalidBffRuntime: '错误: 不支持的 BFF 运行时 "{runtime}",请使用 "hono" 或 "effect"',
|
|
40
|
+
legacyModernJsNotConfirmed: '已中止。UltraModern.js 仍是默认的免交互初始化方案。',
|
|
39
41
|
createFailed: '创建项目时出错:'
|
|
40
42
|
},
|
|
41
43
|
message: {
|
|
@@ -44,7 +46,8 @@ const ZH_LOCALE = {
|
|
|
44
46
|
nextSteps: '📋 下一步:',
|
|
45
47
|
step1: 'cd {projectName}',
|
|
46
48
|
step2: 'pnpm install',
|
|
47
|
-
step3: 'pnpm dev'
|
|
49
|
+
step3: 'pnpm dev',
|
|
50
|
+
legacyModernJsWarning: "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n严重警告:你正在退出 ULTRAMODERN.JS 默认配置。\n免交互默认值是最佳 UltraModern.js 配置:\npresetUltramodern、TanStack Router、Effect BFF、Tailwind CSS v4,\n以及 BleedingDev 包版本队列。\n原始 Modern.js 初始化仅用于遗留兼容。\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
|
48
51
|
},
|
|
49
52
|
help: {
|
|
50
53
|
title: '🚀 UltraModern.js 项目创建工具',
|
|
@@ -65,6 +68,7 @@ const ZH_LOCALE = {
|
|
|
65
68
|
optionUltramodernPackageScope: ' --ultramodern-package-scope npm alias 安装使用的发布 scope(例如 bleedingdev)',
|
|
66
69
|
optionUltramodernPackageNamePrefix: ' --ultramodern-package-name-prefix npm alias 包名前缀(默认:modern-js-)',
|
|
67
70
|
optionVertical: ' --vertical 修改当前已有的 UltraModern 工作区,并接入名为 <项目名称> 的 MicroVertical',
|
|
71
|
+
optionLegacyModernJs: ' --legacy-modern-js 在大型警告和输入确认后,选择原始 Modern.js 初始化',
|
|
68
72
|
optionSub: ' -s, --sub 标记为子项目(monorepo 中的子包)',
|
|
69
73
|
examples: '💡 示例:',
|
|
70
74
|
example1: ' pnpm dlx @bleedingdev/modern-js-create my-app',
|
|
@@ -52,9 +52,11 @@ var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node
|
|
|
52
52
|
const external_node_path_namespaceObject = require("node:path");
|
|
53
53
|
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
54
54
|
const external_node_url_namespaceObject = require("node:url");
|
|
55
|
+
const external_create_package_root_cjs_namespaceObject = require("./create-package-root.cjs");
|
|
55
56
|
const external_ultramodern_package_source_cjs_namespaceObject = require("./ultramodern-package-source.cjs");
|
|
56
57
|
const ultramodern_workspace_dirname = external_node_path_default().dirname((0, external_node_url_namespaceObject.fileURLToPath)(__rslib_import_meta_url__));
|
|
57
|
-
const
|
|
58
|
+
const createPackageRoot = (0, external_create_package_root_cjs_namespaceObject.resolveCreatePackageRoot)(ultramodern_workspace_dirname);
|
|
59
|
+
const workspaceTemplateDir = external_node_path_default().join(createPackageRoot, 'template-workspace');
|
|
58
60
|
const TANSTACK_ROUTER_VERSION = '1.170.15';
|
|
59
61
|
const MODULE_FEDERATION_VERSION = '2.5.1';
|
|
60
62
|
const ZEPHYR_RSPACK_PLUGIN_VERSION = '1.1.1';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import node_fs from "node:fs";
|
|
2
|
+
import node_path from "node:path";
|
|
3
|
+
function resolveCreatePackageRoot(fromDir) {
|
|
4
|
+
const candidates = [
|
|
5
|
+
fromDir,
|
|
6
|
+
node_path.resolve(fromDir, '..'),
|
|
7
|
+
node_path.resolve(fromDir, '..', '..')
|
|
8
|
+
];
|
|
9
|
+
const seen = new Set();
|
|
10
|
+
for (const candidate of candidates)if (!seen.has(candidate)) {
|
|
11
|
+
seen.add(candidate);
|
|
12
|
+
if (node_fs.existsSync(node_path.join(candidate, 'package.json')) && node_fs.existsSync(node_path.join(candidate, 'template'))) return candidate;
|
|
13
|
+
}
|
|
14
|
+
throw new Error('Unable to resolve create package root');
|
|
15
|
+
}
|
|
16
|
+
export { resolveCreatePackageRoot };
|
package/dist/esm/index.js
CHANGED
|
@@ -5,11 +5,13 @@ import node_path from "node:path";
|
|
|
5
5
|
import node_readline from "node:readline";
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
7
7
|
import { getLocaleLanguage } from "@modern-js/i18n-utils/language-detector";
|
|
8
|
+
import { resolveCreatePackageRoot } from "./create-package-root.js";
|
|
8
9
|
import { i18n, localeKeys } from "./locale/index.js";
|
|
9
10
|
import { BLEEDINGDEV_CREATE_PACKAGE, BLEEDINGDEV_FRAMEWORK_VERSION_ENV, BLEEDINGDEV_PACKAGE_NAME_PREFIX, BLEEDINGDEV_PACKAGE_SCOPE, ULTRAMODERN_SINGLE_APP_MODERN_PACKAGES, WORKSPACE_PACKAGE_VERSION, createModernPackagesMetadata, modernPackageSpecifier } from "./ultramodern-package-source.js";
|
|
10
11
|
import { ULTRAMODERN_WORKSPACE_FLAG, addUltramodernVertical, generateUltramodernWorkspace } from "./ultramodern-workspace.js";
|
|
11
12
|
const src_dirname = node_path.dirname(fileURLToPath(import.meta.url));
|
|
12
|
-
const
|
|
13
|
+
const createPackageRoot = resolveCreatePackageRoot(src_dirname);
|
|
14
|
+
const templateDir = node_path.join(createPackageRoot, 'template');
|
|
13
15
|
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.-]+)?$/;
|
|
14
16
|
const semverTagPattern = /^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(?:-[0-9A-Za-z.-]+)?$/;
|
|
15
17
|
const sha1Pattern = /^[0-9a-f]{40}$/;
|
|
@@ -51,6 +53,8 @@ const requiredLifecycleDeniedScripts = [
|
|
|
51
53
|
const requiredLifecycleAllowedScripts = [
|
|
52
54
|
'postinstall'
|
|
53
55
|
];
|
|
56
|
+
const LEGACY_MODERN_JS_FLAG = '--legacy-modern-js';
|
|
57
|
+
const LEGACY_MODERN_JS_CONFIRMATION = 'USE LEGACY MODERN.JS';
|
|
54
58
|
function getOptionValue(args, names) {
|
|
55
59
|
for (const name of names){
|
|
56
60
|
const prefix = `${name}=`;
|
|
@@ -387,7 +391,7 @@ function writeTemplateManifestEvidence(targetDir, manifest) {
|
|
|
387
391
|
node_fs.writeFileSync(evidencePath, `${JSON.stringify(manifest, null, 2)}\n`);
|
|
388
392
|
}
|
|
389
393
|
function readCreatePackageJson() {
|
|
390
|
-
const createPackageJson = node_path.
|
|
394
|
+
const createPackageJson = node_path.join(createPackageRoot, 'package.json');
|
|
391
395
|
return JSON.parse(node_fs.readFileSync(createPackageJson, 'utf-8'));
|
|
392
396
|
}
|
|
393
397
|
function isBleedingDevCreatePackage(createPackage) {
|
|
@@ -426,6 +430,7 @@ function showHelp() {
|
|
|
426
430
|
if (localeKeys.help.optionUltramodernPackageScope) console.log(i18n.t(localeKeys.help.optionUltramodernPackageScope));
|
|
427
431
|
if (localeKeys.help.optionUltramodernPackageNamePrefix) console.log(i18n.t(localeKeys.help.optionUltramodernPackageNamePrefix));
|
|
428
432
|
if (localeKeys.help.optionVertical) console.log(i18n.t(localeKeys.help.optionVertical));
|
|
433
|
+
if (localeKeys.help.optionLegacyModernJs) console.log(i18n.t(localeKeys.help.optionLegacyModernJs));
|
|
429
434
|
console.log(i18n.t(localeKeys.help.optionSub));
|
|
430
435
|
console.log('');
|
|
431
436
|
console.log(i18n.t(localeKeys.help.examples));
|
|
@@ -458,6 +463,45 @@ function promptInput(question) {
|
|
|
458
463
|
});
|
|
459
464
|
});
|
|
460
465
|
}
|
|
466
|
+
function detectLegacyModernJsFlag(args) {
|
|
467
|
+
if (args.some((arg)=>arg.startsWith(`${LEGACY_MODERN_JS_FLAG}=`))) {
|
|
468
|
+
console.error(`${LEGACY_MODERN_JS_FLAG} does not accept a value.`);
|
|
469
|
+
process.exit(1);
|
|
470
|
+
}
|
|
471
|
+
return args.includes(LEGACY_MODERN_JS_FLAG);
|
|
472
|
+
}
|
|
473
|
+
function stripLegacyModernJsArgs(args) {
|
|
474
|
+
return args.filter((arg)=>arg !== LEGACY_MODERN_JS_FLAG);
|
|
475
|
+
}
|
|
476
|
+
async function confirmLegacyModernJsSetup() {
|
|
477
|
+
console.error('');
|
|
478
|
+
console.error(i18n.t(localeKeys.message.legacyModernJsWarning));
|
|
479
|
+
console.error('');
|
|
480
|
+
const answer = await promptInput(i18n.t(localeKeys.prompt.legacyModernJsConfirmation, {
|
|
481
|
+
confirmation: LEGACY_MODERN_JS_CONFIRMATION
|
|
482
|
+
}));
|
|
483
|
+
if (answer !== LEGACY_MODERN_JS_CONFIRMATION) {
|
|
484
|
+
console.error(i18n.t(localeKeys.error.legacyModernJsNotConfirmed));
|
|
485
|
+
process.exit(1);
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
function delegateLegacyModernJsSetup(args) {
|
|
489
|
+
const forwardedArgs = stripLegacyModernJsArgs(args);
|
|
490
|
+
if (commandExists('pnpm')) return void runSetupCommand('pnpm', [
|
|
491
|
+
'dlx',
|
|
492
|
+
'@modern-js/create',
|
|
493
|
+
...forwardedArgs
|
|
494
|
+
], {
|
|
495
|
+
stdio: 'inherit'
|
|
496
|
+
});
|
|
497
|
+
if (commandExists('npx')) return void runSetupCommand('npx', [
|
|
498
|
+
'@modern-js/create',
|
|
499
|
+
...forwardedArgs
|
|
500
|
+
], {
|
|
501
|
+
stdio: 'inherit'
|
|
502
|
+
});
|
|
503
|
+
throw new Error('Legacy Modern.js setup requires pnpm or npx to run @modern-js/create.');
|
|
504
|
+
}
|
|
461
505
|
function detectSubprojectFlag() {
|
|
462
506
|
const args = process.argv.slice(2);
|
|
463
507
|
if (args.includes('--sub') || args.includes('-s')) return true;
|
|
@@ -724,6 +768,7 @@ async function getProjectName() {
|
|
|
724
768
|
'--no-tailwind',
|
|
725
769
|
'--workspace',
|
|
726
770
|
'--vertical',
|
|
771
|
+
LEGACY_MODERN_JS_FLAG,
|
|
727
772
|
ULTRAMODERN_WORKSPACE_FLAG
|
|
728
773
|
]);
|
|
729
774
|
const positionalArgs = [];
|
|
@@ -771,6 +816,11 @@ async function main() {
|
|
|
771
816
|
const args = process.argv.slice(2);
|
|
772
817
|
if (args.includes('--help') || args.includes('-h')) return void showHelp();
|
|
773
818
|
if (args.includes('--version') || args.includes('-v')) return void showVersion();
|
|
819
|
+
if (detectLegacyModernJsFlag(args)) {
|
|
820
|
+
await confirmLegacyModernJsSetup();
|
|
821
|
+
delegateLegacyModernJsSetup(args);
|
|
822
|
+
return;
|
|
823
|
+
}
|
|
774
824
|
console.log(`\n${i18n.t(localeKeys.message.welcome)}\n`);
|
|
775
825
|
const { name: projectName, useCurrentDir } = await getProjectName();
|
|
776
826
|
const targetDir = useCurrentDir ? process.cwd() : node_path.isAbsolute(projectName) ? projectName : node_path.resolve(process.cwd(), projectName);
|
package/dist/esm/locale/en.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
const EN_LOCALE = {
|
|
2
2
|
prompt: {
|
|
3
|
-
projectName: 'Please enter project name: '
|
|
3
|
+
projectName: 'Please enter project name: ',
|
|
4
|
+
legacyModernJsConfirmation: 'Type "{confirmation}" to continue with the original Modern.js setup: '
|
|
4
5
|
},
|
|
5
6
|
error: {
|
|
6
7
|
projectNameEmpty: 'Error: Project name cannot be empty',
|
|
7
8
|
directoryExists: 'Error: Directory "{projectName}" already exists and is not empty',
|
|
8
9
|
invalidRouter: 'Error: Unsupported router "{router}". Use "react-router" or "tanstack".',
|
|
9
10
|
invalidBffRuntime: 'Error: Unsupported BFF runtime "{runtime}". Use "hono" or "effect".',
|
|
11
|
+
legacyModernJsNotConfirmed: 'Aborted. UltraModern.js remains the default unattended setup.',
|
|
10
12
|
createFailed: 'Error creating project:'
|
|
11
13
|
},
|
|
12
14
|
message: {
|
|
@@ -15,7 +17,8 @@ const EN_LOCALE = {
|
|
|
15
17
|
nextSteps: '📋 Next steps:',
|
|
16
18
|
step1: 'cd {projectName}',
|
|
17
19
|
step2: 'pnpm install',
|
|
18
|
-
step3: 'pnpm dev'
|
|
20
|
+
step3: 'pnpm dev',
|
|
21
|
+
legacyModernJsWarning: "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\nBRUTAL WARNING: YOU ARE OPTING OUT OF ULTRAMODERN.JS DEFAULTS.\nThe unattended default is the best UltraModern.js configuration:\npresetUltramodern, TanStack Router, Effect BFF, Tailwind CSS v4,\nand the BleedingDev package cohort.\nThe original Modern.js setup is legacy compatibility only.\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
|
19
22
|
},
|
|
20
23
|
help: {
|
|
21
24
|
title: '🚀 UltraModern.js Project Creator',
|
|
@@ -36,6 +39,7 @@ const EN_LOCALE = {
|
|
|
36
39
|
optionUltramodernPackageScope: ' --ultramodern-package-scope Publish scope for npm alias installs (for example bleedingdev)',
|
|
37
40
|
optionUltramodernPackageNamePrefix: ' --ultramodern-package-name-prefix Prefix for npm alias package names (default: modern-js-)',
|
|
38
41
|
optionVertical: ' --vertical Mutate the current existing UltraModern workspace and wire a MicroVertical named <project-name>',
|
|
42
|
+
optionLegacyModernJs: ' --legacy-modern-js Opt into the original Modern.js setup after a large warning and typed confirmation',
|
|
39
43
|
optionSub: ' -s, --sub Mark as a subproject (package in monorepo)',
|
|
40
44
|
examples: '💡 Examples:',
|
|
41
45
|
example1: ' pnpm dlx @bleedingdev/modern-js-create my-app',
|
package/dist/esm/locale/zh.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
const ZH_LOCALE = {
|
|
2
2
|
prompt: {
|
|
3
|
-
projectName: '请输入项目名称: '
|
|
3
|
+
projectName: '请输入项目名称: ',
|
|
4
|
+
legacyModernJsConfirmation: '输入 "{confirmation}" 以继续使用原始 Modern.js 初始化: '
|
|
4
5
|
},
|
|
5
6
|
error: {
|
|
6
7
|
projectNameEmpty: '错误: 项目名称不能为空',
|
|
7
8
|
directoryExists: '错误: 目录 "{projectName}" 已存在且不为空',
|
|
8
9
|
invalidRouter: '错误: 不支持的路由器 "{router}",请使用 "react-router" 或 "tanstack"',
|
|
9
10
|
invalidBffRuntime: '错误: 不支持的 BFF 运行时 "{runtime}",请使用 "hono" 或 "effect"',
|
|
11
|
+
legacyModernJsNotConfirmed: '已中止。UltraModern.js 仍是默认的免交互初始化方案。',
|
|
10
12
|
createFailed: '创建项目时出错:'
|
|
11
13
|
},
|
|
12
14
|
message: {
|
|
@@ -15,7 +17,8 @@ const ZH_LOCALE = {
|
|
|
15
17
|
nextSteps: '📋 下一步:',
|
|
16
18
|
step1: 'cd {projectName}',
|
|
17
19
|
step2: 'pnpm install',
|
|
18
|
-
step3: 'pnpm dev'
|
|
20
|
+
step3: 'pnpm dev',
|
|
21
|
+
legacyModernJsWarning: "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n严重警告:你正在退出 ULTRAMODERN.JS 默认配置。\n免交互默认值是最佳 UltraModern.js 配置:\npresetUltramodern、TanStack Router、Effect BFF、Tailwind CSS v4,\n以及 BleedingDev 包版本队列。\n原始 Modern.js 初始化仅用于遗留兼容。\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
|
19
22
|
},
|
|
20
23
|
help: {
|
|
21
24
|
title: '🚀 UltraModern.js 项目创建工具',
|
|
@@ -36,6 +39,7 @@ const ZH_LOCALE = {
|
|
|
36
39
|
optionUltramodernPackageScope: ' --ultramodern-package-scope npm alias 安装使用的发布 scope(例如 bleedingdev)',
|
|
37
40
|
optionUltramodernPackageNamePrefix: ' --ultramodern-package-name-prefix npm alias 包名前缀(默认:modern-js-)',
|
|
38
41
|
optionVertical: ' --vertical 修改当前已有的 UltraModern 工作区,并接入名为 <项目名称> 的 MicroVertical',
|
|
42
|
+
optionLegacyModernJs: ' --legacy-modern-js 在大型警告和输入确认后,选择原始 Modern.js 初始化',
|
|
39
43
|
optionSub: ' -s, --sub 标记为子项目(monorepo 中的子包)',
|
|
40
44
|
examples: '💡 示例:',
|
|
41
45
|
example1: ' pnpm dlx @bleedingdev/modern-js-create my-app',
|
|
@@ -2,9 +2,11 @@ import node_crypto from "node:crypto";
|
|
|
2
2
|
import node_fs from "node:fs";
|
|
3
3
|
import node_path from "node:path";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { resolveCreatePackageRoot } from "./create-package-root.js";
|
|
5
6
|
import { BLEEDINGDEV_PACKAGE_NAME_PREFIX, BLEEDINGDEV_PACKAGE_SCOPE, ULTRAMODERN_WORKSPACE_MODERN_PACKAGES, WORKSPACE_PACKAGE_VERSION, createModernPackagesMetadata, modernPackageSpecifier, modernPackageVersion } from "./ultramodern-package-source.js";
|
|
6
7
|
const ultramodern_workspace_dirname = node_path.dirname(fileURLToPath(import.meta.url));
|
|
7
|
-
const
|
|
8
|
+
const createPackageRoot = resolveCreatePackageRoot(ultramodern_workspace_dirname);
|
|
9
|
+
const workspaceTemplateDir = node_path.join(createPackageRoot, 'template-workspace');
|
|
8
10
|
const TANSTACK_ROUTER_VERSION = '1.170.15';
|
|
9
11
|
const MODULE_FEDERATION_VERSION = '2.5.1';
|
|
10
12
|
const ZEPHYR_RSPACK_PLUGIN_VERSION = '1.1.1';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import node_fs from "node:fs";
|
|
3
|
+
import node_path from "node:path";
|
|
4
|
+
function resolveCreatePackageRoot(fromDir) {
|
|
5
|
+
const candidates = [
|
|
6
|
+
fromDir,
|
|
7
|
+
node_path.resolve(fromDir, '..'),
|
|
8
|
+
node_path.resolve(fromDir, '..', '..')
|
|
9
|
+
];
|
|
10
|
+
const seen = new Set();
|
|
11
|
+
for (const candidate of candidates)if (!seen.has(candidate)) {
|
|
12
|
+
seen.add(candidate);
|
|
13
|
+
if (node_fs.existsSync(node_path.join(candidate, 'package.json')) && node_fs.existsSync(node_path.join(candidate, 'template'))) return candidate;
|
|
14
|
+
}
|
|
15
|
+
throw new Error('Unable to resolve create package root');
|
|
16
|
+
}
|
|
17
|
+
export { resolveCreatePackageRoot };
|
package/dist/esm-node/index.js
CHANGED
|
@@ -6,11 +6,13 @@ import node_path from "node:path";
|
|
|
6
6
|
import node_readline from "node:readline";
|
|
7
7
|
import { fileURLToPath } from "node:url";
|
|
8
8
|
import { getLocaleLanguage } from "@modern-js/i18n-utils/language-detector";
|
|
9
|
+
import { resolveCreatePackageRoot } from "./create-package-root.js";
|
|
9
10
|
import { i18n, localeKeys } from "./locale/index.js";
|
|
10
11
|
import { BLEEDINGDEV_CREATE_PACKAGE, BLEEDINGDEV_FRAMEWORK_VERSION_ENV, BLEEDINGDEV_PACKAGE_NAME_PREFIX, BLEEDINGDEV_PACKAGE_SCOPE, ULTRAMODERN_SINGLE_APP_MODERN_PACKAGES, WORKSPACE_PACKAGE_VERSION, createModernPackagesMetadata, modernPackageSpecifier } from "./ultramodern-package-source.js";
|
|
11
12
|
import { ULTRAMODERN_WORKSPACE_FLAG, addUltramodernVertical, generateUltramodernWorkspace } from "./ultramodern-workspace.js";
|
|
12
13
|
const src_dirname = node_path.dirname(fileURLToPath(import.meta.url));
|
|
13
|
-
const
|
|
14
|
+
const createPackageRoot = resolveCreatePackageRoot(src_dirname);
|
|
15
|
+
const templateDir = node_path.join(createPackageRoot, 'template');
|
|
14
16
|
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.-]+)?$/;
|
|
15
17
|
const semverTagPattern = /^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(?:-[0-9A-Za-z.-]+)?$/;
|
|
16
18
|
const sha1Pattern = /^[0-9a-f]{40}$/;
|
|
@@ -52,6 +54,8 @@ const requiredLifecycleDeniedScripts = [
|
|
|
52
54
|
const requiredLifecycleAllowedScripts = [
|
|
53
55
|
'postinstall'
|
|
54
56
|
];
|
|
57
|
+
const LEGACY_MODERN_JS_FLAG = '--legacy-modern-js';
|
|
58
|
+
const LEGACY_MODERN_JS_CONFIRMATION = 'USE LEGACY MODERN.JS';
|
|
55
59
|
function getOptionValue(args, names) {
|
|
56
60
|
for (const name of names){
|
|
57
61
|
const prefix = `${name}=`;
|
|
@@ -388,7 +392,7 @@ function writeTemplateManifestEvidence(targetDir, manifest) {
|
|
|
388
392
|
node_fs.writeFileSync(evidencePath, `${JSON.stringify(manifest, null, 2)}\n`);
|
|
389
393
|
}
|
|
390
394
|
function readCreatePackageJson() {
|
|
391
|
-
const createPackageJson = node_path.
|
|
395
|
+
const createPackageJson = node_path.join(createPackageRoot, 'package.json');
|
|
392
396
|
return JSON.parse(node_fs.readFileSync(createPackageJson, 'utf-8'));
|
|
393
397
|
}
|
|
394
398
|
function isBleedingDevCreatePackage(createPackage) {
|
|
@@ -427,6 +431,7 @@ function showHelp() {
|
|
|
427
431
|
if (localeKeys.help.optionUltramodernPackageScope) console.log(i18n.t(localeKeys.help.optionUltramodernPackageScope));
|
|
428
432
|
if (localeKeys.help.optionUltramodernPackageNamePrefix) console.log(i18n.t(localeKeys.help.optionUltramodernPackageNamePrefix));
|
|
429
433
|
if (localeKeys.help.optionVertical) console.log(i18n.t(localeKeys.help.optionVertical));
|
|
434
|
+
if (localeKeys.help.optionLegacyModernJs) console.log(i18n.t(localeKeys.help.optionLegacyModernJs));
|
|
430
435
|
console.log(i18n.t(localeKeys.help.optionSub));
|
|
431
436
|
console.log('');
|
|
432
437
|
console.log(i18n.t(localeKeys.help.examples));
|
|
@@ -459,6 +464,45 @@ function promptInput(question) {
|
|
|
459
464
|
});
|
|
460
465
|
});
|
|
461
466
|
}
|
|
467
|
+
function detectLegacyModernJsFlag(args) {
|
|
468
|
+
if (args.some((arg)=>arg.startsWith(`${LEGACY_MODERN_JS_FLAG}=`))) {
|
|
469
|
+
console.error(`${LEGACY_MODERN_JS_FLAG} does not accept a value.`);
|
|
470
|
+
process.exit(1);
|
|
471
|
+
}
|
|
472
|
+
return args.includes(LEGACY_MODERN_JS_FLAG);
|
|
473
|
+
}
|
|
474
|
+
function stripLegacyModernJsArgs(args) {
|
|
475
|
+
return args.filter((arg)=>arg !== LEGACY_MODERN_JS_FLAG);
|
|
476
|
+
}
|
|
477
|
+
async function confirmLegacyModernJsSetup() {
|
|
478
|
+
console.error('');
|
|
479
|
+
console.error(i18n.t(localeKeys.message.legacyModernJsWarning));
|
|
480
|
+
console.error('');
|
|
481
|
+
const answer = await promptInput(i18n.t(localeKeys.prompt.legacyModernJsConfirmation, {
|
|
482
|
+
confirmation: LEGACY_MODERN_JS_CONFIRMATION
|
|
483
|
+
}));
|
|
484
|
+
if (answer !== LEGACY_MODERN_JS_CONFIRMATION) {
|
|
485
|
+
console.error(i18n.t(localeKeys.error.legacyModernJsNotConfirmed));
|
|
486
|
+
process.exit(1);
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
function delegateLegacyModernJsSetup(args) {
|
|
490
|
+
const forwardedArgs = stripLegacyModernJsArgs(args);
|
|
491
|
+
if (commandExists('pnpm')) return void runSetupCommand('pnpm', [
|
|
492
|
+
'dlx',
|
|
493
|
+
'@modern-js/create',
|
|
494
|
+
...forwardedArgs
|
|
495
|
+
], {
|
|
496
|
+
stdio: 'inherit'
|
|
497
|
+
});
|
|
498
|
+
if (commandExists('npx')) return void runSetupCommand('npx', [
|
|
499
|
+
'@modern-js/create',
|
|
500
|
+
...forwardedArgs
|
|
501
|
+
], {
|
|
502
|
+
stdio: 'inherit'
|
|
503
|
+
});
|
|
504
|
+
throw new Error('Legacy Modern.js setup requires pnpm or npx to run @modern-js/create.');
|
|
505
|
+
}
|
|
462
506
|
function detectSubprojectFlag() {
|
|
463
507
|
const args = process.argv.slice(2);
|
|
464
508
|
if (args.includes('--sub') || args.includes('-s')) return true;
|
|
@@ -725,6 +769,7 @@ async function getProjectName() {
|
|
|
725
769
|
'--no-tailwind',
|
|
726
770
|
'--workspace',
|
|
727
771
|
'--vertical',
|
|
772
|
+
LEGACY_MODERN_JS_FLAG,
|
|
728
773
|
ULTRAMODERN_WORKSPACE_FLAG
|
|
729
774
|
]);
|
|
730
775
|
const positionalArgs = [];
|
|
@@ -772,6 +817,11 @@ async function main() {
|
|
|
772
817
|
const args = process.argv.slice(2);
|
|
773
818
|
if (args.includes('--help') || args.includes('-h')) return void showHelp();
|
|
774
819
|
if (args.includes('--version') || args.includes('-v')) return void showVersion();
|
|
820
|
+
if (detectLegacyModernJsFlag(args)) {
|
|
821
|
+
await confirmLegacyModernJsSetup();
|
|
822
|
+
delegateLegacyModernJsSetup(args);
|
|
823
|
+
return;
|
|
824
|
+
}
|
|
775
825
|
console.log(`\n${i18n.t(localeKeys.message.welcome)}\n`);
|
|
776
826
|
const { name: projectName, useCurrentDir } = await getProjectName();
|
|
777
827
|
const targetDir = useCurrentDir ? process.cwd() : node_path.isAbsolute(projectName) ? projectName : node_path.resolve(process.cwd(), projectName);
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import "node:module";
|
|
2
2
|
const EN_LOCALE = {
|
|
3
3
|
prompt: {
|
|
4
|
-
projectName: 'Please enter project name: '
|
|
4
|
+
projectName: 'Please enter project name: ',
|
|
5
|
+
legacyModernJsConfirmation: 'Type "{confirmation}" to continue with the original Modern.js setup: '
|
|
5
6
|
},
|
|
6
7
|
error: {
|
|
7
8
|
projectNameEmpty: 'Error: Project name cannot be empty',
|
|
8
9
|
directoryExists: 'Error: Directory "{projectName}" already exists and is not empty',
|
|
9
10
|
invalidRouter: 'Error: Unsupported router "{router}". Use "react-router" or "tanstack".',
|
|
10
11
|
invalidBffRuntime: 'Error: Unsupported BFF runtime "{runtime}". Use "hono" or "effect".',
|
|
12
|
+
legacyModernJsNotConfirmed: 'Aborted. UltraModern.js remains the default unattended setup.',
|
|
11
13
|
createFailed: 'Error creating project:'
|
|
12
14
|
},
|
|
13
15
|
message: {
|
|
@@ -16,7 +18,8 @@ const EN_LOCALE = {
|
|
|
16
18
|
nextSteps: '📋 Next steps:',
|
|
17
19
|
step1: 'cd {projectName}',
|
|
18
20
|
step2: 'pnpm install',
|
|
19
|
-
step3: 'pnpm dev'
|
|
21
|
+
step3: 'pnpm dev',
|
|
22
|
+
legacyModernJsWarning: "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\nBRUTAL WARNING: YOU ARE OPTING OUT OF ULTRAMODERN.JS DEFAULTS.\nThe unattended default is the best UltraModern.js configuration:\npresetUltramodern, TanStack Router, Effect BFF, Tailwind CSS v4,\nand the BleedingDev package cohort.\nThe original Modern.js setup is legacy compatibility only.\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
|
20
23
|
},
|
|
21
24
|
help: {
|
|
22
25
|
title: '🚀 UltraModern.js Project Creator',
|
|
@@ -37,6 +40,7 @@ const EN_LOCALE = {
|
|
|
37
40
|
optionUltramodernPackageScope: ' --ultramodern-package-scope Publish scope for npm alias installs (for example bleedingdev)',
|
|
38
41
|
optionUltramodernPackageNamePrefix: ' --ultramodern-package-name-prefix Prefix for npm alias package names (default: modern-js-)',
|
|
39
42
|
optionVertical: ' --vertical Mutate the current existing UltraModern workspace and wire a MicroVertical named <project-name>',
|
|
43
|
+
optionLegacyModernJs: ' --legacy-modern-js Opt into the original Modern.js setup after a large warning and typed confirmation',
|
|
40
44
|
optionSub: ' -s, --sub Mark as a subproject (package in monorepo)',
|
|
41
45
|
examples: '💡 Examples:',
|
|
42
46
|
example1: ' pnpm dlx @bleedingdev/modern-js-create my-app',
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import "node:module";
|
|
2
2
|
const ZH_LOCALE = {
|
|
3
3
|
prompt: {
|
|
4
|
-
projectName: '请输入项目名称: '
|
|
4
|
+
projectName: '请输入项目名称: ',
|
|
5
|
+
legacyModernJsConfirmation: '输入 "{confirmation}" 以继续使用原始 Modern.js 初始化: '
|
|
5
6
|
},
|
|
6
7
|
error: {
|
|
7
8
|
projectNameEmpty: '错误: 项目名称不能为空',
|
|
8
9
|
directoryExists: '错误: 目录 "{projectName}" 已存在且不为空',
|
|
9
10
|
invalidRouter: '错误: 不支持的路由器 "{router}",请使用 "react-router" 或 "tanstack"',
|
|
10
11
|
invalidBffRuntime: '错误: 不支持的 BFF 运行时 "{runtime}",请使用 "hono" 或 "effect"',
|
|
12
|
+
legacyModernJsNotConfirmed: '已中止。UltraModern.js 仍是默认的免交互初始化方案。',
|
|
11
13
|
createFailed: '创建项目时出错:'
|
|
12
14
|
},
|
|
13
15
|
message: {
|
|
@@ -16,7 +18,8 @@ const ZH_LOCALE = {
|
|
|
16
18
|
nextSteps: '📋 下一步:',
|
|
17
19
|
step1: 'cd {projectName}',
|
|
18
20
|
step2: 'pnpm install',
|
|
19
|
-
step3: 'pnpm dev'
|
|
21
|
+
step3: 'pnpm dev',
|
|
22
|
+
legacyModernJsWarning: "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n严重警告:你正在退出 ULTRAMODERN.JS 默认配置。\n免交互默认值是最佳 UltraModern.js 配置:\npresetUltramodern、TanStack Router、Effect BFF、Tailwind CSS v4,\n以及 BleedingDev 包版本队列。\n原始 Modern.js 初始化仅用于遗留兼容。\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
|
20
23
|
},
|
|
21
24
|
help: {
|
|
22
25
|
title: '🚀 UltraModern.js 项目创建工具',
|
|
@@ -37,6 +40,7 @@ const ZH_LOCALE = {
|
|
|
37
40
|
optionUltramodernPackageScope: ' --ultramodern-package-scope npm alias 安装使用的发布 scope(例如 bleedingdev)',
|
|
38
41
|
optionUltramodernPackageNamePrefix: ' --ultramodern-package-name-prefix npm alias 包名前缀(默认:modern-js-)',
|
|
39
42
|
optionVertical: ' --vertical 修改当前已有的 UltraModern 工作区,并接入名为 <项目名称> 的 MicroVertical',
|
|
43
|
+
optionLegacyModernJs: ' --legacy-modern-js 在大型警告和输入确认后,选择原始 Modern.js 初始化',
|
|
40
44
|
optionSub: ' -s, --sub 标记为子项目(monorepo 中的子包)',
|
|
41
45
|
examples: '💡 示例:',
|
|
42
46
|
example1: ' pnpm dlx @bleedingdev/modern-js-create my-app',
|
|
@@ -3,9 +3,11 @@ import node_crypto from "node:crypto";
|
|
|
3
3
|
import node_fs from "node:fs";
|
|
4
4
|
import node_path from "node:path";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
|
+
import { resolveCreatePackageRoot } from "./create-package-root.js";
|
|
6
7
|
import { BLEEDINGDEV_PACKAGE_NAME_PREFIX, BLEEDINGDEV_PACKAGE_SCOPE, ULTRAMODERN_WORKSPACE_MODERN_PACKAGES, WORKSPACE_PACKAGE_VERSION, createModernPackagesMetadata, modernPackageSpecifier, modernPackageVersion } from "./ultramodern-package-source.js";
|
|
7
8
|
const ultramodern_workspace_dirname = node_path.dirname(fileURLToPath(import.meta.url));
|
|
8
|
-
const
|
|
9
|
+
const createPackageRoot = resolveCreatePackageRoot(ultramodern_workspace_dirname);
|
|
10
|
+
const workspaceTemplateDir = node_path.join(createPackageRoot, 'template-workspace');
|
|
9
11
|
const TANSTACK_ROUTER_VERSION = '1.170.15';
|
|
10
12
|
const MODULE_FEDERATION_VERSION = '2.5.1';
|
|
11
13
|
const ZEPHYR_RSPACK_PLUGIN_VERSION = '1.1.1';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function resolveCreatePackageRoot(fromDir: string): string;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
export declare const EN_LOCALE: {
|
|
2
2
|
prompt: {
|
|
3
3
|
projectName: string;
|
|
4
|
+
legacyModernJsConfirmation: string;
|
|
4
5
|
};
|
|
5
6
|
error: {
|
|
6
7
|
projectNameEmpty: string;
|
|
7
8
|
directoryExists: string;
|
|
8
9
|
invalidRouter: string;
|
|
9
10
|
invalidBffRuntime: string;
|
|
11
|
+
legacyModernJsNotConfirmed: string;
|
|
10
12
|
createFailed: string;
|
|
11
13
|
};
|
|
12
14
|
message: {
|
|
@@ -16,6 +18,7 @@ export declare const EN_LOCALE: {
|
|
|
16
18
|
step1: string;
|
|
17
19
|
step2: string;
|
|
18
20
|
step3: string;
|
|
21
|
+
legacyModernJsWarning: string;
|
|
19
22
|
};
|
|
20
23
|
help: {
|
|
21
24
|
title: string;
|
|
@@ -36,6 +39,7 @@ export declare const EN_LOCALE: {
|
|
|
36
39
|
optionUltramodernPackageScope: string;
|
|
37
40
|
optionUltramodernPackageNamePrefix: string;
|
|
38
41
|
optionVertical: string;
|
|
42
|
+
optionLegacyModernJs: string;
|
|
39
43
|
optionSub: string;
|
|
40
44
|
examples: string;
|
|
41
45
|
example1: string;
|
|
@@ -3,12 +3,14 @@ declare const i18n: I18n;
|
|
|
3
3
|
declare const localeKeys: {
|
|
4
4
|
prompt: {
|
|
5
5
|
projectName: string;
|
|
6
|
+
legacyModernJsConfirmation: string;
|
|
6
7
|
};
|
|
7
8
|
error: {
|
|
8
9
|
projectNameEmpty: string;
|
|
9
10
|
directoryExists: string;
|
|
10
11
|
invalidRouter: string;
|
|
11
12
|
invalidBffRuntime: string;
|
|
13
|
+
legacyModernJsNotConfirmed: string;
|
|
12
14
|
createFailed: string;
|
|
13
15
|
};
|
|
14
16
|
message: {
|
|
@@ -18,6 +20,7 @@ declare const localeKeys: {
|
|
|
18
20
|
step1: string;
|
|
19
21
|
step2: string;
|
|
20
22
|
step3: string;
|
|
23
|
+
legacyModernJsWarning: string;
|
|
21
24
|
};
|
|
22
25
|
help: {
|
|
23
26
|
title: string;
|
|
@@ -38,6 +41,7 @@ declare const localeKeys: {
|
|
|
38
41
|
optionUltramodernPackageScope: string;
|
|
39
42
|
optionUltramodernPackageNamePrefix: string;
|
|
40
43
|
optionVertical: string;
|
|
44
|
+
optionLegacyModernJs: string;
|
|
41
45
|
optionSub: string;
|
|
42
46
|
examples: string;
|
|
43
47
|
example1: string;
|
|
@@ -60,12 +64,14 @@ declare const localeKeys: {
|
|
|
60
64
|
} | {
|
|
61
65
|
prompt: {
|
|
62
66
|
projectName: string;
|
|
67
|
+
legacyModernJsConfirmation: string;
|
|
63
68
|
};
|
|
64
69
|
error: {
|
|
65
70
|
projectNameEmpty: string;
|
|
66
71
|
directoryExists: string;
|
|
67
72
|
invalidRouter: string;
|
|
68
73
|
invalidBffRuntime: string;
|
|
74
|
+
legacyModernJsNotConfirmed: string;
|
|
69
75
|
createFailed: string;
|
|
70
76
|
};
|
|
71
77
|
message: {
|
|
@@ -75,6 +81,7 @@ declare const localeKeys: {
|
|
|
75
81
|
step1: string;
|
|
76
82
|
step2: string;
|
|
77
83
|
step3: string;
|
|
84
|
+
legacyModernJsWarning: string;
|
|
78
85
|
};
|
|
79
86
|
help: {
|
|
80
87
|
title: string;
|
|
@@ -95,6 +102,7 @@ declare const localeKeys: {
|
|
|
95
102
|
optionUltramodernPackageScope: string;
|
|
96
103
|
optionUltramodernPackageNamePrefix: string;
|
|
97
104
|
optionVertical: string;
|
|
105
|
+
optionLegacyModernJs: string;
|
|
98
106
|
optionSub: string;
|
|
99
107
|
examples: string;
|
|
100
108
|
example1: string;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
export declare const ZH_LOCALE: {
|
|
2
2
|
prompt: {
|
|
3
3
|
projectName: string;
|
|
4
|
+
legacyModernJsConfirmation: string;
|
|
4
5
|
};
|
|
5
6
|
error: {
|
|
6
7
|
projectNameEmpty: string;
|
|
7
8
|
directoryExists: string;
|
|
8
9
|
invalidRouter: string;
|
|
9
10
|
invalidBffRuntime: string;
|
|
11
|
+
legacyModernJsNotConfirmed: string;
|
|
10
12
|
createFailed: string;
|
|
11
13
|
};
|
|
12
14
|
message: {
|
|
@@ -16,6 +18,7 @@ export declare const ZH_LOCALE: {
|
|
|
16
18
|
step1: string;
|
|
17
19
|
step2: string;
|
|
18
20
|
step3: string;
|
|
21
|
+
legacyModernJsWarning: string;
|
|
19
22
|
};
|
|
20
23
|
help: {
|
|
21
24
|
title: string;
|
|
@@ -36,6 +39,7 @@ export declare const ZH_LOCALE: {
|
|
|
36
39
|
optionUltramodernPackageScope: string;
|
|
37
40
|
optionUltramodernPackageNamePrefix: string;
|
|
38
41
|
optionVertical: string;
|
|
42
|
+
optionLegacyModernJs: string;
|
|
39
43
|
optionSub: string;
|
|
40
44
|
examples: string;
|
|
41
45
|
example1: string;
|
package/package.json
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"engines": {
|
|
22
22
|
"node": ">=20"
|
|
23
23
|
},
|
|
24
|
-
"version": "3.2.0-ultramodern.
|
|
24
|
+
"version": "3.2.0-ultramodern.115",
|
|
25
25
|
"types": "./dist/types/index.d.ts",
|
|
26
26
|
"main": "./dist/esm-node/index.js",
|
|
27
27
|
"bin": {
|
|
@@ -50,12 +50,14 @@
|
|
|
50
50
|
"dist",
|
|
51
51
|
"bin.js"
|
|
52
52
|
],
|
|
53
|
+
"dependencies": {
|
|
54
|
+
"@modern-js/i18n-utils": "npm:@bleedingdev/modern-js-i18n-utils@3.2.0-ultramodern.115"
|
|
55
|
+
},
|
|
53
56
|
"devDependencies": {
|
|
54
57
|
"@rslib/core": "0.21.5",
|
|
55
58
|
"@types/node": "^25.9.1",
|
|
56
59
|
"@typescript/native-preview": "7.0.0-dev.20260606.1",
|
|
57
60
|
"tsx": "^4.22.3",
|
|
58
|
-
"@modern-js/i18n-utils": "npm:@bleedingdev/modern-js-i18n-utils@3.2.0-ultramodern.112",
|
|
59
61
|
"@scripts/rstest-config": "2.66.0"
|
|
60
62
|
},
|
|
61
63
|
"publishConfig": {
|
|
@@ -70,6 +72,6 @@
|
|
|
70
72
|
"test": "rm -rf dist && rslib build -c rslibconfig.mts && rstest --passWithNoTests"
|
|
71
73
|
},
|
|
72
74
|
"ultramodern": {
|
|
73
|
-
"frameworkVersion": "3.2.0-ultramodern.
|
|
75
|
+
"frameworkVersion": "3.2.0-ultramodern.115"
|
|
74
76
|
}
|
|
75
77
|
}
|