arcadible 1.0.38 → 1.0.40-next.0
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 +2 -2
- package/dist/account.js +52 -0
- package/dist/action/deploy/tool.js +5 -3
- package/dist/action/deploy/wait.js +8 -6
- package/dist/action/function/logs.js +6 -2
- package/dist/action/key/tool.js +1 -1
- package/dist/action/login/tool.js +4 -3
- package/dist/action/pack/hosted.js +58 -0
- package/dist/action/pack/limits.js +44 -13
- package/dist/action/pack/tool.js +6 -3
- package/dist/action/serve/tool.js +36 -12
- package/dist/action/validate/tool.js +1 -1
- package/dist/cli/command.js +21 -6
- package/dist/cli/confirm.js +1 -1
- package/dist/cli/options.js +2 -2
- package/dist/cli/prompt.js +168 -0
- package/dist/cli/rc.js +34 -58
- package/dist/command/deploy/report.js +134 -0
- package/dist/command/deploy.js +8 -130
- package/dist/command/function/secret/remove.js +1 -0
- package/dist/command/function/secret/set.js +2 -2
- package/dist/command/game/delete.js +1 -0
- package/dist/command/init.js +2 -12
- package/dist/command/inspect.js +1 -1
- package/dist/command/open.js +1 -1
- package/dist/command/pack.js +2 -2
- package/dist/command/play.js +1 -1
- package/dist/command/serve.js +6 -1
- package/dist/command/server/key/revoke.js +1 -0
- package/dist/command/unstable/index.js +1 -1
- package/dist/command/value/remove.js +1 -0
- package/dist/config/code.js +3 -1
- package/dist/config/uri.js +3 -2
- package/dist/parser/readme-file.js +3 -4
- package/dist/parser/readme.js +9 -16
- package/dist/parser/sections.js +10 -19
- package/dist/phrase/account.js +3 -1
- package/dist/phrase/pack.js +15 -0
- package/dist/phrase/serve.js +11 -1
- package/dist/serve/page.js +21 -5
- package/dist/serve/remote.js +8 -5
- package/dist/serve/retry.js +44 -0
- package/dist/serve/runner.js +55 -9
- package/dist/serve/server.js +17 -6
- package/dist/serve/wires.js +32 -12
- package/dist/util/doc.js +6 -16
- package/dist/util/links.js +4 -2
- package/dist/util/objs.js +1 -1
- package/dist/util/tree.js +79 -0
- package/dist/util/zip.js +19 -2
- package/dist/wires/room.js +154 -29
- package/npm-shrinkwrap.json +20 -854
- package/package.json +3 -5
package/README.md
CHANGED
|
@@ -48,12 +48,12 @@ Your repository is the store page: `arcadible.toml` holds the game's settings, `
|
|
|
48
48
|
| `arc pack` | Packages your project into the zip that `arc deploy` uploads |
|
|
49
49
|
| `arc serve` | Serves your game locally, framed in a play page, as Arcadible does |
|
|
50
50
|
| `arc deploy` | Validates, builds, packages, and publishes, directly or through GitHub Actions |
|
|
51
|
-
| `arc play` | Plays a deployed game from any channel or version |
|
|
52
51
|
| `arc open` | Opens a game's store page |
|
|
52
|
+
| `arc play` | Plays a deployed game from any channel or version |
|
|
53
53
|
| `arc login` | Logs in to Arcadible with a device code |
|
|
54
54
|
| `arc logout` | Logs out |
|
|
55
55
|
| `arc whoami` | Shows the account you're logged in to |
|
|
56
|
-
| `arc unstable` | Commands
|
|
56
|
+
| `arc unstable` | Commands that aren't settled yet, which may change or go in any release |
|
|
57
57
|
|
|
58
58
|
Run `arc <command> --help` for its options, or see the [CLI reference](https://developer.arcadible.com/references/arcadible-cli).
|
|
59
59
|
|
package/dist/account.js
CHANGED
|
@@ -157,6 +157,43 @@ export function ended(current) {
|
|
|
157
157
|
};
|
|
158
158
|
}
|
|
159
159
|
// [function]
|
|
160
|
+
// the session to send again with, once the API refused `current`'s access
|
|
161
|
+
// token: the saved one, when another arc renewed it meanwhile (a refresh
|
|
162
|
+
// token works once, so renewing from `current`'s would end the session),
|
|
163
|
+
// or else `current`'s, renewed and saved. A refresh refused is the
|
|
164
|
+
// session's end, as `refresh` says.
|
|
165
|
+
async function renew(current) {
|
|
166
|
+
const saved = await readSaved();
|
|
167
|
+
const base = isAccount(saved) ? saved : current;
|
|
168
|
+
if (base.session.access_token !== current.session.access_token &&
|
|
169
|
+
!expired(base.session)) {
|
|
170
|
+
return base;
|
|
171
|
+
}
|
|
172
|
+
return refresh(base);
|
|
173
|
+
}
|
|
174
|
+
// [function]
|
|
175
|
+
// sends `call` with the account's access token, and when the API refuses it
|
|
176
|
+
// (401) for the saved session, renews the session and sends it once more. A
|
|
177
|
+
// token can expire during a long command (a deploy's build, upload, and
|
|
178
|
+
// wait), where `get` renews it only at the start. Renewed, `current` holds
|
|
179
|
+
// the new session, so the calls after it send that. An ARCADIBLE_TOKEN's
|
|
180
|
+
// refusal stands, as does a second refusal, which `ended` then reads.
|
|
181
|
+
export async function authed(current, call) {
|
|
182
|
+
try {
|
|
183
|
+
return await call(auth(current?.session.access_token));
|
|
184
|
+
}
|
|
185
|
+
catch (ex) {
|
|
186
|
+
if (!current?.session ||
|
|
187
|
+
current.token ||
|
|
188
|
+
!(ex instanceof HttpError) ||
|
|
189
|
+
ex.status !== 401) {
|
|
190
|
+
throw ex;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
current.session = (await renew(current)).session;
|
|
194
|
+
return call(auth(current.session.access_token));
|
|
195
|
+
}
|
|
196
|
+
// [function]
|
|
160
197
|
// an access token for the saved session to end with: its own, or a refreshed
|
|
161
198
|
// one when it's expired, which isn't saved, since the session is ending.
|
|
162
199
|
function accessToken(session) {
|
|
@@ -172,6 +209,21 @@ function revoke(session) {
|
|
|
172
209
|
return accessToken(session).then((access) => postAuthLogout(null, auth(access)));
|
|
173
210
|
}
|
|
174
211
|
// [function]
|
|
212
|
+
// the saved session, ended on the server as a new one replaces it at a
|
|
213
|
+
// login, so a login never leaves the last one working where no file holds
|
|
214
|
+
// it. Never an error, as `end`; the file is left for the new session to
|
|
215
|
+
// overwrite.
|
|
216
|
+
export function replace() {
|
|
217
|
+
return readSaved()
|
|
218
|
+
.then((current) => {
|
|
219
|
+
if (!isAccount(current) || !current.session.refresh_token) {
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
return revoke(current.session).then(() => undefined, () => undefined);
|
|
223
|
+
})
|
|
224
|
+
.catch(() => undefined);
|
|
225
|
+
}
|
|
226
|
+
// [function]
|
|
175
227
|
// a logout: the saved session ended on the server, so its refresh token stops
|
|
176
228
|
// working, then removed. Never an error: a refused refresh means the session
|
|
177
229
|
// was already over, and a failure to reach the API (offline, an outage)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// [import]
|
|
2
|
-
import {
|
|
2
|
+
import { authed } from "../../account.js";
|
|
3
|
+
import { postUpload } from "../../api.js";
|
|
3
4
|
import { DEPLOY_RATE_LIMITED, GAME_UNAVAILABLE } from "../../config/code.js";
|
|
4
5
|
import { ArcError } from "../../util/error.js";
|
|
5
6
|
import { releasing } from "../predeploy/game.js";
|
|
@@ -9,14 +10,15 @@ import { published } from "../../util/links.js";
|
|
|
9
10
|
import { upload as s3Upload } from "../../util/s3.js";
|
|
10
11
|
// [function]
|
|
11
12
|
// asks the API for an upload link, then sends the zip to it, and resolves
|
|
12
|
-
// with the upload.
|
|
13
|
+
// with the upload. A session that expired since the deploy began (its build
|
|
14
|
+
// can be long) is renewed, and the link asked for again (`authed`).
|
|
13
15
|
function uploadBuild(current, artifact, { id, version }, onProgress) {
|
|
14
16
|
const form = new FormData();
|
|
15
17
|
form.append("artifact", id);
|
|
16
18
|
form.append("version", version);
|
|
17
19
|
form.append("sha256", artifact.sha256);
|
|
18
20
|
form.append("size", String(artifact.size));
|
|
19
|
-
return postUpload(form, null,
|
|
21
|
+
return authed(current, (headers) => postUpload(form, null, headers)).then((upload) => s3Upload(upload.upload_url, artifact, onProgress).then(() => upload), (err) => {
|
|
20
22
|
// the API refuses a game that was deleted or is another account's
|
|
21
23
|
// (403), and the same version deployed again within 5 minutes (429),
|
|
22
24
|
// each by its code.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// [import]
|
|
2
|
-
import { ended } from "../../account.js";
|
|
3
|
-
import {
|
|
2
|
+
import { authed, ended } from "../../account.js";
|
|
3
|
+
import { discoverGameReleases, release as apiRelease, } from "../../api.js";
|
|
4
4
|
import { sleep } from "../../util/delay.js";
|
|
5
5
|
import { git } from "../predeploy/git.js";
|
|
6
6
|
import { HttpError } from "../../util/http.js";
|
|
@@ -32,9 +32,11 @@ function actionsUrl(root) {
|
|
|
32
32
|
}, () => null);
|
|
33
33
|
}
|
|
34
34
|
// [function]
|
|
35
|
-
// a direct deploy's release, by its upload's id
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
// a direct deploy's release, by its upload's id, with the session's token:
|
|
36
|
+
// one that expires during the wait is renewed, and the check sent again
|
|
37
|
+
// (`authed`), so a wait longer than a token lasts goes on.
|
|
38
|
+
function findDirect(id, current) {
|
|
39
|
+
return () => authed(current, (headers) => apiRelease(id, { select: SELECT }, headers));
|
|
38
40
|
}
|
|
39
41
|
// [function]
|
|
40
42
|
// a git deploy's release: GitHub's, for this version, made since the tag was
|
|
@@ -90,7 +92,7 @@ export function wait(current, deployed, { git: isGit, root, since, timeout }, {
|
|
|
90
92
|
const game = deployed.game;
|
|
91
93
|
const find = isGit || !("release" in deployed)
|
|
92
94
|
? findGit({ game, since, version: deployed.version.to })
|
|
93
|
-
: findDirect(deployed.release,
|
|
95
|
+
: findDirect(deployed.release, current);
|
|
94
96
|
return Promise.all([
|
|
95
97
|
pollRelease(find, timeout, onRelease),
|
|
96
98
|
isGit ? actionsUrl(root) : null,
|
|
@@ -24,6 +24,8 @@ const PING = 30 * 1000;
|
|
|
24
24
|
// the longest wait between them.
|
|
25
25
|
const TRIES = 5;
|
|
26
26
|
const WAIT = 30 * 1000;
|
|
27
|
+
// the least wait before a follow that closed is opened again.
|
|
28
|
+
const AGAIN = 1000;
|
|
27
29
|
// a version as the Worker takes it, and a span back from now.
|
|
28
30
|
const VERSION = /^[0-9A-Za-z.+-]{1,64}$/u;
|
|
29
31
|
const SPAN = /^([1-9][0-9]{0,4})([mhd])$/u;
|
|
@@ -232,7 +234,9 @@ export async function follow(current, { channel, ...conf }, shown) {
|
|
|
232
234
|
if (failed >= TRIES) {
|
|
233
235
|
throw new ArcError(API_UNREACHABLE, unableToReach());
|
|
234
236
|
}
|
|
235
|
-
|
|
236
|
-
|
|
237
|
+
// a follow that opened and closed is opened again after a second at
|
|
238
|
+
// least, so one the Worker ever closed at once can't ask for tokens in
|
|
239
|
+
// a tight loop; one that didn't open waits longer each time
|
|
240
|
+
await sleep(failed ? Math.min(WAIT, 1000 * 2 ** failed) : AGAIN);
|
|
237
241
|
}
|
|
238
242
|
}
|
package/dist/action/key/tool.js
CHANGED
|
@@ -14,7 +14,7 @@ const NAME = "Server";
|
|
|
14
14
|
// a new key, as `{ id, name, channel, key }`: the only time the key is had.
|
|
15
15
|
export async function create(current, { channel, name, ...conf }) {
|
|
16
16
|
const given = name ?? NAME;
|
|
17
|
-
// a name that isn't text (a number in a
|
|
17
|
+
// a name that isn't text (a number in a config file) is refused as any
|
|
18
18
|
// other that won't do.
|
|
19
19
|
const named = typeof given === "string" ? given.trim() : "";
|
|
20
20
|
if (named === "" || named.length > NAME_MAX) {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
// [import]
|
|
2
|
-
import { save } from "../../account.js";
|
|
2
|
+
import { replace, save } from "../../account.js";
|
|
3
3
|
import { flow } from "./flow.js";
|
|
4
4
|
// [function]
|
|
5
|
-
// logs in, and saves the session
|
|
5
|
+
// logs in, and saves the session, in place of the one saved before, which
|
|
6
|
+
// is ended on the server.
|
|
6
7
|
export function login(_conf, handler) {
|
|
7
|
-
return flow(handler).then(save);
|
|
8
|
+
return flow(handler).then((account) => replace().then(() => save(account)));
|
|
8
9
|
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// the packed pages that load the SDK's 1.5 hosted script,
|
|
2
|
+
// /arcadible/sdk/v1.js, which stays as it was released for the builds
|
|
3
|
+
// released with it: a fact each page's markup says, read as a browser reads
|
|
4
|
+
// it, each `script` element's `src` by its path. A script a page adds by
|
|
5
|
+
// code isn't seen, on purpose: that would be a guess.
|
|
6
|
+
// [import]
|
|
7
|
+
import { WARNING } from "../../config/code.js";
|
|
8
|
+
import { sdkScriptOld } from "../../phrase/index.js";
|
|
9
|
+
import { attrsOf, childrenOf, parseDocument, tagOf, } from "../../util/tree.js";
|
|
10
|
+
// [declare]
|
|
11
|
+
// the SDK's 1.5 script, and the current SDK's.
|
|
12
|
+
const OLD = "/arcadible/sdk/v1.js";
|
|
13
|
+
const NOW = "/arcadible/lib/sdk.v1.js";
|
|
14
|
+
// how much is read, so a package of any size is checked quickly: the most
|
|
15
|
+
// pages, and the most of one. Past them a page isn't read, so a warning can
|
|
16
|
+
// be missed, never made up.
|
|
17
|
+
const MAX_PAGES = 200;
|
|
18
|
+
const MAX_PAGE = 1024 * 1024;
|
|
19
|
+
// [function]
|
|
20
|
+
// whether a script's `src` names the old script: its path, without its
|
|
21
|
+
// query or fragment, ending in `/arcadible/sdk/v1.js` exactly, from the
|
|
22
|
+
// root or from the page.
|
|
23
|
+
function isOld(src) {
|
|
24
|
+
const path = src.trim().split(/[?#]/u)[0] ?? "";
|
|
25
|
+
return `/${path}`.endsWith(OLD);
|
|
26
|
+
}
|
|
27
|
+
// [function]
|
|
28
|
+
// whether a document loads the old script: any `script` element's `src`,
|
|
29
|
+
// in the head or the body. A template's content and a comment aren't
|
|
30
|
+
// elements of the page, so they're never read.
|
|
31
|
+
function loads(node) {
|
|
32
|
+
if (tagOf(node) === "script" && "attrs" in node) {
|
|
33
|
+
const src = attrsOf(node).find((attr) => attr.name === "src");
|
|
34
|
+
if (src && isOld(src.value)) {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return childrenOf(node).some(loads);
|
|
39
|
+
}
|
|
40
|
+
// [function]
|
|
41
|
+
// each packed page that loads the old script, by its name in the package.
|
|
42
|
+
export function hosted(zip) {
|
|
43
|
+
const pages = zip
|
|
44
|
+
.entries()
|
|
45
|
+
.filter((entry) => entry.size <= MAX_PAGE && /\.html?$/iu.test(entry.name))
|
|
46
|
+
.slice(0, MAX_PAGES);
|
|
47
|
+
return pages.flatMap((page) => {
|
|
48
|
+
const html = zip.read(page.name)?.toString("utf8");
|
|
49
|
+
return html !== undefined && loads(parseDocument(html))
|
|
50
|
+
? [
|
|
51
|
+
{
|
|
52
|
+
code: WARNING.SDK_SCRIPT_OLD,
|
|
53
|
+
message: sdkScriptOld(page.name, OLD, NOW),
|
|
54
|
+
},
|
|
55
|
+
]
|
|
56
|
+
: [];
|
|
57
|
+
});
|
|
58
|
+
}
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import fs from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
// [import]
|
|
5
|
-
import { PACKAGE_FILE_TOO_LARGE, PACKAGE_PATH_INVALID, PACKAGE_TOO_MANY_FILES, PACKAGE_UNCOMPRESSED_TOO_LARGE, } from "../../config/code.js";
|
|
5
|
+
import { PACKAGE_FILE_TOO_LARGE, PACKAGE_LINK_INVALID, PACKAGE_PATH_INVALID, PACKAGE_TOO_MANY_FILES, PACKAGE_UNCOMPRESSED_TOO_LARGE, } from "../../config/code.js";
|
|
6
6
|
import { ArcError } from "../../util/error.js";
|
|
7
|
-
import { packageFileTooLarge, packagePathInvalid, packageTooManyEntries, packageTooManyFiles, packageUncompressedTooLarge, } from "../../phrase/index.js";
|
|
7
|
+
import { packageFileTooLarge, packageLinkInvalid, packagePathInvalid, packageTooManyEntries, packageTooManyFiles, packageUncompressedTooLarge, } from "../../phrase/index.js";
|
|
8
8
|
import { ENTRIES, FILE_SIZE, FILES, TOTAL_SIZE } from "../../config/limit.js";
|
|
9
9
|
import { toMb } from "../../util/size.js";
|
|
10
10
|
// [declare]
|
|
@@ -34,7 +34,8 @@ export function checkEntries(count) {
|
|
|
34
34
|
// checks a zip's files against the limits, and throws for the first one it
|
|
35
35
|
// breaks: a name that isn't plain, a file over 64 MB, more than 10,000 files,
|
|
36
36
|
// or over 256 MB in all.
|
|
37
|
-
export function check(
|
|
37
|
+
export function check(all) {
|
|
38
|
+
const entries = all.filter((entry) => !entry.folder);
|
|
38
39
|
const unplain = entries.find((entry) => !isPlain(entry.name));
|
|
39
40
|
if (unplain) {
|
|
40
41
|
throw new ArcError(PACKAGE_PATH_INVALID, packagePathInvalid(unplain.name));
|
|
@@ -57,14 +58,44 @@ export function check(entries) {
|
|
|
57
58
|
// before any of it is read into memory. A file over 64 MB is then refused
|
|
58
59
|
// at once, and nothing that large is held when the command exits, which
|
|
59
60
|
// matters: Node 24 can hang in `process.exit` with that much just allocated
|
|
60
|
-
// (TODO.md, Known bugs).
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
61
|
+
// (TODO.md, Known bugs). A link is packed as what it leads to, under its
|
|
62
|
+
// own name, when that's inside the folder; one that leads outside it (which
|
|
63
|
+
// the release couldn't follow either), back into a folder holding it, or
|
|
64
|
+
// to nothing is refused, naming it, rather than left out of the package.
|
|
65
|
+
// Each folder is an entry too, before what it holds.
|
|
66
|
+
export function measure(dir) {
|
|
67
|
+
const root = fs.realpathSync(dir);
|
|
68
|
+
const inside = (real) => real === root || real.startsWith(root + path.sep);
|
|
69
|
+
// `holding`: the real paths of the folders the walk is in, to tell a loop
|
|
70
|
+
const walk = function (at, under, holding) {
|
|
71
|
+
return fs.readdirSync(at).flatMap((name) => {
|
|
72
|
+
const file = path.join(at, name);
|
|
73
|
+
const entry = under ? `${under}/${name}` : name;
|
|
74
|
+
let real = file;
|
|
75
|
+
if (fs.lstatSync(file).isSymbolicLink()) {
|
|
76
|
+
try {
|
|
77
|
+
real = fs.realpathSync(file);
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
throw new ArcError(PACKAGE_LINK_INVALID, packageLinkInvalid(entry, "nowhere"));
|
|
81
|
+
}
|
|
82
|
+
if (!inside(real)) {
|
|
83
|
+
throw new ArcError(PACKAGE_LINK_INVALID, packageLinkInvalid(entry, "outside"));
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
const stat = fs.statSync(real);
|
|
87
|
+
if (!stat.isDirectory()) {
|
|
88
|
+
return [{ file: real, name: entry, size: stat.size }];
|
|
89
|
+
}
|
|
90
|
+
const folder = fs.realpathSync(real);
|
|
91
|
+
if (holding.includes(folder)) {
|
|
92
|
+
throw new ArcError(PACKAGE_LINK_INVALID, packageLinkInvalid(entry, "loop"));
|
|
93
|
+
}
|
|
94
|
+
return [
|
|
95
|
+
{ folder: true, name: entry, size: 0 },
|
|
96
|
+
...walk(real, entry, [...holding, folder]),
|
|
97
|
+
];
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
return walk(dir, "", [root]);
|
|
70
101
|
}
|
package/dist/action/pack/tool.js
CHANGED
|
@@ -13,6 +13,7 @@ import { check, checkEntries, measure } from "./limits.js";
|
|
|
13
13
|
import { favicon } from "../../util/favicon.js";
|
|
14
14
|
import { handle, tool } from "../../config/product.js";
|
|
15
15
|
import { toMb } from "../../util/size.js";
|
|
16
|
+
import { hosted } from "./hosted.js";
|
|
16
17
|
import { unsound } from "./unsound.js";
|
|
17
18
|
import { Zip } from "../../util/zip.js";
|
|
18
19
|
// [use]
|
|
@@ -101,8 +102,9 @@ function pack(name, game, { deployDir, icon, inputPath, mediaPath, onWarning, ou
|
|
|
101
102
|
: new ArcError(PATH_NOT_FOUND, unableToFind(inputPath));
|
|
102
103
|
}
|
|
103
104
|
// held to the limits by its sizes on disk, before any of it is read
|
|
104
|
-
|
|
105
|
-
|
|
105
|
+
const files = measure(inputPath);
|
|
106
|
+
check(files);
|
|
107
|
+
zip.addFiles(files);
|
|
106
108
|
return zip;
|
|
107
109
|
})
|
|
108
110
|
.then(verifyPartial)
|
|
@@ -116,7 +118,7 @@ function pack(name, game, { deployDir, icon, inputPath, mediaPath, onWarning, ou
|
|
|
116
118
|
})
|
|
117
119
|
.then((existsMedia) => {
|
|
118
120
|
if (existsMedia) {
|
|
119
|
-
zip.
|
|
121
|
+
zip.addFiles(measure(mediaPath), MEDIA);
|
|
120
122
|
}
|
|
121
123
|
// what the build's client may reach goes with it, when it declares
|
|
122
124
|
// any: the pipeline makes its policy from it, and a ticket is only ever
|
|
@@ -151,6 +153,7 @@ function pack(name, game, { deployDir, icon, inputPath, mediaPath, onWarning, ou
|
|
|
151
153
|
.then((file) => {
|
|
152
154
|
if (onWarning) {
|
|
153
155
|
unsound(file.entries()).forEach(onWarning);
|
|
156
|
+
hosted(file).forEach(onWarning);
|
|
154
157
|
}
|
|
155
158
|
file.write(outputPath);
|
|
156
159
|
return { path: outputPath, ...file.stat() };
|
|
@@ -27,6 +27,7 @@ import { LOOPBACK, serve, } from "../../serve/server.js";
|
|
|
27
27
|
import { playerOf } from "../../serve/ticket.js";
|
|
28
28
|
import { buildTool } from "../build/tool.js";
|
|
29
29
|
import { ARCADIBLE_SDK, HOST_HTTP_PLAY } from "../../config/uri.js";
|
|
30
|
+
import { SECRET_NAME, SECRETS } from "../../config/limit.js";
|
|
30
31
|
// [declare]
|
|
31
32
|
// what build.channel says while served locally (docs: arc-serve.md).
|
|
32
33
|
const CHANNEL = "local";
|
|
@@ -144,6 +145,32 @@ function strings(value) {
|
|
|
144
145
|
: [];
|
|
145
146
|
}
|
|
146
147
|
// [function]
|
|
148
|
+
// the secrets the manifest names, from this process's own environment: one
|
|
149
|
+
// that isn't set is undefined in the code, as on Arcadible. Only the names
|
|
150
|
+
// Arcadible can set (SECRET_NAME), and no more than a function takes
|
|
151
|
+
// (SECRETS): any other would never have a value once released, so it has
|
|
152
|
+
// none here either, and `onWarning` says so.
|
|
153
|
+
export function secretsOf(declared, onWarning) {
|
|
154
|
+
const out = {};
|
|
155
|
+
let taken = 0;
|
|
156
|
+
for (const name of new Set(strings(declared))) {
|
|
157
|
+
if (!SECRET_NAME.test(name)) {
|
|
158
|
+
onWarning(phrase.secretSkipped(name, "name", SECRETS));
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
taken += 1;
|
|
162
|
+
if (taken > SECRETS) {
|
|
163
|
+
onWarning(phrase.secretSkipped(name, "count", SECRETS));
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
const value = process.env[name];
|
|
167
|
+
if (typeof value === "string") {
|
|
168
|
+
out[name] = value;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return out;
|
|
172
|
+
}
|
|
173
|
+
// [function]
|
|
147
174
|
// serves the project at `conf.root`. `conf.build` false skips the build, and
|
|
148
175
|
// `conf.url` frames that server's page instead of serving deploy_dir.
|
|
149
176
|
// `conf.handler` hears `onBuild()` as a build starts, `onRemote(name, file,
|
|
@@ -160,6 +187,7 @@ export async function serveTool(conf) {
|
|
|
160
187
|
onRunnerError() { },
|
|
161
188
|
onRunnerInstall() { },
|
|
162
189
|
onRunnerStart() { },
|
|
190
|
+
onWarning() { },
|
|
163
191
|
...conf.handler,
|
|
164
192
|
};
|
|
165
193
|
const project = await given(conf);
|
|
@@ -174,12 +202,12 @@ export async function serveTool(conf) {
|
|
|
174
202
|
const servers = strings(project.client?.server_origins);
|
|
175
203
|
const forServer = servers.length > 0 || Boolean(player);
|
|
176
204
|
// the game's function, when the project has one: its code, where its runtime
|
|
177
|
-
// is kept, and who hears how it's doing
|
|
205
|
+
// is kept, and who hears how it's doing. A `[function]` with no `main` has
|
|
206
|
+
// no code to run, so the game is served without one (`no_function`), as it
|
|
207
|
+
// is with no table: arc serve validates nothing, and `arc validate` says
|
|
208
|
+
// what's missing.
|
|
178
209
|
const runs = project.function;
|
|
179
210
|
const main = runs?.main;
|
|
180
|
-
if (runs && typeof main !== "string") {
|
|
181
|
-
throw new TypeError("function.main must be a path.");
|
|
182
|
-
}
|
|
183
211
|
const runnerMain = typeof main === "string" ? resolvePath(root, main) : null;
|
|
184
212
|
const options = {
|
|
185
213
|
art: storeArt(root),
|
|
@@ -213,13 +241,7 @@ export async function serveTool(conf) {
|
|
|
213
241
|
},
|
|
214
242
|
hosts: strings(runs.outbound_hosts),
|
|
215
243
|
main: runnerMain,
|
|
216
|
-
|
|
217
|
-
// environment: one that isn't set is undefined in the code, as
|
|
218
|
-
// on Arcadible
|
|
219
|
-
secrets: Object.fromEntries(strings(runs.secrets).flatMap((name) => {
|
|
220
|
-
const value = process.env[name];
|
|
221
|
-
return typeof value === "string" ? [[name, value]] : [];
|
|
222
|
-
})),
|
|
244
|
+
secrets: secretsOf(runs.secrets, handler.onWarning),
|
|
223
245
|
},
|
|
224
246
|
}
|
|
225
247
|
: {}),
|
|
@@ -255,9 +277,11 @@ export async function serveTool(conf) {
|
|
|
255
277
|
const built = conf.build !== false && Boolean(buildCommand(project.workflow.build));
|
|
256
278
|
if (built) {
|
|
257
279
|
handler.onBuild();
|
|
280
|
+
// the project's own build only: the function is the runner's to bundle,
|
|
281
|
+
// as it does with no build, so a function that doesn't build is said the
|
|
282
|
+
// same way either way, and the game is still served
|
|
258
283
|
await buildTool({
|
|
259
284
|
project: {
|
|
260
|
-
function: project.function,
|
|
261
285
|
workflow: { build: project.workflow.build, deploy_dir: dir },
|
|
262
286
|
},
|
|
263
287
|
root,
|
package/dist/cli/command.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
// a command's one shape, and running one: `defineCommand` takes a command's
|
|
2
2
|
// options and its flow, and `execute` does the rest around them: reads the
|
|
3
|
-
// command's defaults from
|
|
3
|
+
// command's defaults from its config files (./rc.ts), builds the yargs parser, runs the flow,
|
|
4
4
|
// and sends a failure down the one error path (`abort`).
|
|
5
5
|
// [import]
|
|
6
6
|
import { fail, normalize } from "./argv.js";
|
|
7
7
|
import { aborted } from "../phrase/index.js";
|
|
8
8
|
import { abort, exit } from "../util/output.js";
|
|
9
|
+
import { Cancelled } from "./prompt.js";
|
|
9
10
|
import { version } from "../config/package.js";
|
|
10
11
|
import { tool } from "../config/product.js";
|
|
11
12
|
import { findRc } from "./rc.js";
|
|
@@ -44,8 +45,8 @@ export function defineCommand(spec) {
|
|
|
44
45
|
};
|
|
45
46
|
}
|
|
46
47
|
// [function]
|
|
47
|
-
// an option as yargs takes it, its default the
|
|
48
|
-
// it.
|
|
48
|
+
// an option as yargs takes it, its default the table's when a config file
|
|
49
|
+
// sets it.
|
|
49
50
|
function given(name, spec, conf) {
|
|
50
51
|
const { rc, required: _required, ...rest } = spec;
|
|
51
52
|
return rc
|
|
@@ -97,7 +98,11 @@ function withCommands(cli, family, conf, matched) {
|
|
|
97
98
|
return each.command(child.name, summary, (sub) => withCommands(sub, child, conf, matched));
|
|
98
99
|
}
|
|
99
100
|
return each.command([child.name, syntax(child.positionals)].filter(Boolean).join(" "), summary, (sub) => withPositionals(withOptions(sub, child.options, conf), child.positionals, conf), (parsed) => {
|
|
100
|
-
matched({
|
|
101
|
+
matched({
|
|
102
|
+
command: child,
|
|
103
|
+
heading: child.heading ?? family.name,
|
|
104
|
+
parsed,
|
|
105
|
+
});
|
|
101
106
|
});
|
|
102
107
|
}, cli);
|
|
103
108
|
const demanded = added.demandCommand(1);
|
|
@@ -127,7 +132,7 @@ function parser(command, args, conf, matched) {
|
|
|
127
132
|
return (takesJson(command) ? built.fail(fail(args)) : built).strict();
|
|
128
133
|
}
|
|
129
134
|
// [function]
|
|
130
|
-
// the
|
|
135
|
+
// the table of the config files a command's options are read from: the top-level
|
|
131
136
|
// command's, for a family's commands too, or in a namespace, the name of
|
|
132
137
|
// the command under it that the arguments give.
|
|
133
138
|
function section(command, args) {
|
|
@@ -138,6 +143,11 @@ function section(command, args) {
|
|
|
138
143
|
return args.find((arg) => names.has(arg)) ?? command.name;
|
|
139
144
|
}
|
|
140
145
|
// [function]
|
|
146
|
+
// whether a question ended because it was cancelled (Ctrl+C).
|
|
147
|
+
function cancelled(ex) {
|
|
148
|
+
return ex instanceof Cancelled;
|
|
149
|
+
}
|
|
150
|
+
// [function]
|
|
141
151
|
// runs the command's flow, and ends as it says: with its exit code, or by
|
|
142
152
|
// the one error path.
|
|
143
153
|
async function run({ command, heading, parsed }) {
|
|
@@ -149,6 +159,11 @@ async function run({ command, heading, parsed }) {
|
|
|
149
159
|
}
|
|
150
160
|
}
|
|
151
161
|
catch (ex) {
|
|
162
|
+
// a prompt cancelled with Ctrl+C ends as an interrupted process does,
|
|
163
|
+
// not as a failure: whatever it asked about didn't happen
|
|
164
|
+
if (cancelled(ex)) {
|
|
165
|
+
await exit(130);
|
|
166
|
+
}
|
|
152
167
|
await abort(aborted(heading), ex instanceof Error ? ex : new Error(String(ex)), {
|
|
153
168
|
...aborting,
|
|
154
169
|
json: Object.hasOwn(command.options, "json") && Boolean(parsed["json"]),
|
|
@@ -166,7 +181,7 @@ export async function execute(command, args) {
|
|
|
166
181
|
}).parse();
|
|
167
182
|
const match = isFamily(command)
|
|
168
183
|
? matches[0]
|
|
169
|
-
: { command, heading: command.name, parsed };
|
|
184
|
+
: { command, heading: command.heading ?? command.name, parsed };
|
|
170
185
|
if (match) {
|
|
171
186
|
await run(match);
|
|
172
187
|
}
|
package/dist/cli/confirm.js
CHANGED
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
// secret set again) isn't asked about. `--yes` is declared in ./options.ts
|
|
8
8
|
// (`YES`).
|
|
9
9
|
// [import]
|
|
10
|
-
import { confirm } from "@inquirer/prompts";
|
|
11
10
|
// [import]
|
|
12
11
|
import { ARGUMENT_INVALID } from "../config/code.js";
|
|
12
|
+
import { confirm } from "./prompt.js";
|
|
13
13
|
import { ArcError } from "../util/error.js";
|
|
14
14
|
import { confirmRequired } from "../phrase/index.js";
|
|
15
15
|
// [function]
|
package/dist/cli/options.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// the options several commands take, declared once: a command lists the
|
|
2
2
|
// ones it takes, under the option's name (`options: { json: JSON_OUTPUT }`).
|
|
3
|
-
// One marked `rc` takes its default from the command's
|
|
4
|
-
// when the
|
|
3
|
+
// One marked `rc` takes its default from the command's table of the config
|
|
4
|
+
// files (`arc.config.toml`, ./rc.ts), when the table has it.
|
|
5
5
|
// [declare]
|
|
6
6
|
// the --browser option of arc open and arc play.
|
|
7
7
|
export const BROWSER = {
|