@simon_he/pi 0.0.5 → 0.0.7
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 +15 -2
- package/dist/index.cjs +89 -49
- package/dist/index.d.ts +5 -4
- package/dist/index.mjs +90 -51
- package/dist/seprateThread.cjs +3 -1
- package/dist/seprateThread.mjs +3 -1
- package/package.json +13 -11
package/README.md
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
<span ><p align="center"></p></span>
|
|
2
2
|
|
|
3
3
|
## PI
|
|
4
|
-
一个带有自定义loading样式的smart包管理器,让你安装依赖时更加美观:)
|
|
4
|
+
一个带有自定义loading样式的smart包管理器,让你安装依赖时更加美观:)
|
|
5
|
+
|
|
6
|
+
## 聪明的包管理器
|
|
7
|
+
- 支持 go mod 的依赖安装、卸载、执行和打包
|
|
8
|
+
- 支持 Cargo 的依赖安装、卸载、执行和打包
|
|
9
|
+
- 支持 npm 的依赖安装、卸载和执行
|
|
10
|
+
- 支持 pnpm 的依赖安装、卸载和执行
|
|
11
|
+
- 支持 yarn 的依赖安装、卸载和执行
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
https://user-images.githubusercontent.com/57086651/203143603-9e78f686-399e-4c3d-ae53-56638501b276.mov
|
|
5
15
|
|
|
6
|
-
https://user-images.githubusercontent.com/57086651/200901242-34bc9576-b21c-4e2e-8e9c-9d858c9ffb12.mov
|
|
7
16
|
|
|
8
17
|
## 安装
|
|
9
18
|
```
|
|
@@ -19,6 +28,10 @@ https://user-images.githubusercontent.com/57086651/200901242-34bc9576-b21c-4e2e-
|
|
|
19
28
|
pui xxx
|
|
20
29
|
# 执行命令
|
|
21
30
|
prun
|
|
31
|
+
# 初始化
|
|
32
|
+
pinit
|
|
33
|
+
# 打包 - 针对cargo go
|
|
34
|
+
pbuild
|
|
22
35
|
```
|
|
23
36
|
|
|
24
37
|
## 自定义配置
|
package/dist/index.cjs
CHANGED
|
@@ -14,37 +14,25 @@ const path__default = /*#__PURE__*/_interopDefaultLegacy(path);
|
|
|
14
14
|
const process__default = /*#__PURE__*/_interopDefaultLegacy(process);
|
|
15
15
|
const ora__default = /*#__PURE__*/_interopDefaultLegacy(ora);
|
|
16
16
|
|
|
17
|
-
const version = "0.0.
|
|
17
|
+
const version = "0.0.7";
|
|
18
18
|
|
|
19
19
|
const __filename$1 = url$1.fileURLToPath((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('index.cjs', document.baseURI).href)));
|
|
20
20
|
const __dirname$1 = path__default.dirname(__filename$1);
|
|
21
21
|
const url = path__default.resolve(__dirname$1, "./seprateThread.mjs");
|
|
22
|
-
async function pi(
|
|
23
|
-
returnVersion(argv);
|
|
24
|
-
const { color, spinner } = await getStyle();
|
|
25
|
-
const params = argv.join(" ");
|
|
26
|
-
const pkg = argv.filter((v) => !v.startsWith("-")).join(" ");
|
|
22
|
+
async function pi(params, pkg) {
|
|
27
23
|
const text = pkg ? `Installing ${pkg} ...
|
|
28
24
|
` : "\u6B63\u5728\u66F4\u65B0\u4F9D\u8D56...\n";
|
|
29
25
|
const successMsg = pkg ? `Installed ${pkg} successfully! \u{1F60A}` : "\u66F4\u65B0\u4F9D\u8D56\u6210\u529F! \u{1F60A}";
|
|
30
26
|
const failMsg = pkg ? `Failed to install ${pkg} , v\u621150 \u{1F62D}` : "\u66F4\u65B0\u4F9D\u8D56\u5931\u8D25! \u{1F62D}";
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
spinner,
|
|
34
|
-
color
|
|
35
|
-
}).start();
|
|
36
|
-
const { status } = await simonJsTool.useNodeWorker(url, { params, operate: "install" });
|
|
27
|
+
const loading_status = await loading(text);
|
|
28
|
+
const { status } = await simonJsTool.useNodeWorker(url, `ni ${params}`);
|
|
37
29
|
if (status === 0)
|
|
38
|
-
|
|
30
|
+
loading_status.succeed(successMsg);
|
|
39
31
|
else
|
|
40
|
-
|
|
32
|
+
loading_status.fail(failMsg);
|
|
41
33
|
process__default.exit();
|
|
42
34
|
}
|
|
43
|
-
async function pui(
|
|
44
|
-
returnVersion(argv);
|
|
45
|
-
const { color, spinner } = await getStyle();
|
|
46
|
-
const params = argv.join(" ");
|
|
47
|
-
const pkg = argv.filter((v) => !v.startsWith("-")).join(" ");
|
|
35
|
+
async function pui(params, pkg) {
|
|
48
36
|
const text = `Uninstalling ${pkg} ...
|
|
49
37
|
`;
|
|
50
38
|
const successMsg = `unInstalled ${pkg} successfully! \u{1F60A}`;
|
|
@@ -53,23 +41,33 @@ async function pui(argv) {
|
|
|
53
41
|
console.log("\u8BF7\u8F93\u5165\u8981\u5378\u8F7D\u7684\u5305\u540D");
|
|
54
42
|
process__default.exit(1);
|
|
55
43
|
}
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
spinner,
|
|
59
|
-
color
|
|
60
|
-
}).start();
|
|
61
|
-
const { status } = await simonJsTool.useNodeWorker(url, { params, operate: "uninstall" });
|
|
44
|
+
const loading_status = await loading(text);
|
|
45
|
+
const { status } = await simonJsTool.useNodeWorker(url, `nun ${params}`);
|
|
62
46
|
if (status === 0)
|
|
63
|
-
|
|
47
|
+
loading_status.succeed(successMsg);
|
|
64
48
|
else
|
|
65
|
-
|
|
49
|
+
loading_status.fail(failMsg);
|
|
66
50
|
process__default.exit();
|
|
67
51
|
}
|
|
68
|
-
function prun(
|
|
69
|
-
returnVersion(argv);
|
|
70
|
-
const params = argv.join(" ");
|
|
52
|
+
function prun(params) {
|
|
71
53
|
simonJsTool.jsShell(`ccommand ${params}`);
|
|
72
54
|
}
|
|
55
|
+
function pinit() {
|
|
56
|
+
console.log("\u6B63\u5728\u521D\u59CB\u5316\u9879\u76EE...");
|
|
57
|
+
switch (simonJsTool.getPkgTool()) {
|
|
58
|
+
case "npm":
|
|
59
|
+
simonJsTool.jsShell("npm init -y");
|
|
60
|
+
return;
|
|
61
|
+
case "yarn":
|
|
62
|
+
simonJsTool.jsShell("yarn init -y");
|
|
63
|
+
return;
|
|
64
|
+
case "pnpm":
|
|
65
|
+
simonJsTool.jsShell("pnpm init -y");
|
|
66
|
+
return;
|
|
67
|
+
default:
|
|
68
|
+
simonJsTool.jsShell("npm init -y");
|
|
69
|
+
}
|
|
70
|
+
}
|
|
73
71
|
async function getStyle() {
|
|
74
72
|
const { result: _color = "yellow" } = await simonJsTool.jsShell("echo $PI_COLOR", "pipe");
|
|
75
73
|
const color = _color;
|
|
@@ -94,14 +92,15 @@ function returnVersion(argv) {
|
|
|
94
92
|
simonJsTool.jsShell(`gum style --foreground 212 --border-foreground 212 --border double --align center --width 50 --margin "1 2" --padding "2 4" 'pi version:${version}' '\u8BF7\u4E3A\u6211\u7684\u52AA\u529B\u70B9\u4E2Astar\u{1F31F}'`);
|
|
95
93
|
process__default.exit(0);
|
|
96
94
|
} else if (arg === "-h" || arg === "--help") {
|
|
97
|
-
simonJsTool.jsShell(`gum style --foreground 212 --border-foreground 212 --border double --align center --width 50 --margin "1 2" --padding "1 1" 'PI Commands:' 'pi: install package' 'pui: uninstall package' 'prun: run package script'`);
|
|
95
|
+
simonJsTool.jsShell(`gum style --foreground 212 --border-foreground 212 --border double --align center --width 50 --margin "1 2" --padding "1 1" 'PI Commands:' 'pi: install package' 'pui: uninstall package' 'prun: run package script' 'pinit: package init' 'pbuild: go build | cargo build'`);
|
|
98
96
|
process__default.exit(0);
|
|
99
97
|
}
|
|
100
98
|
}
|
|
101
99
|
const runMap = {
|
|
102
100
|
pi,
|
|
103
101
|
pui,
|
|
104
|
-
prun
|
|
102
|
+
prun,
|
|
103
|
+
pinit
|
|
105
104
|
};
|
|
106
105
|
function isGo() {
|
|
107
106
|
const { result } = simonJsTool.jsShell('test -f "go.mod" && echo "0"|| echo "1"', "pipe");
|
|
@@ -111,49 +110,90 @@ function isRust() {
|
|
|
111
110
|
const { result } = simonJsTool.jsShell('test -f "Cargo.toml" && echo "0"|| echo "1"', "pipe");
|
|
112
111
|
return result === "0";
|
|
113
112
|
}
|
|
113
|
+
async function loading(text) {
|
|
114
|
+
const { color, spinner } = await getStyle();
|
|
115
|
+
const result = ora__default({
|
|
116
|
+
text,
|
|
117
|
+
spinner,
|
|
118
|
+
color
|
|
119
|
+
}).start();
|
|
120
|
+
return result;
|
|
121
|
+
}
|
|
114
122
|
async function runner() {
|
|
115
123
|
const cmd = process__default.argv[1];
|
|
116
124
|
const last = cmd.lastIndexOf("/") + 1;
|
|
117
125
|
const exec = cmd.slice(last, cmd.length);
|
|
118
126
|
const argv = process__default.argv.slice(2);
|
|
127
|
+
returnVersion(argv);
|
|
128
|
+
const params = argv.join(" ");
|
|
119
129
|
if (isGo()) {
|
|
120
130
|
if (exec === "pi") {
|
|
121
|
-
|
|
122
|
-
|
|
131
|
+
const loading_status = await loading(`Installing ${params} ...
|
|
132
|
+
`);
|
|
133
|
+
const { status } = await simonJsTool.useNodeWorker(url, `go get ${params}`);
|
|
134
|
+
if (status === 0)
|
|
135
|
+
loading_status.succeed("Installed successfully! \u{1F60A}");
|
|
136
|
+
else
|
|
137
|
+
loading_status.fail("Failed to install \u{1F62D}");
|
|
123
138
|
} else if (exec === "pui") {
|
|
124
|
-
|
|
125
|
-
|
|
139
|
+
const loading_status = await loading(`Uninstalling ${params} ...
|
|
140
|
+
`);
|
|
141
|
+
const { status } = await simonJsTool.useNodeWorker(url, `go clean ${params}`);
|
|
142
|
+
if (status === 0)
|
|
143
|
+
loading_status.succeed("Uninstalled successfully! \u{1F60A}");
|
|
144
|
+
else
|
|
145
|
+
loading_status.fail("Failed to uninstall \u{1F62D}");
|
|
126
146
|
} else if (exec === "prun") {
|
|
127
|
-
simonJsTool.jsShell(`go run ${
|
|
128
|
-
|
|
147
|
+
simonJsTool.jsShell(`go run ${params}`);
|
|
148
|
+
} else if (exec === "pinit") {
|
|
149
|
+
simonJsTool.jsShell(`go mod init ${params}`);
|
|
150
|
+
} else if (exec === "pbuild") {
|
|
151
|
+
simonJsTool.jsShell(`go build ${params}`);
|
|
152
|
+
} else {
|
|
153
|
+
console.log("go mod \u9879\u76EE\u6682\u4E0D\u652F\u6301\u5176\u4ED6\u547D\u4EE4");
|
|
129
154
|
}
|
|
130
|
-
|
|
131
|
-
return;
|
|
155
|
+
process__default.exit();
|
|
132
156
|
}
|
|
133
157
|
if (isRust()) {
|
|
134
158
|
if (exec === "pi") {
|
|
135
|
-
|
|
136
|
-
|
|
159
|
+
const loading_status = await loading(`Installing ${params} ...
|
|
160
|
+
`);
|
|
161
|
+
const { status } = await simonJsTool.useNodeWorker(url, `cargo install ${params}`);
|
|
162
|
+
if (status === 0)
|
|
163
|
+
loading_status.succeed("installed successfully! \u{1F60A}");
|
|
164
|
+
else
|
|
165
|
+
loading_status.fail("Failed to install \u{1F62D}");
|
|
137
166
|
} else if (exec === "pui") {
|
|
138
|
-
|
|
139
|
-
|
|
167
|
+
const loading_status = await loading(`Uninstalling ${params} ...
|
|
168
|
+
`);
|
|
169
|
+
const { status } = await simonJsTool.useNodeWorker(url, `cargo uninstall ${params}`);
|
|
170
|
+
if (status === 0)
|
|
171
|
+
loading_status.succeed("Uninstalled successfully! \u{1F60A}");
|
|
172
|
+
else
|
|
173
|
+
loading_status.fail("Failed to uninstall \u{1F62D}");
|
|
140
174
|
} else if (exec === "prun") {
|
|
141
|
-
simonJsTool.jsShell(`cargo run ${
|
|
142
|
-
|
|
175
|
+
simonJsTool.jsShell(`cargo run ${params}`);
|
|
176
|
+
} else if (exec === "pinit") {
|
|
177
|
+
simonJsTool.jsShell(`cargo init ${params}`);
|
|
178
|
+
} else if (exec === "pbuild") {
|
|
179
|
+
simonJsTool.jsShell(`cargo build ${params}`);
|
|
180
|
+
} else {
|
|
181
|
+
console.log("Cargo \u9879\u76EE\u6682\u4E0D\u652F\u6301\u5176\u4ED6\u547D\u4EE4");
|
|
143
182
|
}
|
|
144
|
-
|
|
145
|
-
return;
|
|
183
|
+
process__default.exit();
|
|
146
184
|
}
|
|
147
185
|
if (!runMap[exec]) {
|
|
148
186
|
console.log("\u547D\u4EE4\u4E0D\u5B58\u5728,\u8BF7\u6267\u884Cpi -h\u67E5\u770B\u5E2E\u52A9");
|
|
149
187
|
return;
|
|
150
188
|
}
|
|
189
|
+
const pkg = argv.filter((v) => !v.startsWith("-")).join(" ");
|
|
151
190
|
await installDeps();
|
|
152
|
-
runMap[exec](
|
|
191
|
+
runMap[exec](params, pkg);
|
|
153
192
|
}
|
|
154
193
|
runner();
|
|
155
194
|
|
|
156
195
|
exports.pi = pi;
|
|
196
|
+
exports.pinit = pinit;
|
|
157
197
|
exports.prun = prun;
|
|
158
198
|
exports.pui = pui;
|
|
159
199
|
exports.runner = runner;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
declare function pi(
|
|
2
|
-
declare function pui(
|
|
3
|
-
declare function prun(
|
|
1
|
+
declare function pi(params: string[], pkg: string): Promise<void>;
|
|
2
|
+
declare function pui(params: string[], pkg: string): Promise<void>;
|
|
3
|
+
declare function prun(params: string[]): void;
|
|
4
|
+
declare function pinit(): void;
|
|
4
5
|
declare function runner(): Promise<void>;
|
|
5
6
|
|
|
6
|
-
export { pi, prun, pui, runner };
|
|
7
|
+
export { pi, pinit, prun, pui, runner };
|
package/dist/index.mjs
CHANGED
|
@@ -1,40 +1,28 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
2
|
import process from 'process';
|
|
3
3
|
import { fileURLToPath } from 'url';
|
|
4
|
-
import { useNodeWorker, jsShell } from 'simon-js-tool';
|
|
4
|
+
import { useNodeWorker, jsShell, getPkgTool } from 'simon-js-tool';
|
|
5
5
|
import ora from 'ora';
|
|
6
6
|
|
|
7
|
-
const version = "0.0.
|
|
7
|
+
const version = "0.0.7";
|
|
8
8
|
|
|
9
9
|
const __filename = fileURLToPath(import.meta.url);
|
|
10
10
|
const __dirname = path.dirname(__filename);
|
|
11
11
|
const url = path.resolve(__dirname, "./seprateThread.mjs");
|
|
12
|
-
async function pi(
|
|
13
|
-
returnVersion(argv);
|
|
14
|
-
const { color, spinner } = await getStyle();
|
|
15
|
-
const params = argv.join(" ");
|
|
16
|
-
const pkg = argv.filter((v) => !v.startsWith("-")).join(" ");
|
|
12
|
+
async function pi(params, pkg) {
|
|
17
13
|
const text = pkg ? `Installing ${pkg} ...
|
|
18
14
|
` : "\u6B63\u5728\u66F4\u65B0\u4F9D\u8D56...\n";
|
|
19
15
|
const successMsg = pkg ? `Installed ${pkg} successfully! \u{1F60A}` : "\u66F4\u65B0\u4F9D\u8D56\u6210\u529F! \u{1F60A}";
|
|
20
16
|
const failMsg = pkg ? `Failed to install ${pkg} , v\u621150 \u{1F62D}` : "\u66F4\u65B0\u4F9D\u8D56\u5931\u8D25! \u{1F62D}";
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
spinner,
|
|
24
|
-
color
|
|
25
|
-
}).start();
|
|
26
|
-
const { status } = await useNodeWorker(url, { params, operate: "install" });
|
|
17
|
+
const loading_status = await loading(text);
|
|
18
|
+
const { status } = await useNodeWorker(url, `ni ${params}`);
|
|
27
19
|
if (status === 0)
|
|
28
|
-
|
|
20
|
+
loading_status.succeed(successMsg);
|
|
29
21
|
else
|
|
30
|
-
|
|
22
|
+
loading_status.fail(failMsg);
|
|
31
23
|
process.exit();
|
|
32
24
|
}
|
|
33
|
-
async function pui(
|
|
34
|
-
returnVersion(argv);
|
|
35
|
-
const { color, spinner } = await getStyle();
|
|
36
|
-
const params = argv.join(" ");
|
|
37
|
-
const pkg = argv.filter((v) => !v.startsWith("-")).join(" ");
|
|
25
|
+
async function pui(params, pkg) {
|
|
38
26
|
const text = `Uninstalling ${pkg} ...
|
|
39
27
|
`;
|
|
40
28
|
const successMsg = `unInstalled ${pkg} successfully! \u{1F60A}`;
|
|
@@ -43,23 +31,33 @@ async function pui(argv) {
|
|
|
43
31
|
console.log("\u8BF7\u8F93\u5165\u8981\u5378\u8F7D\u7684\u5305\u540D");
|
|
44
32
|
process.exit(1);
|
|
45
33
|
}
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
spinner,
|
|
49
|
-
color
|
|
50
|
-
}).start();
|
|
51
|
-
const { status } = await useNodeWorker(url, { params, operate: "uninstall" });
|
|
34
|
+
const loading_status = await loading(text);
|
|
35
|
+
const { status } = await useNodeWorker(url, `nun ${params}`);
|
|
52
36
|
if (status === 0)
|
|
53
|
-
|
|
37
|
+
loading_status.succeed(successMsg);
|
|
54
38
|
else
|
|
55
|
-
|
|
39
|
+
loading_status.fail(failMsg);
|
|
56
40
|
process.exit();
|
|
57
41
|
}
|
|
58
|
-
function prun(
|
|
59
|
-
returnVersion(argv);
|
|
60
|
-
const params = argv.join(" ");
|
|
42
|
+
function prun(params) {
|
|
61
43
|
jsShell(`ccommand ${params}`);
|
|
62
44
|
}
|
|
45
|
+
function pinit() {
|
|
46
|
+
console.log("\u6B63\u5728\u521D\u59CB\u5316\u9879\u76EE...");
|
|
47
|
+
switch (getPkgTool()) {
|
|
48
|
+
case "npm":
|
|
49
|
+
jsShell("npm init -y");
|
|
50
|
+
return;
|
|
51
|
+
case "yarn":
|
|
52
|
+
jsShell("yarn init -y");
|
|
53
|
+
return;
|
|
54
|
+
case "pnpm":
|
|
55
|
+
jsShell("pnpm init -y");
|
|
56
|
+
return;
|
|
57
|
+
default:
|
|
58
|
+
jsShell("npm init -y");
|
|
59
|
+
}
|
|
60
|
+
}
|
|
63
61
|
async function getStyle() {
|
|
64
62
|
const { result: _color = "yellow" } = await jsShell("echo $PI_COLOR", "pipe");
|
|
65
63
|
const color = _color;
|
|
@@ -84,14 +82,15 @@ function returnVersion(argv) {
|
|
|
84
82
|
jsShell(`gum style --foreground 212 --border-foreground 212 --border double --align center --width 50 --margin "1 2" --padding "2 4" 'pi version:${version}' '\u8BF7\u4E3A\u6211\u7684\u52AA\u529B\u70B9\u4E2Astar\u{1F31F}'`);
|
|
85
83
|
process.exit(0);
|
|
86
84
|
} else if (arg === "-h" || arg === "--help") {
|
|
87
|
-
jsShell(`gum style --foreground 212 --border-foreground 212 --border double --align center --width 50 --margin "1 2" --padding "1 1" 'PI Commands:' 'pi: install package' 'pui: uninstall package' 'prun: run package script'`);
|
|
85
|
+
jsShell(`gum style --foreground 212 --border-foreground 212 --border double --align center --width 50 --margin "1 2" --padding "1 1" 'PI Commands:' 'pi: install package' 'pui: uninstall package' 'prun: run package script' 'pinit: package init' 'pbuild: go build | cargo build'`);
|
|
88
86
|
process.exit(0);
|
|
89
87
|
}
|
|
90
88
|
}
|
|
91
89
|
const runMap = {
|
|
92
90
|
pi,
|
|
93
91
|
pui,
|
|
94
|
-
prun
|
|
92
|
+
prun,
|
|
93
|
+
pinit
|
|
95
94
|
};
|
|
96
95
|
function isGo() {
|
|
97
96
|
const { result } = jsShell('test -f "go.mod" && echo "0"|| echo "1"', "pipe");
|
|
@@ -101,46 +100,86 @@ function isRust() {
|
|
|
101
100
|
const { result } = jsShell('test -f "Cargo.toml" && echo "0"|| echo "1"', "pipe");
|
|
102
101
|
return result === "0";
|
|
103
102
|
}
|
|
103
|
+
async function loading(text) {
|
|
104
|
+
const { color, spinner } = await getStyle();
|
|
105
|
+
const result = ora({
|
|
106
|
+
text,
|
|
107
|
+
spinner,
|
|
108
|
+
color
|
|
109
|
+
}).start();
|
|
110
|
+
return result;
|
|
111
|
+
}
|
|
104
112
|
async function runner() {
|
|
105
113
|
const cmd = process.argv[1];
|
|
106
114
|
const last = cmd.lastIndexOf("/") + 1;
|
|
107
115
|
const exec = cmd.slice(last, cmd.length);
|
|
108
116
|
const argv = process.argv.slice(2);
|
|
117
|
+
returnVersion(argv);
|
|
118
|
+
const params = argv.join(" ");
|
|
109
119
|
if (isGo()) {
|
|
110
120
|
if (exec === "pi") {
|
|
111
|
-
|
|
112
|
-
|
|
121
|
+
const loading_status = await loading(`Installing ${params} ...
|
|
122
|
+
`);
|
|
123
|
+
const { status } = await useNodeWorker(url, `go get ${params}`);
|
|
124
|
+
if (status === 0)
|
|
125
|
+
loading_status.succeed("Installed successfully! \u{1F60A}");
|
|
126
|
+
else
|
|
127
|
+
loading_status.fail("Failed to install \u{1F62D}");
|
|
113
128
|
} else if (exec === "pui") {
|
|
114
|
-
|
|
115
|
-
|
|
129
|
+
const loading_status = await loading(`Uninstalling ${params} ...
|
|
130
|
+
`);
|
|
131
|
+
const { status } = await useNodeWorker(url, `go clean ${params}`);
|
|
132
|
+
if (status === 0)
|
|
133
|
+
loading_status.succeed("Uninstalled successfully! \u{1F60A}");
|
|
134
|
+
else
|
|
135
|
+
loading_status.fail("Failed to uninstall \u{1F62D}");
|
|
116
136
|
} else if (exec === "prun") {
|
|
117
|
-
jsShell(`go run ${
|
|
118
|
-
|
|
137
|
+
jsShell(`go run ${params}`);
|
|
138
|
+
} else if (exec === "pinit") {
|
|
139
|
+
jsShell(`go mod init ${params}`);
|
|
140
|
+
} else if (exec === "pbuild") {
|
|
141
|
+
jsShell(`go build ${params}`);
|
|
142
|
+
} else {
|
|
143
|
+
console.log("go mod \u9879\u76EE\u6682\u4E0D\u652F\u6301\u5176\u4ED6\u547D\u4EE4");
|
|
119
144
|
}
|
|
120
|
-
|
|
121
|
-
return;
|
|
145
|
+
process.exit();
|
|
122
146
|
}
|
|
123
147
|
if (isRust()) {
|
|
124
148
|
if (exec === "pi") {
|
|
125
|
-
|
|
126
|
-
|
|
149
|
+
const loading_status = await loading(`Installing ${params} ...
|
|
150
|
+
`);
|
|
151
|
+
const { status } = await useNodeWorker(url, `cargo install ${params}`);
|
|
152
|
+
if (status === 0)
|
|
153
|
+
loading_status.succeed("installed successfully! \u{1F60A}");
|
|
154
|
+
else
|
|
155
|
+
loading_status.fail("Failed to install \u{1F62D}");
|
|
127
156
|
} else if (exec === "pui") {
|
|
128
|
-
|
|
129
|
-
|
|
157
|
+
const loading_status = await loading(`Uninstalling ${params} ...
|
|
158
|
+
`);
|
|
159
|
+
const { status } = await useNodeWorker(url, `cargo uninstall ${params}`);
|
|
160
|
+
if (status === 0)
|
|
161
|
+
loading_status.succeed("Uninstalled successfully! \u{1F60A}");
|
|
162
|
+
else
|
|
163
|
+
loading_status.fail("Failed to uninstall \u{1F62D}");
|
|
130
164
|
} else if (exec === "prun") {
|
|
131
|
-
jsShell(`cargo run ${
|
|
132
|
-
|
|
165
|
+
jsShell(`cargo run ${params}`);
|
|
166
|
+
} else if (exec === "pinit") {
|
|
167
|
+
jsShell(`cargo init ${params}`);
|
|
168
|
+
} else if (exec === "pbuild") {
|
|
169
|
+
jsShell(`cargo build ${params}`);
|
|
170
|
+
} else {
|
|
171
|
+
console.log("Cargo \u9879\u76EE\u6682\u4E0D\u652F\u6301\u5176\u4ED6\u547D\u4EE4");
|
|
133
172
|
}
|
|
134
|
-
|
|
135
|
-
return;
|
|
173
|
+
process.exit();
|
|
136
174
|
}
|
|
137
175
|
if (!runMap[exec]) {
|
|
138
176
|
console.log("\u547D\u4EE4\u4E0D\u5B58\u5728,\u8BF7\u6267\u884Cpi -h\u67E5\u770B\u5E2E\u52A9");
|
|
139
177
|
return;
|
|
140
178
|
}
|
|
179
|
+
const pkg = argv.filter((v) => !v.startsWith("-")).join(" ");
|
|
141
180
|
await installDeps();
|
|
142
|
-
runMap[exec](
|
|
181
|
+
runMap[exec](params, pkg);
|
|
143
182
|
}
|
|
144
183
|
runner();
|
|
145
184
|
|
|
146
|
-
export { pi, prun, pui, runner };
|
|
185
|
+
export { pi, pinit, prun, pui, runner };
|
package/dist/seprateThread.cjs
CHANGED
|
@@ -2,4 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
const simonJsTool = require('simon-js-tool');
|
|
4
4
|
|
|
5
|
-
simonJsTool.useProcressNodeWorker(
|
|
5
|
+
simonJsTool.useProcressNodeWorker(
|
|
6
|
+
async (command) => simonJsTool.jsShell(`${command}`, "pipe")
|
|
7
|
+
);
|
package/dist/seprateThread.mjs
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { useProcressNodeWorker, jsShell } from 'simon-js-tool';
|
|
2
2
|
|
|
3
|
-
useProcressNodeWorker(
|
|
3
|
+
useProcressNodeWorker(
|
|
4
|
+
async (command) => jsShell(`${command}`, "pipe")
|
|
5
|
+
);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simon_he/pi",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.7",
|
|
5
5
|
"packageManager": "pnpm@7.2.1",
|
|
6
6
|
"description": "",
|
|
7
7
|
"author": "Simon He",
|
|
@@ -36,7 +36,9 @@
|
|
|
36
36
|
"bin": {
|
|
37
37
|
"pi": "./cli.mjs",
|
|
38
38
|
"pui": "./cli.mjs",
|
|
39
|
-
"prun": "./cli.mjs"
|
|
39
|
+
"prun": "./cli.mjs",
|
|
40
|
+
"pinit": "./cli.mjs",
|
|
41
|
+
"pbuild": "./cli.mjs"
|
|
40
42
|
},
|
|
41
43
|
"files": [
|
|
42
44
|
"dist"
|
|
@@ -59,22 +61,22 @@
|
|
|
59
61
|
"dot-text": "^1.0.7",
|
|
60
62
|
"libnpmsearch": "^6.0.0",
|
|
61
63
|
"ora": "^6.1.2",
|
|
62
|
-
"simon-js-tool": "^4.1.
|
|
64
|
+
"simon-js-tool": "^4.1.27",
|
|
63
65
|
"terminal-kit": "^3.0.0",
|
|
64
66
|
"terminal-link": "^3.0.0",
|
|
65
|
-
"vitest": "^0.25.
|
|
67
|
+
"vitest": "^0.25.2"
|
|
66
68
|
},
|
|
67
69
|
"devDependencies": {
|
|
68
|
-
"@antfu/eslint-config": "^0.25.
|
|
69
|
-
"@antfu/ni": "^0.16.
|
|
70
|
+
"@antfu/eslint-config": "^0.25.2",
|
|
71
|
+
"@antfu/ni": "^0.16.3",
|
|
70
72
|
"@antfu/utils": "^0.5.2",
|
|
71
|
-
"@types/node": "^18.
|
|
73
|
+
"@types/node": "^18.11.9",
|
|
72
74
|
"bumpp": "^8.2.1",
|
|
73
|
-
"eslint": "^8.
|
|
75
|
+
"eslint": "^8.28.0",
|
|
74
76
|
"esno": "^0.16.3",
|
|
75
|
-
"pnpm": "^7.
|
|
77
|
+
"pnpm": "^7.17.0",
|
|
76
78
|
"rimraf": "^3.0.2",
|
|
77
|
-
"typescript": "^4.
|
|
78
|
-
"unbuild": "^0.7.
|
|
79
|
+
"typescript": "^4.9.3",
|
|
80
|
+
"unbuild": "^0.7.6"
|
|
79
81
|
}
|
|
80
82
|
}
|