@project-ajax/cli 0.0.12 → 0.0.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/api/client.d.ts +16 -3
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +29 -5
- package/dist/commands/auth.impl.d.ts.map +1 -1
- package/dist/commands/auth.impl.js +67 -13
- package/dist/commands/deploy.impl.d.ts.map +1 -1
- package/dist/commands/deploy.impl.js +0 -1
- package/dist/commands/exec.impl.js +1 -1
- package/dist/commands/pack.d.ts +3 -0
- package/dist/commands/pack.d.ts.map +1 -0
- package/dist/commands/pack.impl.d.ts +3 -0
- package/dist/commands/pack.impl.d.ts.map +1 -0
- package/dist/commands/pack.impl.js +13 -0
- package/dist/commands/pack.impl.test.d.ts +2 -0
- package/dist/commands/pack.impl.test.d.ts.map +1 -0
- package/dist/commands/pack.js +16 -0
- package/dist/commands/secrets.impl.d.ts +7 -0
- package/dist/commands/secrets.impl.d.ts.map +1 -1
- package/dist/commands/secrets.impl.js +9 -5
- package/dist/commands/secrets.impl.test.d.ts +2 -0
- package/dist/commands/secrets.impl.test.d.ts.map +1 -0
- package/dist/commands/secrets.js +2 -2
- package/dist/deploy.d.ts.map +1 -1
- package/dist/deploy.js +74 -29
- package/dist/packaging.d.ts +5 -0
- package/dist/packaging.d.ts.map +1 -0
- package/dist/packaging.js +130 -0
- package/dist/routes.d.ts.map +1 -1
- package/dist/routes.js +7 -2
- package/package.json +1 -1
package/dist/api/client.d.ts
CHANGED
|
@@ -35,7 +35,9 @@ export declare class ApiClient {
|
|
|
35
35
|
/**
|
|
36
36
|
* Create a new worker
|
|
37
37
|
*/
|
|
38
|
-
createWorker(name: string
|
|
38
|
+
createWorker(name: string, options?: {
|
|
39
|
+
uploadType?: "bundle" | "source";
|
|
40
|
+
}): Promise<Result<{
|
|
39
41
|
worker: {
|
|
40
42
|
workerId: string;
|
|
41
43
|
name: string;
|
|
@@ -48,12 +50,23 @@ export declare class ApiClient {
|
|
|
48
50
|
fields: Record<string, string>;
|
|
49
51
|
}, ApiError>>;
|
|
50
52
|
/**
|
|
51
|
-
*
|
|
53
|
+
* Get a pre-signed URL for uploading a worker tarball
|
|
52
54
|
*/
|
|
53
|
-
updateWorkerBundle(workerId: string
|
|
55
|
+
updateWorkerBundle(workerId: string, options?: {
|
|
56
|
+
uploadType?: "bundle" | "source";
|
|
57
|
+
}): Promise<Result<{
|
|
54
58
|
url: string;
|
|
55
59
|
fields: Record<string, string>;
|
|
56
60
|
}, ApiError>>;
|
|
61
|
+
/**
|
|
62
|
+
* Build a worker bundle in a sandbox
|
|
63
|
+
*/
|
|
64
|
+
buildWorker(workerId: string, stream: true): Promise<Result<ReadableStream<Uint8Array<ArrayBufferLike>>, ApiError>>;
|
|
65
|
+
buildWorker(workerId: string, stream?: false | undefined): Promise<Result<{
|
|
66
|
+
result: {
|
|
67
|
+
ok: true;
|
|
68
|
+
};
|
|
69
|
+
}, ApiError>>;
|
|
57
70
|
/**
|
|
58
71
|
* Get a worker by ID
|
|
59
72
|
*/
|
package/dist/api/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,SAAS,GAAG,KAAK,GAAG,MAAM,CAAC;AAE/D,UAAU,eAAe;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,WAAW,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,EAAE,CAAC;CACX;AAID,MAAM,WAAW,QAAQ;IACxB,MAAM,EAAE,MAAM,CAAC;IAC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AAe,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;IAazE;;OAEG;IACG,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CACjD,MAAM,CACL;QACC,IAAI,EAAE,KAAK,CAAC;YACX,QAAQ,EAAE,MAAM,CAAC;YACjB,OAAO,EAAE,MAAM,CAAC;YAChB,KAAK,EAAE,MAAM,CAAC;YACd,IAAI,EAAE,MAAM,CAAC;YACb,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;YACxB,SAAS,EAAE,MAAM,CAAC;YAClB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;SACvB,CAAC,CAAC;KACH,EACD,QAAQ,CACR,CACD;IASD;;OAEG;IACG,UAAU,CACf,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,GACX,OAAO,CACT,MAAM,CACL;QACC,IAAI,EAAE,MAAM,CAAC;KACb,EACD,QAAQ,CACR,CACD;CASD"}
|
package/dist/api/client.js
CHANGED
|
@@ -58,22 +58,46 @@ class ApiClient {
|
|
|
58
58
|
/**
|
|
59
59
|
* Create a new worker
|
|
60
60
|
*/
|
|
61
|
-
async createWorker(name) {
|
|
61
|
+
async createWorker(name, options) {
|
|
62
62
|
return this.fetch("/workersCreateWorker", {
|
|
63
63
|
method: "POST",
|
|
64
64
|
body: {
|
|
65
|
-
name
|
|
65
|
+
name,
|
|
66
|
+
uploadType: options?.uploadType
|
|
66
67
|
}
|
|
67
68
|
});
|
|
68
69
|
}
|
|
69
70
|
/**
|
|
70
|
-
*
|
|
71
|
+
* Get a pre-signed URL for uploading a worker tarball
|
|
71
72
|
*/
|
|
72
|
-
async updateWorkerBundle(workerId) {
|
|
73
|
+
async updateWorkerBundle(workerId, options) {
|
|
73
74
|
return this.fetch("/workersUpdateWorker", {
|
|
74
75
|
method: "POST",
|
|
75
76
|
body: {
|
|
76
|
-
workerId
|
|
77
|
+
workerId,
|
|
78
|
+
uploadType: options?.uploadType
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
async buildWorker(workerId, stream) {
|
|
83
|
+
if (stream) {
|
|
84
|
+
return this.fetch(
|
|
85
|
+
"/workersBuildWorker",
|
|
86
|
+
{
|
|
87
|
+
method: "POST",
|
|
88
|
+
body: {
|
|
89
|
+
workerId,
|
|
90
|
+
stream
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
{ stream }
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
return this.fetch("/workersBuildWorker", {
|
|
97
|
+
method: "POST",
|
|
98
|
+
body: {
|
|
99
|
+
workerId,
|
|
100
|
+
stream
|
|
77
101
|
}
|
|
78
102
|
});
|
|
79
103
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.impl.d.ts","sourceRoot":"","sources":["../../src/commands/auth.impl.ts"],"names":[],"mappings":"AACA,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":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAgB,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AAiIlE,wBAAsB,QAAQ,CAAC,OAAO,EAAE,cAAc,EAAE,KAAK,CAAC,EAAE,MAAM,iBA8GrE;AAED,eAAO,MAAM,KAAK,+GAMhB,CAAC;AAEH,eAAO,MAAM,IAAI,mFAEf,CAAC;AAEH,eAAO,MAAM,MAAM,mFAIjB,CAAC"}
|
|
@@ -30,6 +30,44 @@ async function pollLoginRedeem(baseUrl, sessionId, timeoutMs = 3e5, intervalMs =
|
|
|
30
30
|
}
|
|
31
31
|
return { status: "expired" };
|
|
32
32
|
}
|
|
33
|
+
async function waitForEnterOrRedeem(context, browserUrl, redeemOutcomePromise) {
|
|
34
|
+
if (!process.stdin.isTTY) {
|
|
35
|
+
context.io.writeErr(
|
|
36
|
+
`Please visit this URL to authenticate:
|
|
37
|
+
${browserUrl}`
|
|
38
|
+
);
|
|
39
|
+
process.exit(1);
|
|
40
|
+
}
|
|
41
|
+
context.io.writeErr(
|
|
42
|
+
`Press Enter to open the browser, or visit: ${browserUrl}`
|
|
43
|
+
);
|
|
44
|
+
return new Promise((resolve) => {
|
|
45
|
+
let settled = false;
|
|
46
|
+
const cleanup = () => {
|
|
47
|
+
process.stdin.off("data", onData);
|
|
48
|
+
process.stdin.pause();
|
|
49
|
+
};
|
|
50
|
+
const settle = (value) => {
|
|
51
|
+
if (settled) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
settled = true;
|
|
55
|
+
cleanup();
|
|
56
|
+
resolve(value);
|
|
57
|
+
};
|
|
58
|
+
const onData = (data) => {
|
|
59
|
+
const hasNewline = typeof data === "string" ? data.includes("\n") || data.includes("\r") : data.includes(10) || data.includes(13);
|
|
60
|
+
if (hasNewline) {
|
|
61
|
+
settle("enter");
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
process.stdin.resume();
|
|
65
|
+
process.stdin.on("data", onData);
|
|
66
|
+
void redeemOutcomePromise.then(() => {
|
|
67
|
+
settle("redeem");
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
}
|
|
33
71
|
async function runLogin(context, token) {
|
|
34
72
|
const environment = context.config.environment;
|
|
35
73
|
const baseUrl = context.config.baseUrl;
|
|
@@ -65,23 +103,39 @@ async function runLogin(context, token) {
|
|
|
65
103
|
);
|
|
66
104
|
context.io.writeErr(` ${verificationCode}
|
|
67
105
|
`);
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
106
|
+
const redeemPromise = pollLoginRedeem(baseUrl, sessionId);
|
|
107
|
+
const redeemOutcomePromise = redeemPromise.then(
|
|
108
|
+
(value) => ({ ok: true, value }),
|
|
109
|
+
(error) => ({ ok: false, error })
|
|
110
|
+
);
|
|
111
|
+
const nextStep = await waitForEnterOrRedeem(
|
|
112
|
+
context,
|
|
113
|
+
browserUrl,
|
|
114
|
+
redeemOutcomePromise
|
|
115
|
+
);
|
|
116
|
+
if (nextStep === "enter") {
|
|
117
|
+
try {
|
|
118
|
+
await openNotionUrl(environment, browserUrl);
|
|
119
|
+
} catch (_error) {
|
|
120
|
+
context.io.writeErr(
|
|
121
|
+
`Could not open browser automatically. Please visit:
|
|
71
122
|
${browserUrl}`
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
if (nextStep !== "redeem") {
|
|
127
|
+
context.io.writeErr("");
|
|
128
|
+
context.io.writeErr("Waiting for browser confirmation...");
|
|
129
|
+
context.io.writeErr("(Press Ctrl+C to cancel)\n");
|
|
130
|
+
}
|
|
131
|
+
const redeemOutcome = await redeemOutcomePromise;
|
|
132
|
+
if (!redeemOutcome.ok) {
|
|
76
133
|
context.io.writeErr(
|
|
77
|
-
`
|
|
78
|
-
${browserUrl}`
|
|
134
|
+
`Login failed: ${redeemOutcome.error instanceof Error ? redeemOutcome.error.message : String(redeemOutcome.error)}`
|
|
79
135
|
);
|
|
136
|
+
process.exit(1);
|
|
80
137
|
}
|
|
81
|
-
|
|
82
|
-
context.io.writeErr("Waiting for browser confirmation...");
|
|
83
|
-
context.io.writeErr("(Press Ctrl+C to cancel)\n");
|
|
84
|
-
const redeemResponse = await pollLoginRedeem(baseUrl, sessionId);
|
|
138
|
+
const redeemResponse = redeemOutcome.value;
|
|
85
139
|
if (redeemResponse.status === "expired") {
|
|
86
140
|
context.io.writeErr("Login session expired. Please try again.");
|
|
87
141
|
process.exit(1);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy.impl.d.ts","sourceRoot":"","sources":["../../src/commands/deploy.impl.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAI/C,UAAU,WAAW;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;CACd;AAED,eAAO,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"deploy.impl.d.ts","sourceRoot":"","sources":["../../src/commands/deploy.impl.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAI/C,UAAU,WAAW;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;CACd;AAED,eAAO,MAAM,MAAM,iGAoFjB,CAAC"}
|
|
@@ -5,7 +5,6 @@ import { buildHandler } from "../handler.js";
|
|
|
5
5
|
import { runLogin } from "./auth.impl.js";
|
|
6
6
|
const deploy = buildHandler(async function(flags) {
|
|
7
7
|
if (!this.config.token) {
|
|
8
|
-
this.io.writeErr("No authentication token found. Starting login flow...");
|
|
9
8
|
await runLogin(this);
|
|
10
9
|
}
|
|
11
10
|
const { token, cellId } = this.config.tokenInfo;
|
|
@@ -136,7 +136,7 @@ function showUrls(context, workerId, collectionId) {
|
|
|
136
136
|
context.io.writeErr(" View execution state, logs, and debugging info");
|
|
137
137
|
if (collectionId) {
|
|
138
138
|
context.io.writeErr("");
|
|
139
|
-
const databaseUrl = `${baseUrl}/${formatIdForUrl(collectionId)}`;
|
|
139
|
+
const databaseUrl = `${baseUrl}/ds/${formatIdForUrl(collectionId)}`;
|
|
140
140
|
context.io.writeErr(`Synced Database: ${databaseUrl}`);
|
|
141
141
|
context.io.writeErr(" View the synced data in Notion");
|
|
142
142
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pack.d.ts","sourceRoot":"","sources":["../../src/commands/pack.ts"],"names":[],"mappings":";AAGA,wBAUG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pack.impl.d.ts","sourceRoot":"","sources":["../../src/commands/pack.impl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAI/C,eAAO,MAAM,IAAI,mFAQf,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { buildHandler } from "../handler.js";
|
|
2
|
+
import { packWorkerSource } from "../packaging.js";
|
|
3
|
+
const pack = buildHandler(async function(_flags) {
|
|
4
|
+
const rootPath = this.process.cwd();
|
|
5
|
+
const archivePath = packWorkerSource({
|
|
6
|
+
rootPath,
|
|
7
|
+
tempRoot: this.os.tmpdir()
|
|
8
|
+
});
|
|
9
|
+
this.io.writeOut(archivePath);
|
|
10
|
+
});
|
|
11
|
+
export {
|
|
12
|
+
pack
|
|
13
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pack.impl.test.d.ts","sourceRoot":"","sources":["../../src/commands/pack.impl.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { buildCommand } from "@stricli/core";
|
|
2
|
+
import { globalFlags } from "../flags.js";
|
|
3
|
+
var pack_default = buildCommand({
|
|
4
|
+
docs: {
|
|
5
|
+
brief: "Create a tarball of the un-bundled worker files"
|
|
6
|
+
},
|
|
7
|
+
parameters: {
|
|
8
|
+
flags: {
|
|
9
|
+
...globalFlags
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
loader: () => import("./pack.impl.js").then((m) => m.pack)
|
|
13
|
+
});
|
|
14
|
+
export {
|
|
15
|
+
pack_default as default
|
|
16
|
+
};
|
|
@@ -2,4 +2,11 @@ import type { FormatFlags, 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>;
|
|
5
|
+
/**
|
|
6
|
+
* Parse secret arguments from CLI, supporting "key=value" format.
|
|
7
|
+
*/
|
|
8
|
+
export declare function parseSecretArgs(args: readonly string[]): Array<{
|
|
9
|
+
key: string;
|
|
10
|
+
value: string;
|
|
11
|
+
}>;
|
|
5
12
|
//# sourceMappingURL=secrets.impl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secrets.impl.d.ts","sourceRoot":"","sources":["../../src/commands/secrets.impl.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"secrets.impl.d.ts","sourceRoot":"","sources":["../../src/commands/secrets.impl.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAI5D,eAAO,MAAM,UAAU,sGA0BrB,CAAC;AAEH,eAAO,MAAM,WAAW,iGAkCtB,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,6 +1,5 @@
|
|
|
1
1
|
import { Result } from "../api/result.js";
|
|
2
2
|
import { buildAuthedHandler } from "../handler.js";
|
|
3
|
-
import { chunkEvery } from "../utils/array.js";
|
|
4
3
|
import { pluralize } from "../utils/string.js";
|
|
5
4
|
const setSecrets = buildAuthedHandler(async function(_flags, ...args) {
|
|
6
5
|
const secrets = parseSecretArgs(args);
|
|
@@ -70,24 +69,29 @@ const removeSecret = buildAuthedHandler(async function(_flags, key) {
|
|
|
70
69
|
});
|
|
71
70
|
function usageError() {
|
|
72
71
|
return new Error(
|
|
73
|
-
"Invalid secrets provided. Usage: workers secrets set <key
|
|
72
|
+
"Invalid secrets provided. Usage: workers secrets set <key>=<value> [<key2>=<value2>...]"
|
|
74
73
|
);
|
|
75
74
|
}
|
|
76
75
|
function parseSecretArgs(args) {
|
|
77
76
|
if (args.length === 0) {
|
|
78
77
|
throw usageError();
|
|
79
78
|
}
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
return args.map((arg) => {
|
|
80
|
+
const separatorIndex = arg.indexOf("=");
|
|
81
|
+
if (separatorIndex <= 0 || separatorIndex === arg.length - 1) {
|
|
82
|
+
throw usageError();
|
|
83
|
+
}
|
|
84
|
+
const key = arg.slice(0, separatorIndex);
|
|
85
|
+
const value = arg.slice(separatorIndex + 1);
|
|
82
86
|
if (!key || !value) {
|
|
83
87
|
throw usageError();
|
|
84
88
|
}
|
|
85
89
|
return { key, value };
|
|
86
90
|
});
|
|
87
|
-
return secrets;
|
|
88
91
|
}
|
|
89
92
|
export {
|
|
90
93
|
listSecrets,
|
|
94
|
+
parseSecretArgs,
|
|
91
95
|
removeSecret,
|
|
92
96
|
setSecrets
|
|
93
97
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secrets.impl.test.d.ts","sourceRoot":"","sources":["../../src/commands/secrets.impl.test.ts"],"names":[],"mappings":""}
|
package/dist/commands/secrets.js
CHANGED
|
@@ -7,13 +7,13 @@ const secretsCommands = buildRouteMap({
|
|
|
7
7
|
routes: {
|
|
8
8
|
set: buildCommand({
|
|
9
9
|
docs: {
|
|
10
|
-
brief: "Set one or more secrets for a worker. Supports 'key
|
|
10
|
+
brief: "Set one or more secrets for a worker. Supports 'key=value' format."
|
|
11
11
|
},
|
|
12
12
|
parameters: {
|
|
13
13
|
positional: {
|
|
14
14
|
kind: "array",
|
|
15
15
|
parameter: {
|
|
16
|
-
brief: "Secret key-value pairs (key
|
|
16
|
+
brief: "Secret key-value pairs (key=value)",
|
|
17
17
|
parse: String,
|
|
18
18
|
placeholder: "secrets..."
|
|
19
19
|
}
|
package/dist/deploy.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../src/deploy.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../src/deploy.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAGlD,MAAM,WAAW,iBAAiB;IACjC;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,WAAW,EAAE,WAAW,CAAC;CACzB;AAED,MAAM,WAAW,mBAAoB,SAAQ,iBAAiB;IAC7D;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,mBAAoB,SAAQ,iBAAiB;IAC7D;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,aAAa,GAAG,mBAAmB,GAAG,mBAAmB,CAAC;AAEtE;;GAEG;AACH,wBAAsB,YAAY,CACjC,OAAO,EAAE,aAAa,EACtB,OAAO,EAAE,aAAa,GACpB,OAAO,CAAC,MAAM,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,EAAE,QAAQ,CAAC,CAAC,CAgFjD"}
|
package/dist/deploy.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import * as childProcess from "node:child_process";
|
|
2
1
|
import * as fs from "node:fs";
|
|
3
2
|
import * as path from "node:path";
|
|
4
|
-
import * as esbuild from "esbuild";
|
|
5
3
|
import { Result } from "./api/result.js";
|
|
4
|
+
import { packWorkerSource } from "./packaging.js";
|
|
6
5
|
async function deployWorker(context, options) {
|
|
7
6
|
const { workerPath } = options;
|
|
8
7
|
const absPath = path.resolve(process.cwd(), workerPath);
|
|
@@ -14,20 +13,24 @@ async function deployWorker(context, options) {
|
|
|
14
13
|
if ("workerId" in options) {
|
|
15
14
|
context.io.writeErr(`Updating worker...`);
|
|
16
15
|
workerId = options.workerId;
|
|
17
|
-
const updateResult = await client.updateWorkerBundle(workerId
|
|
16
|
+
const updateResult = await client.updateWorkerBundle(workerId, {
|
|
17
|
+
uploadType: "source"
|
|
18
|
+
});
|
|
18
19
|
if (Result.isSuccess(updateResult)) {
|
|
19
20
|
const res = Result.unwrap(updateResult);
|
|
20
21
|
uploadUrl = res.url;
|
|
21
22
|
uploadFields = res.fields;
|
|
22
23
|
} else {
|
|
23
24
|
context.io.writeErr(
|
|
24
|
-
"Failed to generate pre-signed upload URL for worker
|
|
25
|
+
"Failed to generate pre-signed upload URL for worker source:"
|
|
25
26
|
);
|
|
26
27
|
throw new Error(updateResult.error.message);
|
|
27
28
|
}
|
|
28
29
|
} else {
|
|
29
30
|
context.io.writeErr(`Creating worker...`);
|
|
30
|
-
const createResult = await client.createWorker(options.name
|
|
31
|
+
const createResult = await client.createWorker(options.name, {
|
|
32
|
+
uploadType: "source"
|
|
33
|
+
});
|
|
31
34
|
if (Result.isSuccess(createResult)) {
|
|
32
35
|
const res = Result.unwrap(createResult);
|
|
33
36
|
uploadUrl = res.url;
|
|
@@ -39,12 +42,20 @@ async function deployWorker(context, options) {
|
|
|
39
42
|
}
|
|
40
43
|
}
|
|
41
44
|
context.io.debug(`Generated upload URL: ${uploadUrl}`);
|
|
42
|
-
context.io.writeErr("
|
|
43
|
-
const archivePath =
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
context.io.writeErr("Packing worker source...");
|
|
46
|
+
const archivePath = packWorkerSource({
|
|
47
|
+
rootPath: absPath,
|
|
48
|
+
tempRoot: context.os.tmpdir()
|
|
49
|
+
});
|
|
50
|
+
context.io.debug(`Created source archive at: ${archivePath}`);
|
|
51
|
+
context.io.writeErr("Uploading source...");
|
|
46
52
|
await uploadBundle(uploadUrl, uploadFields, archivePath);
|
|
47
|
-
context.io.debug("
|
|
53
|
+
context.io.debug("Source upload complete");
|
|
54
|
+
context.io.writeErr("Building worker in sandbox...");
|
|
55
|
+
const buildResult = await buildWorkerBundle(context, workerId);
|
|
56
|
+
if (Result.isFail(buildResult)) {
|
|
57
|
+
return buildResult;
|
|
58
|
+
}
|
|
48
59
|
context.io.writeErr("Fetching and saving worker capabilities...");
|
|
49
60
|
const capabilitiesResult = await client.fetchAndSaveCapabilities(workerId);
|
|
50
61
|
if (Result.isSuccess(capabilitiesResult)) {
|
|
@@ -53,25 +64,6 @@ async function deployWorker(context, options) {
|
|
|
53
64
|
return capabilitiesResult;
|
|
54
65
|
}
|
|
55
66
|
}
|
|
56
|
-
async function buildWorkerBundle(context, workerPath) {
|
|
57
|
-
const entrypoint = "src/index.ts";
|
|
58
|
-
if (!fs.existsSync(path.join(workerPath, entrypoint))) {
|
|
59
|
-
throw new Error(`Entrypoint not found: ${entrypoint}`);
|
|
60
|
-
}
|
|
61
|
-
const outdir = fs.mkdtempSync("/tmp/workers-build-");
|
|
62
|
-
esbuild.buildSync({
|
|
63
|
-
entryPoints: [entrypoint],
|
|
64
|
-
absWorkingDir: workerPath,
|
|
65
|
-
bundle: true,
|
|
66
|
-
outdir,
|
|
67
|
-
platform: "node"
|
|
68
|
-
});
|
|
69
|
-
context.io.debug(`Built bundle to: ${outdir}`);
|
|
70
|
-
const archiveDir = fs.mkdtempSync("/tmp/workers-archive-");
|
|
71
|
-
const archivePath = path.join(archiveDir, "archive.tar.gz");
|
|
72
|
-
childProcess.execSync(`tar -czf ${archivePath} -C ${outdir} .`);
|
|
73
|
-
return archivePath;
|
|
74
|
-
}
|
|
75
67
|
async function uploadBundle(url, fields, archivePath) {
|
|
76
68
|
const formData = new FormData();
|
|
77
69
|
for (const [key, value] of Object.entries(fields)) {
|
|
@@ -95,6 +87,59 @@ ${errorText}`
|
|
|
95
87
|
);
|
|
96
88
|
}
|
|
97
89
|
}
|
|
90
|
+
async function buildWorkerBundle(context, workerId) {
|
|
91
|
+
const result = await context.apiClient.buildWorker(workerId, true);
|
|
92
|
+
if (Result.isFail(result)) {
|
|
93
|
+
return result;
|
|
94
|
+
}
|
|
95
|
+
const decoder = new TextDecoder();
|
|
96
|
+
let buffer = "";
|
|
97
|
+
let buildSucceeded = false;
|
|
98
|
+
const onBodyLine = async (jsonLine) => {
|
|
99
|
+
try {
|
|
100
|
+
const parsedLine = JSON.parse(jsonLine);
|
|
101
|
+
switch (parsedLine._tag) {
|
|
102
|
+
case "log": {
|
|
103
|
+
const prefix = parsedLine.event.stream === "stdout" ? "build" : "build:err";
|
|
104
|
+
parsedLine.event.data.split("\n").filter(Boolean).forEach((line) => {
|
|
105
|
+
context.io.writeErr(`[${prefix}] ${line}`);
|
|
106
|
+
});
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
case "result":
|
|
110
|
+
buildSucceeded = parsedLine.result.ok;
|
|
111
|
+
break;
|
|
112
|
+
case "error":
|
|
113
|
+
context.io.writeErr(`Build error: ${parsedLine.error}`);
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
} catch (error) {
|
|
117
|
+
context.io.writeErr(
|
|
118
|
+
`Error parsing build log line: ${jsonLine}: ${error}`
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
for await (const log of result.value) {
|
|
123
|
+
const output = decoder.decode(log);
|
|
124
|
+
buffer += output;
|
|
125
|
+
const lines = buffer.split("\n");
|
|
126
|
+
buffer = lines.pop() ?? "";
|
|
127
|
+
for (const line of lines) {
|
|
128
|
+
await onBodyLine(line);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
if (buffer) {
|
|
132
|
+
await onBodyLine(buffer);
|
|
133
|
+
}
|
|
134
|
+
if (!buildSucceeded) {
|
|
135
|
+
return Result.fail({
|
|
136
|
+
status: 500,
|
|
137
|
+
statusText: "Build failed",
|
|
138
|
+
message: "Worker build failed. Check logs for details."
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
return Result.success({ ok: true });
|
|
142
|
+
}
|
|
98
143
|
export {
|
|
99
144
|
deployWorker
|
|
100
145
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"packaging.d.ts","sourceRoot":"","sources":["../src/packaging.ts"],"names":[],"mappings":"AAQA,wBAAgB,gBAAgB,CAAC,IAAI,EAAE;IACtC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CACjB,GAAG,MAAM,CAWT"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import * as childProcess from "node:child_process";
|
|
2
|
+
import * as fs from "node:fs";
|
|
3
|
+
import * as path from "node:path";
|
|
4
|
+
const ALWAYS_EXCLUDED_DIRS = /* @__PURE__ */ new Set(["node_modules", "dist"]);
|
|
5
|
+
const ALWAYS_EXCLUDED_FILES = /* @__PURE__ */ new Set(["workers.json", ".env"]);
|
|
6
|
+
const ALWAYS_EXCLUDED_PREFIXES = [".env."];
|
|
7
|
+
function packWorkerSource(args) {
|
|
8
|
+
const files = listPackableFiles(args.rootPath);
|
|
9
|
+
if (files.length === 0) {
|
|
10
|
+
throw new Error("No files found to pack.");
|
|
11
|
+
}
|
|
12
|
+
return createArchive({
|
|
13
|
+
files,
|
|
14
|
+
rootPath: args.rootPath,
|
|
15
|
+
tempRoot: args.tempRoot
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
function listPackableFiles(rootPath) {
|
|
19
|
+
const gitFiles = listPackableFilesWithGit(rootPath);
|
|
20
|
+
if (gitFiles !== null) {
|
|
21
|
+
return gitFiles;
|
|
22
|
+
}
|
|
23
|
+
return listPackableFilesFromFs(rootPath);
|
|
24
|
+
}
|
|
25
|
+
function listPackableFilesWithGit(rootPath) {
|
|
26
|
+
const result = childProcess.spawnSync(
|
|
27
|
+
"git",
|
|
28
|
+
["ls-files", "-z", "-co", "--exclude-standard"],
|
|
29
|
+
{
|
|
30
|
+
cwd: rootPath,
|
|
31
|
+
encoding: "utf-8"
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
if (result.error) {
|
|
35
|
+
if (result.error.code === "ENOENT") {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
throw new Error(`Failed to list files with git: ${result.error.message}`);
|
|
39
|
+
}
|
|
40
|
+
if (result.status !== 0) {
|
|
41
|
+
const stderr = typeof result.stderr === "string" ? result.stderr.trim() : "";
|
|
42
|
+
if (stderr.includes("not a git repository")) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
const message = stderr ? `Failed to list files with git: ${stderr}` : "Failed to list files with git.";
|
|
46
|
+
throw new Error(message);
|
|
47
|
+
}
|
|
48
|
+
const stdout = typeof result.stdout === "string" ? result.stdout : "";
|
|
49
|
+
const files = stdout.split("\0").filter(Boolean);
|
|
50
|
+
return files.filter((file) => isPackablePath(file));
|
|
51
|
+
}
|
|
52
|
+
function listPackableFilesFromFs(rootPath) {
|
|
53
|
+
const files = [];
|
|
54
|
+
const stack = [
|
|
55
|
+
{ absPath: rootPath, relPath: "" }
|
|
56
|
+
];
|
|
57
|
+
while (stack.length > 0) {
|
|
58
|
+
const entry = stack.pop();
|
|
59
|
+
if (!entry) {
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
const entries = fs.readdirSync(entry.absPath, { withFileTypes: true });
|
|
63
|
+
for (const dirent of entries) {
|
|
64
|
+
const relPath = entry.relPath ? `${entry.relPath}/${dirent.name}` : dirent.name;
|
|
65
|
+
if (!isPackablePath(relPath)) {
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
if (dirent.isDirectory()) {
|
|
69
|
+
stack.push({
|
|
70
|
+
absPath: path.join(entry.absPath, dirent.name),
|
|
71
|
+
relPath
|
|
72
|
+
});
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
if (dirent.isFile() || dirent.isSymbolicLink()) {
|
|
76
|
+
files.push(relPath);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return files;
|
|
81
|
+
}
|
|
82
|
+
function isPackablePath(file) {
|
|
83
|
+
const segments = file.split("/");
|
|
84
|
+
if (segments.some((segment) => ALWAYS_EXCLUDED_DIRS.has(segment))) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
const fileName = segments.at(-1) ?? file;
|
|
88
|
+
if (ALWAYS_EXCLUDED_FILES.has(fileName)) {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
if (isWorkersJsonVariant(fileName)) {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
return !ALWAYS_EXCLUDED_PREFIXES.some(
|
|
95
|
+
(prefix) => fileName.startsWith(prefix)
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
function isWorkersJsonVariant(fileName) {
|
|
99
|
+
return fileName.startsWith("workers.") && fileName.endsWith(".json");
|
|
100
|
+
}
|
|
101
|
+
function createArchive({
|
|
102
|
+
files,
|
|
103
|
+
rootPath,
|
|
104
|
+
tempRoot
|
|
105
|
+
}) {
|
|
106
|
+
const archiveDir = fs.mkdtempSync(path.join(tempRoot, "workers-pack-"));
|
|
107
|
+
const archivePath = path.join(archiveDir, "pack.tar.gz");
|
|
108
|
+
const listPath = path.join(archiveDir, "pack-files.txt");
|
|
109
|
+
fs.writeFileSync(listPath, `${files.join("\0")}\0`);
|
|
110
|
+
const tarResult = childProcess.spawnSync(
|
|
111
|
+
"tar",
|
|
112
|
+
["-czf", archivePath, "-C", rootPath, "--null", "-T", listPath],
|
|
113
|
+
{
|
|
114
|
+
cwd: rootPath,
|
|
115
|
+
encoding: "utf-8"
|
|
116
|
+
}
|
|
117
|
+
);
|
|
118
|
+
if (tarResult.error) {
|
|
119
|
+
throw new Error(`Failed to create archive: ${tarResult.error.message}`);
|
|
120
|
+
}
|
|
121
|
+
if (tarResult.status !== 0) {
|
|
122
|
+
const stderr = typeof tarResult.stderr === "string" ? tarResult.stderr.trim() : "";
|
|
123
|
+
const message = stderr ? `Failed to create archive: ${stderr}` : "Failed to create archive.";
|
|
124
|
+
throw new Error(message);
|
|
125
|
+
}
|
|
126
|
+
return archivePath;
|
|
127
|
+
}
|
|
128
|
+
export {
|
|
129
|
+
packWorkerSource
|
|
130
|
+
};
|
package/dist/routes.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AAiDA,eAAO,MAAM,GAAG,0EAgBd,CAAC"}
|
package/dist/routes.js
CHANGED
|
@@ -7,6 +7,7 @@ import deploy from "./commands/deploy.js";
|
|
|
7
7
|
import { envCommands } from "./commands/env.js";
|
|
8
8
|
import exec from "./commands/exec.js";
|
|
9
9
|
import { oauthCommands } from "./commands/oauth.js";
|
|
10
|
+
import pack from "./commands/pack.js";
|
|
10
11
|
import { runsCommands } from "./commands/runs.js";
|
|
11
12
|
import { secretsCommands } from "./commands/secrets.js";
|
|
12
13
|
import { TokenNotSetError } from "./config.js";
|
|
@@ -26,7 +27,10 @@ variables can also be provided:
|
|
|
26
27
|
- WORKERS_ENVIRONMENT: The environment to use
|
|
27
28
|
- WORKERS_WORKER_ID: The worker ID to use
|
|
28
29
|
- WORKERS_BASE_URL: The base API URL to use
|
|
29
|
-
`.trim()
|
|
30
|
+
`.trim(),
|
|
31
|
+
hideRoute: {
|
|
32
|
+
pack: true
|
|
33
|
+
}
|
|
30
34
|
},
|
|
31
35
|
routes: {
|
|
32
36
|
auth: authCommands,
|
|
@@ -37,7 +41,8 @@ variables can also be provided:
|
|
|
37
41
|
env: envCommands,
|
|
38
42
|
runs: runsCommands,
|
|
39
43
|
secrets: secretsCommands,
|
|
40
|
-
bundle: bundleCommands
|
|
44
|
+
bundle: bundleCommands,
|
|
45
|
+
pack
|
|
41
46
|
}
|
|
42
47
|
});
|
|
43
48
|
const app = buildApplication(routes, {
|