@simon_he/pi 0.0.13 → 0.0.14
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 +3 -0
- package/dist/index.cjs +74 -63
- package/dist/index.mjs +74 -63
- package/{LICENSE → license} +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -79,5 +79,8 @@ export PI_SPINNER=star # loadingstyle
|
|
|
79
79
|
- [ccommand](https://github.com/Simon-He95/ccommand)
|
|
80
80
|
|
|
81
81
|
|
|
82
|
+
## License
|
|
83
|
+
[MIT](./LICENSE) License © 2022 [Simon He](https://github.com/Simon-He95)
|
|
84
|
+
|
|
82
85
|
## :coffee:
|
|
83
86
|
<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
|
@@ -16,7 +16,7 @@ const process__default = /*#__PURE__*/_interopDefaultLegacy(process);
|
|
|
16
16
|
const ora__default = /*#__PURE__*/_interopDefaultLegacy(ora);
|
|
17
17
|
const fg__default = /*#__PURE__*/_interopDefaultLegacy(fg);
|
|
18
18
|
|
|
19
|
-
const version = "0.0.
|
|
19
|
+
const version = "0.0.14";
|
|
20
20
|
|
|
21
21
|
const rootPath = process__default.cwd();
|
|
22
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)));
|
|
@@ -25,8 +25,10 @@ const url = path__default.resolve(__dirname$1, "./seprateThread.mjs");
|
|
|
25
25
|
async function pi(params, pkg) {
|
|
26
26
|
const text = pkg ? `Installing ${pkg} ...
|
|
27
27
|
` : "Updating dependency ...\n";
|
|
28
|
-
const successMsg = pkg ? `
|
|
29
|
-
|
|
28
|
+
const successMsg = pkg ? `
|
|
29
|
+
Installed ${pkg} successfully! \u{1F60A}` : "Updated dependency successfully! \u{1F60A}";
|
|
30
|
+
const failMsg = pkg ? `
|
|
31
|
+
Failed to install ${pkg} \u{1F62D}` : "Failed to update dependency! \u{1F62D}";
|
|
30
32
|
const loading_status = await loading(text);
|
|
31
33
|
const { status } = await simonJsTool.useNodeWorker(url, `ni ${params}`);
|
|
32
34
|
if (status === 0)
|
|
@@ -38,8 +40,10 @@ async function pi(params, pkg) {
|
|
|
38
40
|
async function pui(params, pkg) {
|
|
39
41
|
const text = `Uninstalling ${pkg} ...
|
|
40
42
|
`;
|
|
41
|
-
const successMsg = `
|
|
42
|
-
|
|
43
|
+
const successMsg = `
|
|
44
|
+
UnInstalled ${pkg} successfully! \u{1F60A}`;
|
|
45
|
+
const failMsg = `
|
|
46
|
+
Failed to uninstall ${pkg} \u{1F62D}`;
|
|
43
47
|
if (!pkg) {
|
|
44
48
|
console.log("Need to specify an uninstall package name");
|
|
45
49
|
process__default.exit(1);
|
|
@@ -128,6 +132,11 @@ async function loading(text) {
|
|
|
128
132
|
}).start();
|
|
129
133
|
return result;
|
|
130
134
|
}
|
|
135
|
+
function hasPkg() {
|
|
136
|
+
const url2 = path__default.resolve(rootPath, "package.json");
|
|
137
|
+
const { result } = simonJsTool.jsShell(`test -f "${url2}" && echo "0"|| echo "1"`, "pipe");
|
|
138
|
+
return result === "0";
|
|
139
|
+
}
|
|
131
140
|
async function runner() {
|
|
132
141
|
const cmd = process__default.argv[1];
|
|
133
142
|
const last = cmd.lastIndexOf("/") + 1;
|
|
@@ -135,71 +144,73 @@ async function runner() {
|
|
|
135
144
|
const argv = process__default.argv.slice(2);
|
|
136
145
|
returnVersion(argv);
|
|
137
146
|
const params = argv.join(" ").trim();
|
|
138
|
-
if (
|
|
139
|
-
if (
|
|
140
|
-
|
|
147
|
+
if (!hasPkg()) {
|
|
148
|
+
if (isGo()) {
|
|
149
|
+
if (exec === "pi") {
|
|
150
|
+
const loading_status = await loading(`Installing ${params} ...
|
|
141
151
|
`);
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
152
|
+
const { status } = await simonJsTool.useNodeWorker(url, `go get ${params}`);
|
|
153
|
+
if (status === 0)
|
|
154
|
+
loading_status.succeed("Installed successfully! \u{1F60A}");
|
|
155
|
+
else
|
|
156
|
+
loading_status.fail("Failed to install \u{1F62D}");
|
|
157
|
+
} else if (exec === "pui") {
|
|
158
|
+
const loading_status = await loading(`Uninstalling ${params} ...
|
|
149
159
|
`);
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
160
|
+
const { status } = await simonJsTool.useNodeWorker(url, `go clean ${params}`);
|
|
161
|
+
if (status === 0)
|
|
162
|
+
loading_status.succeed("Uninstalled successfully! \u{1F60A}");
|
|
163
|
+
else
|
|
164
|
+
loading_status.fail("Failed to uninstall \u{1F62D}");
|
|
165
|
+
} else if (exec === "prun") {
|
|
166
|
+
const match = params ? params.endsWith(".go") ? [`**/${params}`] : [`**/${params}.go`, `**/${params}/main.go`] : "main.go";
|
|
167
|
+
const target = (await fg__default(match))[0];
|
|
168
|
+
if (!target) {
|
|
169
|
+
console.log("No such file");
|
|
170
|
+
process__default.exit(1);
|
|
171
|
+
}
|
|
172
|
+
simonJsTool.jsShell(`go run ${target}`);
|
|
173
|
+
} else if (exec === "pinit") {
|
|
174
|
+
simonJsTool.jsShell(`go mod init ${params}`);
|
|
175
|
+
} else if (exec === "pbuild") {
|
|
176
|
+
simonJsTool.jsShell(`go build ${params}`);
|
|
177
|
+
} else {
|
|
178
|
+
console.log("The commands is not supported");
|
|
161
179
|
}
|
|
162
|
-
|
|
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");
|
|
180
|
+
process__default.exit();
|
|
169
181
|
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
if (exec === "pi") {
|
|
174
|
-
const loading_status = await loading(`Installing ${params} ...
|
|
182
|
+
if (isRust()) {
|
|
183
|
+
if (exec === "pi") {
|
|
184
|
+
const loading_status = await loading(`Installing ${params} ...
|
|
175
185
|
`);
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
186
|
+
const { status } = await simonJsTool.useNodeWorker(url, `cargo install ${params}`);
|
|
187
|
+
if (status === 0)
|
|
188
|
+
loading_status.succeed("Installed successfully! \u{1F60A}");
|
|
189
|
+
else
|
|
190
|
+
loading_status.fail("Failed to install \u{1F62D}");
|
|
191
|
+
} else if (exec === "pui") {
|
|
192
|
+
const loading_status = await loading(`Uninstalling ${params} ...
|
|
183
193
|
`);
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
194
|
+
const { status } = await simonJsTool.useNodeWorker(url, `cargo uninstall ${params}`);
|
|
195
|
+
if (status === 0)
|
|
196
|
+
loading_status.succeed("Uninstalled successfully! \u{1F60A}");
|
|
197
|
+
else
|
|
198
|
+
loading_status.fail("Failed to uninstall \u{1F62D}");
|
|
199
|
+
} else if (exec === "prun") {
|
|
200
|
+
simonJsTool.jsShell(`cargo run ${params}`);
|
|
201
|
+
} else if (exec === "pinit") {
|
|
202
|
+
simonJsTool.jsShell(`cargo init ${params}`);
|
|
203
|
+
} else if (exec === "pbuild") {
|
|
204
|
+
simonJsTool.jsShell(`cargo build ${params}`);
|
|
205
|
+
} else {
|
|
206
|
+
console.log("The commands is not supported");
|
|
207
|
+
}
|
|
208
|
+
process__default.exit();
|
|
209
|
+
}
|
|
210
|
+
if (!runMap[exec]) {
|
|
211
|
+
console.log("The command does not exist, please execute pi -h to view the help");
|
|
212
|
+
return;
|
|
197
213
|
}
|
|
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
214
|
}
|
|
204
215
|
const pkg = argv.filter((v) => !v.startsWith("-")).join(" ");
|
|
205
216
|
await installDeps();
|
package/dist/index.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import { useNodeWorker, jsShell, getPkgTool } from 'simon-js-tool';
|
|
|
5
5
|
import ora from 'ora';
|
|
6
6
|
import fg from 'fast-glob';
|
|
7
7
|
|
|
8
|
-
const version = "0.0.
|
|
8
|
+
const version = "0.0.14";
|
|
9
9
|
|
|
10
10
|
const rootPath = process.cwd();
|
|
11
11
|
const __filename = fileURLToPath(import.meta.url);
|
|
@@ -14,8 +14,10 @@ const url = path.resolve(__dirname, "./seprateThread.mjs");
|
|
|
14
14
|
async function pi(params, pkg) {
|
|
15
15
|
const text = pkg ? `Installing ${pkg} ...
|
|
16
16
|
` : "Updating dependency ...\n";
|
|
17
|
-
const successMsg = pkg ? `
|
|
18
|
-
|
|
17
|
+
const successMsg = pkg ? `
|
|
18
|
+
Installed ${pkg} successfully! \u{1F60A}` : "Updated dependency successfully! \u{1F60A}";
|
|
19
|
+
const failMsg = pkg ? `
|
|
20
|
+
Failed to install ${pkg} \u{1F62D}` : "Failed to update dependency! \u{1F62D}";
|
|
19
21
|
const loading_status = await loading(text);
|
|
20
22
|
const { status } = await useNodeWorker(url, `ni ${params}`);
|
|
21
23
|
if (status === 0)
|
|
@@ -27,8 +29,10 @@ async function pi(params, pkg) {
|
|
|
27
29
|
async function pui(params, pkg) {
|
|
28
30
|
const text = `Uninstalling ${pkg} ...
|
|
29
31
|
`;
|
|
30
|
-
const successMsg = `
|
|
31
|
-
|
|
32
|
+
const successMsg = `
|
|
33
|
+
UnInstalled ${pkg} successfully! \u{1F60A}`;
|
|
34
|
+
const failMsg = `
|
|
35
|
+
Failed to uninstall ${pkg} \u{1F62D}`;
|
|
32
36
|
if (!pkg) {
|
|
33
37
|
console.log("Need to specify an uninstall package name");
|
|
34
38
|
process.exit(1);
|
|
@@ -117,6 +121,11 @@ async function loading(text) {
|
|
|
117
121
|
}).start();
|
|
118
122
|
return result;
|
|
119
123
|
}
|
|
124
|
+
function hasPkg() {
|
|
125
|
+
const url2 = path.resolve(rootPath, "package.json");
|
|
126
|
+
const { result } = jsShell(`test -f "${url2}" && echo "0"|| echo "1"`, "pipe");
|
|
127
|
+
return result === "0";
|
|
128
|
+
}
|
|
120
129
|
async function runner() {
|
|
121
130
|
const cmd = process.argv[1];
|
|
122
131
|
const last = cmd.lastIndexOf("/") + 1;
|
|
@@ -124,71 +133,73 @@ async function runner() {
|
|
|
124
133
|
const argv = process.argv.slice(2);
|
|
125
134
|
returnVersion(argv);
|
|
126
135
|
const params = argv.join(" ").trim();
|
|
127
|
-
if (
|
|
128
|
-
if (
|
|
129
|
-
|
|
136
|
+
if (!hasPkg()) {
|
|
137
|
+
if (isGo()) {
|
|
138
|
+
if (exec === "pi") {
|
|
139
|
+
const loading_status = await loading(`Installing ${params} ...
|
|
130
140
|
`);
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
141
|
+
const { status } = await useNodeWorker(url, `go get ${params}`);
|
|
142
|
+
if (status === 0)
|
|
143
|
+
loading_status.succeed("Installed successfully! \u{1F60A}");
|
|
144
|
+
else
|
|
145
|
+
loading_status.fail("Failed to install \u{1F62D}");
|
|
146
|
+
} else if (exec === "pui") {
|
|
147
|
+
const loading_status = await loading(`Uninstalling ${params} ...
|
|
138
148
|
`);
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
149
|
+
const { status } = await useNodeWorker(url, `go clean ${params}`);
|
|
150
|
+
if (status === 0)
|
|
151
|
+
loading_status.succeed("Uninstalled successfully! \u{1F60A}");
|
|
152
|
+
else
|
|
153
|
+
loading_status.fail("Failed to uninstall \u{1F62D}");
|
|
154
|
+
} else if (exec === "prun") {
|
|
155
|
+
const match = params ? params.endsWith(".go") ? [`**/${params}`] : [`**/${params}.go`, `**/${params}/main.go`] : "main.go";
|
|
156
|
+
const target = (await fg(match))[0];
|
|
157
|
+
if (!target) {
|
|
158
|
+
console.log("No such file");
|
|
159
|
+
process.exit(1);
|
|
160
|
+
}
|
|
161
|
+
jsShell(`go run ${target}`);
|
|
162
|
+
} else if (exec === "pinit") {
|
|
163
|
+
jsShell(`go mod init ${params}`);
|
|
164
|
+
} else if (exec === "pbuild") {
|
|
165
|
+
jsShell(`go build ${params}`);
|
|
166
|
+
} else {
|
|
167
|
+
console.log("The commands is not supported");
|
|
150
168
|
}
|
|
151
|
-
|
|
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");
|
|
169
|
+
process.exit();
|
|
158
170
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
if (exec === "pi") {
|
|
163
|
-
const loading_status = await loading(`Installing ${params} ...
|
|
171
|
+
if (isRust()) {
|
|
172
|
+
if (exec === "pi") {
|
|
173
|
+
const loading_status = await loading(`Installing ${params} ...
|
|
164
174
|
`);
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
175
|
+
const { status } = await useNodeWorker(url, `cargo install ${params}`);
|
|
176
|
+
if (status === 0)
|
|
177
|
+
loading_status.succeed("Installed successfully! \u{1F60A}");
|
|
178
|
+
else
|
|
179
|
+
loading_status.fail("Failed to install \u{1F62D}");
|
|
180
|
+
} else if (exec === "pui") {
|
|
181
|
+
const loading_status = await loading(`Uninstalling ${params} ...
|
|
172
182
|
`);
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
183
|
+
const { status } = await useNodeWorker(url, `cargo uninstall ${params}`);
|
|
184
|
+
if (status === 0)
|
|
185
|
+
loading_status.succeed("Uninstalled successfully! \u{1F60A}");
|
|
186
|
+
else
|
|
187
|
+
loading_status.fail("Failed to uninstall \u{1F62D}");
|
|
188
|
+
} else if (exec === "prun") {
|
|
189
|
+
jsShell(`cargo run ${params}`);
|
|
190
|
+
} else if (exec === "pinit") {
|
|
191
|
+
jsShell(`cargo init ${params}`);
|
|
192
|
+
} else if (exec === "pbuild") {
|
|
193
|
+
jsShell(`cargo build ${params}`);
|
|
194
|
+
} else {
|
|
195
|
+
console.log("The commands is not supported");
|
|
196
|
+
}
|
|
197
|
+
process.exit();
|
|
198
|
+
}
|
|
199
|
+
if (!runMap[exec]) {
|
|
200
|
+
console.log("The command does not exist, please execute pi -h to view the help");
|
|
201
|
+
return;
|
|
186
202
|
}
|
|
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
203
|
}
|
|
193
204
|
const pkg = argv.filter((v) => !v.startsWith("-")).join(" ");
|
|
194
205
|
await installDeps();
|
package/{LICENSE → license}
RENAMED