create-weapp-vite 2.0.59 → 2.0.61

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/cli.js CHANGED
@@ -1,4 +1,4 @@
1
- import { n as TemplateName, t as createProject } from "./src-D1-gOdfL.js";
1
+ import { n as TemplateName, t as createProject } from "./src-De83rZqI.js";
2
2
  import logger from "@weapp-core/logger";
3
3
  import fs from "fs-extra";
4
4
  import path from "node:path";
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import { n as TemplateName, t as createProject } from "./src-D1-gOdfL.js";
1
+ import { n as TemplateName, t as createProject } from "./src-De83rZqI.js";
2
2
  export { TemplateName, createProject };
@@ -4,10 +4,10 @@ import fs from "fs-extra";
4
4
  import path from "pathe";
5
5
  import https from "node:https";
6
6
  //#region ../weapp-vite/package.json
7
- var version$1 = "6.11.4";
7
+ var version$1 = "6.11.6";
8
8
  //#endregion
9
9
  //#region ../wevu/package.json
10
- var version = "6.11.4";
10
+ var version = "6.11.6";
11
11
  //#endregion
12
12
  //#region src/enums.ts
13
13
  let TemplateName = /* @__PURE__ */ function(TemplateName) {
@@ -36,7 +36,7 @@ const TEMPLATE_CATALOG = {
36
36
  "@types/node": "^25.5.0",
37
37
  "@types/semver": "^7.7.1",
38
38
  "@vant/weapp": "^1.11.7",
39
- "@vue/compiler-core": "^3.5.30",
39
+ "@vue/compiler-core": "^3.5.31",
40
40
  "@vue/language-core": "^3.2.6",
41
41
  "antd-mini": "^3.4.3",
42
42
  "bundle-require": "^5.1.0",
@@ -52,11 +52,11 @@ const TEMPLATE_CATALOG = {
52
52
  "object-hash": "^3.0.0",
53
53
  "pkg-types": "^2.3.0",
54
54
  "sass-embedded": "^1.98.0",
55
- "tdesign-miniprogram": "^1.13.0",
55
+ "tdesign-miniprogram": "^1.13.1",
56
56
  "ts-morph": "^27.0.2",
57
57
  "vite-plugin-inspect": "^11.3.3",
58
58
  "vue-tsc": "^3.2.6",
59
- "weapp-tailwindcss": "^4.10.3",
59
+ "weapp-tailwindcss": "^4.11.0",
60
60
  autoprefixer: "^10.4.27",
61
61
  clsx: "^2.1.1",
62
62
  dayjs: "^1.11.20",
@@ -69,20 +69,21 @@ const TEMPLATE_CATALOG = {
69
69
  merge: "^2.1.1",
70
70
  pathe: "^2.0.3",
71
71
  postcss: "^8.5.8",
72
+ rolldown: "1.0.0-rc.12",
72
73
  sass: "^1.98.0",
73
74
  tailwindcss: "^4.2.2",
74
75
  tslib: "^2.8.1",
75
- typescript: "^5.9.3",
76
- vite: "8.0.0",
77
- vue: "^3.5.30",
76
+ typescript: "^6.0.2",
77
+ vite: "8.0.3",
78
+ vue: "^3.5.31",
78
79
  zod: "^4.3.6"
79
80
  };
80
81
  const TEMPLATE_NAMED_CATALOG = {
81
- "tdesign-miniprogram-fixed": { "tdesign-miniprogram": "1.13.0" },
82
- "weapp-tailwindcss-fixed": { "weapp-tailwindcss": "4.10.3" },
82
+ "tdesign-miniprogram-fixed": { "tdesign-miniprogram": "1.13.1" },
83
+ "weapp-tailwindcss-fixed": { "weapp-tailwindcss": "4.11.0" },
83
84
  latest: {
84
85
  "miniprogram-api-typings": "^5.1.2",
85
- typescript: "latest"
86
+ typescript: "^6.0.2"
86
87
  },
87
88
  tailwind3: { tailwindcss: "3.4.19" },
88
89
  tailwind4: { tailwindcss: "^4.2.2" }
@@ -169,9 +170,9 @@ dist-web
169
170
  dist/web
170
171
  vite.config.ts.timestamp-*.mjs
171
172
  .weapp-vite/`;
172
- const CRLF_RE = /\r\n/g;
173
+ const CRLF_RE$1 = /\r\n/g;
173
174
  function normalizeLineEndings(value) {
174
- return value.replace(CRLF_RE, "\n");
175
+ return value.replace(CRLF_RE$1, "\n");
175
176
  }
176
177
  function trimTrailingBlankLines(lines) {
177
178
  let end = lines.length;
@@ -266,9 +267,61 @@ async function updateGitIgnore(options) {
266
267
  //#endregion
267
268
  //#region src/createProject.ts
268
269
  const DIGIT_RE = /\d/;
270
+ const CRLF_RE = /\r\n/g;
269
271
  const moduleDir = path.dirname(fileURLToPath(import.meta.url));
272
+ const TEMPLATE_DIR_MAP = {
273
+ [TemplateName.default]: "weapp-vite-template",
274
+ [TemplateName.lib]: "weapp-vite-lib-template",
275
+ [TemplateName.wevu]: "weapp-vite-wevu-template",
276
+ [TemplateName.wevuTdesign]: "weapp-vite-wevu-tailwindcss-tdesign-template",
277
+ [TemplateName.tailwindcss]: "weapp-vite-tailwindcss-template",
278
+ [TemplateName.tdesign]: "weapp-vite-tailwindcss-tdesign-template",
279
+ [TemplateName.vant]: "weapp-vite-tailwindcss-vant-template"
280
+ };
270
281
  const templateCatalogMap = { ...TEMPLATE_CATALOG };
271
282
  const templateNamedCatalogMap = Object.fromEntries(Object.entries(TEMPLATE_NAMED_CATALOG).map(([name, deps]) => [name, { ...deps }]));
283
+ function resolveWorkspaceTemplateDir(templateName) {
284
+ const templateDirName = TEMPLATE_DIR_MAP[templateName];
285
+ return templateDirName ? path.resolve(moduleDir, "../../../templates", templateDirName) : path.resolve(moduleDir, "../../../templates", templateName);
286
+ }
287
+ async function resolveTemplateDirs(templateName) {
288
+ const packagedTemplateDir = path.resolve(moduleDir, "../templates", templateName);
289
+ const workspaceTemplateDir = resolveWorkspaceTemplateDir(templateName);
290
+ return {
291
+ packagedTemplateDir,
292
+ workspaceTemplateDir,
293
+ preferredTemplateDir: await fs.pathExists(packagedTemplateDir) ? packagedTemplateDir : workspaceTemplateDir
294
+ };
295
+ }
296
+ function shouldSkipTemplateFile(filePath) {
297
+ return filePath.includes("node_modules") || filePath.includes(`${path.sep}.weapp-vite${path.sep}`) || filePath.includes("vite.config.ts.timestamp") || filePath.includes(`${path.sep}dist${path.sep}`) || filePath.endsWith(`${path.sep}CHANGELOG.md`) || filePath.includes(`${path.sep}.turbo${path.sep}`) || filePath.endsWith(`${path.sep}.DS_Store`);
298
+ }
299
+ function normalizeLines(value) {
300
+ return value.replace(CRLF_RE, "\n").split("\n");
301
+ }
302
+ function mergeGitignoreSource(existing, template) {
303
+ const merged = normalizeLines(existing);
304
+ const seen = new Set(merged);
305
+ for (const line of normalizeLines(template)) {
306
+ if (seen.has(line)) continue;
307
+ merged.push(line);
308
+ seen.add(line);
309
+ }
310
+ while (merged.length > 0 && merged.at(-1) === "") merged.pop();
311
+ return `${merged.join("\n")}\n`;
312
+ }
313
+ async function copyTemplateDir(sourceDir, fallbackDir, targetDir) {
314
+ const copyOptions = { filter(src) {
315
+ return !shouldSkipTemplateFile(src);
316
+ } };
317
+ try {
318
+ await fs.copy(sourceDir, targetDir, copyOptions);
319
+ } catch (error) {
320
+ const errorCode = error?.code;
321
+ if (sourceDir === fallbackDir || errorCode !== "ENOENT") throw error;
322
+ await fs.copy(fallbackDir, targetDir, copyOptions);
323
+ }
324
+ }
272
325
  async function ensureDotGitignore(root) {
273
326
  const gitignorePath = path.resolve(root, "gitignore");
274
327
  const dotGitignorePath = path.resolve(root, ".gitignore");
@@ -342,15 +395,21 @@ function normalizeTemplateDependencySpecs(pkgJson) {
342
395
  * @description 根据模板创建项目
343
396
  */
344
397
  async function createProject(targetDir = "", templateName = TemplateName.default) {
345
- const targetTemplateDir = path.resolve(moduleDir, "../templates", templateName);
346
- if (!await fs.pathExists(targetTemplateDir)) {
398
+ const { preferredTemplateDir, workspaceTemplateDir } = await resolveTemplateDirs(templateName);
399
+ const dotGitignorePath = path.resolve(targetDir, ".gitignore");
400
+ const existingGitignore = await fs.pathExists(dotGitignorePath) ? await fs.readFile(dotGitignorePath, "utf8") : null;
401
+ if (!await fs.pathExists(preferredTemplateDir) && !await fs.pathExists(workspaceTemplateDir)) {
347
402
  logger.warn(`没有找到 ${templateName} 模板!`);
348
403
  return;
349
404
  }
350
- await fs.copy(targetTemplateDir, targetDir);
351
- const templatePackagePath = path.resolve(targetTemplateDir, "package.json");
405
+ await copyTemplateDir(preferredTemplateDir, workspaceTemplateDir, targetDir);
406
+ const templatePackagePath = path.resolve(preferredTemplateDir, "package.json");
352
407
  const packageJsonPath = path.resolve(targetDir, "package.json");
353
408
  await ensureDotGitignore(targetDir);
409
+ if (existingGitignore !== null && await fs.pathExists(dotGitignorePath)) {
410
+ const currentGitignore = await fs.readFile(dotGitignorePath, "utf8");
411
+ await fs.writeFile(dotGitignorePath, mergeGitignoreSource(existingGitignore, currentGitignore));
412
+ }
354
413
  const pkgJson = await fs.pathExists(templatePackagePath) ? await fs.readJSON(templatePackagePath) : createEmptyPackageJson();
355
414
  normalizeTemplateDependencySpecs(pkgJson);
356
415
  if (!pkgJson.devDependencies) pkgJson.devDependencies = {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "create-weapp-vite",
3
3
  "type": "module",
4
- "version": "2.0.59",
4
+ "version": "2.0.61",
5
5
  "description": "create-weapp-vite",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "MIT",
@@ -4,5 +4,5 @@
4
4
  "setting": {
5
5
  "compileHotReLoad": true
6
6
  },
7
- "libVersion": "3.9.0"
7
+ "libVersion": "3.15.0"
8
8
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "weapp-vite-lib-template",
3
3
  "type": "module",
4
- "version": "2.0.4",
4
+ "version": "2.0.6",
5
5
  "private": true,
6
6
  "description": "weapp-vite 组件库(lib 模式)模板",
7
7
  "author": "ice breaker <1324318532@qq.com>",
@@ -4,5 +4,5 @@
4
4
  "setting": {
5
5
  "compileHotReLoad": true
6
6
  },
7
- "libVersion": "3.9.0"
7
+ "libVersion": "3.15.0"
8
8
  }
@@ -4,5 +4,5 @@
4
4
  "setting": {
5
5
  "compileHotReLoad": true
6
6
  },
7
- "libVersion": "3.9.3"
7
+ "libVersion": "3.15.0"
8
8
  }
@@ -4,5 +4,5 @@
4
4
  "setting": {
5
5
  "compileHotReLoad": true
6
6
  },
7
- "libVersion": "3.14.2"
7
+ "libVersion": "3.15.0"
8
8
  }
@@ -4,5 +4,5 @@
4
4
  "setting": {
5
5
  "compileHotReLoad": true
6
6
  },
7
- "libVersion": "3.14.0"
7
+ "libVersion": "3.15.0"
8
8
  }
@@ -4,5 +4,5 @@
4
4
  "setting": {
5
5
  "compileHotReLoad": true
6
6
  },
7
- "libVersion": "3.13.0"
7
+ "libVersion": "3.15.0"
8
8
  }
@@ -76,5 +76,5 @@
76
76
  ]
77
77
  }
78
78
  },
79
- "libVersion": "3.14.0"
79
+ "libVersion": "3.15.0"
80
80
  }