bamboo-agents 0.1.5-dev.11 → 0.1.5-dev.14
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/VERSION +1 -1
- package/dist/index.js +62 -11
- package/dist/index.js.map +2 -2
- package/package.json +1 -1
package/dist/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.1.5-dev.
|
|
1
|
+
0.1.5-dev.14
|
package/dist/index.js
CHANGED
|
@@ -3037,7 +3037,7 @@ var VERSION;
|
|
|
3037
3037
|
var init_version = __esm({
|
|
3038
3038
|
"src/version.ts"() {
|
|
3039
3039
|
"use strict";
|
|
3040
|
-
VERSION = "0.1.5-dev.
|
|
3040
|
+
VERSION = "0.1.5-dev.14";
|
|
3041
3041
|
}
|
|
3042
3042
|
});
|
|
3043
3043
|
|
|
@@ -11363,6 +11363,7 @@ var init_auth_token = __esm({
|
|
|
11363
11363
|
error: external_exports.enum([
|
|
11364
11364
|
"unauthorized",
|
|
11365
11365
|
"no_github_token",
|
|
11366
|
+
"no_active_install",
|
|
11366
11367
|
"expired",
|
|
11367
11368
|
"lookup_failed"
|
|
11368
11369
|
]),
|
|
@@ -11465,7 +11466,16 @@ async function startGithubOAuthRelink(bambooSession) {
|
|
|
11465
11466
|
const json = await res.json();
|
|
11466
11467
|
return OAuthRelinkStartResponseSchema.parse(json);
|
|
11467
11468
|
}
|
|
11468
|
-
|
|
11469
|
+
async function provisionWorkspace(bambooSession) {
|
|
11470
|
+
const res = await cliApiFetch(`${apiBase()}/api/cli/workspace/provision`, {
|
|
11471
|
+
method: "POST",
|
|
11472
|
+
headers: { Authorization: `Bearer ${bambooSession}` }
|
|
11473
|
+
});
|
|
11474
|
+
if (!res.ok) throw await parseError(res);
|
|
11475
|
+
const json = await res.json();
|
|
11476
|
+
return ProvisionWorkspaceResponseSchema.parse(json);
|
|
11477
|
+
}
|
|
11478
|
+
var PROD_DEFAULT_BASE, DEV_DEFAULT_BASE, REQUEST_TIMEOUT_MS, ApiError, OAuthRelinkStartResponseSchema, ProvisionWorkspaceResponseSchema;
|
|
11469
11479
|
var init_api = __esm({
|
|
11470
11480
|
"src/lib/api.ts"() {
|
|
11471
11481
|
"use strict";
|
|
@@ -11487,6 +11497,9 @@ var init_api = __esm({
|
|
|
11487
11497
|
OAuthRelinkStartResponseSchema = external_exports.object({
|
|
11488
11498
|
relink_url: external_exports.string().url()
|
|
11489
11499
|
});
|
|
11500
|
+
ProvisionWorkspaceResponseSchema = external_exports.object({
|
|
11501
|
+
workspace_repo: external_exports.string()
|
|
11502
|
+
});
|
|
11490
11503
|
}
|
|
11491
11504
|
});
|
|
11492
11505
|
|
|
@@ -11605,12 +11618,6 @@ async function handleMissingGithubToken(bambooSession) {
|
|
|
11605
11618
|
);
|
|
11606
11619
|
return null;
|
|
11607
11620
|
}
|
|
11608
|
-
if (err.status === 410) {
|
|
11609
|
-
spinner.fail(
|
|
11610
|
-
"Your GitHub token expired. Sign in to Bamboo with GitHub again, then re-run."
|
|
11611
|
-
);
|
|
11612
|
-
return null;
|
|
11613
|
-
}
|
|
11614
11621
|
}
|
|
11615
11622
|
continue;
|
|
11616
11623
|
}
|
|
@@ -11735,8 +11742,12 @@ async function runLogin() {
|
|
|
11735
11742
|
if (!polled) process.exit(1);
|
|
11736
11743
|
tokenResp = polled;
|
|
11737
11744
|
} else if (err instanceof ApiError && err.status === 410) {
|
|
11738
|
-
tokenSpinner.
|
|
11739
|
-
|
|
11745
|
+
tokenSpinner.warn(
|
|
11746
|
+
"Your GitHub token expired \u2014 opening browser to refresh authorization\u2026"
|
|
11747
|
+
);
|
|
11748
|
+
const polled = await handleMissingGithubToken(bambooSession);
|
|
11749
|
+
if (!polled) process.exit(1);
|
|
11750
|
+
tokenResp = polled;
|
|
11740
11751
|
} else {
|
|
11741
11752
|
tokenSpinner.fail(`Couldn't fetch GitHub token: ${err.message}`);
|
|
11742
11753
|
process.exit(1);
|
|
@@ -11920,6 +11931,7 @@ var init_exports = {};
|
|
|
11920
11931
|
__export(init_exports, {
|
|
11921
11932
|
WORKSPACE_POLL: () => WORKSPACE_POLL,
|
|
11922
11933
|
pollForWorkspaceReady: () => pollForWorkspaceReady,
|
|
11934
|
+
preProvisionWorkspace: () => preProvisionWorkspace,
|
|
11923
11935
|
runInit: () => runInit,
|
|
11924
11936
|
slugify: () => slugify
|
|
11925
11937
|
});
|
|
@@ -11951,6 +11963,19 @@ async function pollForWorkspaceReady(bambooSession, initial) {
|
|
|
11951
11963
|
function slugify(input) {
|
|
11952
11964
|
return input.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
11953
11965
|
}
|
|
11966
|
+
async function preProvisionWorkspace(bambooSession, call = provisionWorkspace) {
|
|
11967
|
+
try {
|
|
11968
|
+
const result = await call(bambooSession);
|
|
11969
|
+
return { kind: "ok", workspaceRepo: result.workspace_repo };
|
|
11970
|
+
} catch (err) {
|
|
11971
|
+
if (err instanceof ApiError) {
|
|
11972
|
+
if (err.status === 412) return { kind: "fatal_412" };
|
|
11973
|
+
if (err.status === 403) return { kind: "fatal_403" };
|
|
11974
|
+
if (err.status === 401) return { kind: "fatal_401" };
|
|
11975
|
+
}
|
|
11976
|
+
return { kind: "transient", message: err.message };
|
|
11977
|
+
}
|
|
11978
|
+
}
|
|
11954
11979
|
async function runInit() {
|
|
11955
11980
|
const creds = await readCredentials();
|
|
11956
11981
|
if (!creds) {
|
|
@@ -11994,6 +12019,32 @@ async function runInit() {
|
|
|
11994
12019
|
if (initialMembership.workspace_ready && initialMembership.org.workspace_repo) {
|
|
11995
12020
|
membership = initialMembership;
|
|
11996
12021
|
} else {
|
|
12022
|
+
const provisionSpinner = ora("Setting up your workspace\u2026").start();
|
|
12023
|
+
const provisionResult = await preProvisionWorkspace(creds.bamboo_session);
|
|
12024
|
+
if (provisionResult.kind === "ok") {
|
|
12025
|
+
provisionSpinner.succeed(
|
|
12026
|
+
`Workspace repo ready: ${provisionResult.workspaceRepo}`
|
|
12027
|
+
);
|
|
12028
|
+
} else if (provisionResult.kind === "fatal_412") {
|
|
12029
|
+
provisionSpinner.fail(
|
|
12030
|
+
"GitHub isn't connected. Run `bamboo-agents login` first."
|
|
12031
|
+
);
|
|
12032
|
+
process.exit(2);
|
|
12033
|
+
} else if (provisionResult.kind === "fatal_403") {
|
|
12034
|
+
provisionSpinner.fail(
|
|
12035
|
+
"Only org admins can create the workspace. Ask an admin to run `bamboo-agents init` once."
|
|
12036
|
+
);
|
|
12037
|
+
process.exit(2);
|
|
12038
|
+
} else if (provisionResult.kind === "fatal_401") {
|
|
12039
|
+
provisionSpinner.fail(
|
|
12040
|
+
"Your Bamboo session expired. Run `bamboo-agents login` again."
|
|
12041
|
+
);
|
|
12042
|
+
process.exit(1);
|
|
12043
|
+
} else {
|
|
12044
|
+
provisionSpinner.warn(
|
|
12045
|
+
`Couldn't pre-provision workspace (${provisionResult.message}); falling back to polling\u2026`
|
|
12046
|
+
);
|
|
12047
|
+
}
|
|
11997
12048
|
const pollSpinner = ora(
|
|
11998
12049
|
`Waiting for ${initialMembership.org.name}'s workspace to be ready\u2026`
|
|
11999
12050
|
).start();
|
|
@@ -12006,7 +12057,7 @@ async function runInit() {
|
|
|
12006
12057
|
process.exit(1);
|
|
12007
12058
|
}
|
|
12008
12059
|
pollSpinner.fail(
|
|
12009
|
-
`Timed out waiting for ${initialMembership.org.name}'s workspace. If you just connected GitHub, give it another moment and re-run \`bamboo-agents init
|
|
12060
|
+
`Timed out waiting for ${initialMembership.org.name}'s workspace. If you just connected GitHub, give it another moment and re-run \`bamboo-agents init\`.`
|
|
12010
12061
|
);
|
|
12011
12062
|
process.exit(2);
|
|
12012
12063
|
}
|