@bleedingdev/modern-js-create 3.2.0-ultramodern.99 → 3.4.0-ultramodern.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +281 -106
- package/bin/run.js +1 -0
- package/dist/cjs/create-package-root.cjs +63 -0
- package/dist/cjs/index.cjs +658 -0
- package/dist/cjs/locale/en.cjs +101 -0
- package/dist/cjs/locale/index.cjs +50 -0
- package/dist/cjs/locale/zh.cjs +101 -0
- package/dist/cjs/ultramodern-package-source.cjs +135 -0
- package/dist/cjs/ultramodern-workspace/add-vertical.cjs +603 -0
- package/dist/cjs/ultramodern-workspace/app-files.cjs +223 -0
- package/dist/cjs/ultramodern-workspace/codesmith.cjs +134 -0
- package/dist/cjs/ultramodern-workspace/contracts.cjs +837 -0
- package/dist/cjs/ultramodern-workspace/demo-components.cjs +422 -0
- package/dist/cjs/ultramodern-workspace/descriptors.cjs +222 -0
- package/dist/cjs/ultramodern-workspace/effect-api.cjs +952 -0
- package/dist/cjs/ultramodern-workspace/fs-io.cjs +191 -0
- package/dist/cjs/ultramodern-workspace/generation-result.cjs +158 -0
- package/dist/cjs/ultramodern-workspace/index.cjs +51 -0
- package/dist/cjs/ultramodern-workspace/locales.cjs +173 -0
- package/dist/cjs/ultramodern-workspace/module-federation.cjs +487 -0
- package/dist/cjs/ultramodern-workspace/naming.cjs +161 -0
- package/dist/cjs/ultramodern-workspace/overlays.cjs +120 -0
- package/dist/cjs/ultramodern-workspace/package-json.cjs +406 -0
- package/dist/cjs/ultramodern-workspace/package-source.cjs +59 -0
- package/dist/cjs/ultramodern-workspace/policy.cjs +248 -0
- package/dist/cjs/ultramodern-workspace/public-api.cjs +47 -0
- package/dist/cjs/ultramodern-workspace/public-surface.cjs +268 -0
- package/dist/cjs/ultramodern-workspace/routes.cjs +375 -0
- package/dist/cjs/ultramodern-workspace/types.cjs +61 -0
- package/dist/cjs/ultramodern-workspace/versions.cjs +161 -0
- package/dist/cjs/ultramodern-workspace/workspace-scripts.cjs +154 -0
- package/dist/cjs/ultramodern-workspace/write-workspace.cjs +197 -0
- package/dist/esm/create-package-root.js +14 -0
- package/dist/esm/index.js +621 -0
- package/dist/esm/locale/en.js +63 -0
- package/dist/esm/locale/index.js +9 -0
- package/dist/esm/locale/zh.js +63 -0
- package/dist/esm/ultramodern-package-source.js +63 -0
- package/dist/esm/ultramodern-workspace/add-vertical.js +511 -0
- package/dist/esm/ultramodern-workspace/app-files.js +149 -0
- package/dist/esm/ultramodern-workspace/codesmith.js +86 -0
- package/dist/esm/ultramodern-workspace/contracts.js +742 -0
- package/dist/esm/ultramodern-workspace/demo-components.js +363 -0
- package/dist/esm/ultramodern-workspace/descriptors.js +133 -0
- package/dist/esm/ultramodern-workspace/effect-api.js +854 -0
- package/dist/esm/ultramodern-workspace/fs-io.js +90 -0
- package/dist/esm/ultramodern-workspace/generation-result.js +102 -0
- package/dist/esm/ultramodern-workspace/index.js +3 -0
- package/dist/esm/ultramodern-workspace/locales.js +122 -0
- package/dist/esm/ultramodern-workspace/module-federation.js +415 -0
- package/dist/esm/ultramodern-workspace/naming.js +71 -0
- package/dist/esm/ultramodern-workspace/overlays.js +79 -0
- package/dist/esm/ultramodern-workspace/package-json.js +338 -0
- package/dist/esm/ultramodern-workspace/package-source.js +21 -0
- package/dist/esm/ultramodern-workspace/policy.js +183 -0
- package/dist/esm/ultramodern-workspace/public-api.js +2 -0
- package/dist/esm/ultramodern-workspace/public-surface.js +183 -0
- package/dist/esm/ultramodern-workspace/routes.js +280 -0
- package/dist/esm/ultramodern-workspace/types.js +16 -0
- package/dist/esm/ultramodern-workspace/versions.js +36 -0
- package/dist/esm/ultramodern-workspace/workspace-scripts.js +92 -0
- package/dist/esm/ultramodern-workspace/write-workspace.js +143 -0
- package/dist/esm-node/create-package-root.js +15 -0
- package/dist/esm-node/index.js +622 -0
- package/dist/esm-node/locale/en.js +64 -0
- package/dist/esm-node/locale/index.js +10 -0
- package/dist/esm-node/locale/zh.js +64 -0
- package/dist/esm-node/ultramodern-package-source.js +64 -0
- package/dist/esm-node/ultramodern-workspace/add-vertical.js +512 -0
- package/dist/esm-node/ultramodern-workspace/app-files.js +150 -0
- package/dist/esm-node/ultramodern-workspace/codesmith.js +87 -0
- package/dist/esm-node/ultramodern-workspace/contracts.js +743 -0
- package/dist/esm-node/ultramodern-workspace/demo-components.js +364 -0
- package/dist/esm-node/ultramodern-workspace/descriptors.js +134 -0
- package/dist/esm-node/ultramodern-workspace/effect-api.js +855 -0
- package/dist/esm-node/ultramodern-workspace/fs-io.js +91 -0
- package/dist/esm-node/ultramodern-workspace/generation-result.js +103 -0
- package/dist/esm-node/ultramodern-workspace/index.js +4 -0
- package/dist/esm-node/ultramodern-workspace/locales.js +123 -0
- package/dist/esm-node/ultramodern-workspace/module-federation.js +416 -0
- package/dist/esm-node/ultramodern-workspace/naming.js +72 -0
- package/dist/esm-node/ultramodern-workspace/overlays.js +80 -0
- package/dist/esm-node/ultramodern-workspace/package-json.js +339 -0
- package/dist/esm-node/ultramodern-workspace/package-source.js +22 -0
- package/dist/esm-node/ultramodern-workspace/policy.js +184 -0
- package/dist/esm-node/ultramodern-workspace/public-api.js +3 -0
- package/dist/esm-node/ultramodern-workspace/public-surface.js +184 -0
- package/dist/esm-node/ultramodern-workspace/routes.js +281 -0
- package/dist/esm-node/ultramodern-workspace/types.js +17 -0
- package/dist/esm-node/ultramodern-workspace/versions.js +37 -0
- package/dist/esm-node/ultramodern-workspace/workspace-scripts.js +93 -0
- package/dist/esm-node/ultramodern-workspace/write-workspace.js +144 -0
- package/dist/types/create-package-root.d.ts +1 -0
- package/dist/types/locale/en.d.ts +12 -8
- package/dist/types/locale/index.d.ts +125 -2
- package/dist/types/locale/zh.d.ts +12 -8
- package/dist/types/ultramodern-package-source.d.ts +28 -0
- package/dist/types/ultramodern-workspace/add-vertical.d.ts +36 -0
- package/dist/types/ultramodern-workspace/app-files.d.ts +14 -0
- package/dist/types/ultramodern-workspace/codesmith.d.ts +53 -0
- package/dist/types/ultramodern-workspace/contracts.d.ts +21 -0
- package/dist/types/ultramodern-workspace/demo-components.d.ts +9 -0
- package/dist/types/ultramodern-workspace/descriptors.d.ts +39 -0
- package/dist/types/ultramodern-workspace/effect-api.d.ts +73 -0
- package/dist/types/ultramodern-workspace/fs-io.d.ts +18 -0
- package/dist/types/ultramodern-workspace/generation-result.d.ts +14 -0
- package/dist/types/ultramodern-workspace/index.d.ts +4 -0
- package/dist/types/ultramodern-workspace/locales.d.ts +183 -0
- package/dist/types/ultramodern-workspace/module-federation.d.ts +16 -0
- package/dist/types/ultramodern-workspace/naming.d.ts +16 -0
- package/dist/types/ultramodern-workspace/overlays.d.ts +6 -0
- package/dist/types/ultramodern-workspace/package-json.d.ts +12 -0
- package/dist/types/ultramodern-workspace/package-source.d.ts +2 -0
- package/dist/types/ultramodern-workspace/policy.d.ts +60 -0
- package/dist/types/ultramodern-workspace/public-api.d.ts +3 -0
- package/dist/types/ultramodern-workspace/public-surface.d.ts +37 -0
- package/dist/types/ultramodern-workspace/routes.d.ts +25 -0
- package/dist/types/ultramodern-workspace/types.d.ts +197 -0
- package/dist/types/ultramodern-workspace/versions.d.ts +40 -0
- package/dist/types/ultramodern-workspace/workspace-scripts.d.ts +10 -0
- package/dist/types/ultramodern-workspace/write-workspace.d.ts +4 -0
- package/package.json +58 -15
- package/template-workspace/.github/workflows/ultramodern-workspace-gates.yml.handlebars +23 -10
- package/template-workspace/.mise.toml.handlebars +1 -0
- package/template-workspace/{AGENTS.md → AGENTS.md.handlebars} +20 -9
- package/template-workspace/README.md.handlebars +85 -14
- package/template-workspace/lefthook.yml +18 -4
- package/template-workspace/pnpm-workspace.yaml.handlebars +45 -0
- package/template-workspace/scripts/bootstrap-agent-skills.mjs +69 -75
- package/template-workspace/scripts/setup-agent-reference-repos.mjs +8 -6
- package/templates/app/shell-frame.tsx +49 -0
- package/templates/app/ultramodern-route-head.tsx.handlebars +142 -0
- package/templates/packages/shared-contracts-index.ts +466 -0
- package/templates/workspace-scripts/assert-mf-types.mjs.handlebars +69 -0
- package/templates/workspace-scripts/check-ultramodern-i18n-boundaries.mjs +9 -0
- package/templates/workspace-scripts/generate-public-surface-assets.mjs +529 -0
- package/templates/workspace-scripts/proof-cloudflare-version.mjs +125 -0
- package/templates/workspace-scripts/ultramodern-cloudflare-proof.mjs +851 -0
- package/templates/workspace-scripts/ultramodern-performance-readiness.config.mjs +7 -0
- package/templates/workspace-scripts/ultramodern-performance-readiness.mjs +223 -0
- package/templates/workspace-scripts/validate-ultramodern-workspace.mjs.handlebars +986 -0
- package/dist/index.js +0 -6625
- package/dist/types/ultramodern-workspace.d.ts +0 -31
- 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 -105
- package/template/api/effect/index.ts.handlebars +0 -34
- package/template/api/lambda/hello.ts.handlebars +0 -6
- package/template/config/public/locales/cs/translation.json +0 -39
- package/template/config/public/locales/en/translation.json +0 -39
- package/template/lefthook.yml +0 -10
- package/template/modern.config.ts.handlebars +0 -71
- package/template/oxfmt.config.ts +0 -15
- package/template/oxlint.config.ts +0 -19
- package/template/package.json.handlebars +0 -66
- package/template/pnpm-workspace.yaml +0 -29
- 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 -94
- package/template/scripts/validate-ultramodern.mjs.handlebars +0 -538
- 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 -211
- package/template/src/routes/index.css.handlebars +0 -129
- 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 -78
- package/template/tsconfig.json +0 -120
- package/template-workspace/pnpm-workspace.yaml +0 -35
|
@@ -0,0 +1,621 @@
|
|
|
1
|
+
import { execFileSync } from "node:child_process";
|
|
2
|
+
import node_fs from "node:fs";
|
|
3
|
+
import node_path from "node:path";
|
|
4
|
+
import node_readline from "node:readline";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
import { resolveCreatePackageRoot } from "./create-package-root.js";
|
|
7
|
+
import { i18n, localeKeys } from "./locale/index.js";
|
|
8
|
+
import { BLEEDINGDEV_CREATE_PACKAGE, BLEEDINGDEV_FRAMEWORK_VERSION_ENV, BLEEDINGDEV_PACKAGE_NAME_PREFIX, BLEEDINGDEV_PACKAGE_SCOPE, WORKSPACE_PACKAGE_VERSION } from "./ultramodern-package-source.js";
|
|
9
|
+
import { addUltramodernVertical, generateUltramodernWorkspace, planUltramodernVertical } from "./ultramodern-workspace/index.js";
|
|
10
|
+
const src_dirname = node_path.dirname(fileURLToPath(import.meta.url));
|
|
11
|
+
const createPackageRoot = resolveCreatePackageRoot(src_dirname);
|
|
12
|
+
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.-]+)?$/;
|
|
13
|
+
const LEGACY_MODERN_JS_FLAG = '--legacy-modern-js';
|
|
14
|
+
const LEGACY_MODERN_JS_CONFIRMATION = 'USE LEGACY MODERN.JS';
|
|
15
|
+
const WORKSPACE_PROTOCOL_FLAG = '--workspace';
|
|
16
|
+
const DRY_RUN_FLAG = '--dry-run';
|
|
17
|
+
const VERTICAL_FLAG = '--vertical';
|
|
18
|
+
const VERTICAL_NAME_FLAG = '--vertical-name';
|
|
19
|
+
const CODESMITH_OVERLAY_FLAG = '--codesmith-overlay';
|
|
20
|
+
const BFF_FLAG = '--bff';
|
|
21
|
+
const BFF_RUNTIME_OPTION = '--bff-runtime';
|
|
22
|
+
const SUPPORTED_BFF_RUNTIMES = [
|
|
23
|
+
'effect'
|
|
24
|
+
];
|
|
25
|
+
const REGISTRY_LOOKUP_TIMEOUT_MS = 15000;
|
|
26
|
+
function getOptionValue(args, names) {
|
|
27
|
+
for (const name of names){
|
|
28
|
+
const prefix = `${name}=`;
|
|
29
|
+
const byEquals = args.find((arg)=>arg.startsWith(prefix));
|
|
30
|
+
if (byEquals) return byEquals.slice(prefix.length);
|
|
31
|
+
const index = args.findIndex((arg)=>arg === name);
|
|
32
|
+
if (-1 !== index && args[index + 1] && !args[index + 1].startsWith('-')) return args[index + 1];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const detectLanguage = ()=>{
|
|
36
|
+
const lang = getOptionValue(process.argv.slice(2), [
|
|
37
|
+
'--lang',
|
|
38
|
+
'-l'
|
|
39
|
+
]);
|
|
40
|
+
if ('zh' === lang) return 'zh';
|
|
41
|
+
return 'en';
|
|
42
|
+
};
|
|
43
|
+
i18n.changeLanguage({
|
|
44
|
+
locale: detectLanguage()
|
|
45
|
+
});
|
|
46
|
+
function readCreatePackageJson() {
|
|
47
|
+
const createPackageJson = node_path.join(createPackageRoot, 'package.json');
|
|
48
|
+
return JSON.parse(node_fs.readFileSync(createPackageJson, 'utf-8'));
|
|
49
|
+
}
|
|
50
|
+
function isBleedingDevCreatePackage(createPackage) {
|
|
51
|
+
return createPackage.name === BLEEDINGDEV_CREATE_PACKAGE;
|
|
52
|
+
}
|
|
53
|
+
function getBleedingDevFrameworkVersion(createPackage, fallbackVersion) {
|
|
54
|
+
const frameworkVersion = createPackage.ultramodern?.frameworkVersion;
|
|
55
|
+
return 'string' == typeof frameworkVersion && frameworkVersion.length > 0 ? frameworkVersion : fallbackVersion;
|
|
56
|
+
}
|
|
57
|
+
function showVersion() {
|
|
58
|
+
const createPackage = readCreatePackageJson();
|
|
59
|
+
const name = createPackage.name || '@modern-js/create';
|
|
60
|
+
const version = createPackage.version || 'unknown';
|
|
61
|
+
console.log(i18n.t(localeKeys.version.message, {
|
|
62
|
+
name,
|
|
63
|
+
version
|
|
64
|
+
}));
|
|
65
|
+
process.exit(0);
|
|
66
|
+
}
|
|
67
|
+
function showHelp() {
|
|
68
|
+
console.log(i18n.t(localeKeys.help.title));
|
|
69
|
+
console.log(i18n.t(localeKeys.help.description));
|
|
70
|
+
console.log('');
|
|
71
|
+
console.log(i18n.t(localeKeys.help.usage));
|
|
72
|
+
console.log(i18n.t(localeKeys.help.usageExample));
|
|
73
|
+
console.log('');
|
|
74
|
+
console.log(i18n.t(localeKeys.help.options));
|
|
75
|
+
console.log(i18n.t(localeKeys.help.optionHelp));
|
|
76
|
+
console.log(i18n.t(localeKeys.help.optionVersion));
|
|
77
|
+
console.log(i18n.t(localeKeys.help.optionLang));
|
|
78
|
+
console.log(i18n.t(localeKeys.help.optionTailwind));
|
|
79
|
+
console.log(i18n.t(localeKeys.help.optionBff));
|
|
80
|
+
console.log(i18n.t(localeKeys.help.optionBffRuntime));
|
|
81
|
+
console.log(i18n.t(localeKeys.help.optionWorkspace));
|
|
82
|
+
console.log(i18n.t(localeKeys.help.optionUltramodernPackageSource));
|
|
83
|
+
console.log(i18n.t(localeKeys.help.optionUltramodernPackageVersion));
|
|
84
|
+
console.log(i18n.t(localeKeys.help.optionUltramodernPackageRegistry));
|
|
85
|
+
console.log(i18n.t(localeKeys.help.optionUltramodernPackageScope));
|
|
86
|
+
console.log(i18n.t(localeKeys.help.optionUltramodernPackageNamePrefix));
|
|
87
|
+
console.log(i18n.t(localeKeys.help.optionVertical));
|
|
88
|
+
console.log(i18n.t(localeKeys.help.optionVerticalName));
|
|
89
|
+
console.log(i18n.t(localeKeys.help.optionDryRun));
|
|
90
|
+
console.log(i18n.t(localeKeys.help.optionCodeSmithOverlay));
|
|
91
|
+
console.log(i18n.t(localeKeys.help.optionLegacyModernJs));
|
|
92
|
+
console.log('');
|
|
93
|
+
console.log(i18n.t(localeKeys.help.examples));
|
|
94
|
+
console.log(i18n.t(localeKeys.help.example1));
|
|
95
|
+
console.log(i18n.t(localeKeys.help.example2));
|
|
96
|
+
console.log(i18n.t(localeKeys.help.example3));
|
|
97
|
+
console.log(i18n.t(localeKeys.help.example4));
|
|
98
|
+
console.log(i18n.t(localeKeys.help.example5));
|
|
99
|
+
console.log(i18n.t(localeKeys.help.example6));
|
|
100
|
+
console.log(i18n.t(localeKeys.help.example7));
|
|
101
|
+
console.log(i18n.t(localeKeys.help.example8));
|
|
102
|
+
console.log(i18n.t(localeKeys.help.example9));
|
|
103
|
+
console.log(i18n.t(localeKeys.help.example10));
|
|
104
|
+
console.log('');
|
|
105
|
+
console.log(i18n.t(localeKeys.help.moreInfo));
|
|
106
|
+
console.log('');
|
|
107
|
+
process.exit(0);
|
|
108
|
+
}
|
|
109
|
+
function promptInput(question) {
|
|
110
|
+
const rl = node_readline.createInterface({
|
|
111
|
+
input: process.stdin,
|
|
112
|
+
output: process.stdout
|
|
113
|
+
});
|
|
114
|
+
return new Promise((resolve)=>{
|
|
115
|
+
rl.question(question, (answer)=>{
|
|
116
|
+
rl.close();
|
|
117
|
+
resolve(answer.trim());
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
function detectLegacyModernJsFlag(args) {
|
|
122
|
+
if (args.some((arg)=>arg.startsWith(`${LEGACY_MODERN_JS_FLAG}=`))) {
|
|
123
|
+
console.error(`${LEGACY_MODERN_JS_FLAG} does not accept a value.`);
|
|
124
|
+
process.exit(1);
|
|
125
|
+
}
|
|
126
|
+
return args.includes(LEGACY_MODERN_JS_FLAG);
|
|
127
|
+
}
|
|
128
|
+
function stripLegacyModernJsArgs(args) {
|
|
129
|
+
return args.filter((arg)=>arg !== LEGACY_MODERN_JS_FLAG);
|
|
130
|
+
}
|
|
131
|
+
async function confirmLegacyModernJsSetup() {
|
|
132
|
+
console.error('');
|
|
133
|
+
console.error(i18n.t(localeKeys.message.legacyModernJsWarning));
|
|
134
|
+
console.error('');
|
|
135
|
+
const answer = await promptInput(i18n.t(localeKeys.prompt.legacyModernJsConfirmation, {
|
|
136
|
+
confirmation: LEGACY_MODERN_JS_CONFIRMATION
|
|
137
|
+
}));
|
|
138
|
+
if (answer !== LEGACY_MODERN_JS_CONFIRMATION) {
|
|
139
|
+
console.error(i18n.t(localeKeys.error.legacyModernJsNotConfirmed));
|
|
140
|
+
process.exit(1);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
function delegateLegacyModernJsSetup(args) {
|
|
144
|
+
const forwardedArgs = stripLegacyModernJsArgs(args);
|
|
145
|
+
if (commandExists('pnpm')) return void runSetupCommand('pnpm', [
|
|
146
|
+
'dlx',
|
|
147
|
+
'@modern-js/create',
|
|
148
|
+
...forwardedArgs
|
|
149
|
+
], {
|
|
150
|
+
stdio: 'inherit'
|
|
151
|
+
});
|
|
152
|
+
if (commandExists('npx')) return void runSetupCommand('npx', [
|
|
153
|
+
'@modern-js/create',
|
|
154
|
+
...forwardedArgs
|
|
155
|
+
], {
|
|
156
|
+
stdio: 'inherit'
|
|
157
|
+
});
|
|
158
|
+
throw new Error('Legacy Modern.js setup requires pnpm or npx to run @modern-js/create.');
|
|
159
|
+
}
|
|
160
|
+
function detectBffRuntime(args) {
|
|
161
|
+
if (args.some((arg)=>arg.startsWith(`${BFF_FLAG}=`))) {
|
|
162
|
+
console.error(`${BFF_FLAG} does not accept a value. Use: ${BFF_RUNTIME_OPTION} <runtime>`);
|
|
163
|
+
process.exit(1);
|
|
164
|
+
}
|
|
165
|
+
const runtimeRequested = args.some((arg)=>arg === BFF_RUNTIME_OPTION || arg.startsWith(`${BFF_RUNTIME_OPTION}=`));
|
|
166
|
+
if (!runtimeRequested) return 'effect';
|
|
167
|
+
const runtime = getOptionValue(args, [
|
|
168
|
+
BFF_RUNTIME_OPTION
|
|
169
|
+
]);
|
|
170
|
+
if (!runtime) {
|
|
171
|
+
console.error(`${BFF_RUNTIME_OPTION} requires a value (supported: ${SUPPORTED_BFF_RUNTIMES.join(', ')})`);
|
|
172
|
+
process.exit(1);
|
|
173
|
+
}
|
|
174
|
+
if (!SUPPORTED_BFF_RUNTIMES.includes(runtime)) {
|
|
175
|
+
console.error(`Unsupported BFF runtime "${runtime}". UltraModern workspaces scaffold an Effect BFF for every MicroVertical (supported: ${SUPPORTED_BFF_RUNTIMES.join(', ')}).`);
|
|
176
|
+
process.exit(1);
|
|
177
|
+
}
|
|
178
|
+
return runtime;
|
|
179
|
+
}
|
|
180
|
+
function detectTailwindFlag() {
|
|
181
|
+
const args = process.argv.slice(2);
|
|
182
|
+
return !args.includes('--no-tailwind');
|
|
183
|
+
}
|
|
184
|
+
function detectExplicitTailwindFlag() {
|
|
185
|
+
const args = process.argv.slice(2);
|
|
186
|
+
if (args.includes('--no-tailwind')) return false;
|
|
187
|
+
if (args.includes('--tailwind')) return true;
|
|
188
|
+
}
|
|
189
|
+
function collectPositionalArgs(args) {
|
|
190
|
+
const optionWithValue = new Set([
|
|
191
|
+
'--lang',
|
|
192
|
+
'-l',
|
|
193
|
+
BFF_RUNTIME_OPTION,
|
|
194
|
+
'--ultramodern-package-source',
|
|
195
|
+
'--ultramodern-package-version',
|
|
196
|
+
'--ultramodern-package-registry',
|
|
197
|
+
'--ultramodern-package-scope',
|
|
198
|
+
'--ultramodern-package-name-prefix',
|
|
199
|
+
VERTICAL_NAME_FLAG,
|
|
200
|
+
CODESMITH_OVERLAY_FLAG
|
|
201
|
+
]);
|
|
202
|
+
const optionWithoutValue = new Set([
|
|
203
|
+
'--help',
|
|
204
|
+
'-h',
|
|
205
|
+
'--version',
|
|
206
|
+
'-v',
|
|
207
|
+
'--tailwind',
|
|
208
|
+
'--no-tailwind',
|
|
209
|
+
BFF_FLAG,
|
|
210
|
+
WORKSPACE_PROTOCOL_FLAG,
|
|
211
|
+
DRY_RUN_FLAG,
|
|
212
|
+
VERTICAL_FLAG,
|
|
213
|
+
LEGACY_MODERN_JS_FLAG
|
|
214
|
+
]);
|
|
215
|
+
const positionalArgs = [];
|
|
216
|
+
for(let i = 0; i < args.length; i++){
|
|
217
|
+
const arg = args[i];
|
|
218
|
+
if (!optionWithoutValue.has(arg)) {
|
|
219
|
+
if (optionWithValue.has(arg)) {
|
|
220
|
+
i += 1;
|
|
221
|
+
continue;
|
|
222
|
+
}
|
|
223
|
+
if (!(arg.startsWith('--lang=') || arg.startsWith(`${BFF_RUNTIME_OPTION}=`) || 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=') || arg.startsWith(`${VERTICAL_FLAG}=`) || arg.startsWith(`${VERTICAL_NAME_FLAG}=`) || arg.startsWith(`${CODESMITH_OVERLAY_FLAG}=`))) positionalArgs.push(arg);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return positionalArgs;
|
|
227
|
+
}
|
|
228
|
+
function readRequiredVerticalNameValue(args, index) {
|
|
229
|
+
const value = args[index + 1];
|
|
230
|
+
if (!value || value.startsWith('-')) {
|
|
231
|
+
console.error(i18n.t(localeKeys.error.verticalNameMissing));
|
|
232
|
+
process.exit(1);
|
|
233
|
+
}
|
|
234
|
+
return value;
|
|
235
|
+
}
|
|
236
|
+
function resolveVerticalCliInput(args) {
|
|
237
|
+
const candidates = [];
|
|
238
|
+
let addVertical = false;
|
|
239
|
+
for(let i = 0; i < args.length; i++){
|
|
240
|
+
const arg = args[i];
|
|
241
|
+
if (arg === VERTICAL_FLAG) {
|
|
242
|
+
addVertical = true;
|
|
243
|
+
continue;
|
|
244
|
+
}
|
|
245
|
+
if (arg.startsWith(`${VERTICAL_FLAG}=`)) {
|
|
246
|
+
addVertical = true;
|
|
247
|
+
candidates.push({
|
|
248
|
+
value: arg.slice(`${VERTICAL_FLAG}=`.length),
|
|
249
|
+
source: `${VERTICAL_FLAG}=<name>`
|
|
250
|
+
});
|
|
251
|
+
continue;
|
|
252
|
+
}
|
|
253
|
+
if (arg === VERTICAL_NAME_FLAG) {
|
|
254
|
+
addVertical = true;
|
|
255
|
+
candidates.push({
|
|
256
|
+
value: readRequiredVerticalNameValue(args, i),
|
|
257
|
+
source: VERTICAL_NAME_FLAG
|
|
258
|
+
});
|
|
259
|
+
i += 1;
|
|
260
|
+
continue;
|
|
261
|
+
}
|
|
262
|
+
if (arg.startsWith(`${VERTICAL_NAME_FLAG}=`)) {
|
|
263
|
+
addVertical = true;
|
|
264
|
+
candidates.push({
|
|
265
|
+
value: arg.slice(`${VERTICAL_NAME_FLAG}=`.length),
|
|
266
|
+
source: `${VERTICAL_NAME_FLAG}=<name>`
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
if (!addVertical) return {
|
|
271
|
+
addVertical: false
|
|
272
|
+
};
|
|
273
|
+
const positionalArgs = collectPositionalArgs(args);
|
|
274
|
+
if (positionalArgs.length > 1) {
|
|
275
|
+
console.error(`Unexpected positional argument: ${positionalArgs[1]}`);
|
|
276
|
+
process.exit(1);
|
|
277
|
+
}
|
|
278
|
+
if (positionalArgs[0]) candidates.push({
|
|
279
|
+
value: positionalArgs[0],
|
|
280
|
+
source: 'positional argument'
|
|
281
|
+
});
|
|
282
|
+
const emptyCandidate = candidates.find((candidate)=>'' === candidate.value);
|
|
283
|
+
if (!candidates.length || emptyCandidate) {
|
|
284
|
+
console.error(i18n.t(localeKeys.error.verticalNameMissing));
|
|
285
|
+
process.exit(1);
|
|
286
|
+
}
|
|
287
|
+
const [firstCandidate] = candidates;
|
|
288
|
+
const disagreement = candidates.find((candidate)=>candidate.value !== firstCandidate.value);
|
|
289
|
+
if (disagreement) {
|
|
290
|
+
console.error(i18n.t(localeKeys.error.verticalNameAmbiguous, {
|
|
291
|
+
firstName: firstCandidate.value,
|
|
292
|
+
firstSource: firstCandidate.source,
|
|
293
|
+
secondName: disagreement.value,
|
|
294
|
+
secondSource: disagreement.source
|
|
295
|
+
}));
|
|
296
|
+
process.exit(1);
|
|
297
|
+
}
|
|
298
|
+
return {
|
|
299
|
+
addVertical: true,
|
|
300
|
+
name: firstCandidate.value
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
function detectDryRunFlag(args) {
|
|
304
|
+
if (args.some((arg)=>arg.startsWith(`${DRY_RUN_FLAG}=`))) {
|
|
305
|
+
console.error(`${DRY_RUN_FLAG} does not accept a value.`);
|
|
306
|
+
process.exit(1);
|
|
307
|
+
}
|
|
308
|
+
return args.includes(DRY_RUN_FLAG);
|
|
309
|
+
}
|
|
310
|
+
function detectCodeSmithOverlays(args) {
|
|
311
|
+
const overlays = [];
|
|
312
|
+
for(let i = 0; i < args.length; i++){
|
|
313
|
+
const arg = args[i];
|
|
314
|
+
if (arg === CODESMITH_OVERLAY_FLAG) {
|
|
315
|
+
const generator = args[i + 1];
|
|
316
|
+
if (!generator || generator.startsWith('-')) {
|
|
317
|
+
console.error(`${CODESMITH_OVERLAY_FLAG} requires a package or path.`);
|
|
318
|
+
process.exit(1);
|
|
319
|
+
}
|
|
320
|
+
overlays.push({
|
|
321
|
+
generator
|
|
322
|
+
});
|
|
323
|
+
i += 1;
|
|
324
|
+
continue;
|
|
325
|
+
}
|
|
326
|
+
if (arg.startsWith(`${CODESMITH_OVERLAY_FLAG}=`)) {
|
|
327
|
+
const generator = arg.slice(`${CODESMITH_OVERLAY_FLAG}=`.length);
|
|
328
|
+
if (!generator) {
|
|
329
|
+
console.error(`${CODESMITH_OVERLAY_FLAG} requires a package or path.`);
|
|
330
|
+
process.exit(1);
|
|
331
|
+
}
|
|
332
|
+
overlays.push({
|
|
333
|
+
generator
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
return overlays.length > 0 ? overlays : void 0;
|
|
338
|
+
}
|
|
339
|
+
function detectUltramodernPackageSource(args, defaultPackageVersion, createPackage) {
|
|
340
|
+
const bleedingDevDefaults = isBleedingDevCreatePackage(createPackage);
|
|
341
|
+
const strategy = getOptionValue(args, [
|
|
342
|
+
'--ultramodern-package-source'
|
|
343
|
+
]) ?? (bleedingDevDefaults ? 'install' : 'workspace');
|
|
344
|
+
if ('workspace' !== strategy && 'install' !== strategy) {
|
|
345
|
+
console.error('--ultramodern-package-source must be "workspace" or "install"');
|
|
346
|
+
process.exit(1);
|
|
347
|
+
}
|
|
348
|
+
const packageSourceStrategy = strategy;
|
|
349
|
+
const explicitRegistry = getOptionValue(args, [
|
|
350
|
+
'--ultramodern-package-registry'
|
|
351
|
+
]);
|
|
352
|
+
const aliasScope = getOptionValue(args, [
|
|
353
|
+
'--ultramodern-package-scope'
|
|
354
|
+
]) ?? (bleedingDevDefaults && 'install' === packageSourceStrategy && !explicitRegistry ? BLEEDINGDEV_PACKAGE_SCOPE : void 0);
|
|
355
|
+
return {
|
|
356
|
+
strategy: packageSourceStrategy,
|
|
357
|
+
modernPackageVersion: getOptionValue(args, [
|
|
358
|
+
'--ultramodern-package-version'
|
|
359
|
+
]) ?? defaultPackageVersion,
|
|
360
|
+
registry: explicitRegistry,
|
|
361
|
+
aliasScope,
|
|
362
|
+
aliasPackageNamePrefix: getOptionValue(args, [
|
|
363
|
+
'--ultramodern-package-name-prefix'
|
|
364
|
+
]) ?? (aliasScope ? BLEEDINGDEV_PACKAGE_NAME_PREFIX : void 0)
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
function hasExplicitUltramodernPackageSource(args, value) {
|
|
368
|
+
const configuredValue = getOptionValue(args, [
|
|
369
|
+
'--ultramodern-package-source'
|
|
370
|
+
]);
|
|
371
|
+
return value ? configuredValue === value : void 0 !== configuredValue;
|
|
372
|
+
}
|
|
373
|
+
function readBleedingDevFrameworkVersionFromRegistry(fallbackVersion) {
|
|
374
|
+
const envVersion = process.env[BLEEDINGDEV_FRAMEWORK_VERSION_ENV]?.trim();
|
|
375
|
+
if (envVersion) {
|
|
376
|
+
if (!semverPattern.test(envVersion)) {
|
|
377
|
+
console.error(`${BLEEDINGDEV_FRAMEWORK_VERSION_ENV} must be a valid semver version`);
|
|
378
|
+
process.exit(1);
|
|
379
|
+
}
|
|
380
|
+
return envVersion;
|
|
381
|
+
}
|
|
382
|
+
try {
|
|
383
|
+
const rawVersion = runSetupCommand('npm', [
|
|
384
|
+
'view',
|
|
385
|
+
`${BLEEDINGDEV_CREATE_PACKAGE}@latest`,
|
|
386
|
+
'ultramodern.frameworkVersion',
|
|
387
|
+
'--json'
|
|
388
|
+
], {
|
|
389
|
+
timeoutMs: REGISTRY_LOOKUP_TIMEOUT_MS
|
|
390
|
+
}).trim();
|
|
391
|
+
const version = JSON.parse(rawVersion);
|
|
392
|
+
if ('string' == typeof version && semverPattern.test(version)) return version;
|
|
393
|
+
} catch {}
|
|
394
|
+
console.warn([
|
|
395
|
+
`Could not resolve ${BLEEDINGDEV_CREATE_PACKAGE}@latest ultramodern.frameworkVersion from the npm registry.`,
|
|
396
|
+
`Falling back to the packaged framework version ${fallbackVersion}.`,
|
|
397
|
+
`Pass ${WORKSPACE_PROTOCOL_FLAG} to use local workspace protocol dependencies,`,
|
|
398
|
+
'or pass --ultramodern-package-version with the exact BleedingDev framework cohort.'
|
|
399
|
+
].join(' '));
|
|
400
|
+
return fallbackVersion;
|
|
401
|
+
}
|
|
402
|
+
function resolveInstallBackedPackageSource(args, createPackage, packageSource) {
|
|
403
|
+
const explicitVersion = getOptionValue(args, [
|
|
404
|
+
'--ultramodern-package-version'
|
|
405
|
+
]);
|
|
406
|
+
const explicitRegistry = getOptionValue(args, [
|
|
407
|
+
'--ultramodern-package-registry'
|
|
408
|
+
]);
|
|
409
|
+
const aliasScope = getOptionValue(args, [
|
|
410
|
+
'--ultramodern-package-scope'
|
|
411
|
+
]) ?? packageSource.aliasScope ?? (explicitRegistry ? void 0 : BLEEDINGDEV_PACKAGE_SCOPE);
|
|
412
|
+
return {
|
|
413
|
+
...packageSource,
|
|
414
|
+
strategy: 'install',
|
|
415
|
+
modernPackageVersion: explicitVersion ?? (isBleedingDevCreatePackage(createPackage) ? packageSource.modernPackageVersion : readBleedingDevFrameworkVersionFromRegistry(packageSource.modernPackageVersion)),
|
|
416
|
+
aliasScope,
|
|
417
|
+
aliasPackageNamePrefix: getOptionValue(args, [
|
|
418
|
+
'--ultramodern-package-name-prefix'
|
|
419
|
+
]) ?? packageSource.aliasPackageNamePrefix ?? (aliasScope ? BLEEDINGDEV_PACKAGE_NAME_PREFIX : void 0)
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
function resolveWorkspacePackageSource(args, createPackage, packageSource) {
|
|
423
|
+
const workspaceProtocolRequested = args.includes(WORKSPACE_PROTOCOL_FLAG);
|
|
424
|
+
if (workspaceProtocolRequested && hasExplicitUltramodernPackageSource(args, 'install')) {
|
|
425
|
+
console.error(`${WORKSPACE_PROTOCOL_FLAG} conflicts with --ultramodern-package-source=install`);
|
|
426
|
+
process.exit(1);
|
|
427
|
+
}
|
|
428
|
+
if (workspaceProtocolRequested || hasExplicitUltramodernPackageSource(args, 'workspace')) return {
|
|
429
|
+
...packageSource,
|
|
430
|
+
strategy: 'workspace',
|
|
431
|
+
modernPackageVersion: WORKSPACE_PACKAGE_VERSION
|
|
432
|
+
};
|
|
433
|
+
return resolveInstallBackedPackageSource(args, createPackage, packageSource);
|
|
434
|
+
}
|
|
435
|
+
function runSetupCommand(command, args, options = {}) {
|
|
436
|
+
return execFileSync(command, args, {
|
|
437
|
+
cwd: options.cwd,
|
|
438
|
+
encoding: 'utf-8',
|
|
439
|
+
stdio: options.stdio ?? [
|
|
440
|
+
'ignore',
|
|
441
|
+
'pipe',
|
|
442
|
+
'pipe'
|
|
443
|
+
],
|
|
444
|
+
timeout: options.timeoutMs
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
function commandExists(command) {
|
|
448
|
+
try {
|
|
449
|
+
runSetupCommand(command, [
|
|
450
|
+
'--version'
|
|
451
|
+
], {
|
|
452
|
+
stdio: 'ignore'
|
|
453
|
+
});
|
|
454
|
+
return true;
|
|
455
|
+
} catch {
|
|
456
|
+
return false;
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
function assertGitAvailableForGeneratedProject() {
|
|
460
|
+
if (commandExists('git')) return;
|
|
461
|
+
throw new Error('Git is required for UltraModern setup. Install git yourself (for example "brew install git" or "sudo apt-get install git") and rerun create. This tool never installs system packages on your behalf.');
|
|
462
|
+
}
|
|
463
|
+
function isInsideGitWorkTree(targetDir) {
|
|
464
|
+
try {
|
|
465
|
+
return 'true' === runSetupCommand('git', [
|
|
466
|
+
'rev-parse',
|
|
467
|
+
'--is-inside-work-tree'
|
|
468
|
+
], {
|
|
469
|
+
cwd: targetDir
|
|
470
|
+
}).trim();
|
|
471
|
+
} catch {
|
|
472
|
+
return false;
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
function initializeGeneratedGitRepository(targetDir) {
|
|
476
|
+
assertGitAvailableForGeneratedProject();
|
|
477
|
+
if (isInsideGitWorkTree(targetDir)) return;
|
|
478
|
+
try {
|
|
479
|
+
runSetupCommand('git', [
|
|
480
|
+
'init',
|
|
481
|
+
'-b',
|
|
482
|
+
'main'
|
|
483
|
+
], {
|
|
484
|
+
cwd: targetDir,
|
|
485
|
+
stdio: 'inherit'
|
|
486
|
+
});
|
|
487
|
+
} catch {
|
|
488
|
+
runSetupCommand('git', [
|
|
489
|
+
'init'
|
|
490
|
+
], {
|
|
491
|
+
cwd: targetDir,
|
|
492
|
+
stdio: 'inherit'
|
|
493
|
+
});
|
|
494
|
+
runSetupCommand('git', [
|
|
495
|
+
'branch',
|
|
496
|
+
'-M',
|
|
497
|
+
'main'
|
|
498
|
+
], {
|
|
499
|
+
cwd: targetDir,
|
|
500
|
+
stdio: 'inherit'
|
|
501
|
+
});
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
function isDirectoryEmpty(dirPath) {
|
|
505
|
+
if (!node_fs.existsSync(dirPath)) return false;
|
|
506
|
+
try {
|
|
507
|
+
const files = node_fs.readdirSync(dirPath);
|
|
508
|
+
return 0 === files.length;
|
|
509
|
+
} catch {
|
|
510
|
+
return false;
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
async function getProjectName() {
|
|
514
|
+
const args = process.argv.slice(2);
|
|
515
|
+
const positionalArgs = collectPositionalArgs(args);
|
|
516
|
+
if (positionalArgs.length > 1) {
|
|
517
|
+
console.error(`Unexpected positional argument: ${positionalArgs[1]}`);
|
|
518
|
+
process.exit(1);
|
|
519
|
+
}
|
|
520
|
+
const projectNameArg = positionalArgs[0];
|
|
521
|
+
if (projectNameArg) {
|
|
522
|
+
if ('.' === projectNameArg) return {
|
|
523
|
+
name: node_path.basename(process.cwd()),
|
|
524
|
+
useCurrentDir: true
|
|
525
|
+
};
|
|
526
|
+
return {
|
|
527
|
+
name: projectNameArg,
|
|
528
|
+
useCurrentDir: false
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
const currentDir = process.cwd();
|
|
532
|
+
if (isDirectoryEmpty(currentDir)) return {
|
|
533
|
+
name: node_path.basename(currentDir),
|
|
534
|
+
useCurrentDir: true
|
|
535
|
+
};
|
|
536
|
+
const projectName = await promptInput(i18n.t(localeKeys.prompt.projectName));
|
|
537
|
+
if (!projectName) {
|
|
538
|
+
console.error(i18n.t(localeKeys.error.projectNameEmpty));
|
|
539
|
+
process.exit(1);
|
|
540
|
+
}
|
|
541
|
+
return {
|
|
542
|
+
name: projectName,
|
|
543
|
+
useCurrentDir: false
|
|
544
|
+
};
|
|
545
|
+
}
|
|
546
|
+
async function main() {
|
|
547
|
+
const args = process.argv.slice(2);
|
|
548
|
+
if (args.includes('--help') || args.includes('-h')) return void showHelp();
|
|
549
|
+
if (args.includes('--version') || args.includes('-v')) return void showVersion();
|
|
550
|
+
if (detectLegacyModernJsFlag(args)) {
|
|
551
|
+
await confirmLegacyModernJsSetup();
|
|
552
|
+
delegateLegacyModernJsSetup(args);
|
|
553
|
+
return;
|
|
554
|
+
}
|
|
555
|
+
detectBffRuntime(args);
|
|
556
|
+
const dryRun = detectDryRunFlag(args);
|
|
557
|
+
const verticalInput = resolveVerticalCliInput(args);
|
|
558
|
+
const overlays = detectCodeSmithOverlays(args);
|
|
559
|
+
if (dryRun && !verticalInput.addVertical) {
|
|
560
|
+
console.error(`${DRY_RUN_FLAG} is currently supported only with ${VERTICAL_FLAG}`);
|
|
561
|
+
process.exit(1);
|
|
562
|
+
}
|
|
563
|
+
if (!dryRun) console.log(`\n${i18n.t(localeKeys.message.welcome)}\n`);
|
|
564
|
+
const createPackage = readCreatePackageJson();
|
|
565
|
+
const version = createPackage.version || 'latest';
|
|
566
|
+
const ultramodernPackageVersion = isBleedingDevCreatePackage(createPackage) ? getBleedingDevFrameworkVersion(createPackage, version) : version;
|
|
567
|
+
if (verticalInput.addVertical) {
|
|
568
|
+
const overridePackageSource = args.some((arg)=>arg.startsWith('--ultramodern-package-')) ? detectUltramodernPackageSource(args, ultramodernPackageVersion, createPackage) : void 0;
|
|
569
|
+
const verticalOptions = {
|
|
570
|
+
workspaceRoot: process.cwd(),
|
|
571
|
+
name: verticalInput.name,
|
|
572
|
+
modernVersion: version,
|
|
573
|
+
enableTailwind: detectExplicitTailwindFlag(),
|
|
574
|
+
overlays,
|
|
575
|
+
packageSource: overridePackageSource
|
|
576
|
+
};
|
|
577
|
+
if (dryRun) return void console.log(JSON.stringify(planUltramodernVertical(verticalOptions), null, 2));
|
|
578
|
+
addUltramodernVertical(verticalOptions);
|
|
579
|
+
const dim = '\x1b[2m\x1b[3m';
|
|
580
|
+
const reset = '\x1b[0m';
|
|
581
|
+
console.log(`${i18n.t(localeKeys.message.success)}\n`);
|
|
582
|
+
console.log(`${dim} pnpm check${reset}\n`);
|
|
583
|
+
return;
|
|
584
|
+
}
|
|
585
|
+
const { name: projectName, useCurrentDir } = await getProjectName();
|
|
586
|
+
const targetDir = useCurrentDir ? process.cwd() : node_path.isAbsolute(projectName) ? projectName : node_path.resolve(process.cwd(), projectName);
|
|
587
|
+
const generatedPackageName = useCurrentDir || node_path.isAbsolute(projectName) ? node_path.basename(targetDir) : projectName;
|
|
588
|
+
if (node_fs.existsSync(targetDir)) {
|
|
589
|
+
const files = node_fs.readdirSync(targetDir);
|
|
590
|
+
if (files.length > 0) {
|
|
591
|
+
console.error(i18n.t(localeKeys.error.directoryExists, {
|
|
592
|
+
projectName
|
|
593
|
+
}));
|
|
594
|
+
process.exit(1);
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
const packageSource = resolveWorkspacePackageSource(args, createPackage, detectUltramodernPackageSource(args, ultramodernPackageVersion, createPackage));
|
|
598
|
+
generateUltramodernWorkspace({
|
|
599
|
+
targetDir,
|
|
600
|
+
packageName: generatedPackageName,
|
|
601
|
+
modernVersion: version,
|
|
602
|
+
enableTailwind: detectTailwindFlag(),
|
|
603
|
+
overlays,
|
|
604
|
+
packageSource
|
|
605
|
+
});
|
|
606
|
+
initializeGeneratedGitRepository(targetDir);
|
|
607
|
+
const dim = '\x1b[2m\x1b[3m';
|
|
608
|
+
const reset = '\x1b[0m';
|
|
609
|
+
console.log(`${i18n.t(localeKeys.message.success)}\n`);
|
|
610
|
+
console.log(i18n.t(localeKeys.message.nextSteps));
|
|
611
|
+
if (!useCurrentDir) console.log(`${dim} ${i18n.t(localeKeys.message.step1, {
|
|
612
|
+
projectName
|
|
613
|
+
})}${reset}`);
|
|
614
|
+
console.log(`${dim} ${i18n.t(localeKeys.message.step2)}${reset}`);
|
|
615
|
+
console.log(`${dim} pnpm check${reset}`);
|
|
616
|
+
console.log(`${dim} ${i18n.t(localeKeys.message.step3)}${reset}\n`);
|
|
617
|
+
}
|
|
618
|
+
main().catch((error)=>{
|
|
619
|
+
console.error(i18n.t(localeKeys.error.createFailed), error);
|
|
620
|
+
process.exit(1);
|
|
621
|
+
});
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
const EN_LOCALE = {
|
|
2
|
+
prompt: {
|
|
3
|
+
projectName: 'Please enter project name: ',
|
|
4
|
+
legacyModernJsConfirmation: 'Type "{confirmation}" to continue with the original Modern.js setup: '
|
|
5
|
+
},
|
|
6
|
+
error: {
|
|
7
|
+
projectNameEmpty: 'Error: Project name cannot be empty',
|
|
8
|
+
directoryExists: 'Error: Directory "{projectName}" already exists and is not empty',
|
|
9
|
+
verticalNameMissing: 'Error: Missing MicroVertical name. Use <name> --vertical, --vertical=<name>, or --vertical-name <name>.',
|
|
10
|
+
verticalNameAmbiguous: 'Error: Ambiguous MicroVertical name: "{firstName}" from {firstSource} does not match "{secondName}" from {secondSource}.',
|
|
11
|
+
legacyModernJsNotConfirmed: 'Aborted. UltraModern.js remains the default unattended setup.',
|
|
12
|
+
createFailed: 'Error creating project:'
|
|
13
|
+
},
|
|
14
|
+
message: {
|
|
15
|
+
welcome: '🚀 Welcome to UltraModern.js',
|
|
16
|
+
success: '✨ Created successfully!',
|
|
17
|
+
nextSteps: '📋 Next steps:',
|
|
18
|
+
step1: 'cd {projectName}',
|
|
19
|
+
step2: 'pnpm install',
|
|
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:\na structured SuperApp workspace, presetUltramodern, TanStack Router,\nEffect BFF, Tailwind CSS v4, and the BleedingDev package cohort.\nThe original Modern.js setup is a dangerous opt-in path.\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
|
22
|
+
},
|
|
23
|
+
help: {
|
|
24
|
+
title: '🚀 UltraModern.js Project Creator',
|
|
25
|
+
description: 'Create a new UltraModern.js SuperApp workspace with the full quality baseline by default',
|
|
26
|
+
usage: '📖 Usage:',
|
|
27
|
+
usageExample: ' pnpm dlx @bleedingdev/modern-js-create [project-name] [options]',
|
|
28
|
+
options: '⚙️ Options:',
|
|
29
|
+
optionHelp: ' -h, --help Display this help message',
|
|
30
|
+
optionVersion: ' -v, --version Display version information',
|
|
31
|
+
optionLang: ' -l, --lang Set the language (en default; zh opt-in)',
|
|
32
|
+
optionTailwind: ' --no-tailwind Disable default Tailwind CSS v4 workspace styling',
|
|
33
|
+
optionBff: ' --bff Keep the default Effect BFF scaffolding (every MicroVertical ships an Effect BFF)',
|
|
34
|
+
optionBffRuntime: ' --bff-runtime Select the BFF runtime for scaffolded MicroVerticals (supported: effect; default: effect)',
|
|
35
|
+
optionWorkspace: ' --workspace Use workspace protocol for @modern-js dependencies (for local monorepo testing)',
|
|
36
|
+
optionUltramodernPackageSource: ' --ultramodern-package-source Select UltraModern package source (workspace or install; BleedingDev defaults to install aliases)',
|
|
37
|
+
optionUltramodernPackageVersion: ' --ultramodern-package-version Pin the exact BleedingDev framework cohort for install package sources',
|
|
38
|
+
optionUltramodernPackageRegistry: ' --ultramodern-package-registry npm registry URL used for install package sources',
|
|
39
|
+
optionUltramodernPackageScope: ' --ultramodern-package-scope Publish scope for npm alias installs (for example bleedingdev)',
|
|
40
|
+
optionUltramodernPackageNamePrefix: ' --ultramodern-package-name-prefix Prefix for npm alias package names (default: modern-js-)',
|
|
41
|
+
optionVertical: ' --vertical[=<name>] Mutate the current existing UltraModern workspace and wire a MicroVertical',
|
|
42
|
+
optionVerticalName: ' --vertical-name <name> Explicit MicroVertical name for automation-friendly workspace mutation',
|
|
43
|
+
optionDryRun: ' --dry-run Preview a MicroVertical mutation plan without writing files (supported with --vertical)',
|
|
44
|
+
optionCodeSmithOverlay: ' --codesmith-overlay <package-or-path> Run an explicit CodeSmith overlay after generation',
|
|
45
|
+
optionLegacyModernJs: ' --legacy-modern-js Opt into the original Modern.js setup after a large warning and typed confirmation',
|
|
46
|
+
examples: '💡 Examples:',
|
|
47
|
+
example1: ' pnpm dlx @bleedingdev/modern-js-create my-workspace',
|
|
48
|
+
example2: ' pnpm dlx @bleedingdev/modern-js-create my-workspace --lang zh',
|
|
49
|
+
example3: ' pnpm dlx @bleedingdev/modern-js-create my-workspace --no-tailwind',
|
|
50
|
+
example4: ' pnpm dlx @bleedingdev/modern-js-create --help',
|
|
51
|
+
example5: ' pnpm dlx @bleedingdev/modern-js-create .',
|
|
52
|
+
example6: ' pnpm dlx @bleedingdev/modern-js-create my-workspace --workspace',
|
|
53
|
+
example7: ' pnpm dlx @bleedingdev/modern-js-create catalog --vertical',
|
|
54
|
+
example8: ' pnpm dlx @bleedingdev/modern-js-create --vertical=catalog',
|
|
55
|
+
example9: ' pnpm dlx @bleedingdev/modern-js-create catalog --vertical --dry-run',
|
|
56
|
+
example10: ' pnpm dlx @bleedingdev/modern-js-create catalog --vertical --codesmith-overlay ./overlay-generator',
|
|
57
|
+
moreInfo: '📚 Learn more: https://modernjs.dev'
|
|
58
|
+
},
|
|
59
|
+
version: {
|
|
60
|
+
message: '{name} version: {version}'
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
export { EN_LOCALE };
|