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
@@ -54,20 +54,20 @@ export function handler({ json, pb, quiet, sw, warnings, }) {
54
54
  // what was deployed, whether workflow.build ran, where it will be once it's
55
55
  // published (the store only shows production), and what happens next. Once
56
56
  // waited on, it's published, so it says so.
57
- export function report({ built, channel, store, tag, url, version }, { git, published }) {
57
+ export function report({ built, channel, play_url: play, store_url: store, tag, version }, { git, published }) {
58
58
  let heading = git
59
59
  ? tagPushed(String(tag))
60
- : buildSubmitted(version.to, channel, built);
60
+ : buildSubmitted(version, channel, built);
61
61
  let next = git
62
62
  ? buildPublishingGit(channel)
63
63
  : buildPublishing();
64
64
  if (published) {
65
- heading = releasePublished(version.to, channel, built);
65
+ heading = releasePublished(version, channel, built);
66
66
  next = null;
67
67
  }
68
68
  logResult(heading, [
69
69
  store ? [storeLabel(), store] : null,
70
- [playLabel(), url],
70
+ [playLabel(), play],
71
71
  next,
72
72
  ]);
73
73
  }
@@ -100,7 +100,7 @@ export async function waitAndReport(current, deployed, result, { git, json, quie
100
100
  const data = { ...result, release: releaseJson(waited.release) };
101
101
  if (waited.timedOut) {
102
102
  const found = Boolean(waited.release);
103
- const reason = releaseTimedOut(result.version.to, timeout, {
103
+ const reason = releaseTimedOut(result.version, timeout, {
104
104
  actions,
105
105
  found,
106
106
  git,
@@ -1,17 +1,17 @@
1
- // arc unstable function: a game's function, the server code Arcadible runs
1
+ // arc function: a game's function, the server code Arcadible runs
2
2
  // for it: paused and resumed on a channel by the game's owner, with no
3
- // release, its logs, and its secrets (./secret/index.ts). Under
4
- // `arc unstable` until functions ship, with the docs.
3
+ // release, its logs, and its secrets (./secret/index.ts).
5
4
  // [import]
6
5
  import { defineCommand } from "../../cli/command.js";
7
6
  import secret from "./secret/index.js";
8
7
  import pause from "./pause.js";
9
8
  import resume from "./resume.js";
10
9
  import status from "./status.js";
10
+ import usage from "./usage.js";
11
11
  import logs from "./logs.js";
12
12
  // [export]
13
13
  export default defineCommand({
14
- commands: [pause, resume, status, logs, secret],
14
+ commands: [pause, resume, status, usage, logs, secret],
15
15
  name: "function",
16
16
  summary: "Pause, resume, and show the game's function, its logs, and its secrets",
17
17
  });
@@ -1,4 +1,4 @@
1
- // arc unstable function logs: what the game's function said, as Arcadible keeps it,
1
+ // arc function logs: what the game's function said, as Arcadible keeps it,
2
2
  // for its owner (plan/FUNCTION-LOGS.md, Reading them): the newest 100
3
3
  // requests, oldest first, as `tail` prints, or those and then each as it
4
4
  // comes, with `--follow`. With `--json`, an entry a line, as the logs
@@ -105,7 +105,7 @@ export default defineCommand({
105
105
  describe: "From a time: 10m, 2h, 1d, or an ISO time",
106
106
  type: "string",
107
107
  },
108
- errors: {
108
+ failed: {
109
109
  describe: "Only the requests that failed",
110
110
  type: "boolean",
111
111
  },
@@ -131,7 +131,7 @@ export default defineCommand({
131
131
  sw.stop(true);
132
132
  const conf = {
133
133
  channel: where,
134
- errors: argv.errors,
134
+ failed: argv.failed,
135
135
  root: resolvePath(process.cwd(), argv.cwd),
136
136
  since: argv.since,
137
137
  version: argv.release,
@@ -153,7 +153,7 @@ export default defineCommand({
153
153
  show(entry, json);
154
154
  if (!entries.length && !json) {
155
155
  p(functionLogsNone({
156
- filtered: Boolean(where || argv.release || argv.since || argv.errors),
156
+ filtered: Boolean(where || argv.release || argv.since || argv.failed),
157
157
  }));
158
158
  }
159
159
  },
@@ -12,7 +12,7 @@ export default defineCommand({
12
12
  run(argv, aborting) {
13
13
  return run(argv, aborting, pause, (paused) => {
14
14
  p(functionPaused(paused));
15
- }, "arc unstable function pause");
15
+ }, "arc function pause");
16
16
  },
17
17
  summary: "Pause the game's function on a channel",
18
18
  });
@@ -12,7 +12,7 @@ export default defineCommand({
12
12
  run(argv, aborting) {
13
13
  return run(argv, aborting, resume, (resumed) => {
14
14
  p(functionResumed(resumed));
15
- }, "arc unstable function resume");
15
+ }, "arc function resume");
16
16
  },
17
17
  summary: "Resume the game's function on a channel",
18
18
  });
@@ -1,4 +1,4 @@
1
- // what `arc unstable function`'s own commands share: running one as the logged-in
1
+ // what `arc function`'s own commands share: running one as the logged-in
2
2
  // account.
3
3
  // [import]
4
4
  import { resolve as resolvePath } from "node:path";
@@ -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,28 +1,18 @@
1
1
  // [import]
2
2
  import { defineCommand } from "../../cli/command.js";
3
- import { cpuTime, functionState, functionUsage } from "../../phrase/index.js";
3
+ import { functionState } from "../../phrase/index.js";
4
4
  import { 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";
8
8
  import { status } from "../../action/function/tool.js";
9
9
  // [function]
10
- // a count as it's read: 1,000,000.
11
- function count(value) {
12
- return value.toLocaleString("en-US");
13
- }
14
- // [function]
15
- // each channel's function as a table, a row each: its requests and CPU
16
- // time this month.
10
+ // each channel's function as a table, a row each: running, or why it's
11
+ // paused and until when. Its numbers are `arc function usage`'s.
17
12
  function rows(channels) {
18
13
  return table([
19
- ["CHANNEL", "STATUS", "REQUESTS", "CPU"],
20
- ...channels.map((each) => [
21
- each.channel,
22
- functionState(each),
23
- count(each.requests),
24
- cpuTime(each.cpu_ms),
25
- ]),
14
+ ["CHANNEL", "STATUS"],
15
+ ...channels.map((each) => [each.channel, functionState(each)]),
26
16
  ]);
27
17
  }
28
18
  // [export]
@@ -30,28 +20,9 @@ export default defineCommand({
30
20
  name: "status",
31
21
  options: { ...CHANNEL_SHOWS, json: JSON_OUTPUT, quiet: QUIET, cwd: CWD },
32
22
  run(argv, aborting) {
33
- return run(argv, aborting, status, ({ channels, day, month, pool }) => {
23
+ return run(argv, aborting, status, ({ channels }) => {
34
24
  p(rows(channels));
35
- // nothing to say of its limits when its usage couldn't be read
36
- if (day && month && pool) {
37
- const limit = (value) => value === null ? null : count(value);
38
- p(functionUsage({
39
- day: {
40
- allowance: limit(day.allowance),
41
- requests: count(day.requests),
42
- },
43
- month: {
44
- cpu: cpuTime(month.cpu_ms),
45
- requests: count(month.requests),
46
- },
47
- pool: {
48
- allowance: limit(pool.allowance),
49
- cpu: cpuTime(pool.cpu_ms),
50
- requests: count(pool.requests),
51
- },
52
- }));
53
- }
54
25
  });
55
26
  },
56
- summary: "Show whether the game's function is running, and its usage against its limits",
27
+ summary: "Show whether the game's function is running, on each channel",
57
28
  });
@@ -0,0 +1,64 @@
1
+ // [import]
2
+ import { defineCommand } from "../../cli/command.js";
3
+ import { cpuTime, functionUsage } from "../../phrase/index.js";
4
+ import { nlp, p } from "../../util/log.js";
5
+ import { CHANNEL_SHOWS, CWD, JSON_OUTPUT, QUIET } from "../../cli/options.js";
6
+ import { run } from "./run.js";
7
+ import { table } from "../../util/table.js";
8
+ import { usage } from "../../action/function/tool.js";
9
+ // [function]
10
+ // a count as it's read: 1,000,000.
11
+ function count(value) {
12
+ return value.toLocaleString("en-US");
13
+ }
14
+ // [function]
15
+ // each channel's own as a table, a row each: its requests and CPU time
16
+ // today and this month.
17
+ function rows(channels) {
18
+ return table([
19
+ [
20
+ "CHANNEL",
21
+ "REQUESTS TODAY",
22
+ "CPU TODAY",
23
+ "REQUESTS THIS MONTH",
24
+ "CPU THIS MONTH",
25
+ ],
26
+ ...channels.map((each) => [
27
+ each.channel,
28
+ count(each.today.requests),
29
+ cpuTime(each.today.cpu_ms),
30
+ count(each.month.requests),
31
+ cpuTime(each.month.cpu_ms),
32
+ ]),
33
+ ]);
34
+ }
35
+ // [export]
36
+ export default defineCommand({
37
+ name: "usage",
38
+ options: { ...CHANNEL_SHOWS, json: JSON_OUTPUT, quiet: QUIET, cwd: CWD },
39
+ run(argv, aborting) {
40
+ return run(argv, aborting, usage, ({ account, channels, month, today }) => {
41
+ p(rows(channels));
42
+ // nothing to say of its limits when its usage couldn't be read
43
+ if (today && month && account) {
44
+ const limit = (value) => value === null ? null : count(value);
45
+ nlp(functionUsage({
46
+ account: {
47
+ allowance: limit(account.allowance),
48
+ cpu: cpuTime(account.cpu_ms),
49
+ requests: count(account.requests),
50
+ },
51
+ month: {
52
+ cpu: cpuTime(month.cpu_ms),
53
+ requests: count(month.requests),
54
+ },
55
+ today: {
56
+ allowance: limit(today.allowance),
57
+ requests: count(today.requests),
58
+ },
59
+ }));
60
+ }
61
+ });
62
+ },
63
+ summary: "Show what the game's function answered, today and this month, against its limits",
64
+ });
@@ -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
+ }