@h-rig/standard-plugin 0.0.6-alpha.89 → 0.0.6-alpha.90
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/github-issues-source.js +14 -29
- package/dist/src/index.js +17 -33
- package/package.json +3 -3
|
@@ -11,9 +11,9 @@ function createEnvGitHubCredentialProvider() {
|
|
|
11
11
|
return {
|
|
12
12
|
async resolveGitHubToken(input) {
|
|
13
13
|
if (input.purpose === "selected-repo") {
|
|
14
|
-
return { token: cleanToken(process.env.RIG_GITHUB_SELECTED_TOKEN ??
|
|
14
|
+
return { token: cleanToken(process.env.RIG_GITHUB_SELECTED_TOKEN ?? null) ?? "", source: "signed-in-user" };
|
|
15
15
|
}
|
|
16
|
-
const token = cleanToken(process.env.
|
|
16
|
+
const token = cleanToken(process.env.GH_TOKEN ?? process.env.GITHUB_TOKEN ?? null);
|
|
17
17
|
if (!token) {
|
|
18
18
|
throw new Error("No host GitHub token is configured for admin fallback.");
|
|
19
19
|
}
|
|
@@ -44,12 +44,12 @@ function createStateGitHubCredentialProvider(options = {}) {
|
|
|
44
44
|
async resolveGitHubToken(input) {
|
|
45
45
|
const token = readToken();
|
|
46
46
|
if (input.purpose === "selected-repo") {
|
|
47
|
-
return { token: token ??
|
|
47
|
+
return { token: token ?? "", source: "signed-in-user" };
|
|
48
48
|
}
|
|
49
49
|
if (token) {
|
|
50
50
|
return { token, source: "signed-in-user" };
|
|
51
51
|
}
|
|
52
|
-
const fallback = cleanToken(process.env.
|
|
52
|
+
const fallback = cleanToken(process.env.GH_TOKEN ?? process.env.GITHUB_TOKEN ?? null);
|
|
53
53
|
if (!fallback) {
|
|
54
54
|
throw new Error("No signed-in GitHub token is stored for Rig and no host admin fallback token is configured.");
|
|
55
55
|
}
|
|
@@ -183,21 +183,13 @@ function isRigStickyStatusComment(body) {
|
|
|
183
183
|
return body.includes(RIG_STATUS_COMMENT_MARKER);
|
|
184
184
|
}
|
|
185
185
|
function ghSpawnOptions(extraEnv, timeoutMs) {
|
|
186
|
-
|
|
187
|
-
encoding: "utf-8",
|
|
188
|
-
|
|
189
|
-
env: {
|
|
190
|
-
...process.env,
|
|
191
|
-
...process.env.GH_TOKEN !== undefined ? { GH_TOKEN: process.env.GH_TOKEN } : {},
|
|
192
|
-
...process.env.GITHUB_TOKEN !== undefined ? { GITHUB_TOKEN: process.env.GITHUB_TOKEN } : {},
|
|
193
|
-
...process.env.RIG_GITHUB_TOKEN !== undefined ? { RIG_GITHUB_TOKEN: process.env.RIG_GITHUB_TOKEN } : {},
|
|
194
|
-
...extraEnv ?? {}
|
|
195
|
-
}
|
|
196
|
-
};
|
|
186
|
+
if (!extraEnv)
|
|
187
|
+
return { encoding: "utf-8", timeout: timeoutMs };
|
|
188
|
+
return { encoding: "utf-8", timeout: timeoutMs, env: { ...process.env, ...extraEnv } };
|
|
197
189
|
}
|
|
198
190
|
function credentialEnv(token) {
|
|
199
191
|
const clean = token?.trim() ?? "";
|
|
200
|
-
return { GH_TOKEN: clean, GITHUB_TOKEN: clean
|
|
192
|
+
return { GH_TOKEN: clean, GITHUB_TOKEN: clean };
|
|
201
193
|
}
|
|
202
194
|
async function resolveCredentialEnv(opts, purpose) {
|
|
203
195
|
if (!opts.credentialProvider)
|
|
@@ -212,31 +204,24 @@ async function resolveCredentialEnv(opts, purpose) {
|
|
|
212
204
|
const resolved = await opts.credentialProvider.resolveGitHubToken(input);
|
|
213
205
|
return credentialEnv(resolved.token);
|
|
214
206
|
}
|
|
215
|
-
function tokenDiagnostic(value) {
|
|
216
|
-
const clean = value?.trim() ?? "";
|
|
217
|
-
return clean ? `present(len=${clean.length})` : "missing";
|
|
218
|
-
}
|
|
219
207
|
function runGh(bin, args, spawn, extraEnv, timeoutMs) {
|
|
220
|
-
const
|
|
221
|
-
|
|
222
|
-
assertGhSuccess(args, res, options.env);
|
|
208
|
+
const res = spawn(bin, [...args], ghSpawnOptions(extraEnv, timeoutMs));
|
|
209
|
+
assertGhSuccess(args, res);
|
|
223
210
|
if (!res.stdout || res.stdout.trim() === "")
|
|
224
211
|
return [];
|
|
225
212
|
return JSON.parse(res.stdout);
|
|
226
213
|
}
|
|
227
214
|
function runGhVoid(bin, args, spawn, extraEnv, timeoutMs) {
|
|
228
|
-
const
|
|
229
|
-
|
|
230
|
-
assertGhSuccess(args, res, options.env);
|
|
215
|
+
const res = spawn(bin, [...args], ghSpawnOptions(extraEnv, timeoutMs));
|
|
216
|
+
assertGhSuccess(args, res);
|
|
231
217
|
}
|
|
232
|
-
function assertGhSuccess(args, res
|
|
218
|
+
function assertGhSuccess(args, res) {
|
|
233
219
|
if (res.error) {
|
|
234
220
|
const msg = res.error.message ?? String(res.error);
|
|
235
221
|
throw new Error(`gh CLI not available \u2014 install gh (brew install gh / apt install gh): ${msg}`);
|
|
236
222
|
}
|
|
237
223
|
if (res.status !== 0) {
|
|
238
|
-
throw new Error(`gh ${args.join(" ")} failed (exit ${res.status}): ${res.stderr}
|
|
239
|
-
[rig gh env:standard-plugin] GH_TOKEN=${tokenDiagnostic(env.GH_TOKEN)} GITHUB_TOKEN=${tokenDiagnostic(env.GITHUB_TOKEN)} RIG_GITHUB_TOKEN=${tokenDiagnostic(env.RIG_GITHUB_TOKEN)}`);
|
|
224
|
+
throw new Error(`gh ${args.join(" ")} failed (exit ${res.status}): ${res.stderr}`);
|
|
240
225
|
}
|
|
241
226
|
}
|
|
242
227
|
function statusLabelFor(status) {
|
package/dist/src/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
// packages/standard-plugin/src/index.ts
|
|
3
|
-
import { resolve as resolve3 } from "path";
|
|
4
3
|
import { definePlugin } from "@rig/core";
|
|
5
4
|
|
|
6
5
|
// packages/standard-plugin/src/github-issues-source.ts
|
|
@@ -15,9 +14,9 @@ function createEnvGitHubCredentialProvider() {
|
|
|
15
14
|
return {
|
|
16
15
|
async resolveGitHubToken(input) {
|
|
17
16
|
if (input.purpose === "selected-repo") {
|
|
18
|
-
return { token: cleanToken(process.env.RIG_GITHUB_SELECTED_TOKEN ??
|
|
17
|
+
return { token: cleanToken(process.env.RIG_GITHUB_SELECTED_TOKEN ?? null) ?? "", source: "signed-in-user" };
|
|
19
18
|
}
|
|
20
|
-
const token = cleanToken(process.env.
|
|
19
|
+
const token = cleanToken(process.env.GH_TOKEN ?? process.env.GITHUB_TOKEN ?? null);
|
|
21
20
|
if (!token) {
|
|
22
21
|
throw new Error("No host GitHub token is configured for admin fallback.");
|
|
23
22
|
}
|
|
@@ -48,12 +47,12 @@ function createStateGitHubCredentialProvider(options = {}) {
|
|
|
48
47
|
async resolveGitHubToken(input) {
|
|
49
48
|
const token = readToken();
|
|
50
49
|
if (input.purpose === "selected-repo") {
|
|
51
|
-
return { token: token ??
|
|
50
|
+
return { token: token ?? "", source: "signed-in-user" };
|
|
52
51
|
}
|
|
53
52
|
if (token) {
|
|
54
53
|
return { token, source: "signed-in-user" };
|
|
55
54
|
}
|
|
56
|
-
const fallback = cleanToken(process.env.
|
|
55
|
+
const fallback = cleanToken(process.env.GH_TOKEN ?? process.env.GITHUB_TOKEN ?? null);
|
|
57
56
|
if (!fallback) {
|
|
58
57
|
throw new Error("No signed-in GitHub token is stored for Rig and no host admin fallback token is configured.");
|
|
59
58
|
}
|
|
@@ -171,21 +170,13 @@ function isRigStickyStatusComment(body) {
|
|
|
171
170
|
return body.includes(RIG_STATUS_COMMENT_MARKER);
|
|
172
171
|
}
|
|
173
172
|
function ghSpawnOptions(extraEnv, timeoutMs) {
|
|
174
|
-
|
|
175
|
-
encoding: "utf-8",
|
|
176
|
-
|
|
177
|
-
env: {
|
|
178
|
-
...process.env,
|
|
179
|
-
...process.env.GH_TOKEN !== undefined ? { GH_TOKEN: process.env.GH_TOKEN } : {},
|
|
180
|
-
...process.env.GITHUB_TOKEN !== undefined ? { GITHUB_TOKEN: process.env.GITHUB_TOKEN } : {},
|
|
181
|
-
...process.env.RIG_GITHUB_TOKEN !== undefined ? { RIG_GITHUB_TOKEN: process.env.RIG_GITHUB_TOKEN } : {},
|
|
182
|
-
...extraEnv ?? {}
|
|
183
|
-
}
|
|
184
|
-
};
|
|
173
|
+
if (!extraEnv)
|
|
174
|
+
return { encoding: "utf-8", timeout: timeoutMs };
|
|
175
|
+
return { encoding: "utf-8", timeout: timeoutMs, env: { ...process.env, ...extraEnv } };
|
|
185
176
|
}
|
|
186
177
|
function credentialEnv(token) {
|
|
187
178
|
const clean = token?.trim() ?? "";
|
|
188
|
-
return { GH_TOKEN: clean, GITHUB_TOKEN: clean
|
|
179
|
+
return { GH_TOKEN: clean, GITHUB_TOKEN: clean };
|
|
189
180
|
}
|
|
190
181
|
async function resolveCredentialEnv(opts, purpose) {
|
|
191
182
|
if (!opts.credentialProvider)
|
|
@@ -200,31 +191,24 @@ async function resolveCredentialEnv(opts, purpose) {
|
|
|
200
191
|
const resolved = await opts.credentialProvider.resolveGitHubToken(input);
|
|
201
192
|
return credentialEnv(resolved.token);
|
|
202
193
|
}
|
|
203
|
-
function tokenDiagnostic(value) {
|
|
204
|
-
const clean = value?.trim() ?? "";
|
|
205
|
-
return clean ? `present(len=${clean.length})` : "missing";
|
|
206
|
-
}
|
|
207
194
|
function runGh(bin, args, spawn, extraEnv, timeoutMs) {
|
|
208
|
-
const
|
|
209
|
-
|
|
210
|
-
assertGhSuccess(args, res, options.env);
|
|
195
|
+
const res = spawn(bin, [...args], ghSpawnOptions(extraEnv, timeoutMs));
|
|
196
|
+
assertGhSuccess(args, res);
|
|
211
197
|
if (!res.stdout || res.stdout.trim() === "")
|
|
212
198
|
return [];
|
|
213
199
|
return JSON.parse(res.stdout);
|
|
214
200
|
}
|
|
215
201
|
function runGhVoid(bin, args, spawn, extraEnv, timeoutMs) {
|
|
216
|
-
const
|
|
217
|
-
|
|
218
|
-
assertGhSuccess(args, res, options.env);
|
|
202
|
+
const res = spawn(bin, [...args], ghSpawnOptions(extraEnv, timeoutMs));
|
|
203
|
+
assertGhSuccess(args, res);
|
|
219
204
|
}
|
|
220
|
-
function assertGhSuccess(args, res
|
|
205
|
+
function assertGhSuccess(args, res) {
|
|
221
206
|
if (res.error) {
|
|
222
207
|
const msg = res.error.message ?? String(res.error);
|
|
223
208
|
throw new Error(`gh CLI not available \u2014 install gh (brew install gh / apt install gh): ${msg}`);
|
|
224
209
|
}
|
|
225
210
|
if (res.status !== 0) {
|
|
226
|
-
throw new Error(`gh ${args.join(" ")} failed (exit ${res.status}): ${res.stderr}
|
|
227
|
-
[rig gh env:standard-plugin] GH_TOKEN=${tokenDiagnostic(env.GH_TOKEN)} GITHUB_TOKEN=${tokenDiagnostic(env.GITHUB_TOKEN)} RIG_GITHUB_TOKEN=${tokenDiagnostic(env.RIG_GITHUB_TOKEN)}`);
|
|
211
|
+
throw new Error(`gh ${args.join(" ")} failed (exit ${res.status}): ${res.stderr}`);
|
|
228
212
|
}
|
|
229
213
|
}
|
|
230
214
|
function statusLabelFor(status) {
|
|
@@ -626,13 +610,13 @@ function standardPlugin(opts = {}) {
|
|
|
626
610
|
id: "std:github-issues",
|
|
627
611
|
kind: "github-issues",
|
|
628
612
|
description: "GitHub Issues via gh CLI",
|
|
629
|
-
factory(config
|
|
613
|
+
factory(config) {
|
|
630
614
|
const options = {
|
|
631
615
|
owner: requireStringField(config, "owner", "github-issues"),
|
|
632
616
|
repo: requireStringField(config, "repo", "github-issues")
|
|
633
617
|
};
|
|
634
|
-
|
|
635
|
-
|
|
618
|
+
if (opts.githubCredentialProvider)
|
|
619
|
+
options.credentialProvider = opts.githubCredentialProvider;
|
|
636
620
|
if (opts.githubWorkspaceId)
|
|
637
621
|
options.workspaceId = opts.githubWorkspaceId;
|
|
638
622
|
if (opts.githubUserId)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@h-rig/standard-plugin",
|
|
3
|
-
"version": "0.0.6-alpha.
|
|
3
|
+
"version": "0.0.6-alpha.90",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Rig package",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"module": "./dist/src/index.js",
|
|
22
22
|
"types": "./dist/src/index.d.ts",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@rig/contracts": "npm:@h-rig/contracts@0.0.6-alpha.
|
|
25
|
-
"@rig/core": "npm:@h-rig/core@0.0.6-alpha.
|
|
24
|
+
"@rig/contracts": "npm:@h-rig/contracts@0.0.6-alpha.90",
|
|
25
|
+
"@rig/core": "npm:@h-rig/core@0.0.6-alpha.90",
|
|
26
26
|
"effect": "4.0.0-beta.78"
|
|
27
27
|
}
|
|
28
28
|
}
|