@weapp-core/init 1.1.15 → 1.1.16
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/index.cjs +260 -59
- package/dist/index.js +259 -58
- package/package.json +5 -5
- package/templates/default/package.json +3 -3
- package/templates/tailwindcss/package.json +6 -6
- package/templates/tdesign/package.json +9 -9
- package/templates/vant/package.json +6 -6
package/dist/index.cjs
CHANGED
|
@@ -41,7 +41,7 @@ __export(index_exports, {
|
|
|
41
41
|
});
|
|
42
42
|
module.exports = __toCommonJS(index_exports);
|
|
43
43
|
|
|
44
|
-
// ../../node_modules/.pnpm/tsup@8.3.
|
|
44
|
+
// ../../node_modules/.pnpm/tsup@8.3.6_@swc+core@1.10.15_jiti@2.4.2_postcss@8.5.1_tsx@4.19.2_typescript@5.7.3_yaml@2.7.0/node_modules/tsup/assets/cjs_shims.js
|
|
45
45
|
var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
|
|
46
46
|
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
47
47
|
|
|
@@ -52,7 +52,172 @@ var import_logger = __toESM(require("@weapp-core/logger"), 1);
|
|
|
52
52
|
var import_shared = require("@weapp-core/shared");
|
|
53
53
|
var import_fs_extra = __toESM(require("fs-extra"), 1);
|
|
54
54
|
|
|
55
|
-
// ../../node_modules/.pnpm/pathe@
|
|
55
|
+
// ../../node_modules/.pnpm/pathe@2.0.2/node_modules/pathe/dist/shared/pathe.UZ-hd4nF.mjs
|
|
56
|
+
var _lazyMatch = () => {
|
|
57
|
+
var __lib__ = (() => {
|
|
58
|
+
var m = Object.defineProperty, V = Object.getOwnPropertyDescriptor, G = Object.getOwnPropertyNames, T = Object.prototype.hasOwnProperty, q = (r, e) => {
|
|
59
|
+
for (var n in e) m(r, n, { get: e[n], enumerable: true });
|
|
60
|
+
}, H = (r, e, n, t) => {
|
|
61
|
+
if (typeof e == "object" || typeof e == "function") for (let a of G(e)) !T.call(r, a) && a !== n && m(r, a, { get: () => e[a], enumerable: !(t = V(e, a)) || t.enumerable });
|
|
62
|
+
return r;
|
|
63
|
+
}, J = (r) => H(m({}, "__esModule", { value: true }), r), w = {};
|
|
64
|
+
q(w, { zeptomatch: () => re });
|
|
65
|
+
var A = (r) => Array.isArray(r), d = (r) => typeof r == "function", Q = (r) => r.length === 0, W = (r) => typeof r == "number", K = (r) => typeof r == "object" && r !== null, X = (r) => r instanceof RegExp, b = (r) => typeof r == "string", h = (r) => r === void 0, Y = (r) => {
|
|
66
|
+
const e = /* @__PURE__ */ new Map();
|
|
67
|
+
return (n) => {
|
|
68
|
+
const t = e.get(n);
|
|
69
|
+
if (t) return t;
|
|
70
|
+
const a = r(n);
|
|
71
|
+
return e.set(n, a), a;
|
|
72
|
+
};
|
|
73
|
+
}, rr = (r, e, n = {}) => {
|
|
74
|
+
const t = { cache: {}, input: r, index: 0, indexMax: 0, options: n, output: [] };
|
|
75
|
+
if (v(e)(t) && t.index === r.length) return t.output;
|
|
76
|
+
throw new Error(`Failed to parse at index ${t.indexMax}`);
|
|
77
|
+
}, i = (r, e) => A(r) ? er(r, e) : b(r) ? tr(r, e) : nr(r, e), er = (r, e) => {
|
|
78
|
+
const n = {};
|
|
79
|
+
for (const t of r) {
|
|
80
|
+
if (t.length !== 1) throw new Error(`Invalid character: "${t}"`);
|
|
81
|
+
const a = t.charCodeAt(0);
|
|
82
|
+
n[a] = true;
|
|
83
|
+
}
|
|
84
|
+
return (t) => {
|
|
85
|
+
const a = t.index, o = t.input;
|
|
86
|
+
for (; t.index < o.length && o.charCodeAt(t.index) in n; ) t.index += 1;
|
|
87
|
+
const u = t.index;
|
|
88
|
+
if (u > a) {
|
|
89
|
+
if (!h(e) && !t.options.silent) {
|
|
90
|
+
const s = t.input.slice(a, u), c = d(e) ? e(s, o, String(a)) : e;
|
|
91
|
+
h(c) || t.output.push(c);
|
|
92
|
+
}
|
|
93
|
+
t.indexMax = Math.max(t.indexMax, t.index);
|
|
94
|
+
}
|
|
95
|
+
return true;
|
|
96
|
+
};
|
|
97
|
+
}, nr = (r, e) => {
|
|
98
|
+
const n = r.source, t = r.flags.replace(/y|$/, "y"), a = new RegExp(n, t);
|
|
99
|
+
return g((o) => {
|
|
100
|
+
a.lastIndex = o.index;
|
|
101
|
+
const u = a.exec(o.input);
|
|
102
|
+
if (u) {
|
|
103
|
+
if (!h(e) && !o.options.silent) {
|
|
104
|
+
const s = d(e) ? e(...u, o.input, String(o.index)) : e;
|
|
105
|
+
h(s) || o.output.push(s);
|
|
106
|
+
}
|
|
107
|
+
return o.index += u[0].length, o.indexMax = Math.max(o.indexMax, o.index), true;
|
|
108
|
+
} else return false;
|
|
109
|
+
});
|
|
110
|
+
}, tr = (r, e) => (n) => {
|
|
111
|
+
if (n.input.startsWith(r, n.index)) {
|
|
112
|
+
if (!h(e) && !n.options.silent) {
|
|
113
|
+
const a = d(e) ? e(r, n.input, String(n.index)) : e;
|
|
114
|
+
h(a) || n.output.push(a);
|
|
115
|
+
}
|
|
116
|
+
return n.index += r.length, n.indexMax = Math.max(n.indexMax, n.index), true;
|
|
117
|
+
} else return false;
|
|
118
|
+
}, C = (r, e, n, t) => {
|
|
119
|
+
const a = v(r);
|
|
120
|
+
return g(_(M((o) => {
|
|
121
|
+
let u = 0;
|
|
122
|
+
for (; u < n; ) {
|
|
123
|
+
const s = o.index;
|
|
124
|
+
if (!a(o) || (u += 1, o.index === s)) break;
|
|
125
|
+
}
|
|
126
|
+
return u >= e;
|
|
127
|
+
})));
|
|
128
|
+
}, ar = (r, e) => C(r, 0, 1), f = (r, e) => C(r, 0, 1 / 0), x = (r, e) => {
|
|
129
|
+
const n = r.map(v);
|
|
130
|
+
return g(_(M((t) => {
|
|
131
|
+
for (let a = 0, o = n.length; a < o; a++) if (!n[a](t)) return false;
|
|
132
|
+
return true;
|
|
133
|
+
})));
|
|
134
|
+
}, l = (r, e) => {
|
|
135
|
+
const n = r.map(v);
|
|
136
|
+
return g(_((t) => {
|
|
137
|
+
for (let a = 0, o = n.length; a < o; a++) if (n[a](t)) return true;
|
|
138
|
+
return false;
|
|
139
|
+
}));
|
|
140
|
+
}, M = (r, e = false) => {
|
|
141
|
+
const n = v(r);
|
|
142
|
+
return (t) => {
|
|
143
|
+
const a = t.index, o = t.output.length, u = n(t);
|
|
144
|
+
return (!u || e) && (t.index = a, t.output.length !== o && (t.output.length = o)), u;
|
|
145
|
+
};
|
|
146
|
+
}, _ = (r, e) => {
|
|
147
|
+
const n = v(r);
|
|
148
|
+
return n;
|
|
149
|
+
}, g = /* @__PURE__ */ (() => {
|
|
150
|
+
let r = 0;
|
|
151
|
+
return (e) => {
|
|
152
|
+
const n = v(e), t = r += 1;
|
|
153
|
+
return (a) => {
|
|
154
|
+
var o;
|
|
155
|
+
if (a.options.memoization === false) return n(a);
|
|
156
|
+
const u = a.index, s = (o = a.cache)[t] || (o[t] = /* @__PURE__ */ new Map()), c = s.get(u);
|
|
157
|
+
if (c === false) return false;
|
|
158
|
+
if (W(c)) return a.index = c, true;
|
|
159
|
+
if (c) return a.index = c.index, c.output?.length && a.output.push(...c.output), true;
|
|
160
|
+
{
|
|
161
|
+
const Z = a.output.length;
|
|
162
|
+
if (n(a)) {
|
|
163
|
+
const D = a.index, U = a.output.length;
|
|
164
|
+
if (U > Z) {
|
|
165
|
+
const ee = a.output.slice(Z, U);
|
|
166
|
+
s.set(u, { index: D, output: ee });
|
|
167
|
+
} else s.set(u, D);
|
|
168
|
+
return true;
|
|
169
|
+
} else return s.set(u, false), false;
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
})(), E = (r) => {
|
|
174
|
+
let e;
|
|
175
|
+
return (n) => (e || (e = v(r())), e(n));
|
|
176
|
+
}, v = Y((r) => {
|
|
177
|
+
if (d(r)) return Q(r) ? E(r) : r;
|
|
178
|
+
if (b(r) || X(r)) return i(r);
|
|
179
|
+
if (A(r)) return x(r);
|
|
180
|
+
if (K(r)) return l(Object.values(r));
|
|
181
|
+
throw new Error("Invalid rule");
|
|
182
|
+
}), P = "abcdefghijklmnopqrstuvwxyz", ir = (r) => {
|
|
183
|
+
let e = "";
|
|
184
|
+
for (; r > 0; ) {
|
|
185
|
+
const n = (r - 1) % 26;
|
|
186
|
+
e = P[n] + e, r = Math.floor((r - 1) / 26);
|
|
187
|
+
}
|
|
188
|
+
return e;
|
|
189
|
+
}, z = (r) => {
|
|
190
|
+
let e = 0;
|
|
191
|
+
for (let n = 0, t = r.length; n < t; n++) e = e * 26 + P.indexOf(r[n]) + 1;
|
|
192
|
+
return e;
|
|
193
|
+
}, S = (r, e) => {
|
|
194
|
+
if (e < r) return S(e, r);
|
|
195
|
+
const n = [];
|
|
196
|
+
for (; r <= e; ) n.push(r++);
|
|
197
|
+
return n;
|
|
198
|
+
}, or = (r, e, n) => S(r, e).map((t) => String(t).padStart(n, "0")), O = (r, e) => S(z(r), z(e)).map(ir), p = (r) => r, R = (r) => ur((e) => rr(e, r, { memoization: false }).join("")), ur = (r) => {
|
|
199
|
+
const e = {};
|
|
200
|
+
return (n) => e[n] ?? (e[n] = r(n));
|
|
201
|
+
}, sr = i(/^\*\*\/\*$/, ".*"), cr = i(/^\*\*\/(\*)?([ a-zA-Z0-9._-]+)$/, (r, e, n) => `.*${e ? "" : "(?:^|/)"}${n.replaceAll(".", "\\.")}`), lr = i(/^\*\*\/(\*)?([ a-zA-Z0-9._-]*)\{([ a-zA-Z0-9._-]+(?:,[ a-zA-Z0-9._-]+)*)\}$/, (r, e, n, t) => `.*${e ? "" : "(?:^|/)"}${n.replaceAll(".", "\\.")}(?:${t.replaceAll(",", "|").replaceAll(".", "\\.")})`), y = i(/\\./, p), pr = i(/[$.*+?^(){}[\]\|]/, (r) => `\\${r}`), vr = i(/./, p), hr = i(/^(?:!!)*!(.*)$/, (r, e) => `(?!^${L(e)}$).*?`), dr = i(/^(!!)+/, ""), fr = l([hr, dr]), xr = i(/\/(\*\*\/)+/, "(?:/.+/|/)"), gr = i(/^(\*\*\/)+/, "(?:^|.*/)"), mr = i(/\/(\*\*)$/, "(?:/.*|$)"), _r = i(/\*\*/, ".*"), j = l([xr, gr, mr, _r]), Sr = i(/\*\/(?!\*\*\/)/, "[^/]*/"), yr = i(/\*/, "[^/]*"), N = l([Sr, yr]), k = i("?", "[^/]"), $r = i("[", p), wr = i("]", p), Ar = i(/[!^]/, "^/"), br = i(/[a-z]-[a-z]|[0-9]-[0-9]/i, p), Cr = i(/[$.*+?^(){}[\|]/, (r) => `\\${r}`), Mr = i(/[^\]]/, p), Er = l([y, Cr, br, Mr]), B = x([$r, ar(Ar), f(Er), wr]), Pr = i("{", "(?:"), zr = i("}", ")"), Or = i(/(\d+)\.\.(\d+)/, (r, e, n) => or(+e, +n, Math.min(e.length, n.length)).join("|")), Rr = i(/([a-z]+)\.\.([a-z]+)/, (r, e, n) => O(e, n).join("|")), jr = i(/([A-Z]+)\.\.([A-Z]+)/, (r, e, n) => O(e.toLowerCase(), n.toLowerCase()).join("|").toUpperCase()), Nr = l([Or, Rr, jr]), I = x([Pr, Nr, zr]), kr = i("{", "(?:"), Br = i("}", ")"), Ir = i(",", "|"), Fr = i(/[$.*+?^(){[\]\|]/, (r) => `\\${r}`), Lr = i(/[^}]/, p), Zr = E(() => F), Dr = l([j, N, k, B, I, Zr, y, Fr, Ir, Lr]), F = x([kr, f(Dr), Br]), Ur = f(l([sr, cr, lr, fr, j, N, k, B, I, F, y, pr, vr])), Vr = Ur, Gr = R(Vr), L = Gr, Tr = i(/\\./, p), qr = i(/./, p), Hr = i(/\*\*\*+/, "*"), Jr = i(/([^/{[(!])\*\*/, (r, e) => `${e}*`), Qr = i(/(^|.)\*\*(?=[^*/)\]}])/, (r, e) => `${e}*`), Wr = f(l([Tr, Hr, Jr, Qr, qr])), Kr = Wr, Xr = R(Kr), Yr = Xr, $ = (r, e) => {
|
|
202
|
+
const n = Array.isArray(r) ? r : [r];
|
|
203
|
+
if (!n.length) return false;
|
|
204
|
+
const t = n.map($.compile), a = n.every((s) => /(\/(?:\*\*)?|\[\/\])$/.test(s)), o = e.replace(/[\\\/]+/g, "/").replace(/\/$/, a ? "/" : "");
|
|
205
|
+
return t.some((s) => s.test(o));
|
|
206
|
+
};
|
|
207
|
+
$.compile = (r) => new RegExp(`^${L(Yr(r))}$`, "s");
|
|
208
|
+
var re = $;
|
|
209
|
+
return J(w);
|
|
210
|
+
})();
|
|
211
|
+
return __lib__.default || __lib__;
|
|
212
|
+
};
|
|
213
|
+
var _match;
|
|
214
|
+
var zeptomatch = (path, pattern) => {
|
|
215
|
+
if (!_match) {
|
|
216
|
+
_match = _lazyMatch();
|
|
217
|
+
_lazyMatch = null;
|
|
218
|
+
}
|
|
219
|
+
return _match(path, pattern);
|
|
220
|
+
};
|
|
56
221
|
var _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
57
222
|
function normalizeWindowsPath(input = "") {
|
|
58
223
|
if (!input) {
|
|
@@ -64,55 +229,58 @@ var _UNC_REGEX = /^[/\\]{2}/;
|
|
|
64
229
|
var _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
|
|
65
230
|
var _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
|
|
66
231
|
var _ROOT_FOLDER_RE = /^\/([A-Za-z]:)?$/;
|
|
232
|
+
var _EXTNAME_RE = /.(\.[^./]+|\.)$/;
|
|
233
|
+
var _PATH_ROOT_RE = /^[/\\]|^[a-zA-Z]:[/\\]/;
|
|
67
234
|
var sep = "/";
|
|
68
|
-
var
|
|
69
|
-
|
|
70
|
-
if (path2.length === 0) {
|
|
235
|
+
var normalize = function(path) {
|
|
236
|
+
if (path.length === 0) {
|
|
71
237
|
return ".";
|
|
72
238
|
}
|
|
73
|
-
|
|
74
|
-
const isUNCPath =
|
|
75
|
-
const isPathAbsolute = isAbsolute(
|
|
76
|
-
const trailingSeparator =
|
|
77
|
-
|
|
78
|
-
if (
|
|
239
|
+
path = normalizeWindowsPath(path);
|
|
240
|
+
const isUNCPath = path.match(_UNC_REGEX);
|
|
241
|
+
const isPathAbsolute = isAbsolute(path);
|
|
242
|
+
const trailingSeparator = path[path.length - 1] === "/";
|
|
243
|
+
path = normalizeString(path, !isPathAbsolute);
|
|
244
|
+
if (path.length === 0) {
|
|
79
245
|
if (isPathAbsolute) {
|
|
80
246
|
return "/";
|
|
81
247
|
}
|
|
82
248
|
return trailingSeparator ? "./" : ".";
|
|
83
249
|
}
|
|
84
250
|
if (trailingSeparator) {
|
|
85
|
-
|
|
251
|
+
path += "/";
|
|
86
252
|
}
|
|
87
|
-
if (_DRIVE_LETTER_RE.test(
|
|
88
|
-
|
|
253
|
+
if (_DRIVE_LETTER_RE.test(path)) {
|
|
254
|
+
path += "/";
|
|
89
255
|
}
|
|
90
256
|
if (isUNCPath) {
|
|
91
257
|
if (!isPathAbsolute) {
|
|
92
|
-
return `//./${
|
|
258
|
+
return `//./${path}`;
|
|
93
259
|
}
|
|
94
|
-
return `//${
|
|
260
|
+
return `//${path}`;
|
|
95
261
|
}
|
|
96
|
-
return isPathAbsolute && !isAbsolute(
|
|
262
|
+
return isPathAbsolute && !isAbsolute(path) ? `/${path}` : path;
|
|
97
263
|
};
|
|
98
|
-
var join = function(...
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
if (
|
|
105
|
-
|
|
106
|
-
|
|
264
|
+
var join = function(...segments) {
|
|
265
|
+
let path = "";
|
|
266
|
+
for (const seg of segments) {
|
|
267
|
+
if (!seg) {
|
|
268
|
+
continue;
|
|
269
|
+
}
|
|
270
|
+
if (path.length > 0) {
|
|
271
|
+
const pathTrailing = path[path.length - 1] === "/";
|
|
272
|
+
const segLeading = seg[0] === "/";
|
|
273
|
+
const both = pathTrailing && segLeading;
|
|
274
|
+
if (both) {
|
|
275
|
+
path += seg.slice(1);
|
|
107
276
|
} else {
|
|
108
|
-
|
|
277
|
+
path += pathTrailing || segLeading ? seg : `/${seg}`;
|
|
109
278
|
}
|
|
279
|
+
} else {
|
|
280
|
+
path += seg;
|
|
110
281
|
}
|
|
111
282
|
}
|
|
112
|
-
|
|
113
|
-
return ".";
|
|
114
|
-
}
|
|
115
|
-
return normalize(joined.replace(/\/\/+/g, "/"));
|
|
283
|
+
return normalize(path);
|
|
116
284
|
};
|
|
117
285
|
function cwd() {
|
|
118
286
|
if (typeof process !== "undefined" && typeof process.cwd === "function") {
|
|
@@ -125,12 +293,12 @@ var resolve = function(...arguments_) {
|
|
|
125
293
|
let resolvedPath = "";
|
|
126
294
|
let resolvedAbsolute = false;
|
|
127
295
|
for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
|
|
128
|
-
const
|
|
129
|
-
if (!
|
|
296
|
+
const path = index >= 0 ? arguments_[index] : cwd();
|
|
297
|
+
if (!path || path.length === 0) {
|
|
130
298
|
continue;
|
|
131
299
|
}
|
|
132
|
-
resolvedPath = `${
|
|
133
|
-
resolvedAbsolute = isAbsolute(
|
|
300
|
+
resolvedPath = `${path}/${resolvedPath}`;
|
|
301
|
+
resolvedAbsolute = isAbsolute(path);
|
|
134
302
|
}
|
|
135
303
|
resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
|
|
136
304
|
if (resolvedAbsolute && !isAbsolute(resolvedPath)) {
|
|
@@ -138,15 +306,15 @@ var resolve = function(...arguments_) {
|
|
|
138
306
|
}
|
|
139
307
|
return resolvedPath.length > 0 ? resolvedPath : ".";
|
|
140
308
|
};
|
|
141
|
-
function normalizeString(
|
|
309
|
+
function normalizeString(path, allowAboveRoot) {
|
|
142
310
|
let res = "";
|
|
143
311
|
let lastSegmentLength = 0;
|
|
144
312
|
let lastSlash = -1;
|
|
145
313
|
let dots = 0;
|
|
146
314
|
let char = null;
|
|
147
|
-
for (let index = 0; index <=
|
|
148
|
-
if (index <
|
|
149
|
-
char =
|
|
315
|
+
for (let index = 0; index <= path.length; ++index) {
|
|
316
|
+
if (index < path.length) {
|
|
317
|
+
char = path[index];
|
|
150
318
|
} else if (char === "/") {
|
|
151
319
|
break;
|
|
152
320
|
} else {
|
|
@@ -182,9 +350,9 @@ function normalizeString(path2, allowAboveRoot) {
|
|
|
182
350
|
}
|
|
183
351
|
} else {
|
|
184
352
|
if (res.length > 0) {
|
|
185
|
-
res += `/${
|
|
353
|
+
res += `/${path.slice(lastSlash + 1, index)}`;
|
|
186
354
|
} else {
|
|
187
|
-
res =
|
|
355
|
+
res = path.slice(lastSlash + 1, index);
|
|
188
356
|
}
|
|
189
357
|
lastSegmentLength = index - lastSlash - 1;
|
|
190
358
|
}
|
|
@@ -204,8 +372,8 @@ var isAbsolute = function(p) {
|
|
|
204
372
|
var toNamespacedPath = function(p) {
|
|
205
373
|
return normalizeWindowsPath(p);
|
|
206
374
|
};
|
|
207
|
-
var _EXTNAME_RE = /.(\.[^./]+)$/;
|
|
208
375
|
var extname = function(p) {
|
|
376
|
+
if (p === "..") return "";
|
|
209
377
|
const match = _EXTNAME_RE.exec(normalizeWindowsPath(p));
|
|
210
378
|
return match && match[1] || "";
|
|
211
379
|
};
|
|
@@ -233,17 +401,28 @@ var dirname = function(p) {
|
|
|
233
401
|
return segments.join("/") || (isAbsolute(p) ? "/" : ".");
|
|
234
402
|
};
|
|
235
403
|
var format = function(p) {
|
|
236
|
-
const
|
|
404
|
+
const ext = p.ext ? p.ext.startsWith(".") ? p.ext : `.${p.ext}` : "";
|
|
405
|
+
const segments = [p.root, p.dir, p.base ?? (p.name ?? "") + ext].filter(
|
|
406
|
+
Boolean
|
|
407
|
+
);
|
|
237
408
|
return normalizeWindowsPath(
|
|
238
409
|
p.root ? resolve(...segments) : segments.join("/")
|
|
239
410
|
);
|
|
240
411
|
};
|
|
241
412
|
var basename = function(p, extension) {
|
|
242
|
-
const
|
|
413
|
+
const segments = normalizeWindowsPath(p).split("/");
|
|
414
|
+
let lastSegment = "";
|
|
415
|
+
for (let i = segments.length - 1; i >= 0; i--) {
|
|
416
|
+
const val = segments[i];
|
|
417
|
+
if (val) {
|
|
418
|
+
lastSegment = val;
|
|
419
|
+
break;
|
|
420
|
+
}
|
|
421
|
+
}
|
|
243
422
|
return extension && lastSegment.endsWith(extension) ? lastSegment.slice(0, -extension.length) : lastSegment;
|
|
244
423
|
};
|
|
245
424
|
var parse = function(p) {
|
|
246
|
-
const root =
|
|
425
|
+
const root = _PATH_ROOT_RE.exec(p)?.[0]?.replace(/\\/g, "/") || "";
|
|
247
426
|
const base = basename(p);
|
|
248
427
|
const extension = extname(base);
|
|
249
428
|
return {
|
|
@@ -254,15 +433,18 @@ var parse = function(p) {
|
|
|
254
433
|
name: base.slice(0, base.length - extension.length)
|
|
255
434
|
};
|
|
256
435
|
};
|
|
257
|
-
var
|
|
436
|
+
var matchesGlob = (path, pattern) => {
|
|
437
|
+
return zeptomatch(pattern, normalize(path));
|
|
438
|
+
};
|
|
439
|
+
var _path = {
|
|
258
440
|
__proto__: null,
|
|
259
441
|
basename,
|
|
260
|
-
delimiter,
|
|
261
442
|
dirname,
|
|
262
443
|
extname,
|
|
263
444
|
format,
|
|
264
445
|
isAbsolute,
|
|
265
446
|
join,
|
|
447
|
+
matchesGlob,
|
|
266
448
|
normalize,
|
|
267
449
|
normalizeString,
|
|
268
450
|
parse,
|
|
@@ -272,8 +454,24 @@ var path = {
|
|
|
272
454
|
toNamespacedPath
|
|
273
455
|
};
|
|
274
456
|
|
|
457
|
+
// ../../node_modules/.pnpm/pathe@2.0.2/node_modules/pathe/dist/index.mjs
|
|
458
|
+
var delimiter = /* @__PURE__ */ (() => globalThis.process?.platform === "win32" ? ";" : ":")();
|
|
459
|
+
var _platforms = { posix: void 0, win32: void 0 };
|
|
460
|
+
var mix = (del = delimiter) => {
|
|
461
|
+
return new Proxy(_path, {
|
|
462
|
+
get(_, prop) {
|
|
463
|
+
if (prop === "delimiter") return del;
|
|
464
|
+
if (prop === "posix") return posix;
|
|
465
|
+
if (prop === "win32") return win32;
|
|
466
|
+
return _platforms[prop] || _path[prop];
|
|
467
|
+
}
|
|
468
|
+
});
|
|
469
|
+
};
|
|
470
|
+
var posix = /* @__PURE__ */ mix(":");
|
|
471
|
+
var win32 = /* @__PURE__ */ mix(";");
|
|
472
|
+
|
|
275
473
|
// ../../packages/weapp-vite/package.json
|
|
276
|
-
var version = "2.
|
|
474
|
+
var version = "2.1.3";
|
|
277
475
|
|
|
278
476
|
// src/context.ts
|
|
279
477
|
function createContext() {
|
|
@@ -441,7 +639,7 @@ export default defineConfig({
|
|
|
441
639
|
}
|
|
442
640
|
|
|
443
641
|
// src/index.ts
|
|
444
|
-
var __dirname =
|
|
642
|
+
var __dirname = posix.dirname((0, import_node_url.fileURLToPath)(importMetaUrl));
|
|
445
643
|
var ctx = createContext();
|
|
446
644
|
async function createOrUpdateProjectConfig(options) {
|
|
447
645
|
const { root, dest, cb, write, filename } = (0, import_shared.defu)(
|
|
@@ -452,7 +650,7 @@ async function createOrUpdateProjectConfig(options) {
|
|
|
452
650
|
}
|
|
453
651
|
);
|
|
454
652
|
const projectConfigFilename = ctx.projectConfig.name = filename;
|
|
455
|
-
const projectConfigPath = ctx.projectConfig.path =
|
|
653
|
+
const projectConfigPath = ctx.projectConfig.path = posix.resolve(root, projectConfigFilename);
|
|
456
654
|
if (await import_fs_extra.default.exists(projectConfigPath)) {
|
|
457
655
|
try {
|
|
458
656
|
const projectConfig = await import_fs_extra.default.readJSON(projectConfigPath);
|
|
@@ -541,7 +739,7 @@ async function createOrUpdatePackageJson(options) {
|
|
|
541
739
|
command: "weapp-vite"
|
|
542
740
|
});
|
|
543
741
|
const packageJsonFilename = ctx.packageJson.name = filename;
|
|
544
|
-
const packageJsonPath = ctx.packageJson.path =
|
|
742
|
+
const packageJsonPath = ctx.packageJson.path = posix.resolve(root, packageJsonFilename);
|
|
545
743
|
let packageJson;
|
|
546
744
|
if (await import_fs_extra.default.exists(packageJsonPath)) {
|
|
547
745
|
packageJson = await import_fs_extra.default.readJSON(packageJsonPath);
|
|
@@ -583,7 +781,7 @@ async function initViteConfigFile(options) {
|
|
|
583
781
|
const { root, write = true } = options;
|
|
584
782
|
const type = (0, import_shared.get)(ctx.packageJson.value, "type");
|
|
585
783
|
const targetFilename = ctx.viteConfig.name = type === "module" ? "vite.config.ts" : "vite.config.mts";
|
|
586
|
-
const viteConfigFilePath = ctx.viteConfig.path =
|
|
784
|
+
const viteConfigFilePath = ctx.viteConfig.path = posix.resolve(root, targetFilename);
|
|
587
785
|
const viteConfigFileCode = ctx.viteConfig.value = getDefaultViteConfig();
|
|
588
786
|
if (write) {
|
|
589
787
|
await import_fs_extra.default.outputFile(viteConfigFilePath, viteConfigFileCode, "utf8");
|
|
@@ -594,7 +792,7 @@ async function initViteConfigFile(options) {
|
|
|
594
792
|
async function initTsDtsFile(options) {
|
|
595
793
|
const { root, write = true } = options;
|
|
596
794
|
const targetFilename = "vite-env.d.ts";
|
|
597
|
-
const viteDtsFilePath =
|
|
795
|
+
const viteDtsFilePath = posix.resolve(root, targetFilename);
|
|
598
796
|
const code = getDefaultTsDts();
|
|
599
797
|
if (write) {
|
|
600
798
|
await import_fs_extra.default.outputFile(viteDtsFilePath, code, "utf8");
|
|
@@ -605,9 +803,9 @@ async function initTsDtsFile(options) {
|
|
|
605
803
|
async function initTsJsonFiles(options) {
|
|
606
804
|
const { root, write = true } = options;
|
|
607
805
|
const tsJsonFilename = ctx.tsconfig.name = "tsconfig.json";
|
|
608
|
-
const tsJsonFilePath = ctx.tsconfig.path =
|
|
806
|
+
const tsJsonFilePath = ctx.tsconfig.path = posix.resolve(root, tsJsonFilename);
|
|
609
807
|
const tsNodeJsonFilename = ctx.tsconfigNode.name = "tsconfig.node.json";
|
|
610
|
-
const tsNodeJsonFilePath = ctx.tsconfigNode.path =
|
|
808
|
+
const tsNodeJsonFilePath = ctx.tsconfigNode.path = posix.resolve(root, tsNodeJsonFilename);
|
|
611
809
|
if (write) {
|
|
612
810
|
const tsJsonValue = getDefaultTsconfigJson();
|
|
613
811
|
if (write) {
|
|
@@ -637,7 +835,7 @@ async function initTsJsonFiles(options) {
|
|
|
637
835
|
}
|
|
638
836
|
async function updateGitIgnore(options) {
|
|
639
837
|
const { root, write = true } = options;
|
|
640
|
-
const filepath =
|
|
838
|
+
const filepath = posix.resolve(root, ".gitignore");
|
|
641
839
|
const data = getDefaultGitignore();
|
|
642
840
|
if (write) {
|
|
643
841
|
await import_fs_extra.default.outputFile(filepath, data, {
|
|
@@ -659,10 +857,10 @@ async function initConfig(options) {
|
|
|
659
857
|
return ctx;
|
|
660
858
|
}
|
|
661
859
|
async function createProject(targetDir = "", templateName = "default" /* default */) {
|
|
662
|
-
const targetTemplateDir =
|
|
860
|
+
const targetTemplateDir = posix.resolve(__dirname, "../templates", templateName);
|
|
663
861
|
if (await import_fs_extra.default.exists(targetTemplateDir)) {
|
|
664
862
|
await import_fs_extra.default.copy(targetTemplateDir, targetDir);
|
|
665
|
-
const pkgJsonPath =
|
|
863
|
+
const pkgJsonPath = posix.resolve(targetTemplateDir, "package.json");
|
|
666
864
|
const pkgJson = await import_fs_extra.default.readJson(pkgJsonPath);
|
|
667
865
|
if (pkgJson.devDependencies) {
|
|
668
866
|
if (pkgJson.devDependencies["weapp-vite"]) {
|
|
@@ -672,7 +870,10 @@ async function createProject(targetDir = "", templateName = "default" /* default
|
|
|
672
870
|
pkgJson.devDependencies["weapp-tailwindcss"] = "latest";
|
|
673
871
|
}
|
|
674
872
|
}
|
|
675
|
-
await import_fs_extra.default.writeJson(
|
|
873
|
+
await import_fs_extra.default.writeJson(posix.resolve(targetDir, "package.json"), pkgJson, { spaces: 2 });
|
|
874
|
+
if (!await import_fs_extra.default.exists(posix.resolve(targetDir, ".gitignore"))) {
|
|
875
|
+
await updateGitIgnore({ root: targetDir, write: true });
|
|
876
|
+
}
|
|
676
877
|
import_logger.default.log(`\u2728 \u521B\u5EFA\u6A21\u677F\u6210\u529F!`);
|
|
677
878
|
} else {
|
|
678
879
|
import_logger.default.warn(`\u6CA1\u6709\u627E\u5230 ${templateName} \u6A21\u677F!`);
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,172 @@ import logger from "@weapp-core/logger";
|
|
|
5
5
|
import { defu, get, set } from "@weapp-core/shared";
|
|
6
6
|
import fs from "fs-extra";
|
|
7
7
|
|
|
8
|
-
// ../../node_modules/.pnpm/pathe@
|
|
8
|
+
// ../../node_modules/.pnpm/pathe@2.0.2/node_modules/pathe/dist/shared/pathe.UZ-hd4nF.mjs
|
|
9
|
+
var _lazyMatch = () => {
|
|
10
|
+
var __lib__ = (() => {
|
|
11
|
+
var m = Object.defineProperty, V = Object.getOwnPropertyDescriptor, G = Object.getOwnPropertyNames, T = Object.prototype.hasOwnProperty, q = (r, e) => {
|
|
12
|
+
for (var n in e) m(r, n, { get: e[n], enumerable: true });
|
|
13
|
+
}, H = (r, e, n, t) => {
|
|
14
|
+
if (typeof e == "object" || typeof e == "function") for (let a of G(e)) !T.call(r, a) && a !== n && m(r, a, { get: () => e[a], enumerable: !(t = V(e, a)) || t.enumerable });
|
|
15
|
+
return r;
|
|
16
|
+
}, J = (r) => H(m({}, "__esModule", { value: true }), r), w = {};
|
|
17
|
+
q(w, { zeptomatch: () => re });
|
|
18
|
+
var A = (r) => Array.isArray(r), d = (r) => typeof r == "function", Q = (r) => r.length === 0, W = (r) => typeof r == "number", K = (r) => typeof r == "object" && r !== null, X = (r) => r instanceof RegExp, b = (r) => typeof r == "string", h = (r) => r === void 0, Y = (r) => {
|
|
19
|
+
const e = /* @__PURE__ */ new Map();
|
|
20
|
+
return (n) => {
|
|
21
|
+
const t = e.get(n);
|
|
22
|
+
if (t) return t;
|
|
23
|
+
const a = r(n);
|
|
24
|
+
return e.set(n, a), a;
|
|
25
|
+
};
|
|
26
|
+
}, rr = (r, e, n = {}) => {
|
|
27
|
+
const t = { cache: {}, input: r, index: 0, indexMax: 0, options: n, output: [] };
|
|
28
|
+
if (v(e)(t) && t.index === r.length) return t.output;
|
|
29
|
+
throw new Error(`Failed to parse at index ${t.indexMax}`);
|
|
30
|
+
}, i = (r, e) => A(r) ? er(r, e) : b(r) ? tr(r, e) : nr(r, e), er = (r, e) => {
|
|
31
|
+
const n = {};
|
|
32
|
+
for (const t of r) {
|
|
33
|
+
if (t.length !== 1) throw new Error(`Invalid character: "${t}"`);
|
|
34
|
+
const a = t.charCodeAt(0);
|
|
35
|
+
n[a] = true;
|
|
36
|
+
}
|
|
37
|
+
return (t) => {
|
|
38
|
+
const a = t.index, o = t.input;
|
|
39
|
+
for (; t.index < o.length && o.charCodeAt(t.index) in n; ) t.index += 1;
|
|
40
|
+
const u = t.index;
|
|
41
|
+
if (u > a) {
|
|
42
|
+
if (!h(e) && !t.options.silent) {
|
|
43
|
+
const s = t.input.slice(a, u), c = d(e) ? e(s, o, String(a)) : e;
|
|
44
|
+
h(c) || t.output.push(c);
|
|
45
|
+
}
|
|
46
|
+
t.indexMax = Math.max(t.indexMax, t.index);
|
|
47
|
+
}
|
|
48
|
+
return true;
|
|
49
|
+
};
|
|
50
|
+
}, nr = (r, e) => {
|
|
51
|
+
const n = r.source, t = r.flags.replace(/y|$/, "y"), a = new RegExp(n, t);
|
|
52
|
+
return g((o) => {
|
|
53
|
+
a.lastIndex = o.index;
|
|
54
|
+
const u = a.exec(o.input);
|
|
55
|
+
if (u) {
|
|
56
|
+
if (!h(e) && !o.options.silent) {
|
|
57
|
+
const s = d(e) ? e(...u, o.input, String(o.index)) : e;
|
|
58
|
+
h(s) || o.output.push(s);
|
|
59
|
+
}
|
|
60
|
+
return o.index += u[0].length, o.indexMax = Math.max(o.indexMax, o.index), true;
|
|
61
|
+
} else return false;
|
|
62
|
+
});
|
|
63
|
+
}, tr = (r, e) => (n) => {
|
|
64
|
+
if (n.input.startsWith(r, n.index)) {
|
|
65
|
+
if (!h(e) && !n.options.silent) {
|
|
66
|
+
const a = d(e) ? e(r, n.input, String(n.index)) : e;
|
|
67
|
+
h(a) || n.output.push(a);
|
|
68
|
+
}
|
|
69
|
+
return n.index += r.length, n.indexMax = Math.max(n.indexMax, n.index), true;
|
|
70
|
+
} else return false;
|
|
71
|
+
}, C = (r, e, n, t) => {
|
|
72
|
+
const a = v(r);
|
|
73
|
+
return g(_(M((o) => {
|
|
74
|
+
let u = 0;
|
|
75
|
+
for (; u < n; ) {
|
|
76
|
+
const s = o.index;
|
|
77
|
+
if (!a(o) || (u += 1, o.index === s)) break;
|
|
78
|
+
}
|
|
79
|
+
return u >= e;
|
|
80
|
+
})));
|
|
81
|
+
}, ar = (r, e) => C(r, 0, 1), f = (r, e) => C(r, 0, 1 / 0), x = (r, e) => {
|
|
82
|
+
const n = r.map(v);
|
|
83
|
+
return g(_(M((t) => {
|
|
84
|
+
for (let a = 0, o = n.length; a < o; a++) if (!n[a](t)) return false;
|
|
85
|
+
return true;
|
|
86
|
+
})));
|
|
87
|
+
}, l = (r, e) => {
|
|
88
|
+
const n = r.map(v);
|
|
89
|
+
return g(_((t) => {
|
|
90
|
+
for (let a = 0, o = n.length; a < o; a++) if (n[a](t)) return true;
|
|
91
|
+
return false;
|
|
92
|
+
}));
|
|
93
|
+
}, M = (r, e = false) => {
|
|
94
|
+
const n = v(r);
|
|
95
|
+
return (t) => {
|
|
96
|
+
const a = t.index, o = t.output.length, u = n(t);
|
|
97
|
+
return (!u || e) && (t.index = a, t.output.length !== o && (t.output.length = o)), u;
|
|
98
|
+
};
|
|
99
|
+
}, _ = (r, e) => {
|
|
100
|
+
const n = v(r);
|
|
101
|
+
return n;
|
|
102
|
+
}, g = /* @__PURE__ */ (() => {
|
|
103
|
+
let r = 0;
|
|
104
|
+
return (e) => {
|
|
105
|
+
const n = v(e), t = r += 1;
|
|
106
|
+
return (a) => {
|
|
107
|
+
var o;
|
|
108
|
+
if (a.options.memoization === false) return n(a);
|
|
109
|
+
const u = a.index, s = (o = a.cache)[t] || (o[t] = /* @__PURE__ */ new Map()), c = s.get(u);
|
|
110
|
+
if (c === false) return false;
|
|
111
|
+
if (W(c)) return a.index = c, true;
|
|
112
|
+
if (c) return a.index = c.index, c.output?.length && a.output.push(...c.output), true;
|
|
113
|
+
{
|
|
114
|
+
const Z = a.output.length;
|
|
115
|
+
if (n(a)) {
|
|
116
|
+
const D = a.index, U = a.output.length;
|
|
117
|
+
if (U > Z) {
|
|
118
|
+
const ee = a.output.slice(Z, U);
|
|
119
|
+
s.set(u, { index: D, output: ee });
|
|
120
|
+
} else s.set(u, D);
|
|
121
|
+
return true;
|
|
122
|
+
} else return s.set(u, false), false;
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
})(), E = (r) => {
|
|
127
|
+
let e;
|
|
128
|
+
return (n) => (e || (e = v(r())), e(n));
|
|
129
|
+
}, v = Y((r) => {
|
|
130
|
+
if (d(r)) return Q(r) ? E(r) : r;
|
|
131
|
+
if (b(r) || X(r)) return i(r);
|
|
132
|
+
if (A(r)) return x(r);
|
|
133
|
+
if (K(r)) return l(Object.values(r));
|
|
134
|
+
throw new Error("Invalid rule");
|
|
135
|
+
}), P = "abcdefghijklmnopqrstuvwxyz", ir = (r) => {
|
|
136
|
+
let e = "";
|
|
137
|
+
for (; r > 0; ) {
|
|
138
|
+
const n = (r - 1) % 26;
|
|
139
|
+
e = P[n] + e, r = Math.floor((r - 1) / 26);
|
|
140
|
+
}
|
|
141
|
+
return e;
|
|
142
|
+
}, z = (r) => {
|
|
143
|
+
let e = 0;
|
|
144
|
+
for (let n = 0, t = r.length; n < t; n++) e = e * 26 + P.indexOf(r[n]) + 1;
|
|
145
|
+
return e;
|
|
146
|
+
}, S = (r, e) => {
|
|
147
|
+
if (e < r) return S(e, r);
|
|
148
|
+
const n = [];
|
|
149
|
+
for (; r <= e; ) n.push(r++);
|
|
150
|
+
return n;
|
|
151
|
+
}, or = (r, e, n) => S(r, e).map((t) => String(t).padStart(n, "0")), O = (r, e) => S(z(r), z(e)).map(ir), p = (r) => r, R = (r) => ur((e) => rr(e, r, { memoization: false }).join("")), ur = (r) => {
|
|
152
|
+
const e = {};
|
|
153
|
+
return (n) => e[n] ?? (e[n] = r(n));
|
|
154
|
+
}, sr = i(/^\*\*\/\*$/, ".*"), cr = i(/^\*\*\/(\*)?([ a-zA-Z0-9._-]+)$/, (r, e, n) => `.*${e ? "" : "(?:^|/)"}${n.replaceAll(".", "\\.")}`), lr = i(/^\*\*\/(\*)?([ a-zA-Z0-9._-]*)\{([ a-zA-Z0-9._-]+(?:,[ a-zA-Z0-9._-]+)*)\}$/, (r, e, n, t) => `.*${e ? "" : "(?:^|/)"}${n.replaceAll(".", "\\.")}(?:${t.replaceAll(",", "|").replaceAll(".", "\\.")})`), y = i(/\\./, p), pr = i(/[$.*+?^(){}[\]\|]/, (r) => `\\${r}`), vr = i(/./, p), hr = i(/^(?:!!)*!(.*)$/, (r, e) => `(?!^${L(e)}$).*?`), dr = i(/^(!!)+/, ""), fr = l([hr, dr]), xr = i(/\/(\*\*\/)+/, "(?:/.+/|/)"), gr = i(/^(\*\*\/)+/, "(?:^|.*/)"), mr = i(/\/(\*\*)$/, "(?:/.*|$)"), _r = i(/\*\*/, ".*"), j = l([xr, gr, mr, _r]), Sr = i(/\*\/(?!\*\*\/)/, "[^/]*/"), yr = i(/\*/, "[^/]*"), N = l([Sr, yr]), k = i("?", "[^/]"), $r = i("[", p), wr = i("]", p), Ar = i(/[!^]/, "^/"), br = i(/[a-z]-[a-z]|[0-9]-[0-9]/i, p), Cr = i(/[$.*+?^(){}[\|]/, (r) => `\\${r}`), Mr = i(/[^\]]/, p), Er = l([y, Cr, br, Mr]), B = x([$r, ar(Ar), f(Er), wr]), Pr = i("{", "(?:"), zr = i("}", ")"), Or = i(/(\d+)\.\.(\d+)/, (r, e, n) => or(+e, +n, Math.min(e.length, n.length)).join("|")), Rr = i(/([a-z]+)\.\.([a-z]+)/, (r, e, n) => O(e, n).join("|")), jr = i(/([A-Z]+)\.\.([A-Z]+)/, (r, e, n) => O(e.toLowerCase(), n.toLowerCase()).join("|").toUpperCase()), Nr = l([Or, Rr, jr]), I = x([Pr, Nr, zr]), kr = i("{", "(?:"), Br = i("}", ")"), Ir = i(",", "|"), Fr = i(/[$.*+?^(){[\]\|]/, (r) => `\\${r}`), Lr = i(/[^}]/, p), Zr = E(() => F), Dr = l([j, N, k, B, I, Zr, y, Fr, Ir, Lr]), F = x([kr, f(Dr), Br]), Ur = f(l([sr, cr, lr, fr, j, N, k, B, I, F, y, pr, vr])), Vr = Ur, Gr = R(Vr), L = Gr, Tr = i(/\\./, p), qr = i(/./, p), Hr = i(/\*\*\*+/, "*"), Jr = i(/([^/{[(!])\*\*/, (r, e) => `${e}*`), Qr = i(/(^|.)\*\*(?=[^*/)\]}])/, (r, e) => `${e}*`), Wr = f(l([Tr, Hr, Jr, Qr, qr])), Kr = Wr, Xr = R(Kr), Yr = Xr, $ = (r, e) => {
|
|
155
|
+
const n = Array.isArray(r) ? r : [r];
|
|
156
|
+
if (!n.length) return false;
|
|
157
|
+
const t = n.map($.compile), a = n.every((s) => /(\/(?:\*\*)?|\[\/\])$/.test(s)), o = e.replace(/[\\\/]+/g, "/").replace(/\/$/, a ? "/" : "");
|
|
158
|
+
return t.some((s) => s.test(o));
|
|
159
|
+
};
|
|
160
|
+
$.compile = (r) => new RegExp(`^${L(Yr(r))}$`, "s");
|
|
161
|
+
var re = $;
|
|
162
|
+
return J(w);
|
|
163
|
+
})();
|
|
164
|
+
return __lib__.default || __lib__;
|
|
165
|
+
};
|
|
166
|
+
var _match;
|
|
167
|
+
var zeptomatch = (path, pattern) => {
|
|
168
|
+
if (!_match) {
|
|
169
|
+
_match = _lazyMatch();
|
|
170
|
+
_lazyMatch = null;
|
|
171
|
+
}
|
|
172
|
+
return _match(path, pattern);
|
|
173
|
+
};
|
|
9
174
|
var _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
10
175
|
function normalizeWindowsPath(input = "") {
|
|
11
176
|
if (!input) {
|
|
@@ -17,55 +182,58 @@ var _UNC_REGEX = /^[/\\]{2}/;
|
|
|
17
182
|
var _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
|
|
18
183
|
var _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
|
|
19
184
|
var _ROOT_FOLDER_RE = /^\/([A-Za-z]:)?$/;
|
|
185
|
+
var _EXTNAME_RE = /.(\.[^./]+|\.)$/;
|
|
186
|
+
var _PATH_ROOT_RE = /^[/\\]|^[a-zA-Z]:[/\\]/;
|
|
20
187
|
var sep = "/";
|
|
21
|
-
var
|
|
22
|
-
|
|
23
|
-
if (path2.length === 0) {
|
|
188
|
+
var normalize = function(path) {
|
|
189
|
+
if (path.length === 0) {
|
|
24
190
|
return ".";
|
|
25
191
|
}
|
|
26
|
-
|
|
27
|
-
const isUNCPath =
|
|
28
|
-
const isPathAbsolute = isAbsolute(
|
|
29
|
-
const trailingSeparator =
|
|
30
|
-
|
|
31
|
-
if (
|
|
192
|
+
path = normalizeWindowsPath(path);
|
|
193
|
+
const isUNCPath = path.match(_UNC_REGEX);
|
|
194
|
+
const isPathAbsolute = isAbsolute(path);
|
|
195
|
+
const trailingSeparator = path[path.length - 1] === "/";
|
|
196
|
+
path = normalizeString(path, !isPathAbsolute);
|
|
197
|
+
if (path.length === 0) {
|
|
32
198
|
if (isPathAbsolute) {
|
|
33
199
|
return "/";
|
|
34
200
|
}
|
|
35
201
|
return trailingSeparator ? "./" : ".";
|
|
36
202
|
}
|
|
37
203
|
if (trailingSeparator) {
|
|
38
|
-
|
|
204
|
+
path += "/";
|
|
39
205
|
}
|
|
40
|
-
if (_DRIVE_LETTER_RE.test(
|
|
41
|
-
|
|
206
|
+
if (_DRIVE_LETTER_RE.test(path)) {
|
|
207
|
+
path += "/";
|
|
42
208
|
}
|
|
43
209
|
if (isUNCPath) {
|
|
44
210
|
if (!isPathAbsolute) {
|
|
45
|
-
return `//./${
|
|
211
|
+
return `//./${path}`;
|
|
46
212
|
}
|
|
47
|
-
return `//${
|
|
213
|
+
return `//${path}`;
|
|
48
214
|
}
|
|
49
|
-
return isPathAbsolute && !isAbsolute(
|
|
215
|
+
return isPathAbsolute && !isAbsolute(path) ? `/${path}` : path;
|
|
50
216
|
};
|
|
51
|
-
var join = function(...
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
if (
|
|
58
|
-
|
|
59
|
-
|
|
217
|
+
var join = function(...segments) {
|
|
218
|
+
let path = "";
|
|
219
|
+
for (const seg of segments) {
|
|
220
|
+
if (!seg) {
|
|
221
|
+
continue;
|
|
222
|
+
}
|
|
223
|
+
if (path.length > 0) {
|
|
224
|
+
const pathTrailing = path[path.length - 1] === "/";
|
|
225
|
+
const segLeading = seg[0] === "/";
|
|
226
|
+
const both = pathTrailing && segLeading;
|
|
227
|
+
if (both) {
|
|
228
|
+
path += seg.slice(1);
|
|
60
229
|
} else {
|
|
61
|
-
|
|
230
|
+
path += pathTrailing || segLeading ? seg : `/${seg}`;
|
|
62
231
|
}
|
|
232
|
+
} else {
|
|
233
|
+
path += seg;
|
|
63
234
|
}
|
|
64
235
|
}
|
|
65
|
-
|
|
66
|
-
return ".";
|
|
67
|
-
}
|
|
68
|
-
return normalize(joined.replace(/\/\/+/g, "/"));
|
|
236
|
+
return normalize(path);
|
|
69
237
|
};
|
|
70
238
|
function cwd() {
|
|
71
239
|
if (typeof process !== "undefined" && typeof process.cwd === "function") {
|
|
@@ -78,12 +246,12 @@ var resolve = function(...arguments_) {
|
|
|
78
246
|
let resolvedPath = "";
|
|
79
247
|
let resolvedAbsolute = false;
|
|
80
248
|
for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
|
|
81
|
-
const
|
|
82
|
-
if (!
|
|
249
|
+
const path = index >= 0 ? arguments_[index] : cwd();
|
|
250
|
+
if (!path || path.length === 0) {
|
|
83
251
|
continue;
|
|
84
252
|
}
|
|
85
|
-
resolvedPath = `${
|
|
86
|
-
resolvedAbsolute = isAbsolute(
|
|
253
|
+
resolvedPath = `${path}/${resolvedPath}`;
|
|
254
|
+
resolvedAbsolute = isAbsolute(path);
|
|
87
255
|
}
|
|
88
256
|
resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
|
|
89
257
|
if (resolvedAbsolute && !isAbsolute(resolvedPath)) {
|
|
@@ -91,15 +259,15 @@ var resolve = function(...arguments_) {
|
|
|
91
259
|
}
|
|
92
260
|
return resolvedPath.length > 0 ? resolvedPath : ".";
|
|
93
261
|
};
|
|
94
|
-
function normalizeString(
|
|
262
|
+
function normalizeString(path, allowAboveRoot) {
|
|
95
263
|
let res = "";
|
|
96
264
|
let lastSegmentLength = 0;
|
|
97
265
|
let lastSlash = -1;
|
|
98
266
|
let dots = 0;
|
|
99
267
|
let char = null;
|
|
100
|
-
for (let index = 0; index <=
|
|
101
|
-
if (index <
|
|
102
|
-
char =
|
|
268
|
+
for (let index = 0; index <= path.length; ++index) {
|
|
269
|
+
if (index < path.length) {
|
|
270
|
+
char = path[index];
|
|
103
271
|
} else if (char === "/") {
|
|
104
272
|
break;
|
|
105
273
|
} else {
|
|
@@ -135,9 +303,9 @@ function normalizeString(path2, allowAboveRoot) {
|
|
|
135
303
|
}
|
|
136
304
|
} else {
|
|
137
305
|
if (res.length > 0) {
|
|
138
|
-
res += `/${
|
|
306
|
+
res += `/${path.slice(lastSlash + 1, index)}`;
|
|
139
307
|
} else {
|
|
140
|
-
res =
|
|
308
|
+
res = path.slice(lastSlash + 1, index);
|
|
141
309
|
}
|
|
142
310
|
lastSegmentLength = index - lastSlash - 1;
|
|
143
311
|
}
|
|
@@ -157,8 +325,8 @@ var isAbsolute = function(p) {
|
|
|
157
325
|
var toNamespacedPath = function(p) {
|
|
158
326
|
return normalizeWindowsPath(p);
|
|
159
327
|
};
|
|
160
|
-
var _EXTNAME_RE = /.(\.[^./]+)$/;
|
|
161
328
|
var extname = function(p) {
|
|
329
|
+
if (p === "..") return "";
|
|
162
330
|
const match = _EXTNAME_RE.exec(normalizeWindowsPath(p));
|
|
163
331
|
return match && match[1] || "";
|
|
164
332
|
};
|
|
@@ -186,17 +354,28 @@ var dirname = function(p) {
|
|
|
186
354
|
return segments.join("/") || (isAbsolute(p) ? "/" : ".");
|
|
187
355
|
};
|
|
188
356
|
var format = function(p) {
|
|
189
|
-
const
|
|
357
|
+
const ext = p.ext ? p.ext.startsWith(".") ? p.ext : `.${p.ext}` : "";
|
|
358
|
+
const segments = [p.root, p.dir, p.base ?? (p.name ?? "") + ext].filter(
|
|
359
|
+
Boolean
|
|
360
|
+
);
|
|
190
361
|
return normalizeWindowsPath(
|
|
191
362
|
p.root ? resolve(...segments) : segments.join("/")
|
|
192
363
|
);
|
|
193
364
|
};
|
|
194
365
|
var basename = function(p, extension) {
|
|
195
|
-
const
|
|
366
|
+
const segments = normalizeWindowsPath(p).split("/");
|
|
367
|
+
let lastSegment = "";
|
|
368
|
+
for (let i = segments.length - 1; i >= 0; i--) {
|
|
369
|
+
const val = segments[i];
|
|
370
|
+
if (val) {
|
|
371
|
+
lastSegment = val;
|
|
372
|
+
break;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
196
375
|
return extension && lastSegment.endsWith(extension) ? lastSegment.slice(0, -extension.length) : lastSegment;
|
|
197
376
|
};
|
|
198
377
|
var parse = function(p) {
|
|
199
|
-
const root =
|
|
378
|
+
const root = _PATH_ROOT_RE.exec(p)?.[0]?.replace(/\\/g, "/") || "";
|
|
200
379
|
const base = basename(p);
|
|
201
380
|
const extension = extname(base);
|
|
202
381
|
return {
|
|
@@ -207,15 +386,18 @@ var parse = function(p) {
|
|
|
207
386
|
name: base.slice(0, base.length - extension.length)
|
|
208
387
|
};
|
|
209
388
|
};
|
|
210
|
-
var
|
|
389
|
+
var matchesGlob = (path, pattern) => {
|
|
390
|
+
return zeptomatch(pattern, normalize(path));
|
|
391
|
+
};
|
|
392
|
+
var _path = {
|
|
211
393
|
__proto__: null,
|
|
212
394
|
basename,
|
|
213
|
-
delimiter,
|
|
214
395
|
dirname,
|
|
215
396
|
extname,
|
|
216
397
|
format,
|
|
217
398
|
isAbsolute,
|
|
218
399
|
join,
|
|
400
|
+
matchesGlob,
|
|
219
401
|
normalize,
|
|
220
402
|
normalizeString,
|
|
221
403
|
parse,
|
|
@@ -225,8 +407,24 @@ var path = {
|
|
|
225
407
|
toNamespacedPath
|
|
226
408
|
};
|
|
227
409
|
|
|
410
|
+
// ../../node_modules/.pnpm/pathe@2.0.2/node_modules/pathe/dist/index.mjs
|
|
411
|
+
var delimiter = /* @__PURE__ */ (() => globalThis.process?.platform === "win32" ? ";" : ":")();
|
|
412
|
+
var _platforms = { posix: void 0, win32: void 0 };
|
|
413
|
+
var mix = (del = delimiter) => {
|
|
414
|
+
return new Proxy(_path, {
|
|
415
|
+
get(_, prop) {
|
|
416
|
+
if (prop === "delimiter") return del;
|
|
417
|
+
if (prop === "posix") return posix;
|
|
418
|
+
if (prop === "win32") return win32;
|
|
419
|
+
return _platforms[prop] || _path[prop];
|
|
420
|
+
}
|
|
421
|
+
});
|
|
422
|
+
};
|
|
423
|
+
var posix = /* @__PURE__ */ mix(":");
|
|
424
|
+
var win32 = /* @__PURE__ */ mix(";");
|
|
425
|
+
|
|
228
426
|
// ../../packages/weapp-vite/package.json
|
|
229
|
-
var version = "2.
|
|
427
|
+
var version = "2.1.3";
|
|
230
428
|
|
|
231
429
|
// src/context.ts
|
|
232
430
|
function createContext() {
|
|
@@ -394,7 +592,7 @@ export default defineConfig({
|
|
|
394
592
|
}
|
|
395
593
|
|
|
396
594
|
// src/index.ts
|
|
397
|
-
var __dirname2 =
|
|
595
|
+
var __dirname2 = posix.dirname(fileURLToPath(import.meta.url));
|
|
398
596
|
var ctx = createContext();
|
|
399
597
|
async function createOrUpdateProjectConfig(options) {
|
|
400
598
|
const { root, dest, cb, write, filename } = defu(
|
|
@@ -405,7 +603,7 @@ async function createOrUpdateProjectConfig(options) {
|
|
|
405
603
|
}
|
|
406
604
|
);
|
|
407
605
|
const projectConfigFilename = ctx.projectConfig.name = filename;
|
|
408
|
-
const projectConfigPath = ctx.projectConfig.path =
|
|
606
|
+
const projectConfigPath = ctx.projectConfig.path = posix.resolve(root, projectConfigFilename);
|
|
409
607
|
if (await fs.exists(projectConfigPath)) {
|
|
410
608
|
try {
|
|
411
609
|
const projectConfig = await fs.readJSON(projectConfigPath);
|
|
@@ -494,7 +692,7 @@ async function createOrUpdatePackageJson(options) {
|
|
|
494
692
|
command: "weapp-vite"
|
|
495
693
|
});
|
|
496
694
|
const packageJsonFilename = ctx.packageJson.name = filename;
|
|
497
|
-
const packageJsonPath = ctx.packageJson.path =
|
|
695
|
+
const packageJsonPath = ctx.packageJson.path = posix.resolve(root, packageJsonFilename);
|
|
498
696
|
let packageJson;
|
|
499
697
|
if (await fs.exists(packageJsonPath)) {
|
|
500
698
|
packageJson = await fs.readJSON(packageJsonPath);
|
|
@@ -536,7 +734,7 @@ async function initViteConfigFile(options) {
|
|
|
536
734
|
const { root, write = true } = options;
|
|
537
735
|
const type = get(ctx.packageJson.value, "type");
|
|
538
736
|
const targetFilename = ctx.viteConfig.name = type === "module" ? "vite.config.ts" : "vite.config.mts";
|
|
539
|
-
const viteConfigFilePath = ctx.viteConfig.path =
|
|
737
|
+
const viteConfigFilePath = ctx.viteConfig.path = posix.resolve(root, targetFilename);
|
|
540
738
|
const viteConfigFileCode = ctx.viteConfig.value = getDefaultViteConfig();
|
|
541
739
|
if (write) {
|
|
542
740
|
await fs.outputFile(viteConfigFilePath, viteConfigFileCode, "utf8");
|
|
@@ -547,7 +745,7 @@ async function initViteConfigFile(options) {
|
|
|
547
745
|
async function initTsDtsFile(options) {
|
|
548
746
|
const { root, write = true } = options;
|
|
549
747
|
const targetFilename = "vite-env.d.ts";
|
|
550
|
-
const viteDtsFilePath =
|
|
748
|
+
const viteDtsFilePath = posix.resolve(root, targetFilename);
|
|
551
749
|
const code = getDefaultTsDts();
|
|
552
750
|
if (write) {
|
|
553
751
|
await fs.outputFile(viteDtsFilePath, code, "utf8");
|
|
@@ -558,9 +756,9 @@ async function initTsDtsFile(options) {
|
|
|
558
756
|
async function initTsJsonFiles(options) {
|
|
559
757
|
const { root, write = true } = options;
|
|
560
758
|
const tsJsonFilename = ctx.tsconfig.name = "tsconfig.json";
|
|
561
|
-
const tsJsonFilePath = ctx.tsconfig.path =
|
|
759
|
+
const tsJsonFilePath = ctx.tsconfig.path = posix.resolve(root, tsJsonFilename);
|
|
562
760
|
const tsNodeJsonFilename = ctx.tsconfigNode.name = "tsconfig.node.json";
|
|
563
|
-
const tsNodeJsonFilePath = ctx.tsconfigNode.path =
|
|
761
|
+
const tsNodeJsonFilePath = ctx.tsconfigNode.path = posix.resolve(root, tsNodeJsonFilename);
|
|
564
762
|
if (write) {
|
|
565
763
|
const tsJsonValue = getDefaultTsconfigJson();
|
|
566
764
|
if (write) {
|
|
@@ -590,7 +788,7 @@ async function initTsJsonFiles(options) {
|
|
|
590
788
|
}
|
|
591
789
|
async function updateGitIgnore(options) {
|
|
592
790
|
const { root, write = true } = options;
|
|
593
|
-
const filepath =
|
|
791
|
+
const filepath = posix.resolve(root, ".gitignore");
|
|
594
792
|
const data = getDefaultGitignore();
|
|
595
793
|
if (write) {
|
|
596
794
|
await fs.outputFile(filepath, data, {
|
|
@@ -612,10 +810,10 @@ async function initConfig(options) {
|
|
|
612
810
|
return ctx;
|
|
613
811
|
}
|
|
614
812
|
async function createProject(targetDir = "", templateName = "default" /* default */) {
|
|
615
|
-
const targetTemplateDir =
|
|
813
|
+
const targetTemplateDir = posix.resolve(__dirname2, "../templates", templateName);
|
|
616
814
|
if (await fs.exists(targetTemplateDir)) {
|
|
617
815
|
await fs.copy(targetTemplateDir, targetDir);
|
|
618
|
-
const pkgJsonPath =
|
|
816
|
+
const pkgJsonPath = posix.resolve(targetTemplateDir, "package.json");
|
|
619
817
|
const pkgJson = await fs.readJson(pkgJsonPath);
|
|
620
818
|
if (pkgJson.devDependencies) {
|
|
621
819
|
if (pkgJson.devDependencies["weapp-vite"]) {
|
|
@@ -625,7 +823,10 @@ async function createProject(targetDir = "", templateName = "default" /* default
|
|
|
625
823
|
pkgJson.devDependencies["weapp-tailwindcss"] = "latest";
|
|
626
824
|
}
|
|
627
825
|
}
|
|
628
|
-
await fs.writeJson(
|
|
826
|
+
await fs.writeJson(posix.resolve(targetDir, "package.json"), pkgJson, { spaces: 2 });
|
|
827
|
+
if (!await fs.exists(posix.resolve(targetDir, ".gitignore"))) {
|
|
828
|
+
await updateGitIgnore({ root: targetDir, write: true });
|
|
829
|
+
}
|
|
629
830
|
logger.log(`\u2728 \u521B\u5EFA\u6A21\u677F\u6210\u529F!`);
|
|
630
831
|
} else {
|
|
631
832
|
logger.warn(`\u6CA1\u6709\u627E\u5230 ${templateName} \u6A21\u677F!`);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weapp-core/init",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.16",
|
|
5
5
|
"description": "@weapp-core/init",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -38,13 +38,13 @@
|
|
|
38
38
|
"templates"
|
|
39
39
|
],
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"fs-extra": "^11.
|
|
42
|
-
"@weapp-core/logger": "^1.0.
|
|
43
|
-
"@weapp-core/shared": "^1.0.
|
|
41
|
+
"fs-extra": "^11.3.0",
|
|
42
|
+
"@weapp-core/logger": "^1.0.3",
|
|
43
|
+
"@weapp-core/shared": "^1.0.6"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@types/semver": "^7.5.8",
|
|
47
|
-
"semver": "^7.
|
|
47
|
+
"semver": "^7.7.1"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"dev": "tsup --watch --sourcemap",
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
"g": "weapp-vite generate"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"miniprogram-api-typings": "^4.0.
|
|
27
|
-
"sass": "^1.
|
|
28
|
-
"typescript": "^5.7.
|
|
26
|
+
"miniprogram-api-typings": "^4.0.5",
|
|
27
|
+
"sass": "^1.84.0",
|
|
28
|
+
"typescript": "^5.7.3",
|
|
29
29
|
"weapp-vite": "workspace:*"
|
|
30
30
|
}
|
|
31
31
|
}
|
|
@@ -24,14 +24,14 @@
|
|
|
24
24
|
"postinstall": "weapp-tw patch"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@egoist/tailwindcss-icons": "^1.
|
|
28
|
-
"@iconify-json/mdi": "^1.2.
|
|
27
|
+
"@egoist/tailwindcss-icons": "^1.9.0",
|
|
28
|
+
"@iconify-json/mdi": "^1.2.3",
|
|
29
29
|
"autoprefixer": "^10.4.20",
|
|
30
|
-
"miniprogram-api-typings": "^4.0.
|
|
31
|
-
"postcss": "^8.
|
|
32
|
-
"sass": "^1.
|
|
30
|
+
"miniprogram-api-typings": "^4.0.5",
|
|
31
|
+
"postcss": "^8.5.1",
|
|
32
|
+
"sass": "^1.84.0",
|
|
33
33
|
"tailwindcss": "^3.4.17",
|
|
34
|
-
"typescript": "^5.7.
|
|
34
|
+
"typescript": "^5.7.3",
|
|
35
35
|
"weapp-tailwindcss": "^3.7.0",
|
|
36
36
|
"weapp-vite": "workspace:*"
|
|
37
37
|
}
|
|
@@ -23,19 +23,19 @@
|
|
|
23
23
|
"g": "weapp-vite generate",
|
|
24
24
|
"postinstall": "weapp-tw patch"
|
|
25
25
|
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"tdesign-miniprogram": "^1.8.5"
|
|
28
|
+
},
|
|
26
29
|
"devDependencies": {
|
|
27
|
-
"@egoist/tailwindcss-icons": "^1.
|
|
28
|
-
"@iconify-json/mdi": "^1.2.
|
|
30
|
+
"@egoist/tailwindcss-icons": "^1.9.0",
|
|
31
|
+
"@iconify-json/mdi": "^1.2.3",
|
|
29
32
|
"autoprefixer": "^10.4.20",
|
|
30
|
-
"miniprogram-api-typings": "^4.0.
|
|
31
|
-
"postcss": "^8.
|
|
32
|
-
"sass": "^1.
|
|
33
|
+
"miniprogram-api-typings": "^4.0.5",
|
|
34
|
+
"postcss": "^8.5.1",
|
|
35
|
+
"sass": "^1.84.0",
|
|
33
36
|
"tailwindcss": "^3.4.17",
|
|
34
|
-
"typescript": "^5.7.
|
|
37
|
+
"typescript": "^5.7.3",
|
|
35
38
|
"weapp-tailwindcss": "^3.7.0",
|
|
36
39
|
"weapp-vite": "workspace:*"
|
|
37
|
-
},
|
|
38
|
-
"dependencies": {
|
|
39
|
-
"tdesign-miniprogram": "^1.8.4"
|
|
40
40
|
}
|
|
41
41
|
}
|
|
@@ -24,14 +24,14 @@
|
|
|
24
24
|
"postinstall": "weapp-tw patch"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@egoist/tailwindcss-icons": "^1.
|
|
28
|
-
"@iconify-json/mdi": "^1.2.
|
|
27
|
+
"@egoist/tailwindcss-icons": "^1.9.0",
|
|
28
|
+
"@iconify-json/mdi": "^1.2.3",
|
|
29
29
|
"autoprefixer": "^10.4.20",
|
|
30
|
-
"miniprogram-api-typings": "^4.0.
|
|
31
|
-
"postcss": "^8.
|
|
32
|
-
"sass": "^1.
|
|
30
|
+
"miniprogram-api-typings": "^4.0.5",
|
|
31
|
+
"postcss": "^8.5.1",
|
|
32
|
+
"sass": "^1.84.0",
|
|
33
33
|
"tailwindcss": "^3.4.17",
|
|
34
|
-
"typescript": "^5.7.
|
|
34
|
+
"typescript": "^5.7.3",
|
|
35
35
|
"weapp-tailwindcss": "^3.7.0",
|
|
36
36
|
"weapp-vite": "workspace:*"
|
|
37
37
|
},
|