@simon_he/pi 0.0.16 → 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 CHANGED
@@ -15,7 +15,19 @@ A smart package manager with a custom loading style, which makes you install dep
15
15
  - Support pnpm dependency installation, uninstallation and execution
16
16
  - Support yarn dependency installation, uninstallation and execution
17
17
 
18
- https://user-images.githubusercontent.com/57086651/203143603-9e78f686-399e-4c3d-ae53-56638501b276.mov
18
+ ## Demo
19
+
20
+ - pi
21
+ ![gif](/assets/pi.gif)
22
+
23
+ - prun
24
+ ![gif](/assets/prun.gif)
25
+
26
+ - pfind
27
+ ![gif](/assets/pfind.gif)
28
+
29
+ - others
30
+ ![gif](/assets/others.gif)
19
31
 
20
32
  ## :gear: Install
21
33
 
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 index = require('./chunks/index.cjs');
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,19 +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.16";
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
28
  const successMsg = pkg ? `Installed ${pkg} successfully! \u{1F60A}` : "Updated dependency successfully! \u{1F60A}";
37
29
  const failMsg = pkg ? `Failed to install ${pkg} \u{1F62D}` : "Failed to update dependency! \u{1F62D}";
38
30
  const loading_status = await loading(text);
39
- const { status } = await index.useNodeWorker(url, `ni ${params}`);
31
+ const { status } = await lazyJsUtils.useNodeWorker(
32
+ url,
33
+ `${executor} ${params}`
34
+ );
40
35
  if (status === 0)
41
36
  loading_status.succeed(successMsg);
42
37
  else
@@ -55,7 +50,7 @@ Failed to uninstall ${pkg} \u{1F62D}`;
55
50
  process__default.exit(1);
56
51
  }
57
52
  const loading_status = await loading(text);
58
- const { status } = await index.useNodeWorker(url, `nun ${params}`);
53
+ const { status } = await lazyJsUtils.useNodeWorker(url, `nun ${params}`);
59
54
  if (status === 0)
60
55
  loading_status.succeed(successMsg);
61
56
  else
@@ -63,31 +58,44 @@ Failed to uninstall ${pkg} \u{1F62D}`;
63
58
  process__default.exit();
64
59
  }
65
60
  function prun(params) {
66
- index.jsShell(`ccommand ${params}`);
61
+ return lazyJsUtils.jsShell(`ccommand ${params}`);
67
62
  }
68
63
  function pfind(params) {
69
- index.jsShell(`ccommand find ${params}`);
64
+ return lazyJsUtils.jsShell(`ccommand find ${params}`);
70
65
  }
71
66
  function pinit() {
72
67
  console.log("Initializing project...");
73
- switch (index.getPkgTool()) {
68
+ switch (lazyJsUtils.getPkgTool()) {
74
69
  case "npm":
75
- index.jsShell("npm init -y");
70
+ lazyJsUtils.jsShell("npm init -y");
76
71
  return;
77
72
  case "yarn":
78
- index.jsShell("yarn init -y");
73
+ lazyJsUtils.jsShell("yarn init -y");
79
74
  return;
80
75
  case "pnpm":
81
- index.jsShell("pnpm init -y");
76
+ lazyJsUtils.jsShell("pnpm init -y");
82
77
  return;
83
78
  default:
84
- index.jsShell("npm init -y");
79
+ lazyJsUtils.jsShell("npm init -y");
85
80
  }
86
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
+ }
87
95
  async function getStyle() {
88
- const { result: _color = "yellow" } = await index.jsShell("echo $PI_COLOR", "pipe");
96
+ const { result: _color = "yellow" } = await lazyJsUtils.jsShell("echo $PI_COLOR", "pipe");
89
97
  const color = _color;
90
- const { result: _spinner = "star" } = await index.jsShell(
98
+ const { result: _spinner = "star" } = await lazyJsUtils.jsShell(
91
99
  "echo $PI_SPINNER",
92
100
  "pipe"
93
101
  );
@@ -95,38 +103,42 @@ async function getStyle() {
95
103
  return { color, spinner };
96
104
  }
97
105
  async function installDeps() {
98
- const { status: hasGum } = index.jsShell("gum -v", "pipe");
106
+ const { status: hasGum } = lazyJsUtils.jsShell("gum -v", "pipe");
99
107
  if (hasGum === 1)
100
- await index.jsShell("brew install gum", "pipe");
101
- const { status: hasNi } = index.jsShell("ni -v", "pipe");
108
+ await lazyJsUtils.jsShell("brew install gum", "pipe");
109
+ const { status: hasNi } = lazyJsUtils.jsShell("ni -v", "pipe");
102
110
  if (hasNi === 1)
103
- await index.jsShell("npm i -g @antfu/ni", "pipe");
104
- const { status: hasCcommand } = index.jsShell("ccommand -v", "pipe");
111
+ await lazyJsUtils.jsShell("npm i -g @antfu/ni", "pipe");
112
+ const { status: hasCcommand } = lazyJsUtils.jsShell("ccommand -v", "pipe");
105
113
  if (hasCcommand === 1)
106
- await index.jsShell("npm i -g ccommand", "pipe");
114
+ await lazyJsUtils.jsShell("npm i -g ccommand", "pipe");
107
115
  }
108
116
  function returnVersion(argv) {
109
117
  const arg = argv[0];
110
118
  if (arg === "-v" || arg === "--version") {
111
- index.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'`);
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'`);
112
120
  process__default.exit(0);
113
121
  } else if (arg === "-h" || arg === "--help") {
114
- index.jsShell(
115
- `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' 'pfind: find monorepo of yarn or pnpm'`
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'`
116
124
  );
117
125
  process__default.exit(0);
118
126
  }
119
127
  }
120
128
  const runMap = {
121
129
  pi,
130
+ pa,
122
131
  pui,
132
+ pu,
133
+ pil,
134
+ pci,
123
135
  prun,
124
136
  pinit,
125
137
  pfind
126
138
  };
127
139
  function isGo() {
128
140
  const url2 = path__default.resolve(rootPath, "go.mod");
129
- const { result } = index.jsShell(
141
+ const { result } = lazyJsUtils.jsShell(
130
142
  `(test -f "main.go" || test -f "${url2}") && echo "0"|| echo "1"`,
131
143
  "pipe"
132
144
  );
@@ -134,7 +146,7 @@ function isGo() {
134
146
  }
135
147
  function isRust() {
136
148
  const url2 = path__default.resolve(rootPath, "Cargo.toml");
137
- const { result } = index.jsShell(`test -f "${url2}" && echo "0"|| echo "1"`, "pipe");
149
+ const { result } = lazyJsUtils.jsShell(`test -f "${url2}" && echo "0"|| echo "1"`, "pipe");
138
150
  return result === "0";
139
151
  }
140
152
  async function loading(text) {
@@ -148,7 +160,7 @@ async function loading(text) {
148
160
  }
149
161
  function hasPkg() {
150
162
  const url2 = path__default.resolve(rootPath, "package.json");
151
- const { result } = index.jsShell(`test -f "${url2}" && echo "0"|| echo "1"`, "pipe");
163
+ const { result } = lazyJsUtils.jsShell(`test -f "${url2}" && echo "0"|| echo "1"`, "pipe");
152
164
  return result === "0";
153
165
  }
154
166
  async function runner() {
@@ -157,13 +169,13 @@ async function runner() {
157
169
  const exec = cmd.slice(last, cmd.length);
158
170
  const argv = process__default.argv.slice(2);
159
171
  returnVersion(argv);
160
- const params = argv.join(" ").trim();
172
+ const params = lazyJsUtils.spaceFormat(argv.join(" ")).trim();
161
173
  if (!hasPkg()) {
162
174
  if (isGo()) {
163
175
  if (exec === "pi") {
164
176
  const loading_status = await loading(`Installing ${params} ...
165
177
  `);
166
- const { status } = await index.useNodeWorker(
178
+ const { status } = await lazyJsUtils.useNodeWorker(
167
179
  url,
168
180
  `go get ${params}`
169
181
  );
@@ -174,7 +186,7 @@ async function runner() {
174
186
  } else if (exec === "pui") {
175
187
  const loading_status = await loading(`Uninstalling ${params} ...
176
188
  `);
177
- const { status } = await index.useNodeWorker(
189
+ const { status } = await lazyJsUtils.useNodeWorker(
178
190
  url,
179
191
  `go clean ${params}`
180
192
  );
@@ -189,11 +201,11 @@ async function runner() {
189
201
  console.log("No such file");
190
202
  process__default.exit(1);
191
203
  }
192
- index.jsShell(`go run ${target}`);
204
+ lazyJsUtils.jsShell(`go run ${target}`);
193
205
  } else if (exec === "pinit") {
194
- index.jsShell(`go mod init ${params}`);
206
+ lazyJsUtils.jsShell(`go mod init ${params}`);
195
207
  } else if (exec === "pbuild") {
196
- index.jsShell(`go build ${params}`);
208
+ lazyJsUtils.jsShell(`go build ${params}`);
197
209
  } else {
198
210
  console.log("The commands is not supported");
199
211
  }
@@ -203,7 +215,7 @@ async function runner() {
203
215
  if (exec === "pi") {
204
216
  const loading_status = await loading(`Installing ${params} ...
205
217
  `);
206
- const { status } = await index.useNodeWorker(
218
+ const { status } = await lazyJsUtils.useNodeWorker(
207
219
  url,
208
220
  `cargo install ${params}`
209
221
  );
@@ -214,7 +226,7 @@ async function runner() {
214
226
  } else if (exec === "pui") {
215
227
  const loading_status = await loading(`Uninstalling ${params} ...
216
228
  `);
217
- const { status } = await index.useNodeWorker(
229
+ const { status } = await lazyJsUtils.useNodeWorker(
218
230
  url,
219
231
  `cargo uninstall ${params}`
220
232
  );
@@ -223,11 +235,11 @@ async function runner() {
223
235
  else
224
236
  loading_status.fail("Failed to uninstall \u{1F62D}");
225
237
  } else if (exec === "prun") {
226
- index.jsShell(`cargo run ${params}`);
238
+ lazyJsUtils.jsShell(`cargo run ${params}`);
227
239
  } else if (exec === "pinit") {
228
- index.jsShell(`cargo init ${params}`);
240
+ lazyJsUtils.jsShell(`cargo init ${params}`);
229
241
  } else if (exec === "pbuild") {
230
- index.jsShell(`cargo build ${params}`);
242
+ lazyJsUtils.jsShell(`cargo build ${params}`);
231
243
  } else {
232
244
  console.log("The commands is not supported");
233
245
  }
@@ -246,9 +258,13 @@ async function runner() {
246
258
  }
247
259
  runner();
248
260
 
261
+ exports.pa = pa;
262
+ exports.pci = pci;
249
263
  exports.pfind = pfind;
250
264
  exports.pi = pi;
265
+ exports.pil = pil;
251
266
  exports.pinit = pinit;
252
267
  exports.prun = prun;
268
+ exports.pu = pu;
253
269
  exports.pui = pui;
254
270
  exports.runner = runner;
package/dist/index.d.ts CHANGED
@@ -1,8 +1,14 @@
1
- declare function pi(params: string[], pkg: string): Promise<void>;
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): void;
4
- declare function pfind(params: string): void;
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,31 +1,26 @@
1
1
  import path from 'path';
2
2
  import process from 'process';
3
3
  import { fileURLToPath } from 'url';
4
- import { u as useNodeWorker, j as jsShell, g as getPkgTool } from './chunks/index.mjs';
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.16";
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
17
  const successMsg = pkg ? `Installed ${pkg} successfully! \u{1F60A}` : "Updated dependency successfully! \u{1F60A}";
26
18
  const failMsg = pkg ? `Failed to install ${pkg} \u{1F62D}` : "Failed to update dependency! \u{1F62D}";
27
19
  const loading_status = await loading(text);
28
- const { status } = await useNodeWorker(url, `ni ${params}`);
20
+ const { status } = await useNodeWorker(
21
+ url,
22
+ `${executor} ${params}`
23
+ );
29
24
  if (status === 0)
30
25
  loading_status.succeed(successMsg);
31
26
  else
@@ -52,10 +47,10 @@ Failed to uninstall ${pkg} \u{1F62D}`;
52
47
  process.exit();
53
48
  }
54
49
  function prun(params) {
55
- jsShell(`ccommand ${params}`);
50
+ return jsShell(`ccommand ${params}`);
56
51
  }
57
52
  function pfind(params) {
58
- jsShell(`ccommand find ${params}`);
53
+ return jsShell(`ccommand find ${params}`);
59
54
  }
60
55
  function pinit() {
61
56
  console.log("Initializing project...");
@@ -73,6 +68,19 @@ function pinit() {
73
68
  jsShell("npm init -y");
74
69
  }
75
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
+ }
76
84
  async function getStyle() {
77
85
  const { result: _color = "yellow" } = await jsShell("echo $PI_COLOR", "pipe");
78
86
  const color = _color;
@@ -101,14 +109,18 @@ function returnVersion(argv) {
101
109
  process.exit(0);
102
110
  } else if (arg === "-h" || arg === "--help") {
103
111
  jsShell(
104
- `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' 'pfind: find monorepo of yarn or pnpm'`
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'`
105
113
  );
106
114
  process.exit(0);
107
115
  }
108
116
  }
109
117
  const runMap = {
110
118
  pi,
119
+ pa,
111
120
  pui,
121
+ pu,
122
+ pil,
123
+ pci,
112
124
  prun,
113
125
  pinit,
114
126
  pfind
@@ -146,7 +158,7 @@ async function runner() {
146
158
  const exec = cmd.slice(last, cmd.length);
147
159
  const argv = process.argv.slice(2);
148
160
  returnVersion(argv);
149
- const params = argv.join(" ").trim();
161
+ const params = spaceFormat(argv.join(" ")).trim();
150
162
  if (!hasPkg()) {
151
163
  if (isGo()) {
152
164
  if (exec === "pi") {
@@ -235,4 +247,4 @@ async function runner() {
235
247
  }
236
248
  runner();
237
249
 
238
- export { pfind, pi, pinit, prun, pui, runner };
250
+ export { pa, pci, pfind, pi, pil, pinit, prun, pu, pui, runner };
@@ -1,15 +1,5 @@
1
1
  'use strict';
2
2
 
3
- const index = require('./chunks/index.cjs');
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
- index.useProcressNodeWorker(async (command) => index.jsShell(`${command}`, "pipe"));
5
+ lazyJsUtils.useProcressNodeWorker(async (command) => lazyJsUtils.jsShell(`${command}`, "pipe"));
@@ -1,13 +1,3 @@
1
- import { a as useProcressNodeWorker, j as jsShell } from './chunks/index.mjs';
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.16",
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",
@@ -59,26 +63,27 @@
59
63
  },
60
64
  "dependencies": {
61
65
  "fast-glob": "^3.2.12",
66
+ "lazy-js-utils": "^0.0.7",
62
67
  "ora": "^6.1.2"
63
68
  },
64
69
  "devDependencies": {
65
70
  "@antfu/eslint-config": "^0.25.2",
66
71
  "@antfu/ni": "^0.16.3",
67
72
  "@antfu/utils": "^0.5.2",
68
- "@types/node": "^18.11.9",
73
+ "@types/node": "^18.11.15",
69
74
  "bumpp": "^8.2.1",
70
- "eslint": "^8.28.0",
75
+ "eslint": "^8.29.0",
71
76
  "esno": "^0.16.3",
72
77
  "lint-staged": "^13.1.0",
73
78
  "picocolors": "^1.0.0",
74
- "pnpm": "^7.17.0",
79
+ "pnpm": "^7.18.2",
75
80
  "prettier": "^2.8.1",
76
81
  "rimraf": "^3.0.2",
77
82
  "simple-git-hooks": "^2.8.1",
78
83
  "tsx": "^3.12.1",
79
- "typescript": "^4.9.3",
84
+ "typescript": "^4.9.4",
80
85
  "unbuild": "^0.7.6",
81
- "vitest": "^0.25.2"
86
+ "vitest": "^0.25.8"
82
87
  },
83
88
  "simple-git-hooks": {
84
89
  "pre-commit": "pnpm exec lint-staged --concurrent false",