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 +1 -1
- package/dist/index.js +1 -1
- package/dist/{src-D1-gOdfL.js → src-CXCuh90o.js} +69 -11
- package/package.json +1 -1
- package/templates/default/project.private.config.json +1 -1
- package/templates/lib/package.json +1 -1
- package/templates/lib/project.private.config.json +1 -1
- package/templates/tailwindcss/project.private.config.json +1 -1
- package/templates/tdesign/project.private.config.json +1 -1
- package/templates/vant/project.private.config.json +1 -1
- package/templates/wevu/project.private.config.json +1 -1
- package/templates/wevu-tdesign/project.private.config.json +1 -1
package/dist/cli.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as TemplateName, t as createProject } from "./src-
|
|
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.
|
|
7
|
+
var version$1 = "6.11.5";
|
|
8
8
|
//#endregion
|
|
9
9
|
//#region ../wevu/package.json
|
|
10
|
-
var version = "6.11.
|
|
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: "^
|
|
76
|
-
vite: "8.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: "
|
|
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
|
|
346
|
-
|
|
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
|
|
351
|
-
const templatePackagePath = path.resolve(
|
|
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