@simon_he/pi 0.0.15 → 0.0.17
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 +25 -3
- package/dist/index.cjs +63 -49
- package/dist/index.d.ts +10 -4
- package/dist/index.mjs +31 -21
- package/dist/seprateThread.cjs +2 -12
- package/dist/seprateThread.mjs +1 -11
- package/package.json +11 -7
- package/dist/chunks/index.cjs +0 -7000
- package/dist/chunks/index.mjs +0 -6982
package/README.md
CHANGED
|
@@ -1,27 +1,42 @@
|
|
|
1
1
|
<span ><p align="center"></p></span>
|
|
2
|
+
|
|
2
3
|
<p align="center"> English | <a href="./README_zh.md">简体中文</a></p>
|
|
3
4
|
<p align="center"><a href="https://www.npmjs.com/package/@simon_he/pi"><img src="https://img.shields.io/npm/v/@simon_he/pi?color=3fb883&label=" alt="NPM version"></a>
|
|
4
5
|
|
|
5
6
|
## :lollipop: PI
|
|
7
|
+
|
|
6
8
|
A smart package manager with a custom loading style, which makes you install dependencies more beautifully :)
|
|
7
9
|
|
|
8
10
|
## :rocket: Smart package manager
|
|
11
|
+
|
|
9
12
|
- Supports dependency installation, uninstallation, execution and packaging of go mod
|
|
10
13
|
- Supports Cargo's dependency installation, uninstallation, execution and packaging
|
|
11
14
|
- Support npm dependency installation, uninstallation and execution
|
|
12
15
|
- Support pnpm dependency installation, uninstallation and execution
|
|
13
16
|
- Support yarn dependency installation, uninstallation and execution
|
|
14
17
|
|
|
18
|
+
## Demo
|
|
19
|
+
|
|
20
|
+
- pi
|
|
21
|
+

|
|
15
22
|
|
|
16
|
-
|
|
23
|
+
- prun
|
|
24
|
+

|
|
17
25
|
|
|
26
|
+
- pfind
|
|
27
|
+

|
|
28
|
+
|
|
29
|
+
- others
|
|
30
|
+

|
|
18
31
|
|
|
19
32
|
## :gear: Install
|
|
33
|
+
|
|
20
34
|
```
|
|
21
35
|
npm i -g @simon_he/pi
|
|
22
36
|
```
|
|
23
37
|
|
|
24
38
|
## :open_hands: Usage
|
|
39
|
+
|
|
25
40
|
```
|
|
26
41
|
# According to the environment of the current directory to analyze which package manager to use,go、rust、pnpm、yarn、npm
|
|
27
42
|
# Install dependencies
|
|
@@ -37,6 +52,7 @@ https://user-images.githubusercontent.com/57086651/203143603-9e78f686-399e-4c3d-
|
|
|
37
52
|
```
|
|
38
53
|
|
|
39
54
|
## Power
|
|
55
|
+
|
|
40
56
|
The current environment is npm | yarn | pnpm, and it supports passing some args --silent
|
|
41
57
|
|
|
42
58
|
- prun dev The dev command in the current package.json
|
|
@@ -56,6 +72,7 @@ workspace of pnpm | yarn
|
|
|
56
72
|
- pfind Select the package under the current workspace, and then select the corresponding command
|
|
57
73
|
|
|
58
74
|
## :monocle_face: Feature
|
|
75
|
+
|
|
59
76
|
```
|
|
60
77
|
<-- Go -->
|
|
61
78
|
## input folder and executor command
|
|
@@ -65,22 +82,27 @@ workspace of pnpm | yarn
|
|
|
65
82
|
```
|
|
66
83
|
|
|
67
84
|
## :bulb: Custom configuration
|
|
85
|
+
|
|
68
86
|
You can configure the loading style in .zshrc, as follows:
|
|
87
|
+
|
|
69
88
|
```
|
|
70
89
|
export PI_COLOR=red # loadingstyle color
|
|
71
90
|
export PI_SPINNER=star # loadingstyle
|
|
72
91
|
```
|
|
92
|
+
|
|
73
93
|
- 70+ types of styles, from [cli-spinners](https://jsfiddle.net/sindresorhus/2eLtsbey/embedded/result/),You can choose to fill in the name in PI_SPINNER.
|
|
74
94
|
- Color options: 'black' | 'red' | 'green' | 'yellow' | 'blue' | 'magenta' | 'cyan' | 'white' | 'gray', Fill in PI_COLOR.
|
|
75
95
|
|
|
76
96
|
## :battery: Dependency
|
|
97
|
+
|
|
77
98
|
- [@antfu/ni](https://github.com/antfu/ni)
|
|
78
99
|
- [ora](https://github.com/sindresorhus/ora)
|
|
79
100
|
- [ccommand](https://github.com/Simon-He95/ccommand)
|
|
80
101
|
|
|
81
|
-
|
|
82
102
|
## License
|
|
103
|
+
|
|
83
104
|
[MIT](./LICENSE) License © 2022 [Simon He](https://github.com/Simon-He95)
|
|
84
105
|
|
|
85
|
-
## :coffee:
|
|
106
|
+
## :coffee:
|
|
107
|
+
|
|
86
108
|
<a href="https://github.com/Simon-He95/sponsor" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-orange.png" alt="Buy Me A Coffee" style="height: 51px !important;width: 217px !important;" ></a>
|
package/dist/index.cjs
CHANGED
|
@@ -5,17 +5,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
const path = require('path');
|
|
6
6
|
const process = require('process');
|
|
7
7
|
const url$1 = require('url');
|
|
8
|
-
const
|
|
8
|
+
const lazyJsUtils = require('lazy-js-utils');
|
|
9
9
|
const ora = require('ora');
|
|
10
10
|
const fg = require('fast-glob');
|
|
11
|
-
require('fs');
|
|
12
|
-
require('child_process');
|
|
13
|
-
require('worker_threads');
|
|
14
|
-
require('util');
|
|
15
|
-
require('stream');
|
|
16
|
-
require('zlib');
|
|
17
|
-
require('assert');
|
|
18
|
-
require('buffer');
|
|
19
11
|
|
|
20
12
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
|
|
21
13
|
|
|
@@ -24,21 +16,22 @@ const process__default = /*#__PURE__*/_interopDefaultLegacy(process);
|
|
|
24
16
|
const ora__default = /*#__PURE__*/_interopDefaultLegacy(ora);
|
|
25
17
|
const fg__default = /*#__PURE__*/_interopDefaultLegacy(fg);
|
|
26
18
|
|
|
27
|
-
const version = "0.0.
|
|
19
|
+
const version = "0.0.17";
|
|
28
20
|
|
|
29
21
|
const rootPath = process__default.cwd();
|
|
30
22
|
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)));
|
|
31
23
|
const __dirname$1 = path__default.dirname(__filename$1);
|
|
32
24
|
const url = path__default.resolve(__dirname$1, "./seprateThread.mjs");
|
|
33
|
-
async function pi(params, pkg) {
|
|
25
|
+
async function pi(params, pkg, executor = "ni") {
|
|
34
26
|
const text = pkg ? `Installing ${pkg} ...
|
|
35
27
|
` : "Updating dependency ...\n";
|
|
36
|
-
const successMsg = pkg ? `
|
|
37
|
-
|
|
38
|
-
const failMsg = pkg ? `
|
|
39
|
-
Failed to install ${pkg} \u{1F62D}` : "Failed to update dependency! \u{1F62D}";
|
|
28
|
+
const successMsg = pkg ? `Installed ${pkg} successfully! \u{1F60A}` : "Updated dependency successfully! \u{1F60A}";
|
|
29
|
+
const failMsg = pkg ? `Failed to install ${pkg} \u{1F62D}` : "Failed to update dependency! \u{1F62D}";
|
|
40
30
|
const loading_status = await loading(text);
|
|
41
|
-
const { status } = await
|
|
31
|
+
const { status } = await lazyJsUtils.useNodeWorker(
|
|
32
|
+
url,
|
|
33
|
+
`${executor} ${params}`
|
|
34
|
+
);
|
|
42
35
|
if (status === 0)
|
|
43
36
|
loading_status.succeed(successMsg);
|
|
44
37
|
else
|
|
@@ -57,7 +50,7 @@ Failed to uninstall ${pkg} \u{1F62D}`;
|
|
|
57
50
|
process__default.exit(1);
|
|
58
51
|
}
|
|
59
52
|
const loading_status = await loading(text);
|
|
60
|
-
const { status } = await
|
|
53
|
+
const { status } = await lazyJsUtils.useNodeWorker(url, `nun ${params}`);
|
|
61
54
|
if (status === 0)
|
|
62
55
|
loading_status.succeed(successMsg);
|
|
63
56
|
else
|
|
@@ -65,31 +58,44 @@ Failed to uninstall ${pkg} \u{1F62D}`;
|
|
|
65
58
|
process__default.exit();
|
|
66
59
|
}
|
|
67
60
|
function prun(params) {
|
|
68
|
-
|
|
61
|
+
return lazyJsUtils.jsShell(`ccommand ${params}`);
|
|
69
62
|
}
|
|
70
63
|
function pfind(params) {
|
|
71
|
-
|
|
64
|
+
return lazyJsUtils.jsShell(`ccommand find ${params}`);
|
|
72
65
|
}
|
|
73
66
|
function pinit() {
|
|
74
67
|
console.log("Initializing project...");
|
|
75
|
-
switch (
|
|
68
|
+
switch (lazyJsUtils.getPkgTool()) {
|
|
76
69
|
case "npm":
|
|
77
|
-
|
|
70
|
+
lazyJsUtils.jsShell("npm init -y");
|
|
78
71
|
return;
|
|
79
72
|
case "yarn":
|
|
80
|
-
|
|
73
|
+
lazyJsUtils.jsShell("yarn init -y");
|
|
81
74
|
return;
|
|
82
75
|
case "pnpm":
|
|
83
|
-
|
|
76
|
+
lazyJsUtils.jsShell("pnpm init -y");
|
|
84
77
|
return;
|
|
85
78
|
default:
|
|
86
|
-
|
|
79
|
+
lazyJsUtils.jsShell("npm init -y");
|
|
87
80
|
}
|
|
88
81
|
}
|
|
82
|
+
function pil(params, pkg) {
|
|
83
|
+
const latestPkgname = lazyJsUtils.spaceFormat(params, "@latest ");
|
|
84
|
+
return pi(latestPkgname, pkg ? lazyJsUtils.spaceFormat(`${pkg} `, "@latest ").trim() : "");
|
|
85
|
+
}
|
|
86
|
+
function pu() {
|
|
87
|
+
return lazyJsUtils.jsShell("nu");
|
|
88
|
+
}
|
|
89
|
+
function pci(params, pkg) {
|
|
90
|
+
return pi(params, pkg, "nci");
|
|
91
|
+
}
|
|
92
|
+
function pa() {
|
|
93
|
+
return lazyJsUtils.jsShell("na");
|
|
94
|
+
}
|
|
89
95
|
async function getStyle() {
|
|
90
|
-
const { result: _color = "yellow" } = await
|
|
96
|
+
const { result: _color = "yellow" } = await lazyJsUtils.jsShell("echo $PI_COLOR", "pipe");
|
|
91
97
|
const color = _color;
|
|
92
|
-
const { result: _spinner = "star" } = await
|
|
98
|
+
const { result: _spinner = "star" } = await lazyJsUtils.jsShell(
|
|
93
99
|
"echo $PI_SPINNER",
|
|
94
100
|
"pipe"
|
|
95
101
|
);
|
|
@@ -97,38 +103,42 @@ async function getStyle() {
|
|
|
97
103
|
return { color, spinner };
|
|
98
104
|
}
|
|
99
105
|
async function installDeps() {
|
|
100
|
-
const { status: hasGum } =
|
|
106
|
+
const { status: hasGum } = lazyJsUtils.jsShell("gum -v", "pipe");
|
|
101
107
|
if (hasGum === 1)
|
|
102
|
-
await
|
|
103
|
-
const { status: hasNi } =
|
|
108
|
+
await lazyJsUtils.jsShell("brew install gum", "pipe");
|
|
109
|
+
const { status: hasNi } = lazyJsUtils.jsShell("ni -v", "pipe");
|
|
104
110
|
if (hasNi === 1)
|
|
105
|
-
await
|
|
106
|
-
const { status: hasCcommand } =
|
|
111
|
+
await lazyJsUtils.jsShell("npm i -g @antfu/ni", "pipe");
|
|
112
|
+
const { status: hasCcommand } = lazyJsUtils.jsShell("ccommand -v", "pipe");
|
|
107
113
|
if (hasCcommand === 1)
|
|
108
|
-
await
|
|
114
|
+
await lazyJsUtils.jsShell("npm i -g ccommand", "pipe");
|
|
109
115
|
}
|
|
110
116
|
function returnVersion(argv) {
|
|
111
117
|
const arg = argv[0];
|
|
112
118
|
if (arg === "-v" || arg === "--version") {
|
|
113
|
-
|
|
119
|
+
lazyJsUtils.jsShell(`gum style --foreground 212 --border-foreground 212 --border double --align center --width 50 --margin "1 2" --padding "2 4" 'pi version:${version}' 'Please give me a \u{1F31F} for my efforts'`);
|
|
114
120
|
process__default.exit(0);
|
|
115
121
|
} else if (arg === "-h" || arg === "--help") {
|
|
116
|
-
|
|
117
|
-
`gum style --foreground 212 --border-foreground 212 --border double --align
|
|
122
|
+
lazyJsUtils.jsShell(
|
|
123
|
+
`gum style --foreground 212 --border-foreground 212 --border double --align left --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' '~ pfind: find monorepo of yarn or pnpm' '~ pa: agent alias' '~ pu: package upgrade' '~ pci: package clean install' '~ pil: package latest install'`
|
|
118
124
|
);
|
|
119
125
|
process__default.exit(0);
|
|
120
126
|
}
|
|
121
127
|
}
|
|
122
128
|
const runMap = {
|
|
123
129
|
pi,
|
|
130
|
+
pa,
|
|
124
131
|
pui,
|
|
132
|
+
pu,
|
|
133
|
+
pil,
|
|
134
|
+
pci,
|
|
125
135
|
prun,
|
|
126
136
|
pinit,
|
|
127
137
|
pfind
|
|
128
138
|
};
|
|
129
139
|
function isGo() {
|
|
130
140
|
const url2 = path__default.resolve(rootPath, "go.mod");
|
|
131
|
-
const { result } =
|
|
141
|
+
const { result } = lazyJsUtils.jsShell(
|
|
132
142
|
`(test -f "main.go" || test -f "${url2}") && echo "0"|| echo "1"`,
|
|
133
143
|
"pipe"
|
|
134
144
|
);
|
|
@@ -136,7 +146,7 @@ function isGo() {
|
|
|
136
146
|
}
|
|
137
147
|
function isRust() {
|
|
138
148
|
const url2 = path__default.resolve(rootPath, "Cargo.toml");
|
|
139
|
-
const { result } =
|
|
149
|
+
const { result } = lazyJsUtils.jsShell(`test -f "${url2}" && echo "0"|| echo "1"`, "pipe");
|
|
140
150
|
return result === "0";
|
|
141
151
|
}
|
|
142
152
|
async function loading(text) {
|
|
@@ -150,7 +160,7 @@ async function loading(text) {
|
|
|
150
160
|
}
|
|
151
161
|
function hasPkg() {
|
|
152
162
|
const url2 = path__default.resolve(rootPath, "package.json");
|
|
153
|
-
const { result } =
|
|
163
|
+
const { result } = lazyJsUtils.jsShell(`test -f "${url2}" && echo "0"|| echo "1"`, "pipe");
|
|
154
164
|
return result === "0";
|
|
155
165
|
}
|
|
156
166
|
async function runner() {
|
|
@@ -159,13 +169,13 @@ async function runner() {
|
|
|
159
169
|
const exec = cmd.slice(last, cmd.length);
|
|
160
170
|
const argv = process__default.argv.slice(2);
|
|
161
171
|
returnVersion(argv);
|
|
162
|
-
const params = argv.join(" ").trim();
|
|
172
|
+
const params = lazyJsUtils.spaceFormat(argv.join(" ")).trim();
|
|
163
173
|
if (!hasPkg()) {
|
|
164
174
|
if (isGo()) {
|
|
165
175
|
if (exec === "pi") {
|
|
166
176
|
const loading_status = await loading(`Installing ${params} ...
|
|
167
177
|
`);
|
|
168
|
-
const { status } = await
|
|
178
|
+
const { status } = await lazyJsUtils.useNodeWorker(
|
|
169
179
|
url,
|
|
170
180
|
`go get ${params}`
|
|
171
181
|
);
|
|
@@ -176,7 +186,7 @@ async function runner() {
|
|
|
176
186
|
} else if (exec === "pui") {
|
|
177
187
|
const loading_status = await loading(`Uninstalling ${params} ...
|
|
178
188
|
`);
|
|
179
|
-
const { status } = await
|
|
189
|
+
const { status } = await lazyJsUtils.useNodeWorker(
|
|
180
190
|
url,
|
|
181
191
|
`go clean ${params}`
|
|
182
192
|
);
|
|
@@ -191,11 +201,11 @@ async function runner() {
|
|
|
191
201
|
console.log("No such file");
|
|
192
202
|
process__default.exit(1);
|
|
193
203
|
}
|
|
194
|
-
|
|
204
|
+
lazyJsUtils.jsShell(`go run ${target}`);
|
|
195
205
|
} else if (exec === "pinit") {
|
|
196
|
-
|
|
206
|
+
lazyJsUtils.jsShell(`go mod init ${params}`);
|
|
197
207
|
} else if (exec === "pbuild") {
|
|
198
|
-
|
|
208
|
+
lazyJsUtils.jsShell(`go build ${params}`);
|
|
199
209
|
} else {
|
|
200
210
|
console.log("The commands is not supported");
|
|
201
211
|
}
|
|
@@ -205,7 +215,7 @@ async function runner() {
|
|
|
205
215
|
if (exec === "pi") {
|
|
206
216
|
const loading_status = await loading(`Installing ${params} ...
|
|
207
217
|
`);
|
|
208
|
-
const { status } = await
|
|
218
|
+
const { status } = await lazyJsUtils.useNodeWorker(
|
|
209
219
|
url,
|
|
210
220
|
`cargo install ${params}`
|
|
211
221
|
);
|
|
@@ -216,7 +226,7 @@ async function runner() {
|
|
|
216
226
|
} else if (exec === "pui") {
|
|
217
227
|
const loading_status = await loading(`Uninstalling ${params} ...
|
|
218
228
|
`);
|
|
219
|
-
const { status } = await
|
|
229
|
+
const { status } = await lazyJsUtils.useNodeWorker(
|
|
220
230
|
url,
|
|
221
231
|
`cargo uninstall ${params}`
|
|
222
232
|
);
|
|
@@ -225,11 +235,11 @@ async function runner() {
|
|
|
225
235
|
else
|
|
226
236
|
loading_status.fail("Failed to uninstall \u{1F62D}");
|
|
227
237
|
} else if (exec === "prun") {
|
|
228
|
-
|
|
238
|
+
lazyJsUtils.jsShell(`cargo run ${params}`);
|
|
229
239
|
} else if (exec === "pinit") {
|
|
230
|
-
|
|
240
|
+
lazyJsUtils.jsShell(`cargo init ${params}`);
|
|
231
241
|
} else if (exec === "pbuild") {
|
|
232
|
-
|
|
242
|
+
lazyJsUtils.jsShell(`cargo build ${params}`);
|
|
233
243
|
} else {
|
|
234
244
|
console.log("The commands is not supported");
|
|
235
245
|
}
|
|
@@ -248,9 +258,13 @@ async function runner() {
|
|
|
248
258
|
}
|
|
249
259
|
runner();
|
|
250
260
|
|
|
261
|
+
exports.pa = pa;
|
|
262
|
+
exports.pci = pci;
|
|
251
263
|
exports.pfind = pfind;
|
|
252
264
|
exports.pi = pi;
|
|
265
|
+
exports.pil = pil;
|
|
253
266
|
exports.pinit = pinit;
|
|
254
267
|
exports.prun = prun;
|
|
268
|
+
exports.pu = pu;
|
|
255
269
|
exports.pui = pui;
|
|
256
270
|
exports.runner = runner;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
import * as lazy_js_utils from 'lazy-js-utils';
|
|
2
|
+
|
|
3
|
+
declare function pi(params: string, pkg: string, executor?: string): Promise<void>;
|
|
2
4
|
declare function pui(params: string[], pkg: string): Promise<void>;
|
|
3
|
-
declare function prun(params: string):
|
|
4
|
-
declare function pfind(params: string):
|
|
5
|
+
declare function prun(params: string): lazy_js_utils.IShellMessage;
|
|
6
|
+
declare function pfind(params: string): lazy_js_utils.IShellMessage;
|
|
5
7
|
declare function pinit(): void;
|
|
8
|
+
declare function pil(params: string, pkg: string): Promise<void>;
|
|
9
|
+
declare function pu(): lazy_js_utils.IShellMessage;
|
|
10
|
+
declare function pci(params: string, pkg: string): Promise<void>;
|
|
11
|
+
declare function pa(): lazy_js_utils.IShellMessage;
|
|
6
12
|
declare function runner(): Promise<void>;
|
|
7
13
|
|
|
8
|
-
export { pfind, pi, pinit, prun, pui, runner };
|
|
14
|
+
export { pa, pci, pfind, pi, pil, pinit, prun, pu, pui, runner };
|
package/dist/index.mjs
CHANGED
|
@@ -1,33 +1,26 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
2
|
import process from 'process';
|
|
3
3
|
import { fileURLToPath } from 'url';
|
|
4
|
-
import {
|
|
4
|
+
import { useNodeWorker, jsShell, getPkgTool, spaceFormat } from 'lazy-js-utils';
|
|
5
5
|
import ora from 'ora';
|
|
6
6
|
import fg from 'fast-glob';
|
|
7
|
-
import 'fs';
|
|
8
|
-
import 'child_process';
|
|
9
|
-
import 'worker_threads';
|
|
10
|
-
import 'util';
|
|
11
|
-
import 'stream';
|
|
12
|
-
import 'zlib';
|
|
13
|
-
import 'assert';
|
|
14
|
-
import 'buffer';
|
|
15
7
|
|
|
16
|
-
const version = "0.0.
|
|
8
|
+
const version = "0.0.17";
|
|
17
9
|
|
|
18
10
|
const rootPath = process.cwd();
|
|
19
11
|
const __filename = fileURLToPath(import.meta.url);
|
|
20
12
|
const __dirname = path.dirname(__filename);
|
|
21
13
|
const url = path.resolve(__dirname, "./seprateThread.mjs");
|
|
22
|
-
async function pi(params, pkg) {
|
|
14
|
+
async function pi(params, pkg, executor = "ni") {
|
|
23
15
|
const text = pkg ? `Installing ${pkg} ...
|
|
24
16
|
` : "Updating dependency ...\n";
|
|
25
|
-
const successMsg = pkg ? `
|
|
26
|
-
|
|
27
|
-
const failMsg = pkg ? `
|
|
28
|
-
Failed to install ${pkg} \u{1F62D}` : "Failed to update dependency! \u{1F62D}";
|
|
17
|
+
const successMsg = pkg ? `Installed ${pkg} successfully! \u{1F60A}` : "Updated dependency successfully! \u{1F60A}";
|
|
18
|
+
const failMsg = pkg ? `Failed to install ${pkg} \u{1F62D}` : "Failed to update dependency! \u{1F62D}";
|
|
29
19
|
const loading_status = await loading(text);
|
|
30
|
-
const { status } = await useNodeWorker(
|
|
20
|
+
const { status } = await useNodeWorker(
|
|
21
|
+
url,
|
|
22
|
+
`${executor} ${params}`
|
|
23
|
+
);
|
|
31
24
|
if (status === 0)
|
|
32
25
|
loading_status.succeed(successMsg);
|
|
33
26
|
else
|
|
@@ -54,10 +47,10 @@ Failed to uninstall ${pkg} \u{1F62D}`;
|
|
|
54
47
|
process.exit();
|
|
55
48
|
}
|
|
56
49
|
function prun(params) {
|
|
57
|
-
jsShell(`ccommand ${params}`);
|
|
50
|
+
return jsShell(`ccommand ${params}`);
|
|
58
51
|
}
|
|
59
52
|
function pfind(params) {
|
|
60
|
-
jsShell(`ccommand find ${params}`);
|
|
53
|
+
return jsShell(`ccommand find ${params}`);
|
|
61
54
|
}
|
|
62
55
|
function pinit() {
|
|
63
56
|
console.log("Initializing project...");
|
|
@@ -75,6 +68,19 @@ function pinit() {
|
|
|
75
68
|
jsShell("npm init -y");
|
|
76
69
|
}
|
|
77
70
|
}
|
|
71
|
+
function pil(params, pkg) {
|
|
72
|
+
const latestPkgname = spaceFormat(params, "@latest ");
|
|
73
|
+
return pi(latestPkgname, pkg ? spaceFormat(`${pkg} `, "@latest ").trim() : "");
|
|
74
|
+
}
|
|
75
|
+
function pu() {
|
|
76
|
+
return jsShell("nu");
|
|
77
|
+
}
|
|
78
|
+
function pci(params, pkg) {
|
|
79
|
+
return pi(params, pkg, "nci");
|
|
80
|
+
}
|
|
81
|
+
function pa() {
|
|
82
|
+
return jsShell("na");
|
|
83
|
+
}
|
|
78
84
|
async function getStyle() {
|
|
79
85
|
const { result: _color = "yellow" } = await jsShell("echo $PI_COLOR", "pipe");
|
|
80
86
|
const color = _color;
|
|
@@ -103,14 +109,18 @@ function returnVersion(argv) {
|
|
|
103
109
|
process.exit(0);
|
|
104
110
|
} else if (arg === "-h" || arg === "--help") {
|
|
105
111
|
jsShell(
|
|
106
|
-
`gum style --foreground 212 --border-foreground 212 --border double --align
|
|
112
|
+
`gum style --foreground 212 --border-foreground 212 --border double --align left --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' '~ pfind: find monorepo of yarn or pnpm' '~ pa: agent alias' '~ pu: package upgrade' '~ pci: package clean install' '~ pil: package latest install'`
|
|
107
113
|
);
|
|
108
114
|
process.exit(0);
|
|
109
115
|
}
|
|
110
116
|
}
|
|
111
117
|
const runMap = {
|
|
112
118
|
pi,
|
|
119
|
+
pa,
|
|
113
120
|
pui,
|
|
121
|
+
pu,
|
|
122
|
+
pil,
|
|
123
|
+
pci,
|
|
114
124
|
prun,
|
|
115
125
|
pinit,
|
|
116
126
|
pfind
|
|
@@ -148,7 +158,7 @@ async function runner() {
|
|
|
148
158
|
const exec = cmd.slice(last, cmd.length);
|
|
149
159
|
const argv = process.argv.slice(2);
|
|
150
160
|
returnVersion(argv);
|
|
151
|
-
const params = argv.join(" ").trim();
|
|
161
|
+
const params = spaceFormat(argv.join(" ")).trim();
|
|
152
162
|
if (!hasPkg()) {
|
|
153
163
|
if (isGo()) {
|
|
154
164
|
if (exec === "pi") {
|
|
@@ -237,4 +247,4 @@ async function runner() {
|
|
|
237
247
|
}
|
|
238
248
|
runner();
|
|
239
249
|
|
|
240
|
-
export { pfind, pi, pinit, prun, pui, runner };
|
|
250
|
+
export { pa, pci, pfind, pi, pil, pinit, prun, pu, pui, runner };
|
package/dist/seprateThread.cjs
CHANGED
|
@@ -1,15 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
require('fs');
|
|
5
|
-
require('path');
|
|
6
|
-
require('process');
|
|
7
|
-
require('child_process');
|
|
8
|
-
require('worker_threads');
|
|
9
|
-
require('util');
|
|
10
|
-
require('stream');
|
|
11
|
-
require('zlib');
|
|
12
|
-
require('assert');
|
|
13
|
-
require('buffer');
|
|
3
|
+
const lazyJsUtils = require('lazy-js-utils');
|
|
14
4
|
|
|
15
|
-
|
|
5
|
+
lazyJsUtils.useProcressNodeWorker(async (command) => lazyJsUtils.jsShell(`${command}`, "pipe"));
|
package/dist/seprateThread.mjs
CHANGED
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import 'fs';
|
|
3
|
-
import 'path';
|
|
4
|
-
import 'process';
|
|
5
|
-
import 'child_process';
|
|
6
|
-
import 'worker_threads';
|
|
7
|
-
import 'util';
|
|
8
|
-
import 'stream';
|
|
9
|
-
import 'zlib';
|
|
10
|
-
import 'assert';
|
|
11
|
-
import 'buffer';
|
|
1
|
+
import { useProcressNodeWorker, jsShell } from 'lazy-js-utils';
|
|
12
2
|
|
|
13
3
|
useProcressNodeWorker(async (command) => jsShell(`${command}`, "pipe"));
|
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.17",
|
|
5
5
|
"packageManager": "pnpm@7.2.1",
|
|
6
6
|
"description": "",
|
|
7
7
|
"author": "Simon He",
|
|
@@ -35,6 +35,10 @@
|
|
|
35
35
|
},
|
|
36
36
|
"bin": {
|
|
37
37
|
"pi": "./cli.mjs",
|
|
38
|
+
"pa": "./cli.mjs",
|
|
39
|
+
"pu": "./cli.mjs",
|
|
40
|
+
"pci": "./cli.mjs",
|
|
41
|
+
"pil": "./cli.mjs",
|
|
38
42
|
"pui": "./cli.mjs",
|
|
39
43
|
"prun": "./cli.mjs",
|
|
40
44
|
"pinit": "./cli.mjs",
|
|
@@ -45,7 +49,6 @@
|
|
|
45
49
|
"dist"
|
|
46
50
|
],
|
|
47
51
|
"scripts": {
|
|
48
|
-
"preinstall": "npx only-allow pnpm",
|
|
49
52
|
"postinstall": "simple-git-hooks",
|
|
50
53
|
"build": "unbuild",
|
|
51
54
|
"dev": "unbuild --stub",
|
|
@@ -60,26 +63,27 @@
|
|
|
60
63
|
},
|
|
61
64
|
"dependencies": {
|
|
62
65
|
"fast-glob": "^3.2.12",
|
|
66
|
+
"lazy-js-utils": "^0.0.7",
|
|
63
67
|
"ora": "^6.1.2"
|
|
64
68
|
},
|
|
65
69
|
"devDependencies": {
|
|
66
70
|
"@antfu/eslint-config": "^0.25.2",
|
|
67
71
|
"@antfu/ni": "^0.16.3",
|
|
68
72
|
"@antfu/utils": "^0.5.2",
|
|
69
|
-
"@types/node": "^18.11.
|
|
73
|
+
"@types/node": "^18.11.15",
|
|
70
74
|
"bumpp": "^8.2.1",
|
|
71
|
-
"eslint": "^8.
|
|
75
|
+
"eslint": "^8.29.0",
|
|
72
76
|
"esno": "^0.16.3",
|
|
73
77
|
"lint-staged": "^13.1.0",
|
|
74
78
|
"picocolors": "^1.0.0",
|
|
75
|
-
"pnpm": "^7.
|
|
79
|
+
"pnpm": "^7.18.2",
|
|
76
80
|
"prettier": "^2.8.1",
|
|
77
81
|
"rimraf": "^3.0.2",
|
|
78
82
|
"simple-git-hooks": "^2.8.1",
|
|
79
83
|
"tsx": "^3.12.1",
|
|
80
|
-
"typescript": "^4.9.
|
|
84
|
+
"typescript": "^4.9.4",
|
|
81
85
|
"unbuild": "^0.7.6",
|
|
82
|
-
"vitest": "^0.25.
|
|
86
|
+
"vitest": "^0.25.8"
|
|
83
87
|
},
|
|
84
88
|
"simple-git-hooks": {
|
|
85
89
|
"pre-commit": "pnpm exec lint-staged --concurrent false",
|