arcadible 1.0.35 → 1.0.37

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.
Files changed (52) hide show
  1. package/README.md +1 -1
  2. package/dist/action/function/logs.js +238 -0
  3. package/dist/action/function/tool.js +40 -16
  4. package/dist/action/pack/limits.js +28 -4
  5. package/dist/action/pack/tool.js +2 -1
  6. package/dist/action/value/tool.js +2 -2
  7. package/dist/action/wire/tool.js +1 -1
  8. package/dist/api.js +30 -5
  9. package/dist/cli/command.js +12 -2
  10. package/dist/command/function/index.js +7 -7
  11. package/dist/command/function/logs.js +154 -0
  12. package/dist/command/function/pause.js +1 -1
  13. package/dist/command/function/resume.js +1 -1
  14. package/dist/command/function/run.js +1 -1
  15. package/dist/command/function/secret/index.js +1 -1
  16. package/dist/command/function/secret/remove.js +2 -2
  17. package/dist/command/function/secret/run.js +1 -1
  18. package/dist/command/function/secret/set.js +1 -1
  19. package/dist/command/function/status.js +26 -9
  20. package/dist/command/{delete.js → game/delete.js} +14 -13
  21. package/dist/command/game/index.js +12 -0
  22. package/dist/command/server/index.js +3 -4
  23. package/dist/command/server/key/create.js +1 -1
  24. package/dist/command/server/key/index.js +1 -1
  25. package/dist/command/server/key/revoke.js +1 -1
  26. package/dist/command/server/key/run.js +1 -1
  27. package/dist/command/unstable/index.js +23 -0
  28. package/dist/command/value/get.js +1 -1
  29. package/dist/command/value/index.js +6 -6
  30. package/dist/command/value/list.js +1 -1
  31. package/dist/command/value/remove.js +2 -2
  32. package/dist/command/value/set.js +1 -1
  33. package/dist/command/value/usage.js +16 -6
  34. package/dist/command/wire/index.js +4 -5
  35. package/dist/commands.js +3 -29
  36. package/dist/config/code.js +7 -3
  37. package/dist/config/limit.js +4 -0
  38. package/dist/phrase/deploy.js +1 -1
  39. package/dist/phrase/function.js +71 -17
  40. package/dist/phrase/game.js +1 -1
  41. package/dist/phrase/index.js +1 -0
  42. package/dist/phrase/pack.js +9 -0
  43. package/dist/phrase/server.js +4 -4
  44. package/dist/phrase/unstable.js +6 -0
  45. package/dist/phrase/value.js +4 -4
  46. package/dist/runner/entry.js +59 -3
  47. package/dist/schema/check/workflow.js +0 -21
  48. package/dist/schema/workflow.js +6 -28
  49. package/dist/serve/runner.js +9 -2
  50. package/dist/util/zip.js +5 -0
  51. package/npm-shrinkwrap.json +33 -33
  52. package/package.json +1 -1
@@ -6,6 +6,10 @@ const MB = 1024 * 1024;
6
6
  // [declare]
7
7
  // the most files in the zip.
8
8
  export const FILES = 10000;
9
+ // the most entries in the zip, files and folders together (the subscriber's
10
+ // MAX_ENTRY_COUNT), so a deep tree of folders can't pass the files' limit
11
+ // and fail there.
12
+ export const ENTRIES = 20000;
9
13
  // the largest file, uncompressed.
10
14
  export const FILE_SIZE = 64 * MB;
11
15
  // everything packed, uncompressed.
@@ -158,7 +158,7 @@ export function uploadFailed(status) {
158
158
  }
159
159
  // [function]
160
160
  export function deployRateLimited(version) {
161
- return blocks(`v${version} was deployed in the last 5 minutes.`, "Wait, then deploy again.");
161
+ return blocks(`v${version} was deployed in the last 5 minutes, or this account deployed 30 times in the last hour.`, "Wait, then deploy again.");
162
162
  }
163
163
  // [function]
164
164
  export function waitTimedOut() {
@@ -1,4 +1,4 @@
1
- // a game's function: `arc function`, its secrets, and the function as arc
1
+ // a game's function: `arc unstable function`, its secrets, and the function as arc
2
2
  // build and arc serve run it.
3
3
  // [import]
4
4
  import { blocks } from "./internal.js";
@@ -17,16 +17,20 @@ export function secretRemoveQuestion({ channel, name, }) {
17
17
  // a paused function, or a pause on a channel with no function to stop.
18
18
  export function functionPaused({ channel, function: has, }) {
19
19
  if (has === false) {
20
- return blocks(`Paused ${channel}, which has no function yet.`, `A release with one stays stopped until \`arc function resume --${channel}\`.`);
20
+ return blocks(`Paused ${channel}, which has no function yet.`, `A release with one stays stopped until \`arc unstable function resume --${channel}\`.`);
21
21
  }
22
22
  return `Paused the game's function on ${channel}. It stops answering within a minute.`;
23
23
  }
24
24
  // [function]
25
- // why a function is paused, as a status says it.
26
- export function functionPause(reason) {
25
+ // why a function is paused, as a status says it. A limit's pause ends by
26
+ // itself, as the day or the month turns (UTC): `resumes` is when, as the
27
+ // API states it.
28
+ export function functionPause(reason, resumes) {
27
29
  const reasons = {
28
30
  arcadible: "paused by Arcadible",
29
- limit: "its allowance is spent",
31
+ limit: resumes
32
+ ? `at a limit until ${resumes.slice(0, 10)} (UTC)`
33
+ : "at a limit",
30
34
  owner: "paused by you",
31
35
  };
32
36
  return reasons[reason] ?? "paused";
@@ -35,8 +39,8 @@ export function functionPause(reason) {
35
39
  // a channel's function, as a status says it: that there's none, when its
36
40
  // live build has none or it has no build, with any pause that waits for one;
37
41
  // else why it's paused, or that it's running.
38
- export function functionState({ function: has, paused, }) {
39
- const pause = paused ? functionPause(paused) : null;
42
+ export function functionState({ function: has, paused, resumes_at: resumes, }) {
43
+ const pause = paused ? functionPause(paused, resumes) : null;
40
44
  if (has === false) {
41
45
  return pause ? `no function, ${pause}` : "no function";
42
46
  }
@@ -54,11 +58,38 @@ export function functionResumed({ channel, lifted, paused, }) {
54
58
  return `Resumed the game's function on ${channel}. It answers again within a minute.`;
55
59
  }
56
60
  // [function]
57
- // a game's function's month, against its allowance, its channels together.
58
- export function functionMonth({ allowance, requests, }) {
59
- return allowance === null
60
- ? `${requests} requests this month.`
61
- : `${requests} of ${allowance} requests this month, both channels together.`;
61
+ // what holds a game's function, as a status says it under its channels:
62
+ // the game's requests today against its own limit for a day, then its
63
+ // month and its account's, every game's together, against its plan's, then
64
+ // the CPU time of both, which no limit holds. Each number is the API's;
65
+ // null is no limit.
66
+ export function functionUsage({ day, month, pool, }) {
67
+ const today = day.allowance === null
68
+ ? `${day.requests} requests today, with no limit for a day.`
69
+ : `${day.requests} of ${day.allowance} requests today, both channels together.`;
70
+ const account = pool.allowance === null
71
+ ? `Your account's games together: ${pool.requests}, with no limit.`
72
+ : `Your account's games together: ${pool.requests} of ${pool.allowance}.`;
73
+ const cpu = month.cpu && pool.cpu
74
+ ? `\nCPU time this month: ${month.cpu}. Your account's games together: ${pool.cpu}.`
75
+ : "";
76
+ return `${today}\n${month.requests} requests this month. ${account}${cpu}`;
77
+ }
78
+ // [function]
79
+ // a function's CPU time, given in milliseconds, as it's read: "640 ms",
80
+ // "1.2 s", "4.5 min", "1,234.5 h".
81
+ export function cpuTime(ms) {
82
+ const one = (value) => value.toLocaleString("en-US", {
83
+ maximumFractionDigits: 1,
84
+ minimumFractionDigits: 1,
85
+ });
86
+ if (ms < 1000)
87
+ return `${Math.round(ms)} ms`;
88
+ if (ms < 60 * 1000)
89
+ return `${one(ms / 1000)} s`;
90
+ if (ms < 60 * 60 * 1000)
91
+ return `${one(ms / 60 / 1000)} min`;
92
+ return `${one(ms / 60 / 60 / 1000)} h`;
62
93
  }
63
94
  // [function]
64
95
  // a resume with no pause of the owner's to lift, and one of another's: who
@@ -68,7 +99,7 @@ export function functionPauseReserved({ channel, paused, }) {
68
99
  return blocks(`The game's function is paused by Arcadible on ${channel}.`, "Only Arcadible can resume it.");
69
100
  }
70
101
  if (paused === "limit") {
71
- return blocks(`The game's function has spent its allowance on ${channel}.`, "It resumes by itself when the allowance renews.");
102
+ return blocks(`The game's function is at a limit on ${channel}.`, "It resumes by itself as the day or the month turns (UTC): `arc unstable function status` says when.");
72
103
  }
73
104
  return `The game's function is paused on ${channel}, and not by you.`;
74
105
  }
@@ -80,7 +111,7 @@ export function secretSet({ channel, name, }) {
80
111
  // a secret a build declares that has no value on the channel it goes to,
81
112
  // which `arc deploy` warns of (not yet: action/predeploy/secrets.ts).
82
113
  export function secretUnset({ channel, name, }) {
83
- return `Secret ${name} has no value on ${channel}.\nSet it with \`arc function secret set ${name} --${channel}\`.`;
114
+ return `Secret ${name} has no value on ${channel}.\nSet it with \`arc unstable function secret set ${name} --${channel}\`.`;
84
115
  }
85
116
  // [function]
86
117
  export function secretRemoved({ channel, name, }) {
@@ -93,11 +124,11 @@ export function secretNone() {
93
124
  // [function]
94
125
  // the most secrets a game has for a channel, when one more is asked for.
95
126
  export function secretLimitReached(channel) {
96
- return blocks(`Sixteen secrets already for ${channel}.`, "Remove one with `arc function secret remove <name>`, then try again.");
127
+ return blocks(`Sixteen secrets already for ${channel}.`, "Remove one with `arc unstable function secret remove <name>`, then try again.");
97
128
  }
98
129
  // [function]
99
130
  export function secretNotFound({ channel, name, }) {
100
- return blocks(`Secret not found: ${name}`, `It isn't set for ${channel}.\n\`arc function secret list\` shows the game's secrets.`);
131
+ return blocks(`Secret not found: ${name}`, `It isn't set for ${channel}.\n\`arc unstable function secret list\` shows the game's secrets.`);
101
132
  }
102
133
  // [function]
103
134
  export function secretNameInvalid() {
@@ -109,7 +140,7 @@ export function secretNameInvalid() {
109
140
  }
110
141
  // [function]
111
142
  export function secretValueInvalid() {
112
- return blocks("A secret's value is 1 to 4096 bytes, on standard input.", 'Such as: printf %s "$EXAMPLE_KEY" | arc function secret set EXAMPLE_KEY');
143
+ return blocks("A secret's value is 1 to 4096 bytes, on standard input.", 'Such as: printf %s "$EXAMPLE_KEY" | arc unstable function secret set EXAMPLE_KEY');
113
144
  }
114
145
  // [function]
115
146
  // what's asked when a secret's value is typed.
@@ -153,3 +184,26 @@ export function runnerFailed(message) {
153
184
  export function runnerLabel() {
154
185
  return "Function:";
155
186
  }
187
+ // [function]
188
+ // no entry that matches: what's kept, and where else lines are printed.
189
+ export function functionLogsNone({ filtered }) {
190
+ return blocks(filtered ? "No logs that match." : "No logs yet.", "Arcadible keeps a function's logs for 7 days.\nUnder `arc serve`, its lines are printed where it runs.");
191
+ }
192
+ // [function]
193
+ export function functionLogsSinceInvalid(text) {
194
+ return blocks(`Not a time to read from: ${text}`, "--since takes a span back from now (10m, 2h, 1d), or an ISO time.");
195
+ }
196
+ // [function]
197
+ export function functionLogsVersionInvalid(text) {
198
+ return blocks(`Not a version: ${text}`, "--release takes a release's version, such as 1.2.0.");
199
+ }
200
+ // [function]
201
+ // a sixth follow of a game's logs, while five are open.
202
+ export function functionLogsBusy() {
203
+ return blocks("The game's logs are followed five times already.", "Stop one of them, then try again.");
204
+ }
205
+ // [function]
206
+ // the logs' refusal, which the CLI didn't expect: its status and code.
207
+ export function functionLogsRefused({ code, status, }) {
208
+ return `Unable to read the function's logs (${status}${code ? `, ${code}` : ""}).`;
209
+ }
@@ -1,4 +1,4 @@
1
- // a game on Arcadible: arc delete.
1
+ // a game on Arcadible: arc unstable game delete.
2
2
  // [import]
3
3
  import { cmdInit } from "./common.js";
4
4
  import { blocks, cmdWhoami } from "./internal.js";
@@ -14,3 +14,4 @@ export * from "./pack.js";
14
14
  export * from "./serve.js";
15
15
  export * from "./server.js";
16
16
  export * from "./value.js";
17
+ export * from "./unstable.js";
@@ -64,6 +64,15 @@ export function packageTooManyFiles(count) {
64
64
  return `Package has more than ${count.toLocaleString("en-US")} files.`;
65
65
  }
66
66
  // [function]
67
+ export function packageTooManyEntries(count) {
68
+ return blocks(`Package has more than ${count.toLocaleString("en-US")} files and folders together.`, "Put the files in fewer folders.");
69
+ }
70
+ // [function]
71
+ // a file whose name a URL reads as another path, which no address reaches.
72
+ export function packagePathInvalid(name) {
73
+ return blocks(`'${name}' isn't a name a browser can ask for: it has a '.' or '..' folder, a backslash, or %2e, %2f, or %5c.`, "Rename it, and the paths that load it.");
74
+ }
75
+ // [function]
67
76
  export function packageUncompressedTooLarge(size) {
68
77
  return `Package is larger than ${size} MB uncompressed.`;
69
78
  }
@@ -1,4 +1,4 @@
1
- // `arc server`: a game's own servers, and their keys.
1
+ // `arc unstable server`: a game's own servers, and their keys.
2
2
  // [import]
3
3
  import { blocks } from "./internal.js";
4
4
  // [function]
@@ -17,11 +17,11 @@ export function keyNone() {
17
17
  // [function]
18
18
  // the most keys a game has for a channel, when one more is asked for.
19
19
  export function keyLimitReached(channel) {
20
- return blocks(`Five keys already for ${channel}.`, "Revoke one with `arc server key revoke <id>`, then try again.");
20
+ return blocks(`Five keys already for ${channel}.`, "Revoke one with `arc unstable server key revoke <id>`, then try again.");
21
21
  }
22
22
  // [function]
23
23
  export function keyNotFound(id) {
24
- return blocks(`Key not found: ${id}`, "It was revoked already, or isn't this game's.\n`arc server key list` shows the game's keys.");
24
+ return blocks(`Key not found: ${id}`, "It was revoked already, or isn't this game's.\n`arc unstable server key list` shows the game's keys.");
25
25
  }
26
26
  // [function]
27
27
  export function keyNameInvalid() {
@@ -32,7 +32,7 @@ export function keyRevokeQuestion() {
32
32
  return "Revoke this key? Servers using it stop working at once, and it can't be undone.";
33
33
  }
34
34
  // [function]
35
- // under `arc server`'s help: what it isn't, a letter away.
35
+ // under `arc unstable server`'s help: what it isn't, a letter away.
36
36
  export function serverNotServe() {
37
37
  return "To run your game on this machine, use `arc serve`.";
38
38
  }
@@ -0,0 +1,6 @@
1
+ // `arc unstable`: the commands for what isn't released yet.
2
+ // [function]
3
+ // the end of `arc unstable --help`.
4
+ export function unstableEpilogue() {
5
+ return "These commands may change or go away in any release.";
6
+ }
@@ -5,9 +5,9 @@ export function valueKeyInvalid(key) {
5
5
  return blocks(`Not a key: ${key}`, "A key is 1 to 128 letters, digits, -, _, ., and /.");
6
6
  }
7
7
  // [function]
8
- // `arc value set` given neither a key nor a folder, or both.
8
+ // `arc unstable value set` given neither a key nor a folder, or both.
9
9
  export function valueSetWhat() {
10
- return blocks("Name a key, or a folder.", "`arc value set <key> --file value.json` sets one value, and `arc value set --dir .arcadible-data/values` sets a value for each .json file in a folder.");
10
+ return blocks("Name a key, or a folder.", "`arc unstable value set <key> --file value.json` sets one value, and `arc unstable value set --dir .arcadible-data/values` sets a value for each .json file in a folder.");
11
11
  }
12
12
  // [function]
13
13
  // a value that isn't JSON: `source` is its file, or standard input.
@@ -28,7 +28,7 @@ export function valueTooLarge(key) {
28
28
  }
29
29
  // [function]
30
30
  export function valueFull(channel) {
31
- return blocks(`The developer's values on ${channel} are full.`, "They hold 10,000 keys and 64 MB. Remove some with `arc value remove <key>`, then try again.");
31
+ return blocks(`The developer's values on ${channel} are full.`, "They hold 10,000 keys and 64 MB. Remove some with `arc unstable value remove <key>`, then try again.");
32
32
  }
33
33
  // [function]
34
34
  export function valueSet({ channel, keys, }) {
@@ -39,7 +39,7 @@ export function valueSet({ channel, keys, }) {
39
39
  }
40
40
  // [function]
41
41
  export function valueNotFound({ channel, key, }) {
42
- return blocks(`Value not found: ${key}`, `It isn't set on ${channel}.\n\`arc value list --${channel}\` shows what is.`);
42
+ return blocks(`Value not found: ${key}`, `It isn't set on ${channel}.\n\`arc unstable value list --${channel}\` shows what is.`);
43
43
  }
44
44
  // [function]
45
45
  export function valueRemoveQuestion({ channel, key, }) {
@@ -25,14 +25,58 @@ export const FUNCTION_MODULE = "function.js";
25
25
  // address in a `process.env` of the entry's making. A function's secrets
26
26
  // arrive as a header too (x-arcadible-secrets, opened by the dispatcher),
27
27
  // and are added to what the code is given, `env`. Neither header reaches
28
- // the developer's code.
28
+ // the developer's code. Under arc serve they're the script's own bindings,
29
+ // named by ARCADIBLE_SECRETS. Whatever the code logs has the secrets' values
30
+ // it was given hidden, `[secret NAME]`, and an error it throws that holds
31
+ // one is logged hidden and thrown as one that doesn't, so a function's logs
32
+ // never keep a secret (plan/FUNCTION-LOGS.md, What's redacted).
29
33
  export const ENTRY = `import handler from "./${FUNCTION_MODULE}";
30
34
  const CLAIM = "x-arcadible-claim";
31
35
  const SECRETS = "x-arcadible-secrets";
32
36
  const API = "https://api.arcadible.com/v1/server";
37
+ // a secret shorter than this isn't hidden in what's logged: it would be
38
+ // found in ordinary words
39
+ const SHORTEST = 8;
33
40
  // the newest claim, and arc serve's address under it
34
41
  let claimed = null;
35
42
  let serve = null;
43
+ // the secrets' values the code has been given, each with its name, longest
44
+ // first, so one inside another is hidden as the longer
45
+ const hidden = [];
46
+ const remember = (values) => {
47
+ let added = false;
48
+ for (const [name, value] of Object.entries(values)) {
49
+ if (typeof value !== "string" || value.length < SHORTEST) continue;
50
+ if (hidden.some(([known]) => known === value)) continue;
51
+ hidden.push([value, name]);
52
+ added = true;
53
+ }
54
+ if (added) hidden.sort((a, b) => b[0].length - a[0].length);
55
+ };
56
+ const hide = (text) => {
57
+ for (const [value, name] of hidden) text = text.split(value).join("[secret " + name + "]");
58
+ return text;
59
+ };
60
+ // one of console's arguments with any secret in it hidden: a string as it
61
+ // is, an error as its stack, anything else as JSON, and as the console
62
+ // would show it when no secret's in it
63
+ const shown = (value) => {
64
+ if (typeof value === "string") return hide(value);
65
+ let text;
66
+ try {
67
+ text = value instanceof Error ? String(value.stack ?? value) : JSON.stringify(value);
68
+ } catch {
69
+ return value;
70
+ }
71
+ if (typeof text !== "string") return value;
72
+ const safe = hide(text);
73
+ return safe === text ? value : safe;
74
+ };
75
+ for (const level of ["debug", "error", "info", "log", "trace", "warn"]) {
76
+ const original = console[level];
77
+ if (typeof original !== "function") continue;
78
+ console[level] = (...args) => original.apply(console, hidden.length > 0 ? args.map(shown) : args);
79
+ }
36
80
  globalThis[Symbol.for("arcadible.function.api")] = {
37
81
  version: 1,
38
82
  async fetch(path, init = {}) {
@@ -68,7 +112,12 @@ export default {
68
112
  if (secrets) {
69
113
  const text = atob(secrets.replace(/-/g, "+").replace(/_/g, "/"));
70
114
  const bytes = Uint8Array.from(text, (char) => char.charCodeAt(0));
71
- given = { ...env, ...JSON.parse(new TextDecoder().decode(bytes)) };
115
+ const opened = JSON.parse(new TextDecoder().decode(bytes));
116
+ remember(opened);
117
+ given = { ...env, ...opened };
118
+ }
119
+ if (typeof env.ARCADIBLE_SECRETS === "string") {
120
+ remember(Object.fromEntries(env.ARCADIBLE_SECRETS.split(",").map((name) => [name, env[name]])));
72
121
  }
73
122
  if (claim || secrets) {
74
123
  const headers = new Headers(request.headers);
@@ -79,7 +128,14 @@ export default {
79
128
  if (typeof handler?.fetch !== "function") {
80
129
  return new Response("The function's default export has no fetch(request).\\n", { status: 500 });
81
130
  }
82
- return handler.fetch(request, given, ctx);
131
+ try {
132
+ return await handler.fetch(request, given, ctx);
133
+ } catch (err) {
134
+ const text = String(err?.stack ?? err);
135
+ if (hidden.length === 0 || hide(text) === text) throw err;
136
+ console.error(err);
137
+ throw new Error("The function threw an error holding a secret: it's logged with the secret hidden.");
138
+ }
83
139
  },
84
140
  };
85
141
  `;
@@ -1,5 +1,4 @@
1
1
  // [import]
2
- import { readdirSync } from "node:fs";
3
2
  import { isAbsolute, join, relative, resolve, sep } from "node:path";
4
3
  // [import]
5
4
  import fs from "fs-extra";
@@ -35,23 +34,3 @@ export function avoids(root, target, name) {
35
34
  .split(sep)
36
35
  .includes(name);
37
36
  }
38
- // [function]
39
- // whether an existing `target` has `file` at its root. A directory that
40
- // doesn't exist yet, because a build step creates it, passes.
41
- export function hasFile(root, target, file) {
42
- return !exists(root, target) || exists(join(root, target), file);
43
- }
44
- // [function]
45
- // whether `target` has none of `names` at its root.
46
- export function lacksFiles(root, target, names) {
47
- return names.every((name) => !exists(join(root, target), name));
48
- }
49
- // [function]
50
- // whether an existing `target` lacks a folder named `name` at its root, in any
51
- // letter case, since a build's paths are case-sensitive once it's served.
52
- export function lacksFolder(root, target, name) {
53
- if (!exists(root, target)) {
54
- return true;
55
- }
56
- return !readdirSync(join(root, target), { withFileTypes: true }).some((entry) => entry.isDirectory() && entry.name.toLowerCase() === name);
57
- }
@@ -3,19 +3,13 @@ import * as z from "zod";
3
3
  // [import]
4
4
  import { ISSUE } from "../config/code.js";
5
5
  import { buildCommand } from "../util/command.js";
6
- import { MEDIA, PACKAGED } from "../config/file.js";
6
+ import { MEDIA } from "../config/file.js";
7
7
  import { cmdInspect } from "../phrase/index.js";
8
8
  import { messages } from "./message.js";
9
9
  import { isTable } from "../util/objs.js";
10
- import { handle, title } from "../config/product.js";
11
- import { avoids as avoidsCheck, exists as existsCheck, hasFile as hasFileCheck, isInside as isInsideCheck, isRelative as isRelativeCheck, isRoot as isRootCheck, lacksFiles as lacksFilesCheck, lacksFolder as lacksFolderCheck, } from "./check/workflow.js";
10
+ import { avoids as avoidsCheck, exists as existsCheck, isInside as isInsideCheck, isRelative as isRelativeCheck, isRoot as isRootCheck, } from "./check/workflow.js";
12
11
  // [declare]
13
12
  const message = messages("workflow");
14
- const INDEX = "index.html";
15
- const RESERVED = [PACKAGED, MEDIA];
16
- // the folder every build's origin keeps for Arcadible's own files, such as
17
- // the script games include. arc pack checks it again after the build.
18
- const RESERVED_FOLDER = handle;
19
13
  // [function]
20
14
  // whether `build` runs anything, as `arc build` runs it.
21
15
  function hasBuild(build) {
@@ -36,8 +30,10 @@ function zBuild() {
36
30
  return z.union([z.string(), z.array(z.string())], { error: typeMessage });
37
31
  }
38
32
  // [function]
39
- // a directory inside the project with an index.html. Each check aborts the
40
- // rest when it fails, so one bad path gets one issue.
33
+ // a directory inside the project, which exists unless a build makes it.
34
+ // Only the path is checked: what's in it is the build's, checked by arc pack
35
+ // once it's built (package_index_missing, package_path_reserved). Each
36
+ // check aborts the rest when it fails, so one bad path gets one issue.
41
37
  function zDeployDir(root, { build }) {
42
38
  const field = "deploy_dir";
43
39
  return z
@@ -68,24 +64,6 @@ function zDeployDir(root, { build }) {
68
64
  `Run ${cmdInspect()} for details.`,
69
65
  ], ISSUE.PATH_INVALID),
70
66
  abort: true,
71
- })
72
- .refine((file) => hasFileCheck(root, file, INDEX), {
73
- ...message(field, [`Must have an ${INDEX} at its root.`], ISSUE.INDEX_MISSING),
74
- abort: true,
75
- })
76
- .refine((file) => lacksFilesCheck(root, file, RESERVED), {
77
- ...message(field, [
78
- `Must not have ${RESERVED.join(" or ")} at its root.`,
79
- `They're reserved for the files ${title} adds.`,
80
- ], ISSUE.PATH_INVALID),
81
- abort: true,
82
- })
83
- .refine((file) => lacksFolderCheck(root, file, RESERVED_FOLDER), {
84
- ...message(field, [
85
- `Must not have an ${RESERVED_FOLDER} folder at its root, in any letter case.`,
86
- `It's reserved for ${title}'s own files.`,
87
- ], ISSUE.PATH_INVALID),
88
- abort: true,
89
67
  });
90
68
  }
91
69
  // [function]
@@ -196,12 +196,19 @@ async function runtime(dir, onInstall) {
196
196
  // the manifest's, and to arc serve; only that worker reaches the network,
197
197
  // this machine included, which arc serve is on, and HTTPS hosts, checked
198
198
  // against the certificate authorities browsers trust. `secrets` are the
199
- // values the code is given, each by its name.
199
+ // values the code is given, each by its name, and named to the entry in
200
+ // ARCADIBLE_SECRETS.
200
201
  function config({ hosts, port, secrets, serve, }) {
201
202
  // each secret that has a value here, as the code's own binding
202
203
  const given = Object.entries(secrets)
203
204
  .map(([name, value]) => `, (name = ${JSON.stringify(name)}, text = ${JSON.stringify(value)})`)
204
205
  .join("");
206
+ // which bindings are secrets, so the entry hides their values in what the
207
+ // code logs, as it does on Arcadible
208
+ const names = Object.keys(secrets);
209
+ const named = names.length > 0
210
+ ? `, (name = "ARCADIBLE_SECRETS", text = ${JSON.stringify(names.join(","))})`
211
+ : "";
205
212
  return `using Workerd = import "/workerd/workerd.capnp";
206
213
  const config :Workerd.Config = (
207
214
  services = [
@@ -223,7 +230,7 @@ const runner :Workerd.Worker = (
223
230
  (name = "${FUNCTION_MODULE}", esModule = embed "${FUNCTION_MODULE}"),
224
231
  ],
225
232
  compatibilityDate = "${COMPATIBILITY_DATE}",
226
- bindings = [(name = "ARCADIBLE_SERVE", text = ${JSON.stringify(serve)})${given}],
233
+ bindings = [(name = "ARCADIBLE_SERVE", text = ${JSON.stringify(serve)})${given}${named}],
227
234
  globalOutbound = "outbound",
228
235
  );
229
236
  const outbound :Workerd.Worker = (
package/dist/util/zip.js CHANGED
@@ -51,6 +51,11 @@ export class Zip {
51
51
  }));
52
52
  }
53
53
  // [method]
54
+ // every entry in the zip, files and folders.
55
+ count() {
56
+ return this.zip.getEntries().length;
57
+ }
58
+ // [method]
54
59
  has(name) {
55
60
  return this.zip.getEntry(join(this.prefix, name)) !== null;
56
61
  }
@@ -44,7 +44,7 @@
44
44
  },
45
45
  "license": "Apache-2.0",
46
46
  "name": "arcadible",
47
- "version": "1.0.35"
47
+ "version": "1.0.37"
48
48
  },
49
49
  "node_modules/@asamuzakjp/css-color": {
50
50
  "dependencies": {
@@ -884,20 +884,6 @@
884
884
  "resolved": "https://registry.npmjs.org/@inquirer/core/-/core-10.3.2.tgz",
885
885
  "version": "10.3.2"
886
886
  },
887
- "node_modules/@inquirer/core/node_modules/wrap-ansi": {
888
- "dependencies": {
889
- "ansi-styles": "^4.0.0",
890
- "string-width": "^4.1.0",
891
- "strip-ansi": "^6.0.0"
892
- },
893
- "engines": {
894
- "node": ">=8"
895
- },
896
- "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==",
897
- "license": "MIT",
898
- "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz",
899
- "version": "6.2.0"
900
- },
901
887
  "node_modules/@inquirer/editor": {
902
888
  "dependencies": {
903
889
  "@inquirer/core": "^10.3.2",
@@ -1247,10 +1233,10 @@
1247
1233
  "engines": {
1248
1234
  "node": ">= 4"
1249
1235
  },
1250
- "integrity": "sha512-wCBiZ77u1tuWde6G/nfOtLaCTYcFDU5yCzARzK10y+rLhzYoL7a7yEemcopcc2Mzow7gZOIjnV2ym1NYmdiJOQ==",
1236
+ "integrity": "sha512-52N+Y4HRMOJmbLmr+DqO4iSRyyB7N52gm7PWCT6h0p978+oKbqHCB7gIJIwZvBUsjlSdWbrBFqUSmIFNZMpn0A==",
1251
1237
  "license": "MIT",
1252
- "resolved": "https://registry.npmjs.org/ignore/-/ignore-7.0.14.tgz",
1253
- "version": "7.0.14"
1238
+ "resolved": "https://registry.npmjs.org/ignore/-/ignore-7.0.16.tgz",
1239
+ "version": "7.0.16"
1254
1240
  },
1255
1241
  "node_modules/@typescript-eslint/parser": {
1256
1242
  "dependencies": {
@@ -1645,6 +1631,23 @@
1645
1631
  "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz",
1646
1632
  "version": "8.0.1"
1647
1633
  },
1634
+ "node_modules/cliui/node_modules/wrap-ansi": {
1635
+ "dependencies": {
1636
+ "ansi-styles": "^4.0.0",
1637
+ "string-width": "^4.1.0",
1638
+ "strip-ansi": "^6.0.0"
1639
+ },
1640
+ "engines": {
1641
+ "node": ">=10"
1642
+ },
1643
+ "funding": {
1644
+ "url": "https://github.com/chalk/wrap-ansi?sponsor=1"
1645
+ },
1646
+ "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==",
1647
+ "license": "MIT",
1648
+ "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz",
1649
+ "version": "7.0.0"
1650
+ },
1648
1651
  "node_modules/color-convert": {
1649
1652
  "dependencies": {
1650
1653
  "color-name": "~1.1.4"
@@ -2158,10 +2161,10 @@
2158
2161
  "version": "6.0.2"
2159
2162
  },
2160
2163
  "node_modules/graceful-fs": {
2161
- "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==",
2162
- "license": "ISC",
2163
- "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz",
2164
- "version": "4.2.11"
2164
+ "integrity": "sha512-iuyGF2E4oafQfPsRrG2wtY2ILupMhvtdrhzrxB+0VcjsPpSPttpfYdjnGFGsTi5MaJFjI1jOKHPQ6UTbTj9TAw==",
2165
+ "license": "BlueOak-1.0.0",
2166
+ "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.12.tgz",
2167
+ "version": "4.2.12"
2165
2168
  },
2166
2169
  "node_modules/hashery": {
2167
2170
  "dependencies": {
@@ -2540,10 +2543,10 @@
2540
2543
  "funding": {
2541
2544
  "url": "https://github.com/sponsors/isaacs"
2542
2545
  },
2543
- "integrity": "sha512-nFQuYSTVrGvysVBps5Ih+0BdnYFN/Cj3C816r6+p7yK+FHrVLGE4O4N9AFwykrlNlvM2HYt+Rad1Uiro6h88Ig==",
2546
+ "integrity": "sha512-KCFkfyjqerNlSstjlhIGNXIKZGA/6O4V4RlhZ+Dsr621SPPw0mzlypE9D9ZOoPiVefHID+j7/XuMMlqfD/F60Q==",
2544
2547
  "license": "BlueOak-1.0.0",
2545
- "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-11.0.8.tgz",
2546
- "version": "11.0.8"
2548
+ "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-11.0.9.tgz",
2549
+ "version": "11.0.9"
2547
2550
  },
2548
2551
  "node_modules/mp4box": {
2549
2552
  "engines": {
@@ -3134,15 +3137,12 @@
3134
3137
  "strip-ansi": "^6.0.0"
3135
3138
  },
3136
3139
  "engines": {
3137
- "node": ">=10"
3138
- },
3139
- "funding": {
3140
- "url": "https://github.com/chalk/wrap-ansi?sponsor=1"
3140
+ "node": ">=8"
3141
3141
  },
3142
- "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==",
3142
+ "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==",
3143
3143
  "license": "MIT",
3144
- "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz",
3145
- "version": "7.0.0"
3144
+ "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz",
3145
+ "version": "6.2.0"
3146
3146
  },
3147
3147
  "node_modules/ws": {
3148
3148
  "engines": {
@@ -3267,5 +3267,5 @@
3267
3267
  }
3268
3268
  },
3269
3269
  "requires": true,
3270
- "version": "1.0.35"
3270
+ "version": "1.0.37"
3271
3271
  }
package/package.json CHANGED
@@ -68,5 +68,5 @@
68
68
  "test": "tsc && npm run lint && node --test \"test/**/*.test.js\" \"test/**/*.test.mjs\""
69
69
  },
70
70
  "type": "module",
71
- "version": "1.0.35"
71
+ "version": "1.0.37"
72
72
  }