@databricks-solutions/lakebase-scm-utils 0.3.9 → 0.3.11
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/{pr-e-E4aP4j.d.cts → pr-D-eayWyJ.d.cts} +59 -1
- package/dist/{pr-e-E4aP4j.d.ts → pr-D-eayWyJ.d.ts} +59 -1
- package/dist/scripts/git/index.cjs +30 -14
- package/dist/scripts/git/index.d.cts +32 -1
- package/dist/scripts/git/index.d.ts +32 -1
- package/dist/scripts/git/index.js +28 -14
- package/dist/scripts/github/index.d.cts +2 -60
- package/dist/scripts/github/index.d.ts +2 -60
- package/dist/scripts/index.cjs +301 -98
- package/dist/scripts/index.d.cts +4 -4
- package/dist/scripts/index.d.ts +4 -4
- package/dist/scripts/index.js +296 -98
- package/dist/scripts/lakebase/branch.cli.cjs +55 -10
- package/dist/scripts/lakebase/branch.cli.js +55 -10
- package/dist/scripts/lakebase/ci-resolve-branch.cli.cjs +59 -24
- package/dist/scripts/lakebase/ci-resolve-branch.cli.js +59 -24
- package/dist/scripts/lakebase/collapse-heads.cli.cjs +16 -14
- package/dist/scripts/lakebase/collapse-heads.cli.js +16 -14
- package/dist/scripts/lakebase/cut-backup.cli.cjs +43 -10
- package/dist/scripts/lakebase/cut-backup.cli.js +43 -10
- package/dist/scripts/lakebase/cut-tier.cli.cjs +43 -10
- package/dist/scripts/lakebase/cut-tier.cli.js +43 -10
- package/dist/scripts/lakebase/detect-language.cli.cjs +16 -14
- package/dist/scripts/lakebase/detect-language.cli.js +16 -14
- package/dist/scripts/lakebase/doctor.cli.cjs +16 -14
- package/dist/scripts/lakebase/doctor.cli.js +16 -14
- package/dist/scripts/lakebase/get-connection.cli.cjs +16 -14
- package/dist/scripts/lakebase/get-connection.cli.js +16 -14
- package/dist/scripts/lakebase/index.cjs +313 -99
- package/dist/scripts/lakebase/index.d.cts +97 -2
- package/dist/scripts/lakebase/index.d.ts +97 -2
- package/dist/scripts/lakebase/index.js +310 -99
- package/dist/scripts/lakebase/infra-runner.cli.cjs +16 -14
- package/dist/scripts/lakebase/infra-runner.cli.js +16 -14
- package/dist/scripts/lakebase/new-migration.cli.cjs +16 -14
- package/dist/scripts/lakebase/new-migration.cli.js +16 -14
- package/dist/scripts/lakebase/schema-diff.cli.cjs +16 -14
- package/dist/scripts/lakebase/schema-diff.cli.js +16 -14
- package/dist/scripts/lakebase/schema-migrate.cli.cjs +16 -14
- package/dist/scripts/lakebase/schema-migrate.cli.js +16 -14
- package/dist/scripts/lakebase/scm-claim-feature.cli.cjs +59 -24
- package/dist/scripts/lakebase/scm-claim-feature.cli.js +59 -24
- package/dist/scripts/lakebase/scm-doctor.cli.cjs +59 -24
- package/dist/scripts/lakebase/scm-doctor.cli.js +59 -24
- package/dist/scripts/lakebase/scm-merge.cli.cjs +16 -14
- package/dist/scripts/lakebase/scm-merge.cli.js +16 -14
- package/dist/scripts/lakebase/scm-reconcile-tier.cli.cjs +16 -14
- package/dist/scripts/lakebase/scm-reconcile-tier.cli.js +16 -14
- package/dist/scripts/lakebase/scm-recover-orphans.cli.cjs +43 -10
- package/dist/scripts/lakebase/scm-recover-orphans.cli.js +43 -10
- package/dist/scripts/lakebase/snapshot.cli.cjs +418 -0
- package/dist/scripts/lakebase/snapshot.cli.d.cts +1 -0
- package/dist/scripts/lakebase/snapshot.cli.d.ts +1 -0
- package/dist/scripts/lakebase/snapshot.cli.js +395 -0
- package/dist/scripts/util/index.cjs +2 -2
- package/dist/scripts/util/index.js +2 -2
- package/package.json +2 -1
- package/scripts/git/commit-push.ts +60 -14
- package/scripts/lakebase/branch-create.ts +93 -14
- package/scripts/lakebase/branch.cli.ts +15 -0
- package/scripts/lakebase/create-preflight.ts +213 -1
- package/scripts/lakebase/create-project.ts +98 -30
- package/scripts/lakebase/get-connection.ts +29 -12
- package/scripts/lakebase/snapshot.cli.ts +117 -0
- package/scripts/lakebase/snapshot.ts +85 -0
- package/templates/project/common/scripts/run-tests.sh +43 -2
- package/templates/project/python/tests/conftest.py +22 -0
- package/templates/project/common/tests/e2e/__pycache__/conftest.cpython-314.pyc +0 -0
- package/templates/project/python/tests/__pycache__/conftest.cpython-314.pyc +0 -0
|
@@ -1,3 +1,61 @@
|
|
|
1
|
+
declare class GitHubRepoError extends Error {
|
|
2
|
+
readonly status?: number;
|
|
3
|
+
constructor(message: string, status?: number);
|
|
4
|
+
}
|
|
5
|
+
/** Returns the GitHub login of the currently authenticated user. */
|
|
6
|
+
declare function getCurrentUser(): Promise<string>;
|
|
7
|
+
interface GitHubScopeStatus {
|
|
8
|
+
/** Granted OAuth scopes, or null when the token exposes NONE — a fine-grained
|
|
9
|
+
* PAT or GitHub App token carries no OAuth scope header; its permissions
|
|
10
|
+
* aren't a scope set, so callers MUST treat null as "unknown", never a miss. */
|
|
11
|
+
granted: string[] | null;
|
|
12
|
+
/** Required scopes absent from `granted` (empty when `granted` is null). */
|
|
13
|
+
missing: string[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Read the authenticated token's granted OAuth scopes from the GitHub API
|
|
17
|
+
* `x-oauth-scopes` response header and diff them against `required`. A classic
|
|
18
|
+
* OAuth/PAT token returns a (possibly empty) comma-separated header; a
|
|
19
|
+
* fine-grained PAT / GitHub App token omits it entirely → `granted: null`.
|
|
20
|
+
* Reading your own user needs no special scope, so this succeeds for any VALID
|
|
21
|
+
* token regardless of scopes (and throws, like the other ops, on a bad token /
|
|
22
|
+
* network error — callers decide whether that is blocking).
|
|
23
|
+
*/
|
|
24
|
+
declare function checkGitHubScopes(required?: readonly string[]): Promise<GitHubScopeStatus>;
|
|
25
|
+
interface CreateRepoOptions {
|
|
26
|
+
/** Make the repo private. Default: true. */
|
|
27
|
+
private?: boolean;
|
|
28
|
+
description?: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Create a new GitHub repository. Accepts either bare name (creates for the
|
|
32
|
+
* authenticated user) or "owner/name" (creates in org if owner != login).
|
|
33
|
+
*
|
|
34
|
+
* @returns the repo HTML URL.
|
|
35
|
+
*/
|
|
36
|
+
declare function createRepo(name: string, opts?: CreateRepoOptions): Promise<string>;
|
|
37
|
+
/** Delete a GitHub repository. Requires the `delete_repo` OAuth scope. */
|
|
38
|
+
declare function deleteRepo(name: string): Promise<void>;
|
|
39
|
+
/** True iff the repository exists and is visible to the authenticated user. */
|
|
40
|
+
declare function repoExists(name: string): Promise<boolean>;
|
|
41
|
+
/**
|
|
42
|
+
* Whether GitHub Actions is enabled for `ownerRepo`. `GET .../actions/permissions`
|
|
43
|
+
* returns `enabled:false` both when a repo admin disabled Actions AND when an org
|
|
44
|
+
* policy disables it for the repo. When Actions is off, the kit's CI workflows
|
|
45
|
+
* (pr.yml / merge.yml) silently never run, which presents as "CI didn't follow
|
|
46
|
+
* the kit workflow". Returns:
|
|
47
|
+
* - true / false : the determined state
|
|
48
|
+
* - undefined : couldn't determine (no token, repo invisible, API error) ,
|
|
49
|
+
* callers must treat this as "unknown", never as disabled,
|
|
50
|
+
* so a missing token never produces a false alarm.
|
|
51
|
+
*/
|
|
52
|
+
declare function getActionsEnabled(ownerRepo: string): Promise<boolean | undefined>;
|
|
53
|
+
/**
|
|
54
|
+
* Resolve the canonical `owner/repo` slug. Used by create-project to poll
|
|
55
|
+
* until a freshly-created repo is visible (SAML / propagation delays).
|
|
56
|
+
*/
|
|
57
|
+
declare function getRepoFullName(name: string): Promise<string>;
|
|
58
|
+
|
|
1
59
|
declare class GitHubPullRequestError extends Error {
|
|
2
60
|
readonly status?: number | undefined;
|
|
3
61
|
constructor(message: string, status?: number | undefined);
|
|
@@ -172,4 +230,4 @@ interface MergePairedPullRequestResult {
|
|
|
172
230
|
*/
|
|
173
231
|
declare function mergePairedPullRequest(args: MergePairedPullRequestArgs): Promise<MergePairedPullRequestResult>;
|
|
174
232
|
|
|
175
|
-
export { type CreatePullRequestArgs as C, type FastForwardBranchArgs as F, GitHubPullRequestError as G, type MergePairedPullRequestArgs as M, type PullRequestCheck as P, type WorkflowRunSummary as W, type
|
|
233
|
+
export { type CreatePullRequestArgs as C, type FastForwardBranchArgs as F, GitHubPullRequestError as G, type MergePairedPullRequestArgs as M, type PullRequestCheck as P, type WorkflowRunSummary as W, type CreateRepoOptions as a, GitHubRepoError as b, type GitHubScopeStatus as c, type MergePairedPullRequestResult as d, type MergePullRequestArgs as e, type MergePullRequestResult as f, type PullRequestFile as g, type PullRequestInfo as h, type PullRequestReview as i, checkGitHubScopes as j, createPullRequest as k, createRepo as l, deleteRepo as m, fastForwardBranch as n, getActionsEnabled as o, getCurrentUser as p, getPullRequest as q, getPullRequestComments as r, getPullRequestFiles as s, getPullRequestReviews as t, getRepoFullName as u, listIssueComments as v, listWorkflowRuns as w, mergePairedPullRequest as x, mergePullRequest as y, repoExists as z };
|
|
@@ -1,3 +1,61 @@
|
|
|
1
|
+
declare class GitHubRepoError extends Error {
|
|
2
|
+
readonly status?: number;
|
|
3
|
+
constructor(message: string, status?: number);
|
|
4
|
+
}
|
|
5
|
+
/** Returns the GitHub login of the currently authenticated user. */
|
|
6
|
+
declare function getCurrentUser(): Promise<string>;
|
|
7
|
+
interface GitHubScopeStatus {
|
|
8
|
+
/** Granted OAuth scopes, or null when the token exposes NONE — a fine-grained
|
|
9
|
+
* PAT or GitHub App token carries no OAuth scope header; its permissions
|
|
10
|
+
* aren't a scope set, so callers MUST treat null as "unknown", never a miss. */
|
|
11
|
+
granted: string[] | null;
|
|
12
|
+
/** Required scopes absent from `granted` (empty when `granted` is null). */
|
|
13
|
+
missing: string[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Read the authenticated token's granted OAuth scopes from the GitHub API
|
|
17
|
+
* `x-oauth-scopes` response header and diff them against `required`. A classic
|
|
18
|
+
* OAuth/PAT token returns a (possibly empty) comma-separated header; a
|
|
19
|
+
* fine-grained PAT / GitHub App token omits it entirely → `granted: null`.
|
|
20
|
+
* Reading your own user needs no special scope, so this succeeds for any VALID
|
|
21
|
+
* token regardless of scopes (and throws, like the other ops, on a bad token /
|
|
22
|
+
* network error — callers decide whether that is blocking).
|
|
23
|
+
*/
|
|
24
|
+
declare function checkGitHubScopes(required?: readonly string[]): Promise<GitHubScopeStatus>;
|
|
25
|
+
interface CreateRepoOptions {
|
|
26
|
+
/** Make the repo private. Default: true. */
|
|
27
|
+
private?: boolean;
|
|
28
|
+
description?: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Create a new GitHub repository. Accepts either bare name (creates for the
|
|
32
|
+
* authenticated user) or "owner/name" (creates in org if owner != login).
|
|
33
|
+
*
|
|
34
|
+
* @returns the repo HTML URL.
|
|
35
|
+
*/
|
|
36
|
+
declare function createRepo(name: string, opts?: CreateRepoOptions): Promise<string>;
|
|
37
|
+
/** Delete a GitHub repository. Requires the `delete_repo` OAuth scope. */
|
|
38
|
+
declare function deleteRepo(name: string): Promise<void>;
|
|
39
|
+
/** True iff the repository exists and is visible to the authenticated user. */
|
|
40
|
+
declare function repoExists(name: string): Promise<boolean>;
|
|
41
|
+
/**
|
|
42
|
+
* Whether GitHub Actions is enabled for `ownerRepo`. `GET .../actions/permissions`
|
|
43
|
+
* returns `enabled:false` both when a repo admin disabled Actions AND when an org
|
|
44
|
+
* policy disables it for the repo. When Actions is off, the kit's CI workflows
|
|
45
|
+
* (pr.yml / merge.yml) silently never run, which presents as "CI didn't follow
|
|
46
|
+
* the kit workflow". Returns:
|
|
47
|
+
* - true / false : the determined state
|
|
48
|
+
* - undefined : couldn't determine (no token, repo invisible, API error) ,
|
|
49
|
+
* callers must treat this as "unknown", never as disabled,
|
|
50
|
+
* so a missing token never produces a false alarm.
|
|
51
|
+
*/
|
|
52
|
+
declare function getActionsEnabled(ownerRepo: string): Promise<boolean | undefined>;
|
|
53
|
+
/**
|
|
54
|
+
* Resolve the canonical `owner/repo` slug. Used by create-project to poll
|
|
55
|
+
* until a freshly-created repo is visible (SAML / propagation delays).
|
|
56
|
+
*/
|
|
57
|
+
declare function getRepoFullName(name: string): Promise<string>;
|
|
58
|
+
|
|
1
59
|
declare class GitHubPullRequestError extends Error {
|
|
2
60
|
readonly status?: number | undefined;
|
|
3
61
|
constructor(message: string, status?: number | undefined);
|
|
@@ -172,4 +230,4 @@ interface MergePairedPullRequestResult {
|
|
|
172
230
|
*/
|
|
173
231
|
declare function mergePairedPullRequest(args: MergePairedPullRequestArgs): Promise<MergePairedPullRequestResult>;
|
|
174
232
|
|
|
175
|
-
export { type CreatePullRequestArgs as C, type FastForwardBranchArgs as F, GitHubPullRequestError as G, type MergePairedPullRequestArgs as M, type PullRequestCheck as P, type WorkflowRunSummary as W, type
|
|
233
|
+
export { type CreatePullRequestArgs as C, type FastForwardBranchArgs as F, GitHubPullRequestError as G, type MergePairedPullRequestArgs as M, type PullRequestCheck as P, type WorkflowRunSummary as W, type CreateRepoOptions as a, GitHubRepoError as b, type GitHubScopeStatus as c, type MergePairedPullRequestResult as d, type MergePullRequestArgs as e, type MergePullRequestResult as f, type PullRequestFile as g, type PullRequestInfo as h, type PullRequestReview as i, checkGitHubScopes as j, createPullRequest as k, createRepo as l, deleteRepo as m, fastForwardBranch as n, getActionsEnabled as o, getCurrentUser as p, getPullRequest as q, getPullRequestComments as r, getPullRequestFiles as s, getPullRequestReviews as t, getRepoFullName as u, listIssueComments as v, listWorkflowRuns as w, mergePairedPullRequest as x, mergePullRequest as y, repoExists as z };
|
|
@@ -44,6 +44,7 @@ __export(git_exports, {
|
|
|
44
44
|
commitAllSignedOff: () => commitAllSignedOff,
|
|
45
45
|
commitAmend: () => commitAmend,
|
|
46
46
|
commitAndPush: () => commitAndPush,
|
|
47
|
+
commitInitial: () => commitInitial,
|
|
47
48
|
commitSignedOff: () => commitSignedOff,
|
|
48
49
|
createTag: () => createTag,
|
|
49
50
|
createWorktree: () => createWorktree,
|
|
@@ -88,6 +89,7 @@ __export(git_exports, {
|
|
|
88
89
|
pullRebase: () => pullRebase,
|
|
89
90
|
push: () => push,
|
|
90
91
|
pushCurrentBranchForPr: () => pushCurrentBranchForPr,
|
|
92
|
+
pushInitial: () => pushInitial,
|
|
91
93
|
pushTo: () => pushTo,
|
|
92
94
|
rebaseBranch: () => rebaseBranch,
|
|
93
95
|
removeRemote: () => removeRemote,
|
|
@@ -161,26 +163,38 @@ To finish:
|
|
|
161
163
|
}
|
|
162
164
|
};
|
|
163
165
|
async function commitAndPush(args) {
|
|
164
|
-
await
|
|
165
|
-
|
|
166
|
-
|
|
166
|
+
await commitInitial(args.projectDir, args.message);
|
|
167
|
+
if (args.push === false) return;
|
|
168
|
+
await pushInitial({ projectDir: args.projectDir, remote: args.remote, branch: args.branch });
|
|
169
|
+
}
|
|
170
|
+
async function commitInitial(projectDir, message) {
|
|
171
|
+
await exec2("git add -A", { cwd: projectDir });
|
|
172
|
+
await exec2(`git commit -m ${JSON.stringify(message)}`, {
|
|
173
|
+
cwd: projectDir,
|
|
167
174
|
timeout: 3e4
|
|
168
175
|
});
|
|
169
|
-
|
|
176
|
+
}
|
|
177
|
+
async function pushInitial(args) {
|
|
170
178
|
const remote = args.remote ?? "origin";
|
|
171
179
|
const branch = args.branch ?? "main";
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
180
|
+
const attempts = Math.max(1, args.attempts ?? 1);
|
|
181
|
+
const sleep = args.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms)));
|
|
182
|
+
const run = args.run ?? ((cmd, cwd) => exec2(cmd, { cwd, timeout: 3e4 }).then(() => void 0));
|
|
183
|
+
let lastErr;
|
|
184
|
+
for (let i = 1; i <= attempts; i++) {
|
|
185
|
+
try {
|
|
186
|
+
await run(`git push -u ${remote} ${branch}`, args.projectDir);
|
|
187
|
+
return;
|
|
188
|
+
} catch (err) {
|
|
189
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
190
|
+
if (/without `?workflow`? scope|workflow scope/i.test(msg)) {
|
|
191
|
+
throw new WorkflowScopeError(args.projectDir);
|
|
192
|
+
}
|
|
193
|
+
lastErr = err;
|
|
194
|
+
if (i < attempts) await sleep(args.delayMs ?? 1500);
|
|
181
195
|
}
|
|
182
|
-
throw err;
|
|
183
196
|
}
|
|
197
|
+
throw lastErr instanceof Error ? lastErr : new Error(String(lastErr));
|
|
184
198
|
}
|
|
185
199
|
|
|
186
200
|
// scripts/util/parse-owner-repo.ts
|
|
@@ -984,6 +998,7 @@ async function cherryPick(args) {
|
|
|
984
998
|
commitAllSignedOff,
|
|
985
999
|
commitAmend,
|
|
986
1000
|
commitAndPush,
|
|
1001
|
+
commitInitial,
|
|
987
1002
|
commitSignedOff,
|
|
988
1003
|
createTag,
|
|
989
1004
|
createWorktree,
|
|
@@ -1028,6 +1043,7 @@ async function cherryPick(args) {
|
|
|
1028
1043
|
pullRebase,
|
|
1029
1044
|
push,
|
|
1030
1045
|
pushCurrentBranchForPr,
|
|
1046
|
+
pushInitial,
|
|
1031
1047
|
pushTo,
|
|
1032
1048
|
rebaseBranch,
|
|
1033
1049
|
removeRemote,
|
|
@@ -56,6 +56,37 @@ declare class WorkflowScopeError extends Error {
|
|
|
56
56
|
* For non-initial-commit flows, prefer the primitives in ./commits.ts.
|
|
57
57
|
*/
|
|
58
58
|
declare function commitAndPush(args: CommitAndPushArgs): Promise<void>;
|
|
59
|
+
/** Stage everything and make the initial commit (no push). */
|
|
60
|
+
declare function commitInitial(projectDir: string, message: string): Promise<void>;
|
|
61
|
+
interface PushInitialArgs {
|
|
62
|
+
projectDir: string;
|
|
63
|
+
/** Remote name. Default: "origin". */
|
|
64
|
+
remote?: string;
|
|
65
|
+
/** Branch name. Default: "main". */
|
|
66
|
+
branch?: string;
|
|
67
|
+
/**
|
|
68
|
+
* Total push attempts (>= 1). Default 1 (preserves commitAndPush's behavior).
|
|
69
|
+
* The create flow passes 2: the FIRST push fires the project's pre-push hook,
|
|
70
|
+
* which triggers the one-time cold download of the Consort toolkit — that race
|
|
71
|
+
* can fail the push, but the toolkit is CACHED afterward, so a single retry then
|
|
72
|
+
* sails through (the cold-download incident). A `workflow`-scope rejection is a
|
|
73
|
+
* real auth gap, never retried.
|
|
74
|
+
*/
|
|
75
|
+
attempts?: number;
|
|
76
|
+
/** Delay between attempts (ms). Default 1500. Injected in tests. */
|
|
77
|
+
delayMs?: number;
|
|
78
|
+
/** Injectable sleep (tests). */
|
|
79
|
+
sleep?: (ms: number) => Promise<void>;
|
|
80
|
+
/** Injectable runner (tests); defaults to the real `git push`. */
|
|
81
|
+
run?: (cmd: string, cwd: string) => Promise<void>;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Push the initial branch with `-u`, retrying a transient failure up to
|
|
85
|
+
* `attempts` times. Maps the GitHub `workflow`-scope rejection to
|
|
86
|
+
* {@link WorkflowScopeError} (thrown immediately, never retried). Throws the last
|
|
87
|
+
* error after the final attempt.
|
|
88
|
+
*/
|
|
89
|
+
declare function pushInitial(args: PushInitialArgs): Promise<void>;
|
|
59
90
|
|
|
60
91
|
interface AddRemoteArgs {
|
|
61
92
|
cwd: string;
|
|
@@ -763,4 +794,4 @@ declare function revert(args: ShaArgs): Promise<void>;
|
|
|
763
794
|
/** `git cherry-pick <sha>`. */
|
|
764
795
|
declare function cherryPick(args: ShaArgs): Promise<void>;
|
|
765
796
|
|
|
766
|
-
export { type AddRemoteArgs, type AheadBehind, type AmendArgs, type BranchesAtCommitArgs, type CheckoutBranchArgs, type CloneRepoArgs, type CommitAllArgs, type CommitAndPushArgs, type CommitArgs, type CommitFilesArgs, type CreateTagArgs, type CreateWorktreeArgs, type CwdOnlyArgs, type DeleteLocalBranchArgs, type DeleteRemoteBranchArgs, type DeleteRemoteTagArgs, type DeleteTagArgs, type DiffFilesArgs, type DiscardAllChangesArgs, type FetchArgs, type FileChangeShort, type GetFileAtRefArgs, type GetMergeBaseArgs, type GitBranchInfo, type HasRemoteBranchArgs, type IsDirtyArgs, type ListLocalBranchesArgs, type ListMigrationsOnBranchArgs, type ListRemoteBranchesArgs, type LogRawArgs, type MergeBranchArgs, type MergeCommit, type NearestParent, type OutgoingIncomingArgs, ProtectedBranchError, type PublishBranchArgs, type PullFromArgs, type PushCurrentBranchForPrArgs, type PushToArgs, type RebaseBranchArgs, type RecentMergesArgs, type RemoveRemoteArgs, type RemoveWorktreeArgs, type RenameBranchArgs, type ResolveNearestParentArgs, type ShaArgs, type StashIndexArgs, type StashWithMessageArgs, type UndoLastCommitArgs, WorkflowScopeError, abortRebase, addRemote, checkoutBranch, checkoutDetached, cherryPick, cloneRepo, commit, commitAll, commitAllIfChanged, commitAllSignedOff, commitAmend, commitAndPush, commitSignedOff, createTag, createWorktree, deleteLocalBranch, deleteRemoteBranch, deleteRemoteTag, deleteTag, discardAllChanges, fetch, getAheadBehind, getBranchesAtCommit, getCommitFiles, getCurrentBranch, getDiffFiles, getFileAtRef, getGitHubUrl, getIncomingCommits, getLogRaw, getLogShortstat, getMergeBase, getNearestParentName, getOutgoingCommits, getOwnerRepo, getRecentMerges, getRepoRoot, gitBranchExists, gitInit, hasRemoteBranch, hasUpstream, isDirty, isRebasing, listLocalBranches, listMigrationsOnBranch, listRemoteBranches, listRemotes, listTags, listWorktrees, mergeBranch, publishBranch, pull, pullFrom, pullRebase, push, pushCurrentBranchForPr, pushTo, rebaseBranch, removeRemote, removeWorktree, renameBranch, resolveDefaultBranch, resolveNearestParent, revert, stash, stashApply, stashDrop, stashDropAll, stashIncludeUntracked, stashList, stashPop, stashStaged, sync, undoLastCommit };
|
|
797
|
+
export { type AddRemoteArgs, type AheadBehind, type AmendArgs, type BranchesAtCommitArgs, type CheckoutBranchArgs, type CloneRepoArgs, type CommitAllArgs, type CommitAndPushArgs, type CommitArgs, type CommitFilesArgs, type CreateTagArgs, type CreateWorktreeArgs, type CwdOnlyArgs, type DeleteLocalBranchArgs, type DeleteRemoteBranchArgs, type DeleteRemoteTagArgs, type DeleteTagArgs, type DiffFilesArgs, type DiscardAllChangesArgs, type FetchArgs, type FileChangeShort, type GetFileAtRefArgs, type GetMergeBaseArgs, type GitBranchInfo, type HasRemoteBranchArgs, type IsDirtyArgs, type ListLocalBranchesArgs, type ListMigrationsOnBranchArgs, type ListRemoteBranchesArgs, type LogRawArgs, type MergeBranchArgs, type MergeCommit, type NearestParent, type OutgoingIncomingArgs, ProtectedBranchError, type PublishBranchArgs, type PullFromArgs, type PushCurrentBranchForPrArgs, type PushInitialArgs, type PushToArgs, type RebaseBranchArgs, type RecentMergesArgs, type RemoveRemoteArgs, type RemoveWorktreeArgs, type RenameBranchArgs, type ResolveNearestParentArgs, type ShaArgs, type StashIndexArgs, type StashWithMessageArgs, type UndoLastCommitArgs, WorkflowScopeError, abortRebase, addRemote, checkoutBranch, checkoutDetached, cherryPick, cloneRepo, commit, commitAll, commitAllIfChanged, commitAllSignedOff, commitAmend, commitAndPush, commitInitial, commitSignedOff, createTag, createWorktree, deleteLocalBranch, deleteRemoteBranch, deleteRemoteTag, deleteTag, discardAllChanges, fetch, getAheadBehind, getBranchesAtCommit, getCommitFiles, getCurrentBranch, getDiffFiles, getFileAtRef, getGitHubUrl, getIncomingCommits, getLogRaw, getLogShortstat, getMergeBase, getNearestParentName, getOutgoingCommits, getOwnerRepo, getRecentMerges, getRepoRoot, gitBranchExists, gitInit, hasRemoteBranch, hasUpstream, isDirty, isRebasing, listLocalBranches, listMigrationsOnBranch, listRemoteBranches, listRemotes, listTags, listWorktrees, mergeBranch, publishBranch, pull, pullFrom, pullRebase, push, pushCurrentBranchForPr, pushInitial, pushTo, rebaseBranch, removeRemote, removeWorktree, renameBranch, resolveDefaultBranch, resolveNearestParent, revert, stash, stashApply, stashDrop, stashDropAll, stashIncludeUntracked, stashList, stashPop, stashStaged, sync, undoLastCommit };
|
|
@@ -56,6 +56,37 @@ declare class WorkflowScopeError extends Error {
|
|
|
56
56
|
* For non-initial-commit flows, prefer the primitives in ./commits.ts.
|
|
57
57
|
*/
|
|
58
58
|
declare function commitAndPush(args: CommitAndPushArgs): Promise<void>;
|
|
59
|
+
/** Stage everything and make the initial commit (no push). */
|
|
60
|
+
declare function commitInitial(projectDir: string, message: string): Promise<void>;
|
|
61
|
+
interface PushInitialArgs {
|
|
62
|
+
projectDir: string;
|
|
63
|
+
/** Remote name. Default: "origin". */
|
|
64
|
+
remote?: string;
|
|
65
|
+
/** Branch name. Default: "main". */
|
|
66
|
+
branch?: string;
|
|
67
|
+
/**
|
|
68
|
+
* Total push attempts (>= 1). Default 1 (preserves commitAndPush's behavior).
|
|
69
|
+
* The create flow passes 2: the FIRST push fires the project's pre-push hook,
|
|
70
|
+
* which triggers the one-time cold download of the Consort toolkit — that race
|
|
71
|
+
* can fail the push, but the toolkit is CACHED afterward, so a single retry then
|
|
72
|
+
* sails through (the cold-download incident). A `workflow`-scope rejection is a
|
|
73
|
+
* real auth gap, never retried.
|
|
74
|
+
*/
|
|
75
|
+
attempts?: number;
|
|
76
|
+
/** Delay between attempts (ms). Default 1500. Injected in tests. */
|
|
77
|
+
delayMs?: number;
|
|
78
|
+
/** Injectable sleep (tests). */
|
|
79
|
+
sleep?: (ms: number) => Promise<void>;
|
|
80
|
+
/** Injectable runner (tests); defaults to the real `git push`. */
|
|
81
|
+
run?: (cmd: string, cwd: string) => Promise<void>;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Push the initial branch with `-u`, retrying a transient failure up to
|
|
85
|
+
* `attempts` times. Maps the GitHub `workflow`-scope rejection to
|
|
86
|
+
* {@link WorkflowScopeError} (thrown immediately, never retried). Throws the last
|
|
87
|
+
* error after the final attempt.
|
|
88
|
+
*/
|
|
89
|
+
declare function pushInitial(args: PushInitialArgs): Promise<void>;
|
|
59
90
|
|
|
60
91
|
interface AddRemoteArgs {
|
|
61
92
|
cwd: string;
|
|
@@ -763,4 +794,4 @@ declare function revert(args: ShaArgs): Promise<void>;
|
|
|
763
794
|
/** `git cherry-pick <sha>`. */
|
|
764
795
|
declare function cherryPick(args: ShaArgs): Promise<void>;
|
|
765
796
|
|
|
766
|
-
export { type AddRemoteArgs, type AheadBehind, type AmendArgs, type BranchesAtCommitArgs, type CheckoutBranchArgs, type CloneRepoArgs, type CommitAllArgs, type CommitAndPushArgs, type CommitArgs, type CommitFilesArgs, type CreateTagArgs, type CreateWorktreeArgs, type CwdOnlyArgs, type DeleteLocalBranchArgs, type DeleteRemoteBranchArgs, type DeleteRemoteTagArgs, type DeleteTagArgs, type DiffFilesArgs, type DiscardAllChangesArgs, type FetchArgs, type FileChangeShort, type GetFileAtRefArgs, type GetMergeBaseArgs, type GitBranchInfo, type HasRemoteBranchArgs, type IsDirtyArgs, type ListLocalBranchesArgs, type ListMigrationsOnBranchArgs, type ListRemoteBranchesArgs, type LogRawArgs, type MergeBranchArgs, type MergeCommit, type NearestParent, type OutgoingIncomingArgs, ProtectedBranchError, type PublishBranchArgs, type PullFromArgs, type PushCurrentBranchForPrArgs, type PushToArgs, type RebaseBranchArgs, type RecentMergesArgs, type RemoveRemoteArgs, type RemoveWorktreeArgs, type RenameBranchArgs, type ResolveNearestParentArgs, type ShaArgs, type StashIndexArgs, type StashWithMessageArgs, type UndoLastCommitArgs, WorkflowScopeError, abortRebase, addRemote, checkoutBranch, checkoutDetached, cherryPick, cloneRepo, commit, commitAll, commitAllIfChanged, commitAllSignedOff, commitAmend, commitAndPush, commitSignedOff, createTag, createWorktree, deleteLocalBranch, deleteRemoteBranch, deleteRemoteTag, deleteTag, discardAllChanges, fetch, getAheadBehind, getBranchesAtCommit, getCommitFiles, getCurrentBranch, getDiffFiles, getFileAtRef, getGitHubUrl, getIncomingCommits, getLogRaw, getLogShortstat, getMergeBase, getNearestParentName, getOutgoingCommits, getOwnerRepo, getRecentMerges, getRepoRoot, gitBranchExists, gitInit, hasRemoteBranch, hasUpstream, isDirty, isRebasing, listLocalBranches, listMigrationsOnBranch, listRemoteBranches, listRemotes, listTags, listWorktrees, mergeBranch, publishBranch, pull, pullFrom, pullRebase, push, pushCurrentBranchForPr, pushTo, rebaseBranch, removeRemote, removeWorktree, renameBranch, resolveDefaultBranch, resolveNearestParent, revert, stash, stashApply, stashDrop, stashDropAll, stashIncludeUntracked, stashList, stashPop, stashStaged, sync, undoLastCommit };
|
|
797
|
+
export { type AddRemoteArgs, type AheadBehind, type AmendArgs, type BranchesAtCommitArgs, type CheckoutBranchArgs, type CloneRepoArgs, type CommitAllArgs, type CommitAndPushArgs, type CommitArgs, type CommitFilesArgs, type CreateTagArgs, type CreateWorktreeArgs, type CwdOnlyArgs, type DeleteLocalBranchArgs, type DeleteRemoteBranchArgs, type DeleteRemoteTagArgs, type DeleteTagArgs, type DiffFilesArgs, type DiscardAllChangesArgs, type FetchArgs, type FileChangeShort, type GetFileAtRefArgs, type GetMergeBaseArgs, type GitBranchInfo, type HasRemoteBranchArgs, type IsDirtyArgs, type ListLocalBranchesArgs, type ListMigrationsOnBranchArgs, type ListRemoteBranchesArgs, type LogRawArgs, type MergeBranchArgs, type MergeCommit, type NearestParent, type OutgoingIncomingArgs, ProtectedBranchError, type PublishBranchArgs, type PullFromArgs, type PushCurrentBranchForPrArgs, type PushInitialArgs, type PushToArgs, type RebaseBranchArgs, type RecentMergesArgs, type RemoveRemoteArgs, type RemoveWorktreeArgs, type RenameBranchArgs, type ResolveNearestParentArgs, type ShaArgs, type StashIndexArgs, type StashWithMessageArgs, type UndoLastCommitArgs, WorkflowScopeError, abortRebase, addRemote, checkoutBranch, checkoutDetached, cherryPick, cloneRepo, commit, commitAll, commitAllIfChanged, commitAllSignedOff, commitAmend, commitAndPush, commitInitial, commitSignedOff, createTag, createWorktree, deleteLocalBranch, deleteRemoteBranch, deleteRemoteTag, deleteTag, discardAllChanges, fetch, getAheadBehind, getBranchesAtCommit, getCommitFiles, getCurrentBranch, getDiffFiles, getFileAtRef, getGitHubUrl, getIncomingCommits, getLogRaw, getLogShortstat, getMergeBase, getNearestParentName, getOutgoingCommits, getOwnerRepo, getRecentMerges, getRepoRoot, gitBranchExists, gitInit, hasRemoteBranch, hasUpstream, isDirty, isRebasing, listLocalBranches, listMigrationsOnBranch, listRemoteBranches, listRemotes, listTags, listWorktrees, mergeBranch, publishBranch, pull, pullFrom, pullRebase, push, pushCurrentBranchForPr, pushInitial, pushTo, rebaseBranch, removeRemote, removeWorktree, renameBranch, resolveDefaultBranch, resolveNearestParent, revert, stash, stashApply, stashDrop, stashDropAll, stashIncludeUntracked, stashList, stashPop, stashStaged, sync, undoLastCommit };
|
|
@@ -50,26 +50,38 @@ To finish:
|
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
52
|
async function commitAndPush(args) {
|
|
53
|
-
await
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
await commitInitial(args.projectDir, args.message);
|
|
54
|
+
if (args.push === false) return;
|
|
55
|
+
await pushInitial({ projectDir: args.projectDir, remote: args.remote, branch: args.branch });
|
|
56
|
+
}
|
|
57
|
+
async function commitInitial(projectDir, message) {
|
|
58
|
+
await exec2("git add -A", { cwd: projectDir });
|
|
59
|
+
await exec2(`git commit -m ${JSON.stringify(message)}`, {
|
|
60
|
+
cwd: projectDir,
|
|
56
61
|
timeout: 3e4
|
|
57
62
|
});
|
|
58
|
-
|
|
63
|
+
}
|
|
64
|
+
async function pushInitial(args) {
|
|
59
65
|
const remote = args.remote ?? "origin";
|
|
60
66
|
const branch = args.branch ?? "main";
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
const attempts = Math.max(1, args.attempts ?? 1);
|
|
68
|
+
const sleep = args.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms)));
|
|
69
|
+
const run = args.run ?? ((cmd, cwd) => exec2(cmd, { cwd, timeout: 3e4 }).then(() => void 0));
|
|
70
|
+
let lastErr;
|
|
71
|
+
for (let i = 1; i <= attempts; i++) {
|
|
72
|
+
try {
|
|
73
|
+
await run(`git push -u ${remote} ${branch}`, args.projectDir);
|
|
74
|
+
return;
|
|
75
|
+
} catch (err) {
|
|
76
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
77
|
+
if (/without `?workflow`? scope|workflow scope/i.test(msg)) {
|
|
78
|
+
throw new WorkflowScopeError(args.projectDir);
|
|
79
|
+
}
|
|
80
|
+
lastErr = err;
|
|
81
|
+
if (i < attempts) await sleep(args.delayMs ?? 1500);
|
|
70
82
|
}
|
|
71
|
-
throw err;
|
|
72
83
|
}
|
|
84
|
+
throw lastErr instanceof Error ? lastErr : new Error(String(lastErr));
|
|
73
85
|
}
|
|
74
86
|
|
|
75
87
|
// scripts/util/parse-owner-repo.ts
|
|
@@ -872,6 +884,7 @@ export {
|
|
|
872
884
|
commitAllSignedOff,
|
|
873
885
|
commitAmend,
|
|
874
886
|
commitAndPush,
|
|
887
|
+
commitInitial,
|
|
875
888
|
commitSignedOff,
|
|
876
889
|
createTag,
|
|
877
890
|
createWorktree,
|
|
@@ -916,6 +929,7 @@ export {
|
|
|
916
929
|
pullRebase,
|
|
917
930
|
push,
|
|
918
931
|
pushCurrentBranchForPr,
|
|
932
|
+
pushInitial,
|
|
919
933
|
pushTo,
|
|
920
934
|
rebaseBranch,
|
|
921
935
|
removeRemote,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { C as CreatePullRequestArgs, F as FastForwardBranchArgs, G as GitHubPullRequestError, M as MergePairedPullRequestArgs,
|
|
1
|
+
export { C as CreatePullRequestArgs, a as CreateRepoOptions, F as FastForwardBranchArgs, G as GitHubPullRequestError, b as GitHubRepoError, c as GitHubScopeStatus, M as MergePairedPullRequestArgs, d as MergePairedPullRequestResult, e as MergePullRequestArgs, f as MergePullRequestResult, P as PullRequestCheck, g as PullRequestFile, h as PullRequestInfo, i as PullRequestReview, W as WorkflowRunSummary, j as checkGitHubScopes, k as createPullRequest, l as createRepo, m as deleteRepo, n as fastForwardBranch, o as getActionsEnabled, p as getCurrentUser, q as getPullRequest, r as getPullRequestComments, s as getPullRequestFiles, t as getPullRequestReviews, u as getRepoFullName, v as listIssueComments, w as listWorkflowRuns, x as mergePairedPullRequest, y as mergePullRequest, z as repoExists } from '../../pr-D-eayWyJ.cjs';
|
|
2
2
|
|
|
3
3
|
/** OAuth scopes the workflow ops collectively need. */
|
|
4
4
|
declare const GITHUB_SCOPES: readonly ["repo", "workflow", "delete_repo"];
|
|
@@ -49,64 +49,6 @@ interface GitHubAuthDiagnosis {
|
|
|
49
49
|
scopes: string[];
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
declare class GitHubRepoError extends Error {
|
|
53
|
-
readonly status?: number;
|
|
54
|
-
constructor(message: string, status?: number);
|
|
55
|
-
}
|
|
56
|
-
/** Returns the GitHub login of the currently authenticated user. */
|
|
57
|
-
declare function getCurrentUser(): Promise<string>;
|
|
58
|
-
interface GitHubScopeStatus {
|
|
59
|
-
/** Granted OAuth scopes, or null when the token exposes NONE — a fine-grained
|
|
60
|
-
* PAT or GitHub App token carries no OAuth scope header; its permissions
|
|
61
|
-
* aren't a scope set, so callers MUST treat null as "unknown", never a miss. */
|
|
62
|
-
granted: string[] | null;
|
|
63
|
-
/** Required scopes absent from `granted` (empty when `granted` is null). */
|
|
64
|
-
missing: string[];
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Read the authenticated token's granted OAuth scopes from the GitHub API
|
|
68
|
-
* `x-oauth-scopes` response header and diff them against `required`. A classic
|
|
69
|
-
* OAuth/PAT token returns a (possibly empty) comma-separated header; a
|
|
70
|
-
* fine-grained PAT / GitHub App token omits it entirely → `granted: null`.
|
|
71
|
-
* Reading your own user needs no special scope, so this succeeds for any VALID
|
|
72
|
-
* token regardless of scopes (and throws, like the other ops, on a bad token /
|
|
73
|
-
* network error — callers decide whether that is blocking).
|
|
74
|
-
*/
|
|
75
|
-
declare function checkGitHubScopes(required?: readonly string[]): Promise<GitHubScopeStatus>;
|
|
76
|
-
interface CreateRepoOptions {
|
|
77
|
-
/** Make the repo private. Default: true. */
|
|
78
|
-
private?: boolean;
|
|
79
|
-
description?: string;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Create a new GitHub repository. Accepts either bare name (creates for the
|
|
83
|
-
* authenticated user) or "owner/name" (creates in org if owner != login).
|
|
84
|
-
*
|
|
85
|
-
* @returns the repo HTML URL.
|
|
86
|
-
*/
|
|
87
|
-
declare function createRepo(name: string, opts?: CreateRepoOptions): Promise<string>;
|
|
88
|
-
/** Delete a GitHub repository. Requires the `delete_repo` OAuth scope. */
|
|
89
|
-
declare function deleteRepo(name: string): Promise<void>;
|
|
90
|
-
/** True iff the repository exists and is visible to the authenticated user. */
|
|
91
|
-
declare function repoExists(name: string): Promise<boolean>;
|
|
92
|
-
/**
|
|
93
|
-
* Whether GitHub Actions is enabled for `ownerRepo`. `GET .../actions/permissions`
|
|
94
|
-
* returns `enabled:false` both when a repo admin disabled Actions AND when an org
|
|
95
|
-
* policy disables it for the repo. When Actions is off, the kit's CI workflows
|
|
96
|
-
* (pr.yml / merge.yml) silently never run, which presents as "CI didn't follow
|
|
97
|
-
* the kit workflow". Returns:
|
|
98
|
-
* - true / false : the determined state
|
|
99
|
-
* - undefined : couldn't determine (no token, repo invisible, API error) ,
|
|
100
|
-
* callers must treat this as "unknown", never as disabled,
|
|
101
|
-
* so a missing token never produces a false alarm.
|
|
102
|
-
*/
|
|
103
|
-
declare function getActionsEnabled(ownerRepo: string): Promise<boolean | undefined>;
|
|
104
|
-
/**
|
|
105
|
-
* Resolve the canonical `owner/repo` slug. Used by create-project to poll
|
|
106
|
-
* until a freshly-created repo is visible (SAML / propagation delays).
|
|
107
|
-
*/
|
|
108
|
-
declare function getRepoFullName(name: string): Promise<string>;
|
|
109
|
-
|
|
110
52
|
declare class GitHubRunnerError extends Error {
|
|
111
53
|
readonly status?: number;
|
|
112
54
|
constructor(message: string, status?: number);
|
|
@@ -145,4 +87,4 @@ declare function setRepoSecrets(ownerRepo: string, secrets: Record<string, strin
|
|
|
145
87
|
/** List configured secret names (returns empty array on any error). */
|
|
146
88
|
declare function listSecretNames(ownerRepo: string): Promise<string[]>;
|
|
147
89
|
|
|
148
|
-
export {
|
|
90
|
+
export { GITHUB_SCOPES, type GitHubAuthDiagnosis, type GitHubAuthSource, GitHubRunnerError, GitHubSecretsError, type RepoRunner, type VsCodeSessionOptions, createRegistrationToken, deleteRunner, diagnoseGitHubAuth, getRunnerIdByName, getRunnerStatus, listRepoRunners, listSecretNames, resolveGitHubToken, setRepoSecret, setRepoSecrets, tryGhAuthToken, tryVsCodeSession };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { C as CreatePullRequestArgs, F as FastForwardBranchArgs, G as GitHubPullRequestError, M as MergePairedPullRequestArgs,
|
|
1
|
+
export { C as CreatePullRequestArgs, a as CreateRepoOptions, F as FastForwardBranchArgs, G as GitHubPullRequestError, b as GitHubRepoError, c as GitHubScopeStatus, M as MergePairedPullRequestArgs, d as MergePairedPullRequestResult, e as MergePullRequestArgs, f as MergePullRequestResult, P as PullRequestCheck, g as PullRequestFile, h as PullRequestInfo, i as PullRequestReview, W as WorkflowRunSummary, j as checkGitHubScopes, k as createPullRequest, l as createRepo, m as deleteRepo, n as fastForwardBranch, o as getActionsEnabled, p as getCurrentUser, q as getPullRequest, r as getPullRequestComments, s as getPullRequestFiles, t as getPullRequestReviews, u as getRepoFullName, v as listIssueComments, w as listWorkflowRuns, x as mergePairedPullRequest, y as mergePullRequest, z as repoExists } from '../../pr-D-eayWyJ.js';
|
|
2
2
|
|
|
3
3
|
/** OAuth scopes the workflow ops collectively need. */
|
|
4
4
|
declare const GITHUB_SCOPES: readonly ["repo", "workflow", "delete_repo"];
|
|
@@ -49,64 +49,6 @@ interface GitHubAuthDiagnosis {
|
|
|
49
49
|
scopes: string[];
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
declare class GitHubRepoError extends Error {
|
|
53
|
-
readonly status?: number;
|
|
54
|
-
constructor(message: string, status?: number);
|
|
55
|
-
}
|
|
56
|
-
/** Returns the GitHub login of the currently authenticated user. */
|
|
57
|
-
declare function getCurrentUser(): Promise<string>;
|
|
58
|
-
interface GitHubScopeStatus {
|
|
59
|
-
/** Granted OAuth scopes, or null when the token exposes NONE — a fine-grained
|
|
60
|
-
* PAT or GitHub App token carries no OAuth scope header; its permissions
|
|
61
|
-
* aren't a scope set, so callers MUST treat null as "unknown", never a miss. */
|
|
62
|
-
granted: string[] | null;
|
|
63
|
-
/** Required scopes absent from `granted` (empty when `granted` is null). */
|
|
64
|
-
missing: string[];
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Read the authenticated token's granted OAuth scopes from the GitHub API
|
|
68
|
-
* `x-oauth-scopes` response header and diff them against `required`. A classic
|
|
69
|
-
* OAuth/PAT token returns a (possibly empty) comma-separated header; a
|
|
70
|
-
* fine-grained PAT / GitHub App token omits it entirely → `granted: null`.
|
|
71
|
-
* Reading your own user needs no special scope, so this succeeds for any VALID
|
|
72
|
-
* token regardless of scopes (and throws, like the other ops, on a bad token /
|
|
73
|
-
* network error — callers decide whether that is blocking).
|
|
74
|
-
*/
|
|
75
|
-
declare function checkGitHubScopes(required?: readonly string[]): Promise<GitHubScopeStatus>;
|
|
76
|
-
interface CreateRepoOptions {
|
|
77
|
-
/** Make the repo private. Default: true. */
|
|
78
|
-
private?: boolean;
|
|
79
|
-
description?: string;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Create a new GitHub repository. Accepts either bare name (creates for the
|
|
83
|
-
* authenticated user) or "owner/name" (creates in org if owner != login).
|
|
84
|
-
*
|
|
85
|
-
* @returns the repo HTML URL.
|
|
86
|
-
*/
|
|
87
|
-
declare function createRepo(name: string, opts?: CreateRepoOptions): Promise<string>;
|
|
88
|
-
/** Delete a GitHub repository. Requires the `delete_repo` OAuth scope. */
|
|
89
|
-
declare function deleteRepo(name: string): Promise<void>;
|
|
90
|
-
/** True iff the repository exists and is visible to the authenticated user. */
|
|
91
|
-
declare function repoExists(name: string): Promise<boolean>;
|
|
92
|
-
/**
|
|
93
|
-
* Whether GitHub Actions is enabled for `ownerRepo`. `GET .../actions/permissions`
|
|
94
|
-
* returns `enabled:false` both when a repo admin disabled Actions AND when an org
|
|
95
|
-
* policy disables it for the repo. When Actions is off, the kit's CI workflows
|
|
96
|
-
* (pr.yml / merge.yml) silently never run, which presents as "CI didn't follow
|
|
97
|
-
* the kit workflow". Returns:
|
|
98
|
-
* - true / false : the determined state
|
|
99
|
-
* - undefined : couldn't determine (no token, repo invisible, API error) ,
|
|
100
|
-
* callers must treat this as "unknown", never as disabled,
|
|
101
|
-
* so a missing token never produces a false alarm.
|
|
102
|
-
*/
|
|
103
|
-
declare function getActionsEnabled(ownerRepo: string): Promise<boolean | undefined>;
|
|
104
|
-
/**
|
|
105
|
-
* Resolve the canonical `owner/repo` slug. Used by create-project to poll
|
|
106
|
-
* until a freshly-created repo is visible (SAML / propagation delays).
|
|
107
|
-
*/
|
|
108
|
-
declare function getRepoFullName(name: string): Promise<string>;
|
|
109
|
-
|
|
110
52
|
declare class GitHubRunnerError extends Error {
|
|
111
53
|
readonly status?: number;
|
|
112
54
|
constructor(message: string, status?: number);
|
|
@@ -145,4 +87,4 @@ declare function setRepoSecrets(ownerRepo: string, secrets: Record<string, strin
|
|
|
145
87
|
/** List configured secret names (returns empty array on any error). */
|
|
146
88
|
declare function listSecretNames(ownerRepo: string): Promise<string[]>;
|
|
147
89
|
|
|
148
|
-
export {
|
|
90
|
+
export { GITHUB_SCOPES, type GitHubAuthDiagnosis, type GitHubAuthSource, GitHubRunnerError, GitHubSecretsError, type RepoRunner, type VsCodeSessionOptions, createRegistrationToken, deleteRunner, diagnoseGitHubAuth, getRunnerIdByName, getRunnerStatus, listRepoRunners, listSecretNames, resolveGitHubToken, setRepoSecret, setRepoSecrets, tryGhAuthToken, tryVsCodeSession };
|