@h-rig/core 0.0.6-alpha.48 → 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.
@@ -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)
@@ -4,8 +4,24 @@ import { existsSync, mkdtempSync, readFileSync, rmSync } from "fs";
4
4
  import { tmpdir } from "os";
5
5
  import { dirname, join } from "path";
6
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) {
@@ -27,13 +43,19 @@ async function importConfigViaRuntimeBundle(configPath) {
27
43
  return process.cwd();
28
44
  }
29
45
  })();
46
+ const configDir = dirname(configPath);
30
47
  const hostResolverPlugin = {
31
48
  name: "rig-host-package-resolver",
32
49
  setup(build) {
33
50
  build.onResolve({ filter: /^@rig\// }, (args) => {
34
- for (const specifier of [args.path, args.path.replace(/^@rig\//, "@h-rig/")]) {
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) {
35
57
  try {
36
- const resolved = bun.resolveSync?.(specifier, hostDir);
58
+ const resolved = bun.resolveSync?.(specifier, parent);
37
59
  if (resolved)
38
60
  return { path: resolved };
39
61
  } catch {}
@@ -104,7 +126,7 @@ function decodePreservingRuntime(raw) {
104
126
  }
105
127
  }
106
128
  }
107
- const decoded = Schema.decodeUnknownSync(RigConfig)(raw);
129
+ const decoded = Schema2.decodeUnknownSync(RigConfig2)(applyConfigDefaults(raw));
108
130
  const plugins = decoded.plugins.map((p) => {
109
131
  const runtime = runtimeByName.get(p.name);
110
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.48",
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.48",
34
+ "@rig/contracts": "npm:@h-rig/contracts@0.0.6-alpha.49",
35
35
  "effect": "4.0.0-beta.78"
36
36
  }
37
37
  }