weapp-vite 5.1.8 → 5.2.0-alpha.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/auto-import-components/resolvers.cjs +9 -10
- package/dist/auto-import-components/resolvers.mjs +5 -6
- package/dist/{chunk-25P7FHKE.mjs → chunk-7MAZ2JUY.mjs} +2 -4
- package/dist/chunk-BT7FLFCC.cjs +29 -0
- package/dist/{chunk-HZDUFKUQ.cjs → chunk-DVVMF6ND.cjs} +2 -4
- package/dist/chunk-FUOZYLBR.mjs +29 -0
- package/dist/{chunk-CFXQW5Z6.mjs → chunk-HVMR6H5Z.mjs} +1 -3
- package/dist/chunk-NANSUN4W.mjs +6 -0
- package/dist/{chunk-PGL7ZN2W.cjs → chunk-OS76JPG2.cjs} +4 -6
- package/dist/{chunk-V5JUVPYM.mjs → chunk-Q43Q3Z2L.mjs} +10622 -20717
- package/dist/chunk-U5ERJUOU.cjs +6 -0
- package/dist/{chunk-TBCCIJBL.cjs → chunk-Y6PWETW7.cjs} +24244 -34339
- package/dist/cli.cjs +131 -128
- package/dist/cli.mjs +113 -110
- package/dist/{config-D8_I48lF.d.cts → config-DZ6sLDPC.d.cts} +188 -181
- package/dist/{config-bZQG-PcY.d.ts → config-jn9VVQXs.d.ts} +188 -181
- package/dist/config.cjs +4 -4
- package/dist/config.d.cts +3 -5
- package/dist/config.d.ts +3 -5
- package/dist/config.mjs +3 -3
- package/dist/index.cjs +7 -9
- package/dist/index.d.cts +6 -8
- package/dist/index.d.ts +6 -8
- package/dist/index.mjs +6 -8
- package/dist/json.cjs +3 -3
- package/dist/json.d.cts +3 -5
- package/dist/json.d.ts +3 -5
- package/dist/json.mjs +2 -2
- package/dist/types.cjs +8 -7
- package/dist/types.d.cts +7 -9
- package/dist/types.d.ts +7 -9
- package/dist/types.mjs +2 -1
- package/dist/volar.cjs +2 -2
- package/dist/volar.mjs +1 -1
- package/package.json +15 -17
- package/dist/chunk-AIYQXRJY.mjs +0 -30
- package/dist/chunk-O47EPGAL.cjs +0 -30
package/dist/cli.cjs
CHANGED
|
@@ -3,33 +3,26 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
+
var _chunkY6PWETW7cjs = require('./chunk-Y6PWETW7.cjs');
|
|
6
7
|
|
|
7
|
-
var _chunkTBCCIJBLcjs = require('./chunk-TBCCIJBL.cjs');
|
|
8
|
-
require('./chunk-HZDUFKUQ.cjs');
|
|
9
|
-
require('./chunk-O47EPGAL.cjs');
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var _chunkPGL7ZN2Wcjs = require('./chunk-PGL7ZN2W.cjs');
|
|
9
|
+
var _chunkOS76JPG2cjs = require('./chunk-OS76JPG2.cjs');
|
|
15
10
|
|
|
16
11
|
// src/cli.ts
|
|
17
|
-
|
|
12
|
+
_chunkOS76JPG2cjs.init_cjs_shims.call(void 0, );
|
|
18
13
|
var _process = require('process'); var _process2 = _interopRequireDefault(_process);
|
|
19
14
|
var _init = require('@weapp-core/init');
|
|
20
15
|
|
|
21
16
|
// ../../node_modules/.pnpm/cac@6.7.14/node_modules/cac/dist/index.mjs
|
|
22
|
-
|
|
17
|
+
_chunkOS76JPG2cjs.init_cjs_shims.call(void 0, );
|
|
23
18
|
var _events = require('events');
|
|
24
19
|
function toArr(any) {
|
|
25
20
|
return any == null ? [] : Array.isArray(any) ? any : [any];
|
|
26
21
|
}
|
|
27
|
-
_chunkPGL7ZN2Wcjs.__name.call(void 0, toArr, "toArr");
|
|
28
22
|
function toVal(out, key, val, opts) {
|
|
29
23
|
var x, old = out[key], nxt = !!~opts.string.indexOf(key) ? val == null || val === true ? "" : String(val) : typeof val === "boolean" ? val : !!~opts.boolean.indexOf(key) ? val === "false" ? false : val === "true" || (out._.push((x = +val, x * 0 === 0) ? x : val), !!val) : (x = +val, x * 0 === 0) ? x : val;
|
|
30
24
|
out[key] = old == null ? nxt : Array.isArray(old) ? old.concat(nxt) : [old, nxt];
|
|
31
25
|
}
|
|
32
|
-
_chunkPGL7ZN2Wcjs.__name.call(void 0, toVal, "toVal");
|
|
33
26
|
function mri2(args, opts) {
|
|
34
27
|
args = args || [];
|
|
35
28
|
opts = opts || {};
|
|
@@ -118,13 +111,12 @@ function mri2(args, opts) {
|
|
|
118
111
|
}
|
|
119
112
|
return out;
|
|
120
113
|
}
|
|
121
|
-
|
|
122
|
-
var
|
|
123
|
-
var findAllBrackets = /* @__PURE__ */ _chunkPGL7ZN2Wcjs.__name.call(void 0, (v) => {
|
|
114
|
+
var removeBrackets = (v) => v.replace(/[<[].+/, "").trim();
|
|
115
|
+
var findAllBrackets = (v) => {
|
|
124
116
|
const ANGLED_BRACKET_RE_GLOBAL = /<([^>]+)>/g;
|
|
125
117
|
const SQUARE_BRACKET_RE_GLOBAL = /\[([^\]]+)\]/g;
|
|
126
118
|
const res = [];
|
|
127
|
-
const parse2 =
|
|
119
|
+
const parse2 = (match) => {
|
|
128
120
|
let variadic = false;
|
|
129
121
|
let value = match[1];
|
|
130
122
|
if (value.startsWith("...")) {
|
|
@@ -136,7 +128,7 @@ var findAllBrackets = /* @__PURE__ */ _chunkPGL7ZN2Wcjs.__name.call(void 0, (v)
|
|
|
136
128
|
value,
|
|
137
129
|
variadic
|
|
138
130
|
};
|
|
139
|
-
}
|
|
131
|
+
};
|
|
140
132
|
let angledMatch;
|
|
141
133
|
while (angledMatch = ANGLED_BRACKET_RE_GLOBAL.exec(v)) {
|
|
142
134
|
res.push(parse2(angledMatch));
|
|
@@ -146,8 +138,8 @@ var findAllBrackets = /* @__PURE__ */ _chunkPGL7ZN2Wcjs.__name.call(void 0, (v)
|
|
|
146
138
|
res.push(parse2(squareMatch));
|
|
147
139
|
}
|
|
148
140
|
return res;
|
|
149
|
-
}
|
|
150
|
-
var getMriOptions =
|
|
141
|
+
};
|
|
142
|
+
var getMriOptions = (options) => {
|
|
151
143
|
const result = { alias: {}, boolean: [] };
|
|
152
144
|
for (const [index, option] of options.entries()) {
|
|
153
145
|
if (option.names.length > 1) {
|
|
@@ -167,21 +159,21 @@ var getMriOptions = /* @__PURE__ */ _chunkPGL7ZN2Wcjs.__name.call(void 0, (optio
|
|
|
167
159
|
}
|
|
168
160
|
}
|
|
169
161
|
return result;
|
|
170
|
-
}
|
|
171
|
-
var findLongest =
|
|
162
|
+
};
|
|
163
|
+
var findLongest = (arr) => {
|
|
172
164
|
return arr.sort((a, b) => {
|
|
173
165
|
return a.length > b.length ? -1 : 1;
|
|
174
166
|
})[0];
|
|
175
|
-
}
|
|
176
|
-
var padRight =
|
|
167
|
+
};
|
|
168
|
+
var padRight = (str, length) => {
|
|
177
169
|
return str.length >= length ? str : `${str}${" ".repeat(length - str.length)}`;
|
|
178
|
-
}
|
|
179
|
-
var camelcase =
|
|
170
|
+
};
|
|
171
|
+
var camelcase = (input) => {
|
|
180
172
|
return input.replace(/([a-z])-([a-z])/g, (_, p1, p2) => {
|
|
181
173
|
return p1 + p2.toUpperCase();
|
|
182
174
|
});
|
|
183
|
-
}
|
|
184
|
-
var setDotProp =
|
|
175
|
+
};
|
|
176
|
+
var setDotProp = (obj, keys, val) => {
|
|
185
177
|
let i = 0;
|
|
186
178
|
let length = keys.length;
|
|
187
179
|
let t = obj;
|
|
@@ -190,8 +182,8 @@ var setDotProp = /* @__PURE__ */ _chunkPGL7ZN2Wcjs.__name.call(void 0, (obj, key
|
|
|
190
182
|
x = t[keys[i]];
|
|
191
183
|
t = t[keys[i]] = i === length - 1 ? val : x != null ? x : !!~keys[i + 1].indexOf(".") || !(+keys[i + 1] > -1) ? {} : [];
|
|
192
184
|
}
|
|
193
|
-
}
|
|
194
|
-
var setByType =
|
|
185
|
+
};
|
|
186
|
+
var setByType = (obj, transforms) => {
|
|
195
187
|
for (const key of Object.keys(transforms)) {
|
|
196
188
|
const transform = transforms[key];
|
|
197
189
|
if (transform.shouldTransform) {
|
|
@@ -201,20 +193,17 @@ var setByType = /* @__PURE__ */ _chunkPGL7ZN2Wcjs.__name.call(void 0, (obj, tran
|
|
|
201
193
|
}
|
|
202
194
|
}
|
|
203
195
|
}
|
|
204
|
-
}
|
|
205
|
-
var getFileName =
|
|
196
|
+
};
|
|
197
|
+
var getFileName = (input) => {
|
|
206
198
|
const m = /([^\\\/]+)$/.exec(input);
|
|
207
199
|
return m ? m[1] : "";
|
|
208
|
-
}
|
|
209
|
-
var camelcaseOptionName =
|
|
200
|
+
};
|
|
201
|
+
var camelcaseOptionName = (name) => {
|
|
210
202
|
return name.split(".").map((v, i) => {
|
|
211
203
|
return i === 0 ? camelcase(v) : v;
|
|
212
204
|
}).join(".");
|
|
213
|
-
}
|
|
205
|
+
};
|
|
214
206
|
var CACError = class extends Error {
|
|
215
|
-
static {
|
|
216
|
-
_chunkPGL7ZN2Wcjs.__name.call(void 0, this, "CACError");
|
|
217
|
-
}
|
|
218
207
|
constructor(message) {
|
|
219
208
|
super(message);
|
|
220
209
|
this.name = this.constructor.name;
|
|
@@ -226,9 +215,6 @@ var CACError = class extends Error {
|
|
|
226
215
|
}
|
|
227
216
|
};
|
|
228
217
|
var Option = class {
|
|
229
|
-
static {
|
|
230
|
-
_chunkPGL7ZN2Wcjs.__name.call(void 0, this, "Option");
|
|
231
|
-
}
|
|
232
218
|
constructor(rawName, description, config) {
|
|
233
219
|
this.rawName = rawName;
|
|
234
220
|
this.description = description;
|
|
@@ -259,9 +245,6 @@ var Option = class {
|
|
|
259
245
|
var processArgs = process.argv;
|
|
260
246
|
var platformInfo = `${process.platform}-${process.arch} node-${process.version}`;
|
|
261
247
|
var Command = class {
|
|
262
|
-
static {
|
|
263
|
-
_chunkPGL7ZN2Wcjs.__name.call(void 0, this, "Command");
|
|
264
|
-
}
|
|
265
248
|
constructor(rawName, description, config = {}, cli2) {
|
|
266
249
|
this.rawName = rawName;
|
|
267
250
|
this.description = description;
|
|
@@ -422,18 +405,12 @@ ${section.body}` : section.body;
|
|
|
422
405
|
}
|
|
423
406
|
};
|
|
424
407
|
var GlobalCommand = class extends Command {
|
|
425
|
-
static {
|
|
426
|
-
_chunkPGL7ZN2Wcjs.__name.call(void 0, this, "GlobalCommand");
|
|
427
|
-
}
|
|
428
408
|
constructor(cli2) {
|
|
429
409
|
super("@@global@@", "", {}, cli2);
|
|
430
410
|
}
|
|
431
411
|
};
|
|
432
412
|
var __assign = Object.assign;
|
|
433
413
|
var CAC = class extends _events.EventEmitter {
|
|
434
|
-
static {
|
|
435
|
-
_chunkPGL7ZN2Wcjs.__name.call(void 0, this, "CAC");
|
|
436
|
-
}
|
|
437
414
|
constructor(name = "") {
|
|
438
415
|
super();
|
|
439
416
|
this.name = name;
|
|
@@ -620,10 +597,10 @@ var CAC = class extends _events.EventEmitter {
|
|
|
620
597
|
return command.commandAction.apply(this, actionArgs);
|
|
621
598
|
}
|
|
622
599
|
};
|
|
623
|
-
var cac =
|
|
600
|
+
var cac = (name = "") => new CAC(name);
|
|
624
601
|
|
|
625
602
|
// ../../node_modules/.pnpm/package-manager-detector@1.3.0/node_modules/package-manager-detector/dist/commands.mjs
|
|
626
|
-
|
|
603
|
+
_chunkOS76JPG2cjs.init_cjs_shims.call(void 0, );
|
|
627
604
|
function dashDashArg(agent, agentCommand) {
|
|
628
605
|
return (args) => {
|
|
629
606
|
if (args.length > 1) {
|
|
@@ -633,13 +610,11 @@ function dashDashArg(agent, agentCommand) {
|
|
|
633
610
|
}
|
|
634
611
|
};
|
|
635
612
|
}
|
|
636
|
-
_chunkPGL7ZN2Wcjs.__name.call(void 0, dashDashArg, "dashDashArg");
|
|
637
613
|
function denoExecute() {
|
|
638
614
|
return (args) => {
|
|
639
615
|
return ["deno", "run", `npm:${args[0]}`, ...args.slice(1)];
|
|
640
616
|
};
|
|
641
617
|
}
|
|
642
|
-
_chunkPGL7ZN2Wcjs.__name.call(void 0, denoExecute, "denoExecute");
|
|
643
618
|
var npm = {
|
|
644
619
|
"agent": ["npm", 0],
|
|
645
620
|
"run": dashDashArg("npm", "run"),
|
|
@@ -738,7 +713,6 @@ function resolveCommand(agent, command, args) {
|
|
|
738
713
|
const value = COMMANDS[agent][command];
|
|
739
714
|
return constructCommand(value, args);
|
|
740
715
|
}
|
|
741
|
-
_chunkPGL7ZN2Wcjs.__name.call(void 0, resolveCommand, "resolveCommand");
|
|
742
716
|
function constructCommand(value, args) {
|
|
743
717
|
if (value == null)
|
|
744
718
|
return null;
|
|
@@ -752,7 +726,6 @@ function constructCommand(value, args) {
|
|
|
752
726
|
args: list.slice(1)
|
|
753
727
|
};
|
|
754
728
|
}
|
|
755
|
-
_chunkPGL7ZN2Wcjs.__name.call(void 0, constructCommand, "constructCommand");
|
|
756
729
|
|
|
757
730
|
// src/cli.ts
|
|
758
731
|
var _pathe = require('pathe'); var _pathe2 = _interopRequireDefault(_pathe);
|
|
@@ -760,7 +733,7 @@ var _vite = require('vite');
|
|
|
760
733
|
var _weappidecli = require('weapp-ide-cli');
|
|
761
734
|
|
|
762
735
|
// src/schematics.ts
|
|
763
|
-
|
|
736
|
+
_chunkOS76JPG2cjs.init_cjs_shims.call(void 0, );
|
|
764
737
|
|
|
765
738
|
var _schematics = require('@weapp-core/schematics');
|
|
766
739
|
var _shared = require('@weapp-core/shared');
|
|
@@ -769,7 +742,6 @@ var _fsextra = require('fs-extra'); var _fsextra2 = _interopRequireDefault(_fsex
|
|
|
769
742
|
function composePath(outDir, filename) {
|
|
770
743
|
return `${outDir}${outDir ? "/" : ""}${filename}`;
|
|
771
744
|
}
|
|
772
|
-
_chunkPGL7ZN2Wcjs.__name.call(void 0, composePath, "composePath");
|
|
773
745
|
var defaultExtensions = {
|
|
774
746
|
js: "js",
|
|
775
747
|
json: "json",
|
|
@@ -779,62 +751,98 @@ var defaultExtensions = {
|
|
|
779
751
|
function resolveExtension(extension) {
|
|
780
752
|
return extension ? extension.startsWith(".") ? extension : `.${extension}` : "";
|
|
781
753
|
}
|
|
782
|
-
_chunkPGL7ZN2Wcjs.__name.call(void 0, resolveExtension, "resolveExtension");
|
|
783
754
|
async function generate(options) {
|
|
784
|
-
let { fileName, outDir, extensions, type, cwd } = _shared.defu.call(void 0, options, {
|
|
785
|
-
// fileName: 'index',
|
|
755
|
+
let { fileName, outDir, extensions, type, cwd, templates } = _shared.defu.call(void 0, options, {
|
|
786
756
|
type: "component",
|
|
787
757
|
extensions: {
|
|
788
758
|
...defaultExtensions
|
|
789
759
|
},
|
|
790
|
-
cwd: _process2.default.cwd()
|
|
760
|
+
cwd: _process2.default.cwd(),
|
|
761
|
+
templates: void 0
|
|
791
762
|
});
|
|
792
763
|
if (fileName === void 0) {
|
|
793
764
|
fileName = _pathe2.default.basename(outDir);
|
|
794
765
|
}
|
|
795
766
|
const basepath = _pathe2.default.resolve(cwd, outDir);
|
|
796
|
-
const targetFileTypes = [
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
code = _schematics.generateWxml.call(void 0, _pathe2.default.join(outDir, fileName));
|
|
813
|
-
} else if (x === "json") {
|
|
814
|
-
code = _schematics.generateJson.call(void 0, type, ext);
|
|
815
|
-
if (ext === "js" || ext === "ts") {
|
|
816
|
-
ext = `json.${ext}`;
|
|
767
|
+
const targetFileTypes = type === "app" ? ["js", "wxss", "json"] : ["js", "wxss", "json", "wxml"];
|
|
768
|
+
const files = [];
|
|
769
|
+
for (const fileType of targetFileTypes) {
|
|
770
|
+
const configuredExt = _nullishCoalesce(extensions[fileType], () => ( defaultExtensions[fileType]));
|
|
771
|
+
let resolvedExt = configuredExt;
|
|
772
|
+
let defaultCode;
|
|
773
|
+
if (fileType === "js") {
|
|
774
|
+
defaultCode = _schematics.generateJs.call(void 0, type);
|
|
775
|
+
} else if (fileType === "wxss") {
|
|
776
|
+
defaultCode = _schematics.generateWxss.call(void 0, );
|
|
777
|
+
} else if (fileType === "wxml") {
|
|
778
|
+
defaultCode = _schematics.generateWxml.call(void 0, _pathe2.default.join(outDir, fileName));
|
|
779
|
+
} else if (fileType === "json") {
|
|
780
|
+
defaultCode = _schematics.generateJson.call(void 0, type, configuredExt);
|
|
781
|
+
if (configuredExt === "js" || configuredExt === "ts") {
|
|
782
|
+
resolvedExt = `json.${configuredExt}`;
|
|
817
783
|
}
|
|
818
784
|
}
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
785
|
+
const context = {
|
|
786
|
+
type,
|
|
787
|
+
fileType,
|
|
788
|
+
fileName,
|
|
789
|
+
outDir,
|
|
790
|
+
extension: resolvedExt,
|
|
791
|
+
cwd,
|
|
792
|
+
defaultCode
|
|
822
793
|
};
|
|
823
|
-
|
|
794
|
+
const template = resolveTemplate(templates, type, fileType);
|
|
795
|
+
const customCode = await loadTemplate(template, context);
|
|
796
|
+
const finalCode = _nullishCoalesce(customCode, () => ( defaultCode));
|
|
797
|
+
if (finalCode !== void 0) {
|
|
798
|
+
files.push({
|
|
799
|
+
fileName: `${fileName}${resolveExtension(resolvedExt)}`,
|
|
800
|
+
code: finalCode
|
|
801
|
+
});
|
|
802
|
+
}
|
|
803
|
+
}
|
|
824
804
|
for (const { code, fileName: fileName2 } of files) {
|
|
825
805
|
if (code !== void 0) {
|
|
826
806
|
await _fsextra2.default.outputFile(_pathe2.default.resolve(basepath, fileName2), code, "utf8");
|
|
827
|
-
|
|
807
|
+
_chunkY6PWETW7cjs.logger_default.success(`${composePath(outDir, fileName2)} \u521B\u5EFA\u6210\u529F\uFF01`);
|
|
828
808
|
}
|
|
829
809
|
}
|
|
830
810
|
}
|
|
831
|
-
|
|
811
|
+
function resolveTemplate(templates, type, fileType) {
|
|
812
|
+
const scoped = _optionalChain([templates, 'optionalAccess', _2 => _2[type], 'optionalAccess', _3 => _3[fileType]]);
|
|
813
|
+
if (scoped !== void 0) {
|
|
814
|
+
return scoped;
|
|
815
|
+
}
|
|
816
|
+
return _optionalChain([templates, 'optionalAccess', _4 => _4.shared, 'optionalAccess', _5 => _5[fileType]]);
|
|
817
|
+
}
|
|
818
|
+
async function loadTemplate(template, context) {
|
|
819
|
+
if (template === void 0) {
|
|
820
|
+
return void 0;
|
|
821
|
+
}
|
|
822
|
+
if (typeof template === "function") {
|
|
823
|
+
const result = await template(context);
|
|
824
|
+
return result == null ? void 0 : String(result);
|
|
825
|
+
}
|
|
826
|
+
if (typeof template === "string") {
|
|
827
|
+
return readTemplateFile(template, context);
|
|
828
|
+
}
|
|
829
|
+
if ("content" in template && typeof template.content === "string") {
|
|
830
|
+
return template.content;
|
|
831
|
+
}
|
|
832
|
+
if ("path" in template && typeof template.path === "string") {
|
|
833
|
+
return readTemplateFile(template.path, context);
|
|
834
|
+
}
|
|
835
|
+
return void 0;
|
|
836
|
+
}
|
|
837
|
+
async function readTemplateFile(templatePath, context) {
|
|
838
|
+
const absolutePath = _pathe2.default.isAbsolute(templatePath) ? templatePath : _pathe2.default.resolve(context.cwd, templatePath);
|
|
839
|
+
return _fsextra2.default.readFile(absolutePath, "utf8");
|
|
840
|
+
}
|
|
832
841
|
|
|
833
842
|
// src/cli.ts
|
|
834
|
-
var import_reflect_metadata = _chunkPGL7ZN2Wcjs.__toESM.call(void 0, _chunkTBCCIJBLcjs.require_Reflect.call(void 0, ), 1);
|
|
835
843
|
var cli = cac("weapp-vite");
|
|
836
844
|
try {
|
|
837
|
-
|
|
845
|
+
_chunkY6PWETW7cjs.checkRuntime.call(void 0, {
|
|
838
846
|
bun: "0.0.0",
|
|
839
847
|
deno: "0.0.0",
|
|
840
848
|
node: "20.19.0"
|
|
@@ -847,27 +855,24 @@ function loadConfig(configFile) {
|
|
|
847
855
|
mode: "development"
|
|
848
856
|
}, configFile, _process2.default.cwd());
|
|
849
857
|
}
|
|
850
|
-
_chunkPGL7ZN2Wcjs.__name.call(void 0, loadConfig, "loadConfig");
|
|
851
858
|
var logBuildAppFinishOnlyShowOnce = false;
|
|
852
859
|
function logBuildAppFinish(configService) {
|
|
853
860
|
if (!logBuildAppFinishOnlyShowOnce) {
|
|
854
|
-
const { command, args } = _nullishCoalesce(resolveCommand(
|
|
855
|
-
|
|
856
|
-
|
|
861
|
+
const { command, args } = _nullishCoalesce(resolveCommand(
|
|
862
|
+
configService.packageManager.agent,
|
|
863
|
+
"run",
|
|
864
|
+
["open"]
|
|
865
|
+
), () => ( {
|
|
857
866
|
command: "npm",
|
|
858
|
-
args: [
|
|
859
|
-
"run",
|
|
860
|
-
"open"
|
|
861
|
-
]
|
|
867
|
+
args: ["run", "open"]
|
|
862
868
|
}));
|
|
863
869
|
const devCommand = `${command} ${args.join(" ")}`;
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
870
|
+
_chunkY6PWETW7cjs.logger_default.success("\u5E94\u7528\u6784\u5EFA\u5B8C\u6210\uFF01\u9884\u89C8\u65B9\u5F0F ( `2` \u79CD\u9009\u5176\u4E00\u5373\u53EF)\uFF1A");
|
|
871
|
+
_chunkY6PWETW7cjs.logger_default.info(`\u6267\u884C \`${devCommand}\` \u53EF\u4EE5\u76F4\u63A5\u5728 \`\u5FAE\u4FE1\u5F00\u53D1\u8005\u5DE5\u5177\` \u91CC\u6253\u5F00\u5F53\u524D\u5E94\u7528`);
|
|
872
|
+
_chunkY6PWETW7cjs.logger_default.info("\u6216\u624B\u52A8\u6253\u5F00\u5FAE\u4FE1\u5F00\u53D1\u8005\u5DE5\u5177\uFF0C\u5BFC\u5165\u6839\u76EE\u5F55(`project.config.json` \u6587\u4EF6\u6240\u5728\u7684\u76EE\u5F55)\uFF0C\u5373\u53EF\u9884\u89C8\u6548\u679C");
|
|
867
873
|
logBuildAppFinishOnlyShowOnce = true;
|
|
868
874
|
}
|
|
869
875
|
}
|
|
870
|
-
_chunkPGL7ZN2Wcjs.__name.call(void 0, logBuildAppFinish, "logBuildAppFinish");
|
|
871
876
|
function filterDuplicateOptions(options) {
|
|
872
877
|
for (const [key, value] of Object.entries(options)) {
|
|
873
878
|
if (Array.isArray(value)) {
|
|
@@ -875,7 +880,6 @@ function filterDuplicateOptions(options) {
|
|
|
875
880
|
}
|
|
876
881
|
}
|
|
877
882
|
}
|
|
878
|
-
_chunkPGL7ZN2Wcjs.__name.call(void 0, filterDuplicateOptions, "filterDuplicateOptions");
|
|
879
883
|
function resolveConfigFile(options) {
|
|
880
884
|
if (typeof options.config === "string") {
|
|
881
885
|
return options.config;
|
|
@@ -884,34 +888,26 @@ function resolveConfigFile(options) {
|
|
|
884
888
|
return options.c;
|
|
885
889
|
}
|
|
886
890
|
}
|
|
887
|
-
_chunkPGL7ZN2Wcjs.__name.call(void 0, resolveConfigFile, "resolveConfigFile");
|
|
888
891
|
function convertBase(v) {
|
|
889
892
|
if (v === 0) {
|
|
890
893
|
return "";
|
|
891
894
|
}
|
|
892
895
|
return v;
|
|
893
896
|
}
|
|
894
|
-
_chunkPGL7ZN2Wcjs.__name.call(void 0, convertBase, "convertBase");
|
|
895
897
|
async function openIde() {
|
|
896
898
|
try {
|
|
897
|
-
await _weappidecli.parse.call(void 0, [
|
|
898
|
-
"open",
|
|
899
|
-
"-p"
|
|
900
|
-
]);
|
|
899
|
+
await _weappidecli.parse.call(void 0, ["open", "-p"]);
|
|
901
900
|
} catch (error) {
|
|
902
|
-
|
|
901
|
+
_chunkY6PWETW7cjs.logger_default.error(error);
|
|
903
902
|
}
|
|
904
903
|
}
|
|
905
|
-
_chunkPGL7ZN2Wcjs.__name.call(void 0, openIde, "openIde");
|
|
906
904
|
cli.option("-c, --config <file>", `[string] use specified config file`).option("--base <path>", `[string] public base path (default: /)`, {
|
|
907
|
-
type: [
|
|
908
|
-
convertBase
|
|
909
|
-
]
|
|
905
|
+
type: [convertBase]
|
|
910
906
|
}).option("-l, --logLevel <level>", `[string] info | warn | error | silent`).option("--clearScreen", `[boolean] allow/disable clear screen when logging`).option("-d, --debug [feat]", `[string | boolean] show debug logs`).option("-f, --filter <filter>", `[string] filter debug logs`).option("-m, --mode <mode>", `[string] set env mode`);
|
|
911
907
|
cli.command("[root]", "start dev server").alias("serve").alias("dev").option("--skipNpm", `[boolean] if skip npm build`).option("-o, --open", `[boolean] open ide`).action(async (root, options) => {
|
|
912
908
|
filterDuplicateOptions(options);
|
|
913
909
|
const configFile = resolveConfigFile(options);
|
|
914
|
-
const { buildService, configService } = await
|
|
910
|
+
const { buildService, configService } = await _chunkY6PWETW7cjs.createCompilerContext.call(void 0, {
|
|
915
911
|
cwd: root,
|
|
916
912
|
mode: _nullishCoalesce(options.mode, () => ( "development")),
|
|
917
913
|
isDev: true,
|
|
@@ -923,10 +919,19 @@ cli.command("[root]", "start dev server").alias("serve").alias("dev").option("--
|
|
|
923
919
|
await openIde();
|
|
924
920
|
}
|
|
925
921
|
});
|
|
926
|
-
cli.command("build [root]", "build for production").option("--target <target>", `[string] transpile target (default: 'modules')`).option("--outDir <dir>", `[string] output directory (default: dist)`).option(
|
|
922
|
+
cli.command("build [root]", "build for production").option("--target <target>", `[string] transpile target (default: 'modules')`).option("--outDir <dir>", `[string] output directory (default: dist)`).option(
|
|
923
|
+
"--sourcemap [output]",
|
|
924
|
+
`[boolean | "inline" | "hidden"] output source maps for build (default: false)`
|
|
925
|
+
).option(
|
|
926
|
+
"--minify [minifier]",
|
|
927
|
+
`[boolean | "terser" | "esbuild"] enable/disable minification, or specify minifier to use (default: esbuild)`
|
|
928
|
+
).option(
|
|
929
|
+
"--emptyOutDir",
|
|
930
|
+
`[boolean] force empty outDir when it's outside of root`
|
|
931
|
+
).option("-w, --watch", `[boolean] rebuilds when modules have changed on disk`).option("--skipNpm", `[boolean] if skip npm build`).option("-o, --open", `[boolean] open ide`).action(async (root, options) => {
|
|
927
932
|
filterDuplicateOptions(options);
|
|
928
933
|
const configFile = resolveConfigFile(options);
|
|
929
|
-
const { buildService, configService } = await
|
|
934
|
+
const { buildService, configService } = await _chunkY6PWETW7cjs.createCompilerContext.call(void 0, {
|
|
930
935
|
cwd: root,
|
|
931
936
|
mode: _nullishCoalesce(options.mode, () => ( "production")),
|
|
932
937
|
configFile
|
|
@@ -943,7 +948,7 @@ cli.command("init").action(async () => {
|
|
|
943
948
|
command: "weapp-vite"
|
|
944
949
|
});
|
|
945
950
|
} catch (error) {
|
|
946
|
-
|
|
951
|
+
_chunkY6PWETW7cjs.logger_default.error(error);
|
|
947
952
|
}
|
|
948
953
|
});
|
|
949
954
|
cli.command("open").action(async () => {
|
|
@@ -951,12 +956,9 @@ cli.command("open").action(async () => {
|
|
|
951
956
|
});
|
|
952
957
|
cli.command("npm").alias("build:npm").alias("build-npm").action(async () => {
|
|
953
958
|
try {
|
|
954
|
-
await _weappidecli.parse.call(void 0, [
|
|
955
|
-
"build-npm",
|
|
956
|
-
"-p"
|
|
957
|
-
]);
|
|
959
|
+
await _weappidecli.parse.call(void 0, ["build-npm", "-p"]);
|
|
958
960
|
} catch (error) {
|
|
959
|
-
|
|
961
|
+
_chunkY6PWETW7cjs.logger_default.error(error);
|
|
960
962
|
}
|
|
961
963
|
});
|
|
962
964
|
cli.command("g [filepath]", "generate component").alias("generate").option("-a, --app", "type app").option("-p, --page", "type app").option("-n, --name <name>", "filename").action(async (filepath, options) => {
|
|
@@ -971,24 +973,25 @@ cli.command("g [filepath]", "generate component").alias("generate").option("-a,
|
|
|
971
973
|
fileName = "app";
|
|
972
974
|
}
|
|
973
975
|
if (filepath === void 0) {
|
|
974
|
-
|
|
976
|
+
_chunkY6PWETW7cjs.logger_default.error("weapp-vite generate <outDir> \u547D\u4EE4\u5FC5\u987B\u4F20\u5165\u8DEF\u5F84\u53C2\u6570 outDir");
|
|
975
977
|
return;
|
|
976
978
|
}
|
|
977
979
|
if (options.page) {
|
|
978
980
|
type = "page";
|
|
979
981
|
}
|
|
980
|
-
const generateOptions = _optionalChain([config, 'optionalAccess',
|
|
981
|
-
fileName = _nullishCoalesce(_optionalChain([generateOptions, 'optionalAccess',
|
|
982
|
+
const generateOptions = _optionalChain([config, 'optionalAccess', _6 => _6.config, 'access', _7 => _7.weapp, 'optionalAccess', _8 => _8.generate]);
|
|
983
|
+
fileName = _nullishCoalesce(_optionalChain([generateOptions, 'optionalAccess', _9 => _9.filenames, 'optionalAccess', _10 => _10[type]]), () => ( fileName));
|
|
982
984
|
await generate({
|
|
983
|
-
outDir: _pathe2.default.join(_nullishCoalesce(_optionalChain([generateOptions, 'optionalAccess',
|
|
985
|
+
outDir: _pathe2.default.join(_nullishCoalesce(_optionalChain([generateOptions, 'optionalAccess', _11 => _11.dirs, 'optionalAccess', _12 => _12[type]]), () => ( "")), filepath),
|
|
984
986
|
type,
|
|
985
987
|
fileName,
|
|
986
|
-
extensions: _optionalChain([generateOptions, 'optionalAccess',
|
|
988
|
+
extensions: _optionalChain([generateOptions, 'optionalAccess', _13 => _13.extensions]),
|
|
989
|
+
templates: _optionalChain([generateOptions, 'optionalAccess', _14 => _14.templates])
|
|
987
990
|
});
|
|
988
991
|
});
|
|
989
992
|
cli.command("create [outDir]", "create project").option("-t, --template <type>", "template type").action(async (outDir, options) => {
|
|
990
993
|
await _init.createProject.call(void 0, outDir, options.template);
|
|
991
994
|
});
|
|
992
995
|
cli.help();
|
|
993
|
-
cli.version(
|
|
996
|
+
cli.version(_chunkY6PWETW7cjs.VERSION);
|
|
994
997
|
cli.parse();
|