create-widget 26.7.21 → 26.7.22

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/bin/index.js CHANGED
@@ -135,11 +135,7 @@ async function init() {
135
135
  let targetDir = argv2._[0];
136
136
  const defaultProjectName = !targetDir ? "widget-project" : targetDir;
137
137
  const forceOverwrite = argv2.force;
138
- const unocss = argv2.unocss;
139
- const vueuse = argv2.vueuse;
140
- const iconpark = argv2.iconpark;
141
- const githubPage = argv2.githubPage;
142
- const eslintConfig = argv2.eslintConfig;
138
+ const npmmirror = argv2.npmmirror;
143
139
  const cwd2 = process.cwd();
144
140
  let selectedTemplateType = "react";
145
141
  let result = {};
@@ -163,6 +159,11 @@ async function init() {
163
159
  { title: "vue3 (Deprecate)", value: "vue3" }
164
160
  ]
165
161
  },
162
+ {
163
+ name: "useNpmMirror",
164
+ type: npmmirror ? null : "confirm",
165
+ message: "Use npmmirror registry? (Recommended for users in mainland China)"
166
+ },
166
167
  {
167
168
  name: "shouldOverwrite",
168
169
  type: () => canSkipEmptying(targetDir) || forceOverwrite ? null : "confirm",
@@ -170,41 +171,6 @@ async function init() {
170
171
  const dirForPrompt = targetDir === "." ? "Current directory" : `Target directory "${targetDir}"`;
171
172
  return `${dirForPrompt} is not empty. Remove existing files and continue?`;
172
173
  }
173
- },
174
- {
175
- name: "useVueUse",
176
- type: () => selectedTemplateType === "react" || vueuse ? null : "confirm",
177
- message: () => {
178
- return `Use VueUse (Collection of Essential Vue Composition Utilities)?`;
179
- }
180
- },
181
- {
182
- name: "useUnoCss",
183
- type: () => selectedTemplateType === "react" || unocss ? null : "confirm",
184
- message: () => {
185
- return `Use Unocss(Atomic CSS Engine)?`;
186
- }
187
- },
188
- {
189
- name: "useIconPark",
190
- type: () => selectedTemplateType === "react" || iconpark ? null : "confirm",
191
- message: () => {
192
- return `Use IconPark (2000+ high-quality icons)?`;
193
- }
194
- },
195
- {
196
- name: "useGithubPage",
197
- type: () => selectedTemplateType === "react" || githubPage ? null : "confirm",
198
- message: () => {
199
- return `Use GitHub Page to deploy your project?`;
200
- }
201
- },
202
- {
203
- name: "useEslintConfig",
204
- type: () => selectedTemplateType === "react" || eslintConfig ? null : "confirm",
205
- message: () => {
206
- return `Use @antfu/eslint-config (Anthony's ESLint config preset)?`;
207
- }
208
174
  }
209
175
  ],
210
176
  {
@@ -216,12 +182,8 @@ async function init() {
216
182
  const {
217
183
  projectName,
218
184
  templateType = "react",
219
- shouldOverwrite = argv2.force,
220
- useVueUse = argv2.vueuse,
221
- useUnoCss = argv2.unocss,
222
- useIconPark = argv2.iconpark,
223
- useGithubPage = argv2.githubPage,
224
- useEslintConfig = argv2.eslintConfig
185
+ useNpmMirror = argv2.npmmirror,
186
+ shouldOverwrite = argv2.force
225
187
  } = result;
226
188
  const root = path3.join(cwd2, targetDir);
227
189
  if (fs3.existsSync(root) && shouldOverwrite) {
@@ -234,39 +196,16 @@ Scaffolding project in ${root}...`);
234
196
  if (templateType === "react") {
235
197
  const reactTemplateRoot = path3.join(__dirname, "../template/react");
236
198
  await FileUtils.copyFolderRecursive(reactTemplateRoot, root);
199
+ if (useNpmMirror) {
200
+ fs3.writeFileSync(path3.join(root, ".npmrc"), "registry=https://registry.npmmirror.com\n");
201
+ }
237
202
  printInstallInstructions(root, cwd2, "npm install");
238
203
  return;
239
204
  }
240
205
  const templateRoot = path3.join(__dirname, "../template/vue");
241
206
  await FileUtils.copyFolderRecursive(templateRoot, root);
242
- const packageJsonPath = path3.resolve(`${root}/package.json`);
243
- const packageJson = JSON.parse(fs3.readFileSync(packageJsonPath).toString());
244
- if (useVueUse) {
245
- packageJson.dependencies["@vueuse/core"] = "latest";
246
- }
247
- if (useUnoCss) {
248
- packageJson.devDependencies.unocss = "latest";
249
- const unocssTemplateRoot = path3.join(__dirname, "../unocss");
250
- await FileUtils.copyFolderRecursive(unocssTemplateRoot, root);
251
- }
252
- if (useIconPark) {
253
- packageJson.dependencies["@icon-park/vue-next"] = "latest";
254
- }
255
- if (useEslintConfig) {
256
- packageJson.devDependencies["@antfu/eslint-config"] = "latest";
257
- packageJson.devDependencies.eslint = "latest";
258
- packageJson.scripts = {
259
- ...packageJson.scripts,
260
- "lint": "eslint .",
261
- "lint:fix": "eslint . --fix"
262
- };
263
- const eslintTemplateRoot = path3.join(__dirname, "../eslint");
264
- await FileUtils.copyFolderRecursive(eslintTemplateRoot, root);
265
- }
266
- fs3.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
267
- if (useGithubPage) {
268
- const githubPageTemplateRoot = path3.join(__dirname, "../github-page");
269
- await FileUtils.copyFolderRecursive(githubPageTemplateRoot, root);
207
+ if (useNpmMirror) {
208
+ fs3.writeFileSync(path3.join(root, ".npmrc"), "registry=https://registry.npmmirror.com\n");
270
209
  }
271
210
  const userAgent = process.env.npm_config_user_agent ?? "";
272
211
  const packageManager = /pnpm/.test(userAgent) ? "pnpm" : /yarn/.test(userAgent) ? "yarn" : "npm";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-widget",
3
- "version": "26.7.21",
3
+ "version": "26.7.22",
4
4
  "private": false,
5
5
  "description": "An easy way to start a Widget project",
6
6
  "author": "Neo Fu <rtugeek@gmail.com>",
package/readme.md CHANGED
@@ -10,12 +10,10 @@ npx skills@latest add create-widget
10
10
 
11
11
  ### 创建桌面组件项目
12
12
 
13
- :::tip 前提条件
14
13
 
15
14
  - 熟悉命令行
16
15
  - 已安装 18.0 或更高版本的 [Node.js](https://nodejs.org/)
17
16
  - 熟悉 [Vue3](https://cn.vuejs.org/guide/quick-start.html)
18
- :::
19
17
 
20
18
  在命令行中运行以下命令,创建桌面组件项目
21
19
 
@@ -33,8 +33,8 @@
33
33
  "@types/react": "^19.2.7",
34
34
  "@types/react-dom": "^19.2.3",
35
35
  "@vitejs/plugin-react": "^5.1.1",
36
- "@widget-js/cli": "24.1.1-beta.72",
37
- "@widget-js/vite-plugin-widget": "24.1.1-beta.72",
36
+ "@widget-js/cli": "latest",
37
+ "@widget-js/vite-plugin-widget": "latest",
38
38
  "tailwindcss": "^4.3.3",
39
39
  "typescript": "latest",
40
40
  "vite": "latest"