govgate 0.3.2 → 0.3.3
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 +78 -8
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -114,16 +114,27 @@ function emitRunIdVariable(runId, ctx, env = process.env) {
|
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
// src/config.ts
|
|
117
|
-
import { readFileSync, existsSync } from "fs";
|
|
117
|
+
import { readFileSync, existsSync, readdirSync } from "fs";
|
|
118
118
|
import { dirname, join, resolve } from "path";
|
|
119
119
|
var ConfigError = class extends Error {
|
|
120
120
|
};
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
121
|
+
var SKIP_DIRS = /* @__PURE__ */ new Set([
|
|
122
|
+
"node_modules",
|
|
123
|
+
".git",
|
|
124
|
+
".next",
|
|
125
|
+
".vs",
|
|
126
|
+
".vscode",
|
|
127
|
+
".idea",
|
|
128
|
+
"dist",
|
|
129
|
+
"build",
|
|
130
|
+
"bin",
|
|
131
|
+
"obj",
|
|
132
|
+
"coverage",
|
|
133
|
+
".turbo",
|
|
134
|
+
".cache"
|
|
135
|
+
]);
|
|
136
|
+
var DOWNWARD_MAX_DEPTH = 6;
|
|
137
|
+
function findConfigUpward(startDir) {
|
|
127
138
|
let dir = resolve(startDir);
|
|
128
139
|
for (; ; ) {
|
|
129
140
|
const candidate = join(dir, "govgate", "config.json");
|
|
@@ -133,6 +144,58 @@ function findConfigFile(startDir, explicitPath) {
|
|
|
133
144
|
dir = parent;
|
|
134
145
|
}
|
|
135
146
|
}
|
|
147
|
+
function findConfigDownward(startDir) {
|
|
148
|
+
const root = resolve(startDir);
|
|
149
|
+
const found = [];
|
|
150
|
+
const queue = [{ dir: root, depth: 0 }];
|
|
151
|
+
while (queue.length > 0) {
|
|
152
|
+
const { dir, depth } = queue.shift();
|
|
153
|
+
const direct = join(dir, "govgate", "config.json");
|
|
154
|
+
if (existsSync(direct)) found.push(direct);
|
|
155
|
+
if (depth >= DOWNWARD_MAX_DEPTH) continue;
|
|
156
|
+
let entries;
|
|
157
|
+
try {
|
|
158
|
+
entries = readdirSync(dir, { withFileTypes: true });
|
|
159
|
+
} catch {
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
for (const entry of entries) {
|
|
163
|
+
if (!entry.isDirectory()) continue;
|
|
164
|
+
if (entry.name === "govgate") continue;
|
|
165
|
+
if (SKIP_DIRS.has(entry.name)) continue;
|
|
166
|
+
queue.push({ dir: join(dir, entry.name), depth: depth + 1 });
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return [...new Set(found)].sort();
|
|
170
|
+
}
|
|
171
|
+
function findConfigFile(startDir, explicitPath) {
|
|
172
|
+
if (explicitPath) {
|
|
173
|
+
const p = resolve(startDir, explicitPath);
|
|
174
|
+
if (!existsSync(p)) throw new ConfigError(`Config file not found: ${p}`);
|
|
175
|
+
return p;
|
|
176
|
+
}
|
|
177
|
+
const upward = findConfigUpward(startDir);
|
|
178
|
+
if (upward) return upward;
|
|
179
|
+
const downward = findConfigDownward(startDir);
|
|
180
|
+
if (downward.length === 1) {
|
|
181
|
+
console.error(
|
|
182
|
+
`govgate: no govgate/config.json at or above ${resolve(startDir)}; using discovered ${downward[0]}`
|
|
183
|
+
);
|
|
184
|
+
return downward[0];
|
|
185
|
+
}
|
|
186
|
+
if (downward.length > 1) {
|
|
187
|
+
throw new ConfigError(
|
|
188
|
+
`Ambiguous config: found ${downward.length} govgate/config.json files under ${resolve(
|
|
189
|
+
startDir
|
|
190
|
+
)} and none at or above it:
|
|
191
|
+
${downward.map((p) => ` - ${p}`).join(
|
|
192
|
+
"\n"
|
|
193
|
+
)}
|
|
194
|
+
Pick one with --config <path>, pass --suite <slug>, or run govgate from the intended directory.`
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
return void 0;
|
|
198
|
+
}
|
|
136
199
|
function loadFileConfig(path) {
|
|
137
200
|
let data;
|
|
138
201
|
try {
|
|
@@ -197,8 +260,15 @@ function resolveConfig(flags, cwd = process.cwd()) {
|
|
|
197
260
|
);
|
|
198
261
|
}
|
|
199
262
|
if (!suite) {
|
|
263
|
+
if (!configPath) {
|
|
264
|
+
throw new ConfigError(
|
|
265
|
+
`No govgate/config.json found (searched upward from ${resolve(
|
|
266
|
+
cwd
|
|
267
|
+
)}, then downward). Run govgate from your repo root or the artifact/drop folder that contains govgate/, pass --config <path>, or pass --suite <slug>.`
|
|
268
|
+
);
|
|
269
|
+
}
|
|
200
270
|
throw new ConfigError(
|
|
201
|
-
|
|
271
|
+
`Suite missing in ${configPath}. Add { "suite": "<slug>" } to that file or pass --suite <slug>.`
|
|
202
272
|
);
|
|
203
273
|
}
|
|
204
274
|
return {
|
package/package.json
CHANGED