@weapp-core/init 5.0.0 → 6.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/index.d.ts +0 -1
- package/dist/index.js +1 -4
- package/package.json +8 -6
- package/dist/index.cjs +0 -1102
- package/dist/index.d.cts +0 -125
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -500,9 +500,6 @@ function getDefaultTsconfigAppJson() {
|
|
|
500
500
|
paths: {
|
|
501
501
|
"@/*": [
|
|
502
502
|
"./src/*"
|
|
503
|
-
],
|
|
504
|
-
"take:@/*": [
|
|
505
|
-
"./src/*"
|
|
506
503
|
]
|
|
507
504
|
},
|
|
508
505
|
resolveJsonModule: true,
|
|
@@ -719,7 +716,7 @@ import logger2 from "@weapp-core/logger";
|
|
|
719
716
|
import { defu, get, set } from "@weapp-core/shared";
|
|
720
717
|
|
|
721
718
|
// ../../packages/weapp-vite/package.json
|
|
722
|
-
var version = "6.
|
|
719
|
+
var version = "6.2.0";
|
|
723
720
|
|
|
724
721
|
// src/npm.ts
|
|
725
722
|
import https from "https";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weapp-core/init",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "6.0.0",
|
|
5
5
|
"description": "@weapp-core/init",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -18,11 +18,10 @@
|
|
|
18
18
|
"exports": {
|
|
19
19
|
".": {
|
|
20
20
|
"types": "./dist/index.d.ts",
|
|
21
|
-
"import": "./dist/index.js"
|
|
22
|
-
"require": "./dist/index.cjs"
|
|
21
|
+
"import": "./dist/index.js"
|
|
23
22
|
}
|
|
24
23
|
},
|
|
25
|
-
"main": "./dist/index.
|
|
24
|
+
"main": "./dist/index.js",
|
|
26
25
|
"module": "./dist/index.js",
|
|
27
26
|
"types": "./dist/index.d.ts",
|
|
28
27
|
"weapp-vite-dev": {
|
|
@@ -36,10 +35,13 @@
|
|
|
36
35
|
"files": [
|
|
37
36
|
"dist"
|
|
38
37
|
],
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": "^20.19.0 || >=22.12.0"
|
|
40
|
+
},
|
|
39
41
|
"dependencies": {
|
|
40
42
|
"fs-extra": "^11.3.3",
|
|
41
|
-
"@weapp-core/logger": "^
|
|
42
|
-
"@weapp-core/shared": "^
|
|
43
|
+
"@weapp-core/logger": "^3.0.0",
|
|
44
|
+
"@weapp-core/shared": "^3.0.0"
|
|
43
45
|
},
|
|
44
46
|
"scripts": {
|
|
45
47
|
"dev": "tsup --watch --sourcemap",
|
package/dist/index.cjs
DELETED
|
@@ -1,1102 +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
|
-
createOrUpdatePackageJson: () => createOrUpdatePackageJson,
|
|
34
|
-
createOrUpdateProjectConfig: () => createOrUpdateProjectConfig,
|
|
35
|
-
initConfig: () => initConfig,
|
|
36
|
-
initTsDtsFile: () => initTsDtsFile,
|
|
37
|
-
initTsJsonFiles: () => initTsJsonFiles,
|
|
38
|
-
initViteConfigFile: () => initViteConfigFile,
|
|
39
|
-
resetContext: () => resetContext
|
|
40
|
-
});
|
|
41
|
-
module.exports = __toCommonJS(index_exports);
|
|
42
|
-
var import_node_process = __toESM(require("process"), 1);
|
|
43
|
-
|
|
44
|
-
// src/configFiles.ts
|
|
45
|
-
var import_logger = __toESM(require("@weapp-core/logger"), 1);
|
|
46
|
-
|
|
47
|
-
// ../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs
|
|
48
|
-
var _lazyMatch = () => {
|
|
49
|
-
var __lib__ = (() => {
|
|
50
|
-
var m = Object.defineProperty, V = Object.getOwnPropertyDescriptor, G = Object.getOwnPropertyNames, T = Object.prototype.hasOwnProperty, q = (r, e) => {
|
|
51
|
-
for (var n in e) m(r, n, { get: e[n], enumerable: true });
|
|
52
|
-
}, H = (r, e, n, a) => {
|
|
53
|
-
if (e && typeof e == "object" || typeof e == "function") for (let t of G(e)) !T.call(r, t) && t !== n && m(r, t, { get: () => e[t], enumerable: !(a = V(e, t)) || a.enumerable });
|
|
54
|
-
return r;
|
|
55
|
-
}, J = (r) => H(m({}, "__esModule", { value: true }), r), w = {};
|
|
56
|
-
q(w, { default: () => re });
|
|
57
|
-
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) => {
|
|
58
|
-
const e = /* @__PURE__ */ new Map();
|
|
59
|
-
return (n) => {
|
|
60
|
-
const a = e.get(n);
|
|
61
|
-
if (a) return a;
|
|
62
|
-
const t = r(n);
|
|
63
|
-
return e.set(n, t), t;
|
|
64
|
-
};
|
|
65
|
-
}, rr = (r, e, n = {}) => {
|
|
66
|
-
const a = { cache: {}, input: r, index: 0, indexMax: 0, options: n, output: [] };
|
|
67
|
-
if (v(e)(a) && a.index === r.length) return a.output;
|
|
68
|
-
throw new Error(`Failed to parse at index ${a.indexMax}`);
|
|
69
|
-
}, i = (r, e) => A(r) ? er(r, e) : b(r) ? ar(r, e) : nr(r, e), er = (r, e) => {
|
|
70
|
-
const n = {};
|
|
71
|
-
for (const a of r) {
|
|
72
|
-
if (a.length !== 1) throw new Error(`Invalid character: "${a}"`);
|
|
73
|
-
const t = a.charCodeAt(0);
|
|
74
|
-
n[t] = true;
|
|
75
|
-
}
|
|
76
|
-
return (a) => {
|
|
77
|
-
const t = a.index, o = a.input;
|
|
78
|
-
for (; a.index < o.length && o.charCodeAt(a.index) in n; ) a.index += 1;
|
|
79
|
-
const u = a.index;
|
|
80
|
-
if (u > t) {
|
|
81
|
-
if (!h(e) && !a.options.silent) {
|
|
82
|
-
const s = a.input.slice(t, u), c = d(e) ? e(s, o, String(t)) : e;
|
|
83
|
-
h(c) || a.output.push(c);
|
|
84
|
-
}
|
|
85
|
-
a.indexMax = Math.max(a.indexMax, a.index);
|
|
86
|
-
}
|
|
87
|
-
return true;
|
|
88
|
-
};
|
|
89
|
-
}, nr = (r, e) => {
|
|
90
|
-
const n = r.source, a = r.flags.replace(/y|$/, "y"), t = new RegExp(n, a);
|
|
91
|
-
return g((o) => {
|
|
92
|
-
t.lastIndex = o.index;
|
|
93
|
-
const u = t.exec(o.input);
|
|
94
|
-
if (u) {
|
|
95
|
-
if (!h(e) && !o.options.silent) {
|
|
96
|
-
const s = d(e) ? e(...u, o.input, String(o.index)) : e;
|
|
97
|
-
h(s) || o.output.push(s);
|
|
98
|
-
}
|
|
99
|
-
return o.index += u[0].length, o.indexMax = Math.max(o.indexMax, o.index), true;
|
|
100
|
-
} else return false;
|
|
101
|
-
});
|
|
102
|
-
}, ar = (r, e) => (n) => {
|
|
103
|
-
if (n.input.startsWith(r, n.index)) {
|
|
104
|
-
if (!h(e) && !n.options.silent) {
|
|
105
|
-
const t = d(e) ? e(r, n.input, String(n.index)) : e;
|
|
106
|
-
h(t) || n.output.push(t);
|
|
107
|
-
}
|
|
108
|
-
return n.index += r.length, n.indexMax = Math.max(n.indexMax, n.index), true;
|
|
109
|
-
} else return false;
|
|
110
|
-
}, C = (r, e, n, a) => {
|
|
111
|
-
const t = v(r);
|
|
112
|
-
return g(_(M((o) => {
|
|
113
|
-
let u = 0;
|
|
114
|
-
for (; u < n; ) {
|
|
115
|
-
const s = o.index;
|
|
116
|
-
if (!t(o) || (u += 1, o.index === s)) break;
|
|
117
|
-
}
|
|
118
|
-
return u >= e;
|
|
119
|
-
})));
|
|
120
|
-
}, tr = (r, e) => C(r, 0, 1), f = (r, e) => C(r, 0, 1 / 0), x = (r, e) => {
|
|
121
|
-
const n = r.map(v);
|
|
122
|
-
return g(_(M((a) => {
|
|
123
|
-
for (let t = 0, o = n.length; t < o; t++) if (!n[t](a)) return false;
|
|
124
|
-
return true;
|
|
125
|
-
})));
|
|
126
|
-
}, l = (r, e) => {
|
|
127
|
-
const n = r.map(v);
|
|
128
|
-
return g(_((a) => {
|
|
129
|
-
for (let t = 0, o = n.length; t < o; t++) if (n[t](a)) return true;
|
|
130
|
-
return false;
|
|
131
|
-
}));
|
|
132
|
-
}, M = (r, e = false) => {
|
|
133
|
-
const n = v(r);
|
|
134
|
-
return (a) => {
|
|
135
|
-
const t = a.index, o = a.output.length, u = n(a);
|
|
136
|
-
return (!u || e) && (a.index = t, a.output.length !== o && (a.output.length = o)), u;
|
|
137
|
-
};
|
|
138
|
-
}, _ = (r, e) => {
|
|
139
|
-
const n = v(r);
|
|
140
|
-
return n;
|
|
141
|
-
}, g = /* @__PURE__ */ (() => {
|
|
142
|
-
let r = 0;
|
|
143
|
-
return (e) => {
|
|
144
|
-
const n = v(e), a = r += 1;
|
|
145
|
-
return (t) => {
|
|
146
|
-
var o;
|
|
147
|
-
if (t.options.memoization === false) return n(t);
|
|
148
|
-
const u = t.index, s = (o = t.cache)[a] || (o[a] = /* @__PURE__ */ new Map()), c = s.get(u);
|
|
149
|
-
if (c === false) return false;
|
|
150
|
-
if (W(c)) return t.index = c, true;
|
|
151
|
-
if (c) return t.index = c.index, c.output?.length && t.output.push(...c.output), true;
|
|
152
|
-
{
|
|
153
|
-
const Z = t.output.length;
|
|
154
|
-
if (n(t)) {
|
|
155
|
-
const D = t.index, U = t.output.length;
|
|
156
|
-
if (U > Z) {
|
|
157
|
-
const ee = t.output.slice(Z, U);
|
|
158
|
-
s.set(u, { index: D, output: ee });
|
|
159
|
-
} else s.set(u, D);
|
|
160
|
-
return true;
|
|
161
|
-
} else return s.set(u, false), false;
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
};
|
|
165
|
-
})(), E = (r) => {
|
|
166
|
-
let e;
|
|
167
|
-
return (n) => (e || (e = v(r())), e(n));
|
|
168
|
-
}, v = Y((r) => {
|
|
169
|
-
if (d(r)) return Q(r) ? E(r) : r;
|
|
170
|
-
if (b(r) || X(r)) return i(r);
|
|
171
|
-
if (A(r)) return x(r);
|
|
172
|
-
if (K(r)) return l(Object.values(r));
|
|
173
|
-
throw new Error("Invalid rule");
|
|
174
|
-
}), P = "abcdefghijklmnopqrstuvwxyz", ir = (r) => {
|
|
175
|
-
let e = "";
|
|
176
|
-
for (; r > 0; ) {
|
|
177
|
-
const n = (r - 1) % 26;
|
|
178
|
-
e = P[n] + e, r = Math.floor((r - 1) / 26);
|
|
179
|
-
}
|
|
180
|
-
return e;
|
|
181
|
-
}, O = (r) => {
|
|
182
|
-
let e = 0;
|
|
183
|
-
for (let n = 0, a = r.length; n < a; n++) e = e * 26 + P.indexOf(r[n]) + 1;
|
|
184
|
-
return e;
|
|
185
|
-
}, S = (r, e) => {
|
|
186
|
-
if (e < r) return S(e, r);
|
|
187
|
-
const n = [];
|
|
188
|
-
for (; r <= e; ) n.push(r++);
|
|
189
|
-
return n;
|
|
190
|
-
}, or = (r, e, n) => S(r, e).map((a) => String(a).padStart(n, "0")), R = (r, e) => S(O(r), O(e)).map(ir), p = (r) => r, z = (r) => ur((e) => rr(e, r, { memoization: false }).join("")), ur = (r) => {
|
|
191
|
-
const e = {};
|
|
192
|
-
return (n) => e[n] ?? (e[n] = r(n));
|
|
193
|
-
}, 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, a) => `.*${e ? "" : "(?:^|/)"}${n.replaceAll(".", "\\.")}(?:${a.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, tr(Ar), f(Er), wr]), Pr = i("{", "(?:"), Or = i("}", ")"), Rr = i(/(\d+)\.\.(\d+)/, (r, e, n) => or(+e, +n, Math.min(e.length, n.length)).join("|")), zr = i(/([a-z]+)\.\.([a-z]+)/, (r, e, n) => R(e, n).join("|")), jr = i(/([A-Z]+)\.\.([A-Z]+)/, (r, e, n) => R(e.toLowerCase(), n.toLowerCase()).join("|").toUpperCase()), Nr = l([Rr, zr, jr]), I = x([Pr, Nr, Or]), 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 = z(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 = z(Kr), Yr = Xr, $ = (r, e) => {
|
|
194
|
-
const n = Array.isArray(r) ? r : [r];
|
|
195
|
-
if (!n.length) return false;
|
|
196
|
-
const a = n.map($.compile), t = n.every((s) => /(\/(?:\*\*)?|\[\/\])$/.test(s)), o = e.replace(/[\\\/]+/g, "/").replace(/\/$/, t ? "/" : "");
|
|
197
|
-
return a.some((s) => s.test(o));
|
|
198
|
-
};
|
|
199
|
-
$.compile = (r) => new RegExp(`^${L(Yr(r))}$`, "s");
|
|
200
|
-
var re = $;
|
|
201
|
-
return J(w);
|
|
202
|
-
})();
|
|
203
|
-
return __lib__.default || __lib__;
|
|
204
|
-
};
|
|
205
|
-
var _match;
|
|
206
|
-
var zeptomatch = (path, pattern) => {
|
|
207
|
-
if (!_match) {
|
|
208
|
-
_match = _lazyMatch();
|
|
209
|
-
_lazyMatch = null;
|
|
210
|
-
}
|
|
211
|
-
return _match(path, pattern);
|
|
212
|
-
};
|
|
213
|
-
var _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
214
|
-
function normalizeWindowsPath(input = "") {
|
|
215
|
-
if (!input) {
|
|
216
|
-
return input;
|
|
217
|
-
}
|
|
218
|
-
return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
|
|
219
|
-
}
|
|
220
|
-
var _UNC_REGEX = /^[/\\]{2}/;
|
|
221
|
-
var _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
|
|
222
|
-
var _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
|
|
223
|
-
var _ROOT_FOLDER_RE = /^\/([A-Za-z]:)?$/;
|
|
224
|
-
var _EXTNAME_RE = /.(\.[^./]+|\.)$/;
|
|
225
|
-
var _PATH_ROOT_RE = /^[/\\]|^[a-zA-Z]:[/\\]/;
|
|
226
|
-
var sep = "/";
|
|
227
|
-
var normalize = function(path) {
|
|
228
|
-
if (path.length === 0) {
|
|
229
|
-
return ".";
|
|
230
|
-
}
|
|
231
|
-
path = normalizeWindowsPath(path);
|
|
232
|
-
const isUNCPath = path.match(_UNC_REGEX);
|
|
233
|
-
const isPathAbsolute = isAbsolute(path);
|
|
234
|
-
const trailingSeparator = path[path.length - 1] === "/";
|
|
235
|
-
path = normalizeString(path, !isPathAbsolute);
|
|
236
|
-
if (path.length === 0) {
|
|
237
|
-
if (isPathAbsolute) {
|
|
238
|
-
return "/";
|
|
239
|
-
}
|
|
240
|
-
return trailingSeparator ? "./" : ".";
|
|
241
|
-
}
|
|
242
|
-
if (trailingSeparator) {
|
|
243
|
-
path += "/";
|
|
244
|
-
}
|
|
245
|
-
if (_DRIVE_LETTER_RE.test(path)) {
|
|
246
|
-
path += "/";
|
|
247
|
-
}
|
|
248
|
-
if (isUNCPath) {
|
|
249
|
-
if (!isPathAbsolute) {
|
|
250
|
-
return `//./${path}`;
|
|
251
|
-
}
|
|
252
|
-
return `//${path}`;
|
|
253
|
-
}
|
|
254
|
-
return isPathAbsolute && !isAbsolute(path) ? `/${path}` : path;
|
|
255
|
-
};
|
|
256
|
-
var join = function(...segments) {
|
|
257
|
-
let path = "";
|
|
258
|
-
for (const seg of segments) {
|
|
259
|
-
if (!seg) {
|
|
260
|
-
continue;
|
|
261
|
-
}
|
|
262
|
-
if (path.length > 0) {
|
|
263
|
-
const pathTrailing = path[path.length - 1] === "/";
|
|
264
|
-
const segLeading = seg[0] === "/";
|
|
265
|
-
const both = pathTrailing && segLeading;
|
|
266
|
-
if (both) {
|
|
267
|
-
path += seg.slice(1);
|
|
268
|
-
} else {
|
|
269
|
-
path += pathTrailing || segLeading ? seg : `/${seg}`;
|
|
270
|
-
}
|
|
271
|
-
} else {
|
|
272
|
-
path += seg;
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
return normalize(path);
|
|
276
|
-
};
|
|
277
|
-
function cwd() {
|
|
278
|
-
if (typeof process !== "undefined" && typeof process.cwd === "function") {
|
|
279
|
-
return process.cwd().replace(/\\/g, "/");
|
|
280
|
-
}
|
|
281
|
-
return "/";
|
|
282
|
-
}
|
|
283
|
-
var resolve = function(...arguments_) {
|
|
284
|
-
arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
|
|
285
|
-
let resolvedPath = "";
|
|
286
|
-
let resolvedAbsolute = false;
|
|
287
|
-
for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
|
|
288
|
-
const path = index >= 0 ? arguments_[index] : cwd();
|
|
289
|
-
if (!path || path.length === 0) {
|
|
290
|
-
continue;
|
|
291
|
-
}
|
|
292
|
-
resolvedPath = `${path}/${resolvedPath}`;
|
|
293
|
-
resolvedAbsolute = isAbsolute(path);
|
|
294
|
-
}
|
|
295
|
-
resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
|
|
296
|
-
if (resolvedAbsolute && !isAbsolute(resolvedPath)) {
|
|
297
|
-
return `/${resolvedPath}`;
|
|
298
|
-
}
|
|
299
|
-
return resolvedPath.length > 0 ? resolvedPath : ".";
|
|
300
|
-
};
|
|
301
|
-
function normalizeString(path, allowAboveRoot) {
|
|
302
|
-
let res = "";
|
|
303
|
-
let lastSegmentLength = 0;
|
|
304
|
-
let lastSlash = -1;
|
|
305
|
-
let dots = 0;
|
|
306
|
-
let char = null;
|
|
307
|
-
for (let index = 0; index <= path.length; ++index) {
|
|
308
|
-
if (index < path.length) {
|
|
309
|
-
char = path[index];
|
|
310
|
-
} else if (char === "/") {
|
|
311
|
-
break;
|
|
312
|
-
} else {
|
|
313
|
-
char = "/";
|
|
314
|
-
}
|
|
315
|
-
if (char === "/") {
|
|
316
|
-
if (lastSlash === index - 1 || dots === 1) ;
|
|
317
|
-
else if (dots === 2) {
|
|
318
|
-
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
319
|
-
if (res.length > 2) {
|
|
320
|
-
const lastSlashIndex = res.lastIndexOf("/");
|
|
321
|
-
if (lastSlashIndex === -1) {
|
|
322
|
-
res = "";
|
|
323
|
-
lastSegmentLength = 0;
|
|
324
|
-
} else {
|
|
325
|
-
res = res.slice(0, lastSlashIndex);
|
|
326
|
-
lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
|
|
327
|
-
}
|
|
328
|
-
lastSlash = index;
|
|
329
|
-
dots = 0;
|
|
330
|
-
continue;
|
|
331
|
-
} else if (res.length > 0) {
|
|
332
|
-
res = "";
|
|
333
|
-
lastSegmentLength = 0;
|
|
334
|
-
lastSlash = index;
|
|
335
|
-
dots = 0;
|
|
336
|
-
continue;
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
if (allowAboveRoot) {
|
|
340
|
-
res += res.length > 0 ? "/.." : "..";
|
|
341
|
-
lastSegmentLength = 2;
|
|
342
|
-
}
|
|
343
|
-
} else {
|
|
344
|
-
if (res.length > 0) {
|
|
345
|
-
res += `/${path.slice(lastSlash + 1, index)}`;
|
|
346
|
-
} else {
|
|
347
|
-
res = path.slice(lastSlash + 1, index);
|
|
348
|
-
}
|
|
349
|
-
lastSegmentLength = index - lastSlash - 1;
|
|
350
|
-
}
|
|
351
|
-
lastSlash = index;
|
|
352
|
-
dots = 0;
|
|
353
|
-
} else if (char === "." && dots !== -1) {
|
|
354
|
-
++dots;
|
|
355
|
-
} else {
|
|
356
|
-
dots = -1;
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
return res;
|
|
360
|
-
}
|
|
361
|
-
var isAbsolute = function(p) {
|
|
362
|
-
return _IS_ABSOLUTE_RE.test(p);
|
|
363
|
-
};
|
|
364
|
-
var toNamespacedPath = function(p) {
|
|
365
|
-
return normalizeWindowsPath(p);
|
|
366
|
-
};
|
|
367
|
-
var extname = function(p) {
|
|
368
|
-
if (p === "..") return "";
|
|
369
|
-
const match = _EXTNAME_RE.exec(normalizeWindowsPath(p));
|
|
370
|
-
return match && match[1] || "";
|
|
371
|
-
};
|
|
372
|
-
var relative = function(from, to) {
|
|
373
|
-
const _from = resolve(from).replace(_ROOT_FOLDER_RE, "$1").split("/");
|
|
374
|
-
const _to = resolve(to).replace(_ROOT_FOLDER_RE, "$1").split("/");
|
|
375
|
-
if (_to[0][1] === ":" && _from[0][1] === ":" && _from[0] !== _to[0]) {
|
|
376
|
-
return _to.join("/");
|
|
377
|
-
}
|
|
378
|
-
const _fromCopy = [..._from];
|
|
379
|
-
for (const segment of _fromCopy) {
|
|
380
|
-
if (_to[0] !== segment) {
|
|
381
|
-
break;
|
|
382
|
-
}
|
|
383
|
-
_from.shift();
|
|
384
|
-
_to.shift();
|
|
385
|
-
}
|
|
386
|
-
return [..._from.map(() => ".."), ..._to].join("/");
|
|
387
|
-
};
|
|
388
|
-
var dirname = function(p) {
|
|
389
|
-
const segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
|
|
390
|
-
if (segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0])) {
|
|
391
|
-
segments[0] += "/";
|
|
392
|
-
}
|
|
393
|
-
return segments.join("/") || (isAbsolute(p) ? "/" : ".");
|
|
394
|
-
};
|
|
395
|
-
var format = function(p) {
|
|
396
|
-
const ext = p.ext ? p.ext.startsWith(".") ? p.ext : `.${p.ext}` : "";
|
|
397
|
-
const segments = [p.root, p.dir, p.base ?? (p.name ?? "") + ext].filter(
|
|
398
|
-
Boolean
|
|
399
|
-
);
|
|
400
|
-
return normalizeWindowsPath(
|
|
401
|
-
p.root ? resolve(...segments) : segments.join("/")
|
|
402
|
-
);
|
|
403
|
-
};
|
|
404
|
-
var basename = function(p, extension) {
|
|
405
|
-
const segments = normalizeWindowsPath(p).split("/");
|
|
406
|
-
let lastSegment = "";
|
|
407
|
-
for (let i = segments.length - 1; i >= 0; i--) {
|
|
408
|
-
const val = segments[i];
|
|
409
|
-
if (val) {
|
|
410
|
-
lastSegment = val;
|
|
411
|
-
break;
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
return extension && lastSegment.endsWith(extension) ? lastSegment.slice(0, -extension.length) : lastSegment;
|
|
415
|
-
};
|
|
416
|
-
var parse = function(p) {
|
|
417
|
-
const root = _PATH_ROOT_RE.exec(p)?.[0]?.replace(/\\/g, "/") || "";
|
|
418
|
-
const base = basename(p);
|
|
419
|
-
const extension = extname(base);
|
|
420
|
-
return {
|
|
421
|
-
root,
|
|
422
|
-
dir: dirname(p),
|
|
423
|
-
base,
|
|
424
|
-
ext: extension,
|
|
425
|
-
name: base.slice(0, base.length - extension.length)
|
|
426
|
-
};
|
|
427
|
-
};
|
|
428
|
-
var matchesGlob = (path, pattern) => {
|
|
429
|
-
return zeptomatch(pattern, normalize(path));
|
|
430
|
-
};
|
|
431
|
-
var _path = {
|
|
432
|
-
__proto__: null,
|
|
433
|
-
basename,
|
|
434
|
-
dirname,
|
|
435
|
-
extname,
|
|
436
|
-
format,
|
|
437
|
-
isAbsolute,
|
|
438
|
-
join,
|
|
439
|
-
matchesGlob,
|
|
440
|
-
normalize,
|
|
441
|
-
normalizeString,
|
|
442
|
-
parse,
|
|
443
|
-
relative,
|
|
444
|
-
resolve,
|
|
445
|
-
sep,
|
|
446
|
-
toNamespacedPath
|
|
447
|
-
};
|
|
448
|
-
|
|
449
|
-
// ../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/index.mjs
|
|
450
|
-
var delimiter = /* @__PURE__ */ (() => globalThis.process?.platform === "win32" ? ";" : ":")();
|
|
451
|
-
var _platforms = { posix: void 0, win32: void 0 };
|
|
452
|
-
var mix = (del = delimiter) => {
|
|
453
|
-
return new Proxy(_path, {
|
|
454
|
-
get(_, prop) {
|
|
455
|
-
if (prop === "delimiter") return del;
|
|
456
|
-
if (prop === "posix") return posix;
|
|
457
|
-
if (prop === "win32") return win32;
|
|
458
|
-
return _platforms[prop] || _path[prop];
|
|
459
|
-
}
|
|
460
|
-
});
|
|
461
|
-
};
|
|
462
|
-
var posix = /* @__PURE__ */ mix(":");
|
|
463
|
-
var win32 = /* @__PURE__ */ mix(";");
|
|
464
|
-
|
|
465
|
-
// src/context.ts
|
|
466
|
-
function createDocument() {
|
|
467
|
-
return {
|
|
468
|
-
name: "",
|
|
469
|
-
path: "",
|
|
470
|
-
value: null
|
|
471
|
-
};
|
|
472
|
-
}
|
|
473
|
-
function createContext() {
|
|
474
|
-
return {
|
|
475
|
-
projectConfig: createDocument(),
|
|
476
|
-
packageJson: createDocument(),
|
|
477
|
-
viteConfig: createDocument(),
|
|
478
|
-
tsconfig: createDocument(),
|
|
479
|
-
tsconfigApp: createDocument(),
|
|
480
|
-
tsconfigNode: createDocument(),
|
|
481
|
-
dts: createDocument()
|
|
482
|
-
};
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
// src/state.ts
|
|
486
|
-
var ctx = createContext();
|
|
487
|
-
function resetContext() {
|
|
488
|
-
const next = createContext();
|
|
489
|
-
Object.assign(ctx.projectConfig, next.projectConfig);
|
|
490
|
-
Object.assign(ctx.packageJson, next.packageJson);
|
|
491
|
-
Object.assign(ctx.viteConfig, next.viteConfig);
|
|
492
|
-
Object.assign(ctx.tsconfig, next.tsconfig);
|
|
493
|
-
Object.assign(ctx.tsconfigApp, next.tsconfigApp);
|
|
494
|
-
Object.assign(ctx.tsconfigNode, next.tsconfigNode);
|
|
495
|
-
Object.assign(ctx.dts, next.dts);
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
// src/tsconfigJson.ts
|
|
499
|
-
var srcIncludeGlobs = [
|
|
500
|
-
"src/**/*.ts",
|
|
501
|
-
"src/**/*.tsx",
|
|
502
|
-
"src/**/*.js",
|
|
503
|
-
"src/**/*.jsx",
|
|
504
|
-
"src/**/*.mts",
|
|
505
|
-
"src/**/*.cts",
|
|
506
|
-
"src/**/*.vue",
|
|
507
|
-
"src/**/*.json",
|
|
508
|
-
"src/**/*.d.ts",
|
|
509
|
-
"types/**/*.d.ts",
|
|
510
|
-
"env.d.ts"
|
|
511
|
-
];
|
|
512
|
-
function getDefaultTsconfigJson() {
|
|
513
|
-
return {
|
|
514
|
-
references: [
|
|
515
|
-
{
|
|
516
|
-
path: "./tsconfig.app.json"
|
|
517
|
-
},
|
|
518
|
-
{
|
|
519
|
-
path: "./tsconfig.node.json"
|
|
520
|
-
}
|
|
521
|
-
],
|
|
522
|
-
files: []
|
|
523
|
-
};
|
|
524
|
-
}
|
|
525
|
-
function getDefaultTsconfigAppJson() {
|
|
526
|
-
return {
|
|
527
|
-
compilerOptions: {
|
|
528
|
-
tsBuildInfoFile: "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
|
|
529
|
-
target: "ES2023",
|
|
530
|
-
lib: [
|
|
531
|
-
"ES2023",
|
|
532
|
-
"DOM",
|
|
533
|
-
"DOM.Iterable"
|
|
534
|
-
],
|
|
535
|
-
jsx: "preserve",
|
|
536
|
-
module: "ESNext",
|
|
537
|
-
moduleResolution: "bundler",
|
|
538
|
-
moduleDetection: "force",
|
|
539
|
-
baseUrl: ".",
|
|
540
|
-
paths: {
|
|
541
|
-
"@/*": [
|
|
542
|
-
"./src/*"
|
|
543
|
-
],
|
|
544
|
-
"take:@/*": [
|
|
545
|
-
"./src/*"
|
|
546
|
-
]
|
|
547
|
-
},
|
|
548
|
-
resolveJsonModule: true,
|
|
549
|
-
types: [
|
|
550
|
-
"miniprogram-api-typings"
|
|
551
|
-
],
|
|
552
|
-
allowImportingTsExtensions: true,
|
|
553
|
-
allowJs: true,
|
|
554
|
-
allowSyntheticDefaultImports: true,
|
|
555
|
-
esModuleInterop: true,
|
|
556
|
-
isolatedModules: true,
|
|
557
|
-
strict: true,
|
|
558
|
-
noFallthroughCasesInSwitch: true,
|
|
559
|
-
noUnusedLocals: true,
|
|
560
|
-
noUnusedParameters: true,
|
|
561
|
-
noEmit: true,
|
|
562
|
-
verbatimModuleSyntax: true,
|
|
563
|
-
noUncheckedSideEffectImports: true,
|
|
564
|
-
erasableSyntaxOnly: true,
|
|
565
|
-
skipLibCheck: true
|
|
566
|
-
},
|
|
567
|
-
include: srcIncludeGlobs
|
|
568
|
-
};
|
|
569
|
-
}
|
|
570
|
-
function getDefaultTsconfigNodeJson(include = []) {
|
|
571
|
-
const baseInclude = [
|
|
572
|
-
"vite.config.ts",
|
|
573
|
-
"vite.config.*.ts",
|
|
574
|
-
"*.config.ts",
|
|
575
|
-
"config/**/*.ts",
|
|
576
|
-
"scripts/**/*.ts"
|
|
577
|
-
];
|
|
578
|
-
const mergedInclude = Array.from(/* @__PURE__ */ new Set([
|
|
579
|
-
...baseInclude,
|
|
580
|
-
...include
|
|
581
|
-
]));
|
|
582
|
-
return {
|
|
583
|
-
compilerOptions: {
|
|
584
|
-
tsBuildInfoFile: "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
|
|
585
|
-
target: "ES2023",
|
|
586
|
-
lib: [
|
|
587
|
-
"ES2023"
|
|
588
|
-
],
|
|
589
|
-
module: "ESNext",
|
|
590
|
-
moduleResolution: "bundler",
|
|
591
|
-
moduleDetection: "force",
|
|
592
|
-
types: [
|
|
593
|
-
"node"
|
|
594
|
-
],
|
|
595
|
-
allowImportingTsExtensions: true,
|
|
596
|
-
resolveJsonModule: true,
|
|
597
|
-
verbatimModuleSyntax: true,
|
|
598
|
-
strict: true,
|
|
599
|
-
noFallthroughCasesInSwitch: true,
|
|
600
|
-
noUnusedLocals: true,
|
|
601
|
-
noUnusedParameters: true,
|
|
602
|
-
noEmit: true,
|
|
603
|
-
noUncheckedSideEffectImports: true,
|
|
604
|
-
erasableSyntaxOnly: true,
|
|
605
|
-
skipLibCheck: true
|
|
606
|
-
},
|
|
607
|
-
include: mergedInclude
|
|
608
|
-
};
|
|
609
|
-
}
|
|
610
|
-
|
|
611
|
-
// src/tsDts.ts
|
|
612
|
-
function getDefaultTsDts() {
|
|
613
|
-
return `/// <reference types="weapp-vite/client" />
|
|
614
|
-
`;
|
|
615
|
-
}
|
|
616
|
-
|
|
617
|
-
// src/utils/fs.ts
|
|
618
|
-
var import_fs_extra = __toESM(require("fs-extra"), 1);
|
|
619
|
-
var FsReadError = class extends Error {
|
|
620
|
-
constructor(filepath, cause) {
|
|
621
|
-
super(`Failed to read ${filepath}`);
|
|
622
|
-
this.filepath = filepath;
|
|
623
|
-
this.cause = cause;
|
|
624
|
-
this.name = "FsReadError";
|
|
625
|
-
}
|
|
626
|
-
};
|
|
627
|
-
var FsWriteError = class extends Error {
|
|
628
|
-
constructor(filepath, cause) {
|
|
629
|
-
super(`Failed to write ${filepath}`);
|
|
630
|
-
this.filepath = filepath;
|
|
631
|
-
this.cause = cause;
|
|
632
|
-
this.name = "FsWriteError";
|
|
633
|
-
}
|
|
634
|
-
};
|
|
635
|
-
async function readJsonIfExists(filepath) {
|
|
636
|
-
try {
|
|
637
|
-
return await import_fs_extra.default.readJSON(filepath);
|
|
638
|
-
} catch (error) {
|
|
639
|
-
if (error?.code === "ENOENT") {
|
|
640
|
-
return null;
|
|
641
|
-
}
|
|
642
|
-
throw new FsReadError(filepath, error);
|
|
643
|
-
}
|
|
644
|
-
}
|
|
645
|
-
async function readFileIfExists(filepath) {
|
|
646
|
-
try {
|
|
647
|
-
return await import_fs_extra.default.readFile(filepath, "utf8");
|
|
648
|
-
} catch (error) {
|
|
649
|
-
if (error?.code === "ENOENT") {
|
|
650
|
-
return null;
|
|
651
|
-
}
|
|
652
|
-
throw new FsReadError(filepath, error);
|
|
653
|
-
}
|
|
654
|
-
}
|
|
655
|
-
async function writeJsonFile(filepath, data, spaces = 2) {
|
|
656
|
-
try {
|
|
657
|
-
await import_fs_extra.default.outputJSON(filepath, data, {
|
|
658
|
-
spaces
|
|
659
|
-
});
|
|
660
|
-
} catch (error) {
|
|
661
|
-
throw new FsWriteError(filepath, error);
|
|
662
|
-
}
|
|
663
|
-
}
|
|
664
|
-
async function writeFile(filepath, contents) {
|
|
665
|
-
try {
|
|
666
|
-
await import_fs_extra.default.outputFile(filepath, contents, "utf8");
|
|
667
|
-
} catch (error) {
|
|
668
|
-
throw new FsWriteError(filepath, error);
|
|
669
|
-
}
|
|
670
|
-
}
|
|
671
|
-
|
|
672
|
-
// src/utils/path.ts
|
|
673
|
-
function resolveOutputPath(root, dest, fallback) {
|
|
674
|
-
if (!dest) {
|
|
675
|
-
return fallback;
|
|
676
|
-
}
|
|
677
|
-
return posix.isAbsolute(dest) ? dest : posix.resolve(root, dest);
|
|
678
|
-
}
|
|
679
|
-
|
|
680
|
-
// src/viteConfig.ts
|
|
681
|
-
function getDefaultViteConfig() {
|
|
682
|
-
return `import { defineConfig } from 'weapp-vite/config'
|
|
683
|
-
|
|
684
|
-
export default defineConfig({
|
|
685
|
-
weapp: {
|
|
686
|
-
// weapp-vite options
|
|
687
|
-
},
|
|
688
|
-
})
|
|
689
|
-
`;
|
|
690
|
-
}
|
|
691
|
-
|
|
692
|
-
// src/configFiles.ts
|
|
693
|
-
async function initViteConfigFile(options) {
|
|
694
|
-
const { root, dest, write = true } = options;
|
|
695
|
-
const packageType = ctx.packageJson.value?.type ?? "module";
|
|
696
|
-
const targetFilename = ctx.viteConfig.name = packageType === "module" ? "vite.config.ts" : "vite.config.mts";
|
|
697
|
-
const viteConfigFilePath = ctx.viteConfig.path = posix.resolve(root, targetFilename);
|
|
698
|
-
const outputPath = resolveOutputPath(root, dest, viteConfigFilePath);
|
|
699
|
-
const code = getDefaultViteConfig();
|
|
700
|
-
ctx.viteConfig.value = code;
|
|
701
|
-
if (write) {
|
|
702
|
-
await writeFile(outputPath, code);
|
|
703
|
-
import_logger.default.log(`\u2728 \u5199\u5165 ${posix.relative(root, outputPath)} \u6210\u529F!`);
|
|
704
|
-
}
|
|
705
|
-
return code;
|
|
706
|
-
}
|
|
707
|
-
async function initTsDtsFile(options) {
|
|
708
|
-
const { root, dest, write = true } = options;
|
|
709
|
-
const targetFilename = ctx.dts.name = "vite-env.d.ts";
|
|
710
|
-
const viteDtsFilePath = ctx.dts.path = posix.resolve(root, targetFilename);
|
|
711
|
-
const outputPath = resolveOutputPath(root, dest, viteDtsFilePath);
|
|
712
|
-
const code = getDefaultTsDts();
|
|
713
|
-
ctx.dts.value = code;
|
|
714
|
-
if (write) {
|
|
715
|
-
await writeFile(outputPath, code);
|
|
716
|
-
import_logger.default.log(`\u2728 \u5199\u5165 ${posix.relative(root, outputPath)} \u6210\u529F!`);
|
|
717
|
-
}
|
|
718
|
-
return code;
|
|
719
|
-
}
|
|
720
|
-
async function initTsJsonFiles(options) {
|
|
721
|
-
const { root, dest, write = true } = options;
|
|
722
|
-
const tsJsonFilename = ctx.tsconfig.name = "tsconfig.json";
|
|
723
|
-
const tsJsonFilePath = ctx.tsconfig.path = posix.resolve(root, tsJsonFilename);
|
|
724
|
-
const tsAppJsonFilename = ctx.tsconfigApp.name = "tsconfig.app.json";
|
|
725
|
-
const tsAppJsonFilePath = ctx.tsconfigApp.path = posix.resolve(root, tsAppJsonFilename);
|
|
726
|
-
const tsNodeJsonFilename = ctx.tsconfigNode.name = "tsconfig.node.json";
|
|
727
|
-
const tsNodeJsonFilePath = ctx.tsconfigNode.path = posix.resolve(root, tsNodeJsonFilename);
|
|
728
|
-
const tsconfig = getDefaultTsconfigJson();
|
|
729
|
-
const tsconfigApp = getDefaultTsconfigAppJson();
|
|
730
|
-
const includeFiles = ctx.viteConfig.name ? [ctx.viteConfig.name] : [];
|
|
731
|
-
const tsconfigNode = getDefaultTsconfigNodeJson(includeFiles);
|
|
732
|
-
ctx.tsconfig.value = tsconfig;
|
|
733
|
-
ctx.tsconfigApp.value = tsconfigApp;
|
|
734
|
-
ctx.tsconfigNode.value = tsconfigNode;
|
|
735
|
-
if (write) {
|
|
736
|
-
const tsconfigOutputPath = resolveOutputPath(root, dest, tsJsonFilePath);
|
|
737
|
-
const tsconfigAppOutputPath = resolveOutputPath(root, dest, tsAppJsonFilePath);
|
|
738
|
-
const tsconfigNodeOutputPath = resolveOutputPath(root, dest, tsNodeJsonFilePath);
|
|
739
|
-
await writeJsonFile(tsconfigOutputPath, tsconfig);
|
|
740
|
-
await writeJsonFile(tsconfigAppOutputPath, tsconfigApp);
|
|
741
|
-
await writeJsonFile(tsconfigNodeOutputPath, tsconfigNode);
|
|
742
|
-
import_logger.default.log(
|
|
743
|
-
`\u2728 \u5199\u5165 ${[
|
|
744
|
-
posix.relative(root, tsconfigOutputPath),
|
|
745
|
-
posix.relative(root, tsconfigAppOutputPath),
|
|
746
|
-
posix.relative(root, tsconfigNodeOutputPath)
|
|
747
|
-
].join(", ")} \u6210\u529F!`
|
|
748
|
-
);
|
|
749
|
-
}
|
|
750
|
-
return {
|
|
751
|
-
tsconfig,
|
|
752
|
-
tsconfigApp,
|
|
753
|
-
tsconfigNode
|
|
754
|
-
};
|
|
755
|
-
}
|
|
756
|
-
|
|
757
|
-
// src/packageJson.ts
|
|
758
|
-
var import_logger2 = __toESM(require("@weapp-core/logger"), 1);
|
|
759
|
-
var import_shared = require("@weapp-core/shared");
|
|
760
|
-
|
|
761
|
-
// ../../packages/weapp-vite/package.json
|
|
762
|
-
var version = "6.1.4";
|
|
763
|
-
|
|
764
|
-
// src/npm.ts
|
|
765
|
-
var import_node_https = __toESM(require("https"), 1);
|
|
766
|
-
function getLatestVersionFromNpm(packageName) {
|
|
767
|
-
return new Promise((resolve2, reject) => {
|
|
768
|
-
const url = `https://registry.npmjs.org/${packageName}/latest`;
|
|
769
|
-
import_node_https.default.get(url, (res) => {
|
|
770
|
-
if (!res || res.statusCode && res.statusCode >= 400) {
|
|
771
|
-
res?.resume();
|
|
772
|
-
reject(new Error(`Request to ${url} failed with status ${res?.statusCode ?? "unknown"}`));
|
|
773
|
-
return;
|
|
774
|
-
}
|
|
775
|
-
let data = "";
|
|
776
|
-
res.setEncoding("utf8");
|
|
777
|
-
res.on("data", (chunk) => data += chunk);
|
|
778
|
-
res.on("end", () => {
|
|
779
|
-
try {
|
|
780
|
-
const json = JSON.parse(data);
|
|
781
|
-
if (!json.version || typeof json.version !== "string") {
|
|
782
|
-
reject(new Error(`Unexpected response when fetching ${packageName}: missing version`));
|
|
783
|
-
return;
|
|
784
|
-
}
|
|
785
|
-
resolve2(json.version);
|
|
786
|
-
} catch (err) {
|
|
787
|
-
reject(err);
|
|
788
|
-
}
|
|
789
|
-
});
|
|
790
|
-
res.on("error", reject);
|
|
791
|
-
}).on("error", reject);
|
|
792
|
-
});
|
|
793
|
-
}
|
|
794
|
-
async function latestVersion(packageName, prefix = "^", fetch = getLatestVersionFromNpm) {
|
|
795
|
-
try {
|
|
796
|
-
const resolved = await fetch(packageName);
|
|
797
|
-
if (!resolved) {
|
|
798
|
-
return null;
|
|
799
|
-
}
|
|
800
|
-
return `${prefix}${resolved}`;
|
|
801
|
-
} catch {
|
|
802
|
-
return null;
|
|
803
|
-
}
|
|
804
|
-
}
|
|
805
|
-
|
|
806
|
-
// src/packageJson.ts
|
|
807
|
-
var FALLBACK_DEP_VERSIONS = {
|
|
808
|
-
"miniprogram-api-typings": "^4.1.0",
|
|
809
|
-
"typescript": "^5.9.2",
|
|
810
|
-
"weapp-tailwindcss": "^4.3.3"
|
|
811
|
-
};
|
|
812
|
-
function createDefaultPackageJson() {
|
|
813
|
-
return {
|
|
814
|
-
name: "weapp-vite-app",
|
|
815
|
-
homepage: "https://vite.icebreaker.top/",
|
|
816
|
-
type: "module",
|
|
817
|
-
scripts: {},
|
|
818
|
-
devDependencies: {}
|
|
819
|
-
};
|
|
820
|
-
}
|
|
821
|
-
async function upsertDependencyVersion(packageJson, keyPath, packageName, options = {}) {
|
|
822
|
-
const currentValue = (0, import_shared.get)(packageJson, keyPath);
|
|
823
|
-
const resolved = options.skipNetwork ? null : await latestVersion(packageName);
|
|
824
|
-
if (resolved) {
|
|
825
|
-
(0, import_shared.set)(packageJson, keyPath, resolved);
|
|
826
|
-
return;
|
|
827
|
-
}
|
|
828
|
-
if (currentValue === void 0) {
|
|
829
|
-
const fallback = FALLBACK_DEP_VERSIONS[packageName] ?? "latest";
|
|
830
|
-
(0, import_shared.set)(packageJson, keyPath, fallback);
|
|
831
|
-
}
|
|
832
|
-
}
|
|
833
|
-
async function createOrUpdatePackageJson(options) {
|
|
834
|
-
const { root, dest, command, cb, write, filename } = (0, import_shared.defu)(options, {
|
|
835
|
-
write: true,
|
|
836
|
-
filename: "package.json",
|
|
837
|
-
command: "weapp-vite"
|
|
838
|
-
});
|
|
839
|
-
const packageJsonFilename = ctx.packageJson.name = filename;
|
|
840
|
-
const packageJsonPath = ctx.packageJson.path = posix.resolve(root, packageJsonFilename);
|
|
841
|
-
const outputPath = resolveOutputPath(root, dest, packageJsonPath);
|
|
842
|
-
try {
|
|
843
|
-
let packageJson = await readJsonIfExists(packageJsonPath);
|
|
844
|
-
if (!packageJson) {
|
|
845
|
-
packageJson = createDefaultPackageJson();
|
|
846
|
-
import_logger2.default.info(`\u2728 \u6CA1\u6709\u627E\u5230 ${packageJsonFilename} \u6587\u4EF6\uFF0C\u6B63\u5728\u521B\u5EFA\u9ED8\u8BA4 package.json ...`);
|
|
847
|
-
}
|
|
848
|
-
(0, import_shared.set)(packageJson, "scripts.dev", `${command} dev`);
|
|
849
|
-
(0, import_shared.set)(packageJson, "scripts.dev:open", `${command} dev -o`);
|
|
850
|
-
(0, import_shared.set)(packageJson, "scripts.build", `${command} build`);
|
|
851
|
-
if (command === "weapp-vite") {
|
|
852
|
-
(0, import_shared.set)(packageJson, "scripts.open", `${command} open`);
|
|
853
|
-
(0, import_shared.set)(packageJson, "scripts.g", `${command} generate`);
|
|
854
|
-
(0, import_shared.set)(packageJson, "devDependencies.weapp-vite", `^${version}`);
|
|
855
|
-
await Promise.all([
|
|
856
|
-
upsertDependencyVersion(packageJson, "devDependencies.miniprogram-api-typings", "miniprogram-api-typings", { skipNetwork: !write }),
|
|
857
|
-
upsertDependencyVersion(packageJson, "devDependencies.typescript", "typescript", { skipNetwork: !write })
|
|
858
|
-
]);
|
|
859
|
-
}
|
|
860
|
-
cb?.(
|
|
861
|
-
(...args) => {
|
|
862
|
-
(0, import_shared.set)(packageJson, ...args);
|
|
863
|
-
}
|
|
864
|
-
);
|
|
865
|
-
ctx.packageJson.value = packageJson;
|
|
866
|
-
if (write) {
|
|
867
|
-
await writeJsonFile(outputPath, packageJson);
|
|
868
|
-
import_logger2.default.log(`\u2728 \u5199\u5165 ${posix.relative(root, outputPath)} \u6210\u529F!`);
|
|
869
|
-
}
|
|
870
|
-
return packageJson;
|
|
871
|
-
} catch (error) {
|
|
872
|
-
import_logger2.default.error(`\u26A0\uFE0F \u8BBE\u7F6E ${packageJsonFilename} \u914D\u7F6E\u6587\u4EF6\u5931\u8D25`, error);
|
|
873
|
-
throw error;
|
|
874
|
-
}
|
|
875
|
-
}
|
|
876
|
-
|
|
877
|
-
// src/projectConfig.ts
|
|
878
|
-
var import_logger3 = __toESM(require("@weapp-core/logger"), 1);
|
|
879
|
-
var import_shared2 = require("@weapp-core/shared");
|
|
880
|
-
function applyProjectConfigDefaults(projectConfig) {
|
|
881
|
-
(0, import_shared2.set)(projectConfig, "miniprogramRoot", "dist/");
|
|
882
|
-
(0, import_shared2.set)(projectConfig, "srcMiniprogramRoot", "dist/");
|
|
883
|
-
(0, import_shared2.set)(projectConfig, "setting.packNpmManually", true);
|
|
884
|
-
const compileType = (0, import_shared2.get)(projectConfig, "compileType");
|
|
885
|
-
if (compileType === "plugin") {
|
|
886
|
-
(0, import_shared2.set)(projectConfig, "pluginRoot", "dist-plugin");
|
|
887
|
-
}
|
|
888
|
-
}
|
|
889
|
-
function ensurePackNpmRelationList(projectConfig) {
|
|
890
|
-
const relations = (0, import_shared2.get)(projectConfig, "setting.packNpmRelationList");
|
|
891
|
-
const defaultRelation = {
|
|
892
|
-
packageJsonPath: "./package.json",
|
|
893
|
-
miniprogramNpmDistDir: "./dist"
|
|
894
|
-
};
|
|
895
|
-
if (Array.isArray(relations)) {
|
|
896
|
-
const exists = relations.some(
|
|
897
|
-
(relation) => relation.packageJsonPath === defaultRelation.packageJsonPath && relation.miniprogramNpmDistDir === defaultRelation.miniprogramNpmDistDir
|
|
898
|
-
);
|
|
899
|
-
if (!exists) {
|
|
900
|
-
relations.push(defaultRelation);
|
|
901
|
-
}
|
|
902
|
-
} else {
|
|
903
|
-
(0, import_shared2.set)(projectConfig, "setting.packNpmRelationList", [defaultRelation]);
|
|
904
|
-
}
|
|
905
|
-
}
|
|
906
|
-
function createDefaultProjectConfig() {
|
|
907
|
-
return {
|
|
908
|
-
compileType: "miniprogram",
|
|
909
|
-
libVersion: "trial",
|
|
910
|
-
packOptions: {
|
|
911
|
-
ignore: [],
|
|
912
|
-
include: []
|
|
913
|
-
},
|
|
914
|
-
setting: {
|
|
915
|
-
coverView: true,
|
|
916
|
-
es6: true,
|
|
917
|
-
postcss: true,
|
|
918
|
-
minified: true,
|
|
919
|
-
enhance: true,
|
|
920
|
-
showShadowRootInWxmlPanel: true,
|
|
921
|
-
packNpmRelationList: [
|
|
922
|
-
{
|
|
923
|
-
packageJsonPath: "./package.json",
|
|
924
|
-
miniprogramNpmDistDir: "./dist"
|
|
925
|
-
}
|
|
926
|
-
],
|
|
927
|
-
babelSetting: {
|
|
928
|
-
ignore: [],
|
|
929
|
-
disablePlugins: [],
|
|
930
|
-
outputPath: ""
|
|
931
|
-
},
|
|
932
|
-
packNpmManually: true
|
|
933
|
-
},
|
|
934
|
-
condition: {},
|
|
935
|
-
editorSetting: {
|
|
936
|
-
tabIndent: "auto",
|
|
937
|
-
tabSize: 2
|
|
938
|
-
},
|
|
939
|
-
appid: "",
|
|
940
|
-
miniprogramRoot: "dist/",
|
|
941
|
-
srcMiniprogramRoot: "dist/"
|
|
942
|
-
};
|
|
943
|
-
}
|
|
944
|
-
async function createOrUpdateProjectConfig(options) {
|
|
945
|
-
const { root, dest, cb, write, filename } = (0, import_shared2.defu)(
|
|
946
|
-
options,
|
|
947
|
-
{
|
|
948
|
-
write: true,
|
|
949
|
-
filename: "project.config.json"
|
|
950
|
-
}
|
|
951
|
-
);
|
|
952
|
-
const projectConfigFilename = ctx.projectConfig.name = filename;
|
|
953
|
-
const projectConfigPath = ctx.projectConfig.path = posix.resolve(root, projectConfigFilename);
|
|
954
|
-
const outputPath = resolveOutputPath(root, dest, projectConfigPath);
|
|
955
|
-
try {
|
|
956
|
-
let projectConfig = await readJsonIfExists(projectConfigPath);
|
|
957
|
-
if (projectConfig) {
|
|
958
|
-
applyProjectConfigDefaults(projectConfig);
|
|
959
|
-
} else {
|
|
960
|
-
projectConfig = createDefaultProjectConfig();
|
|
961
|
-
import_logger3.default.info(`\u2728 \u6CA1\u6709\u627E\u5230 ${projectConfigFilename} \u6587\u4EF6\uFF0C\u6B63\u5728\u4F7F\u7528\u9ED8\u8BA4\u6A21\u677F\u521B\u5EFA...`);
|
|
962
|
-
}
|
|
963
|
-
cb?.(
|
|
964
|
-
(...args) => {
|
|
965
|
-
(0, import_shared2.set)(projectConfig, ...args);
|
|
966
|
-
}
|
|
967
|
-
);
|
|
968
|
-
ensurePackNpmRelationList(projectConfig);
|
|
969
|
-
ctx.projectConfig.value = projectConfig;
|
|
970
|
-
if (write) {
|
|
971
|
-
await writeJsonFile(outputPath, projectConfig);
|
|
972
|
-
import_logger3.default.log(`\u2728 \u5199\u5165 ${posix.relative(root, outputPath)} \u6210\u529F!`);
|
|
973
|
-
}
|
|
974
|
-
return projectConfig;
|
|
975
|
-
} catch (error) {
|
|
976
|
-
import_logger3.default.error(`\u26A0\uFE0F \u8BBE\u7F6E ${projectConfigFilename} \u914D\u7F6E\u6587\u4EF6\u5931\u8D25`, error);
|
|
977
|
-
throw error;
|
|
978
|
-
}
|
|
979
|
-
}
|
|
980
|
-
|
|
981
|
-
// src/updateGitignore.ts
|
|
982
|
-
var import_logger4 = __toESM(require("@weapp-core/logger"), 1);
|
|
983
|
-
|
|
984
|
-
// src/gitignore.ts
|
|
985
|
-
var DEFAULT_GITIGNORE = `# dependencies
|
|
986
|
-
node_modules
|
|
987
|
-
.pnp
|
|
988
|
-
.pnp.js
|
|
989
|
-
|
|
990
|
-
# testing
|
|
991
|
-
coverage
|
|
992
|
-
|
|
993
|
-
# next.js
|
|
994
|
-
.next/
|
|
995
|
-
out/
|
|
996
|
-
build
|
|
997
|
-
|
|
998
|
-
# misc
|
|
999
|
-
.DS_Store
|
|
1000
|
-
*.pem
|
|
1001
|
-
|
|
1002
|
-
# debug
|
|
1003
|
-
npm-debug.log*
|
|
1004
|
-
yarn-debug.log*
|
|
1005
|
-
yarn-error.log*
|
|
1006
|
-
.pnpm-debug.log*
|
|
1007
|
-
|
|
1008
|
-
# local env files
|
|
1009
|
-
.env.local
|
|
1010
|
-
.env.development.local
|
|
1011
|
-
.env.test.local
|
|
1012
|
-
.env.production.local
|
|
1013
|
-
|
|
1014
|
-
# turbo
|
|
1015
|
-
.turbo
|
|
1016
|
-
|
|
1017
|
-
dist
|
|
1018
|
-
dist-plugin
|
|
1019
|
-
dist-web
|
|
1020
|
-
vite.config.ts.timestamp-*.mjs`;
|
|
1021
|
-
function normalizeLineEndings(value) {
|
|
1022
|
-
return value.replace(/\r\n/g, "\n");
|
|
1023
|
-
}
|
|
1024
|
-
function trimTrailingBlankLines(lines) {
|
|
1025
|
-
let end = lines.length;
|
|
1026
|
-
while (end > 0 && lines[end - 1] === "") {
|
|
1027
|
-
end -= 1;
|
|
1028
|
-
}
|
|
1029
|
-
return lines.slice(0, end);
|
|
1030
|
-
}
|
|
1031
|
-
function ensureTrailingNewline(value) {
|
|
1032
|
-
return value.endsWith("\n") ? value : `${value}
|
|
1033
|
-
`;
|
|
1034
|
-
}
|
|
1035
|
-
function mergeGitignore(existing) {
|
|
1036
|
-
const normalizedExisting = normalizeLineEndings(existing ?? "");
|
|
1037
|
-
const existingLines = normalizedExisting.length ? normalizedExisting.split("\n") : [];
|
|
1038
|
-
const merged = [...existingLines];
|
|
1039
|
-
while (merged.length > 0 && merged[merged.length - 1] === "") {
|
|
1040
|
-
merged.pop();
|
|
1041
|
-
}
|
|
1042
|
-
const seen = new Set(merged);
|
|
1043
|
-
let appendedNonBlank = false;
|
|
1044
|
-
for (const line of DEFAULT_GITIGNORE.split("\n")) {
|
|
1045
|
-
const isBlank = line.length === 0;
|
|
1046
|
-
if (isBlank) {
|
|
1047
|
-
if (merged.length === 0 || merged[merged.length - 1] === "") {
|
|
1048
|
-
continue;
|
|
1049
|
-
}
|
|
1050
|
-
merged.push("");
|
|
1051
|
-
continue;
|
|
1052
|
-
}
|
|
1053
|
-
if (seen.has(line)) {
|
|
1054
|
-
continue;
|
|
1055
|
-
}
|
|
1056
|
-
if (!appendedNonBlank && merged.length > 0 && merged[merged.length - 1] !== "") {
|
|
1057
|
-
merged.push("");
|
|
1058
|
-
}
|
|
1059
|
-
merged.push(line);
|
|
1060
|
-
seen.add(line);
|
|
1061
|
-
appendedNonBlank = true;
|
|
1062
|
-
}
|
|
1063
|
-
return ensureTrailingNewline(trimTrailingBlankLines(merged).join("\n"));
|
|
1064
|
-
}
|
|
1065
|
-
|
|
1066
|
-
// src/updateGitignore.ts
|
|
1067
|
-
async function updateGitIgnore(options) {
|
|
1068
|
-
const { root, dest, write = true } = options;
|
|
1069
|
-
const gitignorePath = posix.resolve(root, ".gitignore");
|
|
1070
|
-
const outputPath = resolveOutputPath(root, dest, gitignorePath);
|
|
1071
|
-
const existing = await readFileIfExists(outputPath);
|
|
1072
|
-
const merged = mergeGitignore(existing);
|
|
1073
|
-
if (write && merged !== (existing ?? "")) {
|
|
1074
|
-
await writeFile(outputPath, merged);
|
|
1075
|
-
import_logger4.default.log(`\u2728 \u66F4\u65B0 ${posix.relative(root, outputPath)} \u6210\u529F!`);
|
|
1076
|
-
}
|
|
1077
|
-
return merged;
|
|
1078
|
-
}
|
|
1079
|
-
|
|
1080
|
-
// src/index.ts
|
|
1081
|
-
async function initConfig(options) {
|
|
1082
|
-
const { root = import_node_process.default.cwd(), command } = options;
|
|
1083
|
-
await createOrUpdateProjectConfig({ root });
|
|
1084
|
-
await createOrUpdatePackageJson({ root, command });
|
|
1085
|
-
await updateGitIgnore({ root });
|
|
1086
|
-
if (command === "weapp-vite") {
|
|
1087
|
-
await initViteConfigFile({ root });
|
|
1088
|
-
await initTsDtsFile({ root });
|
|
1089
|
-
await initTsJsonFiles({ root });
|
|
1090
|
-
}
|
|
1091
|
-
return ctx;
|
|
1092
|
-
}
|
|
1093
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
1094
|
-
0 && (module.exports = {
|
|
1095
|
-
createOrUpdatePackageJson,
|
|
1096
|
-
createOrUpdateProjectConfig,
|
|
1097
|
-
initConfig,
|
|
1098
|
-
initTsDtsFile,
|
|
1099
|
-
initTsJsonFiles,
|
|
1100
|
-
initViteConfigFile,
|
|
1101
|
-
resetContext
|
|
1102
|
-
});
|
package/dist/index.d.cts
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import { PackageJson, TSConfig } from 'pkg-types';
|
|
2
|
-
import { set } from '@weapp-core/shared';
|
|
3
|
-
|
|
4
|
-
interface SetMethod {
|
|
5
|
-
(path: set.InputType, value: any, options?: set.Options): void;
|
|
6
|
-
}
|
|
7
|
-
interface SharedUpdateOptions {
|
|
8
|
-
root: string;
|
|
9
|
-
dest?: string;
|
|
10
|
-
write?: boolean;
|
|
11
|
-
cb?: (set: SetMethod) => void;
|
|
12
|
-
}
|
|
13
|
-
interface UpdateProjectConfigOptions extends SharedUpdateOptions {
|
|
14
|
-
filename?: string;
|
|
15
|
-
}
|
|
16
|
-
interface UpdatePackageJsonOptions extends SharedUpdateOptions {
|
|
17
|
-
command?: 'weapp-vite';
|
|
18
|
-
filename?: string;
|
|
19
|
-
}
|
|
20
|
-
interface ProjectConfig {
|
|
21
|
-
miniprogramRoot?: string;
|
|
22
|
-
srcMiniprogramRoot?: string;
|
|
23
|
-
setting: {
|
|
24
|
-
packNpmManually: boolean;
|
|
25
|
-
packNpmRelationList: {
|
|
26
|
-
packageJsonPath: string;
|
|
27
|
-
miniprogramNpmDistDir: string;
|
|
28
|
-
}[];
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
interface ContextDocument<T> {
|
|
33
|
-
name: string;
|
|
34
|
-
path: string;
|
|
35
|
-
value: T | null;
|
|
36
|
-
}
|
|
37
|
-
interface Context {
|
|
38
|
-
projectConfig: ContextDocument<ProjectConfig>;
|
|
39
|
-
packageJson: ContextDocument<PackageJson>;
|
|
40
|
-
viteConfig: ContextDocument<string>;
|
|
41
|
-
tsconfig: ContextDocument<TSConfig>;
|
|
42
|
-
tsconfigApp: ContextDocument<TSConfig>;
|
|
43
|
-
tsconfigNode: ContextDocument<TSConfig>;
|
|
44
|
-
dts: ContextDocument<string>;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
declare function initViteConfigFile(options: SharedUpdateOptions): Promise<string>;
|
|
48
|
-
declare function initTsDtsFile(options: SharedUpdateOptions): Promise<string>;
|
|
49
|
-
declare function initTsJsonFiles(options: SharedUpdateOptions): Promise<{
|
|
50
|
-
tsconfig: {
|
|
51
|
-
references: {
|
|
52
|
-
path: string;
|
|
53
|
-
}[];
|
|
54
|
-
files: never[];
|
|
55
|
-
};
|
|
56
|
-
tsconfigApp: {
|
|
57
|
-
compilerOptions: {
|
|
58
|
-
tsBuildInfoFile: string;
|
|
59
|
-
target: string;
|
|
60
|
-
lib: string[];
|
|
61
|
-
jsx: string;
|
|
62
|
-
module: string;
|
|
63
|
-
moduleResolution: string;
|
|
64
|
-
moduleDetection: string;
|
|
65
|
-
baseUrl: string;
|
|
66
|
-
paths: {
|
|
67
|
-
'@/*': string[];
|
|
68
|
-
'take:@/*': string[];
|
|
69
|
-
};
|
|
70
|
-
resolveJsonModule: boolean;
|
|
71
|
-
types: string[];
|
|
72
|
-
allowImportingTsExtensions: boolean;
|
|
73
|
-
allowJs: boolean;
|
|
74
|
-
allowSyntheticDefaultImports: boolean;
|
|
75
|
-
esModuleInterop: boolean;
|
|
76
|
-
isolatedModules: boolean;
|
|
77
|
-
strict: boolean;
|
|
78
|
-
noFallthroughCasesInSwitch: boolean;
|
|
79
|
-
noUnusedLocals: boolean;
|
|
80
|
-
noUnusedParameters: boolean;
|
|
81
|
-
noEmit: boolean;
|
|
82
|
-
verbatimModuleSyntax: boolean;
|
|
83
|
-
noUncheckedSideEffectImports: boolean;
|
|
84
|
-
erasableSyntaxOnly: boolean;
|
|
85
|
-
skipLibCheck: boolean;
|
|
86
|
-
};
|
|
87
|
-
include: string[];
|
|
88
|
-
};
|
|
89
|
-
tsconfigNode: {
|
|
90
|
-
compilerOptions: {
|
|
91
|
-
tsBuildInfoFile: string;
|
|
92
|
-
target: string;
|
|
93
|
-
lib: string[];
|
|
94
|
-
module: string;
|
|
95
|
-
moduleResolution: string;
|
|
96
|
-
moduleDetection: string;
|
|
97
|
-
types: string[];
|
|
98
|
-
allowImportingTsExtensions: boolean;
|
|
99
|
-
resolveJsonModule: boolean;
|
|
100
|
-
verbatimModuleSyntax: boolean;
|
|
101
|
-
strict: boolean;
|
|
102
|
-
noFallthroughCasesInSwitch: boolean;
|
|
103
|
-
noUnusedLocals: boolean;
|
|
104
|
-
noUnusedParameters: boolean;
|
|
105
|
-
noEmit: boolean;
|
|
106
|
-
noUncheckedSideEffectImports: boolean;
|
|
107
|
-
erasableSyntaxOnly: boolean;
|
|
108
|
-
skipLibCheck: boolean;
|
|
109
|
-
};
|
|
110
|
-
include: string[];
|
|
111
|
-
};
|
|
112
|
-
}>;
|
|
113
|
-
|
|
114
|
-
declare function createOrUpdatePackageJson(options: UpdatePackageJsonOptions): Promise<PackageJson>;
|
|
115
|
-
|
|
116
|
-
declare function createOrUpdateProjectConfig(options: UpdateProjectConfigOptions): Promise<ProjectConfig>;
|
|
117
|
-
|
|
118
|
-
declare function resetContext(): void;
|
|
119
|
-
|
|
120
|
-
declare function initConfig(options: {
|
|
121
|
-
root?: string;
|
|
122
|
-
command?: 'weapp-vite';
|
|
123
|
-
}): Promise<Context>;
|
|
124
|
-
|
|
125
|
-
export { type Context, createOrUpdatePackageJson, createOrUpdateProjectConfig, initConfig, initTsDtsFile, initTsJsonFiles, initViteConfigFile, resetContext };
|