create-weapp-vite 1.2.1 → 1.3.1
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-REHXOFVU.js +277 -0
- package/dist/cli.cjs +280 -11
- package/dist/cli.js +12 -9
- package/dist/index.cjs +317 -0
- package/dist/index.d.cts +11 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.js +8 -0
- package/package.json +6 -3
- package/templates/default/.editorconfig +9 -0
- package/templates/default/.vscode/settings.json +5 -0
- package/templates/default/README.md +28 -0
- package/templates/default/auto-import-components.json +3 -0
- package/templates/default/gitignore +35 -0
- package/templates/default/package.json +31 -0
- package/templates/default/project.config.json +42 -0
- package/templates/default/project.private.config.json +8 -0
- package/templates/default/public/logo.png +0 -0
- package/templates/default/src/app.json +10 -0
- package/templates/default/src/app.scss +0 -0
- package/templates/default/src/app.ts +6 -0
- package/templates/default/src/components/HelloWorld/HelloWorld.json +6 -0
- package/templates/default/src/components/HelloWorld/HelloWorld.scss +47 -0
- package/templates/default/src/components/HelloWorld/HelloWorld.ts +61 -0
- package/templates/default/src/components/HelloWorld/HelloWorld.wxml +16 -0
- package/templates/default/src/pages/index/index.json +7 -0
- package/templates/default/src/pages/index/index.scss +0 -0
- package/templates/default/src/pages/index/index.ts +24 -0
- package/templates/default/src/pages/index/index.wxml +14 -0
- package/templates/default/src/sitemap.json +10 -0
- package/templates/default/src/theme.json +5 -0
- package/templates/default/src/utils/util.ts +3 -0
- package/templates/default/src/vite-env.d.ts +1 -0
- package/templates/default/tsconfig.app.json +57 -0
- package/templates/default/tsconfig.json +11 -0
- package/templates/default/tsconfig.node.json +33 -0
- package/templates/default/vite.config.ts +39 -0
- package/templates/tailwindcss/.editorconfig +9 -0
- package/templates/tailwindcss/.vscode/settings.json +5 -0
- package/templates/tailwindcss/README.md +28 -0
- package/templates/tailwindcss/auto-import-components.json +3 -0
- package/templates/tailwindcss/gitignore +35 -0
- package/templates/tailwindcss/package.json +38 -0
- package/templates/tailwindcss/postcss.config.js +6 -0
- package/templates/tailwindcss/project.config.json +43 -0
- package/templates/tailwindcss/project.private.config.json +8 -0
- package/templates/tailwindcss/public/icon0.png +0 -0
- package/templates/tailwindcss/public/icon0s.png +0 -0
- package/templates/tailwindcss/public/icon1.png +0 -0
- package/templates/tailwindcss/public/icon1s.png +0 -0
- package/templates/tailwindcss/public/logo.png +0 -0
- package/templates/tailwindcss/src/app.json +31 -0
- package/templates/tailwindcss/src/app.scss +3 -0
- package/templates/tailwindcss/src/app.ts +6 -0
- package/templates/tailwindcss/src/components/HelloWorld/HelloWorld.json +7 -0
- package/templates/tailwindcss/src/components/HelloWorld/HelloWorld.scss +1 -0
- package/templates/tailwindcss/src/components/HelloWorld/HelloWorld.ts +61 -0
- package/templates/tailwindcss/src/components/HelloWorld/HelloWorld.wxml +16 -0
- package/templates/tailwindcss/src/pages/index/index.json +7 -0
- package/templates/tailwindcss/src/pages/index/index.scss +0 -0
- package/templates/tailwindcss/src/pages/index/index.ts +48 -0
- package/templates/tailwindcss/src/pages/index/index.wxml +24 -0
- package/templates/tailwindcss/src/pages/profile/index.json +7 -0
- package/templates/tailwindcss/src/pages/profile/index.scss +0 -0
- package/templates/tailwindcss/src/pages/profile/index.ts +19 -0
- package/templates/tailwindcss/src/pages/profile/index.wxml +11 -0
- package/templates/tailwindcss/src/sitemap.json +10 -0
- package/templates/tailwindcss/src/theme.json +5 -0
- package/templates/tailwindcss/src/utils/util.ts +3 -0
- package/templates/tailwindcss/src/vite-env.d.ts +1 -0
- package/templates/tailwindcss/tailwind.config.ts +22 -0
- package/templates/tailwindcss/tsconfig.app.json +57 -0
- package/templates/tailwindcss/tsconfig.json +11 -0
- package/templates/tailwindcss/tsconfig.node.json +33 -0
- package/templates/tailwindcss/vite.config.ts +37 -0
- package/templates/tdesign/.editorconfig +9 -0
- package/templates/tdesign/.vscode/settings.json +5 -0
- package/templates/tdesign/README.md +28 -0
- package/templates/tdesign/gitignore +35 -0
- package/templates/tdesign/package.json +41 -0
- package/templates/tdesign/postcss.config.js +6 -0
- package/templates/tdesign/project.config.json +45 -0
- package/templates/tdesign/project.private.config.json +8 -0
- package/templates/tdesign/public/logo.png +0 -0
- package/templates/tdesign/src/app.json +10 -0
- package/templates/tdesign/src/app.scss +3 -0
- package/templates/tdesign/src/app.ts +6 -0
- package/templates/tdesign/src/components/HelloWorld/HelloWorld.json +8 -0
- package/templates/tdesign/src/components/HelloWorld/HelloWorld.scss +1 -0
- package/templates/tdesign/src/components/HelloWorld/HelloWorld.ts +64 -0
- package/templates/tdesign/src/components/HelloWorld/HelloWorld.wxml +17 -0
- package/templates/tdesign/src/pages/index/index.json +7 -0
- package/templates/tdesign/src/pages/index/index.scss +0 -0
- package/templates/tdesign/src/pages/index/index.ts +97 -0
- package/templates/tdesign/src/pages/index/index.wxml +24 -0
- package/templates/tdesign/src/sitemap.json +10 -0
- package/templates/tdesign/src/theme.json +5 -0
- package/templates/tdesign/src/utils/util.ts +3 -0
- package/templates/tdesign/src/vite-env.d.ts +1 -0
- package/templates/tdesign/tailwind.config.ts +22 -0
- package/templates/tdesign/tsconfig.app.json +60 -0
- package/templates/tdesign/tsconfig.json +11 -0
- package/templates/tdesign/tsconfig.node.json +33 -0
- package/templates/tdesign/vite.config.ts +41 -0
- package/templates/vant/.editorconfig +9 -0
- package/templates/vant/.vscode/settings.json +5 -0
- package/templates/vant/README.md +28 -0
- package/templates/vant/gitignore +35 -0
- package/templates/vant/package.json +41 -0
- package/templates/vant/postcss.config.js +6 -0
- package/templates/vant/project.config.json +42 -0
- package/templates/vant/project.private.config.json +8 -0
- package/templates/vant/public/logo.png +0 -0
- package/templates/vant/src/app.json +10 -0
- package/templates/vant/src/app.scss +3 -0
- package/templates/vant/src/app.ts +6 -0
- package/templates/vant/src/components/HelloWorld/HelloWorld.json +9 -0
- package/templates/vant/src/components/HelloWorld/HelloWorld.scss +1 -0
- package/templates/vant/src/components/HelloWorld/HelloWorld.ts +61 -0
- package/templates/vant/src/components/HelloWorld/HelloWorld.wxml +19 -0
- package/templates/vant/src/pages/index/index.json +7 -0
- package/templates/vant/src/pages/index/index.scss +0 -0
- package/templates/vant/src/pages/index/index.ts +57 -0
- package/templates/vant/src/pages/index/index.wxml +28 -0
- package/templates/vant/src/sitemap.json +10 -0
- package/templates/vant/src/theme.json +5 -0
- package/templates/vant/src/utils/util.ts +3 -0
- package/templates/vant/src/vite-env.d.ts +1 -0
- package/templates/vant/tailwind.config.ts +22 -0
- package/templates/vant/tsconfig.app.json +60 -0
- package/templates/vant/tsconfig.json +11 -0
- package/templates/vant/tsconfig.node.json +33 -0
- package/templates/vant/vite.config.ts +41 -0
- package/templates/wevu/.editorconfig +9 -0
- package/templates/wevu/.vscode/settings.json +5 -0
- package/templates/wevu/README.md +29 -0
- package/templates/wevu/auto-import-components.json +1 -0
- package/templates/wevu/gitignore +35 -0
- package/templates/wevu/package.json +30 -0
- package/templates/wevu/project.config.json +43 -0
- package/templates/wevu/project.private.config.json +8 -0
- package/templates/wevu/public/logo.png +0 -0
- package/templates/wevu/src/app.vue +36 -0
- package/templates/wevu/src/components/HelloWorld/index.vue +45 -0
- package/templates/wevu/src/pages/index/index.vue +138 -0
- package/templates/wevu/src/sitemap.json +10 -0
- package/templates/wevu/src/theme.json +5 -0
- package/templates/wevu/src/vite-env.d.ts +1 -0
- package/templates/wevu/tsconfig.app.json +57 -0
- package/templates/wevu/tsconfig.json +11 -0
- package/templates/wevu/tsconfig.node.json +33 -0
- package/templates/wevu/vite.config.ts +8 -0
- package/templates/wevu-tdesign/.editorconfig +9 -0
- package/templates/wevu-tdesign/.vscode/settings.json +5 -0
- package/templates/wevu-tdesign/README.md +29 -0
- package/templates/wevu-tdesign/auto-import-components.json +83 -0
- package/templates/wevu-tdesign/components.d.ts +183 -0
- package/templates/wevu-tdesign/gitignore +35 -0
- package/templates/wevu-tdesign/package.json +41 -0
- package/templates/wevu-tdesign/postcss.config.js +6 -0
- package/templates/wevu-tdesign/project.config.json +43 -0
- package/templates/wevu-tdesign/project.private.config.json +8 -0
- package/templates/wevu-tdesign/public/logo.png +0 -0
- package/templates/wevu-tdesign/src/app.vue +35 -0
- package/templates/wevu-tdesign/src/components/HelloWorld/index.vue +23 -0
- package/templates/wevu-tdesign/src/pages/index/index.vue +161 -0
- package/templates/wevu-tdesign/src/sitemap.json +10 -0
- package/templates/wevu-tdesign/src/theme.json +5 -0
- package/templates/wevu-tdesign/src/vite-env.d.ts +1 -0
- package/templates/wevu-tdesign/tailwind.config.ts +22 -0
- package/templates/wevu-tdesign/tsconfig.app.json +62 -0
- package/templates/wevu-tdesign/tsconfig.json +11 -0
- package/templates/wevu-tdesign/tsconfig.node.json +33 -0
- package/templates/wevu-tdesign/typed-components.d.ts +943 -0
- package/templates/wevu-tdesign/vite.config.ts +43 -0
package/dist/index.cjs
CHANGED
|
@@ -1 +1,318 @@
|
|
|
1
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.5";
|
|
50
|
+
|
|
51
|
+
// ../wevu/package.json
|
|
52
|
+
var version2 = "1.0.1";
|
|
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
CHANGED
|
@@ -1,2 +1,12 @@
|
|
|
1
|
+
declare enum TemplateName {
|
|
2
|
+
default = "default",
|
|
3
|
+
wevu = "wevu",
|
|
4
|
+
tailwindcss = "tailwindcss",
|
|
5
|
+
vant = "vant",
|
|
6
|
+
tdesign = "tdesign",
|
|
7
|
+
wevuTdesign = "wevu-tdesign"
|
|
8
|
+
}
|
|
1
9
|
|
|
2
|
-
|
|
10
|
+
declare function createProject(targetDir?: string, templateName?: TemplateName): Promise<void>;
|
|
11
|
+
|
|
12
|
+
export { TemplateName, createProject };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,12 @@
|
|
|
1
|
+
declare enum TemplateName {
|
|
2
|
+
default = "default",
|
|
3
|
+
wevu = "wevu",
|
|
4
|
+
tailwindcss = "tailwindcss",
|
|
5
|
+
vant = "vant",
|
|
6
|
+
tdesign = "tdesign",
|
|
7
|
+
wevuTdesign = "wevu-tdesign"
|
|
8
|
+
}
|
|
1
9
|
|
|
2
|
-
|
|
10
|
+
declare function createProject(targetDir?: string, templateName?: TemplateName): Promise<void>;
|
|
11
|
+
|
|
12
|
+
export { TemplateName, createProject };
|
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": "1.
|
|
4
|
+
"version": "1.3.1",
|
|
5
5
|
"description": "create-weapp-vite",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -29,12 +29,15 @@
|
|
|
29
29
|
"bin": "./bin/create-weapp-vite.js",
|
|
30
30
|
"files": [
|
|
31
31
|
"bin",
|
|
32
|
-
"dist"
|
|
32
|
+
"dist",
|
|
33
|
+
"templates"
|
|
33
34
|
],
|
|
34
35
|
"dependencies": {
|
|
35
36
|
"@inquirer/prompts": "^8.1.0",
|
|
36
37
|
"fs-extra": "^11.3.3",
|
|
37
|
-
"
|
|
38
|
+
"pathe": "^2.0.3",
|
|
39
|
+
"pkg-types": "^2.3.0",
|
|
40
|
+
"@weapp-core/logger": "^2.0.0"
|
|
38
41
|
},
|
|
39
42
|
"scripts": {
|
|
40
43
|
"dev": "tsup --watch --sourcemap",
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# weapp-vite-template
|
|
2
|
+
|
|
3
|
+
`weapp-vite` 模板
|
|
4
|
+
|
|
5
|
+
## 使用方式
|
|
6
|
+
|
|
7
|
+
### 开发
|
|
8
|
+
|
|
9
|
+
- `pnpm dev`
|
|
10
|
+
|
|
11
|
+
- `pnpm dev --open` 可以打包并直接启动微信开发者工具
|
|
12
|
+
|
|
13
|
+
### 构建
|
|
14
|
+
|
|
15
|
+
`pnpm build`
|
|
16
|
+
|
|
17
|
+
### 打开微信开发者工具
|
|
18
|
+
|
|
19
|
+
`pnpm open`
|
|
20
|
+
|
|
21
|
+
### 生成组件/页面
|
|
22
|
+
|
|
23
|
+
`pnpm g path/to/your/component`
|
|
24
|
+
|
|
25
|
+
## 文档地址
|
|
26
|
+
|
|
27
|
+
0. `weapp-vite`: https://vite.icebreaker.top/
|
|
28
|
+
1. `weapp-tailwindcss`: https://tw.icebreaker.top/
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# dependencies
|
|
2
|
+
node_modules
|
|
3
|
+
.pnp
|
|
4
|
+
.pnp.js
|
|
5
|
+
|
|
6
|
+
# testing
|
|
7
|
+
coverage
|
|
8
|
+
|
|
9
|
+
# next.js
|
|
10
|
+
.next/
|
|
11
|
+
out/
|
|
12
|
+
build
|
|
13
|
+
|
|
14
|
+
# misc
|
|
15
|
+
.DS_Store
|
|
16
|
+
*.pem
|
|
17
|
+
|
|
18
|
+
# debug
|
|
19
|
+
npm-debug.log*
|
|
20
|
+
yarn-debug.log*
|
|
21
|
+
yarn-error.log*
|
|
22
|
+
.pnpm-debug.log*
|
|
23
|
+
|
|
24
|
+
# local env files
|
|
25
|
+
.env.local
|
|
26
|
+
.env.development.local
|
|
27
|
+
.env.test.local
|
|
28
|
+
.env.production.local
|
|
29
|
+
|
|
30
|
+
# turbo
|
|
31
|
+
.turbo
|
|
32
|
+
|
|
33
|
+
dist
|
|
34
|
+
vite.config.ts.timestamp-*.mjs
|
|
35
|
+
dist-web
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "weapp-vite-template",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "1.0.3",
|
|
5
|
+
"private": true,
|
|
6
|
+
"description": "原生微信小程序 weapp-vite 模板",
|
|
7
|
+
"author": "ice breaker <1324318532@qq.com>",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/weapp-vite/weapp-vite.git",
|
|
12
|
+
"directory": "templates/weapp-vite-template"
|
|
13
|
+
},
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/weapp-vite/weapp-vite/issues"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"dev": "weapp-vite dev",
|
|
20
|
+
"dev:open": "weapp-vite dev -o",
|
|
21
|
+
"build": "weapp-vite build",
|
|
22
|
+
"open": "weapp-vite open",
|
|
23
|
+
"g": "weapp-vite generate"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"miniprogram-api-typings": "^4.1.2",
|
|
27
|
+
"sass": "^1.97.1",
|
|
28
|
+
"typescript": "^5.9.3",
|
|
29
|
+
"weapp-vite": "workspace:*"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"description": "项目配置文件",
|
|
3
|
+
"miniprogramRoot": "dist/",
|
|
4
|
+
"compileType": "miniprogram",
|
|
5
|
+
"setting": {
|
|
6
|
+
"babelSetting": {
|
|
7
|
+
"ignore": [],
|
|
8
|
+
"disablePlugins": [],
|
|
9
|
+
"outputPath": ""
|
|
10
|
+
},
|
|
11
|
+
"coverView": false,
|
|
12
|
+
"postcss": false,
|
|
13
|
+
"minified": false,
|
|
14
|
+
"enhance": false,
|
|
15
|
+
"showShadowRootInWxmlPanel": false,
|
|
16
|
+
"packNpmRelationList": [
|
|
17
|
+
{
|
|
18
|
+
"packageJsonPath": "./package.json",
|
|
19
|
+
"miniprogramNpmDistDir": "./dist"
|
|
20
|
+
}
|
|
21
|
+
],
|
|
22
|
+
"ignoreUploadUnusedFiles": true,
|
|
23
|
+
"compileHotReLoad": false,
|
|
24
|
+
"skylineRenderEnable": true,
|
|
25
|
+
"packNpmManually": true,
|
|
26
|
+
"es6": true
|
|
27
|
+
},
|
|
28
|
+
"simulatorType": "wechat",
|
|
29
|
+
"simulatorPluginLibVersion": {},
|
|
30
|
+
"condition": {},
|
|
31
|
+
"srcMiniprogramRoot": "dist/",
|
|
32
|
+
"editorSetting": {
|
|
33
|
+
"tabIndent": "insertSpaces",
|
|
34
|
+
"tabSize": 2
|
|
35
|
+
},
|
|
36
|
+
"libVersion": "2.32.3",
|
|
37
|
+
"packOptions": {
|
|
38
|
+
"ignore": [],
|
|
39
|
+
"include": []
|
|
40
|
+
},
|
|
41
|
+
"appid": "wx6ffee4673b257014"
|
|
42
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
{
|
|
2
|
+
"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
|
|
3
|
+
"projectname": "weapp-vite-template",
|
|
4
|
+
"setting": {
|
|
5
|
+
"compileHotReLoad": true
|
|
6
|
+
},
|
|
7
|
+
"libVersion": "3.9.0"
|
|
8
|
+
}
|
|
Binary file
|
|
File without changes
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
.hello-card {
|
|
2
|
+
width: 640rpx;
|
|
3
|
+
margin: 48rpx auto;
|
|
4
|
+
padding: 32rpx;
|
|
5
|
+
border-radius: 32rpx;
|
|
6
|
+
background: #ffffff;
|
|
7
|
+
box-shadow: 0 20rpx 60rpx rgba(15, 23, 42, 0.08);
|
|
8
|
+
display: flex;
|
|
9
|
+
flex-direction: column;
|
|
10
|
+
gap: 24rpx;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.hello-title {
|
|
14
|
+
font-size: 36rpx;
|
|
15
|
+
font-weight: 600;
|
|
16
|
+
color: #2563eb;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.hello-body {
|
|
20
|
+
font-size: 28rpx;
|
|
21
|
+
line-height: 1.6;
|
|
22
|
+
color: #334155;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.hello-actions {
|
|
26
|
+
display: flex;
|
|
27
|
+
flex-wrap: wrap;
|
|
28
|
+
gap: 20rpx;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.hello-button {
|
|
32
|
+
padding: 16rpx 32rpx;
|
|
33
|
+
border-radius: 999rpx;
|
|
34
|
+
background: #2563eb;
|
|
35
|
+
color: #ffffff;
|
|
36
|
+
font-size: 26rpx;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.hello-button--ghost {
|
|
40
|
+
background: #e2e8f0;
|
|
41
|
+
color: #1e293b;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.hello-tip {
|
|
45
|
+
font-size: 24rpx;
|
|
46
|
+
color: #94a3b8;
|
|
47
|
+
}
|