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.
- package/README.md +5 -1
- package/dist/action/deploy/result.js +3 -3
- package/dist/action/deploy/tool-git.js +1 -1
- package/dist/action/deploy/tool.js +1 -1
- package/dist/action/deploy/wait.js +1 -1
- package/dist/action/function/logs.js +4 -4
- package/dist/action/function/tool.js +11 -10
- package/dist/action/key/tool.js +10 -4
- package/dist/action/secret/tool.js +2 -1
- package/dist/action/validate/unknown.js +1 -1
- package/dist/action/value/local.js +78 -0
- package/dist/action/value/tool.js +65 -27
- package/dist/action/wire/tool.js +1 -1
- package/dist/cli/command.js +13 -1
- package/dist/cli/options.js +7 -0
- package/dist/cli/prompt.js +1 -1
- package/dist/command/deploy/report.js +5 -5
- package/dist/command/function/index.js +2 -3
- package/dist/command/function/logs.js +4 -4
- package/dist/command/function/pause.js +1 -1
- package/dist/command/function/resume.js +1 -1
- package/dist/command/function/run.js +1 -1
- package/dist/command/function/secret/index.js +1 -1
- package/dist/command/function/secret/list.js +2 -1
- package/dist/command/function/secret/remove.js +2 -2
- package/dist/command/function/secret/run.js +1 -1
- package/dist/command/function/secret/set.js +1 -1
- package/dist/command/function/status.js +11 -11
- package/dist/command/game/delete.js +2 -2
- package/dist/command/game/index.js +2 -2
- package/dist/command/open.js +1 -1
- package/dist/command/play.js +1 -1
- package/dist/command/server/index.js +3 -3
- package/dist/command/server/key/create.js +4 -4
- package/dist/command/server/key/index.js +1 -1
- package/dist/command/server/key/list.js +3 -2
- package/dist/command/server/key/revoke.js +1 -1
- package/dist/command/server/key/run.js +1 -1
- package/dist/command/unstable/index.js +8 -13
- package/dist/command/value/get.js +12 -8
- package/dist/command/value/index.js +4 -4
- package/dist/command/value/list.js +14 -6
- package/dist/command/value/remove.js +22 -11
- package/dist/command/value/run.js +40 -0
- package/dist/command/value/set.js +27 -22
- package/dist/command/value/usage.js +34 -30
- package/dist/command/wire/index.js +1 -2
- package/dist/commands.js +28 -0
- package/dist/config/code.js +4 -2
- package/dist/config/limit.js +5 -5
- package/dist/config/retry.js +2 -0
- package/dist/parser/project.js +2 -1
- package/dist/phrase/common.js +12 -6
- package/dist/phrase/deploy.js +4 -3
- package/dist/phrase/function.js +27 -21
- package/dist/phrase/game.js +3 -3
- package/dist/phrase/pack.js +4 -1
- package/dist/phrase/serve.js +2 -2
- package/dist/phrase/server.js +10 -5
- package/dist/phrase/value.js +50 -16
- package/dist/schema/client.js +11 -6
- package/dist/serve/values.js +2 -2
- package/dist/util/output.js +11 -4
- package/dist/util/schema.js +5 -3
- package/dist/util/time.js +5 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +2 -1
|
@@ -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
|
|
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
|
|
23
|
+
usage: `arc function secret remove ${argv.name} --${where}`,
|
|
24
24
|
}));
|
|
25
25
|
},
|
|
26
26
|
summary: "Remove a secret",
|
|
@@ -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
|
|
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, ({
|
|
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 (
|
|
36
|
+
if (today && month && account) {
|
|
37
37
|
const limit = (value) => value === null ? null : count(value);
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
allowance: limit(
|
|
41
|
-
|
|
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
|
-
|
|
48
|
-
allowance: limit(
|
|
49
|
-
|
|
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
|
|
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
|
|
22
|
+
const USAGE = "arc game delete";
|
|
23
23
|
// [export]
|
|
24
24
|
export default defineCommand({
|
|
25
25
|
heading: "delete",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
// arc
|
|
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.
|
|
3
|
+
// now.
|
|
4
4
|
// [import]
|
|
5
5
|
import { defineCommand } from "../../cli/command.js";
|
|
6
6
|
import del from "./delete.js";
|
package/dist/command/open.js
CHANGED
|
@@ -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);
|
package/dist/command/play.js
CHANGED
|
@@ -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
|
|
2
|
-
// keys it proves itself to Arcadible with (./key/index.ts).
|
|
3
|
-
//
|
|
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
|
|
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
|
|
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
|
|
27
|
+
options: { ...CHANNEL_SHOWS, json: JSON_OUTPUT, quiet: QUIET, cwd: CWD },
|
|
28
28
|
run(argv, aborting) {
|
|
29
|
-
|
|
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
|
|
21
|
+
usage: `arc server key revoke ${argv.id}`,
|
|
22
22
|
}));
|
|
23
23
|
},
|
|
24
24
|
summary: "Revoke a key, by the id `list` shows",
|
|
@@ -1,22 +1,17 @@
|
|
|
1
|
-
// arc unstable: the commands that aren't settled yet
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
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: [
|
|
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 {
|
|
6
|
-
import { run } from "
|
|
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: { ...
|
|
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,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
|
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
|
|
5
|
-
//
|
|
6
|
-
//
|
|
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 {
|
|
6
|
-
import { run } from "
|
|
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
|
-
...
|
|
31
|
+
...CHANNEL_VALUES,
|
|
31
32
|
json: JSON_OUTPUT,
|
|
32
33
|
quiet: QUIET,
|
|
33
34
|
cwd: CWD,
|
|
34
35
|
},
|
|
35
36
|
run(argv, aborting) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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 {
|
|
7
|
-
import { run } from "
|
|
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: {
|
|
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,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
|
|
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 {
|
|
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 {
|
|
6
|
-
import { run } from "
|
|
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
|
-
|
|
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
|
|
51
|
-
return run(argv, aborting,
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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,
|
|
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
|
|
20
|
-
// its limit is what each may hold, so the most any
|
|
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
|
-
|
|
25
|
+
each.scope,
|
|
29
26
|
players
|
|
30
|
-
? `${each.keys} (${each.owners} ${each.owners === 1 ? "player" : "players"}, ${each.
|
|
31
|
-
:
|
|
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.
|
|
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
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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, (
|
|
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
|
-
|
|
67
|
+
nlp(calls);
|
|
64
68
|
}
|
|
65
|
-
}, "arc
|
|
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
|
|
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";
|