weapp-ide-cli 3.1.0 → 4.0.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/README.md +84 -31
- package/dist/chunk-FJJOQAVP.js +302 -0
- package/dist/cli.cjs +236 -171
- package/dist/cli.js +1 -1
- package/dist/index.cjs +253 -174
- package/dist/index.d.cts +40 -7
- package/dist/index.d.ts +40 -7
- package/dist/index.js +19 -5
- package/package.json +2 -2
- package/dist/chunk-WCSD523G.js +0 -236
package/dist/cli.cjs
CHANGED
|
@@ -23,51 +23,163 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
23
23
|
));
|
|
24
24
|
|
|
25
25
|
// src/cli.ts
|
|
26
|
-
var
|
|
26
|
+
var import_node_process6 = __toESM(require("process"), 1);
|
|
27
27
|
|
|
28
|
-
// src/
|
|
29
|
-
var
|
|
30
|
-
var
|
|
28
|
+
// src/cli/prompt.ts
|
|
29
|
+
var import_node_process2 = require("process");
|
|
30
|
+
var import_promises = require("readline/promises");
|
|
31
|
+
var import_fs_extra2 = __toESM(require("fs-extra"), 1);
|
|
31
32
|
|
|
32
|
-
// src/
|
|
33
|
-
var
|
|
34
|
-
var import_node_readline = __toESM(require("readline"), 1);
|
|
35
|
-
var import_fs_extra3 = __toESM(require("fs-extra"), 1);
|
|
33
|
+
// src/config/custom.ts
|
|
34
|
+
var import_fs_extra = __toESM(require("fs-extra"), 1);
|
|
36
35
|
|
|
37
|
-
// src/
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
// src/utils/path.ts
|
|
37
|
+
var import_node_process = __toESM(require("process"), 1);
|
|
38
|
+
var import_pathe = __toESM(require("pathe"), 1);
|
|
39
|
+
function resolvePath(filePath) {
|
|
40
|
+
if (import_pathe.default.isAbsolute(filePath)) {
|
|
41
|
+
return filePath;
|
|
41
42
|
}
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
return import_pathe.default.resolve(import_node_process.default.cwd(), filePath);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// src/config/paths.ts
|
|
47
|
+
var import_node_os = __toESM(require("os"), 1);
|
|
48
|
+
var import_pathe2 = __toESM(require("pathe"), 1);
|
|
49
|
+
var homedir = import_node_os.default.homedir();
|
|
50
|
+
var defaultCustomConfigDirPath = import_pathe2.default.join(homedir, ".weapp-ide-cli");
|
|
51
|
+
var defaultCustomConfigFilePath = import_pathe2.default.join(
|
|
52
|
+
defaultCustomConfigDirPath,
|
|
53
|
+
"config.json"
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
// src/config/custom.ts
|
|
57
|
+
var JSON_OPTIONS = {
|
|
58
|
+
encoding: "utf8",
|
|
59
|
+
spaces: 2
|
|
60
|
+
};
|
|
61
|
+
async function createCustomConfig(params) {
|
|
62
|
+
const trimmedCliPath = params.cliPath.trim();
|
|
63
|
+
if (!trimmedCliPath) {
|
|
64
|
+
throw new Error("cliPath cannot be empty");
|
|
44
65
|
}
|
|
45
|
-
|
|
46
|
-
|
|
66
|
+
const normalizedCliPath = resolvePath(trimmedCliPath);
|
|
67
|
+
await import_fs_extra.default.ensureDir(defaultCustomConfigDirPath);
|
|
68
|
+
await import_fs_extra.default.writeJSON(
|
|
69
|
+
defaultCustomConfigFilePath,
|
|
70
|
+
{
|
|
71
|
+
cliPath: normalizedCliPath
|
|
72
|
+
},
|
|
73
|
+
JSON_OPTIONS
|
|
47
74
|
);
|
|
75
|
+
return normalizedCliPath;
|
|
48
76
|
}
|
|
49
77
|
|
|
50
|
-
// src/
|
|
51
|
-
var
|
|
78
|
+
// src/logger.ts
|
|
79
|
+
var import_logger = __toESM(require("@weapp-core/logger"), 1);
|
|
80
|
+
var logger_default = import_logger.default;
|
|
52
81
|
|
|
53
|
-
// src/
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
82
|
+
// src/cli/prompt.ts
|
|
83
|
+
async function promptForCliPath() {
|
|
84
|
+
const rl = (0, import_promises.createInterface)({ input: import_node_process2.stdin, output: import_node_process2.stdout });
|
|
85
|
+
try {
|
|
86
|
+
logger_default.log("\u8BF7\u8BBE\u7F6E\u5FAE\u4FE1web\u5F00\u53D1\u8005\u5DE5\u5177 CLI \u7684\u8DEF\u5F84");
|
|
87
|
+
logger_default.log("> \u63D0\u793A\uFF1A\u547D\u4EE4\u884C\u5DE5\u5177\u9ED8\u8BA4\u6240\u5728\u4F4D\u7F6E\uFF1A");
|
|
88
|
+
logger_default.log("- MacOS: <\u5B89\u88C5\u8DEF\u5F84>/Contents/MacOS/cli");
|
|
89
|
+
logger_default.log("- Windows: <\u5B89\u88C5\u8DEF\u5F84>/cli.bat");
|
|
90
|
+
logger_default.log("- Linux: <\u5B89\u88C5\u8DEF\u5F84>/files/bin/bin/wechat-devtools-cli");
|
|
91
|
+
const cliPath = (await rl.question("\u8BF7\u8F93\u5165\u5FAE\u4FE1web\u5F00\u53D1\u8005\u5DE5\u5177 CLI \u8DEF\u5F84\uFF1A")).trim();
|
|
92
|
+
if (!cliPath) {
|
|
93
|
+
logger_default.error("\u8DEF\u5F84\u4E0D\u80FD\u4E3A\u7A7A\uFF0C\u5DF2\u53D6\u6D88\u672C\u6B21\u914D\u7F6E\u3002");
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
try {
|
|
97
|
+
const normalizedPath = await createCustomConfig({ cliPath });
|
|
98
|
+
logger_default.log(`\u5168\u5C40\u914D\u7F6E\u5B58\u50A8\u4F4D\u7F6E\uFF1A${defaultCustomConfigFilePath}`);
|
|
99
|
+
if (!await import_fs_extra2.default.pathExists(normalizedPath)) {
|
|
100
|
+
logger_default.warn("\u5728\u5F53\u524D\u8DEF\u5F84\u672A\u627E\u5230\u5FAE\u4FE1web\u5F00\u53D1\u8005\u547D\u4EE4\u884C\u5DE5\u5177\uFF0C\u8BF7\u786E\u8BA4\u8DEF\u5F84\u662F\u5426\u6B63\u786E\u3002");
|
|
101
|
+
}
|
|
102
|
+
return normalizedPath;
|
|
103
|
+
} catch (error) {
|
|
104
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
105
|
+
logger_default.error(`\u4FDD\u5B58\u914D\u7F6E\u5931\u8D25\uFF1A${reason}`);
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
} finally {
|
|
109
|
+
rl.close();
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// src/cli/resolver.ts
|
|
114
|
+
var import_fs_extra5 = __toESM(require("fs-extra"), 1);
|
|
115
|
+
|
|
116
|
+
// src/config/resolver.ts
|
|
117
|
+
var import_fs_extra4 = __toESM(require("fs-extra"), 1);
|
|
118
|
+
|
|
119
|
+
// src/runtime/platform.ts
|
|
120
|
+
var import_node_os2 = __toESM(require("os"), 1);
|
|
121
|
+
var import_node_process3 = __toESM(require("process"), 1);
|
|
122
|
+
var import_fs_extra3 = __toESM(require("fs-extra"), 1);
|
|
123
|
+
var import_pathe3 = __toESM(require("pathe"), 1);
|
|
59
124
|
var SupportedPlatformsMap = {
|
|
60
125
|
Windows_NT: "Windows_NT",
|
|
61
126
|
Darwin: "Darwin",
|
|
62
127
|
Linux: "Linux"
|
|
63
128
|
};
|
|
129
|
+
function isOperatingSystemSupported(osName = import_node_os2.default.type()) {
|
|
130
|
+
return osName === SupportedPlatformsMap.Windows_NT || osName === SupportedPlatformsMap.Darwin || osName === SupportedPlatformsMap.Linux;
|
|
131
|
+
}
|
|
132
|
+
var operatingSystemName = import_node_os2.default.type();
|
|
133
|
+
function createLinuxCliResolver() {
|
|
134
|
+
let resolvedPath;
|
|
135
|
+
let attempted = false;
|
|
136
|
+
let pending = null;
|
|
137
|
+
return async () => {
|
|
138
|
+
if (attempted) {
|
|
139
|
+
return resolvedPath;
|
|
140
|
+
}
|
|
141
|
+
if (!pending) {
|
|
142
|
+
pending = (async () => {
|
|
143
|
+
try {
|
|
144
|
+
const envPath = await getFirstBinaryPath("wechat-devtools-cli");
|
|
145
|
+
if (envPath) {
|
|
146
|
+
resolvedPath = envPath;
|
|
147
|
+
}
|
|
148
|
+
} catch (error) {
|
|
149
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
150
|
+
logger_default.warn(`\u83B7\u53D6 Linux wechat-devtools-cli \u8DEF\u5F84\u5931\u8D25\uFF1A${reason}`);
|
|
151
|
+
} finally {
|
|
152
|
+
attempted = true;
|
|
153
|
+
}
|
|
154
|
+
return resolvedPath;
|
|
155
|
+
})();
|
|
156
|
+
}
|
|
157
|
+
return pending;
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
var linuxCliResolver = createLinuxCliResolver();
|
|
161
|
+
var WINDOWS_DEFAULT_CLI = "C:\\Program Files (x86)\\Tencent\\\u5FAE\u4FE1web\u5F00\u53D1\u8005\u5DE5\u5177\\cli.bat";
|
|
162
|
+
var DARWIN_DEFAULT_CLI = "/Applications/wechatwebdevtools.app/Contents/MacOS/cli";
|
|
163
|
+
var cliPathResolvers = {
|
|
164
|
+
[SupportedPlatformsMap.Windows_NT]: async () => WINDOWS_DEFAULT_CLI,
|
|
165
|
+
[SupportedPlatformsMap.Darwin]: async () => DARWIN_DEFAULT_CLI,
|
|
166
|
+
[SupportedPlatformsMap.Linux]: linuxCliResolver
|
|
167
|
+
};
|
|
168
|
+
async function getDefaultCliPath(targetOs = operatingSystemName) {
|
|
169
|
+
if (!isOperatingSystemSupported(targetOs)) {
|
|
170
|
+
return void 0;
|
|
171
|
+
}
|
|
172
|
+
const resolver = cliPathResolvers[targetOs];
|
|
173
|
+
const resolvedPath = await resolver();
|
|
174
|
+
return resolvedPath;
|
|
175
|
+
}
|
|
64
176
|
async function getFirstBinaryPath(command) {
|
|
65
|
-
const envPath =
|
|
66
|
-
const pathDirs = envPath.split(
|
|
177
|
+
const envPath = import_node_process3.default.env.PATH || "";
|
|
178
|
+
const pathDirs = envPath.split(import_pathe3.default.delimiter);
|
|
67
179
|
for (const dir of pathDirs) {
|
|
68
|
-
const fullPath =
|
|
180
|
+
const fullPath = import_pathe3.default.join(dir, command);
|
|
69
181
|
try {
|
|
70
|
-
await
|
|
182
|
+
await import_fs_extra3.default.access(fullPath, import_fs_extra3.default.constants.X_OK);
|
|
71
183
|
return fullPath;
|
|
72
184
|
} catch {
|
|
73
185
|
continue;
|
|
@@ -75,151 +187,107 @@ async function getFirstBinaryPath(command) {
|
|
|
75
187
|
}
|
|
76
188
|
return void 0;
|
|
77
189
|
}
|
|
78
|
-
var operatingSystemName = import_node_os.default.type();
|
|
79
|
-
var defaultPathMap = {
|
|
80
|
-
[SupportedPlatformsMap.Windows_NT]: "C:\\Program Files (x86)\\Tencent\\\u5FAE\u4FE1web\u5F00\u53D1\u8005\u5DE5\u5177\\cli.bat",
|
|
81
|
-
[SupportedPlatformsMap.Darwin]: "/Applications/wechatwebdevtools.app/Contents/MacOS/cli"
|
|
82
|
-
};
|
|
83
|
-
var linuxPathInitialized = false;
|
|
84
|
-
async function getLinuxDevToolsPath() {
|
|
85
|
-
if (operatingSystemName !== SupportedPlatformsMap.Linux && linuxPathInitialized) {
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
try {
|
|
89
|
-
const linuxDevCliPath = await getFirstBinaryPath("wechat-devtools-cli");
|
|
90
|
-
if (linuxDevCliPath) {
|
|
91
|
-
linuxPathInitialized = true;
|
|
92
|
-
defaultPathMap[SupportedPlatformsMap.Linux] = linuxDevCliPath;
|
|
93
|
-
}
|
|
94
|
-
} catch (error) {
|
|
95
|
-
if (error instanceof Error) {
|
|
96
|
-
logger_default.error("\u83B7\u53D6Linux\u5F00\u53D1\u5DE5\u5177 wechat-devtools-cli \u8DEF\u5F84\u5931\u8D25:", error.message);
|
|
97
|
-
} else {
|
|
98
|
-
logger_default.error("\u83B7\u53D6Linux\u5F00\u53D1\u5DE5\u5177 wechat-devtools-cli \u8DEF\u5F84\u5931\u8D25:", error);
|
|
99
|
-
}
|
|
100
|
-
return defaultPathMap[SupportedPlatformsMap.Linux];
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
async function getDefaultPath() {
|
|
104
|
-
await getLinuxDevToolsPath();
|
|
105
|
-
return defaultPathMap[operatingSystemName];
|
|
106
|
-
}
|
|
107
|
-
var defaultCustomConfigDirPath = import_pathe.default.join(homedir, ".weapp-ide-cli");
|
|
108
|
-
var defaultCustomConfigFilePath = import_pathe.default.join(
|
|
109
|
-
defaultCustomConfigDirPath,
|
|
110
|
-
"config.json"
|
|
111
|
-
);
|
|
112
190
|
|
|
113
|
-
// src/config.ts
|
|
114
|
-
function createCustomConfig(params) {
|
|
115
|
-
return import_fs_extra2.default.outputJSON(
|
|
116
|
-
defaultCustomConfigFilePath,
|
|
117
|
-
{
|
|
118
|
-
cliPath: params.cliPath
|
|
119
|
-
},
|
|
120
|
-
{
|
|
121
|
-
encoding: "utf8",
|
|
122
|
-
spaces: 2
|
|
123
|
-
}
|
|
124
|
-
);
|
|
125
|
-
}
|
|
191
|
+
// src/config/resolver.ts
|
|
126
192
|
async function getConfig() {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
193
|
+
if (await import_fs_extra4.default.pathExists(defaultCustomConfigFilePath)) {
|
|
194
|
+
try {
|
|
195
|
+
const config = await import_fs_extra4.default.readJSON(defaultCustomConfigFilePath);
|
|
196
|
+
const cliPath = typeof config.cliPath === "string" ? config.cliPath.trim() : "";
|
|
197
|
+
if (cliPath) {
|
|
198
|
+
logger_default.log("> \u5168\u5C40\u914D\u7F6E\u6587\u4EF6\u8DEF\u5F84\uFF1A", defaultCustomConfigFilePath);
|
|
199
|
+
logger_default.log("> \u81EA\u5B9A\u4E49 CLI \u8DEF\u5F84\uFF1A", cliPath);
|
|
200
|
+
return {
|
|
201
|
+
cliPath,
|
|
202
|
+
source: "custom"
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
logger_default.warn("\u81EA\u5B9A\u4E49\u914D\u7F6E\u6587\u4EF6\u7F3A\u5C11\u6709\u6548\u7684 CLI \u8DEF\u5F84\uFF0C\u5C06\u5C1D\u8BD5\u4F7F\u7528\u9ED8\u8BA4\u8DEF\u5F84\u3002");
|
|
206
|
+
} catch (error) {
|
|
207
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
208
|
+
logger_default.warn(`\u89E3\u6790\u81EA\u5B9A\u4E49\u914D\u7F6E\u5931\u8D25\uFF0C\u5C06\u5C1D\u8BD5\u4F7F\u7528\u9ED8\u8BA4\u8DEF\u5F84\u3002\u539F\u56E0\uFF1A${reason}`);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
const fallbackPath = await getDefaultCliPath();
|
|
212
|
+
if (fallbackPath) {
|
|
137
213
|
return {
|
|
138
|
-
cliPath:
|
|
214
|
+
cliPath: fallbackPath,
|
|
215
|
+
source: "default"
|
|
139
216
|
};
|
|
140
217
|
}
|
|
218
|
+
return {
|
|
219
|
+
cliPath: "",
|
|
220
|
+
source: "missing"
|
|
221
|
+
};
|
|
141
222
|
}
|
|
142
223
|
|
|
143
|
-
// src/
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
const task = execa(cliPath, argv2);
|
|
149
|
-
task?.stdout?.pipe(import_node_process2.default.stdout);
|
|
150
|
-
await task;
|
|
151
|
-
}
|
|
152
|
-
function resolvePath(filePath) {
|
|
153
|
-
if (import_pathe2.default.isAbsolute(filePath)) {
|
|
154
|
-
return filePath;
|
|
155
|
-
} else {
|
|
156
|
-
return import_pathe2.default.resolve(import_node_process2.default.cwd(), filePath);
|
|
224
|
+
// src/cli/resolver.ts
|
|
225
|
+
async function resolveCliPath() {
|
|
226
|
+
const config = await getConfig();
|
|
227
|
+
if (!config.cliPath) {
|
|
228
|
+
return { cliPath: null, source: config.source };
|
|
157
229
|
}
|
|
230
|
+
const exists = await import_fs_extra5.default.pathExists(config.cliPath);
|
|
231
|
+
return {
|
|
232
|
+
cliPath: exists ? config.cliPath : null,
|
|
233
|
+
source: config.source
|
|
234
|
+
};
|
|
158
235
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
236
|
+
|
|
237
|
+
// src/utils/argv.ts
|
|
238
|
+
var import_node_process4 = __toESM(require("process"), 1);
|
|
239
|
+
function ensurePathArgument(argv2, optionIndex) {
|
|
240
|
+
const paramIdx = optionIndex + 1;
|
|
241
|
+
const param = argv2[paramIdx];
|
|
242
|
+
if (param && !param.startsWith("-")) {
|
|
243
|
+
argv2[paramIdx] = resolvePath(param);
|
|
163
244
|
} else {
|
|
164
|
-
|
|
165
|
-
}
|
|
166
|
-
if (findIdx > -1) {
|
|
167
|
-
const paramIdx = findIdx + 1;
|
|
168
|
-
const param = argv2[paramIdx];
|
|
169
|
-
if (param && param[0] !== "-") {
|
|
170
|
-
argv2[paramIdx] = resolvePath(param);
|
|
171
|
-
} else {
|
|
172
|
-
argv2.splice(paramIdx, 0, import_node_process2.default.cwd());
|
|
173
|
-
}
|
|
245
|
+
argv2.splice(paramIdx, 0, import_node_process4.default.cwd());
|
|
174
246
|
}
|
|
175
247
|
return argv2;
|
|
176
248
|
}
|
|
177
|
-
function
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
const param = argv2[paramIdx];
|
|
182
|
-
if (param && param[0] !== "-") {
|
|
183
|
-
argv2[paramIdx] = resolvePath(param);
|
|
184
|
-
} else {
|
|
185
|
-
argv2.splice(paramIdx, 0, import_node_process2.default.cwd());
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
return argv2;
|
|
249
|
+
function transformArgv(argv2, transforms) {
|
|
250
|
+
return transforms.reduce((current, transform) => transform(current), [
|
|
251
|
+
...argv2
|
|
252
|
+
]);
|
|
189
253
|
}
|
|
190
254
|
function createAlias(entry) {
|
|
191
|
-
return
|
|
192
|
-
|
|
255
|
+
return (input2) => {
|
|
256
|
+
const argv2 = [...input2];
|
|
257
|
+
let optionIndex = argv2.indexOf(entry.find);
|
|
258
|
+
if (optionIndex > -1) {
|
|
259
|
+
argv2.splice(optionIndex, 1, entry.replacement);
|
|
260
|
+
} else {
|
|
261
|
+
optionIndex = argv2.indexOf(entry.replacement);
|
|
262
|
+
}
|
|
263
|
+
if (optionIndex === -1) {
|
|
264
|
+
return argv2;
|
|
265
|
+
}
|
|
266
|
+
return ensurePathArgument(argv2, optionIndex);
|
|
193
267
|
};
|
|
194
268
|
}
|
|
195
269
|
function createPathCompat(option) {
|
|
196
|
-
return
|
|
197
|
-
|
|
270
|
+
return (input2) => {
|
|
271
|
+
const argv2 = [...input2];
|
|
272
|
+
const optionIndex = argv2.indexOf(option);
|
|
273
|
+
if (optionIndex === -1) {
|
|
274
|
+
return argv2;
|
|
275
|
+
}
|
|
276
|
+
return ensurePathArgument(argv2, optionIndex);
|
|
198
277
|
};
|
|
199
278
|
}
|
|
200
279
|
|
|
201
|
-
// src/
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
logger_default.log("> \u63D0\u793A\uFF1A\u547D\u4EE4\u884C\u5DE5\u5177\u9ED8\u8BA4\u6240\u5728\u4F4D\u7F6E\uFF1A");
|
|
209
|
-
logger_default.log("- MacOS: <\u5B89\u88C5\u8DEF\u5F84>/Contents/MacOS/cli");
|
|
210
|
-
logger_default.log("- Windows: <\u5B89\u88C5\u8DEF\u5F84>/cli.bat");
|
|
211
|
-
logger_default.log("- Linux: <\u5B89\u88C5\u8DEF\u5F84>/files/bin/bin/wechat-devtools-cli");
|
|
212
|
-
return new Promise((resolve, _reject) => {
|
|
213
|
-
rl.question("\u8BF7\u8F93\u5165\u5FAE\u4FE1web\u5F00\u53D1\u8005\u5DE5\u5177cli\u8DEF\u5F84\uFF1A", async (cliPath) => {
|
|
214
|
-
await createCustomConfig({
|
|
215
|
-
cliPath
|
|
216
|
-
});
|
|
217
|
-
logger_default.log(`\u5168\u5C40\u914D\u7F6E\u5B58\u50A8\u4F4D\u7F6E\uFF1A${defaultCustomConfigFilePath}`);
|
|
218
|
-
resolve(cliPath);
|
|
219
|
-
});
|
|
220
|
-
});
|
|
280
|
+
// src/utils/exec.ts
|
|
281
|
+
var import_node_process5 = __toESM(require("process"), 1);
|
|
282
|
+
async function execute(cliPath, argv2) {
|
|
283
|
+
const { execa } = await import("execa");
|
|
284
|
+
const task = execa(cliPath, argv2);
|
|
285
|
+
task?.stdout?.pipe(import_node_process5.default.stdout);
|
|
286
|
+
await task;
|
|
221
287
|
}
|
|
222
|
-
|
|
288
|
+
|
|
289
|
+
// src/cli/run.ts
|
|
290
|
+
var ARG_TRANSFORMS = [
|
|
223
291
|
createAlias({ find: "-p", replacement: "--project" }),
|
|
224
292
|
createPathCompat("--result-output"),
|
|
225
293
|
createPathCompat("-r"),
|
|
@@ -227,32 +295,29 @@ var parseArgv = compose(
|
|
|
227
295
|
createPathCompat("-o"),
|
|
228
296
|
createPathCompat("--info-output"),
|
|
229
297
|
createPathCompat("-i")
|
|
230
|
-
|
|
298
|
+
];
|
|
231
299
|
async function parse(argv2) {
|
|
232
|
-
|
|
233
|
-
if (isSupported) {
|
|
234
|
-
const { cliPath } = await getConfig();
|
|
235
|
-
const isExisted = await import_fs_extra3.default.exists(cliPath);
|
|
236
|
-
if (isExisted) {
|
|
237
|
-
if (argv2[0] === "config") {
|
|
238
|
-
await rlSetConfig();
|
|
239
|
-
return;
|
|
240
|
-
}
|
|
241
|
-
const formattedArgv = parseArgv(argv2);
|
|
242
|
-
await execute(cliPath, formattedArgv);
|
|
243
|
-
} else {
|
|
244
|
-
logger_default.log(
|
|
245
|
-
"\u5728\u5F53\u524D\u81EA\u5B9A\u4E49\u8DEF\u5F84\u4E2D,\u672A\u627E\u5230\u5FAE\u4FE1web\u5F00\u53D1\u8005\u547D\u4EE4\u884C\u5DE5\u5177\uFF0C\u8BF7\u91CD\u65B0\u6307\u5B9A\u8DEF\u5F84"
|
|
246
|
-
);
|
|
247
|
-
await rlSetConfig();
|
|
248
|
-
}
|
|
249
|
-
} else {
|
|
300
|
+
if (!isOperatingSystemSupported(operatingSystemName)) {
|
|
250
301
|
logger_default.log(`\u5FAE\u4FE1web\u5F00\u53D1\u8005\u5DE5\u5177\u4E0D\u652F\u6301\u5F53\u524D\u5E73\u53F0\uFF1A${operatingSystemName} !`);
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
if (argv2[0] === "config") {
|
|
305
|
+
await promptForCliPath();
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
const { cliPath, source } = await resolveCliPath();
|
|
309
|
+
if (!cliPath) {
|
|
310
|
+
const message = source === "custom" ? "\u5728\u5F53\u524D\u81EA\u5B9A\u4E49\u8DEF\u5F84\u4E2D\u672A\u627E\u5230\u5FAE\u4FE1web\u5F00\u53D1\u8005\u547D\u4EE4\u884C\u5DE5\u5177\uFF0C\u8BF7\u91CD\u65B0\u6307\u5B9A\u8DEF\u5F84\u3002" : "\u672A\u68C0\u6D4B\u5230\u5FAE\u4FE1web\u5F00\u53D1\u8005\u547D\u4EE4\u884C\u5DE5\u5177\uFF0C\u8BF7\u6267\u884C `weapp-ide-cli config` \u6307\u5B9A\u8DEF\u5F84\u3002";
|
|
311
|
+
logger_default.log(message);
|
|
312
|
+
await promptForCliPath();
|
|
313
|
+
return;
|
|
251
314
|
}
|
|
315
|
+
const formattedArgv = transformArgv(argv2, ARG_TRANSFORMS);
|
|
316
|
+
await execute(cliPath, formattedArgv);
|
|
252
317
|
}
|
|
253
318
|
|
|
254
319
|
// src/cli.ts
|
|
255
|
-
var argv =
|
|
320
|
+
var argv = import_node_process6.default.argv.slice(2);
|
|
256
321
|
parse(argv).catch((err) => {
|
|
257
322
|
logger_default.error(err);
|
|
258
323
|
});
|