@simon_he/pi 0.0.8 → 0.0.10
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 +1 -1
- package/dist/index.cjs +16 -5
- package/dist/index.mjs +15 -5
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -42,7 +42,7 @@ You can configure the loading style in .zshrc, as follows:
|
|
|
42
42
|
export PI_COLOR=red # loadingstyle color
|
|
43
43
|
export PI_SPINNER=star # loadingstyle
|
|
44
44
|
```
|
|
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.
|
|
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
46
|
- Color options: 'black' | 'red' | 'green' | 'yellow' | 'blue' | 'magenta' | 'cyan' | 'white' | 'gray', Fill in PI_COLOR.
|
|
47
47
|
|
|
48
48
|
## :battery: Dependency
|
package/dist/index.cjs
CHANGED
|
@@ -7,15 +7,18 @@ const process = require('process');
|
|
|
7
7
|
const url$1 = require('url');
|
|
8
8
|
const simonJsTool = require('simon-js-tool');
|
|
9
9
|
const ora = require('ora');
|
|
10
|
+
const fg = require('fast-glob');
|
|
10
11
|
|
|
11
12
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
|
|
12
13
|
|
|
13
14
|
const path__default = /*#__PURE__*/_interopDefaultLegacy(path);
|
|
14
15
|
const process__default = /*#__PURE__*/_interopDefaultLegacy(process);
|
|
15
16
|
const ora__default = /*#__PURE__*/_interopDefaultLegacy(ora);
|
|
17
|
+
const fg__default = /*#__PURE__*/_interopDefaultLegacy(fg);
|
|
16
18
|
|
|
17
|
-
const version = "0.0.
|
|
19
|
+
const version = "0.0.10";
|
|
18
20
|
|
|
21
|
+
const rootPath = process__default.cwd();
|
|
19
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)));
|
|
20
23
|
const __dirname$1 = path__default.dirname(__filename$1);
|
|
21
24
|
const url = path__default.resolve(__dirname$1, "./seprateThread.mjs");
|
|
@@ -103,11 +106,13 @@ const runMap = {
|
|
|
103
106
|
pinit
|
|
104
107
|
};
|
|
105
108
|
function isGo() {
|
|
106
|
-
const
|
|
109
|
+
const url2 = path__default.resolve(rootPath, "go.mod");
|
|
110
|
+
const { result } = simonJsTool.jsShell(`(test -f "main.go" || test -f "${url2}") && echo "0"|| echo "1"`, "pipe");
|
|
107
111
|
return result === "0";
|
|
108
112
|
}
|
|
109
113
|
function isRust() {
|
|
110
|
-
const
|
|
114
|
+
const url2 = path__default.resolve(rootPath, "Cargo.toml");
|
|
115
|
+
const { result } = simonJsTool.jsShell(`test -f "${url2}" && echo "0"|| echo "1"`, "pipe");
|
|
111
116
|
return result === "0";
|
|
112
117
|
}
|
|
113
118
|
async function loading(text) {
|
|
@@ -125,7 +130,7 @@ async function runner() {
|
|
|
125
130
|
const exec = cmd.slice(last, cmd.length);
|
|
126
131
|
const argv = process__default.argv.slice(2);
|
|
127
132
|
returnVersion(argv);
|
|
128
|
-
const params = argv.join(" ");
|
|
133
|
+
const params = argv.join(" ").trim();
|
|
129
134
|
if (isGo()) {
|
|
130
135
|
if (exec === "pi") {
|
|
131
136
|
const loading_status = await loading(`Installing ${params} ...
|
|
@@ -144,7 +149,13 @@ async function runner() {
|
|
|
144
149
|
else
|
|
145
150
|
loading_status.fail("Failed to uninstall \u{1F62D}");
|
|
146
151
|
} else if (exec === "prun") {
|
|
147
|
-
|
|
152
|
+
const match = params ? params.endsWith(".go") ? [`**/${params}`] : [`**/${params}.go`, `**/${params}/main.go`] : "main.go";
|
|
153
|
+
const target = (await fg__default(match))[0];
|
|
154
|
+
if (!target) {
|
|
155
|
+
console.log("No such file");
|
|
156
|
+
process__default.exit(1);
|
|
157
|
+
}
|
|
158
|
+
simonJsTool.jsShell(`go run ${target}`);
|
|
148
159
|
} else if (exec === "pinit") {
|
|
149
160
|
simonJsTool.jsShell(`go mod init ${params}`);
|
|
150
161
|
} else if (exec === "pbuild") {
|
package/dist/index.mjs
CHANGED
|
@@ -3,9 +3,11 @@ import process from 'process';
|
|
|
3
3
|
import { fileURLToPath } from 'url';
|
|
4
4
|
import { useNodeWorker, jsShell, getPkgTool } from 'simon-js-tool';
|
|
5
5
|
import ora from 'ora';
|
|
6
|
+
import fg from 'fast-glob';
|
|
6
7
|
|
|
7
|
-
const version = "0.0.
|
|
8
|
+
const version = "0.0.10";
|
|
8
9
|
|
|
10
|
+
const rootPath = process.cwd();
|
|
9
11
|
const __filename = fileURLToPath(import.meta.url);
|
|
10
12
|
const __dirname = path.dirname(__filename);
|
|
11
13
|
const url = path.resolve(__dirname, "./seprateThread.mjs");
|
|
@@ -93,11 +95,13 @@ const runMap = {
|
|
|
93
95
|
pinit
|
|
94
96
|
};
|
|
95
97
|
function isGo() {
|
|
96
|
-
const
|
|
98
|
+
const url2 = path.resolve(rootPath, "go.mod");
|
|
99
|
+
const { result } = jsShell(`(test -f "main.go" || test -f "${url2}") && echo "0"|| echo "1"`, "pipe");
|
|
97
100
|
return result === "0";
|
|
98
101
|
}
|
|
99
102
|
function isRust() {
|
|
100
|
-
const
|
|
103
|
+
const url2 = path.resolve(rootPath, "Cargo.toml");
|
|
104
|
+
const { result } = jsShell(`test -f "${url2}" && echo "0"|| echo "1"`, "pipe");
|
|
101
105
|
return result === "0";
|
|
102
106
|
}
|
|
103
107
|
async function loading(text) {
|
|
@@ -115,7 +119,7 @@ async function runner() {
|
|
|
115
119
|
const exec = cmd.slice(last, cmd.length);
|
|
116
120
|
const argv = process.argv.slice(2);
|
|
117
121
|
returnVersion(argv);
|
|
118
|
-
const params = argv.join(" ");
|
|
122
|
+
const params = argv.join(" ").trim();
|
|
119
123
|
if (isGo()) {
|
|
120
124
|
if (exec === "pi") {
|
|
121
125
|
const loading_status = await loading(`Installing ${params} ...
|
|
@@ -134,7 +138,13 @@ async function runner() {
|
|
|
134
138
|
else
|
|
135
139
|
loading_status.fail("Failed to uninstall \u{1F62D}");
|
|
136
140
|
} else if (exec === "prun") {
|
|
137
|
-
|
|
141
|
+
const match = params ? params.endsWith(".go") ? [`**/${params}`] : [`**/${params}.go`, `**/${params}/main.go`] : "main.go";
|
|
142
|
+
const target = (await fg(match))[0];
|
|
143
|
+
if (!target) {
|
|
144
|
+
console.log("No such file");
|
|
145
|
+
process.exit(1);
|
|
146
|
+
}
|
|
147
|
+
jsShell(`go run ${target}`);
|
|
138
148
|
} else if (exec === "pinit") {
|
|
139
149
|
jsShell(`go mod init ${params}`);
|
|
140
150
|
} else if (exec === "pbuild") {
|
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.10",
|
|
5
5
|
"packageManager": "pnpm@7.2.1",
|
|
6
6
|
"description": "",
|
|
7
7
|
"author": "Simon He",
|
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
"chalk": "^5.1.2",
|
|
60
60
|
"clipboardy": "^3.0.0",
|
|
61
61
|
"dot-text": "^1.0.7",
|
|
62
|
+
"fast-glob": "^3.2.12",
|
|
62
63
|
"libnpmsearch": "^6.0.0",
|
|
63
64
|
"ora": "^6.1.2",
|
|
64
65
|
"simon-js-tool": "^4.1.27",
|