@0x-jerry/x 2.6.1 → 2.7.1
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/chunk-4D26Y5PK.js +6 -0
- package/dist/x.js +7 -4
- package/dist/xn.js +46 -25
- package/dist/xr.js +4 -1
- package/package.json +4 -4
- package/readme.md +76 -1
package/dist/x.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
version
|
|
4
|
+
} from "./chunk-4D26Y5PK.js";
|
|
2
5
|
|
|
3
6
|
// src/x.ts
|
|
4
7
|
import { sliver } from "@0x-jerry/silver";
|
|
@@ -101,12 +104,12 @@ import { bootstrap } from "global-agent";
|
|
|
101
104
|
bootstrap({
|
|
102
105
|
environmentVariableNamespace: ""
|
|
103
106
|
});
|
|
104
|
-
|
|
105
|
-
|
|
107
|
+
sliver`
|
|
108
|
+
v${version} @autocompletion
|
|
106
109
|
|
|
107
|
-
x,
|
|
110
|
+
x, has some useful subcommand.
|
|
108
111
|
|
|
109
|
-
t/template [dest
|
|
112
|
+
t/template [dest], download git repo as a template. ${defaultAction}
|
|
110
113
|
|
|
111
114
|
-u --url, Git url to download with. eg. -u 0x-jerry/x, -u https://github.com/0x-jerry/x
|
|
112
115
|
-b --branch, Git branch.
|
package/dist/xn.js
CHANGED
|
@@ -4,6 +4,9 @@ import {
|
|
|
4
4
|
exists,
|
|
5
5
|
flagOptionToStringArray
|
|
6
6
|
} from "./chunk-WA6Z2RU3.js";
|
|
7
|
+
import {
|
|
8
|
+
version
|
|
9
|
+
} from "./chunk-4D26Y5PK.js";
|
|
7
10
|
|
|
8
11
|
// src/xn.ts
|
|
9
12
|
import { sliver } from "@0x-jerry/silver";
|
|
@@ -43,18 +46,24 @@ var NodeDependencyManager = class {
|
|
|
43
46
|
await runDepManagerCommand("install");
|
|
44
47
|
}
|
|
45
48
|
async add(modules, option = {}) {
|
|
46
|
-
|
|
47
|
-
|
|
49
|
+
const { t, types, ...otherOption } = option;
|
|
50
|
+
await runDepManagerCommand(
|
|
51
|
+
"add",
|
|
52
|
+
...modules,
|
|
53
|
+
...flagOptionToStringArray(otherOption)
|
|
54
|
+
);
|
|
55
|
+
if (types) {
|
|
48
56
|
const typeModules = modules.map((pkg) => getTypePackageName(pkg));
|
|
49
57
|
await runDepManagerCommand("add", ...typeModules, "-D");
|
|
50
58
|
}
|
|
51
59
|
}
|
|
52
60
|
async remove(modules, option = {}) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
...
|
|
57
|
-
|
|
61
|
+
console.log(option);
|
|
62
|
+
if (option.types) {
|
|
63
|
+
const typeModules = modules.map((pkg) => getTypePackageName(pkg));
|
|
64
|
+
modules.push(...typeModules);
|
|
65
|
+
}
|
|
66
|
+
await runDepManagerCommand("remove", ...modules);
|
|
58
67
|
}
|
|
59
68
|
async upgrade(modules, option = {}) {
|
|
60
69
|
await runDepManagerCommand(
|
|
@@ -185,51 +194,63 @@ var DepManager = class {
|
|
|
185
194
|
;
|
|
186
195
|
(await this._getManager())?.install(option);
|
|
187
196
|
}
|
|
188
|
-
async add(
|
|
197
|
+
async add(params, option) {
|
|
189
198
|
;
|
|
190
|
-
(await this._getManager())?.add(
|
|
199
|
+
(await this._getManager())?.add(params, option);
|
|
191
200
|
}
|
|
192
|
-
async remove(
|
|
201
|
+
async remove(params, option) {
|
|
193
202
|
;
|
|
194
|
-
(await this._getManager())?.remove(
|
|
203
|
+
(await this._getManager())?.remove(params, option);
|
|
195
204
|
}
|
|
196
|
-
async upgrade(
|
|
205
|
+
async upgrade(params, option) {
|
|
197
206
|
;
|
|
198
|
-
(await this._getManager())?.upgrade(
|
|
207
|
+
(await this._getManager())?.upgrade(params, option);
|
|
199
208
|
}
|
|
200
209
|
};
|
|
201
210
|
|
|
202
211
|
// src/xn.ts
|
|
203
212
|
sliver`
|
|
204
|
-
@help @autocompletion
|
|
213
|
+
v${version} @help @autocompletion
|
|
205
214
|
|
|
206
|
-
xn,
|
|
215
|
+
xn, is a dependency manage tool, it is support node/deno/cargo. ${defaultAction}
|
|
207
216
|
|
|
208
|
-
i/install [...modules]
|
|
217
|
+
i/install [...modules], Install dependencies. ${installAction}
|
|
209
218
|
|
|
210
|
-
-t --types @bool, install package's
|
|
219
|
+
-t --types @bool, install package's type too, only take effect in node project.
|
|
211
220
|
|
|
212
|
-
up/upgrade [...modules]
|
|
221
|
+
up/upgrade [...modules], Upgrade dependencies. ${upgradeAction}
|
|
213
222
|
|
|
214
|
-
rm/remove <...modules
|
|
223
|
+
rm/remove <...modules>, Remove dependencies. ${removeAction}
|
|
224
|
+
|
|
225
|
+
-t --types @bool, remove package's type too, only take effect in node project.
|
|
215
226
|
`;
|
|
216
227
|
async function defaultAction() {
|
|
217
228
|
await new DepManager().install();
|
|
218
229
|
}
|
|
219
230
|
async function installAction(_, opt) {
|
|
220
|
-
const params = opt
|
|
231
|
+
const { params, options } = getParameters(opt);
|
|
221
232
|
const installOnly = !params.length;
|
|
222
233
|
if (installOnly) {
|
|
223
|
-
await new DepManager().install(
|
|
234
|
+
await new DepManager().install(options);
|
|
224
235
|
return;
|
|
225
236
|
}
|
|
226
|
-
await new DepManager().add(params,
|
|
237
|
+
await new DepManager().add(params, options);
|
|
227
238
|
}
|
|
228
239
|
async function upgradeAction(_, opt) {
|
|
229
|
-
const params = opt
|
|
230
|
-
await new DepManager().upgrade(params,
|
|
240
|
+
const { params, options } = getParameters(opt);
|
|
241
|
+
await new DepManager().upgrade(params, options);
|
|
231
242
|
}
|
|
232
243
|
async function removeAction(_, opt) {
|
|
244
|
+
const { params, options } = getParameters(opt);
|
|
245
|
+
await new DepManager().remove(params, options);
|
|
246
|
+
}
|
|
247
|
+
function getParameters(opt) {
|
|
233
248
|
const params = opt._;
|
|
234
|
-
|
|
249
|
+
const otherOpt = { ...opt };
|
|
250
|
+
delete otherOpt._;
|
|
251
|
+
delete otherOpt["--"];
|
|
252
|
+
return {
|
|
253
|
+
params,
|
|
254
|
+
options: otherOpt
|
|
255
|
+
};
|
|
235
256
|
}
|
package/dist/xr.js
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
import {
|
|
3
3
|
exec
|
|
4
4
|
} from "./chunk-WA6Z2RU3.js";
|
|
5
|
+
import {
|
|
6
|
+
version
|
|
7
|
+
} from "./chunk-4D26Y5PK.js";
|
|
5
8
|
|
|
6
9
|
// src/xr.ts
|
|
7
10
|
import { sliver } from "@0x-jerry/silver";
|
|
@@ -142,7 +145,7 @@ async function getAvailableCommands() {
|
|
|
142
145
|
|
|
143
146
|
// src/xr.ts
|
|
144
147
|
var ins = sliver`
|
|
145
|
-
@help @autocompletion
|
|
148
|
+
v${version} @help @autocompletion
|
|
146
149
|
|
|
147
150
|
xr [@command:command] #stopEarly, run command quickly. ${defaultAction}
|
|
148
151
|
`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0x-jerry/x",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.1",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/0x-jerry/x.git"
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
"clean": true
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@0x-jerry/silver": "^0.
|
|
46
|
-
"@0x-jerry/utils": "^2.4.
|
|
45
|
+
"@0x-jerry/silver": "^1.0.3",
|
|
46
|
+
"@0x-jerry/utils": "^2.4.3",
|
|
47
47
|
"decompress": "^4.2.1",
|
|
48
48
|
"fs-extra": "^11.2.0",
|
|
49
49
|
"global-agent": "^3.0.0",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"@types/node": "^20.14.11",
|
|
62
62
|
"@types/prompts": "^2.4.9",
|
|
63
63
|
"@vitest/coverage-v8": "^2.0.3",
|
|
64
|
-
"tsup": "^8.
|
|
64
|
+
"tsup": "^8.2.0",
|
|
65
65
|
"tsx": "^4.16.2",
|
|
66
66
|
"typescript": "^5.5.3",
|
|
67
67
|
"vitest": "^2.0.3"
|
package/readme.md
CHANGED
|
@@ -5,7 +5,82 @@ Some useful command for myself.
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
7
7
|
```sh
|
|
8
|
-
|
|
8
|
+
pnpm i -g @0x-jerry/x
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Run task `xr`
|
|
12
|
+
|
|
13
|
+
`xr` command can auto detect tasks in `package.json/scripts`, `deno.json/tasks`, and run it. you can also append any parameters.
|
|
14
|
+
|
|
15
|
+
Example: In a node project with `pnpm-lock.yaml`. And `package.json` has a script `"test": "vitest run"`
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
xr test test/*.ts
|
|
19
|
+
# equals
|
|
20
|
+
vitest run test/*.ts
|
|
21
|
+
|
|
22
|
+
# you can also execute binary file in `node_modules/.bin` folder.
|
|
23
|
+
xr vite --port 4004
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Example: In a deno project with `deno.json` or `deno.jsonc`. And have a task `"dev": "deno run -A main.ts"`
|
|
27
|
+
|
|
28
|
+
```sh
|
|
29
|
+
xr dev
|
|
30
|
+
# equals
|
|
31
|
+
deno run -A main.ts
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Dependency Manager `xn`
|
|
35
|
+
|
|
36
|
+
`xn` command can install modules by detect the correct tool, it detects lockfile to decide which dependency manager tools should be used.
|
|
37
|
+
|
|
38
|
+
Example: install packages in a node project with `pnpm-lock.yaml`
|
|
39
|
+
|
|
40
|
+
```sh
|
|
41
|
+
xn i lodash-es
|
|
42
|
+
# equals
|
|
43
|
+
pnpm i lodash-es
|
|
44
|
+
|
|
45
|
+
xn i lodash-es -D
|
|
46
|
+
# equals
|
|
47
|
+
pnpm i lodash-es -D
|
|
48
|
+
|
|
49
|
+
# -t/--types option support install @types/xx package in one command.
|
|
50
|
+
xn i lodash-es --types
|
|
51
|
+
# equals
|
|
52
|
+
pnpm i lodash-es && pnpm i @types/lodash-es -D
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Example: remove packages in a node project with `pnpm-lock.yaml`
|
|
56
|
+
|
|
57
|
+
```sh
|
|
58
|
+
xn rm lodash-es
|
|
59
|
+
# equals
|
|
60
|
+
pnpm uninstall lodash-es
|
|
61
|
+
|
|
62
|
+
xn rm lodash-es -D
|
|
63
|
+
# equals
|
|
64
|
+
pnpm uninstall lodash-es -D
|
|
65
|
+
|
|
66
|
+
# -t/--types option support remove @types/xx package in one command.
|
|
67
|
+
xn rm lodash-es --types
|
|
68
|
+
# equals
|
|
69
|
+
pnpm uninstall lodash-es @types/lodash-es
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
`xn` also support rust project.
|
|
73
|
+
|
|
74
|
+
Example: in a rust project with `Cargo.toml`
|
|
75
|
+
|
|
76
|
+
```sh
|
|
77
|
+
xn i log
|
|
78
|
+
# equals
|
|
79
|
+
cargo add log
|
|
80
|
+
|
|
81
|
+
xn rm log
|
|
82
|
+
# equals
|
|
83
|
+
cargo remove log
|
|
9
84
|
```
|
|
10
85
|
|
|
11
86
|
## Command Completions
|