arcadible 1.0.49 → 1.0.50

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 (67) 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 +11 -10
  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 +65 -27
  13. package/dist/action/wire/tool.js +1 -1
  14. package/dist/cli/command.js +13 -1
  15. package/dist/cli/options.js +7 -0
  16. package/dist/cli/prompt.js +1 -1
  17. package/dist/command/deploy/report.js +5 -5
  18. package/dist/command/function/index.js +2 -3
  19. package/dist/command/function/logs.js +4 -4
  20. package/dist/command/function/pause.js +1 -1
  21. package/dist/command/function/resume.js +1 -1
  22. package/dist/command/function/run.js +1 -1
  23. package/dist/command/function/secret/index.js +1 -1
  24. package/dist/command/function/secret/list.js +2 -1
  25. package/dist/command/function/secret/remove.js +2 -2
  26. package/dist/command/function/secret/run.js +1 -1
  27. package/dist/command/function/secret/set.js +1 -1
  28. package/dist/command/function/status.js +11 -11
  29. package/dist/command/game/delete.js +2 -2
  30. package/dist/command/game/index.js +2 -2
  31. package/dist/command/open.js +1 -1
  32. package/dist/command/play.js +1 -1
  33. package/dist/command/server/index.js +3 -3
  34. package/dist/command/server/key/create.js +4 -4
  35. package/dist/command/server/key/index.js +1 -1
  36. package/dist/command/server/key/list.js +3 -2
  37. package/dist/command/server/key/revoke.js +1 -1
  38. package/dist/command/server/key/run.js +1 -1
  39. package/dist/command/unstable/index.js +8 -13
  40. package/dist/command/value/get.js +12 -8
  41. package/dist/command/value/index.js +4 -4
  42. package/dist/command/value/list.js +14 -6
  43. package/dist/command/value/remove.js +22 -11
  44. package/dist/command/value/run.js +40 -0
  45. package/dist/command/value/set.js +27 -22
  46. package/dist/command/value/usage.js +34 -30
  47. package/dist/command/wire/index.js +1 -2
  48. package/dist/commands.js +28 -0
  49. package/dist/config/code.js +4 -2
  50. package/dist/config/limit.js +5 -5
  51. package/dist/config/retry.js +2 -0
  52. package/dist/parser/project.js +2 -1
  53. package/dist/phrase/common.js +12 -6
  54. package/dist/phrase/deploy.js +4 -3
  55. package/dist/phrase/function.js +27 -21
  56. package/dist/phrase/game.js +3 -3
  57. package/dist/phrase/pack.js +4 -1
  58. package/dist/phrase/serve.js +2 -2
  59. package/dist/phrase/server.js +10 -5
  60. package/dist/phrase/value.js +50 -16
  61. package/dist/schema/client.js +11 -6
  62. package/dist/serve/values.js +2 -2
  63. package/dist/util/output.js +11 -4
  64. package/dist/util/schema.js +5 -3
  65. package/dist/util/time.js +5 -0
  66. package/npm-shrinkwrap.json +2 -2
  67. package/package.json +2 -1
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
  }
@@ -1,13 +1,39 @@
1
1
  // [import]
2
2
  import { blocks } from "./internal.js";
3
+ // [declare]
4
+ // the project's own values, the local channel `arc serve` reads, where
5
+ // `arc value` works with no channel.
6
+ const VALUES_DIR = ".arcadible-data/values/";
7
+ // [function]
8
+ // where a channel's values are: the project's folder for `local`, else the
9
+ // channel on Arcadible.
10
+ function placeOf(channel) {
11
+ return channel === "local" ? `in ${VALUES_DIR}` : `on ${channel}`;
12
+ }
13
+ // [function]
14
+ // the command that lists a channel's values.
15
+ function listOf(channel) {
16
+ return channel === "local"
17
+ ? "`arc value list`"
18
+ : `\`arc value list --${channel}\``;
19
+ }
3
20
  // [function]
4
21
  export function valueKeyInvalid(key) {
5
22
  return blocks(`Not a key: ${key}`, "A key is 1 to 128 letters, digits, -, _, ., and /.");
6
23
  }
7
24
  // [function]
8
- // `arc unstable value set` given neither a key nor a folder, or both.
25
+ // `arc value set` given no key: on the project's own values, which have
26
+ // nowhere to send it, or with a value and no key to set it under.
9
27
  export function valueSetWhat() {
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.");
28
+ return blocks("Name a key.", [
29
+ `\`arc value set <key> '{"on": true}'\` sets one value, in ${VALUES_DIR}.`,
30
+ `\`arc value set --production\` sends every value in ${VALUES_DIR}.`,
31
+ ]);
32
+ }
33
+ // [function]
34
+ // `arc value set` given a value twice: on the command line, and in a file.
35
+ export function valueSetTwice() {
36
+ return blocks("Two values given.", "Give the value on the command line, or with `--file`, or on standard input.");
11
37
  }
12
38
  // [function]
13
39
  // a value that isn't JSON: `source` is its file, or standard input.
@@ -19,8 +45,12 @@ export function valueFileUnread(path) {
19
45
  return `Can't read ${path}.`;
20
46
  }
21
47
  // [function]
22
- export function valueDirEmpty(dir) {
23
- return blocks(`No values in ${dir}.`, "Each .json file there is a value, and its path its key: daily/2026-11-12.json is daily/2026-11-12.");
48
+ // `arc value set` on a channel with no key, and no values to send.
49
+ export function valueDirEmpty() {
50
+ return blocks(`No values in ${VALUES_DIR}`, [
51
+ "Each .json file there is a value, and its path its key: daily/2026-11-12.json is daily/2026-11-12.",
52
+ "`arc value set <key> <value>` sets one there.",
53
+ ]);
24
54
  }
25
55
  // [function]
26
56
  export function valueTooLarge(key) {
@@ -38,9 +68,9 @@ export function valueSize(bytes) {
38
68
  return `${(bytes / (1024 * 1024)).toFixed(1).replace(/\.0$/u, "")} MB`;
39
69
  }
40
70
  // [function]
41
- // what a scope may hold, as the API states it (null is no limit): "10,000
42
- // keys, 64 MB", or "no limit".
43
- export function valueHolds({ bytes_limit: bytes, keys_limit: keys, }) {
71
+ // what each owner of a scope may hold, as the API states it (null is no
72
+ // limit): "10,000 keys, 64 MB", or "no limit".
73
+ export function valueHolds({ bytes, keys, }) {
44
74
  if (keys === null && bytes === null) {
45
75
  return "no limit";
46
76
  }
@@ -50,35 +80,39 @@ export function valueHolds({ bytes_limit: bytes, keys_limit: keys, }) {
50
80
  // the game's calls to its values spent: its own for the day, or its
51
81
  // account's for the month, as the API doesn't say which.
52
82
  export function valueCallsSpent() {
53
- return blocks("The game's calls to its values are spent for the day, or its account's for the month.", "Writes and removes go on when the day or the month turns (UTC). Reads still work.");
83
+ return blocks("The game's value calls are spent for today, or its account's for the month.", [
84
+ "Writes and removes go on when the day or the month turns (UTC).",
85
+ "Reads still work.",
86
+ ]);
54
87
  }
55
88
  // [function]
56
89
  // the developer's values on `channel` full, with what they may hold, the
57
90
  // account's plan's, when the API could say.
58
91
  export function valueFull(channel, holds) {
59
- const remove = "Remove some with `arc unstable value remove <key>`, then try again.";
92
+ const remove = "Remove some with `arc value remove <key>`, then try again.";
60
93
  return blocks(`The developer's values on ${channel} are full.`, holds === null
61
- ? `${remove}\n\`arc unstable value usage\` shows what they hold.`
62
- : `They may hold ${holds}. ${remove}`);
94
+ ? `${remove}\n\`arc value usage\` shows what they hold.`
95
+ : `They may hold ${holds}.\n${remove}`);
63
96
  }
64
97
  // [function]
65
98
  export function valueSet({ channel, keys, }) {
66
99
  const [only] = keys;
67
100
  return keys.length === 1 && only !== undefined
68
- ? `Set ${only} on ${channel}.`
69
- : `Set ${keys.length} values on ${channel}.`;
101
+ ? `Set ${only} ${placeOf(channel)}.`
102
+ : `Set ${keys.length} values ${placeOf(channel)}.`;
70
103
  }
71
104
  // [function]
72
105
  export function valueNotFound({ channel, key, }) {
73
- return blocks(`Value not found: ${key}`, `It isn't set on ${channel}.\n\`arc unstable value list --${channel}\` shows what is.`);
106
+ return blocks(`Value not found: ${key}`, `It isn't set ${placeOf(channel)}.\n${listOf(channel)} shows what is.`);
74
107
  }
75
108
  // [function]
76
109
  export function valueRemoveQuestion({ channel, key, }) {
77
- return `Remove ${key} from ${channel}? Games read nothing for it from then on.`;
110
+ const from = channel === "local" ? VALUES_DIR : channel;
111
+ return `Remove ${key} from ${from}? Games read nothing for it from then on.`;
78
112
  }
79
113
  // [function]
80
114
  export function valueRemoved({ channel, key, }) {
81
- return `Removed ${key} from ${channel}.`;
115
+ return `Removed ${key} from ${channel === "local" ? VALUES_DIR : channel}.`;
82
116
  }
83
117
  // [function]
84
118
  export function valueNone() {
@@ -36,25 +36,30 @@ function isLocal(value) {
36
36
  }
37
37
  // [function]
38
38
  // what to do about an address that isn't one: that a local one is left out,
39
- // that the port goes, or the origin it almost is.
39
+ // that the port goes, or the origin it almost is: a line each.
40
40
  function hint(value) {
41
41
  if (isLocal(value)) {
42
- return "Leave your own machine out: arc serve reaches any server on it.";
42
+ return ["Leave your own machine out: arc serve reaches any server on it."];
43
43
  }
44
44
  try {
45
45
  const url = new URL(value);
46
46
  const plain = url.username === "" && url.password === "";
47
47
  if (url.protocol === "https:" && plain && url.port !== "") {
48
- return "A server is reached on port 443, the default: leave the port out.";
48
+ return [
49
+ "A server is reached on port 443, the default: leave the port out.",
50
+ ];
49
51
  }
50
52
  if (url.protocol === "https:" && plain && url.origin !== value) {
51
- return `Did you mean ${url.origin}?`;
53
+ return [`Did you mean ${url.origin}?`];
52
54
  }
53
55
  }
54
56
  catch {
55
57
  // not an address at all
56
58
  }
57
- return "A scheme and a host, with no path. A ticket is for the whole server.";
59
+ return [
60
+ "A scheme and a host, with no path.",
61
+ "A ticket is for the whole server.",
62
+ ];
58
63
  }
59
64
  // [function]
60
65
  // one of the developer's own servers: an https origin on the default port.
@@ -67,7 +72,7 @@ function zOrigin() {
67
72
  code: "custom",
68
73
  ...message(field, [
69
74
  "Must be an https origin, such as https://api.example.com.",
70
- hint(value),
75
+ ...hint(value),
71
76
  ], ISSUE.URL_INVALID),
72
77
  });
73
78
  return;
@@ -97,8 +97,8 @@ function itemsOf(given, fields, needsValue) {
97
97
  // [function]
98
98
  // the developer's values, from the project's folder: each `.json` file a
99
99
  // value, its path its key. A file that isn't JSON, or whose path isn't a
100
- // key, is no value.
101
- function developerRows(dir) {
100
+ // key, is no value. `arc value` reads them so too, with no channel.
101
+ export function developerRows(dir) {
102
102
  const rows = new Map();
103
103
  const walk = function (at) {
104
104
  let names;
@@ -100,7 +100,7 @@ export function errorOf(ex, code, retry) {
100
100
  }
101
101
  : {}),
102
102
  code: shown,
103
- link: `${ERRORS}#${shown}`,
103
+ docs_url: `${ERRORS}#${shown}`,
104
104
  message: ex.message,
105
105
  retry: isRetry(said) ? said : retryOf(shown),
106
106
  ...(ex.status ? { status: ex.status } : {}),
@@ -111,14 +111,21 @@ export function errorOf(ex, code, retry) {
111
111
  // aborted.") and the reason on stderr, then its code and the link to it on
112
112
  // the Errors page, once the spinner and progress bar are cleared. Then exits
113
113
  // 1. `data`, and the error's own, go beside the error in JSON, such as the
114
- // release that failed. `nl` puts a blank line before the heading, after
114
+ // release that failed, and `warnings` when there are any. `nl` puts a blank line before the heading, after
115
115
  // output the command has already printed, such as arc login's link.
116
116
  // `code` is a failed release's reason, which the API may add to, so it isn't
117
117
  // checked, and `retry` the API's own word beside it.
118
118
  export function abort(heading, ex, { code, data, json = false, nl = false, pb, retry, sw } = {}) {
119
119
  const shown = code ?? codeOf(ex);
120
120
  if (json) {
121
- print({ ...ex.data, ...data, error: errorOf(ex, code, retry) });
121
+ // `warnings` beside an error only when there are any (OUTPUT.md)
122
+ const { warnings, ...beside } = { ...ex.data, ...data };
123
+ const listed = Array.isArray(warnings) && warnings.length > 0;
124
+ print({
125
+ ...beside,
126
+ ...(listed ? { warnings } : {}),
127
+ error: errorOf(ex, code, retry),
128
+ });
122
129
  }
123
130
  else {
124
131
  if (pb) {
@@ -168,7 +175,7 @@ export function warning(code, message, path = null) {
168
175
  return {
169
176
  code,
170
177
  details: [],
171
- link: `${ERRORS}#${code}`,
178
+ docs_url: `${ERRORS}#${code}`,
172
179
  message,
173
180
  path,
174
181
  };
@@ -106,7 +106,9 @@ export function toIssue(name, issue) {
106
106
  return {
107
107
  code: issueCodeOf(issue),
108
108
  details,
109
- link: issue.path.length ? messageLink(name, String(issue.path[0])) : null,
109
+ docs_url: issue.path.length
110
+ ? messageLink(name, String(issue.path[0]))
111
+ : null,
110
112
  message,
111
113
  path: `${name}.${issue.path.join(".") || "value"}`,
112
114
  };
@@ -115,7 +117,7 @@ export function toIssue(name, issue) {
115
117
  // an issue as it's printed: the path, the message, then its details and its
116
118
  // link, indented beneath it. `linked` false leaves the link out. `marker`
117
119
  // colors it, standard output's unless it's printed elsewhere.
118
- export function print({ details, link, message, path }, linked = true, marker = chalk) {
120
+ export function print({ details, docs_url: link, message, path }, linked = true, marker = chalk) {
119
121
  const rest = [
120
122
  ...details,
121
123
  ...(linked && link ? [marker.cyan.underline(link)] : []),
@@ -128,7 +130,7 @@ export function print({ details, link, message, path }, linked = true, marker =
128
130
  // validate's list of references.
129
131
  export function dereference(issues) {
130
132
  const references = [
131
- ...new Set(issues.flatMap(({ link }) => (link ? [link] : []))),
133
+ ...new Set(issues.flatMap(({ docs_url: link }) => (link ? [link] : []))),
132
134
  ].map((link) => chalk.cyan.underline(link));
133
135
  return [issues.map((issue) => print(issue, false)), references];
134
136
  }
package/dist/util/time.js CHANGED
@@ -14,3 +14,8 @@ export function m(value) {
14
14
  export function h(value) {
15
15
  return m(value * 60);
16
16
  }
17
+ export function iso(value) {
18
+ return value === null || value === undefined || value === ""
19
+ ? null
20
+ : new Date(value).toISOString();
21
+ }