@project-ajax/cli 0.0.16 → 0.0.18
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/commands/auth.d.ts.map +1 -1
- package/dist/commands/auth.impl.d.ts +8 -2
- package/dist/commands/auth.impl.d.ts.map +1 -1
- package/dist/commands/auth.impl.js +31 -5
- package/dist/commands/auth.js +7 -2
- package/dist/commands/capabilities.impl.d.ts +1 -1
- package/dist/commands/capabilities.impl.d.ts.map +1 -1
- package/dist/commands/capabilities.impl.js +7 -1
- package/dist/commands/delete.d.ts +3 -0
- package/dist/commands/delete.d.ts.map +1 -0
- package/dist/commands/delete.impl.d.ts +7 -0
- package/dist/commands/delete.impl.d.ts.map +1 -0
- package/dist/commands/delete.impl.js +26 -0
- package/dist/commands/delete.impl.test.d.ts +2 -0
- package/dist/commands/delete.impl.test.d.ts.map +1 -0
- package/dist/commands/delete.js +31 -0
- package/dist/commands/deploy.impl.d.ts.map +1 -1
- package/dist/commands/deploy.impl.js +3 -0
- package/dist/commands/deploy.js +1 -1
- package/dist/commands/list.d.ts +3 -0
- package/dist/commands/list.d.ts.map +1 -0
- package/dist/commands/list.impl.d.ts +3 -0
- package/dist/commands/list.impl.d.ts.map +1 -0
- package/dist/commands/list.impl.js +41 -0
- package/dist/commands/list.impl.test.d.ts +2 -0
- package/dist/commands/list.impl.test.d.ts.map +1 -0
- package/dist/commands/list.js +17 -0
- package/dist/commands/oauth.impl.d.ts +1 -1
- package/dist/commands/oauth.impl.d.ts.map +1 -1
- package/dist/commands/oauth.impl.js +11 -3
- package/dist/commands/runs.impl.d.ts +1 -1
- package/dist/commands/runs.impl.d.ts.map +1 -1
- package/dist/commands/runs.impl.js +7 -1
- package/dist/commands/secrets.impl.d.ts +1 -1
- package/dist/commands/secrets.impl.d.ts.map +1 -1
- package/dist/commands/secrets.impl.js +7 -1
- package/dist/commands/utils/testing.d.ts +4 -2
- package/dist/commands/utils/testing.d.ts.map +1 -1
- package/dist/commands/utils/testing.js +23 -10
- package/dist/config.d.ts +121 -7
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +194 -37
- package/dist/flags.d.ts +5 -0
- package/dist/flags.d.ts.map +1 -1
- package/dist/flags.js +34 -1
- package/dist/handler.d.ts.map +1 -1
- package/dist/handler.js +9 -3
- package/dist/routes.d.ts.map +1 -1
- package/dist/routes.js +39 -5
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/commands/auth.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/commands/auth.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,YAAY,wEAyCvB,CAAC"}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import type { GlobalFlags } from "../flags.js";
|
|
2
2
|
import { type HandlerContext } from "../handler.js";
|
|
3
|
-
export declare function runLogin(context: HandlerContext
|
|
4
|
-
|
|
3
|
+
export declare function runLogin(context: HandlerContext, options?: {
|
|
4
|
+
noSetDefault?: boolean;
|
|
5
|
+
}): Promise<void>;
|
|
6
|
+
interface LoginFlags {
|
|
7
|
+
"no-set-default": boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare const login: (this: import("../context.js").LocalContext, flags: GlobalFlags & LoginFlags) => Promise<void>;
|
|
5
10
|
export declare const show: (this: import("../context.js").LocalContext, flags: GlobalFlags) => Promise<void>;
|
|
11
|
+
export {};
|
|
6
12
|
//# sourceMappingURL=auth.impl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.impl.d.ts","sourceRoot":"","sources":["../../src/commands/auth.impl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAgB,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"auth.impl.d.ts","sourceRoot":"","sources":["../../src/commands/auth.impl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAgB,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AAiHlE,wBAAsB,QAAQ,CAC7B,OAAO,EAAE,cAAc,EACvB,OAAO,GAAE;IAAE,YAAY,CAAC,EAAE,OAAO,CAAA;CAAO,iBA+CxC;AAiFD,UAAU,UAAU;IACnB,gBAAgB,EAAE,OAAO,CAAC;CAC1B;AAED,eAAO,MAAM,KAAK,gGAKhB,CAAC;AAEH,eAAO,MAAM,IAAI,mFAGf,CAAC"}
|
|
@@ -32,7 +32,27 @@ async function pollLoginRedeem(baseUrl, sessionId, timeoutMs = 3e5, intervalMs =
|
|
|
32
32
|
}
|
|
33
33
|
return { status: "expired" };
|
|
34
34
|
}
|
|
35
|
-
async function
|
|
35
|
+
async function maybeUpdateDefaultSpace(context, spaceId) {
|
|
36
|
+
const currentDefault = context.config.defaultSpaceId;
|
|
37
|
+
if (currentDefault === null) {
|
|
38
|
+
context.config.setDefaultSpaceId(spaceId);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (currentDefault === spaceId) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (process.stdin.isTTY) {
|
|
45
|
+
const shouldUpdate = await context.io.confirm({
|
|
46
|
+
message: "Set this as your default space?",
|
|
47
|
+
default: false,
|
|
48
|
+
noTTY: "Cannot prompt to update default space in non-TTY mode."
|
|
49
|
+
});
|
|
50
|
+
if (shouldUpdate) {
|
|
51
|
+
context.config.setDefaultSpaceId(spaceId);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
async function runLogin(context, options = {}) {
|
|
36
56
|
const cachedSpaces = context.config.getCachedSpaces();
|
|
37
57
|
if (process.stdin.isTTY && cachedSpaces.length > 0) {
|
|
38
58
|
const choices = [
|
|
@@ -55,6 +75,9 @@ async function runLogin(context) {
|
|
|
55
75
|
const token = await fetchToken(spaceId);
|
|
56
76
|
if (token) {
|
|
57
77
|
context.config.switchToSpace(spaceId);
|
|
78
|
+
if (!options.noSetDefault) {
|
|
79
|
+
await maybeUpdateDefaultSpace(context, spaceId);
|
|
80
|
+
}
|
|
58
81
|
const space = cachedSpaces.find((s) => s.id === spaceId);
|
|
59
82
|
context.io.writeErr(`Switched to space: ${space?.name ?? spaceId}`);
|
|
60
83
|
return;
|
|
@@ -64,9 +87,9 @@ async function runLogin(context) {
|
|
|
64
87
|
);
|
|
65
88
|
}
|
|
66
89
|
}
|
|
67
|
-
await runBrowserLogin(context);
|
|
90
|
+
await runBrowserLogin(context, options);
|
|
68
91
|
}
|
|
69
|
-
async function runBrowserLogin(context) {
|
|
92
|
+
async function runBrowserLogin(context, options = {}) {
|
|
70
93
|
const environment = context.config.environment;
|
|
71
94
|
const baseURL = context.config.baseURL;
|
|
72
95
|
context.io.writeErr("Starting browser login...\n");
|
|
@@ -121,10 +144,13 @@ async function runBrowserLogin(context) {
|
|
|
121
144
|
spaceName: redeemResponse.spaceName,
|
|
122
145
|
cellId: tokenInfo.cellId
|
|
123
146
|
});
|
|
147
|
+
if (!options.noSetDefault) {
|
|
148
|
+
await maybeUpdateDefaultSpace(context, tokenInfo.spaceId);
|
|
149
|
+
}
|
|
124
150
|
context.io.writeErr("Logged in.");
|
|
125
151
|
}
|
|
126
|
-
const login = buildHandler(async function(
|
|
127
|
-
await runLogin(this);
|
|
152
|
+
const login = buildHandler(async function(flags) {
|
|
153
|
+
await runLogin(this, { noSetDefault: flags["no-set-default"] });
|
|
128
154
|
});
|
|
129
155
|
const show = buildHandler(async function() {
|
|
130
156
|
const tokenAndInfo = await this.config.getToken();
|
package/dist/commands/auth.js
CHANGED
|
@@ -7,14 +7,19 @@ const authCommands = buildRouteMap({
|
|
|
7
7
|
routes: {
|
|
8
8
|
login: buildCommand({
|
|
9
9
|
docs: {
|
|
10
|
-
brief: "Login to the
|
|
10
|
+
brief: "Login to the Notion Workers platform via browser authentication",
|
|
11
11
|
fullDescription: `
|
|
12
12
|
Opens a browser window for you to authenticate and select a workspace.
|
|
13
13
|
`.trim()
|
|
14
14
|
},
|
|
15
15
|
parameters: {
|
|
16
16
|
flags: {
|
|
17
|
-
...globalFlags
|
|
17
|
+
...globalFlags,
|
|
18
|
+
"no-set-default": {
|
|
19
|
+
kind: "boolean",
|
|
20
|
+
brief: "Do not update the global default space",
|
|
21
|
+
default: false
|
|
22
|
+
}
|
|
18
23
|
}
|
|
19
24
|
},
|
|
20
25
|
loader: () => import("./auth.impl.js").then((m) => m.login)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type FormatFlags, type GlobalFlags } from "../flags.js";
|
|
2
2
|
export declare const listCapabilities: (this: import("../context.js").LocalContext, flags: GlobalFlags & FormatFlags) => Promise<void>;
|
|
3
3
|
export declare const enableCapability: (this: import("../context.js").LocalContext, flags: GlobalFlags, capabilityKey: string) => Promise<void>;
|
|
4
4
|
export declare const disableCapability: (this: import("../context.js").LocalContext, flags: GlobalFlags, capabilityKey: string) => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capabilities.impl.d.ts","sourceRoot":"","sources":["../../src/commands/capabilities.impl.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"capabilities.impl.d.ts","sourceRoot":"","sources":["../../src/commands/capabilities.impl.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,WAAW,EAAiB,MAAM,aAAa,CAAC;AAGhF,eAAO,MAAM,gBAAgB,iGA+C3B,CAAC;AAEH,eAAO,MAAM,gBAAgB,0GAiC3B,CAAC;AAEH,eAAO,MAAM,iBAAiB,0GAiC5B,CAAC"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Result } from "../api/result.js";
|
|
2
|
+
import { resolveFormat } from "../flags.js";
|
|
2
3
|
import { buildAuthedHandler } from "../handler.js";
|
|
3
4
|
const listCapabilities = buildAuthedHandler(async function(flags) {
|
|
5
|
+
const format = resolveFormat(flags, this.process);
|
|
4
6
|
const { workerId } = this.config;
|
|
5
7
|
if (!workerId) {
|
|
6
8
|
throw new Error(
|
|
@@ -12,6 +14,10 @@ const listCapabilities = buildAuthedHandler(async function(flags) {
|
|
|
12
14
|
if (Result.isSuccess(result)) {
|
|
13
15
|
this.process.stderr.write("OK\n\n");
|
|
14
16
|
const data = Result.unwrap(result);
|
|
17
|
+
if (format === "json") {
|
|
18
|
+
this.io.writeOut(JSON.stringify(data.capabilities, null, 2));
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
15
21
|
if (data.capabilities.length === 0) {
|
|
16
22
|
this.io.writeErr("No capabilities found for this worker.");
|
|
17
23
|
} else {
|
|
@@ -21,7 +27,7 @@ const listCapabilities = buildAuthedHandler(async function(flags) {
|
|
|
21
27
|
capability.key,
|
|
22
28
|
capability._tag
|
|
23
29
|
]),
|
|
24
|
-
plain:
|
|
30
|
+
plain: format === "plain"
|
|
25
31
|
});
|
|
26
32
|
}
|
|
27
33
|
} else {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../src/commands/delete.ts"],"names":[],"mappings":";AAGA,wBAyBG"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { GlobalFlags } from "../flags.js";
|
|
2
|
+
interface DeleteFlags {
|
|
3
|
+
yes: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare const deleteWorker: (this: import("../context.js").LocalContext, flags: GlobalFlags & DeleteFlags, workerId: string) => Promise<void>;
|
|
6
|
+
export {};
|
|
7
|
+
//# sourceMappingURL=delete.impl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete.impl.d.ts","sourceRoot":"","sources":["../../src/commands/delete.impl.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C,UAAU,WAAW;IACpB,GAAG,EAAE,OAAO,CAAC;CACb;AAED,eAAO,MAAM,YAAY,mHA2BvB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Result } from "../api/result.js";
|
|
2
|
+
import { buildAuthedHandler } from "../handler.js";
|
|
3
|
+
const deleteWorker = buildAuthedHandler(async function(flags, workerId) {
|
|
4
|
+
if (!flags.yes) {
|
|
5
|
+
const confirmed = await this.io.confirm({
|
|
6
|
+
message: `Are you sure you want to delete worker "${workerId}"?`,
|
|
7
|
+
noTTY: `Cannot delete worker "${workerId}" without confirmation. Use --yes to skip confirmation.`
|
|
8
|
+
});
|
|
9
|
+
if (!confirmed) {
|
|
10
|
+
this.io.writeErr("Aborted.");
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
this.io.writeErr(`Deleting worker "${workerId}"...`);
|
|
15
|
+
const result = await this.apiClient.deleteWorker(workerId);
|
|
16
|
+
if (Result.isSuccess(result)) {
|
|
17
|
+
this.io.writeErr(`\u2713 Successfully deleted worker "${workerId}"`);
|
|
18
|
+
} else {
|
|
19
|
+
this.io.writeErr(`\u2717 Failed to delete worker "${workerId}"`);
|
|
20
|
+
this.io.writeErr(`\u2717 ${result.error.message}`);
|
|
21
|
+
throw new Error(result.error.message);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
export {
|
|
25
|
+
deleteWorker
|
|
26
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete.impl.test.d.ts","sourceRoot":"","sources":["../../src/commands/delete.impl.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { buildCommand } from "@stricli/core";
|
|
2
|
+
import { globalFlags } from "../flags.js";
|
|
3
|
+
var delete_default = buildCommand({
|
|
4
|
+
docs: {
|
|
5
|
+
brief: "Delete a worker"
|
|
6
|
+
},
|
|
7
|
+
parameters: {
|
|
8
|
+
positional: {
|
|
9
|
+
kind: "tuple",
|
|
10
|
+
parameters: [
|
|
11
|
+
{
|
|
12
|
+
brief: "The worker ID to delete",
|
|
13
|
+
parse: String,
|
|
14
|
+
placeholder: "workerId"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
},
|
|
18
|
+
flags: {
|
|
19
|
+
...globalFlags,
|
|
20
|
+
yes: {
|
|
21
|
+
kind: "boolean",
|
|
22
|
+
brief: "Skip confirmation prompt",
|
|
23
|
+
default: false
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
loader: () => import("./delete.impl.js").then((m) => m.deleteWorker)
|
|
28
|
+
});
|
|
29
|
+
export {
|
|
30
|
+
delete_default as default
|
|
31
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy.impl.d.ts","sourceRoot":"","sources":["../../src/commands/deploy.impl.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"deploy.impl.d.ts","sourceRoot":"","sources":["../../src/commands/deploy.impl.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAI/C,UAAU,WAAW;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;CACd;AAED,eAAO,MAAM,MAAM,iGAqFjB,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import path from "node:path";
|
|
1
2
|
import { ApiClient } from "../api/client.js";
|
|
2
3
|
import { Result } from "../api/result.js";
|
|
3
4
|
import { deployWorker } from "../deploy.js";
|
|
@@ -35,12 +36,14 @@ const deploy = buildHandler(async function(flags) {
|
|
|
35
36
|
environment
|
|
36
37
|
});
|
|
37
38
|
} else {
|
|
39
|
+
const defaultName = path.basename(workerPath);
|
|
38
40
|
let validatedName;
|
|
39
41
|
if (name) {
|
|
40
42
|
validatedName = name;
|
|
41
43
|
} else {
|
|
42
44
|
const nameInput = await this.io.input({
|
|
43
45
|
message: "Enter a name for the worker",
|
|
46
|
+
default: defaultName,
|
|
44
47
|
required: true,
|
|
45
48
|
noTTY: "Provide a name for the worker with --name"
|
|
46
49
|
});
|
package/dist/commands/deploy.js
CHANGED
|
@@ -2,7 +2,7 @@ import { buildCommand } from "@stricli/core";
|
|
|
2
2
|
import { globalFlags } from "../flags.js";
|
|
3
3
|
var deploy_default = buildCommand({
|
|
4
4
|
docs: {
|
|
5
|
-
brief: "Deploy a worker to the
|
|
5
|
+
brief: "Deploy a worker to the Notion Workers platform"
|
|
6
6
|
},
|
|
7
7
|
parameters: {
|
|
8
8
|
flags: {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../src/commands/list.ts"],"names":[],"mappings":";AAGA,wBAaG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.impl.d.ts","sourceRoot":"","sources":["../../src/commands/list.impl.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,WAAW,EAAiB,MAAM,aAAa,CAAC;AAG9D,eAAO,MAAM,WAAW,uHA6CtB,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Result } from "../api/result.js";
|
|
2
|
+
import { resolveFormat } from "../flags.js";
|
|
3
|
+
import { buildAuthedHandler } from "../handler.js";
|
|
4
|
+
const listWorkers = buildAuthedHandler(async function(flags) {
|
|
5
|
+
const format = resolveFormat(flags, this.process);
|
|
6
|
+
this.process.stderr.write("Fetching workers...");
|
|
7
|
+
const result = await this.apiClient.listWorkers();
|
|
8
|
+
if (Result.isSuccess(result)) {
|
|
9
|
+
this.process.stderr.write("OK\n\n");
|
|
10
|
+
const data = Result.unwrap(result);
|
|
11
|
+
if (format === "json") {
|
|
12
|
+
this.io.writeOut(JSON.stringify(data.workers, null, 2));
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
if (data.workers.length === 0) {
|
|
16
|
+
this.io.writeErr("No workers found for this space.");
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
this.io.writeTableOut({
|
|
20
|
+
headers: ["Worker ID", "Name", "Created At", "Updated At"],
|
|
21
|
+
rows: data.workers.map((worker) => [
|
|
22
|
+
worker.workerId,
|
|
23
|
+
worker.name,
|
|
24
|
+
worker.createdAt,
|
|
25
|
+
worker.updatedAt
|
|
26
|
+
]),
|
|
27
|
+
plain: format === "plain"
|
|
28
|
+
});
|
|
29
|
+
} else {
|
|
30
|
+
this.process.stderr.write("ERROR\n\n");
|
|
31
|
+
if (result.error.validationError) {
|
|
32
|
+
this.io.writeErr(`\u2717 ${result.error.validationError.debugMessage}`);
|
|
33
|
+
throw new Error(result.error.validationError.debugMessage);
|
|
34
|
+
}
|
|
35
|
+
this.io.writeErr(`\u2717 ${result.error.message}`);
|
|
36
|
+
throw new Error(result.error.message);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
export {
|
|
40
|
+
listWorkers
|
|
41
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.impl.test.d.ts","sourceRoot":"","sources":["../../src/commands/list.impl.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { buildCommand } from "@stricli/core";
|
|
2
|
+
import { formatFlags, globalFlags } from "../flags.js";
|
|
3
|
+
var list_default = buildCommand({
|
|
4
|
+
docs: {
|
|
5
|
+
brief: "List all workers in the current space"
|
|
6
|
+
},
|
|
7
|
+
parameters: {
|
|
8
|
+
flags: {
|
|
9
|
+
...globalFlags,
|
|
10
|
+
...formatFlags
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
loader: () => import("./list.impl.js").then((m) => m.listWorkers)
|
|
14
|
+
});
|
|
15
|
+
export {
|
|
16
|
+
list_default as default
|
|
17
|
+
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type FormatFlags, type GlobalFlags } from "../flags.js";
|
|
2
2
|
export declare const startOauth: (this: import("../context.js").LocalContext, flags: GlobalFlags & FormatFlags, capabilityKey: string | undefined) => Promise<void>;
|
|
3
3
|
//# sourceMappingURL=oauth.impl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth.impl.d.ts","sourceRoot":"","sources":["../../src/commands/oauth.impl.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"oauth.impl.d.ts","sourceRoot":"","sources":["../../src/commands/oauth.impl.ts"],"names":[],"mappings":"AAEA,OAAO,EACN,KAAK,WAAW,EAChB,KAAK,WAAW,EAGhB,MAAM,aAAa,CAAC;AAIrB,eAAO,MAAM,UAAU,oIAgFrB,CAAC"}
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import { Result } from "../api/result.js";
|
|
2
|
+
import {
|
|
3
|
+
resolveFormat
|
|
4
|
+
} from "../flags.js";
|
|
2
5
|
import { buildAuthedHandler } from "../handler.js";
|
|
3
6
|
import { openBrowserUrl } from "../utils/openUrl.js";
|
|
4
7
|
const startOauth = buildAuthedHandler(async function(flags, capabilityKey) {
|
|
5
8
|
const workerId = requireWorkerId(this);
|
|
9
|
+
const format = resolveFormat(flags, this.process);
|
|
6
10
|
if (!capabilityKey) {
|
|
7
11
|
const oauthCapabilityKeys = await fetchOauthCapabilityKeys(
|
|
8
12
|
this,
|
|
9
13
|
workerId,
|
|
10
|
-
|
|
14
|
+
format
|
|
11
15
|
);
|
|
12
16
|
if (oauthCapabilityKeys.length === 0) {
|
|
13
17
|
this.process.exitCode = 1;
|
|
@@ -78,7 +82,7 @@ function reportApiError(context, error, action) {
|
|
|
78
82
|
context.io.writeErr(`\u2717 ${error.message}`);
|
|
79
83
|
throw new Error(error.message);
|
|
80
84
|
}
|
|
81
|
-
async function fetchOauthCapabilityKeys(context, workerId,
|
|
85
|
+
async function fetchOauthCapabilityKeys(context, workerId, format) {
|
|
82
86
|
context.process.stderr.write("Fetching OAuth capabilities...");
|
|
83
87
|
const capabilitiesResult = await context.apiClient.listCapabilities(workerId);
|
|
84
88
|
if (Result.isFail(capabilitiesResult)) {
|
|
@@ -96,11 +100,15 @@ async function fetchOauthCapabilityKeys(context, workerId, plain) {
|
|
|
96
100
|
);
|
|
97
101
|
return [];
|
|
98
102
|
}
|
|
103
|
+
if (format === "json") {
|
|
104
|
+
context.io.writeOut(JSON.stringify(oauthCaps, null, 2));
|
|
105
|
+
return oauthCaps.map((cap) => cap.key);
|
|
106
|
+
}
|
|
99
107
|
context.io.writeErr("OAuth capabilities:");
|
|
100
108
|
context.io.writeTableErr({
|
|
101
109
|
headers: ["Key"],
|
|
102
110
|
rows: oauthCaps.map((cap) => [cap.key]),
|
|
103
|
-
plain
|
|
111
|
+
plain: format === "plain"
|
|
104
112
|
});
|
|
105
113
|
context.io.writeErr("");
|
|
106
114
|
return oauthCaps.map((cap) => cap.key);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type FormatFlags, type GlobalFlags } from "../flags.js";
|
|
2
2
|
export declare const listRuns: (this: import("../context.js").LocalContext, flags: GlobalFlags & FormatFlags) => Promise<void>;
|
|
3
3
|
export declare const getRunLogs: (this: import("../context.js").LocalContext, flags: GlobalFlags, runId: string) => Promise<void>;
|
|
4
4
|
//# sourceMappingURL=runs.impl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runs.impl.d.ts","sourceRoot":"","sources":["../../src/commands/runs.impl.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"runs.impl.d.ts","sourceRoot":"","sources":["../../src/commands/runs.impl.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,WAAW,EAAiB,MAAM,aAAa,CAAC;AAGhF,eAAO,MAAM,QAAQ,iGAgDnB,CAAC;AAEH,eAAO,MAAM,UAAU,kGAqCrB,CAAC"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Result } from "../api/result.js";
|
|
2
|
+
import { resolveFormat } from "../flags.js";
|
|
2
3
|
import { buildAuthedHandler } from "../handler.js";
|
|
3
4
|
const listRuns = buildAuthedHandler(async function(flags) {
|
|
5
|
+
const format = resolveFormat(flags, this.process);
|
|
4
6
|
const { workerId } = this.config;
|
|
5
7
|
if (!workerId) {
|
|
6
8
|
throw new Error(
|
|
@@ -12,6 +14,10 @@ const listRuns = buildAuthedHandler(async function(flags) {
|
|
|
12
14
|
if (Result.isSuccess(result)) {
|
|
13
15
|
this.process.stderr.write("OK\n\n");
|
|
14
16
|
const data = Result.unwrap(result);
|
|
17
|
+
if (format === "json") {
|
|
18
|
+
this.io.writeOut(JSON.stringify(data.runs, null, 2));
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
15
21
|
if (data.runs.length === 0) {
|
|
16
22
|
this.io.writeErr("No runs found for this worker.");
|
|
17
23
|
} else {
|
|
@@ -24,7 +30,7 @@ const listRuns = buildAuthedHandler(async function(flags) {
|
|
|
24
30
|
run.endedAt,
|
|
25
31
|
run.exitCode
|
|
26
32
|
]),
|
|
27
|
-
plain:
|
|
33
|
+
plain: format === "plain"
|
|
28
34
|
});
|
|
29
35
|
}
|
|
30
36
|
} else {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type FormatFlags, type GlobalFlags } from "../flags.js";
|
|
2
2
|
export declare const setSecrets: (this: import("../context.js").LocalContext, flags: GlobalFlags, ...args: string[]) => Promise<void>;
|
|
3
3
|
export declare const listSecrets: (this: import("../context.js").LocalContext, flags: GlobalFlags & FormatFlags) => Promise<void>;
|
|
4
4
|
export declare const removeSecret: (this: import("../context.js").LocalContext, flags: GlobalFlags, key: string) => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secrets.impl.d.ts","sourceRoot":"","sources":["../../src/commands/secrets.impl.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"secrets.impl.d.ts","sourceRoot":"","sources":["../../src/commands/secrets.impl.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,WAAW,EAAiB,MAAM,aAAa,CAAC;AAIhF,eAAO,MAAM,UAAU,sGA0BrB,CAAC;AAEH,eAAO,MAAM,WAAW,iGAuCtB,CAAC;AAEH,eAAO,MAAM,YAAY,gGAwBvB,CAAC;AAQH;;GAEG;AACH,wBAAgB,eAAe,CAC9B,IAAI,EAAE,SAAS,MAAM,EAAE,GACrB,KAAK,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAoBvC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Result } from "../api/result.js";
|
|
2
|
+
import { resolveFormat } from "../flags.js";
|
|
2
3
|
import { buildAuthedHandler } from "../handler.js";
|
|
3
4
|
import { pluralize } from "../utils/string.js";
|
|
4
5
|
const setSecrets = buildAuthedHandler(async function(_flags, ...args) {
|
|
@@ -22,6 +23,7 @@ const setSecrets = buildAuthedHandler(async function(_flags, ...args) {
|
|
|
22
23
|
}
|
|
23
24
|
});
|
|
24
25
|
const listSecrets = buildAuthedHandler(async function(flags) {
|
|
26
|
+
const format = resolveFormat(flags, this.process);
|
|
25
27
|
const { workerId } = this.config;
|
|
26
28
|
if (!workerId) {
|
|
27
29
|
throw new Error(
|
|
@@ -33,13 +35,17 @@ const listSecrets = buildAuthedHandler(async function(flags) {
|
|
|
33
35
|
if (Result.isSuccess(result)) {
|
|
34
36
|
this.process.stderr.write("OK\n\n");
|
|
35
37
|
const data = Result.unwrap(result);
|
|
38
|
+
if (format === "json") {
|
|
39
|
+
this.io.writeOut(JSON.stringify(data.secrets, null, 2));
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
36
42
|
if (data.secrets.length === 0) {
|
|
37
43
|
this.io.writeErr("No secrets for this worker.");
|
|
38
44
|
} else {
|
|
39
45
|
this.io.writeTableOut({
|
|
40
46
|
headers: ["Key", "Created At"],
|
|
41
47
|
rows: data.secrets.map((secret) => [secret.key, secret.createdAt]),
|
|
42
|
-
plain:
|
|
48
|
+
plain: format === "plain"
|
|
43
49
|
});
|
|
44
50
|
}
|
|
45
51
|
} else {
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import { Config, type LocalConfig, type SpaceCache } from "../../config.js";
|
|
1
|
+
import { Config, type GlobalConfig, type LocalConfig, type SpaceCache } from "../../config.js";
|
|
2
2
|
import type { LocalContext } from "../../context.js";
|
|
3
3
|
import type { GlobalFlags } from "../../flags.js";
|
|
4
4
|
import type { TokenInfo } from "../../token.js";
|
|
5
5
|
export declare const baseFlags: GlobalFlags;
|
|
6
6
|
export declare function preventConfigResolution(): void;
|
|
7
7
|
export declare function createAndLoadConfig(args?: {
|
|
8
|
-
|
|
8
|
+
userConfig?: GlobalConfig;
|
|
9
|
+
spaceCache?: SpaceCache;
|
|
9
10
|
localConfig?: LocalConfig;
|
|
10
11
|
env?: Partial<NodeJS.ProcessEnv>;
|
|
11
12
|
flags?: Partial<GlobalFlags>;
|
|
13
|
+
spaceOverride?: string | null;
|
|
12
14
|
}): Promise<Config>;
|
|
13
15
|
export declare function createBaseContext(): LocalContext;
|
|
14
16
|
export declare function cleanupTmpDirectories(): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../../../src/commands/utils/testing.ts"],"names":[],"mappings":"AAOA,OAAO,
|
|
1
|
+
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../../../src/commands/utils/testing.ts"],"names":[],"mappings":"AAOA,OAAO,EACN,MAAM,EACN,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,eAAO,MAAM,SAAS,EAAE,WAEvB,CAAC;AAEF,wBAAgB,uBAAuB,SAItC;AAED,wBAAsB,mBAAmB,CACxC,IAAI,GAAE;IACL,UAAU,CAAC,EAAE,YAAY,CAAC;IAC1B,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,GAAG,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACjC,KAAK,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;IAC7B,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB,GACJ,OAAO,CAAC,MAAM,CAAC,CAyBjB;AAED,wBAAgB,iBAAiB,IAAI,YAAY,CAQhD;AAID,wBAAsB,qBAAqB,kBAU1C;AAmCD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC9B,IAAI,GAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAO,EAChD,IAAI,GAAE;IAAE,IAAI,CAAC,EAAE,OAAO,CAAA;CAAoB,GACxC,CAAC,MAAM,EAAE,SAAS,CAAC,CAuBrB"}
|
|
@@ -5,29 +5,36 @@ import { tmpdir } from "node:os";
|
|
|
5
5
|
import * as path from "node:path";
|
|
6
6
|
import { getPassword } from "cross-keychain";
|
|
7
7
|
import { vi } from "vitest";
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
Config
|
|
10
|
+
} from "../../config.js";
|
|
9
11
|
import { IO } from "../../io.js";
|
|
10
12
|
const baseFlags = {
|
|
11
13
|
debug: false
|
|
12
14
|
};
|
|
13
15
|
function preventConfigResolution() {
|
|
16
|
+
vi.spyOn(Config, "resolveGlobalConfigPath").mockImplementation(() => "");
|
|
14
17
|
vi.spyOn(Config, "resolveSpaceCachePath").mockImplementation(() => "");
|
|
15
18
|
vi.spyOn(Config, "resolveLocalConfigPath").mockImplementation(() => "");
|
|
16
19
|
}
|
|
17
20
|
async function createAndLoadConfig(args = {}) {
|
|
18
|
-
const
|
|
21
|
+
const userConfig = args.userConfig ?? Config.emptyGlobalConfig;
|
|
22
|
+
const spaceCache = args.spaceCache ?? Config.emptySpaceCache;
|
|
19
23
|
const localConfig = args.localConfig ?? Config.emptyLocalConfig;
|
|
20
|
-
const {
|
|
21
|
-
|
|
24
|
+
const { globalConfigPath, spaceCachePath, localPath } = await createConfigFiles({
|
|
25
|
+
userConfig,
|
|
26
|
+
spaceCache,
|
|
22
27
|
localConfig
|
|
23
28
|
});
|
|
24
29
|
const config = Config.load({
|
|
25
|
-
|
|
30
|
+
globalConfigPath,
|
|
31
|
+
spaceCachePath,
|
|
26
32
|
localPath,
|
|
27
33
|
env: args.env ?? {},
|
|
28
34
|
flags: {
|
|
29
35
|
...baseFlags,
|
|
30
|
-
...args.flags ?? {}
|
|
36
|
+
...args.flags ?? {},
|
|
37
|
+
...args.spaceOverride ? { space: args.spaceOverride } : {}
|
|
31
38
|
}
|
|
32
39
|
});
|
|
33
40
|
return config;
|
|
@@ -55,11 +62,17 @@ async function cleanupTmpDirectories() {
|
|
|
55
62
|
async function createConfigFiles(args) {
|
|
56
63
|
const dir = await fsp.mkdtemp(path.join(tmpdir(), "cmd-test-"));
|
|
57
64
|
tmpDirectories.push(dir);
|
|
58
|
-
const
|
|
65
|
+
const globalConfigPath = path.join(dir, "config.json");
|
|
66
|
+
const spaceCachePath = path.join(dir, "spaces.json");
|
|
59
67
|
const localPath = path.join(dir, "local.json");
|
|
60
68
|
await fsp.writeFile(
|
|
61
|
-
|
|
62
|
-
JSON.stringify(args.
|
|
69
|
+
globalConfigPath,
|
|
70
|
+
JSON.stringify(args.userConfig, null, 2),
|
|
71
|
+
"utf-8"
|
|
72
|
+
);
|
|
73
|
+
await fsp.writeFile(
|
|
74
|
+
spaceCachePath,
|
|
75
|
+
JSON.stringify(args.spaceCache, null, 2),
|
|
63
76
|
"utf-8"
|
|
64
77
|
);
|
|
65
78
|
await fsp.writeFile(
|
|
@@ -67,7 +80,7 @@ async function createConfigFiles(args) {
|
|
|
67
80
|
JSON.stringify(args.localConfig, null, 2),
|
|
68
81
|
"utf-8"
|
|
69
82
|
);
|
|
70
|
-
return {
|
|
83
|
+
return { globalConfigPath, spaceCachePath, localPath };
|
|
71
84
|
}
|
|
72
85
|
function generateV1Token(args = {}, opts = { mock: false }) {
|
|
73
86
|
const payload = {
|