arcadible 1.0.49 → 1.0.51

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 (69) hide show
  1. package/README.md +5 -1
  2. package/dist/action/deploy/result.js +3 -3
  3. package/dist/action/deploy/tool-git.js +1 -1
  4. package/dist/action/deploy/tool.js +1 -1
  5. package/dist/action/deploy/wait.js +1 -1
  6. package/dist/action/function/logs.js +4 -4
  7. package/dist/action/function/tool.js +42 -27
  8. package/dist/action/key/tool.js +10 -4
  9. package/dist/action/secret/tool.js +2 -1
  10. package/dist/action/validate/unknown.js +1 -1
  11. package/dist/action/value/local.js +78 -0
  12. package/dist/action/value/tool.js +81 -35
  13. package/dist/action/wire/tool.js +1 -1
  14. package/dist/api.js +1 -0
  15. package/dist/cli/command.js +13 -1
  16. package/dist/cli/options.js +7 -0
  17. package/dist/cli/prompt.js +1 -1
  18. package/dist/command/deploy/report.js +5 -5
  19. package/dist/command/function/index.js +4 -4
  20. package/dist/command/function/logs.js +4 -4
  21. package/dist/command/function/pause.js +1 -1
  22. package/dist/command/function/resume.js +1 -1
  23. package/dist/command/function/run.js +1 -1
  24. package/dist/command/function/secret/index.js +1 -1
  25. package/dist/command/function/secret/list.js +2 -1
  26. package/dist/command/function/secret/remove.js +2 -2
  27. package/dist/command/function/secret/run.js +1 -1
  28. package/dist/command/function/secret/set.js +1 -1
  29. package/dist/command/function/status.js +7 -36
  30. package/dist/command/function/usage.js +64 -0
  31. package/dist/command/game/delete.js +2 -2
  32. package/dist/command/game/index.js +2 -2
  33. package/dist/command/open.js +1 -1
  34. package/dist/command/play.js +1 -1
  35. package/dist/command/server/index.js +3 -3
  36. package/dist/command/server/key/create.js +4 -4
  37. package/dist/command/server/key/index.js +1 -1
  38. package/dist/command/server/key/list.js +3 -2
  39. package/dist/command/server/key/revoke.js +1 -1
  40. package/dist/command/server/key/run.js +1 -1
  41. package/dist/command/unstable/index.js +8 -13
  42. package/dist/command/value/get.js +12 -8
  43. package/dist/command/value/index.js +4 -4
  44. package/dist/command/value/list.js +14 -6
  45. package/dist/command/value/remove.js +22 -11
  46. package/dist/command/value/run.js +40 -0
  47. package/dist/command/value/set.js +27 -22
  48. package/dist/command/value/usage.js +47 -39
  49. package/dist/command/wire/index.js +1 -2
  50. package/dist/commands.js +28 -0
  51. package/dist/config/code.js +4 -2
  52. package/dist/config/limit.js +5 -5
  53. package/dist/config/retry.js +2 -0
  54. package/dist/parser/project.js +2 -1
  55. package/dist/phrase/common.js +12 -6
  56. package/dist/phrase/deploy.js +4 -3
  57. package/dist/phrase/function.js +27 -21
  58. package/dist/phrase/game.js +3 -3
  59. package/dist/phrase/pack.js +4 -1
  60. package/dist/phrase/serve.js +2 -2
  61. package/dist/phrase/server.js +10 -5
  62. package/dist/phrase/value.js +50 -16
  63. package/dist/schema/client.js +11 -6
  64. package/dist/serve/values.js +2 -2
  65. package/dist/util/output.js +11 -4
  66. package/dist/util/schema.js +5 -3
  67. package/dist/util/time.js +5 -0
  68. package/npm-shrinkwrap.json +2 -2
  69. package/package.json +2 -1
@@ -1,10 +1,13 @@
1
1
  // [import]
2
2
  import { defineCommand } from "../../cli/command.js";
3
- import { valueSet } from "../../phrase/index.js";
3
+ import { ARGUMENT_INVALID } from "../../config/code.js";
4
+ import { valueSet, valueSetWhat } from "../../phrase/index.js";
5
+ import { ArcError } from "../../util/error.js";
4
6
  import { p } from "../../util/log.js";
5
- import { CHANNEL, CWD, JSON_OUTPUT, QUIET } from "../../cli/options.js";
6
- import { run } from "../function/secret/run.js";
7
- import { set } from "../../action/value/tool.js";
7
+ import { CHANNEL_VALUES, CWD, JSON_OUTPUT, QUIET } from "../../cli/options.js";
8
+ import { run } from "./run.js";
9
+ import { set, valueOf } from "../../action/value/tool.js";
10
+ import { setLocal } from "../../action/value/local.js";
8
11
  // [function]
9
12
  // all of standard input, as text: a value's JSON, piped in. At a terminal
10
13
  // there's none to read, which fails as empty input does.
@@ -26,16 +29,10 @@ export default defineCommand({
26
29
  name: "set",
27
30
  options: {
28
31
  file: {
29
- alias: "f",
30
32
  describe: "Read the value's JSON from a file",
31
33
  type: "string",
32
34
  },
33
- dir: {
34
- alias: "d",
35
- describe: "Set a value for each .json file in a folder",
36
- type: "string",
37
- },
38
- ...CHANNEL,
35
+ ...CHANNEL_VALUES,
39
36
  json: JSON_OUTPUT,
40
37
  quiet: QUIET,
41
38
  cwd: CWD,
@@ -45,18 +42,26 @@ export default defineCommand({
45
42
  describe: "The value's key, such as daily/2026-11-12",
46
43
  type: "string",
47
44
  },
45
+ value: {
46
+ describe: "The value's JSON, else from --file or standard input",
47
+ type: "string",
48
+ },
48
49
  },
49
50
  run(argv, aborting) {
50
- const what = argv.key ?? `--dir ${argv.dir ?? "<folder>"}`;
51
- return run(argv, aborting, (current, conf) => set(current, {
52
- ...conf,
53
- dir: argv.dir,
54
- file: argv.file,
55
- input,
56
- key: argv.key,
57
- }), (done) => {
58
- p(valueSet(done));
59
- }, `arc unstable value set ${what}`);
51
+ const given = { file: argv.file, input, value: argv.value };
52
+ return run(argv, aborting, {
53
+ // the project's own: one value, by its key
54
+ local: async (root) => {
55
+ if (argv.key === undefined) {
56
+ throw new ArcError(ARGUMENT_INVALID, valueSetWhat());
57
+ }
58
+ return setLocal(root, argv.key, await valueOf(root, given));
59
+ },
60
+ remote: (current, conf) => set(current, { ...conf, ...given, key: argv.key }),
61
+ shown: (done) => {
62
+ p(valueSet(done));
63
+ },
64
+ });
60
65
  },
61
- summary: "Set a value, its JSON from a file or standard input",
66
+ summary: "Set a value, or send them all to a channel",
62
67
  });
@@ -1,68 +1,76 @@
1
1
  // [import]
2
2
  import { defineCommand } from "../../cli/command.js";
3
- import { p } from "../../util/log.js";
4
- import { CHANNEL, CWD, JSON_OUTPUT, QUIET } from "../../cli/options.js";
3
+ import { nlp, p } from "../../util/log.js";
4
+ import { CHANNEL_SHOWS, CWD, JSON_OUTPUT, QUIET } from "../../cli/options.js";
5
5
  import { run } from "../function/secret/run.js";
6
6
  import { table } from "../../util/table.js";
7
7
  import { valueHolds, valueSize } from "../../phrase/index.js";
8
8
  import { usage } from "../../action/value/tool.js";
9
- // [declare]
10
- // each scope as it's said: a player's limits are each player's own.
11
- const NAMES = {
12
- developer: "developer",
13
- game: "game",
14
- player: "players",
15
- server: "server",
16
- };
17
9
  // [function]
10
+ // a count as it's read: 1,284.
11
+ function count(value) {
12
+ return value.toLocaleString("en-US");
13
+ }
18
14
  // [function]
19
- // the scopes as a table. A player's row counts every player's together, and
20
- // its limit is what each may hold, so the most any one holds is beside it.
21
- function rows(scopes) {
15
+ // each channel's scopes as a table, a row a scope, each by its own name. A
16
+ // player's row counts every player's together, and its limit is what each
17
+ // may hold, so the most any one holds is beside it.
18
+ function rows(channels) {
22
19
  return table([
23
- ["SCOPE", "KEYS", "SIZE", "MAY HOLD"],
24
- ...scopes.map((each) => {
20
+ ["CHANNEL", "SCOPE", "KEYS", "SIZE", "MAY HOLD"],
21
+ ...channels.flatMap(({ channel, scopes }) => scopes.map((each) => {
25
22
  const players = each.scope === "player";
26
- const limit = valueHolds(each);
23
+ const limit = valueHolds(each.limit);
27
24
  return [
28
- NAMES[each.scope] ?? each.scope,
25
+ channel,
26
+ each.scope,
29
27
  players
30
- ? `${each.keys} (${each.owners} ${each.owners === 1 ? "player" : "players"}, ${each.keys_most} at most)`
31
- : String(each.keys),
28
+ ? `${count(each.keys)} (${count(each.owners)} ${each.owners === 1 ? "player" : "players"}, ${count(each.owner_max.keys)} at most)`
29
+ : count(each.keys),
32
30
  players
33
- ? `${valueSize(each.bytes)} (${valueSize(each.bytes_most)} at most)`
31
+ ? `${valueSize(each.bytes)} (${valueSize(each.owner_max.bytes)} at most)`
34
32
  : valueSize(each.bytes),
35
33
  players && limit !== "no limit" ? `${limit} each` : limit,
36
34
  ];
37
- }),
35
+ })),
38
36
  ]);
39
37
  }
40
38
  // [function]
41
- // the game's clients' calls: this channel's today, and the game's against
42
- // its own limit for a day, which both channels share and the day (UTC)
43
- // renews; then its month, and its account's, every game's together,
44
- // against its plan's. Each number is the API's; null is no limit.
45
- function called(calls) {
46
- const n = (count) => count.toLocaleString("en-US");
47
- const today = calls.allowance === null
48
- ? `${n(calls.used)} for the day, with no limit.`
49
- : `${n(calls.used)} of ${n(calls.allowance)} for the day, both channels together.`;
50
- const account = calls.pool_allowance === null
51
- ? `Your account's games together: ${n(calls.pool_used)}, with no limit.`
52
- : `Your account's games together: ${n(calls.pool_used)} of ${n(calls.pool_allowance)}.`;
53
- return `Calls from the game today: ${n(calls.reads)} reads, ${n(calls.writes)} writes on ${calls.channel}. ${today}\n${n(calls.month_used)} calls this month. ${account}`;
39
+ // the game's clients' calls: the game's today, both channels together,
40
+ // against its own limit for a day, which the day (UTC) renews, with each
41
+ // channel's reads and writes under it; then its month, and its account's,
42
+ // every game's together, against its plan's: a figure a line, what makes it
43
+ // up under it. Each number is the API's; null is no limit.
44
+ function called({ account, channels, month, today }) {
45
+ if (!account || !month || !today) {
46
+ return null;
47
+ }
48
+ return [
49
+ today.allowance === null
50
+ ? `${count(today.calls)} calls today, with no limit for a day`
51
+ : `${count(today.calls)} of ${count(today.allowance)} calls today, both channels together`,
52
+ ...channels.map(({ channel, today: own }) => own
53
+ ? ` ${channel}: ${count(own.reads)} reads, ${count(own.writes)} writes`
54
+ : ` ${channel}: none`),
55
+ `${count(month.calls)} calls this month`,
56
+ account.allowance === null
57
+ ? ` Your account's games together: ${count(account.calls)}, with no limit`
58
+ : ` Your account's games together: ${count(account.calls)} of ${count(account.allowance)}`,
59
+ ].join("\n");
54
60
  }
55
61
  // [export]
56
62
  export default defineCommand({
57
63
  name: "usage",
58
- options: { ...CHANNEL, json: JSON_OUTPUT, quiet: QUIET, cwd: CWD },
64
+ options: { ...CHANNEL_SHOWS, json: JSON_OUTPUT, quiet: QUIET, cwd: CWD },
59
65
  run(argv, aborting) {
60
- return run(argv, aborting, usage, ({ calls, scopes }) => {
61
- p(rows(scopes));
66
+ // a reader: both channels unless one is named (cli:16a)
67
+ return run(argv, aborting, usage, (used) => {
68
+ p(rows(used.channels));
69
+ const calls = called(used);
62
70
  if (calls) {
63
- p(`\n${called(calls)}`);
71
+ nlp(calls);
64
72
  }
65
- }, "arc unstable value usage");
73
+ });
66
74
  },
67
75
  summary: "Show how much the game's values hold, by scope",
68
76
  });
@@ -1,7 +1,6 @@
1
- // arc unstable wire: a game's wires (plan/SDKWIRES.md), live messages
1
+ // arc wire: a game's wires (plan/SDKWIRES.md), live messages
2
2
  // between its players, relayed and never kept. A game makes and joins them
3
3
  // itself, so what's here is what they came to: their usage, by channel.
4
- // Under `arc unstable` until wires ship, with the docs.
5
4
  // [import]
6
5
  import { defineCommand } from "../../cli/command.js";
7
6
  import usage from "./usage.js";
package/dist/commands.js CHANGED
@@ -73,6 +73,34 @@ export const COMMANDS = [
73
73
  summary: `Log out of ${title}`,
74
74
  },
75
75
  {
76
+ load: () => import("./command/game/index.js"),
77
+ name: "game",
78
+ summary: "Delete the project's game on Arcadible",
79
+ },
80
+ {
81
+ load: () => import("./command/function/index.js"),
82
+ name: "function",
83
+ summary: "Pause, resume, and show the game's function, its logs, and its secrets",
84
+ },
85
+ {
86
+ load: () => import("./command/server/index.js"),
87
+ name: "server",
88
+ summary: "Make, list, and revoke your server's keys",
89
+ },
90
+ {
91
+ load: () => import("./command/value/index.js"),
92
+ name: "value",
93
+ summary: "Set, get, list, and remove the values you publish for the game",
94
+ },
95
+ {
96
+ load: () => import("./command/wire/index.js"),
97
+ name: "wire",
98
+ summary: "Show what the game's wires carried",
99
+ },
100
+ {
101
+ // kept, hidden and empty, for the next command that isn't settled
102
+ // (OUTPUT.md, Unstable commands)
103
+ hidden: true,
76
104
  load: () => import("./command/unstable/index.js"),
77
105
  name: "unstable",
78
106
  summary: "Use commands that aren't stable yet",
@@ -25,6 +25,7 @@ const CLI = {
25
25
  GIT_TAG_EXISTS: "git_tag_exists",
26
26
  GIT_TAG_PUSH_FAILED: "git_tag_push_failed",
27
27
  GIT_UNCOMMITTED: "git_uncommitted",
28
+ KEY_CREATE_RATE_LIMITED: "key_create_rate_limited",
28
29
  KEY_NOT_FOUND: "key_not_found",
29
30
  KEY_QUOTA_FULL: "key_quota_full",
30
31
  LIMIT_REACHED: "limit_reached",
@@ -65,6 +66,7 @@ export const RELEASE = {
65
66
  BUILD_RATE_LIMITED: "build_rate_limited",
66
67
  FUNCTION_INVALID: "function_invalid",
67
68
  FUNCTION_TOO_LARGE: "function_too_large",
69
+ GAME_CREATE_RATE_LIMITED: "game_create_rate_limited",
68
70
  GAME_HANDLE_CHANGED: "game_handle_changed",
69
71
  GAME_MISMATCH: "game_mismatch",
70
72
  GAME_NOT_FOUND: "game_not_found",
@@ -149,6 +151,6 @@ export const ISSUES = new Set(Object.values(ISSUE));
149
151
  export const WARNINGS = new Set(Object.values(WARNING));
150
152
  // [declare]
151
153
  // each error code by its own name too: `cfgcode.NOT_LOGGED_IN`.
152
- export const { API_REFUSED, API_UNREACHABLE, ARGUMENT_INVALID, BUILD_FAILED, DEPLOY_DIR_MISSING, DEPLOY_RATE_LIMITED, FUNCTION_LOGS_FOLLOWS_FULL, FUNCTION_MAIN_MISSING, FUNCTION_NOT_BUILT, FUNCTION_PAUSE_NOT_OWNED, GAME_HANDLE_TAKEN, GAME_ID_MISSING, GAME_NOT_DEPLOYED, GIT_REMOTE_MISSING, GIT_REMOTE_UNREACHABLE, GIT_REPO_MISSING, GIT_TAG_CREATE_FAILED, GIT_TAG_EXISTS, GIT_TAG_PUSH_FAILED, GIT_UNCOMMITTED, KEY_NOT_FOUND, KEY_QUOTA_FULL, LIMIT_REACHED, LOCKFILE_MISSING, LOGIN_CODE_EXPIRED, LOGIN_FAILED, MANIFEST_MISSING, NOT_LOGGED_IN, PACKAGE_INDEX_MISSING, PACKAGE_LINK_INVALID, PACKAGE_TOO_LARGE, PARSE_FAILED, PATH_NOT_FOUND, PORT_IN_USE, PROJECT_NOT_REPO_ROOT, SECRET_NOT_FOUND, SECRET_QUOTA_FULL, SECRET_TOO_LARGE, SESSION_EXPIRED, TEMPLATE_NOT_FOUND, UNAVAILABLE, UNEXPECTED, UPLOAD_FAILED, VALIDATION_FAILED, VALUE_NOT_FOUND, VALUE_STORAGE_QUOTA_FULL, VALUE_TOO_LARGE, WAIT_TIMED_OUT, } = CLI;
153
- export const { ACCOUNT_NOT_FOUND, BUILD_NOT_PUBLISHED, BUILD_RATE_LIMITED, FUNCTION_INVALID, FUNCTION_TOO_LARGE, GAME_HANDLE_CHANGED, GAME_MISMATCH, GAME_NOT_FOUND, GAME_QUOTA_FULL, GIT_RELEASE_NOT_FOUND, GITHUB_APP_NOT_INSTALLED, INTERNAL, MANIFEST_INVALID, MANIFEST_TOO_LARGE, PACKAGE_FILE_TOO_LARGE, PACKAGE_PATH_INVALID, PACKAGE_PATH_RESERVED, PACKAGE_TOO_MANY_FILES, PACKAGE_UNCOMPRESSED_TOO_LARGE, RELEASE_TIMED_OUT, REPO_NOT_CONNECTED, VERSION_EXISTS, VERSION_MISMATCH, ZIP_INVALID, ZIP_MISSING, ZIP_TOO_LARGE, } = RELEASE;
154
+ export const { API_REFUSED, API_UNREACHABLE, ARGUMENT_INVALID, BUILD_FAILED, DEPLOY_DIR_MISSING, DEPLOY_RATE_LIMITED, FUNCTION_LOGS_FOLLOWS_FULL, FUNCTION_MAIN_MISSING, FUNCTION_NOT_BUILT, FUNCTION_PAUSE_NOT_OWNED, GAME_HANDLE_TAKEN, GAME_ID_MISSING, GAME_NOT_DEPLOYED, GIT_REMOTE_MISSING, GIT_REMOTE_UNREACHABLE, GIT_REPO_MISSING, GIT_TAG_CREATE_FAILED, GIT_TAG_EXISTS, GIT_TAG_PUSH_FAILED, GIT_UNCOMMITTED, KEY_CREATE_RATE_LIMITED, KEY_NOT_FOUND, KEY_QUOTA_FULL, LIMIT_REACHED, LOCKFILE_MISSING, LOGIN_CODE_EXPIRED, LOGIN_FAILED, MANIFEST_MISSING, NOT_LOGGED_IN, PACKAGE_INDEX_MISSING, PACKAGE_LINK_INVALID, PACKAGE_TOO_LARGE, PARSE_FAILED, PATH_NOT_FOUND, PORT_IN_USE, PROJECT_NOT_REPO_ROOT, SECRET_NOT_FOUND, SECRET_QUOTA_FULL, SECRET_TOO_LARGE, SESSION_EXPIRED, TEMPLATE_NOT_FOUND, UNAVAILABLE, UNEXPECTED, UPLOAD_FAILED, VALIDATION_FAILED, VALUE_NOT_FOUND, VALUE_STORAGE_QUOTA_FULL, VALUE_TOO_LARGE, WAIT_TIMED_OUT, } = CLI;
155
+ export const { ACCOUNT_NOT_FOUND, BUILD_NOT_PUBLISHED, BUILD_RATE_LIMITED, FUNCTION_INVALID, FUNCTION_TOO_LARGE, GAME_CREATE_RATE_LIMITED, GAME_HANDLE_CHANGED, GAME_MISMATCH, GAME_NOT_FOUND, GAME_QUOTA_FULL, GIT_RELEASE_NOT_FOUND, GITHUB_APP_NOT_INSTALLED, INTERNAL, MANIFEST_INVALID, MANIFEST_TOO_LARGE, PACKAGE_FILE_TOO_LARGE, PACKAGE_PATH_INVALID, PACKAGE_PATH_RESERVED, PACKAGE_TOO_MANY_FILES, PACKAGE_UNCOMPRESSED_TOO_LARGE, RELEASE_TIMED_OUT, REPO_NOT_CONNECTED, VERSION_EXISTS, VERSION_MISMATCH, ZIP_INVALID, ZIP_MISSING, ZIP_TOO_LARGE, } = RELEASE;
154
156
  export const { GIT_TAG_INVALID, GITHUB_APP_NOT_CONNECTED, WORKFLOW_MISSING } = GITHUB;
@@ -18,11 +18,11 @@ export const TOTAL_SIZE = 256 * MB;
18
18
  export const ZIP_SIZE = 64 * MB;
19
19
  // a function's bundle, as Arcadible runs it (the subscriber's RUNNER_MAX).
20
20
  export const FUNCTION_SIZE = 1 * MB;
21
- // a secret's name, as the API, the database (chk_runner_secret_name_is_valid),
22
- // and the subscriber hold it: capitals, digits, and underscores, starting
23
- // with a letter, 64 at most; ARCADIBLE_ is kept for Arcadible's own. The
24
- // manifest's [function] secrets and `arc unstable function secret` both take
25
- // this one.
21
+ // a secret's name, as the API, the database
22
+ // (chk_game_function_secret_name_is_valid), and the subscriber hold it:
23
+ // capitals, digits, and underscores, starting with a letter, 64 at most;
24
+ // ARCADIBLE_ is kept for Arcadible's own. The manifest's [function] secrets
25
+ // and `arc function secret` both take this one.
26
26
  export const SECRET_NAME = /^(?!ARCADIBLE_)[A-Z][A-Z0-9_]{0,63}$/u;
27
27
  // the most secrets a game's channel holds (api_put_game_function_secret), so
28
28
  // the most a function may declare.
@@ -32,6 +32,7 @@ export const RETRY = {
32
32
  [code.GIT_TAG_EXISTS]: "no",
33
33
  [code.GIT_TAG_PUSH_FAILED]: "no",
34
34
  [code.GIT_UNCOMMITTED]: "no",
35
+ [code.KEY_CREATE_RATE_LIMITED]: "later",
35
36
  [code.KEY_NOT_FOUND]: "no",
36
37
  [code.KEY_QUOTA_FULL]: "later",
37
38
  [code.LIMIT_REACHED]: "later",
@@ -66,6 +67,7 @@ export const RETRY = {
66
67
  [code.BUILD_RATE_LIMITED]: "later",
67
68
  [code.FUNCTION_INVALID]: "no",
68
69
  [code.FUNCTION_TOO_LARGE]: "no",
70
+ [code.GAME_CREATE_RATE_LIMITED]: "later",
69
71
  [code.GAME_HANDLE_CHANGED]: "no",
70
72
  [code.GAME_MISMATCH]: "no",
71
73
  [code.GAME_QUOTA_FULL]: "later",
@@ -72,7 +72,8 @@ function nearestAbove(dir) {
72
72
  // fails when `root` has no manifest. A game's id is only ever in it, so a
73
73
  // project without one can't be deployed, and the likeliest cause is running
74
74
  // arc from inside a project: the hint names the project above, if any.
75
- function ensureManifest(root) {
75
+ // `arc value`'s commands ask it too, on the project's own values.
76
+ export function ensureManifest(root) {
76
77
  return pathExists(join(root, MANIFEST))
77
78
  .then((exists) => exists ? false : nearestAbove(root))
78
79
  .then((found) => {
@@ -72,13 +72,22 @@ export function pressEnterToOpen() {
72
72
  return "Press Enter to open the link.";
73
73
  }
74
74
  // [function]
75
+ // a game that isn't there to its caller, as every command says it: one
76
+ // never deployed, one deleted, and another account's are the same to anyone
77
+ // but its owner (OUTPUT.md). A command adds what to do in its details.
75
78
  export function gameNotFound(idOrHandle) {
76
- return `Game not found: ${idOrHandle}`;
79
+ return `Game not found: ${idOrHandle}\nIt was never deployed, was deleted, or belongs to another account.`;
77
80
  }
78
81
  // [function]
79
82
  export function httpError(name, status, detail) {
80
83
  const head = `${name} (${status})`;
81
- return detail ? `${head}: ${detail}` : `${head}.`;
84
+ if (!detail) {
85
+ return `${head}.`;
86
+ }
87
+ // the API's message, a sentence a line: what happened under the status,
88
+ // then what to do, after a blank line (OUTPUT.md)
89
+ const [said = "", ...next] = detail.trim().split(/(?<=[.!?])\s+(?=[A-Z`])/u);
90
+ return next.length ? blocks(`${head}\n${said}`, next) : `${head}\n${said}`;
82
91
  }
83
92
  // [function]
84
93
  // no game: a command that takes one (`arc play`, `arc open`) says to pass
@@ -135,8 +144,5 @@ export function unableToReach() {
135
144
  // an answer of the API's that isn't what this version reads: a newer
136
145
  // Arcadible than this arc, most likely.
137
146
  export function answerUnread(what) {
138
- return [
139
- `Unable to read ${TITLE}'s answer for ${what}.`,
140
- "This arc may be out of date. Update it with `npm install -g arcadible`.",
141
- ].join("\n");
147
+ return blocks(`Unable to read ${TITLE}'s answer for ${what}.\nThis arc may be out of date.`, "Update it with `npm install -g arcadible`.");
142
148
  }
@@ -2,6 +2,7 @@
2
2
  // a release.
3
3
  // [import]
4
4
  import { MANIFEST } from "../config/file.js";
5
+ import { gameNotFound } from "./common.js";
5
6
  import { blocks, cmdDeploy, cmdDeployGit, tail, waited } from "./internal.js";
6
7
  import { title } from "../config/product.js";
7
8
  // [declare]
@@ -63,7 +64,7 @@ export function repoNotConnected(game, repo, url) {
63
64
  }
64
65
  // [function]
65
66
  export function gameDeletedOrNotOwned(id) {
66
- return blocks(`Game not found: ${id}\nIt was deleted, or belongs to another account.`, "Give game.id a new UUID to deploy it as a new game.");
67
+ return blocks(gameNotFound(id), "Give game.id a new UUID to deploy it as a new game.");
67
68
  }
68
69
  // [function]
69
70
  export function gitUncommitted() {
@@ -132,8 +133,8 @@ export function releasePublished(version, channel, built) {
132
133
  export function releaseTimedOut(version, seconds, { actions, found, git, studio, }) {
133
134
  const head = `Waited ${waited(seconds)} for v${version}.`;
134
135
  if (found || !git) {
135
- return blocks(head, [
136
- `It may still finish. See it in ${TITLE} Studio:`,
136
+ return blocks(`${head}\nIt may still finish.`, [
137
+ `See it in ${TITLE} Studio:`,
137
138
  studio,
138
139
  ]);
139
140
  }
@@ -1,4 +1,4 @@
1
- // a game's function: `arc unstable function`, its secrets, and the function as arc
1
+ // a game's function: `arc 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,9 +17,9 @@ 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 unstable function resume --${channel}\`.`);
20
+ return blocks(`Paused ${channel}, which has no function yet.`, `A release with one stays stopped until \`arc function resume --${channel}\`.`);
21
21
  }
22
- return `Paused the game's function on ${channel}. It stops answering within a minute.`;
22
+ return `Paused the game's function on ${channel}.\nIt stops answering within a minute.`;
23
23
  }
24
24
  // [function]
25
25
  // why a function is paused, as a status says it. A limit's pause ends by
@@ -55,7 +55,7 @@ export function functionResumed({ channel, lifted, paused, }) {
55
55
  if (paused) {
56
56
  return blocks(`Lifted your pause on ${channel}.`, `The game's function stays paused: ${functionPause(paused)}.`);
57
57
  }
58
- return `Resumed the game's function on ${channel}. It answers again within a minute.`;
58
+ return `Resumed the game's function on ${channel}.\nIt answers again within a minute.`;
59
59
  }
60
60
  // [function]
61
61
  // what holds a game's function, as a status says it under its channels:
@@ -63,17 +63,20 @@ export function functionResumed({ channel, lifted, paused, }) {
63
63
  // month and its account's, every game's together, against its plan's, then
64
64
  // the CPU time of both, which no limit holds. Each number is the API's;
65
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}`;
66
+ export function functionUsage({ account, month, today, }) {
67
+ const day = today.allowance === null
68
+ ? `${today.requests} requests today, with no limit for a day`
69
+ : `${today.requests} of ${today.allowance} requests today, both channels together`;
70
+ const all = account.allowance === null
71
+ ? ` Your account's games together: ${account.requests}, with no limit`
72
+ : ` Your account's games together: ${account.requests} of ${account.allowance}`;
73
+ const cpu = month.cpu && account.cpu
74
+ ? [
75
+ `CPU time this month: ${month.cpu}`,
76
+ ` Your account's games together: ${account.cpu}`,
77
+ ]
78
+ : [];
79
+ return [day, `${month.requests} requests this month`, all, ...cpu].join("\n");
77
80
  }
78
81
  // [function]
79
82
  // a function's CPU time, given in milliseconds, as it's read: "640 ms",
@@ -99,19 +102,22 @@ export function functionPauseNotOwned({ channel, paused, }) {
99
102
  return blocks(`The game's function is paused by Arcadible on ${channel}.`, "Only Arcadible can resume it.");
100
103
  }
101
104
  if (paused === "limit") {
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.");
105
+ return blocks(`The game's function is at a limit on ${channel}.`, [
106
+ "It resumes by itself as the day or the month turns (UTC).",
107
+ "`arc function status` says when.",
108
+ ]);
103
109
  }
104
110
  return `The game's function is paused on ${channel}, and not by you.`;
105
111
  }
106
112
  // [function]
107
113
  export function secretSet({ channel, name, }) {
108
- return `Set ${name} for ${channel}. The game's function has it within a minute.`;
114
+ return `Set ${name} for ${channel}.\nThe game's function has it within a minute.`;
109
115
  }
110
116
  // [function]
111
117
  // a secret a build declares that has no value on the channel it goes to,
112
118
  // which `arc deploy` warns of (action/predeploy/secrets.ts).
113
119
  export function secretUnset({ channel, name, }) {
114
- return `Secret ${name} has no value on ${channel}.\nSet it with \`arc unstable function secret set ${name} --${channel}\`.`;
120
+ return `Secret ${name} has no value on ${channel}.\nSet it with \`arc function secret set ${name} --${channel}\`.`;
115
121
  }
116
122
  // [function]
117
123
  export function secretRemoved({ channel, name, }) {
@@ -124,11 +130,11 @@ export function secretNone() {
124
130
  // [function]
125
131
  // the most secrets a game has for a channel, when one more is asked for.
126
132
  export function secretQuotaFull(channel) {
127
- return blocks(`Sixteen secrets already for ${channel}.`, "Remove one with `arc unstable function secret remove <name>`, then try again.");
133
+ return blocks(`Sixteen secrets already for ${channel}.`, "Remove one with `arc function secret remove <name>`, then try again.");
128
134
  }
129
135
  // [function]
130
136
  export function secretNotFound({ channel, name, }) {
131
- return blocks(`Secret not found: ${name}`, `It isn't set for ${channel}.\n\`arc unstable function secret list\` shows the game's secrets.`);
137
+ return blocks(`Secret not found: ${name}`, `It isn't set for ${channel}.\n\`arc function secret list\` shows the game's secrets.`);
132
138
  }
133
139
  // [function]
134
140
  export function secretNameInvalid() {
@@ -144,7 +150,7 @@ export function secretTooLarge() {
144
150
  }
145
151
  // [function]
146
152
  export function secretValueInvalid() {
147
- 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');
153
+ 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');
148
154
  }
149
155
  // [function]
150
156
  // what's asked when a secret's value is typed.
@@ -1,6 +1,6 @@
1
- // a game on Arcadible: arc unstable game delete.
1
+ // a game on Arcadible: arc game delete.
2
2
  // [import]
3
- import { cmdInit } from "./common.js";
3
+ import { cmdInit, gameNotFound } from "./common.js";
4
4
  import { blocks, cmdWhoami } from "./internal.js";
5
5
  // [function]
6
6
  // what's asked before a game is deleted, as Studio's Delete game asks it.
@@ -25,5 +25,5 @@ export function gameDeletedProject() {
25
25
  // that isn't on Arcadible, one that's deleted already, and another account's
26
26
  // are the same.
27
27
  export function gameNotOwned(id) {
28
- return blocks(`Game not found: ${id}\nIt was never deployed, was deleted, or belongs to another account.`, `${cmdWhoami()} shows the account you're logged in to.`);
28
+ return blocks(gameNotFound(id), `${cmdWhoami()} shows the account you're logged in to.`);
29
29
  }
@@ -33,7 +33,10 @@ export function buildFailed({ code, signal, stderr, stdout, }) {
33
33
  // `manager`, the one its lockfile names.
34
34
  export function packagesUninstalled(message, manager) {
35
35
  const [reason = "", ...rest] = message.split("\n\n");
36
- return blocks(reason, `The project's packages aren't installed. Run \`${manager} install\` first.`, ...rest);
36
+ return blocks(reason, [
37
+ "The project's packages aren't installed.",
38
+ `Run \`${manager} install\` first.`,
39
+ ], ...rest);
37
40
  }
38
41
  // [function]
39
42
  export function buildOutputMissing(dir) {
@@ -65,7 +65,7 @@ export function playerInvalid() {
65
65
  }
66
66
  // [function]
67
67
  export function serveNext(dir) {
68
- return `Reloads when ${dir}/ changes. Press Ctrl+C to stop.`;
68
+ return blocks(`Reloads when ${dir}/ changes.`, "Press Ctrl+C to stop.");
69
69
  }
70
70
  // [function]
71
71
  export function served({ built, url, version, }) {
@@ -79,7 +79,7 @@ export function served({ built, url, version, }) {
79
79
  }
80
80
  // [function]
81
81
  export function serveNextUrl() {
82
- return "Your server reloads the game. Press Ctrl+C to stop.";
82
+ return blocks("Your server reloads the game.", "Press Ctrl+C to stop.");
83
83
  }
84
84
  // [function]
85
85
  export function urlInvalid() {
@@ -1,10 +1,10 @@
1
- // `arc unstable server`: a game's own servers, and their keys.
1
+ // `arc server`: a game's own servers, and their keys.
2
2
  // [import]
3
3
  import { blocks } from "./internal.js";
4
4
  // [function]
5
5
  // a key that was made: said on stderr, so stdout holds the key alone.
6
6
  export function keyCreated({ channel, id, name, }) {
7
- return blocks(`Made "${name}" for ${channel} (${id}).`, "Keep it somewhere safe. It won't be shown again.");
7
+ return blocks(`Made "${name}" for ${channel} (${id}).\nIt won't be shown again.`, "Keep it somewhere safe.");
8
8
  }
9
9
  // [function]
10
10
  export function keyRevoked(id) {
@@ -15,13 +15,18 @@ export function keyNone() {
15
15
  return "No keys.";
16
16
  }
17
17
  // [function]
18
+ // the most keys an account makes in an hour, when one more is asked for.
19
+ export function keyCreateRateLimited() {
20
+ return blocks("This account made 20 keys in the last hour.", "Wait up to an hour, then try again.");
21
+ }
22
+ // [function]
18
23
  // the most keys a game has for a channel, when one more is asked for.
19
24
  export function keyQuotaFull(channel) {
20
- return blocks(`Five keys already for ${channel}.`, "Revoke one with `arc unstable server key revoke <id>`, then try again.");
25
+ return blocks(`Five keys already for ${channel}.`, "Revoke one with `arc server key revoke <id>`, then try again.");
21
26
  }
22
27
  // [function]
23
28
  export function keyNotFound(id) {
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.");
29
+ 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.");
25
30
  }
26
31
  // [function]
27
32
  export function keyNameInvalid() {
@@ -32,7 +37,7 @@ export function keyRevokeQuestion() {
32
37
  return "Revoke this key? Servers using it stop working at once, and it can't be undone.";
33
38
  }
34
39
  // [function]
35
- // under `arc unstable server`'s help: what it isn't, a letter away.
40
+ // under `arc server`'s help: what it isn't, a letter away.
36
41
  export function serverNotServe() {
37
42
  return "To run your game on this machine, use `arc serve`.";
38
43
  }