create-weapp-vite 1.3.7 → 2.0.0
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/{chunk-YEUXCQ7V.js → chunk-BMBPYJ45.js} +2 -2
- package/dist/cli.d.ts +2 -1
- package/dist/cli.js +4 -3
- package/dist/index.js +1 -1
- package/package.json +7 -5
- package/templates/default/package.json +1 -1
- package/templates/tailwindcss/package.json +1 -1
- package/templates/tdesign/package.json +1 -1
- package/templates/vant/auto-import-components.json +71 -0
- package/templates/vant/package.json +1 -1
- package/templates/wevu/package.json +1 -1
- package/templates/wevu-tdesign/components.d.ts +2 -2
- package/templates/wevu-tdesign/package.json +1 -1
- package/templates/wevu-tdesign/src/vite-env.d.ts +0 -1
- package/templates/wevu-tdesign/typed-components.d.ts +1 -1
- package/dist/cli.cjs +0 -364
- package/dist/cli.d.cts +0 -3
- package/dist/index.cjs +0 -318
- package/dist/index.d.cts +0 -12
|
@@ -5,10 +5,10 @@ import fs2 from "fs-extra";
|
|
|
5
5
|
import path2 from "pathe";
|
|
6
6
|
|
|
7
7
|
// ../weapp-vite/package.json
|
|
8
|
-
var version = "6.
|
|
8
|
+
var version = "6.2.0";
|
|
9
9
|
|
|
10
10
|
// ../wevu/package.json
|
|
11
|
-
var version2 = "1.0
|
|
11
|
+
var version2 = "1.1.0";
|
|
12
12
|
|
|
13
13
|
// src/enums.ts
|
|
14
14
|
var TemplateName = /* @__PURE__ */ ((TemplateName2) => {
|
package/dist/cli.d.ts
CHANGED
package/dist/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createProject
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-BMBPYJ45.js";
|
|
4
4
|
|
|
5
5
|
// src/cli.ts
|
|
6
6
|
import path from "path";
|
|
@@ -52,12 +52,13 @@ async function run() {
|
|
|
52
52
|
});
|
|
53
53
|
await createProject(targetDir, templateName);
|
|
54
54
|
}
|
|
55
|
-
run().catch(
|
|
55
|
+
var runPromise = run().catch(
|
|
56
56
|
(err) => {
|
|
57
57
|
console.error("\u2717 \u521B\u5EFA\u5931\u8D25:", err.message || err);
|
|
58
58
|
console.log("\u2717 \u53D6\u6D88\u521B\u5EFA");
|
|
59
59
|
}
|
|
60
60
|
);
|
|
61
61
|
export {
|
|
62
|
-
run
|
|
62
|
+
run,
|
|
63
|
+
runPromise
|
|
63
64
|
};
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-weapp-vite",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "2.0.0",
|
|
5
5
|
"description": "create-weapp-vite",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -22,8 +22,7 @@
|
|
|
22
22
|
"exports": {
|
|
23
23
|
".": {
|
|
24
24
|
"types": "./dist/index.d.ts",
|
|
25
|
-
"import": "./dist/index.js"
|
|
26
|
-
"require": "./dist/index.cjs"
|
|
25
|
+
"import": "./dist/index.js"
|
|
27
26
|
}
|
|
28
27
|
},
|
|
29
28
|
"bin": "./bin/create-weapp-vite.js",
|
|
@@ -32,12 +31,15 @@
|
|
|
32
31
|
"dist",
|
|
33
32
|
"templates"
|
|
34
33
|
],
|
|
34
|
+
"engines": {
|
|
35
|
+
"node": "^20.19.0 || >=22.12.0"
|
|
36
|
+
},
|
|
35
37
|
"dependencies": {
|
|
36
38
|
"@inquirer/prompts": "^8.2.0",
|
|
37
39
|
"fs-extra": "^11.3.3",
|
|
38
40
|
"pathe": "^2.0.3",
|
|
39
41
|
"pkg-types": "^2.3.0",
|
|
40
|
-
"@weapp-core/logger": "^
|
|
42
|
+
"@weapp-core/logger": "^3.0.0"
|
|
41
43
|
},
|
|
42
44
|
"scripts": {
|
|
43
45
|
"dev": "tsup --watch --sourcemap",
|
|
@@ -48,7 +50,7 @@
|
|
|
48
50
|
"lint": "eslint .",
|
|
49
51
|
"lint:fix": "eslint . --fix"
|
|
50
52
|
},
|
|
51
|
-
"main": "./dist/index.
|
|
53
|
+
"main": "./dist/index.js",
|
|
52
54
|
"module": "./dist/index.js",
|
|
53
55
|
"types": "./dist/index.d.ts"
|
|
54
56
|
}
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"@egoist/tailwindcss-icons": "^1.9.0",
|
|
28
28
|
"@iconify-json/mdi": "^1.2.3",
|
|
29
29
|
"autoprefixer": "^10.4.23",
|
|
30
|
-
"miniprogram-api-typings": "^
|
|
30
|
+
"miniprogram-api-typings": "^5.0.0",
|
|
31
31
|
"postcss": "^8.5.6",
|
|
32
32
|
"sass": "^1.97.2",
|
|
33
33
|
"tailwindcss": "^3.4.19",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"@egoist/tailwindcss-icons": "^1.9.0",
|
|
31
31
|
"@iconify-json/mdi": "^1.2.3",
|
|
32
32
|
"autoprefixer": "^10.4.23",
|
|
33
|
-
"miniprogram-api-typings": "^
|
|
33
|
+
"miniprogram-api-typings": "^5.0.0",
|
|
34
34
|
"postcss": "^8.5.6",
|
|
35
35
|
"sass": "^1.97.2",
|
|
36
36
|
"tailwindcss": "^3.4.19",
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
{
|
|
2
|
+
"van-action-sheet": "@vant/weapp/action-sheet",
|
|
3
|
+
"van-area": "@vant/weapp/area",
|
|
4
|
+
"van-button": "@vant/weapp/button",
|
|
5
|
+
"van-calendar": "@vant/weapp/calendar",
|
|
6
|
+
"van-card": "@vant/weapp/card",
|
|
7
|
+
"van-cascader": "@vant/weapp/cascader",
|
|
8
|
+
"van-cell": "@vant/weapp/cell",
|
|
9
|
+
"van-cell-group": "@vant/weapp/cell-group",
|
|
10
|
+
"van-checkbox": "@vant/weapp/checkbox",
|
|
11
|
+
"van-checkbox-group": "@vant/weapp/checkbox-group",
|
|
12
|
+
"van-circle": "@vant/weapp/circle",
|
|
13
|
+
"van-col": "@vant/weapp/col",
|
|
14
|
+
"van-collapse": "@vant/weapp/collapse",
|
|
15
|
+
"van-collapse-item": "@vant/weapp/collapse-item",
|
|
16
|
+
"van-config-provider": "@vant/weapp/config-provider",
|
|
17
|
+
"van-count-down": "@vant/weapp/count-down",
|
|
18
|
+
"van-datetime-picker": "@vant/weapp/datetime-picker",
|
|
19
|
+
"van-definitions": "@vant/weapp/definitions",
|
|
20
|
+
"van-dialog": "@vant/weapp/dialog",
|
|
21
|
+
"van-divider": "@vant/weapp/divider",
|
|
22
|
+
"van-dropdown-item": "@vant/weapp/dropdown-item",
|
|
23
|
+
"van-dropdown-menu": "@vant/weapp/dropdown-menu",
|
|
24
|
+
"van-empty": "@vant/weapp/empty",
|
|
25
|
+
"van-field": "@vant/weapp/field",
|
|
26
|
+
"van-goods-action": "@vant/weapp/goods-action",
|
|
27
|
+
"van-goods-action-button": "@vant/weapp/goods-action-button",
|
|
28
|
+
"van-goods-action-icon": "@vant/weapp/goods-action-icon",
|
|
29
|
+
"van-grid": "@vant/weapp/grid",
|
|
30
|
+
"van-grid-item": "@vant/weapp/grid-item",
|
|
31
|
+
"van-icon": "@vant/weapp/icon",
|
|
32
|
+
"van-image": "@vant/weapp/image",
|
|
33
|
+
"van-index-anchor": "@vant/weapp/index-anchor",
|
|
34
|
+
"van-index-bar": "@vant/weapp/index-bar",
|
|
35
|
+
"van-info": "@vant/weapp/info",
|
|
36
|
+
"van-loading": "@vant/weapp/loading",
|
|
37
|
+
"van-nav-bar": "@vant/weapp/nav-bar",
|
|
38
|
+
"van-notice-bar": "@vant/weapp/notice-bar",
|
|
39
|
+
"van-notify": "@vant/weapp/notify",
|
|
40
|
+
"van-overlay": "@vant/weapp/overlay",
|
|
41
|
+
"van-panel": "@vant/weapp/panel",
|
|
42
|
+
"van-picker": "@vant/weapp/picker",
|
|
43
|
+
"van-picker-column": "@vant/weapp/picker-column",
|
|
44
|
+
"van-popup": "@vant/weapp/popup",
|
|
45
|
+
"van-progress": "@vant/weapp/progress",
|
|
46
|
+
"van-radio": "@vant/weapp/radio",
|
|
47
|
+
"van-radio-group": "@vant/weapp/radio-group",
|
|
48
|
+
"van-rate": "@vant/weapp/rate",
|
|
49
|
+
"van-row": "@vant/weapp/row",
|
|
50
|
+
"van-search": "@vant/weapp/search",
|
|
51
|
+
"van-share-sheet": "@vant/weapp/share-sheet",
|
|
52
|
+
"van-sidebar": "@vant/weapp/sidebar",
|
|
53
|
+
"van-sidebar-item": "@vant/weapp/sidebar-item",
|
|
54
|
+
"van-skeleton": "@vant/weapp/skeleton",
|
|
55
|
+
"van-slider": "@vant/weapp/slider",
|
|
56
|
+
"van-stepper": "@vant/weapp/stepper",
|
|
57
|
+
"van-steps": "@vant/weapp/steps",
|
|
58
|
+
"van-sticky": "@vant/weapp/sticky",
|
|
59
|
+
"van-submit-bar": "@vant/weapp/submit-bar",
|
|
60
|
+
"van-swipe-cell": "@vant/weapp/swipe-cell",
|
|
61
|
+
"van-switch": "@vant/weapp/switch",
|
|
62
|
+
"van-tab": "@vant/weapp/tab",
|
|
63
|
+
"van-tabbar": "@vant/weapp/tabbar",
|
|
64
|
+
"van-tabbar-item": "@vant/weapp/tabbar-item",
|
|
65
|
+
"van-tabs": "@vant/weapp/tabs",
|
|
66
|
+
"van-tag": "@vant/weapp/tag",
|
|
67
|
+
"van-toast": "@vant/weapp/toast",
|
|
68
|
+
"van-transition": "@vant/weapp/transition",
|
|
69
|
+
"van-tree-select": "@vant/weapp/tree-select",
|
|
70
|
+
"van-uploader": "@vant/weapp/uploader"
|
|
71
|
+
}
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"@egoist/tailwindcss-icons": "^1.9.0",
|
|
31
31
|
"@iconify-json/mdi": "^1.2.3",
|
|
32
32
|
"autoprefixer": "^10.4.23",
|
|
33
|
-
"miniprogram-api-typings": "^
|
|
33
|
+
"miniprogram-api-typings": "^5.0.0",
|
|
34
34
|
"postcss": "^8.5.6",
|
|
35
35
|
"sass": "^1.97.2",
|
|
36
36
|
"tailwindcss": "^3.4.19",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// biome-ignore lint: disable
|
|
3
3
|
// oxlint-disable
|
|
4
4
|
// ------
|
|
5
|
-
//
|
|
5
|
+
// 由 weapp-vite autoImportComponents 生成
|
|
6
6
|
import type { ComponentOptionsMixin, DefineComponent, PublicProps } from 'wevu'
|
|
7
7
|
import type { ComponentProp } from 'weapp-vite/typed-components'
|
|
8
8
|
|
|
@@ -178,7 +178,7 @@ declare module 'wevu' {
|
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
180
|
|
|
181
|
-
//
|
|
181
|
+
// 用于 TSX 支持
|
|
182
182
|
declare global {
|
|
183
183
|
const TActionSheet: __WeappComponentImport<typeof import("tdesign-miniprogram/miniprogram_dist/action-sheet/action-sheet")> & WeappComponent<ComponentProp<"t-action-sheet">>
|
|
184
184
|
const TAvatar: __WeappComponentImport<typeof import("tdesign-miniprogram/miniprogram_dist/avatar/avatar")> & WeappComponent<ComponentProp<"t-avatar">>
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"@egoist/tailwindcss-icons": "^1.9.0",
|
|
30
30
|
"@iconify-json/mdi": "^1.2.3",
|
|
31
31
|
"autoprefixer": "^10.4.23",
|
|
32
|
-
"miniprogram-api-typings": "^
|
|
32
|
+
"miniprogram-api-typings": "^5.0.0",
|
|
33
33
|
"postcss": "^8.5.6",
|
|
34
34
|
"sass": "^1.97.2",
|
|
35
35
|
"tailwindcss": "^3.4.19",
|
package/dist/cli.cjs
DELETED
|
@@ -1,364 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// src/cli.ts
|
|
31
|
-
var cli_exports = {};
|
|
32
|
-
__export(cli_exports, {
|
|
33
|
-
run: () => run
|
|
34
|
-
});
|
|
35
|
-
module.exports = __toCommonJS(cli_exports);
|
|
36
|
-
|
|
37
|
-
// ../../node_modules/.pnpm/tsup@8.5.1_@swc+core@1.15.8_jiti@2.6.1_postcss@8.5.6_tsx@4.21.0_typescript@5.9.3_yaml@2.8.2/node_modules/tsup/assets/cjs_shims.js
|
|
38
|
-
var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.tagName.toUpperCase() === "SCRIPT" ? document.currentScript.src : new URL("main.js", document.baseURI).href;
|
|
39
|
-
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
40
|
-
|
|
41
|
-
// src/cli.ts
|
|
42
|
-
var import_node_path = __toESM(require("path"), 1);
|
|
43
|
-
var import_node_process = __toESM(require("process"), 1);
|
|
44
|
-
var import_prompts = require("@inquirer/prompts");
|
|
45
|
-
var import_fs_extra3 = __toESM(require("fs-extra"), 1);
|
|
46
|
-
|
|
47
|
-
// src/createProject.ts
|
|
48
|
-
var import_node_url = require("url");
|
|
49
|
-
var import_logger2 = __toESM(require("@weapp-core/logger"), 1);
|
|
50
|
-
var import_fs_extra2 = __toESM(require("fs-extra"), 1);
|
|
51
|
-
var import_pathe2 = __toESM(require("pathe"), 1);
|
|
52
|
-
|
|
53
|
-
// ../weapp-vite/package.json
|
|
54
|
-
var version = "6.1.10";
|
|
55
|
-
|
|
56
|
-
// ../wevu/package.json
|
|
57
|
-
var version2 = "1.0.6";
|
|
58
|
-
|
|
59
|
-
// src/npm.ts
|
|
60
|
-
var import_node_https = __toESM(require("https"), 1);
|
|
61
|
-
function getLatestVersionFromNpm(packageName) {
|
|
62
|
-
return new Promise((resolve, reject) => {
|
|
63
|
-
const url = `https://registry.npmjs.org/${packageName}/latest`;
|
|
64
|
-
import_node_https.default.get(url, (res) => {
|
|
65
|
-
if (!res || res.statusCode && res.statusCode >= 400) {
|
|
66
|
-
res?.resume();
|
|
67
|
-
reject(new Error(`Request to ${url} failed with status ${res?.statusCode ?? "unknown"}`));
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
let data = "";
|
|
71
|
-
res.setEncoding("utf8");
|
|
72
|
-
res.on("data", (chunk) => data += chunk);
|
|
73
|
-
res.on("end", () => {
|
|
74
|
-
try {
|
|
75
|
-
const json = JSON.parse(data);
|
|
76
|
-
if (!json.version || typeof json.version !== "string") {
|
|
77
|
-
reject(new Error(`Unexpected response when fetching ${packageName}: missing version`));
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
resolve(json.version);
|
|
81
|
-
} catch (err) {
|
|
82
|
-
reject(err);
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
res.on("error", reject);
|
|
86
|
-
}).on("error", reject);
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
async function latestVersion(packageName, prefix = "^", fetch = getLatestVersionFromNpm) {
|
|
90
|
-
try {
|
|
91
|
-
const resolved = await fetch(packageName);
|
|
92
|
-
if (!resolved) {
|
|
93
|
-
return null;
|
|
94
|
-
}
|
|
95
|
-
return `${prefix}${resolved}`;
|
|
96
|
-
} catch {
|
|
97
|
-
return null;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// src/updateGitignore.ts
|
|
102
|
-
var import_logger = __toESM(require("@weapp-core/logger"), 1);
|
|
103
|
-
var import_pathe = __toESM(require("pathe"), 1);
|
|
104
|
-
|
|
105
|
-
// src/gitignore.ts
|
|
106
|
-
var DEFAULT_GITIGNORE = `# dependencies
|
|
107
|
-
node_modules
|
|
108
|
-
.pnp
|
|
109
|
-
.pnp.js
|
|
110
|
-
|
|
111
|
-
# testing
|
|
112
|
-
coverage
|
|
113
|
-
|
|
114
|
-
# next.js
|
|
115
|
-
.next/
|
|
116
|
-
out/
|
|
117
|
-
build
|
|
118
|
-
|
|
119
|
-
# misc
|
|
120
|
-
.DS_Store
|
|
121
|
-
*.pem
|
|
122
|
-
|
|
123
|
-
# debug
|
|
124
|
-
npm-debug.log*
|
|
125
|
-
yarn-debug.log*
|
|
126
|
-
yarn-error.log*
|
|
127
|
-
.pnpm-debug.log*
|
|
128
|
-
|
|
129
|
-
# local env files
|
|
130
|
-
.env.local
|
|
131
|
-
.env.development.local
|
|
132
|
-
.env.test.local
|
|
133
|
-
.env.production.local
|
|
134
|
-
|
|
135
|
-
# turbo
|
|
136
|
-
.turbo
|
|
137
|
-
|
|
138
|
-
dist
|
|
139
|
-
dist-plugin
|
|
140
|
-
dist-web
|
|
141
|
-
vite.config.ts.timestamp-*.mjs`;
|
|
142
|
-
function normalizeLineEndings(value) {
|
|
143
|
-
return value.replace(/\r\n/g, "\n");
|
|
144
|
-
}
|
|
145
|
-
function trimTrailingBlankLines(lines) {
|
|
146
|
-
let end = lines.length;
|
|
147
|
-
while (end > 0 && lines[end - 1] === "") {
|
|
148
|
-
end -= 1;
|
|
149
|
-
}
|
|
150
|
-
return lines.slice(0, end);
|
|
151
|
-
}
|
|
152
|
-
function ensureTrailingNewline(value) {
|
|
153
|
-
return value.endsWith("\n") ? value : `${value}
|
|
154
|
-
`;
|
|
155
|
-
}
|
|
156
|
-
function mergeGitignore(existing) {
|
|
157
|
-
const normalizedExisting = normalizeLineEndings(existing ?? "");
|
|
158
|
-
const existingLines = normalizedExisting.length ? normalizedExisting.split("\n") : [];
|
|
159
|
-
const merged = [...existingLines];
|
|
160
|
-
while (merged.length > 0 && merged[merged.length - 1] === "") {
|
|
161
|
-
merged.pop();
|
|
162
|
-
}
|
|
163
|
-
const seen = new Set(merged);
|
|
164
|
-
let appendedNonBlank = false;
|
|
165
|
-
for (const line of DEFAULT_GITIGNORE.split("\n")) {
|
|
166
|
-
const isBlank = line.length === 0;
|
|
167
|
-
if (isBlank) {
|
|
168
|
-
if (merged.length === 0 || merged[merged.length - 1] === "") {
|
|
169
|
-
continue;
|
|
170
|
-
}
|
|
171
|
-
merged.push("");
|
|
172
|
-
continue;
|
|
173
|
-
}
|
|
174
|
-
if (seen.has(line)) {
|
|
175
|
-
continue;
|
|
176
|
-
}
|
|
177
|
-
if (!appendedNonBlank && merged.length > 0 && merged[merged.length - 1] !== "") {
|
|
178
|
-
merged.push("");
|
|
179
|
-
}
|
|
180
|
-
merged.push(line);
|
|
181
|
-
seen.add(line);
|
|
182
|
-
appendedNonBlank = true;
|
|
183
|
-
}
|
|
184
|
-
return ensureTrailingNewline(trimTrailingBlankLines(merged).join("\n"));
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
// src/utils/fs.ts
|
|
188
|
-
var import_fs_extra = __toESM(require("fs-extra"), 1);
|
|
189
|
-
var FsReadError = class extends Error {
|
|
190
|
-
constructor(filepath, cause) {
|
|
191
|
-
super(`Failed to read ${filepath}`);
|
|
192
|
-
this.filepath = filepath;
|
|
193
|
-
this.cause = cause;
|
|
194
|
-
this.name = "FsReadError";
|
|
195
|
-
}
|
|
196
|
-
};
|
|
197
|
-
var FsWriteError = class extends Error {
|
|
198
|
-
constructor(filepath, cause) {
|
|
199
|
-
super(`Failed to write ${filepath}`);
|
|
200
|
-
this.filepath = filepath;
|
|
201
|
-
this.cause = cause;
|
|
202
|
-
this.name = "FsWriteError";
|
|
203
|
-
}
|
|
204
|
-
};
|
|
205
|
-
async function readFileIfExists(filepath) {
|
|
206
|
-
try {
|
|
207
|
-
return await import_fs_extra.default.readFile(filepath, "utf8");
|
|
208
|
-
} catch (error) {
|
|
209
|
-
if (error?.code === "ENOENT") {
|
|
210
|
-
return null;
|
|
211
|
-
}
|
|
212
|
-
throw new FsReadError(filepath, error);
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
async function writeJsonFile(filepath, data, spaces = 2) {
|
|
216
|
-
try {
|
|
217
|
-
await import_fs_extra.default.outputJSON(filepath, data, {
|
|
218
|
-
spaces
|
|
219
|
-
});
|
|
220
|
-
} catch (error) {
|
|
221
|
-
throw new FsWriteError(filepath, error);
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
async function writeFile(filepath, contents) {
|
|
225
|
-
try {
|
|
226
|
-
await import_fs_extra.default.outputFile(filepath, contents, "utf8");
|
|
227
|
-
} catch (error) {
|
|
228
|
-
throw new FsWriteError(filepath, error);
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
// src/updateGitignore.ts
|
|
233
|
-
async function updateGitIgnore(options) {
|
|
234
|
-
const { root, write = true } = options;
|
|
235
|
-
const gitignorePath = import_pathe.default.resolve(root, ".gitignore");
|
|
236
|
-
const existing = await readFileIfExists(gitignorePath);
|
|
237
|
-
const merged = mergeGitignore(existing);
|
|
238
|
-
if (write && merged !== (existing ?? "")) {
|
|
239
|
-
await writeFile(gitignorePath, merged);
|
|
240
|
-
import_logger.default.log(`\u2728 \u66F4\u65B0 ${import_pathe.default.relative(root, gitignorePath)} \u6210\u529F!`);
|
|
241
|
-
}
|
|
242
|
-
return merged;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
// src/createProject.ts
|
|
246
|
-
var moduleDir = import_pathe2.default.dirname((0, import_node_url.fileURLToPath)(importMetaUrl));
|
|
247
|
-
async function ensureDotGitignore(root) {
|
|
248
|
-
const gitignorePath = import_pathe2.default.resolve(root, "gitignore");
|
|
249
|
-
const dotGitignorePath = import_pathe2.default.resolve(root, ".gitignore");
|
|
250
|
-
if (!await import_fs_extra2.default.pathExists(gitignorePath)) {
|
|
251
|
-
return;
|
|
252
|
-
}
|
|
253
|
-
if (await import_fs_extra2.default.pathExists(dotGitignorePath)) {
|
|
254
|
-
await import_fs_extra2.default.remove(gitignorePath);
|
|
255
|
-
return;
|
|
256
|
-
}
|
|
257
|
-
await import_fs_extra2.default.move(gitignorePath, dotGitignorePath);
|
|
258
|
-
}
|
|
259
|
-
function createEmptyPackageJson() {
|
|
260
|
-
return {
|
|
261
|
-
name: "weapp-vite-app",
|
|
262
|
-
homepage: "https://vite.icebreaker.top/",
|
|
263
|
-
type: "module",
|
|
264
|
-
scripts: {},
|
|
265
|
-
devDependencies: {}
|
|
266
|
-
};
|
|
267
|
-
}
|
|
268
|
-
async function upsertTailwindcssVersion(pkgJson) {
|
|
269
|
-
if (!pkgJson.devDependencies) {
|
|
270
|
-
return;
|
|
271
|
-
}
|
|
272
|
-
const resolved = await latestVersion("weapp-tailwindcss");
|
|
273
|
-
if (resolved) {
|
|
274
|
-
pkgJson.devDependencies["weapp-tailwindcss"] = resolved;
|
|
275
|
-
} else if (!pkgJson.devDependencies["weapp-tailwindcss"]) {
|
|
276
|
-
pkgJson.devDependencies["weapp-tailwindcss"] = "^4.3.3";
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
function upsertExistingDependencyVersion(pkgJson, packageName, resolvedVersion) {
|
|
280
|
-
if (pkgJson.dependencies?.[packageName]) {
|
|
281
|
-
pkgJson.dependencies[packageName] = resolvedVersion;
|
|
282
|
-
}
|
|
283
|
-
if (pkgJson.devDependencies?.[packageName]) {
|
|
284
|
-
pkgJson.devDependencies[packageName] = resolvedVersion;
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
async function createProject(targetDir = "", templateName = "default" /* default */) {
|
|
288
|
-
const targetTemplateDir = import_pathe2.default.resolve(moduleDir, "../templates", templateName);
|
|
289
|
-
if (!await import_fs_extra2.default.pathExists(targetTemplateDir)) {
|
|
290
|
-
import_logger2.default.warn(`\u6CA1\u6709\u627E\u5230 ${templateName} \u6A21\u677F!`);
|
|
291
|
-
return;
|
|
292
|
-
}
|
|
293
|
-
await import_fs_extra2.default.copy(targetTemplateDir, targetDir);
|
|
294
|
-
const templatePackagePath = import_pathe2.default.resolve(targetTemplateDir, "package.json");
|
|
295
|
-
const packageJsonPath = import_pathe2.default.resolve(targetDir, "package.json");
|
|
296
|
-
await ensureDotGitignore(targetDir);
|
|
297
|
-
const pkgJson = await import_fs_extra2.default.pathExists(templatePackagePath) ? await import_fs_extra2.default.readJSON(templatePackagePath) : createEmptyPackageJson();
|
|
298
|
-
if (!pkgJson.devDependencies) {
|
|
299
|
-
pkgJson.devDependencies = {};
|
|
300
|
-
}
|
|
301
|
-
upsertExistingDependencyVersion(pkgJson, "weapp-vite", version);
|
|
302
|
-
upsertExistingDependencyVersion(pkgJson, "wevu", version2);
|
|
303
|
-
await upsertTailwindcssVersion(pkgJson);
|
|
304
|
-
await writeJsonFile(packageJsonPath, pkgJson);
|
|
305
|
-
await updateGitIgnore({ root: targetDir, write: true });
|
|
306
|
-
import_logger2.default.log("\u2728 \u521B\u5EFA\u6A21\u677F\u6210\u529F!");
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
// src/cli.ts
|
|
310
|
-
var cwd = import_node_process.default.cwd();
|
|
311
|
-
async function run() {
|
|
312
|
-
const [argTarget, argTemplate] = import_node_process.default.argv.slice(2);
|
|
313
|
-
const isArgMode = Boolean(argTarget);
|
|
314
|
-
const targetDir = isArgMode ? argTarget : await (0, import_prompts.input)({ message: "\u521B\u5EFA\u5E94\u7528\u7684\u76EE\u5F55", default: "my-app" });
|
|
315
|
-
const dir = import_node_path.default.resolve(cwd, targetDir);
|
|
316
|
-
const existed = await import_fs_extra3.default.exists(dir);
|
|
317
|
-
if (existed) {
|
|
318
|
-
const isOverwrite = isArgMode ? true : await (0, import_prompts.confirm)({ message: "\u76EE\u5F55\u5DF2\u5B58\u5728\uFF0C\u662F\u5426\u8986\u76D6\uFF1F", default: false });
|
|
319
|
-
if (!isOverwrite) {
|
|
320
|
-
return;
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
const templateName = isArgMode ? argTemplate ?? "default" /* default */ : await (0, import_prompts.select)({
|
|
324
|
-
message: "\u9009\u62E9\u6A21\u677F",
|
|
325
|
-
choices: [
|
|
326
|
-
{
|
|
327
|
-
name: "\u9ED8\u8BA4\u6A21\u677F",
|
|
328
|
-
value: "default" /* default */
|
|
329
|
-
},
|
|
330
|
-
{
|
|
331
|
-
name: "Wevu \u6A21\u677F (Vue SFC)",
|
|
332
|
-
value: "wevu" /* wevu */
|
|
333
|
-
},
|
|
334
|
-
{
|
|
335
|
-
name: "Wevu + TDesign \u6A21\u677F (wevu + tdesign + tailwindcss)",
|
|
336
|
-
value: "wevu-tdesign" /* wevuTdesign */
|
|
337
|
-
},
|
|
338
|
-
{
|
|
339
|
-
name: "\u96C6\u6210 Tailwindcss",
|
|
340
|
-
value: "tailwindcss" /* tailwindcss */
|
|
341
|
-
},
|
|
342
|
-
{
|
|
343
|
-
name: "Vant \u6A21\u677F (vant + tailwindcss)",
|
|
344
|
-
value: "vant" /* vant */
|
|
345
|
-
},
|
|
346
|
-
{
|
|
347
|
-
name: "TDesign \u6A21\u677F (tdesign + tailwindcss)",
|
|
348
|
-
value: "tdesign" /* tdesign */
|
|
349
|
-
}
|
|
350
|
-
],
|
|
351
|
-
default: "default" /* default */
|
|
352
|
-
});
|
|
353
|
-
await createProject(targetDir, templateName);
|
|
354
|
-
}
|
|
355
|
-
run().catch(
|
|
356
|
-
(err) => {
|
|
357
|
-
console.error("\u2717 \u521B\u5EFA\u5931\u8D25:", err.message || err);
|
|
358
|
-
console.log("\u2717 \u53D6\u6D88\u521B\u5EFA");
|
|
359
|
-
}
|
|
360
|
-
);
|
|
361
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
362
|
-
0 && (module.exports = {
|
|
363
|
-
run
|
|
364
|
-
});
|
package/dist/cli.d.cts
DELETED
package/dist/index.cjs
DELETED
|
@@ -1,318 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// src/index.ts
|
|
31
|
-
var index_exports = {};
|
|
32
|
-
__export(index_exports, {
|
|
33
|
-
TemplateName: () => TemplateName,
|
|
34
|
-
createProject: () => createProject
|
|
35
|
-
});
|
|
36
|
-
module.exports = __toCommonJS(index_exports);
|
|
37
|
-
|
|
38
|
-
// ../../node_modules/.pnpm/tsup@8.5.1_@swc+core@1.15.8_jiti@2.6.1_postcss@8.5.6_tsx@4.21.0_typescript@5.9.3_yaml@2.8.2/node_modules/tsup/assets/cjs_shims.js
|
|
39
|
-
var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.tagName.toUpperCase() === "SCRIPT" ? document.currentScript.src : new URL("main.js", document.baseURI).href;
|
|
40
|
-
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
41
|
-
|
|
42
|
-
// src/createProject.ts
|
|
43
|
-
var import_node_url = require("url");
|
|
44
|
-
var import_logger2 = __toESM(require("@weapp-core/logger"), 1);
|
|
45
|
-
var import_fs_extra2 = __toESM(require("fs-extra"), 1);
|
|
46
|
-
var import_pathe2 = __toESM(require("pathe"), 1);
|
|
47
|
-
|
|
48
|
-
// ../weapp-vite/package.json
|
|
49
|
-
var version = "6.1.10";
|
|
50
|
-
|
|
51
|
-
// ../wevu/package.json
|
|
52
|
-
var version2 = "1.0.6";
|
|
53
|
-
|
|
54
|
-
// src/enums.ts
|
|
55
|
-
var TemplateName = /* @__PURE__ */ ((TemplateName2) => {
|
|
56
|
-
TemplateName2["default"] = "default";
|
|
57
|
-
TemplateName2["wevu"] = "wevu";
|
|
58
|
-
TemplateName2["tailwindcss"] = "tailwindcss";
|
|
59
|
-
TemplateName2["vant"] = "vant";
|
|
60
|
-
TemplateName2["tdesign"] = "tdesign";
|
|
61
|
-
TemplateName2["wevuTdesign"] = "wevu-tdesign";
|
|
62
|
-
return TemplateName2;
|
|
63
|
-
})(TemplateName || {});
|
|
64
|
-
|
|
65
|
-
// src/npm.ts
|
|
66
|
-
var import_node_https = __toESM(require("https"), 1);
|
|
67
|
-
function getLatestVersionFromNpm(packageName) {
|
|
68
|
-
return new Promise((resolve, reject) => {
|
|
69
|
-
const url = `https://registry.npmjs.org/${packageName}/latest`;
|
|
70
|
-
import_node_https.default.get(url, (res) => {
|
|
71
|
-
if (!res || res.statusCode && res.statusCode >= 400) {
|
|
72
|
-
res?.resume();
|
|
73
|
-
reject(new Error(`Request to ${url} failed with status ${res?.statusCode ?? "unknown"}`));
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
let data = "";
|
|
77
|
-
res.setEncoding("utf8");
|
|
78
|
-
res.on("data", (chunk) => data += chunk);
|
|
79
|
-
res.on("end", () => {
|
|
80
|
-
try {
|
|
81
|
-
const json = JSON.parse(data);
|
|
82
|
-
if (!json.version || typeof json.version !== "string") {
|
|
83
|
-
reject(new Error(`Unexpected response when fetching ${packageName}: missing version`));
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
resolve(json.version);
|
|
87
|
-
} catch (err) {
|
|
88
|
-
reject(err);
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
res.on("error", reject);
|
|
92
|
-
}).on("error", reject);
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
async function latestVersion(packageName, prefix = "^", fetch = getLatestVersionFromNpm) {
|
|
96
|
-
try {
|
|
97
|
-
const resolved = await fetch(packageName);
|
|
98
|
-
if (!resolved) {
|
|
99
|
-
return null;
|
|
100
|
-
}
|
|
101
|
-
return `${prefix}${resolved}`;
|
|
102
|
-
} catch {
|
|
103
|
-
return null;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// src/updateGitignore.ts
|
|
108
|
-
var import_logger = __toESM(require("@weapp-core/logger"), 1);
|
|
109
|
-
var import_pathe = __toESM(require("pathe"), 1);
|
|
110
|
-
|
|
111
|
-
// src/gitignore.ts
|
|
112
|
-
var DEFAULT_GITIGNORE = `# dependencies
|
|
113
|
-
node_modules
|
|
114
|
-
.pnp
|
|
115
|
-
.pnp.js
|
|
116
|
-
|
|
117
|
-
# testing
|
|
118
|
-
coverage
|
|
119
|
-
|
|
120
|
-
# next.js
|
|
121
|
-
.next/
|
|
122
|
-
out/
|
|
123
|
-
build
|
|
124
|
-
|
|
125
|
-
# misc
|
|
126
|
-
.DS_Store
|
|
127
|
-
*.pem
|
|
128
|
-
|
|
129
|
-
# debug
|
|
130
|
-
npm-debug.log*
|
|
131
|
-
yarn-debug.log*
|
|
132
|
-
yarn-error.log*
|
|
133
|
-
.pnpm-debug.log*
|
|
134
|
-
|
|
135
|
-
# local env files
|
|
136
|
-
.env.local
|
|
137
|
-
.env.development.local
|
|
138
|
-
.env.test.local
|
|
139
|
-
.env.production.local
|
|
140
|
-
|
|
141
|
-
# turbo
|
|
142
|
-
.turbo
|
|
143
|
-
|
|
144
|
-
dist
|
|
145
|
-
dist-plugin
|
|
146
|
-
dist-web
|
|
147
|
-
vite.config.ts.timestamp-*.mjs`;
|
|
148
|
-
function normalizeLineEndings(value) {
|
|
149
|
-
return value.replace(/\r\n/g, "\n");
|
|
150
|
-
}
|
|
151
|
-
function trimTrailingBlankLines(lines) {
|
|
152
|
-
let end = lines.length;
|
|
153
|
-
while (end > 0 && lines[end - 1] === "") {
|
|
154
|
-
end -= 1;
|
|
155
|
-
}
|
|
156
|
-
return lines.slice(0, end);
|
|
157
|
-
}
|
|
158
|
-
function ensureTrailingNewline(value) {
|
|
159
|
-
return value.endsWith("\n") ? value : `${value}
|
|
160
|
-
`;
|
|
161
|
-
}
|
|
162
|
-
function mergeGitignore(existing) {
|
|
163
|
-
const normalizedExisting = normalizeLineEndings(existing ?? "");
|
|
164
|
-
const existingLines = normalizedExisting.length ? normalizedExisting.split("\n") : [];
|
|
165
|
-
const merged = [...existingLines];
|
|
166
|
-
while (merged.length > 0 && merged[merged.length - 1] === "") {
|
|
167
|
-
merged.pop();
|
|
168
|
-
}
|
|
169
|
-
const seen = new Set(merged);
|
|
170
|
-
let appendedNonBlank = false;
|
|
171
|
-
for (const line of DEFAULT_GITIGNORE.split("\n")) {
|
|
172
|
-
const isBlank = line.length === 0;
|
|
173
|
-
if (isBlank) {
|
|
174
|
-
if (merged.length === 0 || merged[merged.length - 1] === "") {
|
|
175
|
-
continue;
|
|
176
|
-
}
|
|
177
|
-
merged.push("");
|
|
178
|
-
continue;
|
|
179
|
-
}
|
|
180
|
-
if (seen.has(line)) {
|
|
181
|
-
continue;
|
|
182
|
-
}
|
|
183
|
-
if (!appendedNonBlank && merged.length > 0 && merged[merged.length - 1] !== "") {
|
|
184
|
-
merged.push("");
|
|
185
|
-
}
|
|
186
|
-
merged.push(line);
|
|
187
|
-
seen.add(line);
|
|
188
|
-
appendedNonBlank = true;
|
|
189
|
-
}
|
|
190
|
-
return ensureTrailingNewline(trimTrailingBlankLines(merged).join("\n"));
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
// src/utils/fs.ts
|
|
194
|
-
var import_fs_extra = __toESM(require("fs-extra"), 1);
|
|
195
|
-
var FsReadError = class extends Error {
|
|
196
|
-
constructor(filepath, cause) {
|
|
197
|
-
super(`Failed to read ${filepath}`);
|
|
198
|
-
this.filepath = filepath;
|
|
199
|
-
this.cause = cause;
|
|
200
|
-
this.name = "FsReadError";
|
|
201
|
-
}
|
|
202
|
-
};
|
|
203
|
-
var FsWriteError = class extends Error {
|
|
204
|
-
constructor(filepath, cause) {
|
|
205
|
-
super(`Failed to write ${filepath}`);
|
|
206
|
-
this.filepath = filepath;
|
|
207
|
-
this.cause = cause;
|
|
208
|
-
this.name = "FsWriteError";
|
|
209
|
-
}
|
|
210
|
-
};
|
|
211
|
-
async function readFileIfExists(filepath) {
|
|
212
|
-
try {
|
|
213
|
-
return await import_fs_extra.default.readFile(filepath, "utf8");
|
|
214
|
-
} catch (error) {
|
|
215
|
-
if (error?.code === "ENOENT") {
|
|
216
|
-
return null;
|
|
217
|
-
}
|
|
218
|
-
throw new FsReadError(filepath, error);
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
async function writeJsonFile(filepath, data, spaces = 2) {
|
|
222
|
-
try {
|
|
223
|
-
await import_fs_extra.default.outputJSON(filepath, data, {
|
|
224
|
-
spaces
|
|
225
|
-
});
|
|
226
|
-
} catch (error) {
|
|
227
|
-
throw new FsWriteError(filepath, error);
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
async function writeFile(filepath, contents) {
|
|
231
|
-
try {
|
|
232
|
-
await import_fs_extra.default.outputFile(filepath, contents, "utf8");
|
|
233
|
-
} catch (error) {
|
|
234
|
-
throw new FsWriteError(filepath, error);
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
// src/updateGitignore.ts
|
|
239
|
-
async function updateGitIgnore(options) {
|
|
240
|
-
const { root, write = true } = options;
|
|
241
|
-
const gitignorePath = import_pathe.default.resolve(root, ".gitignore");
|
|
242
|
-
const existing = await readFileIfExists(gitignorePath);
|
|
243
|
-
const merged = mergeGitignore(existing);
|
|
244
|
-
if (write && merged !== (existing ?? "")) {
|
|
245
|
-
await writeFile(gitignorePath, merged);
|
|
246
|
-
import_logger.default.log(`\u2728 \u66F4\u65B0 ${import_pathe.default.relative(root, gitignorePath)} \u6210\u529F!`);
|
|
247
|
-
}
|
|
248
|
-
return merged;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
// src/createProject.ts
|
|
252
|
-
var moduleDir = import_pathe2.default.dirname((0, import_node_url.fileURLToPath)(importMetaUrl));
|
|
253
|
-
async function ensureDotGitignore(root) {
|
|
254
|
-
const gitignorePath = import_pathe2.default.resolve(root, "gitignore");
|
|
255
|
-
const dotGitignorePath = import_pathe2.default.resolve(root, ".gitignore");
|
|
256
|
-
if (!await import_fs_extra2.default.pathExists(gitignorePath)) {
|
|
257
|
-
return;
|
|
258
|
-
}
|
|
259
|
-
if (await import_fs_extra2.default.pathExists(dotGitignorePath)) {
|
|
260
|
-
await import_fs_extra2.default.remove(gitignorePath);
|
|
261
|
-
return;
|
|
262
|
-
}
|
|
263
|
-
await import_fs_extra2.default.move(gitignorePath, dotGitignorePath);
|
|
264
|
-
}
|
|
265
|
-
function createEmptyPackageJson() {
|
|
266
|
-
return {
|
|
267
|
-
name: "weapp-vite-app",
|
|
268
|
-
homepage: "https://vite.icebreaker.top/",
|
|
269
|
-
type: "module",
|
|
270
|
-
scripts: {},
|
|
271
|
-
devDependencies: {}
|
|
272
|
-
};
|
|
273
|
-
}
|
|
274
|
-
async function upsertTailwindcssVersion(pkgJson) {
|
|
275
|
-
if (!pkgJson.devDependencies) {
|
|
276
|
-
return;
|
|
277
|
-
}
|
|
278
|
-
const resolved = await latestVersion("weapp-tailwindcss");
|
|
279
|
-
if (resolved) {
|
|
280
|
-
pkgJson.devDependencies["weapp-tailwindcss"] = resolved;
|
|
281
|
-
} else if (!pkgJson.devDependencies["weapp-tailwindcss"]) {
|
|
282
|
-
pkgJson.devDependencies["weapp-tailwindcss"] = "^4.3.3";
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
function upsertExistingDependencyVersion(pkgJson, packageName, resolvedVersion) {
|
|
286
|
-
if (pkgJson.dependencies?.[packageName]) {
|
|
287
|
-
pkgJson.dependencies[packageName] = resolvedVersion;
|
|
288
|
-
}
|
|
289
|
-
if (pkgJson.devDependencies?.[packageName]) {
|
|
290
|
-
pkgJson.devDependencies[packageName] = resolvedVersion;
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
async function createProject(targetDir = "", templateName = "default" /* default */) {
|
|
294
|
-
const targetTemplateDir = import_pathe2.default.resolve(moduleDir, "../templates", templateName);
|
|
295
|
-
if (!await import_fs_extra2.default.pathExists(targetTemplateDir)) {
|
|
296
|
-
import_logger2.default.warn(`\u6CA1\u6709\u627E\u5230 ${templateName} \u6A21\u677F!`);
|
|
297
|
-
return;
|
|
298
|
-
}
|
|
299
|
-
await import_fs_extra2.default.copy(targetTemplateDir, targetDir);
|
|
300
|
-
const templatePackagePath = import_pathe2.default.resolve(targetTemplateDir, "package.json");
|
|
301
|
-
const packageJsonPath = import_pathe2.default.resolve(targetDir, "package.json");
|
|
302
|
-
await ensureDotGitignore(targetDir);
|
|
303
|
-
const pkgJson = await import_fs_extra2.default.pathExists(templatePackagePath) ? await import_fs_extra2.default.readJSON(templatePackagePath) : createEmptyPackageJson();
|
|
304
|
-
if (!pkgJson.devDependencies) {
|
|
305
|
-
pkgJson.devDependencies = {};
|
|
306
|
-
}
|
|
307
|
-
upsertExistingDependencyVersion(pkgJson, "weapp-vite", version);
|
|
308
|
-
upsertExistingDependencyVersion(pkgJson, "wevu", version2);
|
|
309
|
-
await upsertTailwindcssVersion(pkgJson);
|
|
310
|
-
await writeJsonFile(packageJsonPath, pkgJson);
|
|
311
|
-
await updateGitIgnore({ root: targetDir, write: true });
|
|
312
|
-
import_logger2.default.log("\u2728 \u521B\u5EFA\u6A21\u677F\u6210\u529F!");
|
|
313
|
-
}
|
|
314
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
315
|
-
0 && (module.exports = {
|
|
316
|
-
TemplateName,
|
|
317
|
-
createProject
|
|
318
|
-
});
|
package/dist/index.d.cts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
declare enum TemplateName {
|
|
2
|
-
default = "default",
|
|
3
|
-
wevu = "wevu",
|
|
4
|
-
tailwindcss = "tailwindcss",
|
|
5
|
-
vant = "vant",
|
|
6
|
-
tdesign = "tdesign",
|
|
7
|
-
wevuTdesign = "wevu-tdesign"
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
declare function createProject(targetDir?: string, templateName?: TemplateName): Promise<void>;
|
|
11
|
-
|
|
12
|
-
export { TemplateName, createProject };
|