@modern-js/create 3.9.3 → 3.10.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/dist/index.js +18 -62
- package/package.json +4 -5
- package/template/.rstack/hooks/pre-commit +3 -0
- package/template/.vscode/extensions.json +3 -0
- package/template/AGENTS.md +8 -0
- package/template/README.md +2 -3
- package/template/package.json.handlebars +6 -3
- package/template/rstack.config.mts +13 -0
- package/template/src/routes/index.css +14 -3
- package/template/tsconfig.json +1 -0
- package/template/CLAUDE.md +0 -1
- package/template/biome.json +0 -37
- package/template/src/modern-app-env.d.ts +0 -1
package/dist/index.js
CHANGED
|
@@ -21,12 +21,13 @@ function getLocaleLanguage() {
|
|
|
21
21
|
const detector = new I18CLILanguageDetector();
|
|
22
22
|
return detector.detect();
|
|
23
23
|
}
|
|
24
|
-
const CLAUDE_IMPORT = '@AGENTS.md';
|
|
25
24
|
const markers = (name)=>({
|
|
26
25
|
begin: `<!-- BEGIN:${name} -->`,
|
|
27
26
|
end: `<!-- END:${name} -->`
|
|
28
27
|
});
|
|
29
|
-
function applyAgentsMd(
|
|
28
|
+
function applyAgentsMd(options) {
|
|
29
|
+
const { targetDir, block, markerName } = options;
|
|
30
|
+
if (!node_fs.existsSync(targetDir)) throw new Error(`target directory does not exist: ${targetDir}`);
|
|
30
31
|
const { begin, end } = markers(markerName);
|
|
31
32
|
const file = node_path.join(targetDir, 'AGENTS.md');
|
|
32
33
|
if (!node_fs.existsSync(file)) {
|
|
@@ -46,25 +47,6 @@ function applyAgentsMd(targetDir, block, markerName) {
|
|
|
46
47
|
node_fs.writeFileSync(file, rest ? `${block}\n\n${rest}` : `${block}\n`, 'utf-8');
|
|
47
48
|
return 'added';
|
|
48
49
|
}
|
|
49
|
-
function applyClaudeMd(targetDir) {
|
|
50
|
-
const file = node_path.join(targetDir, 'CLAUDE.md');
|
|
51
|
-
if (!node_fs.existsSync(file)) {
|
|
52
|
-
node_fs.writeFileSync(file, `${CLAUDE_IMPORT}\n`, 'utf-8');
|
|
53
|
-
return 'created';
|
|
54
|
-
}
|
|
55
|
-
const content = node_fs.readFileSync(file, 'utf-8');
|
|
56
|
-
if (content.split('\n').some((line)=>line.trim() === CLAUDE_IMPORT)) return 'unchanged';
|
|
57
|
-
node_fs.writeFileSync(file, `${CLAUDE_IMPORT}\n\n${content.replace(/^\s*/, '')}`, 'utf-8');
|
|
58
|
-
return 'linked';
|
|
59
|
-
}
|
|
60
|
-
function applyAgentFiles(options) {
|
|
61
|
-
const { targetDir, block, markerName } = options;
|
|
62
|
-
if (!node_fs.existsSync(targetDir)) throw new Error(`target directory does not exist: ${targetDir}`);
|
|
63
|
-
return {
|
|
64
|
-
agents: applyAgentsMd(targetDir, block, markerName),
|
|
65
|
-
claude: applyClaudeMd(targetDir)
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
50
|
const PKG = '@modern-js/app-tools';
|
|
69
51
|
const DOCS_PATH = 'node_modules/@modern-js/app-tools/docs/';
|
|
70
52
|
const BUNDLED_SINCE = '3.8.0';
|
|
@@ -569,7 +551,7 @@ const EN_LOCALE = {
|
|
|
569
551
|
message: {
|
|
570
552
|
welcome: '🚀 Welcome to Modern.js',
|
|
571
553
|
success: '✨ Created successfully!',
|
|
572
|
-
agentsMd: '✔ AGENTS.md
|
|
554
|
+
agentsMd: '✔ AGENTS.md generated — AI coding agents will read it automatically. (--no-agents-md to skip)',
|
|
573
555
|
nextSteps: '📋 Next steps:',
|
|
574
556
|
step1: 'cd {projectName}',
|
|
575
557
|
step2: 'pnpm install',
|
|
@@ -579,7 +561,6 @@ const EN_LOCALE = {
|
|
|
579
561
|
created: '✔ Created {file}',
|
|
580
562
|
updatedBlock: '✔ Updated the modernjs-agent-rules block in {file}',
|
|
581
563
|
addedBlock: '✔ Added the modernjs-agent-rules block to the top of {file}',
|
|
582
|
-
linked: '✔ Added the `@AGENTS.md` import to {file}',
|
|
583
564
|
unchanged: '• {file} is already up to date',
|
|
584
565
|
done: '✨ Done — AI coding agents will read {location}.',
|
|
585
566
|
targetNotFound: 'Error: target directory "{dir}" does not exist',
|
|
@@ -596,13 +577,13 @@ const EN_LOCALE = {
|
|
|
596
577
|
optionVersion: ' -v, --version Display version information',
|
|
597
578
|
optionLang: ' -l, --lang Set the language (zh or en)',
|
|
598
579
|
optionSub: ' -s, --sub Mark as a subproject (package in monorepo)',
|
|
599
|
-
optionNoAgentsMd: ' --no-agents-md Skip generating AGENTS.md
|
|
600
|
-
optionAgentsMdOnly: ' --agents-md-only Only add/refresh AGENTS.md
|
|
580
|
+
optionNoAgentsMd: ' --no-agents-md Skip generating AGENTS.md for AI coding agents',
|
|
581
|
+
optionAgentsMdOnly: ' --agents-md-only Only add/refresh AGENTS.md in the current project (no scaffolding)',
|
|
601
582
|
examples: '💡 Examples:',
|
|
602
583
|
example1: ' create my-app',
|
|
603
584
|
example2: ' create my-app --lang zh',
|
|
604
585
|
example3: ' create my-app --sub',
|
|
605
|
-
example4: ' create --agents-md-only (add/refresh AGENTS.md
|
|
586
|
+
example4: ' create --agents-md-only (add/refresh AGENTS.md in an existing project)',
|
|
606
587
|
moreInfo: '📚 Learn more: https://modernjs.dev'
|
|
607
588
|
},
|
|
608
589
|
version: {
|
|
@@ -622,7 +603,7 @@ const ZH_LOCALE = {
|
|
|
622
603
|
message: {
|
|
623
604
|
welcome: '🚀 欢迎使用 Modern.js',
|
|
624
605
|
success: '✨ 创建成功!',
|
|
625
|
-
agentsMd: '✔ 已生成 AGENTS.md
|
|
606
|
+
agentsMd: '✔ 已生成 AGENTS.md —— AI 编码助手会自动读取。(--no-agents-md 可跳过)',
|
|
626
607
|
nextSteps: '📋 下一步:',
|
|
627
608
|
step1: 'cd {projectName}',
|
|
628
609
|
step2: 'pnpm install',
|
|
@@ -632,7 +613,6 @@ const ZH_LOCALE = {
|
|
|
632
613
|
created: '✔ 已创建 {file}',
|
|
633
614
|
updatedBlock: '✔ 已更新 {file} 中的 modernjs-agent-rules 块',
|
|
634
615
|
addedBlock: '✔ 已在 {file} 顶部添加 modernjs-agent-rules 块',
|
|
635
|
-
linked: '✔ 已向 {file} 添加 `@AGENTS.md` 引用',
|
|
636
616
|
unchanged: '• {file} 已是最新',
|
|
637
617
|
done: '✨ 完成 —— AI 编码助手会读取 {location}。',
|
|
638
618
|
targetNotFound: '错误: 目标目录 "{dir}" 不存在',
|
|
@@ -649,13 +629,13 @@ const ZH_LOCALE = {
|
|
|
649
629
|
optionVersion: ' -v, --version 显示版本信息',
|
|
650
630
|
optionLang: ' -l, --lang 设置语言 (zh 或 en)',
|
|
651
631
|
optionSub: ' -s, --sub 标记为子项目(monorepo 中的子包)',
|
|
652
|
-
optionNoAgentsMd: ' --no-agents-md 跳过生成 AGENTS.md
|
|
653
|
-
optionAgentsMdOnly: ' --agents-md-only 仅为当前项目补齐/更新 AGENTS.md
|
|
632
|
+
optionNoAgentsMd: ' --no-agents-md 跳过生成 AGENTS.md(AI 编码助手指引文件)',
|
|
633
|
+
optionAgentsMdOnly: ' --agents-md-only 仅为当前项目补齐/更新 AGENTS.md(不创建项目)',
|
|
654
634
|
examples: '💡 示例:',
|
|
655
635
|
example1: ' create my-app',
|
|
656
636
|
example2: ' create my-app --lang zh',
|
|
657
637
|
example3: ' create my-app --sub',
|
|
658
|
-
example4: ' create --agents-md-only (为已有项目补齐/更新 AGENTS.md
|
|
638
|
+
example4: ' create --agents-md-only (为已有项目补齐/更新 AGENTS.md)',
|
|
659
639
|
moreInfo: '📚 更多信息: https://modernjs.dev'
|
|
660
640
|
},
|
|
661
641
|
version: {
|
|
@@ -674,11 +654,6 @@ const AGENTS_MESSAGES = {
|
|
|
674
654
|
added: localeKeys.agentsCmd.addedBlock,
|
|
675
655
|
unchanged: localeKeys.agentsCmd.unchanged
|
|
676
656
|
};
|
|
677
|
-
const CLAUDE_MESSAGES = {
|
|
678
|
-
created: localeKeys.agentsCmd.created,
|
|
679
|
-
linked: localeKeys.agentsCmd.linked,
|
|
680
|
-
unchanged: localeKeys.agentsCmd.unchanged
|
|
681
|
-
};
|
|
682
657
|
function runAgentsMd(_templateDir, targetDir) {
|
|
683
658
|
if (!node_fs.existsSync(targetDir)) {
|
|
684
659
|
console.error(i18n.t(localeKeys.agentsCmd.targetNotFound, {
|
|
@@ -696,17 +671,14 @@ function runAgentsMd(_templateDir, targetDir) {
|
|
|
696
671
|
since: "3.8.0"
|
|
697
672
|
}));
|
|
698
673
|
const block = buildBlock(MARKER_NAME);
|
|
699
|
-
const result =
|
|
674
|
+
const result = applyAgentsMd({
|
|
700
675
|
targetDir,
|
|
701
676
|
block,
|
|
702
677
|
markerName: MARKER_NAME
|
|
703
678
|
});
|
|
704
|
-
console.log(i18n.t(AGENTS_MESSAGES[result
|
|
679
|
+
console.log(i18n.t(AGENTS_MESSAGES[result], {
|
|
705
680
|
file: 'AGENTS.md'
|
|
706
681
|
}));
|
|
707
|
-
console.log(i18n.t(CLAUDE_MESSAGES[result.claude], {
|
|
708
|
-
file: 'CLAUDE.md'
|
|
709
|
-
}));
|
|
710
682
|
console.log('');
|
|
711
683
|
console.log(i18n.t(localeKeys.agentsCmd.done, {
|
|
712
684
|
location: DOCS_PATH
|
|
@@ -883,19 +855,6 @@ async function main() {
|
|
|
883
855
|
const targetPackageJson = node_path.join(targetDir, 'package.json');
|
|
884
856
|
const packageJson = JSON.parse(node_fs.readFileSync(targetPackageJson, 'utf-8'));
|
|
885
857
|
packageJson.name = projectName;
|
|
886
|
-
if (isSubproject) {
|
|
887
|
-
delete packageJson['lint-staged'];
|
|
888
|
-
delete packageJson['simple-git-hooks'];
|
|
889
|
-
if (packageJson.scripts) {
|
|
890
|
-
delete packageJson.scripts.prepare;
|
|
891
|
-
delete packageJson.scripts.lint;
|
|
892
|
-
}
|
|
893
|
-
if (packageJson.devDependencies) {
|
|
894
|
-
delete packageJson.devDependencies['lint-staged'];
|
|
895
|
-
delete packageJson.devDependencies['simple-git-hooks'];
|
|
896
|
-
delete packageJson.devDependencies['@biomejs/biome'];
|
|
897
|
-
}
|
|
898
|
-
}
|
|
899
858
|
node_fs.writeFileSync(targetPackageJson, `${JSON.stringify(packageJson, null, 2)}\n`);
|
|
900
859
|
const dim = '\x1b[2m\x1b[3m';
|
|
901
860
|
const reset = '\x1b[0m';
|
|
@@ -913,16 +872,13 @@ function copyTemplate(src, dest, options) {
|
|
|
913
872
|
recursive: true
|
|
914
873
|
});
|
|
915
874
|
const excludeInSubproject = [
|
|
875
|
+
'.rstack',
|
|
876
|
+
'.vscode',
|
|
916
877
|
'.gitignore.handlebars',
|
|
917
|
-
'
|
|
878
|
+
'rstack.config.mts',
|
|
918
879
|
'.npmrc',
|
|
919
880
|
'.nvmrc',
|
|
920
|
-
'AGENTS.md'
|
|
921
|
-
'CLAUDE.md'
|
|
922
|
-
];
|
|
923
|
-
const agentFiles = [
|
|
924
|
-
'AGENTS.md',
|
|
925
|
-
'CLAUDE.md'
|
|
881
|
+
'AGENTS.md'
|
|
926
882
|
];
|
|
927
883
|
function copyRecursive(srcDir, destDir) {
|
|
928
884
|
const entries = node_fs.readdirSync(srcDir, {
|
|
@@ -930,7 +886,7 @@ function copyTemplate(src, dest, options) {
|
|
|
930
886
|
});
|
|
931
887
|
for (const entry of entries){
|
|
932
888
|
if (options.isSubproject && excludeInSubproject.includes(entry.name)) continue;
|
|
933
|
-
if (options.noAgentsMd &&
|
|
889
|
+
if (options.noAgentsMd && 'AGENTS.md' === entry.name) continue;
|
|
934
890
|
const srcPath = node_path.join(srcDir, entry.name);
|
|
935
891
|
let destPath = node_path.join(destDir, entry.name);
|
|
936
892
|
if (entry.isDirectory()) {
|
package/package.json
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"engines": {
|
|
20
20
|
"node": ">=20"
|
|
21
21
|
},
|
|
22
|
-
"version": "3.
|
|
22
|
+
"version": "3.10.0",
|
|
23
23
|
"main": "./dist/index.js",
|
|
24
24
|
"bin": {
|
|
25
25
|
"create": "./bin/run.js"
|
|
@@ -33,11 +33,10 @@
|
|
|
33
33
|
"bin.js"
|
|
34
34
|
],
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@rslib/core": "1.0.1",
|
|
37
36
|
"@types/node": "^20",
|
|
38
37
|
"tsx": "^4.23.15",
|
|
39
38
|
"typescript": "^5",
|
|
40
|
-
"@modern-js/i18n-utils": "3.
|
|
39
|
+
"@modern-js/i18n-utils": "3.10.0",
|
|
41
40
|
"@modern-js/rslib": "2.68.10",
|
|
42
41
|
"@scripts/rstest-config": "2.66.0"
|
|
43
42
|
},
|
|
@@ -46,8 +45,8 @@
|
|
|
46
45
|
"access": "public"
|
|
47
46
|
},
|
|
48
47
|
"scripts": {
|
|
49
|
-
"build": "
|
|
50
|
-
"dev": "
|
|
48
|
+
"build": "rs lib",
|
|
49
|
+
"dev": "rs lib -w",
|
|
51
50
|
"start": "node ./dist/index.js",
|
|
52
51
|
"test": "rstest"
|
|
53
52
|
}
|
package/template/AGENTS.md
CHANGED
|
@@ -18,3 +18,11 @@ from memory on Modern.js configuration, APIs or directory conventions.
|
|
|
18
18
|
- Installing ordinary npm packages (unrelated to Modern.js)
|
|
19
19
|
|
|
20
20
|
<!-- END:modernjs-agent-rules -->
|
|
21
|
+
|
|
22
|
+
# Rstack CLI
|
|
23
|
+
|
|
24
|
+
This project uses Rstack CLI as its JS toolchain:
|
|
25
|
+
|
|
26
|
+
- Read the docs linked from `node_modules/rstack/docs/llms.txt` when needed
|
|
27
|
+
- Online docs: https://rstack.rs/llms.txt
|
|
28
|
+
- Run `rs -h` for CLI help
|
package/template/README.md
CHANGED
|
@@ -10,10 +10,10 @@ pnpm install
|
|
|
10
10
|
|
|
11
11
|
## Get Started
|
|
12
12
|
|
|
13
|
-
Start the
|
|
13
|
+
Start the development server:
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
|
-
pnpm
|
|
16
|
+
pnpm dev
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
Build the app for production:
|
|
@@ -29,4 +29,3 @@ pnpm serve
|
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
For more information, see the [Modern.js documentation](https://modernjs.dev/en).
|
|
32
|
-
|
|
@@ -5,10 +5,13 @@
|
|
|
5
5
|
"dev": "modern dev",
|
|
6
6
|
"build": "modern build",
|
|
7
7
|
"serve": "modern serve"{{#unless isSubproject}},
|
|
8
|
-
"
|
|
8
|
+
"prepare": "rs hooks",
|
|
9
|
+
"check": "rs check",
|
|
10
|
+
"lint": "rs lint",
|
|
11
|
+
"format": "rs fmt"{{/unless}}
|
|
9
12
|
},
|
|
10
13
|
"engines": {
|
|
11
|
-
"node": ">=
|
|
14
|
+
"node": "^22.18.0 || >=24.3.0"
|
|
12
15
|
},
|
|
13
16
|
"dependencies": {
|
|
14
17
|
"@modern-js/runtime": "{{version}}",
|
|
@@ -18,7 +21,7 @@
|
|
|
18
21
|
"devDependencies": {
|
|
19
22
|
"@modern-js/app-tools": "{{version}}",
|
|
20
23
|
"@modern-js/tsconfig": "{{version}}"{{#unless isSubproject}},
|
|
21
|
-
"
|
|
24
|
+
"rstack": "0.8.2"{{/unless}},
|
|
22
25
|
"typescript": "~5.7.3",
|
|
23
26
|
"@types/node": "^20",
|
|
24
27
|
"@types/react": "^19.1.8",
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Configuration guide: https://rstack.rs/config
|
|
2
|
+
import { define } from 'rstack';
|
|
3
|
+
|
|
4
|
+
define.lint(({ js, ts }) => [js.configs.recommended, ts.configs.recommended]);
|
|
5
|
+
|
|
6
|
+
define.staged({
|
|
7
|
+
'*.{js,jsx,ts,tsx,cjs,mjs,cts,mts}': ['rs lint', 'rs fmt'],
|
|
8
|
+
'*.{md,mdx,json,json5,yml,yaml,css,less,scss,html}': 'rs fmt',
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
define.fmt({
|
|
12
|
+
singleQuote: true,
|
|
13
|
+
});
|
|
@@ -2,7 +2,12 @@ html,
|
|
|
2
2
|
body {
|
|
3
3
|
padding: 0;
|
|
4
4
|
margin: 0;
|
|
5
|
-
font-family:
|
|
5
|
+
font-family:
|
|
6
|
+
PingFang SC,
|
|
7
|
+
Hiragino Sans GB,
|
|
8
|
+
Microsoft YaHei,
|
|
9
|
+
Arial,
|
|
10
|
+
sans-serif;
|
|
6
11
|
background: linear-gradient(to bottom, transparent, #fff) #eceeef;
|
|
7
12
|
}
|
|
8
13
|
|
|
@@ -65,8 +70,14 @@ main {
|
|
|
65
70
|
padding: 0.6rem 0.9rem;
|
|
66
71
|
font-size: 1.05rem;
|
|
67
72
|
font-family:
|
|
68
|
-
Menlo,
|
|
69
|
-
|
|
73
|
+
Menlo,
|
|
74
|
+
Monaco,
|
|
75
|
+
Lucida Console,
|
|
76
|
+
Liberation Mono,
|
|
77
|
+
DejaVu Sans Mono,
|
|
78
|
+
Bitstream Vera Sans Mono,
|
|
79
|
+
Courier New,
|
|
80
|
+
monospace;
|
|
70
81
|
}
|
|
71
82
|
|
|
72
83
|
.container-box .grid {
|
package/template/tsconfig.json
CHANGED
package/template/CLAUDE.md
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
@AGENTS.md
|
package/template/biome.json
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
|
|
3
|
-
"vcs": {
|
|
4
|
-
"enabled": true,
|
|
5
|
-
"defaultBranch": "main",
|
|
6
|
-
"clientKind": "git",
|
|
7
|
-
"useIgnoreFile": true
|
|
8
|
-
},
|
|
9
|
-
"formatter": {
|
|
10
|
-
"enabled": true,
|
|
11
|
-
"indentStyle": "space"
|
|
12
|
-
},
|
|
13
|
-
"javascript": {
|
|
14
|
-
"formatter": {
|
|
15
|
-
"quoteStyle": "single",
|
|
16
|
-
"arrowParentheses": "asNeeded",
|
|
17
|
-
"jsxQuoteStyle": "double",
|
|
18
|
-
"lineWidth": 80
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
"linter": {
|
|
22
|
-
"enabled": true,
|
|
23
|
-
"rules": {
|
|
24
|
-
"recommended": true,
|
|
25
|
-
"suspicious": {
|
|
26
|
-
"noDuplicateFontNames": "off"
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
"organizeImports": {
|
|
31
|
-
"enabled": true
|
|
32
|
-
},
|
|
33
|
-
"files": {
|
|
34
|
-
"ignoreUnknown": true,
|
|
35
|
-
"ignore": [".vscode/**/*", "node_modules/**/*", "dist/**/*"]
|
|
36
|
-
}
|
|
37
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/// <reference types='@modern-js/app-tools/types' />
|