@0x-jerry/x 2.9.2 → 2.10.0
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-UW6XLRG7.js → chunk-ELIYGHQS.js} +2 -2
- package/dist/{chunk-TEO3M6Z2.js → chunk-VDPUNX7B.js} +1 -1
- package/dist/hooks/index.js +63 -84
- package/dist/x.js +1 -2
- package/dist/xn.js +2 -3
- package/dist/xr.js +13 -14
- package/package.json +1 -1
- package/dist/chunk-MLKGABMK.js +0 -9
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// src/utils.ts
|
|
2
2
|
import { existsSync } from "fs";
|
|
3
3
|
import { exec as _exec } from "@0x-jerry/utils/node";
|
|
4
|
-
async function exec(script, params,
|
|
4
|
+
async function exec(script, params, opt) {
|
|
5
5
|
const cmd = [script, ...params].join(" ");
|
|
6
|
-
await _exec(cmd,
|
|
6
|
+
await _exec(cmd, opt);
|
|
7
7
|
}
|
|
8
8
|
function exists(path) {
|
|
9
9
|
return existsSync(path);
|
package/dist/hooks/index.js
CHANGED
|
@@ -1,17 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
__export
|
|
3
|
-
} from "../chunk-MLKGABMK.js";
|
|
4
|
-
|
|
5
1
|
// src/hooks/index.ts
|
|
6
2
|
import * as tsx from "tsx/esm";
|
|
7
3
|
|
|
8
4
|
// src/hooks/jsonc.ts
|
|
9
|
-
var jsonc_exports = {};
|
|
10
|
-
__export(jsonc_exports, {
|
|
11
|
-
load: () => load,
|
|
12
|
-
resolve: () => resolve
|
|
13
|
-
});
|
|
14
|
-
import path from "path";
|
|
15
5
|
import stripJsonComment from "strip-json-comments";
|
|
16
6
|
|
|
17
7
|
// src/hooks/utils.ts
|
|
@@ -37,90 +27,79 @@ function chainHooks(fns) {
|
|
|
37
27
|
return wrapperFn;
|
|
38
28
|
}
|
|
39
29
|
|
|
40
|
-
// src/hooks/
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
30
|
+
// src/hooks/helper.ts
|
|
31
|
+
function createModuleHook({
|
|
32
|
+
type,
|
|
33
|
+
loader
|
|
34
|
+
}) {
|
|
35
|
+
const resolve2 = async (specifier, ctx, nextResolve) => {
|
|
36
|
+
const nextResult = await nextResolve(specifier, ctx);
|
|
37
|
+
if (ctx.importAttributes.type !== type) {
|
|
38
|
+
return nextResult;
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
...nextResult,
|
|
42
|
+
format: type,
|
|
43
|
+
shortCircuit: true
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
const load2 = async (url, ctx, nextLoad) => {
|
|
47
|
+
const nextResult = await nextLoad(url, ctx);
|
|
48
|
+
if (ctx.format !== type) return nextResult;
|
|
49
|
+
const source = await loader(sourceToStr(nextResult.source));
|
|
50
|
+
return {
|
|
51
|
+
shortCircuit: true,
|
|
52
|
+
...source
|
|
53
|
+
};
|
|
50
54
|
};
|
|
51
|
-
};
|
|
52
|
-
var load = async (url, ctx, nextLoad) => {
|
|
53
|
-
const nextResult = await nextLoad(url, ctx);
|
|
54
|
-
if (ctx.format !== FORMAT_TYPE) return nextResult;
|
|
55
|
-
const source = stripJsonComment(sourceToStr(nextResult.source));
|
|
56
55
|
return {
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
resolve: resolve2,
|
|
57
|
+
load: load2
|
|
59
58
|
};
|
|
60
|
-
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// src/hooks/jsonc.ts
|
|
62
|
+
var jsonc_default = createModuleHook({
|
|
63
|
+
type: "jsonc",
|
|
64
|
+
loader(rawSource) {
|
|
65
|
+
const source = stripJsonComment(rawSource);
|
|
66
|
+
return {
|
|
67
|
+
format: "json",
|
|
68
|
+
source
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
});
|
|
61
72
|
|
|
62
73
|
// src/hooks/text.ts
|
|
63
|
-
var
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
74
|
+
var text_default = createModuleHook({
|
|
75
|
+
type: "text",
|
|
76
|
+
loader(rawSource) {
|
|
77
|
+
const source = `export default ${JSON.stringify(rawSource)};`;
|
|
78
|
+
return {
|
|
79
|
+
format: "module",
|
|
80
|
+
source
|
|
81
|
+
};
|
|
82
|
+
}
|
|
67
83
|
});
|
|
68
|
-
import path2 from "path";
|
|
69
|
-
var supportedExtensions2 = [".txt", ".sql", ".md"];
|
|
70
|
-
var FORMAT_TYPE2 = "text";
|
|
71
|
-
var resolve2 = async (specifier, ctx, nextResolve) => {
|
|
72
|
-
const nextResult = await nextResolve(specifier, ctx);
|
|
73
|
-
const ext = path2.extname(specifier);
|
|
74
|
-
if (!supportedExtensions2.includes(ext)) return nextResult;
|
|
75
|
-
return {
|
|
76
|
-
...nextResult,
|
|
77
|
-
format: FORMAT_TYPE2
|
|
78
|
-
};
|
|
79
|
-
};
|
|
80
|
-
var load2 = async (url, ctx, nextLoad) => {
|
|
81
|
-
const nextResult = await nextLoad(url, ctx);
|
|
82
|
-
if (ctx.format !== FORMAT_TYPE2) return nextResult;
|
|
83
|
-
const source = `export default ${JSON.stringify(sourceToStr(nextResult.source))};`;
|
|
84
|
-
return {
|
|
85
|
-
format: "module",
|
|
86
|
-
source
|
|
87
|
-
};
|
|
88
|
-
};
|
|
89
84
|
|
|
90
85
|
// src/hooks/yaml.ts
|
|
91
|
-
var yaml_exports = {};
|
|
92
|
-
__export(yaml_exports, {
|
|
93
|
-
load: () => load3,
|
|
94
|
-
resolve: () => resolve3
|
|
95
|
-
});
|
|
96
|
-
import path3 from "path";
|
|
97
86
|
import yaml from "yaml";
|
|
98
|
-
var
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
};
|
|
109
|
-
var load3 = async (url, ctx, nextLoad) => {
|
|
110
|
-
if (ctx.format !== FORMAT_TYPE3) return nextLoad(url, ctx);
|
|
111
|
-
const nextResult = await nextLoad(url, ctx);
|
|
112
|
-
const source = yaml.parse(sourceToStr(nextResult.source));
|
|
113
|
-
return {
|
|
114
|
-
format: "json",
|
|
115
|
-
source: JSON.stringify(source)
|
|
116
|
-
};
|
|
117
|
-
};
|
|
87
|
+
var yaml_default = createModuleHook({
|
|
88
|
+
type: "yaml",
|
|
89
|
+
loader(rawSource) {
|
|
90
|
+
const source = yaml.parse(rawSource);
|
|
91
|
+
return {
|
|
92
|
+
format: "json",
|
|
93
|
+
source: JSON.stringify(source)
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
});
|
|
118
97
|
|
|
119
98
|
// src/hooks/index.ts
|
|
120
|
-
var hooks = [
|
|
121
|
-
var
|
|
122
|
-
var
|
|
99
|
+
var hooks = [jsonc_default, text_default, yaml_default, tsx];
|
|
100
|
+
var resolve = chainHooks(hooks.map((n) => n.resolve));
|
|
101
|
+
var load = chainHooks(hooks.map((n) => n.load));
|
|
123
102
|
export {
|
|
124
|
-
|
|
125
|
-
|
|
103
|
+
load,
|
|
104
|
+
resolve
|
|
126
105
|
};
|
package/dist/x.js
CHANGED
package/dist/xn.js
CHANGED
|
@@ -3,11 +3,10 @@ import {
|
|
|
3
3
|
exec,
|
|
4
4
|
exists,
|
|
5
5
|
flagOptionToStringArray
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-ELIYGHQS.js";
|
|
7
7
|
import {
|
|
8
8
|
version
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import "./chunk-MLKGABMK.js";
|
|
9
|
+
} from "./chunk-VDPUNX7B.js";
|
|
11
10
|
|
|
12
11
|
// src/xn.ts
|
|
13
12
|
import { sliver } from "@0x-jerry/silver";
|
package/dist/xr.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
exec
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-ELIYGHQS.js";
|
|
5
5
|
import {
|
|
6
6
|
version
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-MLKGABMK.js";
|
|
7
|
+
} from "./chunk-VDPUNX7B.js";
|
|
9
8
|
|
|
10
9
|
// src/xr.ts
|
|
11
10
|
import { sliver } from "@0x-jerry/silver";
|
|
@@ -111,7 +110,7 @@ async function runScript(command, params = []) {
|
|
|
111
110
|
const task = await taskDetector.task(cwd, command);
|
|
112
111
|
if (task) {
|
|
113
112
|
const env = makeEnv(await taskDetector.binaryPaths?.(cwd) || []);
|
|
114
|
-
await exec(task, params, env);
|
|
113
|
+
await exec(task, params, { env });
|
|
115
114
|
return;
|
|
116
115
|
}
|
|
117
116
|
}
|
|
@@ -156,17 +155,17 @@ ins.type("command", async () => {
|
|
|
156
155
|
});
|
|
157
156
|
async function defaultAction(_, arg) {
|
|
158
157
|
const [commandOrFile, ...params] = arg._;
|
|
159
|
-
if (isJsFile(commandOrFile)) {
|
|
160
|
-
await exec("node", [
|
|
161
|
-
"--import",
|
|
162
|
-
import.meta.resolve(`./hooks/register.js`),
|
|
163
|
-
commandOrFile
|
|
164
|
-
]);
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
158
|
try {
|
|
168
|
-
|
|
169
|
-
|
|
159
|
+
if (isJsFile(commandOrFile)) {
|
|
160
|
+
await exec(
|
|
161
|
+
"node",
|
|
162
|
+
["--import", import.meta.resolve(`./hooks/register.js`), commandOrFile],
|
|
163
|
+
{ silent: true }
|
|
164
|
+
);
|
|
165
|
+
} else {
|
|
166
|
+
await runScript(commandOrFile, params);
|
|
167
|
+
}
|
|
168
|
+
} catch (_error) {
|
|
170
169
|
process.exit(1);
|
|
171
170
|
}
|
|
172
171
|
}
|
package/package.json
CHANGED