@simon_he/pi 0.0.6 → 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 +9 -5
- package/dist/index.cjs +43 -34
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +43 -34
- package/dist/seprateThread.cjs +1 -1
- package/dist/seprateThread.mjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
一个带有自定义loading样式的smart包管理器,让你安装依赖时更加美观:)
|
|
5
5
|
|
|
6
6
|
## 聪明的包管理器
|
|
7
|
-
- 支持go mod
|
|
8
|
-
- 支持Cargo
|
|
9
|
-
- 支持npm
|
|
10
|
-
- 支持pnpm
|
|
11
|
-
- 支持yarn
|
|
7
|
+
- 支持 go mod 的依赖安装、卸载、执行和打包
|
|
8
|
+
- 支持 Cargo 的依赖安装、卸载、执行和打包
|
|
9
|
+
- 支持 npm 的依赖安装、卸载和执行
|
|
10
|
+
- 支持 pnpm 的依赖安装、卸载和执行
|
|
11
|
+
- 支持 yarn 的依赖安装、卸载和执行
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
https://user-images.githubusercontent.com/57086651/203143603-9e78f686-399e-4c3d-ae53-56638501b276.mov
|
|
@@ -28,6 +28,10 @@ https://user-images.githubusercontent.com/57086651/203143603-9e78f686-399e-4c3d-
|
|
|
28
28
|
pui xxx
|
|
29
29
|
# 执行命令
|
|
30
30
|
prun
|
|
31
|
+
# 初始化
|
|
32
|
+
pinit
|
|
33
|
+
# 打包 - 针对cargo go
|
|
34
|
+
pbuild
|
|
31
35
|
```
|
|
32
36
|
|
|
33
37
|
## 自定义配置
|
package/dist/index.cjs
CHANGED
|
@@ -14,7 +14,7 @@ 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);
|
|
@@ -24,12 +24,12 @@ async function pi(params, pkg) {
|
|
|
24
24
|
` : "\u6B63\u5728\u66F4\u65B0\u4F9D\u8D56...\n";
|
|
25
25
|
const successMsg = pkg ? `Installed ${pkg} successfully! \u{1F60A}` : "\u66F4\u65B0\u4F9D\u8D56\u6210\u529F! \u{1F60A}";
|
|
26
26
|
const failMsg = pkg ? `Failed to install ${pkg} , v\u621150 \u{1F62D}` : "\u66F4\u65B0\u4F9D\u8D56\u5931\u8D25! \u{1F62D}";
|
|
27
|
-
const
|
|
28
|
-
const { status } = await simonJsTool.useNodeWorker(url, {
|
|
27
|
+
const loading_status = await loading(text);
|
|
28
|
+
const { status } = await simonJsTool.useNodeWorker(url, `ni ${params}`);
|
|
29
29
|
if (status === 0)
|
|
30
|
-
succeed(successMsg);
|
|
30
|
+
loading_status.succeed(successMsg);
|
|
31
31
|
else
|
|
32
|
-
fail(failMsg);
|
|
32
|
+
loading_status.fail(failMsg);
|
|
33
33
|
process__default.exit();
|
|
34
34
|
}
|
|
35
35
|
async function pui(params, pkg) {
|
|
@@ -41,18 +41,18 @@ async function pui(params, pkg) {
|
|
|
41
41
|
console.log("\u8BF7\u8F93\u5165\u8981\u5378\u8F7D\u7684\u5305\u540D");
|
|
42
42
|
process__default.exit(1);
|
|
43
43
|
}
|
|
44
|
-
const
|
|
45
|
-
const { status } = await simonJsTool.useNodeWorker(url, {
|
|
44
|
+
const loading_status = await loading(text);
|
|
45
|
+
const { status } = await simonJsTool.useNodeWorker(url, `nun ${params}`);
|
|
46
46
|
if (status === 0)
|
|
47
|
-
succeed(successMsg);
|
|
47
|
+
loading_status.succeed(successMsg);
|
|
48
48
|
else
|
|
49
|
-
fail(failMsg);
|
|
49
|
+
loading_status.fail(failMsg);
|
|
50
50
|
process__default.exit();
|
|
51
51
|
}
|
|
52
|
-
function prun(params
|
|
52
|
+
function prun(params) {
|
|
53
53
|
simonJsTool.jsShell(`ccommand ${params}`);
|
|
54
54
|
}
|
|
55
|
-
function pinit(
|
|
55
|
+
function pinit() {
|
|
56
56
|
console.log("\u6B63\u5728\u521D\u59CB\u5316\u9879\u76EE...");
|
|
57
57
|
switch (simonJsTool.getPkgTool()) {
|
|
58
58
|
case "npm":
|
|
@@ -112,11 +112,12 @@ function isRust() {
|
|
|
112
112
|
}
|
|
113
113
|
async function loading(text) {
|
|
114
114
|
const { color, spinner } = await getStyle();
|
|
115
|
-
|
|
115
|
+
const result = ora__default({
|
|
116
116
|
text,
|
|
117
117
|
spinner,
|
|
118
118
|
color
|
|
119
119
|
}).start();
|
|
120
|
+
return result;
|
|
120
121
|
}
|
|
121
122
|
async function runner() {
|
|
122
123
|
const cmd = process__default.argv[1];
|
|
@@ -127,51 +128,59 @@ async function runner() {
|
|
|
127
128
|
const params = argv.join(" ");
|
|
128
129
|
if (isGo()) {
|
|
129
130
|
if (exec === "pi") {
|
|
130
|
-
loading(`Installing ${params} ...
|
|
131
|
+
const loading_status = await loading(`Installing ${params} ...
|
|
131
132
|
`);
|
|
132
|
-
simonJsTool.
|
|
133
|
-
|
|
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}");
|
|
134
138
|
} else if (exec === "pui") {
|
|
135
|
-
loading(`Uninstalling ${params} ...
|
|
139
|
+
const loading_status = await loading(`Uninstalling ${params} ...
|
|
136
140
|
`);
|
|
137
|
-
simonJsTool.
|
|
138
|
-
|
|
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}");
|
|
139
146
|
} else if (exec === "prun") {
|
|
140
147
|
simonJsTool.jsShell(`go run ${params}`);
|
|
141
|
-
return;
|
|
142
148
|
} else if (exec === "pinit") {
|
|
143
149
|
simonJsTool.jsShell(`go mod init ${params}`);
|
|
144
|
-
return;
|
|
145
150
|
} else if (exec === "pbuild") {
|
|
146
151
|
simonJsTool.jsShell(`go build ${params}`);
|
|
147
|
-
|
|
152
|
+
} else {
|
|
153
|
+
console.log("go mod \u9879\u76EE\u6682\u4E0D\u652F\u6301\u5176\u4ED6\u547D\u4EE4");
|
|
148
154
|
}
|
|
149
|
-
|
|
150
|
-
return;
|
|
155
|
+
process__default.exit();
|
|
151
156
|
}
|
|
152
157
|
if (isRust()) {
|
|
153
158
|
if (exec === "pi") {
|
|
154
|
-
loading(`Installing ${params} ...
|
|
159
|
+
const loading_status = await loading(`Installing ${params} ...
|
|
155
160
|
`);
|
|
156
|
-
simonJsTool.
|
|
157
|
-
|
|
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}");
|
|
158
166
|
} else if (exec === "pui") {
|
|
159
|
-
loading(`Uninstalling ${params} ...
|
|
167
|
+
const loading_status = await loading(`Uninstalling ${params} ...
|
|
160
168
|
`);
|
|
161
|
-
simonJsTool.
|
|
162
|
-
|
|
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}");
|
|
163
174
|
} else if (exec === "prun") {
|
|
164
175
|
simonJsTool.jsShell(`cargo run ${params}`);
|
|
165
|
-
return;
|
|
166
176
|
} else if (exec === "pinit") {
|
|
167
177
|
simonJsTool.jsShell(`cargo init ${params}`);
|
|
168
|
-
return;
|
|
169
178
|
} else if (exec === "pbuild") {
|
|
170
179
|
simonJsTool.jsShell(`cargo build ${params}`);
|
|
171
|
-
|
|
180
|
+
} else {
|
|
181
|
+
console.log("Cargo \u9879\u76EE\u6682\u4E0D\u652F\u6301\u5176\u4ED6\u547D\u4EE4");
|
|
172
182
|
}
|
|
173
|
-
|
|
174
|
-
return;
|
|
183
|
+
process__default.exit();
|
|
175
184
|
}
|
|
176
185
|
if (!runMap[exec]) {
|
|
177
186
|
console.log("\u547D\u4EE4\u4E0D\u5B58\u5728,\u8BF7\u6267\u884Cpi -h\u67E5\u770B\u5E2E\u52A9");
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
declare function pi(params: string[], pkg: string): Promise<void>;
|
|
2
2
|
declare function pui(params: string[], pkg: string): Promise<void>;
|
|
3
|
-
declare function prun(params: string[]
|
|
4
|
-
declare function pinit(
|
|
3
|
+
declare function prun(params: string[]): void;
|
|
4
|
+
declare function pinit(): void;
|
|
5
5
|
declare function runner(): Promise<void>;
|
|
6
6
|
|
|
7
7
|
export { pi, pinit, prun, pui, runner };
|
package/dist/index.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { fileURLToPath } from 'url';
|
|
|
4
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);
|
|
@@ -14,12 +14,12 @@ async function pi(params, pkg) {
|
|
|
14
14
|
` : "\u6B63\u5728\u66F4\u65B0\u4F9D\u8D56...\n";
|
|
15
15
|
const successMsg = pkg ? `Installed ${pkg} successfully! \u{1F60A}` : "\u66F4\u65B0\u4F9D\u8D56\u6210\u529F! \u{1F60A}";
|
|
16
16
|
const failMsg = pkg ? `Failed to install ${pkg} , v\u621150 \u{1F62D}` : "\u66F4\u65B0\u4F9D\u8D56\u5931\u8D25! \u{1F62D}";
|
|
17
|
-
const
|
|
18
|
-
const { status } = await useNodeWorker(url, {
|
|
17
|
+
const loading_status = await loading(text);
|
|
18
|
+
const { status } = await useNodeWorker(url, `ni ${params}`);
|
|
19
19
|
if (status === 0)
|
|
20
|
-
succeed(successMsg);
|
|
20
|
+
loading_status.succeed(successMsg);
|
|
21
21
|
else
|
|
22
|
-
fail(failMsg);
|
|
22
|
+
loading_status.fail(failMsg);
|
|
23
23
|
process.exit();
|
|
24
24
|
}
|
|
25
25
|
async function pui(params, pkg) {
|
|
@@ -31,18 +31,18 @@ async function pui(params, pkg) {
|
|
|
31
31
|
console.log("\u8BF7\u8F93\u5165\u8981\u5378\u8F7D\u7684\u5305\u540D");
|
|
32
32
|
process.exit(1);
|
|
33
33
|
}
|
|
34
|
-
const
|
|
35
|
-
const { status } = await useNodeWorker(url, {
|
|
34
|
+
const loading_status = await loading(text);
|
|
35
|
+
const { status } = await useNodeWorker(url, `nun ${params}`);
|
|
36
36
|
if (status === 0)
|
|
37
|
-
succeed(successMsg);
|
|
37
|
+
loading_status.succeed(successMsg);
|
|
38
38
|
else
|
|
39
|
-
fail(failMsg);
|
|
39
|
+
loading_status.fail(failMsg);
|
|
40
40
|
process.exit();
|
|
41
41
|
}
|
|
42
|
-
function prun(params
|
|
42
|
+
function prun(params) {
|
|
43
43
|
jsShell(`ccommand ${params}`);
|
|
44
44
|
}
|
|
45
|
-
function pinit(
|
|
45
|
+
function pinit() {
|
|
46
46
|
console.log("\u6B63\u5728\u521D\u59CB\u5316\u9879\u76EE...");
|
|
47
47
|
switch (getPkgTool()) {
|
|
48
48
|
case "npm":
|
|
@@ -102,11 +102,12 @@ function isRust() {
|
|
|
102
102
|
}
|
|
103
103
|
async function loading(text) {
|
|
104
104
|
const { color, spinner } = await getStyle();
|
|
105
|
-
|
|
105
|
+
const result = ora({
|
|
106
106
|
text,
|
|
107
107
|
spinner,
|
|
108
108
|
color
|
|
109
109
|
}).start();
|
|
110
|
+
return result;
|
|
110
111
|
}
|
|
111
112
|
async function runner() {
|
|
112
113
|
const cmd = process.argv[1];
|
|
@@ -117,51 +118,59 @@ async function runner() {
|
|
|
117
118
|
const params = argv.join(" ");
|
|
118
119
|
if (isGo()) {
|
|
119
120
|
if (exec === "pi") {
|
|
120
|
-
loading(`Installing ${params} ...
|
|
121
|
+
const loading_status = await loading(`Installing ${params} ...
|
|
121
122
|
`);
|
|
122
|
-
|
|
123
|
-
|
|
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}");
|
|
124
128
|
} else if (exec === "pui") {
|
|
125
|
-
loading(`Uninstalling ${params} ...
|
|
129
|
+
const loading_status = await loading(`Uninstalling ${params} ...
|
|
126
130
|
`);
|
|
127
|
-
|
|
128
|
-
|
|
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}");
|
|
129
136
|
} else if (exec === "prun") {
|
|
130
137
|
jsShell(`go run ${params}`);
|
|
131
|
-
return;
|
|
132
138
|
} else if (exec === "pinit") {
|
|
133
139
|
jsShell(`go mod init ${params}`);
|
|
134
|
-
return;
|
|
135
140
|
} else if (exec === "pbuild") {
|
|
136
141
|
jsShell(`go build ${params}`);
|
|
137
|
-
|
|
142
|
+
} else {
|
|
143
|
+
console.log("go mod \u9879\u76EE\u6682\u4E0D\u652F\u6301\u5176\u4ED6\u547D\u4EE4");
|
|
138
144
|
}
|
|
139
|
-
|
|
140
|
-
return;
|
|
145
|
+
process.exit();
|
|
141
146
|
}
|
|
142
147
|
if (isRust()) {
|
|
143
148
|
if (exec === "pi") {
|
|
144
|
-
loading(`Installing ${params} ...
|
|
149
|
+
const loading_status = await loading(`Installing ${params} ...
|
|
145
150
|
`);
|
|
146
|
-
|
|
147
|
-
|
|
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}");
|
|
148
156
|
} else if (exec === "pui") {
|
|
149
|
-
loading(`Uninstalling ${params} ...
|
|
157
|
+
const loading_status = await loading(`Uninstalling ${params} ...
|
|
150
158
|
`);
|
|
151
|
-
|
|
152
|
-
|
|
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}");
|
|
153
164
|
} else if (exec === "prun") {
|
|
154
165
|
jsShell(`cargo run ${params}`);
|
|
155
|
-
return;
|
|
156
166
|
} else if (exec === "pinit") {
|
|
157
167
|
jsShell(`cargo init ${params}`);
|
|
158
|
-
return;
|
|
159
168
|
} else if (exec === "pbuild") {
|
|
160
169
|
jsShell(`cargo build ${params}`);
|
|
161
|
-
|
|
170
|
+
} else {
|
|
171
|
+
console.log("Cargo \u9879\u76EE\u6682\u4E0D\u652F\u6301\u5176\u4ED6\u547D\u4EE4");
|
|
162
172
|
}
|
|
163
|
-
|
|
164
|
-
return;
|
|
173
|
+
process.exit();
|
|
165
174
|
}
|
|
166
175
|
if (!runMap[exec]) {
|
|
167
176
|
console.log("\u547D\u4EE4\u4E0D\u5B58\u5728,\u8BF7\u6267\u884Cpi -h\u67E5\u770B\u5E2E\u52A9");
|
package/dist/seprateThread.cjs
CHANGED
package/dist/seprateThread.mjs
CHANGED