arcadible 1.0.48 → 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 (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 +6 -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/request.js +17 -7
  65. package/dist/util/s3.js +10 -2
  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,4 +1,4 @@
1
- // arc unstable function secret: a function's secrets, the values a game's function
1
+ // arc function secret: a function's secrets, the values a game's function
2
2
  // needs and its repository mustn't hold. `set` takes the value from standard
3
3
  // input, or asks for it at a terminal, so it's never an argument, in a
4
4
  // shell's history or a process list.
@@ -19,7 +19,8 @@ export default defineCommand({
19
19
  name: "list",
20
20
  options: { ...CHANNEL_SHOWS, json: JSON_OUTPUT, quiet: QUIET, cwd: CWD },
21
21
  run(argv, aborting) {
22
- return run(argv, aborting, list, (secrets) => {
22
+ // an object, not a bare list, so it can gain a field (OUTPUT.md)
23
+ return run(argv, aborting, async (current, conf) => ({ secrets: await list(current, conf) }), ({ secrets }) => {
23
24
  p(secrets.length ? rows(secrets) : secretNone());
24
25
  });
25
26
  },
@@ -15,12 +15,12 @@ export default defineCommand({
15
15
  run(argv, aborting) {
16
16
  return run(argv, aborting, (current, conf) => remove(current, { ...conf, name: argv.name }), (gone) => {
17
17
  p(secretRemoved(gone));
18
- }, `arc unstable function secret remove ${argv.name}`, (where) => ({
18
+ }, `arc function secret remove ${argv.name}`, (where) => ({
19
19
  question: secretRemoveQuestion({
20
20
  channel: String(where),
21
21
  name: argv.name,
22
22
  }),
23
- usage: `arc unstable function secret remove ${argv.name} --${where}`,
23
+ usage: `arc function secret remove ${argv.name} --${where}`,
24
24
  }));
25
25
  },
26
26
  summary: "Remove a secret",
@@ -1,4 +1,4 @@
1
- // what `arc unstable function secret`'s commands share: running one as the logged-in
1
+ // what `arc function secret`'s commands share: running one as the logged-in
2
2
  // account.
3
3
  // [import]
4
4
  import { resolve as resolvePath } from "node:path";
@@ -42,7 +42,7 @@ export default defineCommand({
42
42
  value: () => valueOf(argv.name, argv.json),
43
43
  }), (kept) => {
44
44
  p(secretSet(kept));
45
- }, `arc unstable function secret set ${argv.name}`);
45
+ }, `arc function secret set ${argv.name}`);
46
46
  },
47
47
  summary: "Set a secret, its value from standard input",
48
48
  });
@@ -1,7 +1,7 @@
1
1
  // [import]
2
2
  import { defineCommand } from "../../cli/command.js";
3
3
  import { cpuTime, functionState, functionUsage } from "../../phrase/index.js";
4
- import { p } from "../../util/log.js";
4
+ import { nlp, p } from "../../util/log.js";
5
5
  import { CHANNEL_SHOWS, CWD, JSON_OUTPUT, QUIET } from "../../cli/options.js";
6
6
  import { run } from "./run.js";
7
7
  import { table } from "../../util/table.js";
@@ -30,24 +30,24 @@ export default defineCommand({
30
30
  name: "status",
31
31
  options: { ...CHANNEL_SHOWS, json: JSON_OUTPUT, quiet: QUIET, cwd: CWD },
32
32
  run(argv, aborting) {
33
- return run(argv, aborting, status, ({ channels, day, month, pool }) => {
33
+ return run(argv, aborting, status, ({ account, channels, month, today }) => {
34
34
  p(rows(channels));
35
35
  // nothing to say of its limits when its usage couldn't be read
36
- if (day && month && pool) {
36
+ if (today && month && account) {
37
37
  const limit = (value) => value === null ? null : count(value);
38
- p(functionUsage({
39
- day: {
40
- allowance: limit(day.allowance),
41
- requests: count(day.requests),
38
+ nlp(functionUsage({
39
+ account: {
40
+ allowance: limit(account.allowance),
41
+ cpu: cpuTime(account.cpu_ms),
42
+ requests: count(account.requests),
42
43
  },
43
44
  month: {
44
45
  cpu: cpuTime(month.cpu_ms),
45
46
  requests: count(month.requests),
46
47
  },
47
- pool: {
48
- allowance: limit(pool.allowance),
49
- cpu: cpuTime(pool.cpu_ms),
50
- requests: count(pool.requests),
48
+ today: {
49
+ allowance: limit(today.allowance),
50
+ requests: count(today.requests),
51
51
  },
52
52
  }));
53
53
  }
@@ -1,4 +1,4 @@
1
- // arc unstable game delete: deletes the project's game on Arcadible, for its
1
+ // arc game delete: deletes the project's game on Arcadible, for its
2
2
  // owner. It
3
3
  // can't be undone, so it asks first (src/cli/confirm.ts), naming the game.
4
4
  // The project's files are left as they are.
@@ -19,7 +19,7 @@ import { whoami } from "../../action/whoami/tool.js";
19
19
  // [declare]
20
20
  const COMMAND = "delete";
21
21
  // the command as it's typed, shown with `--yes` when there's no one to ask.
22
- const USAGE = "arc unstable game delete";
22
+ const USAGE = "arc game delete";
23
23
  // [export]
24
24
  export default defineCommand({
25
25
  heading: "delete",
@@ -1,6 +1,6 @@
1
- // arc unstable game: the project's game on Arcadible, where a top-level
1
+ // arc game: the project's game on Arcadible, where a top-level
2
2
  // command is the project's own life (`init` to `deploy`). Deleting it, for
3
- // now. Under `arc unstable` until it's settled, then `arc game`.
3
+ // now.
4
4
  // [import]
5
5
  import { defineCommand } from "../../cli/command.js";
6
6
  import del from "./delete.js";
@@ -39,7 +39,7 @@ export default defineCommand({
39
39
  if (argv.json) {
40
40
  // where it opened (app, browser, or null when it couldn't), and the
41
41
  // store page's URL.
42
- print({ opened: where, url });
42
+ print({ opened: where, store_url: url });
43
43
  }
44
44
  else if (!argv.quiet) {
45
45
  launched(where, url);
@@ -71,7 +71,7 @@ export default defineCommand({
71
71
  if (argv.json) {
72
72
  // where it opened (app, browser, or null when it couldn't), and the
73
73
  // play link, which names the channel or version it plays.
74
- print({ opened: where, url });
74
+ print({ opened: where, play_url: url });
75
75
  }
76
76
  else if (!argv.quiet) {
77
77
  launched(where, url);
@@ -1,6 +1,6 @@
1
- // arc unstable server: a game's own server, the one its developer runs: the
2
- // keys it proves itself to Arcadible with (./key/index.ts). Under
3
- // `arc unstable` until keys ship, with the docs. Not `arc serve`, which runs
1
+ // arc server: a game's own server, the one its developer runs: the
2
+ // keys it proves itself to Arcadible with (./key/index.ts). Not `arc
3
+ // serve`, which runs
4
4
  // the game on this machine: its help says so, since the two are a letter
5
5
  // apart.
6
6
  // [import]
@@ -9,9 +9,6 @@ import { create } from "../../../action/key/tool.js";
9
9
  export default defineCommand({
10
10
  name: "create",
11
11
  options: {
12
- json: JSON_OUTPUT,
13
- quiet: QUIET,
14
- cwd: CWD,
15
12
  ...CHANNEL,
16
13
  name: {
17
14
  alias: "n",
@@ -19,6 +16,9 @@ export default defineCommand({
19
16
  rc: true,
20
17
  type: "string",
21
18
  },
19
+ json: JSON_OUTPUT,
20
+ quiet: QUIET,
21
+ cwd: CWD,
22
22
  },
23
23
  run(argv, aborting) {
24
24
  return run(argv, aborting, (current, conf) => create(current, { ...conf, name: argv.name }), (made, quiet) => {
@@ -30,7 +30,7 @@ export default defineCommand({
30
30
  if (!quiet) {
31
31
  pd(keyCreated(made));
32
32
  }
33
- }, "arc unstable server key create", null, true);
33
+ }, "arc server key create", null, true);
34
34
  },
35
35
  summary: "Make a key, and print it once",
36
36
  });
@@ -1,4 +1,4 @@
1
- // arc unstable server key: a game's keys, which its own server proves itself with
1
+ // arc server key: a game's keys, which its own server proves itself with
2
2
  // to Arcadible. `create` prints the new key alone on stdout, since it's
3
3
  // shown once and is what a script wants; everything else it says goes to
4
4
  // stderr.
@@ -24,9 +24,10 @@ function rows(keys) {
24
24
  // [export]
25
25
  export default defineCommand({
26
26
  name: "list",
27
- options: { json: JSON_OUTPUT, quiet: QUIET, cwd: CWD, ...CHANNEL_SHOWS },
27
+ options: { ...CHANNEL_SHOWS, json: JSON_OUTPUT, quiet: QUIET, cwd: CWD },
28
28
  run(argv, aborting) {
29
- return run(argv, aborting, list, (keys) => {
29
+ // an object, not a bare list, so it can gain a field (OUTPUT.md)
30
+ return run(argv, aborting, async (current, conf) => ({ keys: await list(current, conf) }), ({ keys }) => {
30
31
  p(keys.length ? rows(keys) : keyNone());
31
32
  });
32
33
  },
@@ -18,7 +18,7 @@ export default defineCommand({
18
18
  p(keyRevoked(gone.id));
19
19
  }, null, () => ({
20
20
  question: keyRevokeQuestion(),
21
- usage: `arc unstable server key revoke ${argv.id}`,
21
+ usage: `arc server key revoke ${argv.id}`,
22
22
  }));
23
23
  },
24
24
  summary: "Revoke a key, by the id `list` shows",
@@ -1,4 +1,4 @@
1
- // what `arc unstable server key`'s commands share: running one as the logged-in
1
+ // what `arc server key`'s commands share: running one as the logged-in
2
2
  // account.
3
3
  // [import]
4
4
  import { resolve } from "node:path";
@@ -1,22 +1,17 @@
1
- // arc unstable: the commands that aren't settled yet: the game on
2
- // Arcadible, and what isn't released, a game's function, its server's
3
- // keys, its values, and its wires. Each may change or go in any release,
4
- // and is promoted out of it, to a name of its own, once it's settled or
5
- // released. Its commands are outside the `--json` contract (OUTPUT.md,
6
- // Unstable commands), and each reads its own table of the config files, as a
7
- // top-level command does.
1
+ // arc unstable: the commands that aren't settled yet, hidden from `arc
2
+ // --help`, and empty for now: its commands were promoted to names of their
3
+ // own (cli:4a). The next one that isn't settled goes here, such as
4
+ // `arc status` (plan/ARC-STATUS.md), outside the `--json` contract
5
+ // (OUTPUT.md, Unstable commands), and is promoted out once it is. Each
6
+ // reads its own table of the config files, as a top-level command does.
8
7
  // [import]
9
8
  import { defineCommand } from "../../cli/command.js";
10
9
  import { unstableEpilogue } from "../../phrase/index.js";
11
- import fn from "../function/index.js";
12
- import game from "../game/index.js";
13
- import server from "../server/index.js";
14
- import value from "../value/index.js";
15
- import wire from "../wire/index.js";
16
10
  // [export]
17
11
  export default defineCommand({
18
- commands: [game, fn, server, value, wire],
12
+ commands: [],
19
13
  epilogue: unstableEpilogue(),
14
+ hidden: true,
20
15
  name: "unstable",
21
16
  namespace: true,
22
17
  summary: "Use commands that aren't stable yet",
@@ -2,20 +2,24 @@
2
2
  import { defineCommand } from "../../cli/command.js";
3
3
  import { p } from "../../util/log.js";
4
4
  import { KEY } from "./key.js";
5
- import { CHANNEL, CWD, JSON_OUTPUT, QUIET } from "../../cli/options.js";
6
- import { run } from "../function/secret/run.js";
5
+ import { CHANNEL_VALUES, CWD, JSON_OUTPUT, QUIET } from "../../cli/options.js";
6
+ import { run } from "./run.js";
7
7
  import { get } from "../../action/value/tool.js";
8
+ import { getLocal } from "../../action/value/local.js";
8
9
  // [export]
9
10
  export default defineCommand({
10
11
  name: "get",
11
- options: { ...CHANNEL, json: JSON_OUTPUT, quiet: QUIET, cwd: CWD },
12
+ options: { ...CHANNEL_VALUES, json: JSON_OUTPUT, quiet: QUIET, cwd: CWD },
12
13
  positionals: { key: KEY },
13
14
  run(argv, aborting) {
14
- return run(argv, aborting, (current, conf) => get(current, { ...conf, key: argv.key }),
15
- // the value alone, as JSON, so it pipes to a file as it was set
16
- (got) => {
17
- p(JSON.stringify(got.value, null, 2));
18
- }, `arc unstable value get ${argv.key}`);
15
+ return run(argv, aborting, {
16
+ local: (root) => getLocal(root, argv.key),
17
+ remote: (current, conf) => get(current, { ...conf, key: argv.key }),
18
+ // the value alone, as JSON, so it pipes to a file as it was set
19
+ shown: (got) => {
20
+ p(JSON.stringify(got.value, null, 2));
21
+ },
22
+ });
19
23
  },
20
24
  summary: "Show a value",
21
25
  });
@@ -1,9 +1,9 @@
1
- // arc unstable value: a game's developer's values (plan/VALUES.md), the JSON
1
+ // arc value: a game's developer's values (plan/VALUES.md), the JSON
2
2
  // a game's owner publishes on a channel for the game and its server to read:
3
3
  // a daily puzzle, an event's switch, a table of levels. Set, read, listed,
4
- // and removed, a channel named each time, since nothing is copied between
5
- // them.
6
- // Under `arc unstable` until values ship, with the docs.
4
+ // and removed: with no channel, in the project's own folder, which `arc
5
+ // serve` reads (.arcadible-data/values/, cli:13a); with one, on Arcadible,
6
+ // a channel named each time, since nothing is copied between them.
7
7
  // [import]
8
8
  import { defineCommand } from "../../cli/command.js";
9
9
  import get from "./get.js";
@@ -2,10 +2,11 @@
2
2
  import { defineCommand } from "../../cli/command.js";
3
3
  import { valueNone } from "../../phrase/index.js";
4
4
  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";
5
+ import { CHANNEL_VALUES, CWD, JSON_OUTPUT, QUIET } from "../../cli/options.js";
6
+ import { run } from "./run.js";
7
7
  import { day, table } from "../../util/table.js";
8
8
  import { list } from "../../action/value/tool.js";
9
+ import { listLocal } from "../../action/value/local.js";
9
10
  // [function]
10
11
  // the values as a table, a row each: never a value, which `get` shows.
11
12
  function rows(entries) {
@@ -27,15 +28,22 @@ export default defineCommand({
27
28
  describe: "Only keys that start with this",
28
29
  type: "string",
29
30
  },
30
- ...CHANNEL,
31
+ ...CHANNEL_VALUES,
31
32
  json: JSON_OUTPUT,
32
33
  quiet: QUIET,
33
34
  cwd: CWD,
34
35
  },
35
36
  run(argv, aborting) {
36
- return run(argv, aborting, (current, conf) => list(current, { ...conf, prefix: argv.prefix }), (entries) => {
37
- p(entries.length ? rows(entries) : valueNone());
38
- }, "arc unstable value list");
37
+ // an object, not a bare list, so it can gain a field (OUTPUT.md)
38
+ return run(argv, aborting, {
39
+ local: (root) => ({ values: listLocal(root, argv.prefix) }),
40
+ remote: async (current, conf) => ({
41
+ values: await list(current, { ...conf, prefix: argv.prefix }),
42
+ }),
43
+ shown: ({ values }) => {
44
+ p(values.length ? rows(values) : valueNone());
45
+ },
46
+ });
39
47
  },
40
48
  summary: "List the values' keys, with their sizes",
41
49
  });
@@ -3,25 +3,36 @@ import { defineCommand } from "../../cli/command.js";
3
3
  import { valueRemoved, valueRemoveQuestion } from "../../phrase/index.js";
4
4
  import { p } from "../../util/log.js";
5
5
  import { KEY } from "./key.js";
6
- import { CHANNEL, CWD, JSON_OUTPUT, QUIET, YES } from "../../cli/options.js";
7
- import { run } from "../function/secret/run.js";
6
+ import { CHANNEL_VALUES, CWD, JSON_OUTPUT, QUIET, YES, } from "../../cli/options.js";
7
+ import { run } from "./run.js";
8
8
  import { remove } from "../../action/value/tool.js";
9
+ import { LOCAL, removeLocal } from "../../action/value/local.js";
9
10
  // [export]
10
11
  export default defineCommand({
11
12
  heading: "remove",
12
13
  name: "remove",
13
- options: { ...CHANNEL, json: JSON_OUTPUT, quiet: QUIET, cwd: CWD, yes: YES },
14
+ options: {
15
+ ...CHANNEL_VALUES,
16
+ json: JSON_OUTPUT,
17
+ quiet: QUIET,
18
+ cwd: CWD,
19
+ yes: YES,
20
+ },
14
21
  positionals: { key: KEY },
15
22
  run(argv, aborting) {
16
- return run(argv, aborting, (current, conf) => remove(current, { ...conf, key: argv.key }), (gone) => {
17
- p(valueRemoved({ channel: gone.channel, key: argv.key }));
18
- }, `arc unstable value remove ${argv.key}`, (where) => ({
19
- question: valueRemoveQuestion({
20
- channel: String(where),
21
- key: argv.key,
23
+ return run(argv, aborting, {
24
+ local: (root) => removeLocal(root, argv.key),
25
+ question: (where) => ({
26
+ question: valueRemoveQuestion({ channel: where, key: argv.key }),
27
+ usage: where === LOCAL
28
+ ? `arc value remove ${argv.key}`
29
+ : `arc value remove ${argv.key} --${where}`,
22
30
  }),
23
- usage: `arc unstable value remove ${argv.key} --${where}`,
24
- }));
31
+ remote: (current, conf) => remove(current, { ...conf, key: argv.key }),
32
+ shown: (gone) => {
33
+ p(valueRemoved({ channel: gone.channel, key: argv.key }));
34
+ },
35
+ });
25
36
  },
26
37
  summary: "Remove a value",
27
38
  });
@@ -0,0 +1,40 @@
1
+ // what `arc value`'s commands share: with no channel, the project's own
2
+ // values, in its folder, with no account (src/action/value/local.ts,
3
+ // cli:13a); with `--production` or `--staging`, Arcadible's, as the
4
+ // logged-in account (../function/secret/run.ts).
5
+ // [import]
6
+ import { resolve as resolvePath } from "node:path";
7
+ import { of } from "../../cli/channel.js";
8
+ import { sure } from "../../cli/confirm.js";
9
+ import { confirmDeclined } from "../../phrase/index.js";
10
+ import { p } from "../../util/log.js";
11
+ import { print } from "../../util/output.js";
12
+ import { LOCAL } from "../../action/value/local.js";
13
+ import { ensureManifest } from "../../parser/project.js";
14
+ import { run as remote, } from "../function/secret/run.js";
15
+ // [function]
16
+ // runs a value command on the channel its flags name, or, with none, on
17
+ // the project's own values.
18
+ export async function run(argv, aborting, { local, question = null, remote: onChannel, shown }) {
19
+ if (of(argv) !== null) {
20
+ await remote(argv, aborting, onChannel, shown, null, question ? (where) => question(where ?? LOCAL) : null);
21
+ return;
22
+ }
23
+ // the project's own, so only in a project: never a folder made elsewhere
24
+ const root = resolvePath(process.cwd(), argv.cwd);
25
+ await ensureManifest(root);
26
+ if (question && !(await sure(argv, question(LOCAL)))) {
27
+ // a no at the prompt changes nothing, and isn't a failure
28
+ if (!argv.quiet) {
29
+ p(confirmDeclined());
30
+ }
31
+ return;
32
+ }
33
+ const result = await local(root);
34
+ if (argv.json) {
35
+ print(result);
36
+ }
37
+ else if (!argv.quiet) {
38
+ shown(result);
39
+ }
40
+ }
@@ -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,36 +1,33 @@
1
1
  // [import]
2
2
  import { defineCommand } from "../../cli/command.js";
3
- import { p } from "../../util/log.js";
3
+ import { nlp, p } from "../../util/log.js";
4
4
  import { CHANNEL, 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.
15
+ // the scopes as a table, each by its own name. A player's row counts every
16
+ // player's together, and its limit is what each may hold, so the most any
17
+ // one holds is beside it.
21
18
  function rows(scopes) {
22
19
  return table([
23
20
  ["SCOPE", "KEYS", "SIZE", "MAY HOLD"],
24
21
  ...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
+ each.scope,
29
26
  players
30
- ? `${each.keys} (${each.owners} ${each.owners === 1 ? "player" : "players"}, ${each.keys_most} at most)`
31
- : String(each.keys),
27
+ ? `${count(each.keys)} (${count(each.owners)} ${each.owners === 1 ? "player" : "players"}, ${count(each.owner_max.keys)} at most)`
28
+ : count(each.keys),
32
29
  players
33
- ? `${valueSize(each.bytes)} (${valueSize(each.bytes_most)} at most)`
30
+ ? `${valueSize(each.bytes)} (${valueSize(each.owner_max.bytes)} at most)`
34
31
  : valueSize(each.bytes),
35
32
  players && limit !== "no limit" ? `${limit} each` : limit,
36
33
  ];
@@ -41,28 +38,35 @@ function rows(scopes) {
41
38
  // the game's clients' calls: this channel's today, and the game's against
42
39
  // its own limit for a day, which both channels share and the day (UTC)
43
40
  // 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}`;
41
+ // against its plan's: a figure a line, its account's under it. Each number
42
+ // is the API's; null is no limit.
43
+ function called({ account, channel, channel_today: mine, month, today, }) {
44
+ if (!account || !mine || !month || !today) {
45
+ return null;
46
+ }
47
+ return [
48
+ `Calls from the game today: ${count(mine.reads)} reads, ${count(mine.writes)} writes on ${channel}`,
49
+ today.allowance === null
50
+ ? ` Both channels together: ${count(today.calls)}, with no limit for a day`
51
+ : ` Both channels together: ${count(today.calls)} of ${count(today.allowance)}`,
52
+ `${count(month.calls)} calls this month`,
53
+ account.allowance === null
54
+ ? ` Your account's games together: ${count(account.calls)}, with no limit`
55
+ : ` Your account's games together: ${count(account.calls)} of ${count(account.allowance)}`,
56
+ ].join("\n");
54
57
  }
55
58
  // [export]
56
59
  export default defineCommand({
57
60
  name: "usage",
58
61
  options: { ...CHANNEL, json: JSON_OUTPUT, quiet: QUIET, cwd: CWD },
59
62
  run(argv, aborting) {
60
- return run(argv, aborting, usage, ({ calls, scopes }) => {
61
- p(rows(scopes));
63
+ return run(argv, aborting, usage, (used) => {
64
+ p(rows(used.scopes));
65
+ const calls = called(used);
62
66
  if (calls) {
63
- p(`\n${called(calls)}`);
67
+ nlp(calls);
64
68
  }
65
- }, "arc unstable value usage");
69
+ }, "arc value usage");
66
70
  },
67
71
  summary: "Show how much the game's values hold, by scope",
68
72
  });
@@ -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";