weapp-ide-cli 1.0.1 → 2.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/LICENSE +1 -1
- package/README.md +2 -4
- package/bin/weapp.js +1 -1
- package/dist/chunk-AIRPF73I.js +201 -0
- package/dist/cli.cjs +225 -0
- package/dist/cli.d.cts +2 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +12 -98
- package/dist/index.cjs +246 -0
- package/dist/index.d.cts +21 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +22 -19
- package/package.json +42 -32
- package/dist/types/cli.d.ts +0 -1
- package/dist/types/compose.d.ts +0 -1
- package/dist/types/config.d.ts +0 -3
- package/dist/types/defaults.d.ts +0 -4
- package/dist/types/index.d.ts +0 -3
- package/dist/types/types.d.ts +0 -7
- package/dist/types/utils.d.ts +0 -6
- package/dist/utils-d05fca05.js +0 -128
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
微信开发者工具的命令行(v2) 的一个二次封装的包裹实现,来让开发者更加方便的使用微信开发者工具。
|
|
4
4
|
|
|
5
5
|
> 要使用命令行,注意首先需要在开发者工具的设置 -> 安全设置中开启服务端口。
|
|
6
|
+
|
|
6
7
|
## 快速安装
|
|
7
8
|
|
|
8
9
|
```bash
|
|
@@ -23,7 +24,6 @@ weapp open -p
|
|
|
23
24
|
# 等价
|
|
24
25
|
weapp open --project
|
|
25
26
|
|
|
26
|
-
|
|
27
27
|
# 在相对的路径,打开微信开发者工具
|
|
28
28
|
# 比如 uni-app 就可以在项目目录执行
|
|
29
29
|
weapp open -p dist/dev/mp-weixin
|
|
@@ -38,16 +38,14 @@ weapp open -p dist/dev/mp-weixin
|
|
|
38
38
|
4. `weapp upload` 上传代码
|
|
39
39
|
5. `weapp quit` 关闭开发者工具
|
|
40
40
|
|
|
41
|
-
|
|
42
41
|
### 自定义配置
|
|
43
42
|
|
|
44
43
|
`weapp config` 可以对微信开发者工具的 `cli` 目录进行配置,而配置文件就存放在用户的 `${homedir}/.weapp-ide-cli/config.json` 中,您可以随时进行更改。
|
|
45
44
|
|
|
46
45
|
> 比如 windows 存放位置就在 `C:\Users\${你的用户名}\.weapp-ide-cli/config.json`
|
|
47
46
|
|
|
48
|
-
|
|
49
47
|
### 更多命令
|
|
50
48
|
|
|
51
49
|
这个工具本质是一个 `cli` 二次处理工具,所以绝大部分命令都是透传的。
|
|
52
50
|
|
|
53
|
-
全部的命令请查看 https://developers.weixin.qq.com/miniprogram/dev/devtools/cli.html
|
|
51
|
+
全部的命令请查看 <https://developers.weixin.qq.com/miniprogram/dev/devtools/cli.html>
|
package/bin/weapp.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
import '../dist/cli.js'
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
// src/defaults.ts
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import os from "node:os";
|
|
4
|
+
var homedir = os.homedir();
|
|
5
|
+
var SupportedPlatformsMap = {
|
|
6
|
+
Windows_NT: "Windows_NT",
|
|
7
|
+
Darwin: "Darwin"
|
|
8
|
+
};
|
|
9
|
+
var defaultPathMap = {
|
|
10
|
+
[SupportedPlatformsMap.Windows_NT]: "C:\\Program Files (x86)\\Tencent\\\u5FAE\u4FE1web\u5F00\u53D1\u8005\u5DE5\u5177\\cli.bat",
|
|
11
|
+
[SupportedPlatformsMap.Darwin]: "/Applications/wechatwebdevtools.app/Contents/MacOS/cli"
|
|
12
|
+
};
|
|
13
|
+
var operatingSystemName = os.type();
|
|
14
|
+
var defaultCustomConfigDirPath = path.join(homedir, ".weapp-ide-cli");
|
|
15
|
+
var defaultCustomConfigFilePath = path.join(
|
|
16
|
+
defaultCustomConfigDirPath,
|
|
17
|
+
"config.json"
|
|
18
|
+
);
|
|
19
|
+
var defaultPath = defaultPathMap[operatingSystemName];
|
|
20
|
+
|
|
21
|
+
// src/logger.ts
|
|
22
|
+
import { createConsola } from "consola";
|
|
23
|
+
var logger_default = createConsola();
|
|
24
|
+
|
|
25
|
+
// src/utils.ts
|
|
26
|
+
import process from "node:process";
|
|
27
|
+
import path2 from "pathe";
|
|
28
|
+
import { execa } from "execa";
|
|
29
|
+
async function execute(cliPath, argv) {
|
|
30
|
+
const task = execa(cliPath, argv);
|
|
31
|
+
task?.stdout?.pipe(process.stdout);
|
|
32
|
+
await task;
|
|
33
|
+
}
|
|
34
|
+
function resolvePath(filePath) {
|
|
35
|
+
if (path2.isAbsolute(filePath)) {
|
|
36
|
+
return filePath;
|
|
37
|
+
} else {
|
|
38
|
+
return path2.resolve(process.cwd(), filePath);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function alias(argv, entry) {
|
|
42
|
+
let findIdx = argv.indexOf(entry.find);
|
|
43
|
+
if (findIdx > -1) {
|
|
44
|
+
argv[findIdx] = entry.replacement;
|
|
45
|
+
} else {
|
|
46
|
+
findIdx = argv.indexOf(entry.replacement);
|
|
47
|
+
}
|
|
48
|
+
if (findIdx > -1) {
|
|
49
|
+
const paramIdx = findIdx + 1;
|
|
50
|
+
const param = argv[paramIdx];
|
|
51
|
+
if (param && param[0] !== "-") {
|
|
52
|
+
argv[paramIdx] = resolvePath(param);
|
|
53
|
+
} else {
|
|
54
|
+
argv.splice(paramIdx, 0, process.cwd());
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return argv;
|
|
58
|
+
}
|
|
59
|
+
function pathCompat(argv, option) {
|
|
60
|
+
const findIdx = argv.indexOf(option);
|
|
61
|
+
if (findIdx > -1) {
|
|
62
|
+
const paramIdx = findIdx + 1;
|
|
63
|
+
const param = argv[paramIdx];
|
|
64
|
+
if (param && param[0] !== "-") {
|
|
65
|
+
argv[paramIdx] = resolvePath(param);
|
|
66
|
+
} else {
|
|
67
|
+
argv.splice(paramIdx, 0, process.cwd());
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return argv;
|
|
71
|
+
}
|
|
72
|
+
function createAlias(entry) {
|
|
73
|
+
return function(argv) {
|
|
74
|
+
return alias(argv, entry);
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
function createPathCompat(option) {
|
|
78
|
+
return function(argv) {
|
|
79
|
+
return pathCompat(argv, option);
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// src/parse.ts
|
|
84
|
+
import readline from "node:readline";
|
|
85
|
+
import process2 from "node:process";
|
|
86
|
+
import fs2 from "fs-extra";
|
|
87
|
+
|
|
88
|
+
// src/config.ts
|
|
89
|
+
import fs from "fs-extra";
|
|
90
|
+
async function createCustomConfig(params) {
|
|
91
|
+
const isExisted = await fs.exists(defaultCustomConfigDirPath);
|
|
92
|
+
if (!isExisted) {
|
|
93
|
+
await fs.mkdir(defaultCustomConfigDirPath, { recursive: true });
|
|
94
|
+
}
|
|
95
|
+
await fs.writeFile(
|
|
96
|
+
defaultCustomConfigFilePath,
|
|
97
|
+
JSON.stringify(
|
|
98
|
+
{
|
|
99
|
+
cliPath: params.cliPath
|
|
100
|
+
},
|
|
101
|
+
null,
|
|
102
|
+
2
|
|
103
|
+
),
|
|
104
|
+
{
|
|
105
|
+
encoding: "utf8"
|
|
106
|
+
}
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
async function getConfig() {
|
|
110
|
+
const isExisted = await fs.exists(defaultCustomConfigFilePath);
|
|
111
|
+
if (isExisted) {
|
|
112
|
+
const content = await fs.readFile(defaultCustomConfigFilePath, {
|
|
113
|
+
encoding: "utf8"
|
|
114
|
+
});
|
|
115
|
+
const config = JSON.parse(content);
|
|
116
|
+
logger_default.log("> \u81EA\u5B9A\u4E49cli\u8DEF\u5F84\uFF1A", config.cliPath);
|
|
117
|
+
return config;
|
|
118
|
+
} else {
|
|
119
|
+
return {
|
|
120
|
+
cliPath: defaultPath
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// src/compose.ts
|
|
126
|
+
function compose(...funcs) {
|
|
127
|
+
if (funcs.length === 0) {
|
|
128
|
+
return (arg) => arg;
|
|
129
|
+
}
|
|
130
|
+
if (funcs.length === 1) {
|
|
131
|
+
return funcs[0];
|
|
132
|
+
}
|
|
133
|
+
return funcs.reduce(
|
|
134
|
+
(a, b) => (...args) => a(b(...args))
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// src/parse.ts
|
|
139
|
+
var rl = readline.createInterface({
|
|
140
|
+
input: process2.stdin,
|
|
141
|
+
output: process2.stdout
|
|
142
|
+
});
|
|
143
|
+
var isSupported = Boolean(defaultPath);
|
|
144
|
+
function rlSetConfig() {
|
|
145
|
+
logger_default.log("\u8BF7\u8BBE\u7F6E\u5FAE\u4FE1web\u5F00\u53D1\u8005\u5DE5\u5177 cli \u7684\u8DEF\u5F84");
|
|
146
|
+
logger_default.log("> \u63D0\u793A\uFF1A\u547D\u4EE4\u884C\u5DE5\u5177\u9ED8\u8BA4\u6240\u5728\u4F4D\u7F6E\uFF1A");
|
|
147
|
+
logger_default.log("- MacOS: <\u5B89\u88C5\u8DEF\u5F84>/Contents/MacOS/cli");
|
|
148
|
+
logger_default.log("- Windows: <\u5B89\u88C5\u8DEF\u5F84>/cli.bat");
|
|
149
|
+
return new Promise((resolve, _reject) => {
|
|
150
|
+
rl.question("\u8BF7\u8F93\u5165\u5FAE\u4FE1web\u5F00\u53D1\u8005\u5DE5\u5177cli\u8DEF\u5F84\uFF1A", async (cliPath) => {
|
|
151
|
+
await createCustomConfig({
|
|
152
|
+
cliPath
|
|
153
|
+
});
|
|
154
|
+
logger_default.log(`\u5168\u5C40\u914D\u7F6E\u5B58\u50A8\u4F4D\u7F6E\uFF1A${defaultCustomConfigFilePath}`);
|
|
155
|
+
resolve(cliPath);
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
var parseArgv = compose(
|
|
160
|
+
createAlias({ find: "-p", replacement: "--project" }),
|
|
161
|
+
createPathCompat("--result-output"),
|
|
162
|
+
createPathCompat("-r"),
|
|
163
|
+
createPathCompat("--qr-output"),
|
|
164
|
+
createPathCompat("-o"),
|
|
165
|
+
createPathCompat("--info-output"),
|
|
166
|
+
createPathCompat("-i")
|
|
167
|
+
);
|
|
168
|
+
async function parse(argv) {
|
|
169
|
+
if (isSupported) {
|
|
170
|
+
const { cliPath } = await getConfig();
|
|
171
|
+
const isExisted = await fs2.exists(cliPath);
|
|
172
|
+
if (isExisted) {
|
|
173
|
+
if (argv[0] === "config") {
|
|
174
|
+
await rlSetConfig();
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
const formattedArgv = parseArgv(argv);
|
|
178
|
+
await execute(cliPath, formattedArgv);
|
|
179
|
+
} else {
|
|
180
|
+
logger_default.log(
|
|
181
|
+
"\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"
|
|
182
|
+
);
|
|
183
|
+
await rlSetConfig();
|
|
184
|
+
}
|
|
185
|
+
} else {
|
|
186
|
+
logger_default.log(`\u5FAE\u4FE1web\u5F00\u53D1\u8005\u5DE5\u5177\u4E0D\u652F\u6301\u5F53\u524D\u5E73\u53F0\uFF1A${operatingSystemName} !`);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export {
|
|
191
|
+
operatingSystemName,
|
|
192
|
+
defaultCustomConfigDirPath,
|
|
193
|
+
defaultCustomConfigFilePath,
|
|
194
|
+
defaultPath,
|
|
195
|
+
logger_default,
|
|
196
|
+
execute,
|
|
197
|
+
resolvePath,
|
|
198
|
+
createAlias,
|
|
199
|
+
createPathCompat,
|
|
200
|
+
parse
|
|
201
|
+
};
|
package/dist/cli.cjs
ADDED
|
@@ -0,0 +1,225 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
+
}
|
|
14
|
+
return to;
|
|
15
|
+
};
|
|
16
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
|
|
25
|
+
// src/cli.ts
|
|
26
|
+
var import_node_process3 = __toESM(require("process"), 1);
|
|
27
|
+
|
|
28
|
+
// src/parse.ts
|
|
29
|
+
var import_node_readline = __toESM(require("readline"), 1);
|
|
30
|
+
var import_node_process2 = __toESM(require("process"), 1);
|
|
31
|
+
var import_fs_extra2 = __toESM(require("fs-extra"), 1);
|
|
32
|
+
|
|
33
|
+
// src/defaults.ts
|
|
34
|
+
var import_node_path = __toESM(require("path"), 1);
|
|
35
|
+
var import_node_os = __toESM(require("os"), 1);
|
|
36
|
+
var homedir = import_node_os.default.homedir();
|
|
37
|
+
var SupportedPlatformsMap = {
|
|
38
|
+
Windows_NT: "Windows_NT",
|
|
39
|
+
Darwin: "Darwin"
|
|
40
|
+
};
|
|
41
|
+
var defaultPathMap = {
|
|
42
|
+
[SupportedPlatformsMap.Windows_NT]: "C:\\Program Files (x86)\\Tencent\\\u5FAE\u4FE1web\u5F00\u53D1\u8005\u5DE5\u5177\\cli.bat",
|
|
43
|
+
[SupportedPlatformsMap.Darwin]: "/Applications/wechatwebdevtools.app/Contents/MacOS/cli"
|
|
44
|
+
};
|
|
45
|
+
var operatingSystemName = import_node_os.default.type();
|
|
46
|
+
var defaultCustomConfigDirPath = import_node_path.default.join(homedir, ".weapp-ide-cli");
|
|
47
|
+
var defaultCustomConfigFilePath = import_node_path.default.join(
|
|
48
|
+
defaultCustomConfigDirPath,
|
|
49
|
+
"config.json"
|
|
50
|
+
);
|
|
51
|
+
var defaultPath = defaultPathMap[operatingSystemName];
|
|
52
|
+
|
|
53
|
+
// src/config.ts
|
|
54
|
+
var import_fs_extra = __toESM(require("fs-extra"), 1);
|
|
55
|
+
|
|
56
|
+
// src/logger.ts
|
|
57
|
+
var import_consola = require("consola");
|
|
58
|
+
var logger_default = (0, import_consola.createConsola)();
|
|
59
|
+
|
|
60
|
+
// src/config.ts
|
|
61
|
+
async function createCustomConfig(params) {
|
|
62
|
+
const isExisted = await import_fs_extra.default.exists(defaultCustomConfigDirPath);
|
|
63
|
+
if (!isExisted) {
|
|
64
|
+
await import_fs_extra.default.mkdir(defaultCustomConfigDirPath, { recursive: true });
|
|
65
|
+
}
|
|
66
|
+
await import_fs_extra.default.writeFile(
|
|
67
|
+
defaultCustomConfigFilePath,
|
|
68
|
+
JSON.stringify(
|
|
69
|
+
{
|
|
70
|
+
cliPath: params.cliPath
|
|
71
|
+
},
|
|
72
|
+
null,
|
|
73
|
+
2
|
|
74
|
+
),
|
|
75
|
+
{
|
|
76
|
+
encoding: "utf8"
|
|
77
|
+
}
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
async function getConfig() {
|
|
81
|
+
const isExisted = await import_fs_extra.default.exists(defaultCustomConfigFilePath);
|
|
82
|
+
if (isExisted) {
|
|
83
|
+
const content = await import_fs_extra.default.readFile(defaultCustomConfigFilePath, {
|
|
84
|
+
encoding: "utf8"
|
|
85
|
+
});
|
|
86
|
+
const config = JSON.parse(content);
|
|
87
|
+
logger_default.log("> \u81EA\u5B9A\u4E49cli\u8DEF\u5F84\uFF1A", config.cliPath);
|
|
88
|
+
return config;
|
|
89
|
+
} else {
|
|
90
|
+
return {
|
|
91
|
+
cliPath: defaultPath
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// src/utils.ts
|
|
97
|
+
var import_node_process = __toESM(require("process"), 1);
|
|
98
|
+
var import_pathe = __toESM(require("pathe"), 1);
|
|
99
|
+
var import_execa = require("execa");
|
|
100
|
+
async function execute(cliPath, argv2) {
|
|
101
|
+
const task = (0, import_execa.execa)(cliPath, argv2);
|
|
102
|
+
task?.stdout?.pipe(import_node_process.default.stdout);
|
|
103
|
+
await task;
|
|
104
|
+
}
|
|
105
|
+
function resolvePath(filePath) {
|
|
106
|
+
if (import_pathe.default.isAbsolute(filePath)) {
|
|
107
|
+
return filePath;
|
|
108
|
+
} else {
|
|
109
|
+
return import_pathe.default.resolve(import_node_process.default.cwd(), filePath);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
function alias(argv2, entry) {
|
|
113
|
+
let findIdx = argv2.indexOf(entry.find);
|
|
114
|
+
if (findIdx > -1) {
|
|
115
|
+
argv2[findIdx] = entry.replacement;
|
|
116
|
+
} else {
|
|
117
|
+
findIdx = argv2.indexOf(entry.replacement);
|
|
118
|
+
}
|
|
119
|
+
if (findIdx > -1) {
|
|
120
|
+
const paramIdx = findIdx + 1;
|
|
121
|
+
const param = argv2[paramIdx];
|
|
122
|
+
if (param && param[0] !== "-") {
|
|
123
|
+
argv2[paramIdx] = resolvePath(param);
|
|
124
|
+
} else {
|
|
125
|
+
argv2.splice(paramIdx, 0, import_node_process.default.cwd());
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return argv2;
|
|
129
|
+
}
|
|
130
|
+
function pathCompat(argv2, option) {
|
|
131
|
+
const findIdx = argv2.indexOf(option);
|
|
132
|
+
if (findIdx > -1) {
|
|
133
|
+
const paramIdx = findIdx + 1;
|
|
134
|
+
const param = argv2[paramIdx];
|
|
135
|
+
if (param && param[0] !== "-") {
|
|
136
|
+
argv2[paramIdx] = resolvePath(param);
|
|
137
|
+
} else {
|
|
138
|
+
argv2.splice(paramIdx, 0, import_node_process.default.cwd());
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return argv2;
|
|
142
|
+
}
|
|
143
|
+
function createAlias(entry) {
|
|
144
|
+
return function(argv2) {
|
|
145
|
+
return alias(argv2, entry);
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
function createPathCompat(option) {
|
|
149
|
+
return function(argv2) {
|
|
150
|
+
return pathCompat(argv2, option);
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// src/compose.ts
|
|
155
|
+
function compose(...funcs) {
|
|
156
|
+
if (funcs.length === 0) {
|
|
157
|
+
return (arg) => arg;
|
|
158
|
+
}
|
|
159
|
+
if (funcs.length === 1) {
|
|
160
|
+
return funcs[0];
|
|
161
|
+
}
|
|
162
|
+
return funcs.reduce(
|
|
163
|
+
(a, b) => (...args) => a(b(...args))
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// src/parse.ts
|
|
168
|
+
var rl = import_node_readline.default.createInterface({
|
|
169
|
+
input: import_node_process2.default.stdin,
|
|
170
|
+
output: import_node_process2.default.stdout
|
|
171
|
+
});
|
|
172
|
+
var isSupported = Boolean(defaultPath);
|
|
173
|
+
function rlSetConfig() {
|
|
174
|
+
logger_default.log("\u8BF7\u8BBE\u7F6E\u5FAE\u4FE1web\u5F00\u53D1\u8005\u5DE5\u5177 cli \u7684\u8DEF\u5F84");
|
|
175
|
+
logger_default.log("> \u63D0\u793A\uFF1A\u547D\u4EE4\u884C\u5DE5\u5177\u9ED8\u8BA4\u6240\u5728\u4F4D\u7F6E\uFF1A");
|
|
176
|
+
logger_default.log("- MacOS: <\u5B89\u88C5\u8DEF\u5F84>/Contents/MacOS/cli");
|
|
177
|
+
logger_default.log("- Windows: <\u5B89\u88C5\u8DEF\u5F84>/cli.bat");
|
|
178
|
+
return new Promise((resolve, _reject) => {
|
|
179
|
+
rl.question("\u8BF7\u8F93\u5165\u5FAE\u4FE1web\u5F00\u53D1\u8005\u5DE5\u5177cli\u8DEF\u5F84\uFF1A", async (cliPath) => {
|
|
180
|
+
await createCustomConfig({
|
|
181
|
+
cliPath
|
|
182
|
+
});
|
|
183
|
+
logger_default.log(`\u5168\u5C40\u914D\u7F6E\u5B58\u50A8\u4F4D\u7F6E\uFF1A${defaultCustomConfigFilePath}`);
|
|
184
|
+
resolve(cliPath);
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
var parseArgv = compose(
|
|
189
|
+
createAlias({ find: "-p", replacement: "--project" }),
|
|
190
|
+
createPathCompat("--result-output"),
|
|
191
|
+
createPathCompat("-r"),
|
|
192
|
+
createPathCompat("--qr-output"),
|
|
193
|
+
createPathCompat("-o"),
|
|
194
|
+
createPathCompat("--info-output"),
|
|
195
|
+
createPathCompat("-i")
|
|
196
|
+
);
|
|
197
|
+
async function parse(argv2) {
|
|
198
|
+
if (isSupported) {
|
|
199
|
+
const { cliPath } = await getConfig();
|
|
200
|
+
const isExisted = await import_fs_extra2.default.exists(cliPath);
|
|
201
|
+
if (isExisted) {
|
|
202
|
+
if (argv2[0] === "config") {
|
|
203
|
+
await rlSetConfig();
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
const formattedArgv = parseArgv(argv2);
|
|
207
|
+
await execute(cliPath, formattedArgv);
|
|
208
|
+
} else {
|
|
209
|
+
logger_default.log(
|
|
210
|
+
"\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"
|
|
211
|
+
);
|
|
212
|
+
await rlSetConfig();
|
|
213
|
+
}
|
|
214
|
+
} else {
|
|
215
|
+
logger_default.log(`\u5FAE\u4FE1web\u5F00\u53D1\u8005\u5DE5\u5177\u4E0D\u652F\u6301\u5F53\u524D\u5E73\u53F0\uFF1A${operatingSystemName} !`);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// src/cli.ts
|
|
220
|
+
var argv = import_node_process3.default.argv.slice(2);
|
|
221
|
+
parse(argv).catch((err) => {
|
|
222
|
+
logger_default.error(err);
|
|
223
|
+
}).finally(() => {
|
|
224
|
+
import_node_process3.default.exit();
|
|
225
|
+
});
|
package/dist/cli.d.cts
ADDED
package/dist/cli.d.ts
ADDED
package/dist/cli.js
CHANGED
|
@@ -1,99 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
if (!isExisted) {
|
|
14
|
-
yield fs.mkdir(utils.defaultCustomConfigDirPath, { recursive: true });
|
|
15
|
-
}
|
|
16
|
-
yield fs.writeFile(utils.defaultCustomConfigFilePath, JSON.stringify({
|
|
17
|
-
cliPath: params.cliPath
|
|
18
|
-
}, null, 2), {
|
|
19
|
-
encoding: 'utf8'
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
function getConfig() {
|
|
24
|
-
return utils.__awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
const isExisted = yield utils.exist(utils.defaultCustomConfigFilePath);
|
|
26
|
-
if (isExisted) {
|
|
27
|
-
const content = yield fs.readFile(utils.defaultCustomConfigFilePath, {
|
|
28
|
-
encoding: 'utf8'
|
|
29
|
-
});
|
|
30
|
-
const config = JSON.parse(content);
|
|
31
|
-
console.log('> 自定义cli路径:', config.cliPath);
|
|
32
|
-
return config;
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
return {
|
|
36
|
-
cliPath: utils.defaultPath
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function compose(...funcs) {
|
|
43
|
-
if (funcs.length === 0) {
|
|
44
|
-
return (arg) => arg;
|
|
45
|
-
}
|
|
46
|
-
if (funcs.length === 1) {
|
|
47
|
-
return funcs[0];
|
|
48
|
-
}
|
|
49
|
-
return funcs.reduce((a, b) => (...args) => a(b(...args)));
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const rl = readline.createInterface({
|
|
53
|
-
input: process.stdin,
|
|
54
|
-
output: process.stdout
|
|
55
|
-
});
|
|
56
|
-
const isSupported = Boolean(utils.defaultPath);
|
|
57
|
-
const argv = process.argv.slice(2);
|
|
58
|
-
function rlSetConfig() {
|
|
59
|
-
console.log('请设置微信web开发者工具 cli 的路径');
|
|
60
|
-
console.log('> 提示:命令行工具默认所在位置:');
|
|
61
|
-
console.log('- MacOS: <安装路径>/Contents/MacOS/cli');
|
|
62
|
-
console.log('- Windows: <安装路径>/cli.bat');
|
|
63
|
-
return new Promise((resolve, reject) => {
|
|
64
|
-
rl.question('请输入微信web开发者工具cli路径:', (cliPath) => utils.__awaiter(this, void 0, void 0, function* () {
|
|
65
|
-
yield createCustomConfig({
|
|
66
|
-
cliPath
|
|
67
|
-
});
|
|
68
|
-
console.log(`全局配置存储位置:${utils.defaultCustomConfigFilePath}`);
|
|
69
|
-
resolve(cliPath);
|
|
70
|
-
}));
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
const parseArgv = compose(utils.createAlias({ find: '-p', replacement: '--project' }), utils.createPathCompat('--result-output'), utils.createPathCompat('-r'), utils.createPathCompat('--qr-output'), utils.createPathCompat('-o'), utils.createPathCompat('--info-output'), utils.createPathCompat('-i'));
|
|
74
|
-
function main() {
|
|
75
|
-
return utils.__awaiter(this, void 0, void 0, function* () {
|
|
76
|
-
if (isSupported) {
|
|
77
|
-
const { cliPath } = yield getConfig();
|
|
78
|
-
const isExisted = yield utils.exist(cliPath);
|
|
79
|
-
if (isExisted) {
|
|
80
|
-
if (argv[0] === 'config') {
|
|
81
|
-
yield rlSetConfig();
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
const formattedArgv = parseArgv(argv);
|
|
85
|
-
yield utils.execute(cliPath, formattedArgv);
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
console.log('在当前自定义路径中,未找到微信web开发者命令行工具,请重新指定路径');
|
|
89
|
-
yield rlSetConfig();
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
console.log(`微信web开发者工具不支持当前平台:${utils.operatingSystemName} !`);
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
main().finally(() => {
|
|
98
|
-
process.exit();
|
|
1
|
+
import {
|
|
2
|
+
logger_default,
|
|
3
|
+
parse
|
|
4
|
+
} from "./chunk-AIRPF73I.js";
|
|
5
|
+
|
|
6
|
+
// src/cli.ts
|
|
7
|
+
import process from "node:process";
|
|
8
|
+
var argv = process.argv.slice(2);
|
|
9
|
+
parse(argv).catch((err) => {
|
|
10
|
+
logger_default.error(err);
|
|
11
|
+
}).finally(() => {
|
|
12
|
+
process.exit();
|
|
99
13
|
});
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,246 @@
|
|
|
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 src_exports = {};
|
|
32
|
+
__export(src_exports, {
|
|
33
|
+
createAlias: () => createAlias,
|
|
34
|
+
createPathCompat: () => createPathCompat,
|
|
35
|
+
defaultCustomConfigDirPath: () => defaultCustomConfigDirPath,
|
|
36
|
+
defaultCustomConfigFilePath: () => defaultCustomConfigFilePath,
|
|
37
|
+
defaultPath: () => defaultPath,
|
|
38
|
+
execute: () => execute,
|
|
39
|
+
operatingSystemName: () => operatingSystemName,
|
|
40
|
+
parse: () => parse,
|
|
41
|
+
resolvePath: () => resolvePath
|
|
42
|
+
});
|
|
43
|
+
module.exports = __toCommonJS(src_exports);
|
|
44
|
+
|
|
45
|
+
// src/parse.ts
|
|
46
|
+
var import_node_readline = __toESM(require("readline"), 1);
|
|
47
|
+
var import_node_process2 = __toESM(require("process"), 1);
|
|
48
|
+
var import_fs_extra2 = __toESM(require("fs-extra"), 1);
|
|
49
|
+
|
|
50
|
+
// src/defaults.ts
|
|
51
|
+
var import_node_path = __toESM(require("path"), 1);
|
|
52
|
+
var import_node_os = __toESM(require("os"), 1);
|
|
53
|
+
var homedir = import_node_os.default.homedir();
|
|
54
|
+
var SupportedPlatformsMap = {
|
|
55
|
+
Windows_NT: "Windows_NT",
|
|
56
|
+
Darwin: "Darwin"
|
|
57
|
+
};
|
|
58
|
+
var defaultPathMap = {
|
|
59
|
+
[SupportedPlatformsMap.Windows_NT]: "C:\\Program Files (x86)\\Tencent\\\u5FAE\u4FE1web\u5F00\u53D1\u8005\u5DE5\u5177\\cli.bat",
|
|
60
|
+
[SupportedPlatformsMap.Darwin]: "/Applications/wechatwebdevtools.app/Contents/MacOS/cli"
|
|
61
|
+
};
|
|
62
|
+
var operatingSystemName = import_node_os.default.type();
|
|
63
|
+
var defaultCustomConfigDirPath = import_node_path.default.join(homedir, ".weapp-ide-cli");
|
|
64
|
+
var defaultCustomConfigFilePath = import_node_path.default.join(
|
|
65
|
+
defaultCustomConfigDirPath,
|
|
66
|
+
"config.json"
|
|
67
|
+
);
|
|
68
|
+
var defaultPath = defaultPathMap[operatingSystemName];
|
|
69
|
+
|
|
70
|
+
// src/config.ts
|
|
71
|
+
var import_fs_extra = __toESM(require("fs-extra"), 1);
|
|
72
|
+
|
|
73
|
+
// src/logger.ts
|
|
74
|
+
var import_consola = require("consola");
|
|
75
|
+
var logger_default = (0, import_consola.createConsola)();
|
|
76
|
+
|
|
77
|
+
// src/config.ts
|
|
78
|
+
async function createCustomConfig(params) {
|
|
79
|
+
const isExisted = await import_fs_extra.default.exists(defaultCustomConfigDirPath);
|
|
80
|
+
if (!isExisted) {
|
|
81
|
+
await import_fs_extra.default.mkdir(defaultCustomConfigDirPath, { recursive: true });
|
|
82
|
+
}
|
|
83
|
+
await import_fs_extra.default.writeFile(
|
|
84
|
+
defaultCustomConfigFilePath,
|
|
85
|
+
JSON.stringify(
|
|
86
|
+
{
|
|
87
|
+
cliPath: params.cliPath
|
|
88
|
+
},
|
|
89
|
+
null,
|
|
90
|
+
2
|
|
91
|
+
),
|
|
92
|
+
{
|
|
93
|
+
encoding: "utf8"
|
|
94
|
+
}
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
async function getConfig() {
|
|
98
|
+
const isExisted = await import_fs_extra.default.exists(defaultCustomConfigFilePath);
|
|
99
|
+
if (isExisted) {
|
|
100
|
+
const content = await import_fs_extra.default.readFile(defaultCustomConfigFilePath, {
|
|
101
|
+
encoding: "utf8"
|
|
102
|
+
});
|
|
103
|
+
const config = JSON.parse(content);
|
|
104
|
+
logger_default.log("> \u81EA\u5B9A\u4E49cli\u8DEF\u5F84\uFF1A", config.cliPath);
|
|
105
|
+
return config;
|
|
106
|
+
} else {
|
|
107
|
+
return {
|
|
108
|
+
cliPath: defaultPath
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// src/utils.ts
|
|
114
|
+
var import_node_process = __toESM(require("process"), 1);
|
|
115
|
+
var import_pathe = __toESM(require("pathe"), 1);
|
|
116
|
+
var import_execa = require("execa");
|
|
117
|
+
async function execute(cliPath, argv) {
|
|
118
|
+
const task = (0, import_execa.execa)(cliPath, argv);
|
|
119
|
+
task?.stdout?.pipe(import_node_process.default.stdout);
|
|
120
|
+
await task;
|
|
121
|
+
}
|
|
122
|
+
function resolvePath(filePath) {
|
|
123
|
+
if (import_pathe.default.isAbsolute(filePath)) {
|
|
124
|
+
return filePath;
|
|
125
|
+
} else {
|
|
126
|
+
return import_pathe.default.resolve(import_node_process.default.cwd(), filePath);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
function alias(argv, entry) {
|
|
130
|
+
let findIdx = argv.indexOf(entry.find);
|
|
131
|
+
if (findIdx > -1) {
|
|
132
|
+
argv[findIdx] = entry.replacement;
|
|
133
|
+
} else {
|
|
134
|
+
findIdx = argv.indexOf(entry.replacement);
|
|
135
|
+
}
|
|
136
|
+
if (findIdx > -1) {
|
|
137
|
+
const paramIdx = findIdx + 1;
|
|
138
|
+
const param = argv[paramIdx];
|
|
139
|
+
if (param && param[0] !== "-") {
|
|
140
|
+
argv[paramIdx] = resolvePath(param);
|
|
141
|
+
} else {
|
|
142
|
+
argv.splice(paramIdx, 0, import_node_process.default.cwd());
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return argv;
|
|
146
|
+
}
|
|
147
|
+
function pathCompat(argv, option) {
|
|
148
|
+
const findIdx = argv.indexOf(option);
|
|
149
|
+
if (findIdx > -1) {
|
|
150
|
+
const paramIdx = findIdx + 1;
|
|
151
|
+
const param = argv[paramIdx];
|
|
152
|
+
if (param && param[0] !== "-") {
|
|
153
|
+
argv[paramIdx] = resolvePath(param);
|
|
154
|
+
} else {
|
|
155
|
+
argv.splice(paramIdx, 0, import_node_process.default.cwd());
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return argv;
|
|
159
|
+
}
|
|
160
|
+
function createAlias(entry) {
|
|
161
|
+
return function(argv) {
|
|
162
|
+
return alias(argv, entry);
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
function createPathCompat(option) {
|
|
166
|
+
return function(argv) {
|
|
167
|
+
return pathCompat(argv, option);
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// src/compose.ts
|
|
172
|
+
function compose(...funcs) {
|
|
173
|
+
if (funcs.length === 0) {
|
|
174
|
+
return (arg) => arg;
|
|
175
|
+
}
|
|
176
|
+
if (funcs.length === 1) {
|
|
177
|
+
return funcs[0];
|
|
178
|
+
}
|
|
179
|
+
return funcs.reduce(
|
|
180
|
+
(a, b) => (...args) => a(b(...args))
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// src/parse.ts
|
|
185
|
+
var rl = import_node_readline.default.createInterface({
|
|
186
|
+
input: import_node_process2.default.stdin,
|
|
187
|
+
output: import_node_process2.default.stdout
|
|
188
|
+
});
|
|
189
|
+
var isSupported = Boolean(defaultPath);
|
|
190
|
+
function rlSetConfig() {
|
|
191
|
+
logger_default.log("\u8BF7\u8BBE\u7F6E\u5FAE\u4FE1web\u5F00\u53D1\u8005\u5DE5\u5177 cli \u7684\u8DEF\u5F84");
|
|
192
|
+
logger_default.log("> \u63D0\u793A\uFF1A\u547D\u4EE4\u884C\u5DE5\u5177\u9ED8\u8BA4\u6240\u5728\u4F4D\u7F6E\uFF1A");
|
|
193
|
+
logger_default.log("- MacOS: <\u5B89\u88C5\u8DEF\u5F84>/Contents/MacOS/cli");
|
|
194
|
+
logger_default.log("- Windows: <\u5B89\u88C5\u8DEF\u5F84>/cli.bat");
|
|
195
|
+
return new Promise((resolve, _reject) => {
|
|
196
|
+
rl.question("\u8BF7\u8F93\u5165\u5FAE\u4FE1web\u5F00\u53D1\u8005\u5DE5\u5177cli\u8DEF\u5F84\uFF1A", async (cliPath) => {
|
|
197
|
+
await createCustomConfig({
|
|
198
|
+
cliPath
|
|
199
|
+
});
|
|
200
|
+
logger_default.log(`\u5168\u5C40\u914D\u7F6E\u5B58\u50A8\u4F4D\u7F6E\uFF1A${defaultCustomConfigFilePath}`);
|
|
201
|
+
resolve(cliPath);
|
|
202
|
+
});
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
var parseArgv = compose(
|
|
206
|
+
createAlias({ find: "-p", replacement: "--project" }),
|
|
207
|
+
createPathCompat("--result-output"),
|
|
208
|
+
createPathCompat("-r"),
|
|
209
|
+
createPathCompat("--qr-output"),
|
|
210
|
+
createPathCompat("-o"),
|
|
211
|
+
createPathCompat("--info-output"),
|
|
212
|
+
createPathCompat("-i")
|
|
213
|
+
);
|
|
214
|
+
async function parse(argv) {
|
|
215
|
+
if (isSupported) {
|
|
216
|
+
const { cliPath } = await getConfig();
|
|
217
|
+
const isExisted = await import_fs_extra2.default.exists(cliPath);
|
|
218
|
+
if (isExisted) {
|
|
219
|
+
if (argv[0] === "config") {
|
|
220
|
+
await rlSetConfig();
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
const formattedArgv = parseArgv(argv);
|
|
224
|
+
await execute(cliPath, formattedArgv);
|
|
225
|
+
} else {
|
|
226
|
+
logger_default.log(
|
|
227
|
+
"\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"
|
|
228
|
+
);
|
|
229
|
+
await rlSetConfig();
|
|
230
|
+
}
|
|
231
|
+
} else {
|
|
232
|
+
logger_default.log(`\u5FAE\u4FE1web\u5F00\u53D1\u8005\u5DE5\u5177\u4E0D\u652F\u6301\u5F53\u524D\u5E73\u53F0\uFF1A${operatingSystemName} !`);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
236
|
+
0 && (module.exports = {
|
|
237
|
+
createAlias,
|
|
238
|
+
createPathCompat,
|
|
239
|
+
defaultCustomConfigDirPath,
|
|
240
|
+
defaultCustomConfigFilePath,
|
|
241
|
+
defaultPath,
|
|
242
|
+
execute,
|
|
243
|
+
operatingSystemName,
|
|
244
|
+
parse,
|
|
245
|
+
resolvePath
|
|
246
|
+
});
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
interface BaseConfig {
|
|
2
|
+
cliPath: string;
|
|
3
|
+
}
|
|
4
|
+
interface AliasEntry {
|
|
5
|
+
find: string;
|
|
6
|
+
replacement: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
declare function parse(argv: string[]): Promise<void>;
|
|
10
|
+
|
|
11
|
+
declare const operatingSystemName: string;
|
|
12
|
+
declare const defaultCustomConfigDirPath: string;
|
|
13
|
+
declare const defaultCustomConfigFilePath: string;
|
|
14
|
+
declare const defaultPath: string;
|
|
15
|
+
|
|
16
|
+
declare function execute(cliPath: string, argv: string[]): Promise<void>;
|
|
17
|
+
declare function resolvePath(filePath: string): string;
|
|
18
|
+
declare function createAlias(entry: AliasEntry): (argv: string[]) => string[];
|
|
19
|
+
declare function createPathCompat(option: string): (argv: string[]) => string[];
|
|
20
|
+
|
|
21
|
+
export { type BaseConfig, createAlias, createPathCompat, defaultCustomConfigDirPath, defaultCustomConfigFilePath, defaultPath, execute, operatingSystemName, parse, resolvePath };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
interface BaseConfig {
|
|
2
|
+
cliPath: string;
|
|
3
|
+
}
|
|
4
|
+
interface AliasEntry {
|
|
5
|
+
find: string;
|
|
6
|
+
replacement: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
declare function parse(argv: string[]): Promise<void>;
|
|
10
|
+
|
|
11
|
+
declare const operatingSystemName: string;
|
|
12
|
+
declare const defaultCustomConfigDirPath: string;
|
|
13
|
+
declare const defaultCustomConfigFilePath: string;
|
|
14
|
+
declare const defaultPath: string;
|
|
15
|
+
|
|
16
|
+
declare function execute(cliPath: string, argv: string[]): Promise<void>;
|
|
17
|
+
declare function resolvePath(filePath: string): string;
|
|
18
|
+
declare function createAlias(entry: AliasEntry): (argv: string[]) => string[];
|
|
19
|
+
declare function createPathCompat(option: string): (argv: string[]) => string[];
|
|
20
|
+
|
|
21
|
+
export { type BaseConfig, createAlias, createPathCompat, defaultCustomConfigDirPath, defaultCustomConfigFilePath, defaultPath, execute, operatingSystemName, parse, resolvePath };
|
package/dist/index.js
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
import {
|
|
2
|
+
createAlias,
|
|
3
|
+
createPathCompat,
|
|
4
|
+
defaultCustomConfigDirPath,
|
|
5
|
+
defaultCustomConfigFilePath,
|
|
6
|
+
defaultPath,
|
|
7
|
+
execute,
|
|
8
|
+
operatingSystemName,
|
|
9
|
+
parse,
|
|
10
|
+
resolvePath
|
|
11
|
+
} from "./chunk-AIRPF73I.js";
|
|
12
|
+
export {
|
|
13
|
+
createAlias,
|
|
14
|
+
createPathCompat,
|
|
15
|
+
defaultCustomConfigDirPath,
|
|
16
|
+
defaultCustomConfigFilePath,
|
|
17
|
+
defaultPath,
|
|
18
|
+
execute,
|
|
19
|
+
operatingSystemName,
|
|
20
|
+
parse,
|
|
21
|
+
resolvePath
|
|
22
|
+
};
|
package/package.json
CHANGED
|
@@ -1,21 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "weapp-ide-cli",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
"bin": {
|
|
13
|
-
"weapp": "bin/weapp.js",
|
|
14
|
-
"weapp-ide-cli": "bin/weapp.js"
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "2.0.0-alpha.0",
|
|
5
|
+
"description": "让微信开发者工具,用起来更加方便!",
|
|
6
|
+
"author": "SonOfMagic <qq1324318532@gmail.com>",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"homepage": "https://github.com/sonofmagic/weapp-tailwindcss",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/sonofmagic/weapp-tailwindcss.git"
|
|
15
12
|
},
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"registry": "https://registry.npmjs.org/"
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/sonofmagic/weapp-tailwindcss/issues"
|
|
19
15
|
},
|
|
20
16
|
"keywords": [
|
|
21
17
|
"weapp",
|
|
@@ -29,28 +25,42 @@
|
|
|
29
25
|
"mini",
|
|
30
26
|
"miniprogram"
|
|
31
27
|
],
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
28
|
+
"exports": {
|
|
29
|
+
".": {
|
|
30
|
+
"types": "./dist/index.d.ts",
|
|
31
|
+
"import": "./dist/index.js",
|
|
32
|
+
"require": "./dist/index.cjs"
|
|
33
|
+
}
|
|
37
34
|
},
|
|
38
|
-
"
|
|
39
|
-
|
|
35
|
+
"main": "./dist/index.cjs",
|
|
36
|
+
"module": "./dist/index.js",
|
|
37
|
+
"types": "./dist/index.d.ts",
|
|
38
|
+
"bin": {
|
|
39
|
+
"weapp": "bin/weapp.js",
|
|
40
|
+
"weapp-ide-cli": "bin/weapp.js"
|
|
40
41
|
},
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
42
|
+
"files": [
|
|
43
|
+
"bin",
|
|
44
|
+
"dist"
|
|
45
|
+
],
|
|
46
|
+
"publishConfig": {
|
|
47
|
+
"access": "public",
|
|
48
|
+
"registry": "https://registry.npmjs.org/"
|
|
44
49
|
},
|
|
45
|
-
"
|
|
46
|
-
"
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"consola": "^3.2.3",
|
|
52
|
+
"execa": "9.3.0",
|
|
53
|
+
"fs-extra": "^11.2.0",
|
|
54
|
+
"pathe": "^1.1.2"
|
|
47
55
|
},
|
|
48
|
-
"homepage": "https://github.com/sonofmagic/utils/tree/main/packages/weapp-ide-cli#readme",
|
|
49
56
|
"scripts": {
|
|
50
|
-
"dev": "
|
|
51
|
-
"build": "
|
|
52
|
-
"
|
|
53
|
-
"
|
|
57
|
+
"dev": "tsup --watch --sourcemap",
|
|
58
|
+
"build": "tsup",
|
|
59
|
+
"release": "node scripts/release.js",
|
|
60
|
+
"test:dev": "vitest",
|
|
61
|
+
"test": "vitest run",
|
|
62
|
+
"weapp": "tsx src/cli.ts",
|
|
63
|
+
"debug": "tsx src/cli.ts config",
|
|
54
64
|
"raw": "node bin/weapp.js"
|
|
55
65
|
}
|
|
56
66
|
}
|
package/dist/types/cli.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/types/compose.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function compose<TArgs extends any[]>(...funcs: TArgs): any;
|
package/dist/types/config.d.ts
DELETED
package/dist/types/defaults.d.ts
DELETED
package/dist/types/index.d.ts
DELETED
package/dist/types/types.d.ts
DELETED
package/dist/types/utils.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { IAliasEntry } from './types';
|
|
2
|
-
export declare function exist(filepath: string, mode?: number): Promise<boolean>;
|
|
3
|
-
export declare function execute(cliPath: string, argv: string[]): Promise<void>;
|
|
4
|
-
export declare function resolvePath(filePath: string): string;
|
|
5
|
-
export declare function createAlias(entry: IAliasEntry): (argv: string[]) => string[];
|
|
6
|
-
export declare function createPathCompat(option: string): (argv: string[]) => string[];
|
package/dist/utils-d05fca05.js
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var path = require('path');
|
|
4
|
-
var os = require('os');
|
|
5
|
-
var execa = require('execa');
|
|
6
|
-
var fs = require('fs/promises');
|
|
7
|
-
|
|
8
|
-
const homedir = os.homedir();
|
|
9
|
-
const SupportedPlatformsMap = {
|
|
10
|
-
Windows_NT: 'Windows_NT',
|
|
11
|
-
Darwin: 'Darwin'
|
|
12
|
-
};
|
|
13
|
-
const defaultPathMap = {
|
|
14
|
-
[SupportedPlatformsMap.Windows_NT]: 'C:\\Program Files (x86)\\Tencent\\微信web开发者工具\\cli.bat',
|
|
15
|
-
[SupportedPlatformsMap.Darwin]: '/Applications/wechatwebdevtools.app/Contents/MacOS/cli'
|
|
16
|
-
};
|
|
17
|
-
const operatingSystemName = os.type();
|
|
18
|
-
const defaultCustomConfigDirPath = path.join(homedir, '.weapp-ide-cli');
|
|
19
|
-
const defaultCustomConfigFilePath = path.join(defaultCustomConfigDirPath, 'config.json');
|
|
20
|
-
const defaultPath = defaultPathMap[operatingSystemName];
|
|
21
|
-
|
|
22
|
-
/*! *****************************************************************************
|
|
23
|
-
Copyright (c) Microsoft Corporation.
|
|
24
|
-
|
|
25
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
26
|
-
purpose with or without fee is hereby granted.
|
|
27
|
-
|
|
28
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
29
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
30
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
31
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
32
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
33
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
34
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
35
|
-
***************************************************************************** */
|
|
36
|
-
|
|
37
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
38
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
39
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
40
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
41
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
42
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
43
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function exist(filepath, mode) {
|
|
48
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
-
try {
|
|
50
|
-
yield fs.access(filepath, mode);
|
|
51
|
-
return true;
|
|
52
|
-
}
|
|
53
|
-
catch (error) {
|
|
54
|
-
return false;
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
function execute(cliPath, argv) {
|
|
59
|
-
var _a;
|
|
60
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
-
const task = execa(cliPath, argv);
|
|
62
|
-
(_a = task === null || task === void 0 ? void 0 : task.stdout) === null || _a === void 0 ? void 0 : _a.pipe(process.stdout);
|
|
63
|
-
yield task;
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
function resolvePath(filePath) {
|
|
67
|
-
if (path.isAbsolute(filePath)) {
|
|
68
|
-
return filePath;
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
return path.resolve(process.cwd(), filePath);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
function alias(argv, entry) {
|
|
75
|
-
let findIdx = argv.indexOf(entry.find);
|
|
76
|
-
if (findIdx > -1) {
|
|
77
|
-
argv[findIdx] = entry.replacement;
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
findIdx = argv.indexOf(entry.replacement);
|
|
81
|
-
}
|
|
82
|
-
if (findIdx > -1) {
|
|
83
|
-
const paramIdx = findIdx + 1;
|
|
84
|
-
const param = argv[paramIdx];
|
|
85
|
-
if (param && param[0] !== '-') {
|
|
86
|
-
argv[paramIdx] = resolvePath(param);
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
argv.splice(paramIdx, 0, process.cwd());
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
return argv;
|
|
93
|
-
}
|
|
94
|
-
function pathCompat(argv, option) {
|
|
95
|
-
const findIdx = argv.indexOf(option);
|
|
96
|
-
if (findIdx > -1) {
|
|
97
|
-
const paramIdx = findIdx + 1;
|
|
98
|
-
const param = argv[paramIdx];
|
|
99
|
-
if (param && param[0] !== '-') {
|
|
100
|
-
argv[paramIdx] = resolvePath(param);
|
|
101
|
-
}
|
|
102
|
-
else {
|
|
103
|
-
argv.splice(paramIdx, 0, process.cwd());
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
return argv;
|
|
107
|
-
}
|
|
108
|
-
function createAlias(entry) {
|
|
109
|
-
return function (argv) {
|
|
110
|
-
return alias(argv, entry);
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
function createPathCompat(option) {
|
|
114
|
-
return function (argv) {
|
|
115
|
-
return pathCompat(argv, option);
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
exports.__awaiter = __awaiter;
|
|
120
|
-
exports.createAlias = createAlias;
|
|
121
|
-
exports.createPathCompat = createPathCompat;
|
|
122
|
-
exports.defaultCustomConfigDirPath = defaultCustomConfigDirPath;
|
|
123
|
-
exports.defaultCustomConfigFilePath = defaultCustomConfigFilePath;
|
|
124
|
-
exports.defaultPath = defaultPath;
|
|
125
|
-
exports.execute = execute;
|
|
126
|
-
exports.exist = exist;
|
|
127
|
-
exports.operatingSystemName = operatingSystemName;
|
|
128
|
-
exports.resolvePath = resolvePath;
|