@component-hook/create-app 1.5.0 → 1.5.1

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.d.mts CHANGED
@@ -1 +1 @@
1
- export { };
1
+ export {}
package/dist/index.mjs CHANGED
@@ -43,8 +43,8 @@ function toUpperCasePackageName(projectName) {
43
43
  function getPkgManagerInfo() {
44
44
  const userAgent = process.env.npm_config_user_agent;
45
45
  if (!userAgent) return;
46
- const [pkgManager] = userAgent.split(" ");
47
- const [name, version] = pkgManager.split("/");
46
+ const [pkgManager] = userAgent.split(" ", 1);
47
+ const [name, version] = pkgManager.split("/", 2);
48
48
  return {
49
49
  name,
50
50
  version
@@ -82,92 +82,98 @@ function styleTitle(title) {
82
82
  return colors.bold(colors.magenta(title));
83
83
  }
84
84
  function operationPrompts({ targetDir, template, ci }) {
85
- return prompts([
86
- {
87
- type: targetDir ? null : "text",
88
- name: "projectName",
89
- message: styleTitle("Project name:"),
90
- initial: DEFAULT_PROJECT_NAME
91
- },
92
- {
93
- type: (nameAnswer) => {
94
- const dir = nameAnswer ?? targetDir;
95
- return existsSync(dir) && !isEmptyFolder(dir) ? "select" : null;
96
- },
97
- name: "overwrite",
98
- message: (nameAnswer) => {
99
- const dirName = nameAnswer ?? targetDir;
100
- return styleTitle(`${dirName === "." ? "current directory" : `Target directory "${dirName}"`} is not empty. Please choose how to proceed:`);
101
- },
102
- initial: 0,
103
- choices: [
104
- {
105
- title: "Cancel operation",
106
- value: "cancel"
107
- },
108
- {
109
- title: "Remove existing files and continue",
110
- value: "overwrite"
111
- },
112
- {
113
- title: "Ignore files and continue",
114
- value: "ignore"
115
- }
116
- ]
85
+ const projectName = {
86
+ type: targetDir ? null : "text",
87
+ name: "projectName",
88
+ message: styleTitle("Project name:"),
89
+ initial: DEFAULT_PROJECT_NAME
90
+ };
91
+ const overwrite = {
92
+ type: (nameAnswer) => {
93
+ const dir = nameAnswer ?? targetDir;
94
+ return existsSync(dir) && !isEmptyFolder(dir) ? "select" : null;
117
95
  },
118
- {
119
- type: (overwriteAnswer) => {
120
- if (overwriteAnswer === "cancel") onCancel();
121
- return null;
122
- },
123
- name: "overwriteChecker"
96
+ name: "overwrite",
97
+ message: (nameAnswer) => {
98
+ const dirName = nameAnswer ?? targetDir;
99
+ return styleTitle(`${dirName === "." ? "current directory" : `Target directory "${dirName}"`} is not empty. Please choose how to proceed:`);
124
100
  },
125
- {
126
- type: (_, { projectName: nameAnswer }) => {
127
- return isValidPackageName(getProjectName(nameAnswer ?? targetDir)) ? null : "text";
101
+ initial: 0,
102
+ choices: [
103
+ {
104
+ title: "Cancel operation",
105
+ value: "cancel"
128
106
  },
129
- name: "packageName",
130
- message: styleTitle("Package name:"),
131
- initial: (_, { projectName: nameAnswer }) => {
132
- return toValidPackageName(getProjectName(nameAnswer ?? targetDir));
107
+ {
108
+ title: "Remove existing files and continue",
109
+ value: "overwrite"
133
110
  },
134
- validate: (name) => {
135
- return isValidPackageName(name) || "Invalid package.json name";
111
+ {
112
+ title: "Ignore files and continue",
113
+ value: "ignore"
136
114
  }
115
+ ]
116
+ };
117
+ const overwriteChecker = {
118
+ type: (overwriteAnswer) => {
119
+ if (overwriteAnswer === "cancel") onCancel();
120
+ return null;
121
+ },
122
+ name: "overwriteChecker"
123
+ };
124
+ const packageName = {
125
+ type: (_, { projectName: nameAnswer }) => {
126
+ return isValidPackageName(getProjectName(nameAnswer ?? targetDir)) ? null : "text";
137
127
  },
138
- {
139
- type: builtinTemplate(template) ? null : "select",
140
- name: "framework",
141
- message: styleTitle(template ? `${colors.red(template)} isn't a valid template. Please choose from below:` : "Select a framework:"),
142
- initial: 0,
143
- choices: [{
144
- title: colors.green("Vue"),
145
- value: "vue"
146
- }, {
147
- title: colors.blue("React"),
148
- value: "react"
149
- }]
128
+ name: "packageName",
129
+ message: styleTitle("Package name:"),
130
+ initial: (_, { projectName: nameAnswer }) => {
131
+ return toValidPackageName(getProjectName(nameAnswer ?? targetDir));
150
132
  },
151
- {
152
- type: checkCi(ci) ? null : "select",
153
- name: "ci",
154
- message: styleTitle(ci ? `${colors.red(ci)} isn't a valid CI/CD. Please choose from below:` : "Choose CI/CD:"),
155
- choices: [
156
- {
157
- title: "GitHub Actions",
158
- value: "github-actions"
159
- },
160
- {
161
- title: "GitLab CI",
162
- value: "gitlab-ci"
163
- },
164
- {
165
- title: "None",
166
- value: "none"
167
- }
168
- ],
169
- initial: 0
133
+ validate: (name) => {
134
+ return isValidPackageName(name) || "Invalid package.json name";
170
135
  }
136
+ };
137
+ const framework = {
138
+ type: builtinTemplate(template) ? null : "select",
139
+ name: "framework",
140
+ message: styleTitle(template ? `${colors.red(template)} isn't a valid template. Please choose from below:` : "Select a framework:"),
141
+ initial: 0,
142
+ choices: [{
143
+ title: colors.green("Vue"),
144
+ value: "vue"
145
+ }, {
146
+ title: colors.blue("React"),
147
+ value: "react"
148
+ }]
149
+ };
150
+ const ciPrompt = {
151
+ type: checkCi(ci) ? null : "select",
152
+ name: "ci",
153
+ message: styleTitle(ci ? `${colors.red(ci)} isn't a valid CI/CD. Please choose from below:` : "Choose CI/CD:"),
154
+ choices: [
155
+ {
156
+ title: "GitHub Actions",
157
+ value: "github-actions"
158
+ },
159
+ {
160
+ title: "GitLab CI",
161
+ value: "gitlab-ci"
162
+ },
163
+ {
164
+ title: "None",
165
+ value: "none"
166
+ }
167
+ ],
168
+ initial: 0
169
+ };
170
+ return prompts([
171
+ projectName,
172
+ overwrite,
173
+ overwriteChecker,
174
+ packageName,
175
+ framework,
176
+ ciPrompt
171
177
  ], { onCancel });
172
178
  }
173
179
  //#endregion
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@component-hook/create-app",
3
3
  "type": "module",
4
- "version": "1.5.0",
4
+ "version": "1.5.1",
5
5
  "description": "Scaffolding a basic typescript project",
6
6
  "author": "Tzuyi",
7
7
  "license": "MIT",
@@ -26,8 +26,8 @@
26
26
  "node": ">=20.19.6"
27
27
  },
28
28
  "dependencies": {
29
- "art-template": "^4.13.7",
30
- "fs-extra": "^11.3.6",
29
+ "art-template": "^4.13.4",
30
+ "fs-extra": "^11.4.0",
31
31
  "minimist": "^1.2.8",
32
32
  "ora": "^9.4.1",
33
33
  "picocolors": "^1.1.1",