@simon_he/pi 0.0.13 → 0.0.15

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/dist/index.cjs CHANGED
@@ -5,9 +5,17 @@ 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 simonJsTool = require('simon-js-tool');
8
+ const index = require('./chunks/index.cjs');
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');
11
19
 
12
20
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
13
21
 
@@ -16,7 +24,7 @@ const process__default = /*#__PURE__*/_interopDefaultLegacy(process);
16
24
  const ora__default = /*#__PURE__*/_interopDefaultLegacy(ora);
17
25
  const fg__default = /*#__PURE__*/_interopDefaultLegacy(fg);
18
26
 
19
- const version = "0.0.13";
27
+ const version = "0.0.15";
20
28
 
21
29
  const rootPath = process__default.cwd();
22
30
  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)));
@@ -25,10 +33,12 @@ const url = path__default.resolve(__dirname$1, "./seprateThread.mjs");
25
33
  async function pi(params, pkg) {
26
34
  const text = pkg ? `Installing ${pkg} ...
27
35
  ` : "Updating dependency ...\n";
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}";
36
+ const successMsg = pkg ? `
37
+ Installed ${pkg} successfully! \u{1F60A}` : "Updated dependency successfully! \u{1F60A}";
38
+ const failMsg = pkg ? `
39
+ Failed to install ${pkg} \u{1F62D}` : "Failed to update dependency! \u{1F62D}";
30
40
  const loading_status = await loading(text);
31
- const { status } = await simonJsTool.useNodeWorker(url, `ni ${params}`);
41
+ const { status } = await index.useNodeWorker(url, `ni ${params}`);
32
42
  if (status === 0)
33
43
  loading_status.succeed(successMsg);
34
44
  else
@@ -38,14 +48,16 @@ async function pi(params, pkg) {
38
48
  async function pui(params, pkg) {
39
49
  const text = `Uninstalling ${pkg} ...
40
50
  `;
41
- const successMsg = `unInstalled ${pkg} successfully! \u{1F60A}`;
42
- const failMsg = `Failed to uninstall ${pkg} \u{1F62D}`;
51
+ const successMsg = `
52
+ UnInstalled ${pkg} successfully! \u{1F60A}`;
53
+ const failMsg = `
54
+ Failed to uninstall ${pkg} \u{1F62D}`;
43
55
  if (!pkg) {
44
56
  console.log("Need to specify an uninstall package name");
45
57
  process__default.exit(1);
46
58
  }
47
59
  const loading_status = await loading(text);
48
- const { status } = await simonJsTool.useNodeWorker(url, `nun ${params}`);
60
+ const { status } = await index.useNodeWorker(url, `nun ${params}`);
49
61
  if (status === 0)
50
62
  loading_status.succeed(successMsg);
51
63
  else
@@ -53,52 +65,57 @@ async function pui(params, pkg) {
53
65
  process__default.exit();
54
66
  }
55
67
  function prun(params) {
56
- simonJsTool.jsShell(`ccommand ${params}`);
68
+ index.jsShell(`ccommand ${params}`);
57
69
  }
58
70
  function pfind(params) {
59
- simonJsTool.jsShell(`ccommand find ${params}`);
71
+ index.jsShell(`ccommand find ${params}`);
60
72
  }
61
73
  function pinit() {
62
74
  console.log("Initializing project...");
63
- switch (simonJsTool.getPkgTool()) {
75
+ switch (index.getPkgTool()) {
64
76
  case "npm":
65
- simonJsTool.jsShell("npm init -y");
77
+ index.jsShell("npm init -y");
66
78
  return;
67
79
  case "yarn":
68
- simonJsTool.jsShell("yarn init -y");
80
+ index.jsShell("yarn init -y");
69
81
  return;
70
82
  case "pnpm":
71
- simonJsTool.jsShell("pnpm init -y");
83
+ index.jsShell("pnpm init -y");
72
84
  return;
73
85
  default:
74
- simonJsTool.jsShell("npm init -y");
86
+ index.jsShell("npm init -y");
75
87
  }
76
88
  }
77
89
  async function getStyle() {
78
- const { result: _color = "yellow" } = await simonJsTool.jsShell("echo $PI_COLOR", "pipe");
90
+ const { result: _color = "yellow" } = await index.jsShell("echo $PI_COLOR", "pipe");
79
91
  const color = _color;
80
- const { result: _spinner = "star" } = await simonJsTool.jsShell("echo $PI_SPINNER", "pipe");
92
+ const { result: _spinner = "star" } = await index.jsShell(
93
+ "echo $PI_SPINNER",
94
+ "pipe"
95
+ );
81
96
  const spinner = _spinner;
82
97
  return { color, spinner };
83
98
  }
84
99
  async function installDeps() {
85
- const { status: hasGum } = simonJsTool.jsShell("gum -v", "pipe");
100
+ const { status: hasGum } = index.jsShell("gum -v", "pipe");
86
101
  if (hasGum === 1)
87
- await simonJsTool.jsShell("brew install gum", "pipe");
88
- const { status: hasNi } = simonJsTool.jsShell("ni -v", "pipe");
102
+ await index.jsShell("brew install gum", "pipe");
103
+ const { status: hasNi } = index.jsShell("ni -v", "pipe");
89
104
  if (hasNi === 1)
90
- await simonJsTool.jsShell("npm i -g @antfu/ni", "pipe");
91
- const { status: hasCcommand } = simonJsTool.jsShell("ccommand -v", "pipe");
105
+ await index.jsShell("npm i -g @antfu/ni", "pipe");
106
+ const { status: hasCcommand } = index.jsShell("ccommand -v", "pipe");
92
107
  if (hasCcommand === 1)
93
- await simonJsTool.jsShell("npm i -g ccommand", "pipe");
108
+ await index.jsShell("npm i -g ccommand", "pipe");
94
109
  }
95
110
  function returnVersion(argv) {
96
111
  const arg = argv[0];
97
112
  if (arg === "-v" || arg === "--version") {
98
- simonJsTool.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'`);
113
+ 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'`);
99
114
  process__default.exit(0);
100
115
  } else if (arg === "-h" || arg === "--help") {
101
- 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' 'pfind: find monorepo of yarn or pnpm'`);
116
+ index.jsShell(
117
+ `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'`
118
+ );
102
119
  process__default.exit(0);
103
120
  }
104
121
  }
@@ -111,12 +128,15 @@ const runMap = {
111
128
  };
112
129
  function isGo() {
113
130
  const url2 = path__default.resolve(rootPath, "go.mod");
114
- const { result } = simonJsTool.jsShell(`(test -f "main.go" || test -f "${url2}") && echo "0"|| echo "1"`, "pipe");
131
+ const { result } = index.jsShell(
132
+ `(test -f "main.go" || test -f "${url2}") && echo "0"|| echo "1"`,
133
+ "pipe"
134
+ );
115
135
  return result === "0";
116
136
  }
117
137
  function isRust() {
118
138
  const url2 = path__default.resolve(rootPath, "Cargo.toml");
119
- const { result } = simonJsTool.jsShell(`test -f "${url2}" && echo "0"|| echo "1"`, "pipe");
139
+ const { result } = index.jsShell(`test -f "${url2}" && echo "0"|| echo "1"`, "pipe");
120
140
  return result === "0";
121
141
  }
122
142
  async function loading(text) {
@@ -128,6 +148,11 @@ async function loading(text) {
128
148
  }).start();
129
149
  return result;
130
150
  }
151
+ function hasPkg() {
152
+ const url2 = path__default.resolve(rootPath, "package.json");
153
+ const { result } = index.jsShell(`test -f "${url2}" && echo "0"|| echo "1"`, "pipe");
154
+ return result === "0";
155
+ }
131
156
  async function runner() {
132
157
  const cmd = process__default.argv[1];
133
158
  const last = cmd.lastIndexOf("/") + 1;
@@ -135,71 +160,87 @@ async function runner() {
135
160
  const argv = process__default.argv.slice(2);
136
161
  returnVersion(argv);
137
162
  const params = argv.join(" ").trim();
138
- if (isGo()) {
139
- if (exec === "pi") {
140
- const loading_status = await loading(`Installing ${params} ...
163
+ if (!hasPkg()) {
164
+ if (isGo()) {
165
+ if (exec === "pi") {
166
+ const loading_status = await loading(`Installing ${params} ...
141
167
  `);
142
- const { status } = await simonJsTool.useNodeWorker(url, `go get ${params}`);
143
- if (status === 0)
144
- loading_status.succeed("Installed successfully! \u{1F60A}");
145
- else
146
- loading_status.fail("Failed to install \u{1F62D}");
147
- } else if (exec === "pui") {
148
- const loading_status = await loading(`Uninstalling ${params} ...
168
+ const { status } = await index.useNodeWorker(
169
+ url,
170
+ `go get ${params}`
171
+ );
172
+ if (status === 0)
173
+ loading_status.succeed("Installed successfully! \u{1F60A}");
174
+ else
175
+ loading_status.fail("Failed to install \u{1F62D}");
176
+ } else if (exec === "pui") {
177
+ const loading_status = await loading(`Uninstalling ${params} ...
149
178
  `);
150
- const { status } = await simonJsTool.useNodeWorker(url, `go clean ${params}`);
151
- if (status === 0)
152
- loading_status.succeed("Uninstalled successfully! \u{1F60A}");
153
- else
154
- loading_status.fail("Failed to uninstall \u{1F62D}");
155
- } else if (exec === "prun") {
156
- const match = params ? params.endsWith(".go") ? [`**/${params}`] : [`**/${params}.go`, `**/${params}/main.go`] : "main.go";
157
- const target = (await fg__default(match))[0];
158
- if (!target) {
159
- console.log("No such file");
160
- process__default.exit(1);
179
+ const { status } = await index.useNodeWorker(
180
+ url,
181
+ `go clean ${params}`
182
+ );
183
+ if (status === 0)
184
+ loading_status.succeed("Uninstalled successfully! \u{1F60A}");
185
+ else
186
+ loading_status.fail("Failed to uninstall \u{1F62D}");
187
+ } else if (exec === "prun") {
188
+ const match = params ? params.endsWith(".go") ? [`**/${params}`] : [`**/${params}.go`, `**/${params}/main.go`] : "main.go";
189
+ const target = (await fg__default(match))[0];
190
+ if (!target) {
191
+ console.log("No such file");
192
+ process__default.exit(1);
193
+ }
194
+ index.jsShell(`go run ${target}`);
195
+ } else if (exec === "pinit") {
196
+ index.jsShell(`go mod init ${params}`);
197
+ } else if (exec === "pbuild") {
198
+ index.jsShell(`go build ${params}`);
199
+ } else {
200
+ console.log("The commands is not supported");
161
201
  }
162
- simonJsTool.jsShell(`go run ${target}`);
163
- } else if (exec === "pinit") {
164
- simonJsTool.jsShell(`go mod init ${params}`);
165
- } else if (exec === "pbuild") {
166
- simonJsTool.jsShell(`go build ${params}`);
167
- } else {
168
- console.log("The commands is not supported");
202
+ process__default.exit();
169
203
  }
170
- process__default.exit();
171
- }
172
- if (isRust()) {
173
- if (exec === "pi") {
174
- const loading_status = await loading(`Installing ${params} ...
204
+ if (isRust()) {
205
+ if (exec === "pi") {
206
+ const loading_status = await loading(`Installing ${params} ...
175
207
  `);
176
- const { status } = await simonJsTool.useNodeWorker(url, `cargo install ${params}`);
177
- if (status === 0)
178
- loading_status.succeed("installed successfully! \u{1F60A}");
179
- else
180
- loading_status.fail("Failed to install \u{1F62D}");
181
- } else if (exec === "pui") {
182
- const loading_status = await loading(`Uninstalling ${params} ...
208
+ const { status } = await index.useNodeWorker(
209
+ url,
210
+ `cargo install ${params}`
211
+ );
212
+ if (status === 0)
213
+ loading_status.succeed("Installed successfully! \u{1F60A}");
214
+ else
215
+ loading_status.fail("Failed to install \u{1F62D}");
216
+ } else if (exec === "pui") {
217
+ const loading_status = await loading(`Uninstalling ${params} ...
183
218
  `);
184
- const { status } = await simonJsTool.useNodeWorker(url, `cargo uninstall ${params}`);
185
- if (status === 0)
186
- loading_status.succeed("Uninstalled successfully! \u{1F60A}");
187
- else
188
- loading_status.fail("Failed to uninstall \u{1F62D}");
189
- } else if (exec === "prun") {
190
- simonJsTool.jsShell(`cargo run ${params}`);
191
- } else if (exec === "pinit") {
192
- simonJsTool.jsShell(`cargo init ${params}`);
193
- } else if (exec === "pbuild") {
194
- simonJsTool.jsShell(`cargo build ${params}`);
195
- } else {
196
- console.log("The commands is not supported");
219
+ const { status } = await index.useNodeWorker(
220
+ url,
221
+ `cargo uninstall ${params}`
222
+ );
223
+ if (status === 0)
224
+ loading_status.succeed("Uninstalled successfully! \u{1F60A}");
225
+ else
226
+ loading_status.fail("Failed to uninstall \u{1F62D}");
227
+ } else if (exec === "prun") {
228
+ index.jsShell(`cargo run ${params}`);
229
+ } else if (exec === "pinit") {
230
+ index.jsShell(`cargo init ${params}`);
231
+ } else if (exec === "pbuild") {
232
+ index.jsShell(`cargo build ${params}`);
233
+ } else {
234
+ console.log("The commands is not supported");
235
+ }
236
+ process__default.exit();
237
+ }
238
+ if (!runMap[exec]) {
239
+ console.log(
240
+ "The command does not exist, please execute pi -h to view the help"
241
+ );
242
+ return;
197
243
  }
198
- process__default.exit();
199
- }
200
- if (!runMap[exec]) {
201
- console.log("The command does not exist, please execute pi -h to view the help");
202
- return;
203
244
  }
204
245
  const pkg = argv.filter((v) => !v.startsWith("-")).join(" ");
205
246
  await installDeps();
package/dist/index.mjs CHANGED
@@ -1,11 +1,19 @@
1
1
  import path from 'path';
2
2
  import process from 'process';
3
3
  import { fileURLToPath } from 'url';
4
- import { useNodeWorker, jsShell, getPkgTool } from 'simon-js-tool';
4
+ import { u as useNodeWorker, j as jsShell, g as getPkgTool } from './chunks/index.mjs';
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';
7
15
 
8
- const version = "0.0.13";
16
+ const version = "0.0.15";
9
17
 
10
18
  const rootPath = process.cwd();
11
19
  const __filename = fileURLToPath(import.meta.url);
@@ -14,8 +22,10 @@ const url = path.resolve(__dirname, "./seprateThread.mjs");
14
22
  async function pi(params, pkg) {
15
23
  const text = pkg ? `Installing ${pkg} ...
16
24
  ` : "Updating dependency ...\n";
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}";
25
+ const successMsg = pkg ? `
26
+ Installed ${pkg} successfully! \u{1F60A}` : "Updated dependency successfully! \u{1F60A}";
27
+ const failMsg = pkg ? `
28
+ Failed to install ${pkg} \u{1F62D}` : "Failed to update dependency! \u{1F62D}";
19
29
  const loading_status = await loading(text);
20
30
  const { status } = await useNodeWorker(url, `ni ${params}`);
21
31
  if (status === 0)
@@ -27,8 +37,10 @@ async function pi(params, pkg) {
27
37
  async function pui(params, pkg) {
28
38
  const text = `Uninstalling ${pkg} ...
29
39
  `;
30
- const successMsg = `unInstalled ${pkg} successfully! \u{1F60A}`;
31
- const failMsg = `Failed to uninstall ${pkg} \u{1F62D}`;
40
+ const successMsg = `
41
+ UnInstalled ${pkg} successfully! \u{1F60A}`;
42
+ const failMsg = `
43
+ Failed to uninstall ${pkg} \u{1F62D}`;
32
44
  if (!pkg) {
33
45
  console.log("Need to specify an uninstall package name");
34
46
  process.exit(1);
@@ -66,7 +78,10 @@ function pinit() {
66
78
  async function getStyle() {
67
79
  const { result: _color = "yellow" } = await jsShell("echo $PI_COLOR", "pipe");
68
80
  const color = _color;
69
- const { result: _spinner = "star" } = await jsShell("echo $PI_SPINNER", "pipe");
81
+ const { result: _spinner = "star" } = await jsShell(
82
+ "echo $PI_SPINNER",
83
+ "pipe"
84
+ );
70
85
  const spinner = _spinner;
71
86
  return { color, spinner };
72
87
  }
@@ -87,7 +102,9 @@ function returnVersion(argv) {
87
102
  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'`);
88
103
  process.exit(0);
89
104
  } else if (arg === "-h" || arg === "--help") {
90
- 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' 'pfind: find monorepo of yarn or pnpm'`);
105
+ jsShell(
106
+ `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'`
107
+ );
91
108
  process.exit(0);
92
109
  }
93
110
  }
@@ -100,7 +117,10 @@ const runMap = {
100
117
  };
101
118
  function isGo() {
102
119
  const url2 = path.resolve(rootPath, "go.mod");
103
- const { result } = jsShell(`(test -f "main.go" || test -f "${url2}") && echo "0"|| echo "1"`, "pipe");
120
+ const { result } = jsShell(
121
+ `(test -f "main.go" || test -f "${url2}") && echo "0"|| echo "1"`,
122
+ "pipe"
123
+ );
104
124
  return result === "0";
105
125
  }
106
126
  function isRust() {
@@ -117,6 +137,11 @@ async function loading(text) {
117
137
  }).start();
118
138
  return result;
119
139
  }
140
+ function hasPkg() {
141
+ const url2 = path.resolve(rootPath, "package.json");
142
+ const { result } = jsShell(`test -f "${url2}" && echo "0"|| echo "1"`, "pipe");
143
+ return result === "0";
144
+ }
120
145
  async function runner() {
121
146
  const cmd = process.argv[1];
122
147
  const last = cmd.lastIndexOf("/") + 1;
@@ -124,71 +149,87 @@ async function runner() {
124
149
  const argv = process.argv.slice(2);
125
150
  returnVersion(argv);
126
151
  const params = argv.join(" ").trim();
127
- if (isGo()) {
128
- if (exec === "pi") {
129
- const loading_status = await loading(`Installing ${params} ...
152
+ if (!hasPkg()) {
153
+ if (isGo()) {
154
+ if (exec === "pi") {
155
+ const loading_status = await loading(`Installing ${params} ...
130
156
  `);
131
- const { status } = await useNodeWorker(url, `go get ${params}`);
132
- if (status === 0)
133
- loading_status.succeed("Installed successfully! \u{1F60A}");
134
- else
135
- loading_status.fail("Failed to install \u{1F62D}");
136
- } else if (exec === "pui") {
137
- const loading_status = await loading(`Uninstalling ${params} ...
157
+ const { status } = await useNodeWorker(
158
+ url,
159
+ `go get ${params}`
160
+ );
161
+ if (status === 0)
162
+ loading_status.succeed("Installed successfully! \u{1F60A}");
163
+ else
164
+ loading_status.fail("Failed to install \u{1F62D}");
165
+ } else if (exec === "pui") {
166
+ const loading_status = await loading(`Uninstalling ${params} ...
138
167
  `);
139
- const { status } = await useNodeWorker(url, `go clean ${params}`);
140
- if (status === 0)
141
- loading_status.succeed("Uninstalled successfully! \u{1F60A}");
142
- else
143
- loading_status.fail("Failed to uninstall \u{1F62D}");
144
- } else if (exec === "prun") {
145
- const match = params ? params.endsWith(".go") ? [`**/${params}`] : [`**/${params}.go`, `**/${params}/main.go`] : "main.go";
146
- const target = (await fg(match))[0];
147
- if (!target) {
148
- console.log("No such file");
149
- process.exit(1);
168
+ const { status } = await useNodeWorker(
169
+ url,
170
+ `go clean ${params}`
171
+ );
172
+ if (status === 0)
173
+ loading_status.succeed("Uninstalled successfully! \u{1F60A}");
174
+ else
175
+ loading_status.fail("Failed to uninstall \u{1F62D}");
176
+ } else if (exec === "prun") {
177
+ const match = params ? params.endsWith(".go") ? [`**/${params}`] : [`**/${params}.go`, `**/${params}/main.go`] : "main.go";
178
+ const target = (await fg(match))[0];
179
+ if (!target) {
180
+ console.log("No such file");
181
+ process.exit(1);
182
+ }
183
+ jsShell(`go run ${target}`);
184
+ } else if (exec === "pinit") {
185
+ jsShell(`go mod init ${params}`);
186
+ } else if (exec === "pbuild") {
187
+ jsShell(`go build ${params}`);
188
+ } else {
189
+ console.log("The commands is not supported");
150
190
  }
151
- jsShell(`go run ${target}`);
152
- } else if (exec === "pinit") {
153
- jsShell(`go mod init ${params}`);
154
- } else if (exec === "pbuild") {
155
- jsShell(`go build ${params}`);
156
- } else {
157
- console.log("The commands is not supported");
191
+ process.exit();
158
192
  }
159
- process.exit();
160
- }
161
- if (isRust()) {
162
- if (exec === "pi") {
163
- const loading_status = await loading(`Installing ${params} ...
193
+ if (isRust()) {
194
+ if (exec === "pi") {
195
+ const loading_status = await loading(`Installing ${params} ...
164
196
  `);
165
- const { status } = await useNodeWorker(url, `cargo install ${params}`);
166
- if (status === 0)
167
- loading_status.succeed("installed successfully! \u{1F60A}");
168
- else
169
- loading_status.fail("Failed to install \u{1F62D}");
170
- } else if (exec === "pui") {
171
- const loading_status = await loading(`Uninstalling ${params} ...
197
+ const { status } = await useNodeWorker(
198
+ url,
199
+ `cargo install ${params}`
200
+ );
201
+ if (status === 0)
202
+ loading_status.succeed("Installed successfully! \u{1F60A}");
203
+ else
204
+ loading_status.fail("Failed to install \u{1F62D}");
205
+ } else if (exec === "pui") {
206
+ const loading_status = await loading(`Uninstalling ${params} ...
172
207
  `);
173
- const { status } = await useNodeWorker(url, `cargo uninstall ${params}`);
174
- if (status === 0)
175
- loading_status.succeed("Uninstalled successfully! \u{1F60A}");
176
- else
177
- loading_status.fail("Failed to uninstall \u{1F62D}");
178
- } else if (exec === "prun") {
179
- jsShell(`cargo run ${params}`);
180
- } else if (exec === "pinit") {
181
- jsShell(`cargo init ${params}`);
182
- } else if (exec === "pbuild") {
183
- jsShell(`cargo build ${params}`);
184
- } else {
185
- console.log("The commands is not supported");
208
+ const { status } = await useNodeWorker(
209
+ url,
210
+ `cargo uninstall ${params}`
211
+ );
212
+ if (status === 0)
213
+ loading_status.succeed("Uninstalled successfully! \u{1F60A}");
214
+ else
215
+ loading_status.fail("Failed to uninstall \u{1F62D}");
216
+ } else if (exec === "prun") {
217
+ jsShell(`cargo run ${params}`);
218
+ } else if (exec === "pinit") {
219
+ jsShell(`cargo init ${params}`);
220
+ } else if (exec === "pbuild") {
221
+ jsShell(`cargo build ${params}`);
222
+ } else {
223
+ console.log("The commands is not supported");
224
+ }
225
+ process.exit();
226
+ }
227
+ if (!runMap[exec]) {
228
+ console.log(
229
+ "The command does not exist, please execute pi -h to view the help"
230
+ );
231
+ return;
186
232
  }
187
- process.exit();
188
- }
189
- if (!runMap[exec]) {
190
- console.log("The command does not exist, please execute pi -h to view the help");
191
- return;
192
233
  }
193
234
  const pkg = argv.filter((v) => !v.startsWith("-")).join(" ");
194
235
  await installDeps();
@@ -1,7 +1,15 @@
1
1
  'use strict';
2
2
 
3
- const simonJsTool = require('simon-js-tool');
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');
4
14
 
5
- simonJsTool.useProcressNodeWorker(
6
- async (command) => simonJsTool.jsShell(`${command}`, "pipe")
7
- );
15
+ index.useProcressNodeWorker(async (command) => index.jsShell(`${command}`, "pipe"));
@@ -1,5 +1,13 @@
1
- import { useProcressNodeWorker, jsShell } from 'simon-js-tool';
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';
2
12
 
3
- useProcressNodeWorker(
4
- async (command) => jsShell(`${command}`, "pipe")
5
- );
13
+ useProcressNodeWorker(async (command) => jsShell(`${command}`, "pipe"));
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2022 Anthony Fu <https://github.com/antfu>
3
+ Copyright (c) 2022 Simon He
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@simon_he/pi",
3
3
  "type": "module",
4
- "version": "0.0.13",
4
+ "version": "0.0.15",
5
5
  "packageManager": "pnpm@7.2.1",
6
6
  "description": "",
7
7
  "author": "Simon He",
@@ -45,8 +45,11 @@
45
45
  "dist"
46
46
  ],
47
47
  "scripts": {
48
+ "preinstall": "npx only-allow pnpm",
49
+ "postinstall": "simple-git-hooks",
48
50
  "build": "unbuild",
49
51
  "dev": "unbuild --stub",
52
+ "format": "prettier --write --cache .",
50
53
  "lint": "eslint .",
51
54
  "lint:fix": "eslint . --fix",
52
55
  "prepublishOnly": "nr build",
@@ -57,8 +60,7 @@
57
60
  },
58
61
  "dependencies": {
59
62
  "fast-glob": "^3.2.12",
60
- "ora": "^6.1.2",
61
- "simon-js-tool": "^4.1.27"
63
+ "ora": "^6.1.2"
62
64
  },
63
65
  "devDependencies": {
64
66
  "@antfu/eslint-config": "^0.25.2",
@@ -68,10 +70,25 @@
68
70
  "bumpp": "^8.2.1",
69
71
  "eslint": "^8.28.0",
70
72
  "esno": "^0.16.3",
73
+ "lint-staged": "^13.1.0",
74
+ "picocolors": "^1.0.0",
71
75
  "pnpm": "^7.17.0",
76
+ "prettier": "^2.8.1",
72
77
  "rimraf": "^3.0.2",
78
+ "simple-git-hooks": "^2.8.1",
79
+ "tsx": "^3.12.1",
73
80
  "typescript": "^4.9.3",
74
81
  "unbuild": "^0.7.6",
75
82
  "vitest": "^0.25.2"
83
+ },
84
+ "simple-git-hooks": {
85
+ "pre-commit": "pnpm exec lint-staged --concurrent false",
86
+ "commit-msg": "pnpm exec tsx scripts/verifyCommit.ts $1"
87
+ },
88
+ "lint-staged": {
89
+ "*": [
90
+ "prettier --write --cache --ignore-unknown"
91
+ ],
92
+ "*.{vue,js,ts,jsx,tsx,md,json}": "eslint --fix"
76
93
  }
77
94
  }