@simon_he/pi 0.0.6 → 0.0.8

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
@@ -1,45 +1,51 @@
1
1
  <span ><p align="center">![kv](/assets/pi.png)</p></span>
2
+ <p align="center"> English | <a href="./README_zh.md">简体中文</a></p>
3
+ <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&amp;label=" alt="NPM version"></a>
2
4
 
3
- ## PI
4
- 一个带有自定义loading样式的smart包管理器,让你安装依赖时更加美观:)
5
+ ## :lollipop: PI
6
+ A smart package manager with a custom loading style, which makes you install dependencies more beautifully :)
5
7
 
6
- ## 聪明的包管理器
7
- - 支持go mod 的依赖和执行
8
- - 支持Cargo 的依赖和执行
9
- - 支持npm 的依赖和执行
10
- - 支持pnpm 的依赖和执行
11
- - 支持yarn 的依赖和执行
8
+ ## :rocket: Smart package manager
9
+ - Supports dependency installation, uninstallation, execution and packaging of go mod
10
+ - Supports Cargo's dependency installation, uninstallation, execution and packaging
11
+ - Support npm dependency installation, uninstallation and execution
12
+ - Support pnpm dependency installation, uninstallation and execution
13
+ - Support yarn dependency installation, uninstallation and execution
12
14
 
13
15
 
14
16
  https://user-images.githubusercontent.com/57086651/203143603-9e78f686-399e-4c3d-ae53-56638501b276.mov
15
17
 
16
18
 
17
- ## 安装
19
+ ## :gear: Install
18
20
  ```
19
21
  npm i -g @simon_he/pi
20
22
  ```
21
23
 
22
- ## 使用
24
+ ## :open_hands: Usage
23
25
  ```
24
- # 根据当前目录的环境去分析使用哪种包管理器,go、rust、pnpm、yarn、npm
25
- # 安装依赖
26
+ # According to the environment of the current directory to analyze which package manager to use,go、rust、pnpm、yarn、npm
27
+ # Install dependencies
26
28
  pi xxx
27
- # 卸载依赖
29
+ # Uninstall dependencies
28
30
  pui xxx
29
- # 执行命令
31
+ # Execute command
30
32
  prun
33
+ # Initialization
34
+ pinit
35
+ # build - for cargo, go
36
+ pbuild
31
37
  ```
32
38
 
33
- ## 自定义配置
34
- 可以在.zshrc配置loading样式,如下:
39
+ ## :bulb: Custom configuration
40
+ You can configure the loading style in .zshrc, as follows:
35
41
  ```
36
- export PI_COLOR=red # loading样式颜色
37
- export PI_SPINNER=star # loading样式
42
+ export PI_COLOR=red # loadingstyle color
43
+ export PI_SPINNER=star # loadingstyle
38
44
  ```
39
- - 样式的种类70+,来源于[cli-spinners](https://jsfiddle.net/sindresorhus/2eLtsbey/embedded/result/),可自行选择将名字填入PI_SPINNER中。
40
- - 颜色可选值:'black' | 'red' | 'green' | 'yellow' | 'blue' | 'magenta' | 'cyan' | 'white' | 'gray', 填入PI_COLOR
45
+ - 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.
46
+ - Color options: 'black' | 'red' | 'green' | 'yellow' | 'blue' | 'magenta' | 'cyan' | 'white' | 'gray', Fill in PI_COLOR.
41
47
 
42
- ## 依赖
48
+ ## :battery: Dependency
43
49
  - [@antfu/ni](https://github.com/antfu/ni)
44
50
  - [ora](https://github.com/sindresorhus/ora)
45
51
  - [ccommand](https://github.com/Simon-He95/ccommand)
package/dist/index.cjs CHANGED
@@ -14,22 +14,22 @@ 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.6";
17
+ const version = "0.0.8";
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
22
  async function pi(params, pkg) {
23
23
  const text = pkg ? `Installing ${pkg} ...
24
- ` : "\u6B63\u5728\u66F4\u65B0\u4F9D\u8D56...\n";
25
- const successMsg = pkg ? `Installed ${pkg} successfully! \u{1F60A}` : "\u66F4\u65B0\u4F9D\u8D56\u6210\u529F! \u{1F60A}";
26
- const failMsg = pkg ? `Failed to install ${pkg} , v\u621150 \u{1F62D}` : "\u66F4\u65B0\u4F9D\u8D56\u5931\u8D25! \u{1F62D}";
27
- const { succeed, fail } = await loading(text);
28
- const { status } = await simonJsTool.useNodeWorker(url, { params, operate: "install" });
24
+ ` : "Updating dependency ...\n";
25
+ const successMsg = pkg ? `Installed ${pkg} successfully! \u{1F60A}` : "Updated dependency successfully! \u{1F60A}";
26
+ const failMsg = pkg ? `Failed to install ${pkg} \u{1F62D}` : "Failed to update dependency! \u{1F62D}";
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) {
@@ -38,22 +38,22 @@ async function pui(params, pkg) {
38
38
  const successMsg = `unInstalled ${pkg} successfully! \u{1F60A}`;
39
39
  const failMsg = `Failed to uninstall ${pkg} \u{1F62D}`;
40
40
  if (!pkg) {
41
- console.log("\u8BF7\u8F93\u5165\u8981\u5378\u8F7D\u7684\u5305\u540D");
41
+ console.log("Need to specify an uninstall package name");
42
42
  process__default.exit(1);
43
43
  }
44
- const { succeed, fail } = await loading(text);
45
- 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}`);
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, pkg) {
52
+ function prun(params) {
53
53
  simonJsTool.jsShell(`ccommand ${params}`);
54
54
  }
55
- function pinit(params, pkg) {
56
- console.log("\u6B63\u5728\u521D\u59CB\u5316\u9879\u76EE...");
55
+ function pinit() {
56
+ console.log("Initializing project...");
57
57
  switch (simonJsTool.getPkgTool()) {
58
58
  case "npm":
59
59
  simonJsTool.jsShell("npm init -y");
@@ -89,7 +89,7 @@ async function installDeps() {
89
89
  function returnVersion(argv) {
90
90
  const arg = argv[0];
91
91
  if (arg === "-v" || arg === "--version") {
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}'`);
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}' 'Please give me a \u{1F31F} for my efforts'`);
93
93
  process__default.exit(0);
94
94
  } else if (arg === "-h" || arg === "--help") {
95
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'`);
@@ -112,11 +112,12 @@ function isRust() {
112
112
  }
113
113
  async function loading(text) {
114
114
  const { color, spinner } = await getStyle();
115
- return ora__default({
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,54 +128,62 @@ 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.jsShell(`go get ${params}`);
133
- return;
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.jsShell(`go clean ${params}`);
138
- return;
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
- return;
152
+ } else {
153
+ console.log("The commands is not supported");
148
154
  }
149
- console.log("go mod \u9879\u76EE\u6682\u4E0D\u652F\u6301\u5176\u4ED6\u547D\u4EE4");
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.jsShell(`cargo install ${params}`);
157
- return;
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.jsShell(`cargo uninstall ${params}`);
162
- return;
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
- return;
180
+ } else {
181
+ console.log("The commands is not supported");
172
182
  }
173
- console.log("Cargo \u9879\u76EE\u6682\u4E0D\u652F\u6301\u5176\u4ED6\u547D\u4EE4");
174
- return;
183
+ process__default.exit();
175
184
  }
176
185
  if (!runMap[exec]) {
177
- console.log("\u547D\u4EE4\u4E0D\u5B58\u5728,\u8BF7\u6267\u884Cpi -h\u67E5\u770B\u5E2E\u52A9");
186
+ console.log("The command does not exist, please execute pi -h to view the help");
178
187
  return;
179
188
  }
180
189
  const pkg = argv.filter((v) => !v.startsWith("-")).join(" ");
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[], pkg?: string): void;
4
- declare function pinit(params: string[], pkg?: string): void;
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,22 +4,22 @@ 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.6";
7
+ const version = "0.0.8";
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
12
  async function pi(params, pkg) {
13
13
  const text = pkg ? `Installing ${pkg} ...
14
- ` : "\u6B63\u5728\u66F4\u65B0\u4F9D\u8D56...\n";
15
- const successMsg = pkg ? `Installed ${pkg} successfully! \u{1F60A}` : "\u66F4\u65B0\u4F9D\u8D56\u6210\u529F! \u{1F60A}";
16
- const failMsg = pkg ? `Failed to install ${pkg} , v\u621150 \u{1F62D}` : "\u66F4\u65B0\u4F9D\u8D56\u5931\u8D25! \u{1F62D}";
17
- const { succeed, fail } = await loading(text);
18
- const { status } = await useNodeWorker(url, { params, operate: "install" });
14
+ ` : "Updating dependency ...\n";
15
+ const successMsg = pkg ? `Installed ${pkg} successfully! \u{1F60A}` : "Updated dependency successfully! \u{1F60A}";
16
+ const failMsg = pkg ? `Failed to install ${pkg} \u{1F62D}` : "Failed to update dependency! \u{1F62D}";
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) {
@@ -28,22 +28,22 @@ async function pui(params, pkg) {
28
28
  const successMsg = `unInstalled ${pkg} successfully! \u{1F60A}`;
29
29
  const failMsg = `Failed to uninstall ${pkg} \u{1F62D}`;
30
30
  if (!pkg) {
31
- console.log("\u8BF7\u8F93\u5165\u8981\u5378\u8F7D\u7684\u5305\u540D");
31
+ console.log("Need to specify an uninstall package name");
32
32
  process.exit(1);
33
33
  }
34
- const { succeed, fail } = await loading(text);
35
- const { status } = await useNodeWorker(url, { params, operate: "uninstall" });
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, pkg) {
42
+ function prun(params) {
43
43
  jsShell(`ccommand ${params}`);
44
44
  }
45
- function pinit(params, pkg) {
46
- console.log("\u6B63\u5728\u521D\u59CB\u5316\u9879\u76EE...");
45
+ function pinit() {
46
+ console.log("Initializing project...");
47
47
  switch (getPkgTool()) {
48
48
  case "npm":
49
49
  jsShell("npm init -y");
@@ -79,7 +79,7 @@ async function installDeps() {
79
79
  function returnVersion(argv) {
80
80
  const arg = argv[0];
81
81
  if (arg === "-v" || arg === "--version") {
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}'`);
82
+ 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'`);
83
83
  process.exit(0);
84
84
  } else if (arg === "-h" || arg === "--help") {
85
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'`);
@@ -102,11 +102,12 @@ function isRust() {
102
102
  }
103
103
  async function loading(text) {
104
104
  const { color, spinner } = await getStyle();
105
- return ora({
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,54 +118,62 @@ 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
- jsShell(`go get ${params}`);
123
- return;
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
- jsShell(`go clean ${params}`);
128
- return;
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
- return;
142
+ } else {
143
+ console.log("The commands is not supported");
138
144
  }
139
- console.log("go mod \u9879\u76EE\u6682\u4E0D\u652F\u6301\u5176\u4ED6\u547D\u4EE4");
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
- jsShell(`cargo install ${params}`);
147
- return;
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
- jsShell(`cargo uninstall ${params}`);
152
- return;
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
- return;
170
+ } else {
171
+ console.log("The commands is not supported");
162
172
  }
163
- console.log("Cargo \u9879\u76EE\u6682\u4E0D\u652F\u6301\u5176\u4ED6\u547D\u4EE4");
164
- return;
173
+ process.exit();
165
174
  }
166
175
  if (!runMap[exec]) {
167
- console.log("\u547D\u4EE4\u4E0D\u5B58\u5728,\u8BF7\u6267\u884Cpi -h\u67E5\u770B\u5E2E\u52A9");
176
+ console.log("The command does not exist, please execute pi -h to view the help");
168
177
  return;
169
178
  }
170
179
  const pkg = argv.filter((v) => !v.startsWith("-")).join(" ");
@@ -3,5 +3,5 @@
3
3
  const simonJsTool = require('simon-js-tool');
4
4
 
5
5
  simonJsTool.useProcressNodeWorker(
6
- async ({ params, operate }) => simonJsTool.jsShell(`${operate === "install" ? "ni" : "nun"} ${params}`, "pipe")
6
+ async (command) => simonJsTool.jsShell(`${command}`, "pipe")
7
7
  );
@@ -1,5 +1,5 @@
1
1
  import { useProcressNodeWorker, jsShell } from 'simon-js-tool';
2
2
 
3
3
  useProcressNodeWorker(
4
- async ({ params, operate }) => jsShell(`${operate === "install" ? "ni" : "nun"} ${params}`, "pipe")
4
+ async (command) => jsShell(`${command}`, "pipe")
5
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.6",
4
+ "version": "0.0.8",
5
5
  "packageManager": "pnpm@7.2.1",
6
6
  "description": "",
7
7
  "author": "Simon He",