opencode-completion-gate 2.0.1 → 2.1.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/CHANGELOG.md +7 -0
- package/dist/index.js +29 -4
- package/dist/plugin.js +29 -4
- package/dist/types.d.ts +14 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.1.0](https://github.com/PauloDevelo/opencode-completion-gate/compare/v2.0.1...v2.1.0) (2026-11-19)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* **config:** accept one command per platform for run ([#16](https://github.com/PauloDevelo/opencode-completion-gate/issues/16)) ([17299e9](https://github.com/PauloDevelo/opencode-completion-gate/commit/17299e9984b9c75beb387eea182aff05c842e240))
|
|
9
|
+
|
|
3
10
|
## [2.0.1](https://github.com/PauloDevelo/opencode-completion-gate/compare/v2.0.0...v2.0.1) (2026-11-18)
|
|
4
11
|
|
|
5
12
|
|
package/dist/index.js
CHANGED
|
@@ -123,6 +123,29 @@ function fail(name, evidence) {
|
|
|
123
123
|
function positiveInt(v, fallback) {
|
|
124
124
|
return typeof v === "number" && Number.isFinite(v) && v > 0 ? Math.floor(v) : fallback;
|
|
125
125
|
}
|
|
126
|
+
function resolvePlatformCommand(run, nameOf) {
|
|
127
|
+
if (typeof run === "string") {
|
|
128
|
+
const command2 = run.trim();
|
|
129
|
+
if (!command2) return null;
|
|
130
|
+
return { run, name: nameOf(command2.split(/\s+/)[0]) };
|
|
131
|
+
}
|
|
132
|
+
if (!run || typeof run !== "object" || Array.isArray(run)) return null;
|
|
133
|
+
const pair = run;
|
|
134
|
+
const unknownKeys = Object.keys(pair).filter((key) => key !== "windows" && key !== "linux");
|
|
135
|
+
if (unknownKeys.length > 0) {
|
|
136
|
+
logDiag(`gate config: run carries unknown platform key(s): ${unknownKeys.join(", ")}`);
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
const platform = process.platform === "win32" ? "windows" : "linux";
|
|
140
|
+
const command = pair[platform];
|
|
141
|
+
if (typeof command !== "string" || !command.trim()) {
|
|
142
|
+
logDiag(
|
|
143
|
+
`gate config: run has no "${platform}" command for this host (${process.platform}); the whole config is skipped`
|
|
144
|
+
);
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
return { run: command, name: nameOf(command.trim().split(/\s+/)[0]) };
|
|
148
|
+
}
|
|
126
149
|
function validateGateConfig(raw) {
|
|
127
150
|
if (!raw || typeof raw !== "object") return null;
|
|
128
151
|
const obj = raw;
|
|
@@ -133,15 +156,17 @@ function validateGateConfig(raw) {
|
|
|
133
156
|
if (!a || typeof a !== "object") return null;
|
|
134
157
|
const nameOf = (fb) => typeof a.name === "string" && a.name.trim() ? a.name : fb;
|
|
135
158
|
switch (a.type) {
|
|
136
|
-
case "command":
|
|
137
|
-
|
|
159
|
+
case "command": {
|
|
160
|
+
const resolved = resolvePlatformCommand(a.run, nameOf);
|
|
161
|
+
if (!resolved) return null;
|
|
138
162
|
assertions.push({
|
|
139
163
|
type: "command",
|
|
140
|
-
name:
|
|
141
|
-
run:
|
|
164
|
+
name: resolved.name,
|
|
165
|
+
run: resolved.run,
|
|
142
166
|
timeoutSeconds: positiveInt(a.timeoutSeconds, 300)
|
|
143
167
|
});
|
|
144
168
|
break;
|
|
169
|
+
}
|
|
145
170
|
case "ado-pr":
|
|
146
171
|
assertions.push({
|
|
147
172
|
type: "ado-pr",
|
package/dist/plugin.js
CHANGED
|
@@ -123,6 +123,29 @@ function fail(name, evidence) {
|
|
|
123
123
|
function positiveInt(v, fallback) {
|
|
124
124
|
return typeof v === "number" && Number.isFinite(v) && v > 0 ? Math.floor(v) : fallback;
|
|
125
125
|
}
|
|
126
|
+
function resolvePlatformCommand(run, nameOf) {
|
|
127
|
+
if (typeof run === "string") {
|
|
128
|
+
const command2 = run.trim();
|
|
129
|
+
if (!command2) return null;
|
|
130
|
+
return { run, name: nameOf(command2.split(/\s+/)[0]) };
|
|
131
|
+
}
|
|
132
|
+
if (!run || typeof run !== "object" || Array.isArray(run)) return null;
|
|
133
|
+
const pair = run;
|
|
134
|
+
const unknownKeys = Object.keys(pair).filter((key) => key !== "windows" && key !== "linux");
|
|
135
|
+
if (unknownKeys.length > 0) {
|
|
136
|
+
logDiag(`gate config: run carries unknown platform key(s): ${unknownKeys.join(", ")}`);
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
const platform = process.platform === "win32" ? "windows" : "linux";
|
|
140
|
+
const command = pair[platform];
|
|
141
|
+
if (typeof command !== "string" || !command.trim()) {
|
|
142
|
+
logDiag(
|
|
143
|
+
`gate config: run has no "${platform}" command for this host (${process.platform}); the whole config is skipped`
|
|
144
|
+
);
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
return { run: command, name: nameOf(command.trim().split(/\s+/)[0]) };
|
|
148
|
+
}
|
|
126
149
|
function validateGateConfig(raw) {
|
|
127
150
|
if (!raw || typeof raw !== "object") return null;
|
|
128
151
|
const obj = raw;
|
|
@@ -133,15 +156,17 @@ function validateGateConfig(raw) {
|
|
|
133
156
|
if (!a || typeof a !== "object") return null;
|
|
134
157
|
const nameOf = (fb) => typeof a.name === "string" && a.name.trim() ? a.name : fb;
|
|
135
158
|
switch (a.type) {
|
|
136
|
-
case "command":
|
|
137
|
-
|
|
159
|
+
case "command": {
|
|
160
|
+
const resolved = resolvePlatformCommand(a.run, nameOf);
|
|
161
|
+
if (!resolved) return null;
|
|
138
162
|
assertions.push({
|
|
139
163
|
type: "command",
|
|
140
|
-
name:
|
|
141
|
-
run:
|
|
164
|
+
name: resolved.name,
|
|
165
|
+
run: resolved.run,
|
|
142
166
|
timeoutSeconds: positiveInt(a.timeoutSeconds, 300)
|
|
143
167
|
});
|
|
144
168
|
break;
|
|
169
|
+
}
|
|
145
170
|
case "ado-pr":
|
|
146
171
|
assertions.push({
|
|
147
172
|
type: "ado-pr",
|
package/dist/types.d.ts
CHANGED
|
@@ -4,6 +4,20 @@ export interface CommandAssertion {
|
|
|
4
4
|
run: string;
|
|
5
5
|
timeoutSeconds: number;
|
|
6
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* The `run` field of a command assertion may be a single string (the original
|
|
9
|
+
* shape, still valid) or one command per platform. The config layer resolves it
|
|
10
|
+
* to a single string before anything reaches the runner, so `CommandAssertion.run`
|
|
11
|
+
* stays a string at runtime.
|
|
12
|
+
*
|
|
13
|
+
* Both keys are optional so the JSON can be authored incrementally, but a config
|
|
14
|
+
* that does not carry a command for the platform it is being read on is
|
|
15
|
+
* rejected rather than run against the other platform's shell.
|
|
16
|
+
*/
|
|
17
|
+
export interface PlatformCommand {
|
|
18
|
+
windows?: string;
|
|
19
|
+
linux?: string;
|
|
20
|
+
}
|
|
7
21
|
export interface AdoPrAssertion {
|
|
8
22
|
type: 'ado-pr';
|
|
9
23
|
name: string;
|
package/package.json
CHANGED