weapp-ide-cli 0.0.2 → 1.0.1
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 +21 -0
- package/README.md +52 -52
- package/bin/weapp.js +2 -2
- package/dist/cli.js +91 -107
- package/dist/index.js +6 -3
- package/dist/types/cli.d.ts +1 -1
- package/dist/types/compose.d.ts +1 -0
- package/dist/types/config.d.ts +3 -0
- package/dist/types/defaults.d.ts +4 -4
- package/dist/types/index.d.ts +3 -3
- package/dist/types/types.d.ts +7 -3
- package/dist/types/utils.d.ts +6 -1
- package/dist/{utils-b22f3285.js → utils-d05fca05.js} +88 -29
- package/package.json +56 -56
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 ice breaker
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
# weapp-ide-cli
|
|
2
|
-
|
|
3
|
-
微信开发者工具的命令行(v2) 的一个二次封装的包裹实现,来让开发者更加方便的使用微信开发者工具。
|
|
4
|
-
|
|
5
|
-
> 要使用命令行,注意首先需要在开发者工具的设置 -> 安全设置中开启服务端口。
|
|
6
|
-
## 快速安装
|
|
7
|
-
|
|
8
|
-
```bash
|
|
9
|
-
npm i -g weapp-ide-cli
|
|
10
|
-
# or
|
|
11
|
-
yarn global add weapp-ide-cli
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
### 执行命令
|
|
15
|
-
|
|
16
|
-
```bash
|
|
17
|
-
weapp open
|
|
18
|
-
# 等价
|
|
19
|
-
weapp-ide-cli open
|
|
20
|
-
|
|
21
|
-
# 在当前命令行所在位置,打开微信开发者工具
|
|
22
|
-
weapp open -p
|
|
23
|
-
# 等价
|
|
24
|
-
weapp open --project
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
# 在相对的路径,打开微信开发者工具
|
|
28
|
-
# 比如 uni-app 就可以在项目目录执行
|
|
29
|
-
weapp open -p dist/dev/mp-weixin
|
|
30
|
-
#
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
## 常用命令
|
|
34
|
-
|
|
35
|
-
1. `weapp login` 在命令行进行微信扫码登录
|
|
36
|
-
2. `weapp open -p` 启动工具进行调试开发
|
|
37
|
-
3. `weapp preview` 开始预览
|
|
38
|
-
4. `weapp upload` 上传代码
|
|
39
|
-
5. `weapp quit` 关闭开发者工具
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
### 自定义配置
|
|
43
|
-
|
|
44
|
-
`weapp config` 可以对微信开发者工具的 `cli` 目录进行配置,而配置文件就存放在用户的 `${homedir}/.weapp-ide-cli/config.json` 中,您可以随时进行更改。
|
|
45
|
-
|
|
46
|
-
> 比如 windows 存放位置就在 `C:\Users\${你的用户名}\.weapp-ide-cli/config.json`
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
### 更多命令
|
|
50
|
-
|
|
51
|
-
这个工具本质是一个 `cli` 二次处理工具,所以绝大部分命令都是透传的。
|
|
52
|
-
|
|
1
|
+
# weapp-ide-cli
|
|
2
|
+
|
|
3
|
+
微信开发者工具的命令行(v2) 的一个二次封装的包裹实现,来让开发者更加方便的使用微信开发者工具。
|
|
4
|
+
|
|
5
|
+
> 要使用命令行,注意首先需要在开发者工具的设置 -> 安全设置中开启服务端口。
|
|
6
|
+
## 快速安装
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
npm i -g weapp-ide-cli
|
|
10
|
+
# or
|
|
11
|
+
yarn global add weapp-ide-cli
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
### 执行命令
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
weapp open
|
|
18
|
+
# 等价
|
|
19
|
+
weapp-ide-cli open
|
|
20
|
+
|
|
21
|
+
# 在当前命令行所在位置,打开微信开发者工具
|
|
22
|
+
weapp open -p
|
|
23
|
+
# 等价
|
|
24
|
+
weapp open --project
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
# 在相对的路径,打开微信开发者工具
|
|
28
|
+
# 比如 uni-app 就可以在项目目录执行
|
|
29
|
+
weapp open -p dist/dev/mp-weixin
|
|
30
|
+
# 工具会把相对路径转化为绝对路径,然后打开(绝对路径不转化)
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## 常用命令
|
|
34
|
+
|
|
35
|
+
1. `weapp login` 在命令行进行微信扫码登录
|
|
36
|
+
2. `weapp open -p` 启动工具进行调试开发
|
|
37
|
+
3. `weapp preview` 开始预览
|
|
38
|
+
4. `weapp upload` 上传代码
|
|
39
|
+
5. `weapp quit` 关闭开发者工具
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
### 自定义配置
|
|
43
|
+
|
|
44
|
+
`weapp config` 可以对微信开发者工具的 `cli` 目录进行配置,而配置文件就存放在用户的 `${homedir}/.weapp-ide-cli/config.json` 中,您可以随时进行更改。
|
|
45
|
+
|
|
46
|
+
> 比如 windows 存放位置就在 `C:\Users\${你的用户名}\.weapp-ide-cli/config.json`
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
### 更多命令
|
|
50
|
+
|
|
51
|
+
这个工具本质是一个 `cli` 二次处理工具,所以绝大部分命令都是透传的。
|
|
52
|
+
|
|
53
53
|
全部的命令请查看 https://developers.weixin.qq.com/miniprogram/dev/devtools/cli.html
|
package/bin/weapp.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
require('../dist/cli.js')
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
require('../dist/cli.js')
|
package/dist/cli.js
CHANGED
|
@@ -1,115 +1,99 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var utils = require('./utils-
|
|
4
|
-
var execa = require('execa');
|
|
5
|
-
var fs = require('fs/promises');
|
|
3
|
+
var utils = require('./utils-d05fca05.js');
|
|
6
4
|
var readline = require('readline');
|
|
7
|
-
var
|
|
5
|
+
var fs = require('fs/promises');
|
|
6
|
+
require('path');
|
|
8
7
|
require('os');
|
|
8
|
+
require('execa');
|
|
9
9
|
|
|
10
|
-
function
|
|
10
|
+
function createCustomConfig(params) {
|
|
11
|
+
return utils.__awaiter(this, void 0, void 0, function* () {
|
|
12
|
+
const isExisted = yield utils.exist(utils.defaultCustomConfigDirPath);
|
|
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
|
+
}
|
|
11
41
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
+
}
|
|
16
51
|
|
|
17
|
-
const rl =
|
|
18
|
-
input: process.stdin,
|
|
19
|
-
output: process.stdout
|
|
20
|
-
});
|
|
21
|
-
const isSupported = Boolean(utils.defaultPath);
|
|
22
|
-
const argv = process.argv.slice(2);
|
|
23
|
-
function
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
});
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
console.log(`全局配置存储位置:${utils.defaultCustomConfigFilePath}`);
|
|
65
|
-
resolve(cliPath);
|
|
66
|
-
}));
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
function main() {
|
|
70
|
-
var _a;
|
|
71
|
-
return utils.__awaiter(this, void 0, void 0, function* () {
|
|
72
|
-
if (isSupported) {
|
|
73
|
-
const { cliPath } = yield getConfig();
|
|
74
|
-
const isExisted = yield utils.exist(cliPath);
|
|
75
|
-
if (isExisted) {
|
|
76
|
-
if (argv[0] === 'config') {
|
|
77
|
-
yield rlSetConfig();
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
let projectOptionIdx = argv.indexOf('-p');
|
|
81
|
-
if (projectOptionIdx > -1) {
|
|
82
|
-
argv[projectOptionIdx] = '--project';
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
projectOptionIdx = argv.indexOf('--project');
|
|
86
|
-
}
|
|
87
|
-
if (projectOptionIdx > -1) {
|
|
88
|
-
const projectPathIdx = projectOptionIdx + 1;
|
|
89
|
-
const projectPath = argv[projectPathIdx];
|
|
90
|
-
if (projectPath) {
|
|
91
|
-
if (!path__default["default"].isAbsolute(projectPath)) {
|
|
92
|
-
argv[projectPathIdx] = path__default["default"].resolve(process.cwd(), projectPath);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
argv.splice(projectPathIdx, 0, process.cwd());
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
const task = execa__default["default"](cliPath, argv);
|
|
100
|
-
(_a = task === null || task === void 0 ? void 0 : task.stdout) === null || _a === void 0 ? void 0 : _a.pipe(process.stdout);
|
|
101
|
-
yield task;
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
console.log('在当前自定义路径中,未找到微信web开发者命令行工具,请重新指定路径');
|
|
105
|
-
yield rlSetConfig();
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
else {
|
|
109
|
-
console.log(`微信web开发者工具不支持当前平台:${utils.operatingSystemName} !`);
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
main().finally(() => {
|
|
114
|
-
process.exit();
|
|
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();
|
|
115
99
|
});
|
package/dist/index.js
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var utils = require('./utils-b22f3285.js');
|
|
3
|
+
var utils = require('./utils-d05fca05.js');
|
|
6
4
|
require('path');
|
|
7
5
|
require('os');
|
|
6
|
+
require('execa');
|
|
8
7
|
require('fs/promises');
|
|
9
8
|
|
|
10
9
|
|
|
11
10
|
|
|
11
|
+
exports.createAlias = utils.createAlias;
|
|
12
|
+
exports.createPathCompat = utils.createPathCompat;
|
|
12
13
|
exports.defaultCustomConfigDirPath = utils.defaultCustomConfigDirPath;
|
|
13
14
|
exports.defaultCustomConfigFilePath = utils.defaultCustomConfigFilePath;
|
|
14
15
|
exports.defaultPath = utils.defaultPath;
|
|
16
|
+
exports.execute = utils.execute;
|
|
15
17
|
exports.exist = utils.exist;
|
|
16
18
|
exports.operatingSystemName = utils.operatingSystemName;
|
|
19
|
+
exports.resolvePath = utils.resolvePath;
|
package/dist/types/cli.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function compose<TArgs extends any[]>(...funcs: TArgs): any;
|
package/dist/types/defaults.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const operatingSystemName: string;
|
|
2
|
-
export declare const defaultCustomConfigDirPath: string;
|
|
3
|
-
export declare const defaultCustomConfigFilePath: string;
|
|
4
|
-
export declare const defaultPath: string;
|
|
1
|
+
export declare const operatingSystemName: string;
|
|
2
|
+
export declare const defaultCustomConfigDirPath: string;
|
|
3
|
+
export declare const defaultCustomConfigFilePath: string;
|
|
4
|
+
export declare const defaultPath: string;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export type { IBaseConfig } from './types';
|
|
2
|
-
export * from './defaults';
|
|
3
|
-
export * from './utils';
|
|
1
|
+
export type { IBaseConfig } from './types';
|
|
2
|
+
export * from './defaults';
|
|
3
|
+
export * from './utils';
|
package/dist/types/types.d.ts
CHANGED
package/dist/types/utils.d.ts
CHANGED
|
@@ -1 +1,6 @@
|
|
|
1
|
-
|
|
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[];
|
|
@@ -2,29 +2,24 @@
|
|
|
2
2
|
|
|
3
3
|
var path = require('path');
|
|
4
4
|
var os = require('os');
|
|
5
|
+
var execa = require('execa');
|
|
5
6
|
var fs = require('fs/promises');
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
[SupportedPlatformsMap.Windows_NT]: 'C:\\Program Files (x86)\\Tencent\\微信web开发者工具\\cli.bat',
|
|
20
|
-
[SupportedPlatformsMap.Darwin]: '/Applications/wechatwebdevtools.app/Contents/MacOS/cli'
|
|
21
|
-
};
|
|
22
|
-
const operatingSystemName = os__default["default"].type();
|
|
23
|
-
const defaultCustomConfigDirPath = path__default["default"].join(homedir, '.weapp-ide-cli');
|
|
24
|
-
const defaultCustomConfigFilePath = path__default["default"].join(defaultCustomConfigDirPath, 'config.json');
|
|
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');
|
|
25
20
|
const defaultPath = defaultPathMap[operatingSystemName];
|
|
26
21
|
|
|
27
|
-
|
|
22
|
+
/*! *****************************************************************************
|
|
28
23
|
Copyright (c) Microsoft Corporation.
|
|
29
24
|
|
|
30
25
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -49,21 +44,85 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
49
44
|
});
|
|
50
45
|
}
|
|
51
46
|
|
|
52
|
-
function exist(filepath, mode) {
|
|
53
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
-
try {
|
|
55
|
-
yield
|
|
56
|
-
return true;
|
|
57
|
-
}
|
|
58
|
-
catch (error) {
|
|
59
|
-
return false;
|
|
60
|
-
}
|
|
61
|
-
});
|
|
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
|
+
};
|
|
62
117
|
}
|
|
63
118
|
|
|
64
119
|
exports.__awaiter = __awaiter;
|
|
120
|
+
exports.createAlias = createAlias;
|
|
121
|
+
exports.createPathCompat = createPathCompat;
|
|
65
122
|
exports.defaultCustomConfigDirPath = defaultCustomConfigDirPath;
|
|
66
123
|
exports.defaultCustomConfigFilePath = defaultCustomConfigFilePath;
|
|
67
124
|
exports.defaultPath = defaultPath;
|
|
125
|
+
exports.execute = execute;
|
|
68
126
|
exports.exist = exist;
|
|
69
127
|
exports.operatingSystemName = operatingSystemName;
|
|
128
|
+
exports.resolvePath = resolvePath;
|
package/package.json
CHANGED
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "weapp-ide-cli",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "让微信开发者工具,用起来更加方便吧!",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"module": "dist/index.js",
|
|
7
|
-
"types": "dist/types/index.d.ts",
|
|
8
|
-
"files": [
|
|
9
|
-
"dist",
|
|
10
|
-
"bin"
|
|
11
|
-
],
|
|
12
|
-
"bin": {
|
|
13
|
-
"weapp": "bin/weapp.js",
|
|
14
|
-
"weapp-ide-cli": "bin/weapp.js"
|
|
15
|
-
},
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"weapp",
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
},
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
},
|
|
48
|
-
"
|
|
49
|
-
|
|
50
|
-
"
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
"
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "weapp-ide-cli",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "让微信开发者工具,用起来更加方便吧!",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.js",
|
|
7
|
+
"types": "dist/types/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist",
|
|
10
|
+
"bin"
|
|
11
|
+
],
|
|
12
|
+
"bin": {
|
|
13
|
+
"weapp": "bin/weapp.js",
|
|
14
|
+
"weapp-ide-cli": "bin/weapp.js"
|
|
15
|
+
},
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public",
|
|
18
|
+
"registry": "https://registry.npmjs.org/"
|
|
19
|
+
},
|
|
20
|
+
"keywords": [
|
|
21
|
+
"weapp",
|
|
22
|
+
"weapp-cli",
|
|
23
|
+
"wechat",
|
|
24
|
+
"cli",
|
|
25
|
+
"uni-app",
|
|
26
|
+
"taro",
|
|
27
|
+
"ide",
|
|
28
|
+
"weapp-ide",
|
|
29
|
+
"mini",
|
|
30
|
+
"miniprogram"
|
|
31
|
+
],
|
|
32
|
+
"author": "SonOfMagic <qq1324318532@gmail.com>",
|
|
33
|
+
"license": "MIT",
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@icebreakers/rollup": "*",
|
|
36
|
+
"@icebreakers/tsconfig": "*"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"execa": "5.1.1"
|
|
40
|
+
},
|
|
41
|
+
"repository": {
|
|
42
|
+
"type": "git",
|
|
43
|
+
"url": "git+https://github.com/sonofmagic/utils.git"
|
|
44
|
+
},
|
|
45
|
+
"bugs": {
|
|
46
|
+
"url": "https://github.com/sonofmagic/utils/issues"
|
|
47
|
+
},
|
|
48
|
+
"homepage": "https://github.com/sonofmagic/utils/tree/main/packages/weapp-ide-cli#readme",
|
|
49
|
+
"scripts": {
|
|
50
|
+
"dev": "cross-env NODE_ENV=development rollup -cw",
|
|
51
|
+
"build": "cross-env NODE_ENV=production rollup -c",
|
|
52
|
+
"weapp": "ts-node src/cli.ts",
|
|
53
|
+
"debug": "ts-node src/cli.ts config",
|
|
54
|
+
"raw": "node bin/weapp.js"
|
|
55
|
+
}
|
|
56
|
+
}
|