@project-ajax/cli 0.0.13 → 0.0.15

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.
@@ -35,7 +35,9 @@ export declare class ApiClient {
35
35
  /**
36
36
  * Create a new worker
37
37
  */
38
- createWorker(name: string): Promise<Result<{
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
- * Update an existing worker's bundle
53
+ * Get a pre-signed URL for uploading a worker tarball
52
54
  */
53
- updateWorkerBundle(workerId: string): Promise<Result<{
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
  */
@@ -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,SA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5C,MAAM,CAAC,EAAE,KAAK,GAAG,SAAS,GACxB,OAAO,CAAC,MAAM,CAAC;QAAE,MAAM,EAAE,OAAO,CAAA;KAAE,EAAE,QAAQ,CAAC,CAAC;IA0CjD;;OAEG;IACG,oBAAoB,CACzB,QAAQ,EAAE,MAAM,GACd,OAAO,CAAC,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC,eAAe,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"}
@@ -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
- * Update an existing worker's bundle
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;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"}
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;AAwElE,wBAAsB,QAAQ,CAAC,OAAO,EAAE,cAAc,EAAE,KAAK,CAAC,EAAE,MAAM,iBAyFrE;AAED,eAAO,MAAM,KAAK,+GAMhB,CAAC;AAEH,eAAO,MAAM,IAAI,mFAEf,CAAC;AAEH,eAAO,MAAM,MAAM,mFAIjB,CAAC"}
@@ -30,44 +30,6 @@ 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
- }
71
33
  async function runLogin(context, token) {
72
34
  const environment = context.config.environment;
73
35
  const baseUrl = context.config.baseUrl;
@@ -97,45 +59,28 @@ async function runLogin(context, token) {
97
59
  );
98
60
  process.exit(1);
99
61
  }
100
- const { sessionId, verificationCode, browserUrl } = initResponse;
101
- context.io.writeErr(
102
- "Copy this verification code and paste it in your browser:\n"
103
- );
104
- context.io.writeErr(` ${verificationCode}
105
- `);
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:
62
+ const { sessionId, browserUrl } = initResponse;
63
+ context.io.writeErr(`Opening ${browserUrl} ...`);
64
+ try {
65
+ await openNotionUrl(environment, browserUrl);
66
+ } catch (_error) {
67
+ context.io.writeErr(
68
+ `Could not open browser automatically. Please visit:
122
69
  ${browserUrl}`
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");
70
+ );
130
71
  }
131
- const redeemOutcome = await redeemOutcomePromise;
132
- if (!redeemOutcome.ok) {
72
+ context.io.writeErr("");
73
+ context.io.writeErr("Waiting for browser confirmation...");
74
+ context.io.writeErr("(Press Ctrl+C to cancel)\n");
75
+ let redeemResponse;
76
+ try {
77
+ redeemResponse = await pollLoginRedeem(baseUrl, sessionId);
78
+ } catch (error) {
133
79
  context.io.writeErr(
134
- `Login failed: ${redeemOutcome.error instanceof Error ? redeemOutcome.error.message : String(redeemOutcome.error)}`
80
+ `Login failed: ${error instanceof Error ? error.message : String(error)}`
135
81
  );
136
82
  process.exit(1);
137
83
  }
138
- const redeemResponse = redeemOutcome.value;
139
84
  if (redeemResponse.status === "expired") {
140
85
  context.io.writeErr("Login session expired. Please try again.");
141
86
  process.exit(1);
@@ -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,3 @@
1
+ declare const _default: import("@stricli/core").Command<import("../context.js").LocalContext>;
2
+ export default _default;
3
+ //# sourceMappingURL=pack.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pack.d.ts","sourceRoot":"","sources":["../../src/commands/pack.ts"],"names":[],"mappings":";AAGA,wBAUG"}
@@ -0,0 +1,3 @@
1
+ import type { GlobalFlags } from "../flags.js";
2
+ export declare const pack: (this: import("../context.js").LocalContext, flags: GlobalFlags) => Promise<void>;
3
+ //# sourceMappingURL=pack.impl.d.ts.map
@@ -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,2 @@
1
+ export {};
2
+ //# sourceMappingURL=pack.impl.test.d.ts.map
@@ -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
+ };
package/dist/config.js CHANGED
@@ -178,7 +178,7 @@ function baseUrlForEnvironment(environment) {
178
178
  case "local":
179
179
  return "http://localhost:3000";
180
180
  case "staging":
181
- return "https://staging.notion.so";
181
+ return "https://stg.notion.so";
182
182
  case "dev":
183
183
  return "https://dev.notion.so";
184
184
  case "prod":
@@ -1 +1 @@
1
- {"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../src/deploy.ts"],"names":[],"mappings":"AA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AAE,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 bundle:"
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("Building worker bundle...");
43
- const archivePath = await buildWorkerBundle(context, absPath);
44
- context.io.debug(`Created bundle at: ${archivePath}`);
45
- context.io.writeErr("Uploading bundle...");
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("Upload complete");
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,5 @@
1
+ export declare function packWorkerSource(args: {
2
+ rootPath: string;
3
+ tempRoot: string;
4
+ }): string;
5
+ //# sourceMappingURL=packaging.d.ts.map
@@ -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
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AA4CA,eAAO,MAAM,GAAG,0EAgBd,CAAC"}
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, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@project-ajax/cli",
3
- "version": "0.0.13",
3
+ "version": "0.0.15",
4
4
  "description": "A CLI for the Project Ajax platform",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",