@h-rig/core 0.0.6-alpha.47 → 0.0.6-alpha.49
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/src/define-config.js +13 -2
- package/dist/src/index.js +11 -1
- package/dist/src/load-config.js +49 -4
- package/package.json +2 -2
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
// packages/core/src/define-config.ts
|
|
3
3
|
import { Schema } from "effect";
|
|
4
4
|
import { RigConfig } from "@rig/contracts";
|
|
5
|
+
function applyConfigDefaults(raw) {
|
|
6
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw))
|
|
7
|
+
return raw;
|
|
8
|
+
const record = raw;
|
|
9
|
+
return {
|
|
10
|
+
...record,
|
|
11
|
+
plugins: Array.isArray(record.plugins) ? record.plugins : [],
|
|
12
|
+
workspace: record.workspace && typeof record.workspace === "object" && !Array.isArray(record.workspace) ? record.workspace : { mainRepo: ".", isolation: "worktree" }
|
|
13
|
+
};
|
|
14
|
+
}
|
|
5
15
|
function defineConfig(cfg) {
|
|
6
16
|
const runtimeByName = new Map;
|
|
7
17
|
const plugins = cfg.plugins ?? [];
|
|
@@ -10,7 +20,7 @@ function defineConfig(cfg) {
|
|
|
10
20
|
runtimeByName.set(plugin.name, plugin.__runtime);
|
|
11
21
|
}
|
|
12
22
|
}
|
|
13
|
-
const decoded = Schema.decodeUnknownSync(RigConfig)(cfg);
|
|
23
|
+
const decoded = Schema.decodeUnknownSync(RigConfig)(applyConfigDefaults(cfg));
|
|
14
24
|
const decodedPlugins = decoded.plugins.map((p) => {
|
|
15
25
|
const runtime = runtimeByName.get(p.name);
|
|
16
26
|
if (!runtime)
|
|
@@ -20,5 +30,6 @@ function defineConfig(cfg) {
|
|
|
20
30
|
return { ...decoded, plugins: decodedPlugins };
|
|
21
31
|
}
|
|
22
32
|
export {
|
|
23
|
-
defineConfig
|
|
33
|
+
defineConfig,
|
|
34
|
+
applyConfigDefaults
|
|
24
35
|
};
|
package/dist/src/index.js
CHANGED
|
@@ -48,6 +48,16 @@ function definePlugin(meta, runtime) {
|
|
|
48
48
|
// packages/core/src/define-config.ts
|
|
49
49
|
import { Schema as Schema2 } from "effect";
|
|
50
50
|
import { RigConfig } from "@rig/contracts";
|
|
51
|
+
function applyConfigDefaults(raw) {
|
|
52
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw))
|
|
53
|
+
return raw;
|
|
54
|
+
const record = raw;
|
|
55
|
+
return {
|
|
56
|
+
...record,
|
|
57
|
+
plugins: Array.isArray(record.plugins) ? record.plugins : [],
|
|
58
|
+
workspace: record.workspace && typeof record.workspace === "object" && !Array.isArray(record.workspace) ? record.workspace : { mainRepo: ".", isolation: "worktree" }
|
|
59
|
+
};
|
|
60
|
+
}
|
|
51
61
|
function defineConfig(cfg) {
|
|
52
62
|
const runtimeByName = new Map;
|
|
53
63
|
const plugins = cfg.plugins ?? [];
|
|
@@ -56,7 +66,7 @@ function defineConfig(cfg) {
|
|
|
56
66
|
runtimeByName.set(plugin.name, plugin.__runtime);
|
|
57
67
|
}
|
|
58
68
|
}
|
|
59
|
-
const decoded = Schema2.decodeUnknownSync(RigConfig)(cfg);
|
|
69
|
+
const decoded = Schema2.decodeUnknownSync(RigConfig)(applyConfigDefaults(cfg));
|
|
60
70
|
const decodedPlugins = decoded.plugins.map((p) => {
|
|
61
71
|
const runtime = runtimeByName.get(p.name);
|
|
62
72
|
if (!runtime)
|
package/dist/src/load-config.js
CHANGED
|
@@ -2,10 +2,26 @@
|
|
|
2
2
|
// packages/core/src/load-config.ts
|
|
3
3
|
import { existsSync, mkdtempSync, readFileSync, rmSync } from "fs";
|
|
4
4
|
import { tmpdir } from "os";
|
|
5
|
-
import { join } from "path";
|
|
6
|
-
import { pathToFileURL } from "url";
|
|
5
|
+
import { dirname, join } from "path";
|
|
6
|
+
import { fileURLToPath, pathToFileURL } from "url";
|
|
7
|
+
import { Schema as Schema2 } from "effect";
|
|
8
|
+
import { RigConfig as RigConfig2 } from "@rig/contracts";
|
|
9
|
+
|
|
10
|
+
// packages/core/src/define-config.ts
|
|
7
11
|
import { Schema } from "effect";
|
|
8
12
|
import { RigConfig } from "@rig/contracts";
|
|
13
|
+
function applyConfigDefaults(raw) {
|
|
14
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw))
|
|
15
|
+
return raw;
|
|
16
|
+
const record = raw;
|
|
17
|
+
return {
|
|
18
|
+
...record,
|
|
19
|
+
plugins: Array.isArray(record.plugins) ? record.plugins : [],
|
|
20
|
+
workspace: record.workspace && typeof record.workspace === "object" && !Array.isArray(record.workspace) ? record.workspace : { mainRepo: ".", isolation: "worktree" }
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// packages/core/src/load-config.ts
|
|
9
25
|
var TS_NAMES = ["rig.config.ts", "rig.config.mts"];
|
|
10
26
|
var JSON_NAMES = ["rig.config.json"];
|
|
11
27
|
function isModuleResolutionError(error) {
|
|
@@ -20,11 +36,40 @@ async function importConfigViaRuntimeBundle(configPath) {
|
|
|
20
36
|
if (!bun?.build) {
|
|
21
37
|
throw new Error(`Failed to import ${configPath}: bare imports could not be resolved and no Bun.build runtime bundler is available.`);
|
|
22
38
|
}
|
|
39
|
+
const hostDir = (() => {
|
|
40
|
+
try {
|
|
41
|
+
return dirname(fileURLToPath(import.meta.url));
|
|
42
|
+
} catch {
|
|
43
|
+
return process.cwd();
|
|
44
|
+
}
|
|
45
|
+
})();
|
|
46
|
+
const configDir = dirname(configPath);
|
|
47
|
+
const hostResolverPlugin = {
|
|
48
|
+
name: "rig-host-package-resolver",
|
|
49
|
+
setup(build) {
|
|
50
|
+
build.onResolve({ filter: /^@rig\// }, (args) => {
|
|
51
|
+
const candidates = [
|
|
52
|
+
[args.path, configDir],
|
|
53
|
+
[args.path, hostDir],
|
|
54
|
+
[args.path.replace(/^@rig\//, "@h-rig/"), hostDir]
|
|
55
|
+
];
|
|
56
|
+
for (const [specifier, parent] of candidates) {
|
|
57
|
+
try {
|
|
58
|
+
const resolved = bun.resolveSync?.(specifier, parent);
|
|
59
|
+
if (resolved)
|
|
60
|
+
return { path: resolved };
|
|
61
|
+
} catch {}
|
|
62
|
+
}
|
|
63
|
+
return;
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
};
|
|
23
67
|
const result = await bun.build({
|
|
24
68
|
entrypoints: [configPath],
|
|
25
69
|
target: "bun",
|
|
26
70
|
format: "esm",
|
|
27
|
-
throw: false
|
|
71
|
+
throw: false,
|
|
72
|
+
plugins: [hostResolverPlugin]
|
|
28
73
|
});
|
|
29
74
|
if (!result.success || !result.outputs[0]) {
|
|
30
75
|
const detail = result.logs.map((log) => String(log)).join(`
|
|
@@ -81,7 +126,7 @@ function decodePreservingRuntime(raw) {
|
|
|
81
126
|
}
|
|
82
127
|
}
|
|
83
128
|
}
|
|
84
|
-
const decoded =
|
|
129
|
+
const decoded = Schema2.decodeUnknownSync(RigConfig2)(applyConfigDefaults(raw));
|
|
85
130
|
const plugins = decoded.plugins.map((p) => {
|
|
86
131
|
const runtime = runtimeByName.get(p.name);
|
|
87
132
|
if (!runtime)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@h-rig/core",
|
|
3
|
-
"version": "0.0.6-alpha.
|
|
3
|
+
"version": "0.0.6-alpha.49",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Rig package",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"main": "./dist/src/index.js",
|
|
32
32
|
"module": "./dist/src/index.js",
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@rig/contracts": "npm:@h-rig/contracts@0.0.6-alpha.
|
|
34
|
+
"@rig/contracts": "npm:@h-rig/contracts@0.0.6-alpha.49",
|
|
35
35
|
"effect": "4.0.0-beta.78"
|
|
36
36
|
}
|
|
37
37
|
}
|