@goondan/openharness-cli 0.1.3 → 0.1.5
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/index.js +24 -2
- package/package.json +7 -6
package/dist/index.js
CHANGED
|
@@ -17,9 +17,31 @@ function loadEnv(workdir) {
|
|
|
17
17
|
|
|
18
18
|
// src/config-loader.ts
|
|
19
19
|
import { pathToFileURL } from "url";
|
|
20
|
-
async function
|
|
20
|
+
async function loadWithJiti(configPath) {
|
|
21
|
+
const { createJiti } = await import("jiti");
|
|
22
|
+
const jiti = createJiti(import.meta.url, { interopDefault: true });
|
|
23
|
+
return jiti.import(configPath);
|
|
24
|
+
}
|
|
25
|
+
async function loadWithNativeImport(configPath) {
|
|
21
26
|
const fileUrl = pathToFileURL(configPath).href;
|
|
22
|
-
|
|
27
|
+
return import(fileUrl);
|
|
28
|
+
}
|
|
29
|
+
async function loadConfig(configPath) {
|
|
30
|
+
let mod;
|
|
31
|
+
try {
|
|
32
|
+
mod = await loadWithJiti(configPath);
|
|
33
|
+
} catch {
|
|
34
|
+
try {
|
|
35
|
+
mod = await loadWithNativeImport(configPath);
|
|
36
|
+
} catch (nativeError) {
|
|
37
|
+
if (configPath.endsWith(".ts")) {
|
|
38
|
+
throw new Error(
|
|
39
|
+
`Failed to load TypeScript config "${configPath}". TypeScript config\uB97C \uB85C\uB4DC\uD558\uB824\uBA74 jiti, tsx, \uB610\uB294 ts-node\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4. Cause: ${nativeError instanceof Error ? nativeError.message : String(nativeError)}`
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
throw nativeError;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
23
45
|
const config = mod.default ?? mod;
|
|
24
46
|
if (config === null || typeof config !== "object" || !("agents" in config) || typeof config.agents !== "object") {
|
|
25
47
|
throw new Error(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@goondan/openharness-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"oh": "./dist/index.js"
|
|
@@ -17,14 +17,15 @@
|
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"dotenv": "^16.4.0",
|
|
20
|
-
"
|
|
21
|
-
"@goondan/openharness
|
|
20
|
+
"jiti": "^2.6.1",
|
|
21
|
+
"@goondan/openharness": "0.1.5",
|
|
22
|
+
"@goondan/openharness-types": "0.1.5"
|
|
22
23
|
},
|
|
23
24
|
"devDependencies": {
|
|
24
|
-
"
|
|
25
|
+
"@types/node": "^22.0.0",
|
|
25
26
|
"tsup": "^8.4.0",
|
|
26
|
-
"
|
|
27
|
-
"
|
|
27
|
+
"typescript": "^5.7.0",
|
|
28
|
+
"vitest": "^3.0.0"
|
|
28
29
|
},
|
|
29
30
|
"scripts": {
|
|
30
31
|
"build": "tsup src/index.ts --format esm --dts",
|