@project-ajax/sdk 0.0.59 → 0.0.61
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/builder.d.ts +6 -1
- package/dist/builder.d.ts.map +1 -1
- package/dist/builder.js +4 -0
- package/dist/capabilities/sync.d.ts +10 -3
- package/dist/capabilities/sync.d.ts.map +1 -1
- package/dist/schema.d.ts +7 -1
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +4 -0
- package/dist/types.d.ts +13 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +3 -11
- package/src/builder.ts +15 -1
- package/src/capabilities/sync.ts +18 -3
- package/src/schema.ts +11 -2
- package/src/types.ts +15 -0
- package/dist/cli/api/client.d.ts +0 -212
- package/dist/cli/api/client.d.ts.map +0 -1
- package/dist/cli/api/client.js +0 -330
- package/dist/cli/api/result.d.ts +0 -43
- package/dist/cli/api/result.d.ts.map +0 -1
- package/dist/cli/api/result.js +0 -43
- package/dist/cli/bin/cli.d.ts +0 -3
- package/dist/cli/bin/cli.d.ts.map +0 -1
- package/dist/cli/bin/cli.js +0 -5
- package/dist/cli/commands/auth.d.ts +0 -2
- package/dist/cli/commands/auth.d.ts.map +0 -1
- package/dist/cli/commands/auth.impl.d.ts +0 -5
- package/dist/cli/commands/auth.impl.d.ts.map +0 -1
- package/dist/cli/commands/auth.impl.js +0 -45
- package/dist/cli/commands/auth.impl.test.d.ts +0 -2
- package/dist/cli/commands/auth.impl.test.d.ts.map +0 -1
- package/dist/cli/commands/auth.js +0 -56
- package/dist/cli/commands/bundle.d.ts +0 -2
- package/dist/cli/commands/bundle.d.ts.map +0 -1
- package/dist/cli/commands/bundle.impl.d.ts +0 -2
- package/dist/cli/commands/bundle.impl.d.ts.map +0 -1
- package/dist/cli/commands/bundle.impl.js +0 -21
- package/dist/cli/commands/bundle.impl.test.d.ts +0 -2
- package/dist/cli/commands/bundle.impl.test.d.ts.map +0 -1
- package/dist/cli/commands/bundle.js +0 -23
- package/dist/cli/commands/capabilities.d.ts +0 -2
- package/dist/cli/commands/capabilities.d.ts.map +0 -1
- package/dist/cli/commands/capabilities.impl.d.ts +0 -3
- package/dist/cli/commands/capabilities.impl.d.ts.map +0 -1
- package/dist/cli/commands/capabilities.impl.js +0 -40
- package/dist/cli/commands/capabilities.js +0 -24
- package/dist/cli/commands/connect.d.ts +0 -2
- package/dist/cli/commands/connect.d.ts.map +0 -1
- package/dist/cli/commands/connect.impl.d.ts +0 -6
- package/dist/cli/commands/connect.impl.d.ts.map +0 -1
- package/dist/cli/commands/connect.impl.js +0 -116
- package/dist/cli/commands/connect.js +0 -78
- package/dist/cli/commands/deploy.d.ts +0 -3
- package/dist/cli/commands/deploy.d.ts.map +0 -1
- package/dist/cli/commands/deploy.impl.d.ts +0 -6
- package/dist/cli/commands/deploy.impl.d.ts.map +0 -1
- package/dist/cli/commands/deploy.impl.js +0 -60
- package/dist/cli/commands/deploy.impl.test.d.ts +0 -2
- package/dist/cli/commands/deploy.impl.test.d.ts.map +0 -1
- package/dist/cli/commands/deploy.js +0 -22
- package/dist/cli/commands/env.d.ts +0 -2
- package/dist/cli/commands/env.d.ts.map +0 -1
- package/dist/cli/commands/env.impl.d.ts +0 -11
- package/dist/cli/commands/env.impl.d.ts.map +0 -1
- package/dist/cli/commands/env.impl.js +0 -62
- package/dist/cli/commands/env.js +0 -39
- package/dist/cli/commands/exec.d.ts +0 -3
- package/dist/cli/commands/exec.d.ts.map +0 -1
- package/dist/cli/commands/exec.impl.d.ts +0 -7
- package/dist/cli/commands/exec.impl.d.ts.map +0 -1
- package/dist/cli/commands/exec.impl.js +0 -123
- package/dist/cli/commands/exec.js +0 -30
- package/dist/cli/commands/runs.d.ts +0 -2
- package/dist/cli/commands/runs.d.ts.map +0 -1
- package/dist/cli/commands/runs.impl.d.ts +0 -4
- package/dist/cli/commands/runs.impl.d.ts.map +0 -1
- package/dist/cli/commands/runs.impl.js +0 -71
- package/dist/cli/commands/runs.js +0 -45
- package/dist/cli/commands/secrets.d.ts +0 -2
- package/dist/cli/commands/secrets.d.ts.map +0 -1
- package/dist/cli/commands/secrets.impl.d.ts +0 -5
- package/dist/cli/commands/secrets.impl.d.ts.map +0 -1
- package/dist/cli/commands/secrets.impl.js +0 -99
- package/dist/cli/commands/secrets.js +0 -64
- package/dist/cli/commands/utils/testing.d.ts +0 -13
- package/dist/cli/commands/utils/testing.d.ts.map +0 -1
- package/dist/cli/commands/utils/testing.js +0 -58
- package/dist/cli/config.d.ts +0 -63
- package/dist/cli/config.d.ts.map +0 -1
- package/dist/cli/config.js +0 -194
- package/dist/cli/config.test.d.ts +0 -2
- package/dist/cli/config.test.d.ts.map +0 -1
- package/dist/cli/context.d.ts +0 -15
- package/dist/cli/context.d.ts.map +0 -1
- package/dist/cli/context.js +0 -16
- package/dist/cli/deploy.d.ts +0 -37
- package/dist/cli/deploy.d.ts.map +0 -1
- package/dist/cli/deploy.js +0 -100
- package/dist/cli/flags.d.ts +0 -21
- package/dist/cli/flags.d.ts.map +0 -1
- package/dist/cli/flags.js +0 -49
- package/dist/cli/handler.d.ts +0 -14
- package/dist/cli/handler.d.ts.map +0 -1
- package/dist/cli/handler.js +0 -32
- package/dist/cli/io.d.ts +0 -55
- package/dist/cli/io.d.ts.map +0 -1
- package/dist/cli/io.js +0 -96
- package/dist/cli/routes.d.ts +0 -2
- package/dist/cli/routes.d.ts.map +0 -1
- package/dist/cli/routes.js +0 -62
- package/dist/cli/utils/array.d.ts +0 -2
- package/dist/cli/utils/array.d.ts.map +0 -1
- package/dist/cli/utils/array.js +0 -10
- package/dist/cli/utils/openUrl.d.ts +0 -4
- package/dist/cli/utils/openUrl.d.ts.map +0 -1
- package/dist/cli/utils/openUrl.js +0 -43
- package/dist/cli/utils/string.d.ts +0 -2
- package/dist/cli/utils/string.d.ts.map +0 -1
- package/dist/cli/utils/string.js +0 -12
- package/src/cli/api/client.ts +0 -628
- package/src/cli/api/result.ts +0 -71
- package/src/cli/bin/cli.ts +0 -7
- package/src/cli/commands/.cursor/rules/testing-commands.mdc +0 -212
- package/src/cli/commands/auth.impl.test.ts +0 -228
- package/src/cli/commands/auth.impl.ts +0 -56
- package/src/cli/commands/auth.ts +0 -63
- package/src/cli/commands/bundle.impl.test.ts +0 -143
- package/src/cli/commands/bundle.impl.ts +0 -21
- package/src/cli/commands/bundle.ts +0 -23
- package/src/cli/commands/capabilities.impl.ts +0 -47
- package/src/cli/commands/capabilities.ts +0 -25
- package/src/cli/commands/connect.impl.ts +0 -149
- package/src/cli/commands/connect.ts +0 -80
- package/src/cli/commands/deploy.impl.test.ts +0 -254
- package/src/cli/commands/deploy.impl.ts +0 -73
- package/src/cli/commands/deploy.ts +0 -22
- package/src/cli/commands/env.impl.ts +0 -88
- package/src/cli/commands/env.ts +0 -38
- package/src/cli/commands/exec.impl.ts +0 -171
- package/src/cli/commands/exec.ts +0 -32
- package/src/cli/commands/runs.impl.ts +0 -87
- package/src/cli/commands/runs.ts +0 -49
- package/src/cli/commands/secrets.impl.ts +0 -130
- package/src/cli/commands/secrets.ts +0 -73
- package/src/cli/commands/utils/testing.ts +0 -66
- package/src/cli/config.test.ts +0 -108
- package/src/cli/config.ts +0 -265
- package/src/cli/context.ts +0 -26
- package/src/cli/deploy.ts +0 -190
- package/src/cli/flags.ts +0 -72
- package/src/cli/handler.ts +0 -68
- package/src/cli/io.ts +0 -132
- package/src/cli/routes.ts +0 -61
- package/src/cli/utils/array.ts +0 -7
- package/src/cli/utils/openUrl.ts +0 -53
- package/src/cli/utils/string.ts +0 -9
package/src/cli/flags.ts
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import type { TypedFlagParameter } from "@stricli/core";
|
|
2
|
-
import { type Environment, Environments } from "./config.js";
|
|
3
|
-
import type { LocalContext } from "./context.js";
|
|
4
|
-
|
|
5
|
-
export interface GlobalFlags {
|
|
6
|
-
config?: string;
|
|
7
|
-
debug: boolean;
|
|
8
|
-
env?: Environment;
|
|
9
|
-
"base-url"?: string;
|
|
10
|
-
token?: string;
|
|
11
|
-
"worker-id"?: string;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export const globalFlags: {
|
|
15
|
-
[K in keyof Required<GlobalFlags>]: TypedFlagParameter<
|
|
16
|
-
GlobalFlags[K],
|
|
17
|
-
LocalContext
|
|
18
|
-
>;
|
|
19
|
-
} = {
|
|
20
|
-
config: {
|
|
21
|
-
kind: "parsed",
|
|
22
|
-
parse: String,
|
|
23
|
-
brief: "The path to the config file to use",
|
|
24
|
-
optional: true,
|
|
25
|
-
},
|
|
26
|
-
debug: {
|
|
27
|
-
kind: "boolean",
|
|
28
|
-
brief: "Enable debug logging",
|
|
29
|
-
default: false,
|
|
30
|
-
},
|
|
31
|
-
env: {
|
|
32
|
-
kind: "enum",
|
|
33
|
-
values: Environments,
|
|
34
|
-
brief: "The environment to use for the command",
|
|
35
|
-
optional: true,
|
|
36
|
-
},
|
|
37
|
-
"base-url": {
|
|
38
|
-
kind: "parsed",
|
|
39
|
-
parse: String,
|
|
40
|
-
brief: "The base URL to use for all API requests",
|
|
41
|
-
optional: true,
|
|
42
|
-
},
|
|
43
|
-
token: {
|
|
44
|
-
kind: "parsed",
|
|
45
|
-
parse: String,
|
|
46
|
-
brief: "The token to use for authentication",
|
|
47
|
-
optional: true,
|
|
48
|
-
},
|
|
49
|
-
"worker-id": {
|
|
50
|
-
kind: "parsed",
|
|
51
|
-
parse: String,
|
|
52
|
-
brief: "The ID of the worker to use for the command",
|
|
53
|
-
optional: true,
|
|
54
|
-
},
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
export interface FormatFlags {
|
|
58
|
-
plain: boolean;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export const formatFlags: {
|
|
62
|
-
[K in keyof Required<FormatFlags>]: TypedFlagParameter<
|
|
63
|
-
FormatFlags[K],
|
|
64
|
-
LocalContext
|
|
65
|
-
>;
|
|
66
|
-
} = {
|
|
67
|
-
plain: {
|
|
68
|
-
kind: "boolean",
|
|
69
|
-
brief: "Output the results in plain text format",
|
|
70
|
-
default: false,
|
|
71
|
-
},
|
|
72
|
-
};
|
package/src/cli/handler.ts
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import type { BaseArgs } from "@stricli/core";
|
|
2
|
-
import { ApiClient } from "./api/client.js";
|
|
3
|
-
import { Config } from "./config.js";
|
|
4
|
-
import type { LocalContext } from "./context.js";
|
|
5
|
-
import type { GlobalFlags } from "./flags.js";
|
|
6
|
-
|
|
7
|
-
export interface HandlerContext extends LocalContext {
|
|
8
|
-
config: Config;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface AuthedContext extends HandlerContext {
|
|
12
|
-
apiClient: ApiClient;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function buildHandler<const FLAGS, const ARGS extends BaseArgs = []>(
|
|
16
|
-
handler: (
|
|
17
|
-
this: HandlerContext,
|
|
18
|
-
flags: FLAGS,
|
|
19
|
-
...args: ARGS
|
|
20
|
-
) => Promise<void> | void,
|
|
21
|
-
) {
|
|
22
|
-
return async function (
|
|
23
|
-
this: LocalContext,
|
|
24
|
-
flags: GlobalFlags & FLAGS,
|
|
25
|
-
...args: ARGS
|
|
26
|
-
) {
|
|
27
|
-
const configFilePath =
|
|
28
|
-
flags.config ??
|
|
29
|
-
this.process.env.WORKERS_CONFIG_FILE_PATH ??
|
|
30
|
-
"./workers.json";
|
|
31
|
-
|
|
32
|
-
const config = await Config.load({
|
|
33
|
-
configFilePath,
|
|
34
|
-
processEnv: process.env,
|
|
35
|
-
flags,
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
this.io.debugEnabled = flags.debug;
|
|
39
|
-
|
|
40
|
-
await handler.call({ ...this, config }, flags, ...args);
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function buildAuthedHandler<
|
|
45
|
-
const FLAGS,
|
|
46
|
-
const ARGS extends BaseArgs = [],
|
|
47
|
-
>(
|
|
48
|
-
handler: (
|
|
49
|
-
this: AuthedContext,
|
|
50
|
-
flags: FLAGS,
|
|
51
|
-
...args: ARGS
|
|
52
|
-
) => Promise<void> | void,
|
|
53
|
-
) {
|
|
54
|
-
return buildHandler(function (flags: FLAGS, ...args: ARGS) {
|
|
55
|
-
// Check token first - this will throw TokenNotSetError with helpful message if not authenticated
|
|
56
|
-
const { token, cellId } = this.config.tokenInfo;
|
|
57
|
-
const environment = this.config.environment;
|
|
58
|
-
|
|
59
|
-
const client = new ApiClient({
|
|
60
|
-
token,
|
|
61
|
-
environment,
|
|
62
|
-
baseUrl: this.config.baseUrl,
|
|
63
|
-
cellId,
|
|
64
|
-
writer: this.io,
|
|
65
|
-
});
|
|
66
|
-
return handler.call({ ...this, apiClient: client }, flags, ...args);
|
|
67
|
-
});
|
|
68
|
-
}
|
package/src/cli/io.ts
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
// biome-ignore lint/style/noRestrictedImports: This file contains safe wrappers for prompts.
|
|
2
|
-
import * as prompts from "@inquirer/prompts";
|
|
3
|
-
// biome-ignore lint/style/noRestrictedImports: This is the one allowed location for this import.
|
|
4
|
-
import { createTable, type TableCell, type TableItem } from "@visulima/tabular";
|
|
5
|
-
|
|
6
|
-
export interface WriterOptions {
|
|
7
|
-
debugEnabled: boolean;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface TableOptions {
|
|
11
|
-
headers: TableCell[] | TableCell[][];
|
|
12
|
-
rows: TableCell[][];
|
|
13
|
-
plain: boolean;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
type WithSafety<T> = T & {
|
|
17
|
-
noTTY: string;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* IO manages safe, consistent, input and output patterns for the CLI.
|
|
22
|
-
*/
|
|
23
|
-
export class IO {
|
|
24
|
-
debugEnabled: boolean;
|
|
25
|
-
|
|
26
|
-
constructor(options: WriterOptions) {
|
|
27
|
-
this.debugEnabled = options.debugEnabled;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Writes a debug message to standard error.
|
|
32
|
-
*
|
|
33
|
-
* @param args The arguments to write.
|
|
34
|
-
*/
|
|
35
|
-
debug(...args: Parameters<typeof console.log>) {
|
|
36
|
-
if (this.debugEnabled) {
|
|
37
|
-
args
|
|
38
|
-
.join(" ")
|
|
39
|
-
.split("\n")
|
|
40
|
-
.forEach((line) => {
|
|
41
|
-
this.writeErr(`[debug] ${line}`);
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Writes a message to standard out.
|
|
48
|
-
*
|
|
49
|
-
* @param args The arguments to write.
|
|
50
|
-
*/
|
|
51
|
-
writeOut(...args: Parameters<typeof process.stdout.write>) {
|
|
52
|
-
process.stdout.write(`${args.join(" ")}\n`);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Writes a message to standard error.
|
|
57
|
-
*
|
|
58
|
-
* @param args The arguments to write.
|
|
59
|
-
*/
|
|
60
|
-
writeErr(...args: Parameters<typeof process.stderr.write>) {
|
|
61
|
-
process.stderr.write(`${args.join(" ")}\n`);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Writes a table to standard out.
|
|
66
|
-
*
|
|
67
|
-
* @param tableConfig The table configuration.
|
|
68
|
-
*/
|
|
69
|
-
writeTableOut(tableConfig: TableOptions) {
|
|
70
|
-
const content = this.#buildTable(tableConfig);
|
|
71
|
-
this.writeOut(content);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Writes a table to standard error.
|
|
76
|
-
*
|
|
77
|
-
* @param tableConfig The table configuration.
|
|
78
|
-
*/
|
|
79
|
-
writeTableErr(tableConfig: TableOptions) {
|
|
80
|
-
const content = this.#buildTable(tableConfig);
|
|
81
|
-
this.writeErr(content);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
confirm(config: WithSafety<Parameters<typeof prompts.confirm>[0]>) {
|
|
85
|
-
this.#ensureTTY(config.noTTY);
|
|
86
|
-
return prompts.confirm(config).catch(this.#handlePromptExit.bind(this));
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
input(config: WithSafety<Parameters<typeof prompts.input>[0]>) {
|
|
90
|
-
this.#ensureTTY(config.noTTY);
|
|
91
|
-
return prompts.input(config).catch(this.#handlePromptExit.bind(this));
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
#ensureTTY(noTTY: string): true | never {
|
|
95
|
-
if (!process.stdin.isTTY) {
|
|
96
|
-
this.writeErr(noTTY);
|
|
97
|
-
process.exit(1);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
return true;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
#handlePromptExit(err: unknown) {
|
|
104
|
-
if (err instanceof Error && err.name === "ExitPromptError") {
|
|
105
|
-
this.writeErr("👋 Prompt cancelled. Goodbye!");
|
|
106
|
-
process.exit(1);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
throw err;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
#buildTable(tableConfig: TableOptions) {
|
|
113
|
-
if (tableConfig.plain) {
|
|
114
|
-
return tableConfig.rows
|
|
115
|
-
.map((row) => {
|
|
116
|
-
return row
|
|
117
|
-
.map((cell) => (isTableItem(cell) ? cell.content : cell))
|
|
118
|
-
.join("\t");
|
|
119
|
-
})
|
|
120
|
-
.join("\n");
|
|
121
|
-
} else {
|
|
122
|
-
const table = createTable();
|
|
123
|
-
table.setHeaders(tableConfig.headers);
|
|
124
|
-
table.addRows(...tableConfig.rows);
|
|
125
|
-
return table.toString();
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
function isTableItem(cell: TableCell): cell is TableItem {
|
|
131
|
-
return typeof cell === "object";
|
|
132
|
-
}
|
package/src/cli/routes.ts
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { buildApplication, buildRouteMap, text_en } from "@stricli/core";
|
|
2
|
-
import packageJson from "../../package.json" with { type: "json" };
|
|
3
|
-
import { authCommands } from "./commands/auth.js";
|
|
4
|
-
import { bundleCommands } from "./commands/bundle.js";
|
|
5
|
-
import { capabilitiesCommands } from "./commands/capabilities.js";
|
|
6
|
-
import { connectCommands } from "./commands/connect.js";
|
|
7
|
-
import deploy from "./commands/deploy.js";
|
|
8
|
-
import { envCommands } from "./commands/env.js";
|
|
9
|
-
import exec from "./commands/exec.js";
|
|
10
|
-
import { runsCommands } from "./commands/runs.js";
|
|
11
|
-
import { secretsCommands } from "./commands/secrets.js";
|
|
12
|
-
import { TokenNotSetError } from "./config.js";
|
|
13
|
-
|
|
14
|
-
const routes = buildRouteMap({
|
|
15
|
-
docs: {
|
|
16
|
-
brief: "A CLI for the Project Ajax platform",
|
|
17
|
-
fullDescription: `
|
|
18
|
-
The Project Ajax CLI is a tool for managing workers, which run code written by
|
|
19
|
-
you, other developers, or AI agents to perform automation tasks, such as syncing
|
|
20
|
-
data, adding slash commands, or performing other actions.
|
|
21
|
-
|
|
22
|
-
Most flags are configured either with a config file or flags, but environment
|
|
23
|
-
variables can also be provided:
|
|
24
|
-
|
|
25
|
-
- WORKERS_CONFIG_FILE_PATH: The path to the config file to use (e.g. ./workers.dev.json)
|
|
26
|
-
- WORKERS_TOKEN: The token to use for authentication
|
|
27
|
-
- WORKERS_ENVIRONMENT: The environment to use
|
|
28
|
-
- WORKERS_WORKER_ID: The worker ID to use
|
|
29
|
-
- WORKERS_BASE_URL: The base API URL to use
|
|
30
|
-
`.trim(),
|
|
31
|
-
},
|
|
32
|
-
routes: {
|
|
33
|
-
auth: authCommands,
|
|
34
|
-
capabilities: capabilitiesCommands,
|
|
35
|
-
deploy: deploy,
|
|
36
|
-
exec: exec,
|
|
37
|
-
connect: connectCommands,
|
|
38
|
-
env: envCommands,
|
|
39
|
-
runs: runsCommands,
|
|
40
|
-
secrets: secretsCommands,
|
|
41
|
-
bundle: bundleCommands,
|
|
42
|
-
},
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
export const app = buildApplication(routes, {
|
|
46
|
-
name: "workers",
|
|
47
|
-
versionInfo: {
|
|
48
|
-
currentVersion: packageJson.version,
|
|
49
|
-
},
|
|
50
|
-
localization: {
|
|
51
|
-
loadText: () => ({
|
|
52
|
-
...text_en,
|
|
53
|
-
exceptionWhileRunningCommand(exc: unknown, ansiColor: boolean): string {
|
|
54
|
-
if (exc instanceof TokenNotSetError) {
|
|
55
|
-
return exc.message;
|
|
56
|
-
}
|
|
57
|
-
return text_en.exceptionWhileRunningCommand(exc, ansiColor);
|
|
58
|
-
},
|
|
59
|
-
}),
|
|
60
|
-
},
|
|
61
|
-
});
|
package/src/cli/utils/array.ts
DELETED
package/src/cli/utils/openUrl.ts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { exec } from "node:child_process";
|
|
2
|
-
import { existsSync } from "node:fs";
|
|
3
|
-
|
|
4
|
-
import type { Environment } from "../config.js";
|
|
5
|
-
|
|
6
|
-
export async function openBrowserUrl(url: string): Promise<void> {
|
|
7
|
-
const platform = process.platform;
|
|
8
|
-
|
|
9
|
-
try {
|
|
10
|
-
if (platform === "darwin") {
|
|
11
|
-
exec(`open "${url}"`);
|
|
12
|
-
} else if (platform === "win32") {
|
|
13
|
-
exec(`start "" "${url}"`);
|
|
14
|
-
} else {
|
|
15
|
-
exec(`xdg-open "${url}"`);
|
|
16
|
-
}
|
|
17
|
-
} catch (error) {
|
|
18
|
-
throw new Error(`Failed to open browser: ${error}`);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export async function openNotionUrl(
|
|
23
|
-
env: Environment,
|
|
24
|
-
url: string,
|
|
25
|
-
): Promise<void> {
|
|
26
|
-
const platform = process.platform;
|
|
27
|
-
|
|
28
|
-
if (platform === "darwin") {
|
|
29
|
-
const appName = preferredNotionApp(env);
|
|
30
|
-
if (appName) {
|
|
31
|
-
try {
|
|
32
|
-
exec(`open -a "${appName}" "${url}"`);
|
|
33
|
-
return;
|
|
34
|
-
} catch {
|
|
35
|
-
// Fall back to the default browser below.
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
await openBrowserUrl(url);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function preferredNotionApp(env: Environment): string | null {
|
|
44
|
-
if (env === "prod" && existsSync("/Applications/Notion.app")) {
|
|
45
|
-
return "Notion";
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
if (env === "dev" && existsSync("/Applications/Notion Dev.app")) {
|
|
49
|
-
return "Notion Dev";
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return null;
|
|
53
|
-
}
|
package/src/cli/utils/string.ts
DELETED