create-weapp-vite 2.0.59 → 2.0.60

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-CXCuh90o.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-CXCuh90o.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.5";
8
8
  //#endregion
9
9
  //#region ../wevu/package.json
10
- var version = "6.11.4";
10
+ var version = "6.11.5";
11
11
  //#endregion
12
12
  //#region src/enums.ts
13
13
  let TemplateName = /* @__PURE__ */ function(TemplateName) {
@@ -72,8 +72,8 @@ const TEMPLATE_CATALOG = {
72
72
  sass: "^1.98.0",
73
73
  tailwindcss: "^4.2.2",
74
74
  tslib: "^2.8.1",
75
- typescript: "^5.9.3",
76
- vite: "8.0.0",
75
+ typescript: "^6.0.2",
76
+ vite: "8.0.2",
77
77
  vue: "^3.5.30",
78
78
  zod: "^4.3.6"
79
79
  };
@@ -82,7 +82,7 @@ const TEMPLATE_NAMED_CATALOG = {
82
82
  "weapp-tailwindcss-fixed": { "weapp-tailwindcss": "4.10.3" },
83
83
  latest: {
84
84
  "miniprogram-api-typings": "^5.1.2",
85
- typescript: "latest"
85
+ typescript: "^6.0.2"
86
86
  },
87
87
  tailwind3: { tailwindcss: "3.4.19" },
88
88
  tailwind4: { tailwindcss: "^4.2.2" }
@@ -169,9 +169,9 @@ dist-web
169
169
  dist/web
170
170
  vite.config.ts.timestamp-*.mjs
171
171
  .weapp-vite/`;
172
- const CRLF_RE = /\r\n/g;
172
+ const CRLF_RE$1 = /\r\n/g;
173
173
  function normalizeLineEndings(value) {
174
- return value.replace(CRLF_RE, "\n");
174
+ return value.replace(CRLF_RE$1, "\n");
175
175
  }
176
176
  function trimTrailingBlankLines(lines) {
177
177
  let end = lines.length;
@@ -266,9 +266,61 @@ async function updateGitIgnore(options) {
266
266
  //#endregion
267
267
  //#region src/createProject.ts
268
268
  const DIGIT_RE = /\d/;
269
+ const CRLF_RE = /\r\n/g;
269
270
  const moduleDir = path.dirname(fileURLToPath(import.meta.url));
271
+ const TEMPLATE_DIR_MAP = {
272
+ [TemplateName.default]: "weapp-vite-template",
273
+ [TemplateName.lib]: "weapp-vite-lib-template",
274
+ [TemplateName.wevu]: "weapp-vite-wevu-template",
275
+ [TemplateName.wevuTdesign]: "weapp-vite-wevu-tailwindcss-tdesign-template",
276
+ [TemplateName.tailwindcss]: "weapp-vite-tailwindcss-template",
277
+ [TemplateName.tdesign]: "weapp-vite-tailwindcss-tdesign-template",
278
+ [TemplateName.vant]: "weapp-vite-tailwindcss-vant-template"
279
+ };
270
280
  const templateCatalogMap = { ...TEMPLATE_CATALOG };
271
281
  const templateNamedCatalogMap = Object.fromEntries(Object.entries(TEMPLATE_NAMED_CATALOG).map(([name, deps]) => [name, { ...deps }]));
282
+ function resolveWorkspaceTemplateDir(templateName) {
283
+ const templateDirName = TEMPLATE_DIR_MAP[templateName];
284
+ return templateDirName ? path.resolve(moduleDir, "../../../templates", templateDirName) : path.resolve(moduleDir, "../../../templates", templateName);
285
+ }
286
+ async function resolveTemplateDirs(templateName) {
287
+ const packagedTemplateDir = path.resolve(moduleDir, "../templates", templateName);
288
+ const workspaceTemplateDir = resolveWorkspaceTemplateDir(templateName);
289
+ return {
290
+ packagedTemplateDir,
291
+ workspaceTemplateDir,
292
+ preferredTemplateDir: await fs.pathExists(packagedTemplateDir) ? packagedTemplateDir : workspaceTemplateDir
293
+ };
294
+ }
295
+ function shouldSkipTemplateFile(filePath) {
296
+ 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`);
297
+ }
298
+ function normalizeLines(value) {
299
+ return value.replace(CRLF_RE, "\n").split("\n");
300
+ }
301
+ function mergeGitignoreSource(existing, template) {
302
+ const merged = normalizeLines(existing);
303
+ const seen = new Set(merged);
304
+ for (const line of normalizeLines(template)) {
305
+ if (seen.has(line)) continue;
306
+ merged.push(line);
307
+ seen.add(line);
308
+ }
309
+ while (merged.length > 0 && merged.at(-1) === "") merged.pop();
310
+ return `${merged.join("\n")}\n`;
311
+ }
312
+ async function copyTemplateDir(sourceDir, fallbackDir, targetDir) {
313
+ const copyOptions = { filter(src) {
314
+ return !shouldSkipTemplateFile(src);
315
+ } };
316
+ try {
317
+ await fs.copy(sourceDir, targetDir, copyOptions);
318
+ } catch (error) {
319
+ const errorCode = error?.code;
320
+ if (sourceDir === fallbackDir || errorCode !== "ENOENT") throw error;
321
+ await fs.copy(fallbackDir, targetDir, copyOptions);
322
+ }
323
+ }
272
324
  async function ensureDotGitignore(root) {
273
325
  const gitignorePath = path.resolve(root, "gitignore");
274
326
  const dotGitignorePath = path.resolve(root, ".gitignore");
@@ -342,15 +394,21 @@ function normalizeTemplateDependencySpecs(pkgJson) {
342
394
  * @description 根据模板创建项目
343
395
  */
344
396
  async function createProject(targetDir = "", templateName = TemplateName.default) {
345
- const targetTemplateDir = path.resolve(moduleDir, "../templates", templateName);
346
- if (!await fs.pathExists(targetTemplateDir)) {
397
+ const { preferredTemplateDir, workspaceTemplateDir } = await resolveTemplateDirs(templateName);
398
+ const dotGitignorePath = path.resolve(targetDir, ".gitignore");
399
+ const existingGitignore = await fs.pathExists(dotGitignorePath) ? await fs.readFile(dotGitignorePath, "utf8") : null;
400
+ if (!await fs.pathExists(preferredTemplateDir) && !await fs.pathExists(workspaceTemplateDir)) {
347
401
  logger.warn(`没有找到 ${templateName} 模板!`);
348
402
  return;
349
403
  }
350
- await fs.copy(targetTemplateDir, targetDir);
351
- const templatePackagePath = path.resolve(targetTemplateDir, "package.json");
404
+ await copyTemplateDir(preferredTemplateDir, workspaceTemplateDir, targetDir);
405
+ const templatePackagePath = path.resolve(preferredTemplateDir, "package.json");
352
406
  const packageJsonPath = path.resolve(targetDir, "package.json");
353
407
  await ensureDotGitignore(targetDir);
408
+ if (existingGitignore !== null && await fs.pathExists(dotGitignorePath)) {
409
+ const currentGitignore = await fs.readFile(dotGitignorePath, "utf8");
410
+ await fs.writeFile(dotGitignorePath, mergeGitignoreSource(existingGitignore, currentGitignore));
411
+ }
354
412
  const pkgJson = await fs.pathExists(templatePackagePath) ? await fs.readJSON(templatePackagePath) : createEmptyPackageJson();
355
413
  normalizeTemplateDependencySpecs(pkgJson);
356
414
  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.60",
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.5",
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
  }