@component-hook/create-app 1.5.1 → 1.7.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 +2 -1
- package/dist/index.mjs +22 -23
- package/package.json +14 -12
package/README.md
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Scaffolding a basic `typescript` project.
|
|
4
4
|
|
|
5
5
|
> **Compatibility Note:**
|
|
6
|
+
>
|
|
6
7
|
> Requires [Node.js](https://nodejs.org/en/) version 20.19.6+. However, some templates require a higher Node.js version to work, please upgrade if your package manager warns about it.
|
|
7
8
|
|
|
8
9
|
<p>
|
|
@@ -62,7 +63,7 @@ This project leverages modern frontend practices and tooling, covering developme
|
|
|
62
63
|
|
|
63
64
|
### Code Quality
|
|
64
65
|
|
|
65
|
-
- Enforces consistent code style with `ESLint` and `
|
|
66
|
+
- Enforces consistent code style with `ESLint` and `oxfmt`.
|
|
66
67
|
- Enhanced with:
|
|
67
68
|
- `husky`: For Git hooks.
|
|
68
69
|
- `lint-staged`: Only runs linters on staged files.
|
package/dist/index.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import minimist from "minimist";
|
|
|
8
8
|
import ora from "ora";
|
|
9
9
|
import colors from "picocolors";
|
|
10
10
|
import prompts from "prompts";
|
|
11
|
-
|
|
11
|
+
// src/constants.ts
|
|
12
12
|
const DEFAULT_PROJECT_NAME = "basic-project";
|
|
13
13
|
const TEMPLATES = ["vue", "react"];
|
|
14
14
|
const GITHUB_ACTIONS = "GitHub Actions";
|
|
@@ -18,8 +18,23 @@ const CI = [
|
|
|
18
18
|
"gitlab-ci",
|
|
19
19
|
"none"
|
|
20
20
|
];
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
/** template 內以底線開頭存放、scaffold 時改回原名的檔案,避免被母 repo 的工具或 npm 當成自己的設定 */
|
|
22
|
+
const RENAME_FILES = {
|
|
23
|
+
_gitignore: ".gitignore",
|
|
24
|
+
"_gitlab-ci.yml": ".gitlab-ci.yml",
|
|
25
|
+
"_lint-staged.config.js": "lint-staged.config.js"
|
|
26
|
+
};
|
|
27
|
+
/** 依選擇的 CI 服務,從 template 排除不需要的 CI 檔案 */
|
|
28
|
+
const CI_FILTERS = {
|
|
29
|
+
"github-actions": [".gitlab", "_gitlab-ci.yml"],
|
|
30
|
+
"gitlab-ci": [".github"],
|
|
31
|
+
none: [
|
|
32
|
+
".github",
|
|
33
|
+
".gitlab",
|
|
34
|
+
"_gitlab-ci.yml"
|
|
35
|
+
]
|
|
36
|
+
};
|
|
37
|
+
// src/utils.ts
|
|
23
38
|
function formatTargetDir(targetDir) {
|
|
24
39
|
if (!targetDir) return targetDir;
|
|
25
40
|
targetDir = targetDir.trim();
|
|
@@ -67,8 +82,7 @@ function getCiArtContent(ci = "") {
|
|
|
67
82
|
if (!ciName) return "";
|
|
68
83
|
return `- **CI/CD**: Integrates \`${ciName}\` for automated testing and deployment.`;
|
|
69
84
|
}
|
|
70
|
-
|
|
71
|
-
//#region src/prompts.ts
|
|
85
|
+
// src/prompts.ts
|
|
72
86
|
function builtinTemplate(template) {
|
|
73
87
|
return template && TEMPLATES.includes(template);
|
|
74
88
|
}
|
|
@@ -176,8 +190,7 @@ function operationPrompts({ targetDir, template, ci }) {
|
|
|
176
190
|
ciPrompt
|
|
177
191
|
], { onCancel });
|
|
178
192
|
}
|
|
179
|
-
|
|
180
|
-
//#region src/index.ts
|
|
193
|
+
// src/index.ts
|
|
181
194
|
const cwd = process.cwd();
|
|
182
195
|
const argv = minimist(process.argv.slice(2), {
|
|
183
196
|
default: { help: false },
|
|
@@ -188,19 +201,6 @@ const argv = minimist(process.argv.slice(2), {
|
|
|
188
201
|
},
|
|
189
202
|
string: ["_"]
|
|
190
203
|
});
|
|
191
|
-
const renameFiles = {
|
|
192
|
-
_gitignore: ".gitignore",
|
|
193
|
-
"_gitlab-ci.yml": ".gitlab-ci.yml"
|
|
194
|
-
};
|
|
195
|
-
const ciFilters = {
|
|
196
|
-
"github-actions": [".gitlab", "_gitlab-ci.yml"],
|
|
197
|
-
"gitlab-ci": [".github"],
|
|
198
|
-
none: [
|
|
199
|
-
".github",
|
|
200
|
-
".gitlab",
|
|
201
|
-
"_gitlab-ci.yml"
|
|
202
|
-
]
|
|
203
|
-
};
|
|
204
204
|
const helpMessage = `
|
|
205
205
|
Usage: create-component-hook [project name] [options]
|
|
206
206
|
|
|
@@ -225,10 +225,10 @@ async function writePackageJson(root, dir, packageName) {
|
|
|
225
225
|
}
|
|
226
226
|
async function copyFolder(root, dir, packageName, ci) {
|
|
227
227
|
const files = await readdir(dir);
|
|
228
|
-
const ignoreFiles = /* @__PURE__ */ new Set(["package.json", ...
|
|
228
|
+
const ignoreFiles = /* @__PURE__ */ new Set(["package.json", ...CI_FILTERS[ci] ?? CI_FILTERS.none]);
|
|
229
229
|
const filterFiles = files.filter((file) => !ignoreFiles.has(file));
|
|
230
230
|
const rewriteOrCopyFile = async (file) => {
|
|
231
|
-
const targetPath = path.join(root,
|
|
231
|
+
const targetPath = path.join(root, RENAME_FILES[file] ?? file);
|
|
232
232
|
const templatePath = path.join(dir, file);
|
|
233
233
|
if (file.endsWith(".art")) {
|
|
234
234
|
const name = file.endsWith(".js.art") || file.endsWith(".ts.art") ? packageName : toUpperCasePackageName(packageName);
|
|
@@ -308,5 +308,4 @@ async function bootstrap() {
|
|
|
308
308
|
}
|
|
309
309
|
}
|
|
310
310
|
bootstrap();
|
|
311
|
-
//#endregion
|
|
312
311
|
export {};
|
package/package.json
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@component-hook/create-app",
|
|
3
|
-
"
|
|
4
|
-
"version": "1.5.1",
|
|
3
|
+
"version": "1.7.0",
|
|
5
4
|
"description": "Scaffolding a basic typescript project",
|
|
6
|
-
"author": "Tzuyi",
|
|
7
|
-
"license": "MIT",
|
|
8
5
|
"homepage": "https://github.com/tzuyi0817/component-hook/tree/master/packages/create-app#readme",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://github.com/tzuyi0817/component-hook/issues"
|
|
8
|
+
},
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"author": "Tzuyi",
|
|
9
11
|
"repository": {
|
|
10
12
|
"type": "git",
|
|
11
13
|
"url": "git+https://github.com/tzuyi0817/component-hook.git",
|
|
12
14
|
"directory": "packages/create-app"
|
|
13
15
|
},
|
|
14
|
-
"bugs": {
|
|
15
|
-
"url": "https://github.com/tzuyi0817/component-hook/issues"
|
|
16
|
-
},
|
|
17
16
|
"bin": {
|
|
18
17
|
"create-component-hook": "bin/index.js"
|
|
19
18
|
},
|
|
@@ -22,12 +21,10 @@
|
|
|
22
21
|
"dist",
|
|
23
22
|
"template-*"
|
|
24
23
|
],
|
|
25
|
-
"
|
|
26
|
-
"node": ">=20.19.6"
|
|
27
|
-
},
|
|
24
|
+
"type": "module",
|
|
28
25
|
"dependencies": {
|
|
29
26
|
"art-template": "^4.13.4",
|
|
30
|
-
"fs-extra": "^11.4.
|
|
27
|
+
"fs-extra": "^11.4.1",
|
|
31
28
|
"minimist": "^1.2.8",
|
|
32
29
|
"ora": "^9.4.1",
|
|
33
30
|
"picocolors": "^1.1.1",
|
|
@@ -38,9 +35,14 @@
|
|
|
38
35
|
"@types/minimist": "^1.2.5",
|
|
39
36
|
"@types/prompts": "^2.4.9"
|
|
40
37
|
},
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=20.19.6"
|
|
40
|
+
},
|
|
41
41
|
"scripts": {
|
|
42
42
|
"dev": "tsdown --watch",
|
|
43
43
|
"build": "tsdown",
|
|
44
|
-
"typecheck": "tsc --noEmit"
|
|
44
|
+
"typecheck": "tsc --noEmit",
|
|
45
|
+
"smoke": "node scripts/smoke.ts",
|
|
46
|
+
"sync": "node scripts/sync-template/index.ts"
|
|
45
47
|
}
|
|
46
48
|
}
|