arcadible 1.0.23 → 1.0.25
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 +1 -0
- package/bin/arc.js +1 -85
- package/dist/account.js +197 -0
- package/dist/action/build/tool.js +61 -0
- package/dist/action/delete/tool.js +47 -0
- package/dist/action/deploy/rebuilt.js +25 -0
- package/dist/action/deploy/result.js +36 -0
- package/dist/action/deploy/timeout.js +18 -0
- package/dist/action/deploy/tool-git.js +49 -0
- package/dist/action/deploy/tool.js +49 -0
- package/dist/action/deploy/wait.js +104 -0
- package/dist/action/function/tool.js +127 -0
- package/dist/action/game.js +62 -0
- package/dist/action/init/manifest.js +64 -0
- package/dist/action/init/tool-patch.js +15 -0
- package/dist/action/init/tool.js +64 -0
- package/dist/action/inspect/tool.js +13 -0
- package/dist/action/key/tool.js +88 -0
- package/dist/action/login/flow.js +69 -0
- package/dist/action/login/tool.js +8 -0
- package/dist/action/logout/tool.js +8 -0
- package/dist/action/open/tool.js +30 -0
- package/dist/action/pack/limits.js +46 -0
- package/dist/action/pack/tool.js +148 -0
- package/dist/action/pack/unsound.js +51 -0
- package/dist/action/play/tool.js +84 -0
- package/dist/action/predeploy/ac.js +75 -0
- package/dist/action/predeploy/game.js +6 -0
- package/dist/action/predeploy/git.js +151 -0
- package/dist/action/predeploy/pm.js +20 -0
- package/dist/action/predeploy/published.js +54 -0
- package/dist/action/predeploy/secrets.js +35 -0
- package/dist/action/predeploy/tool-git.js +103 -0
- package/dist/action/predeploy/tool.js +14 -0
- package/dist/action/secret/tool.js +91 -0
- package/dist/action/serve/tool.js +270 -0
- package/dist/action/validate/checked.js +28 -0
- package/dist/action/validate/tool.js +56 -0
- package/dist/action/validate/unknown.js +58 -0
- package/dist/action/validate/unsound.js +99 -0
- package/dist/action/value/tool.js +216 -0
- package/dist/action/whoami/tool.js +7 -0
- package/dist/api.js +312 -0
- package/dist/arc.js +41 -0
- package/dist/cli/argv.js +61 -0
- package/dist/cli/channel.js +29 -0
- package/dist/cli/command.js +163 -0
- package/dist/cli/confirm.js +39 -0
- package/dist/cli/options.js +62 -0
- package/dist/cli/rc.js +103 -0
- package/dist/cli/yargs.js +40 -0
- package/dist/command/build.js +68 -0
- package/dist/command/delete.js +66 -0
- package/dist/command/deploy.js +308 -0
- package/dist/command/function/index.js +17 -0
- package/dist/command/function/pause.js +18 -0
- package/dist/command/function/resume.js +18 -0
- package/dist/command/function/run.js +41 -0
- package/dist/command/function/secret/index.js +15 -0
- package/dist/command/function/secret/list.js +27 -0
- package/dist/command/function/secret/name.js +8 -0
- package/dist/command/function/secret/remove.js +26 -0
- package/dist/command/function/secret/run.js +52 -0
- package/dist/command/function/secret/set.js +48 -0
- package/dist/command/function/status.js +40 -0
- package/dist/command/init.js +128 -0
- package/dist/command/inspect.js +39 -0
- package/dist/command/login.js +108 -0
- package/dist/command/logout.js +24 -0
- package/dist/command/open.js +49 -0
- package/dist/command/pack.js +90 -0
- package/dist/command/play.js +81 -0
- package/dist/command/serve.js +177 -0
- package/dist/command/server/index.js +17 -0
- package/dist/command/server/key/create.js +36 -0
- package/dist/command/server/key/index.js +15 -0
- package/dist/command/server/key/list.js +34 -0
- package/dist/command/server/key/revoke.js +24 -0
- package/dist/command/server/key/run.js +54 -0
- package/dist/command/validate.js +47 -0
- package/dist/command/value/get.js +21 -0
- package/dist/command/value/index.js +19 -0
- package/dist/command/value/key.js +8 -0
- package/dist/command/value/list.js +41 -0
- package/dist/command/value/remove.js +26 -0
- package/dist/command/value/set.js +62 -0
- package/dist/command/value/usage.js +69 -0
- package/dist/command/whoami.js +55 -0
- package/dist/commands.js +100 -0
- package/dist/config/ai.js +2 -0
- package/dist/config/art.js +13 -0
- package/dist/config/audience.js +2 -0
- package/dist/config/code.js +129 -0
- package/dist/config/file.js +13 -0
- package/dist/config/genre.js +19 -0
- package/{src → dist}/config/html.js +2 -7
- package/dist/config/image.js +5 -0
- package/dist/config/input.js +11 -0
- package/dist/config/json.js +23 -0
- package/dist/config/limit.js +14 -0
- package/dist/config/orientation.js +11 -0
- package/dist/config/package.js +8 -0
- package/dist/config/product.js +14 -0
- package/dist/config/template.js +37 -0
- package/dist/config/uri.js +18 -0
- package/dist/config/url.js +11 -0
- package/dist/config/video.js +5 -0
- package/dist/config/visibility.js +2 -0
- package/dist/config/workflow.js +7 -0
- package/dist/parser/env.js +61 -0
- package/dist/parser/given.js +8 -0
- package/dist/parser/manifest.js +45 -0
- package/dist/parser/media.js +57 -0
- package/dist/parser/project.js +129 -0
- package/dist/parser/readme-file.js +44 -0
- package/dist/parser/readme.js +70 -0
- package/dist/parser/sections.js +92 -0
- package/dist/parser/self.js +16 -0
- package/dist/phrase/account.js +35 -0
- package/dist/phrase/common.js +139 -0
- package/dist/phrase/deploy.js +192 -0
- package/dist/phrase/function.js +139 -0
- package/dist/phrase/game.js +27 -0
- package/dist/phrase/index.js +16 -0
- package/dist/phrase/init.js +53 -0
- package/dist/phrase/internal.js +61 -0
- package/dist/phrase/manifest.js +120 -0
- package/dist/phrase/media.js +90 -0
- package/dist/phrase/pack.js +69 -0
- package/dist/phrase/serve.js +84 -0
- package/dist/phrase/server.js +38 -0
- package/dist/phrase/value.js +55 -0
- package/dist/runner/bundle.js +45 -0
- package/dist/runner/entry.js +57 -0
- package/dist/runner/outbound.js +69 -0
- package/dist/schema/check/game.js +29 -0
- package/dist/schema/check/workflow.js +57 -0
- package/dist/schema/game.js +462 -0
- package/dist/schema/message.js +61 -0
- package/dist/schema/readme.js +27 -0
- package/dist/schema/runner.js +43 -0
- package/dist/schema/server.js +91 -0
- package/dist/schema/workflow.js +99 -0
- package/dist/serve/files.js +39 -0
- package/dist/serve/game.js +172 -0
- package/dist/serve/page.js +689 -0
- package/dist/serve/reload.js +55 -0
- package/dist/serve/remote.js +114 -0
- package/dist/serve/runner.js +303 -0
- package/dist/serve/server.js +169 -0
- package/dist/serve/ticket.js +232 -0
- package/dist/serve/values.js +317 -0
- package/dist/util/bytes.js +16 -0
- package/dist/util/chars.js +19 -0
- package/dist/util/command.js +11 -0
- package/dist/util/delay.js +36 -0
- package/dist/util/doc.js +59 -0
- package/dist/util/error.js +35 -0
- package/dist/util/http.js +13 -0
- package/dist/util/image.js +64 -0
- package/dist/util/links.js +45 -0
- package/dist/util/lockfile.js +17 -0
- package/dist/util/log.js +101 -0
- package/dist/util/md.js +37 -0
- package/dist/util/media.js +27 -0
- package/dist/util/objs.js +46 -0
- package/dist/util/os.js +13 -0
- package/dist/util/output.js +133 -0
- package/dist/util/paths.js +8 -0
- package/dist/util/progress.js +57 -0
- package/dist/util/promise.js +18 -0
- package/dist/util/request.js +103 -0
- package/dist/util/s3.js +67 -0
- package/dist/util/schema.js +151 -0
- package/dist/util/screenshot.js +24 -0
- package/dist/util/shape.js +49 -0
- package/dist/util/shell.js +64 -0
- package/dist/util/size.js +32 -0
- package/dist/util/spinner.js +35 -0
- package/dist/util/strs.js +46 -0
- package/dist/util/table.js +18 -0
- package/dist/util/term.js +21 -0
- package/dist/util/time.js +16 -0
- package/dist/util/toml.js +28 -0
- package/{src → dist}/util/uris.js +8 -14
- package/dist/util/video.js +113 -0
- package/dist/util/zip.js +62 -0
- package/npm-shrinkwrap.json +3256 -0
- package/package.json +41 -39
- package/bin/arc-build.js +0 -139
- package/bin/arc-default.js +0 -65
- package/bin/arc-deploy.js +0 -456
- package/bin/arc-init.js +0 -187
- package/bin/arc-inspect.js +0 -97
- package/bin/arc-login.js +0 -165
- package/bin/arc-logout.js +0 -75
- package/bin/arc-open.js +0 -104
- package/bin/arc-pack.js +0 -146
- package/bin/arc-play.js +0 -140
- package/bin/arc-serve.js +0 -214
- package/bin/arc-validate.js +0 -112
- package/bin/arc-whoami.js +0 -119
- package/src/account.js +0 -249
- package/src/action/build/tool.js +0 -80
- package/src/action/deploy/tool-git.js +0 -90
- package/src/action/deploy/tool.js +0 -88
- package/src/action/deploy/wait.js +0 -151
- package/src/action/init/manifest.js +0 -83
- package/src/action/init/tool-patch.js +0 -32
- package/src/action/init/tool.js +0 -97
- package/src/action/inspect/tool.js +0 -26
- package/src/action/login/flow.js +0 -101
- package/src/action/login/tool.js +0 -16
- package/src/action/logout/tool.js +0 -15
- package/src/action/open/tool.js +0 -38
- package/src/action/pack/limits.js +0 -51
- package/src/action/pack/tool.js +0 -171
- package/src/action/pack/unsound.js +0 -69
- package/src/action/play/tool.js +0 -109
- package/src/action/predeploy/ac.js +0 -112
- package/src/action/predeploy/git.js +0 -223
- package/src/action/predeploy/pm.js +0 -37
- package/src/action/predeploy/published.js +0 -82
- package/src/action/predeploy/tool-git.js +0 -154
- package/src/action/predeploy/tool.js +0 -29
- package/src/action/serve/tool.js +0 -209
- package/src/action/validate/checked.js +0 -37
- package/src/action/validate/tool.js +0 -67
- package/src/action/validate/unknown.js +0 -86
- package/src/action/validate/unsound.js +0 -138
- package/src/action/whoami/tool.js +0 -15
- package/src/api.js +0 -163
- package/src/cli/build.js +0 -15
- package/src/cli/deploy.js +0 -21
- package/src/cli/init.js +0 -17
- package/src/cli/inspect.js +0 -15
- package/src/cli/login.js +0 -15
- package/src/cli/logout.js +0 -15
- package/src/cli/open.js +0 -15
- package/src/cli/pack.js +0 -15
- package/src/cli/play.js +0 -15
- package/src/cli/predeploy.js +0 -21
- package/src/cli/serve.js +0 -15
- package/src/cli/validate.js +0 -15
- package/src/cli/whoami.js +0 -15
- package/src/config/ai.js +0 -5
- package/src/config/art.js +0 -16
- package/src/config/audience.js +0 -5
- package/src/config/code.js +0 -142
- package/src/config/file.js +0 -23
- package/src/config/genre.js +0 -22
- package/src/config/image.js +0 -7
- package/src/config/input.js +0 -14
- package/src/config/limit.js +0 -21
- package/src/config/orientation.js +0 -14
- package/src/config/package.js +0 -5
- package/src/config/product.js +0 -5
- package/src/config/template.js +0 -45
- package/src/config/uri.js +0 -27
- package/src/config/url.js +0 -20
- package/src/config/video.js +0 -7
- package/src/config/visibility.js +0 -5
- package/src/config/workflow.js +0 -18
- package/src/parser/env.js +0 -84
- package/src/parser/given.js +0 -17
- package/src/parser/manifest.js +0 -80
- package/src/parser/media.js +0 -90
- package/src/parser/project.js +0 -166
- package/src/parser/readme-file.js +0 -76
- package/src/parser/readme.js +0 -96
- package/src/parser/sections.js +0 -107
- package/src/parser/self.js +0 -27
- package/src/phrase.js +0 -1294
- package/src/schema/check/game.js +0 -61
- package/src/schema/check/workflow.js +0 -99
- package/src/schema/game.js +0 -649
- package/src/schema/message.js +0 -85
- package/src/schema/readme.js +0 -44
- package/src/schema/workflow.js +0 -150
- package/src/serve/files.js +0 -61
- package/src/serve/game.js +0 -191
- package/src/serve/page.js +0 -345
- package/src/serve/reload.js +0 -68
- package/src/serve/remote.js +0 -121
- package/src/serve/server.js +0 -128
- package/src/util/argv.js +0 -116
- package/src/util/bytes.js +0 -25
- package/src/util/chars.js +0 -30
- package/src/util/command.js +0 -18
- package/src/util/delay.js +0 -52
- package/src/util/doc.js +0 -72
- package/src/util/error.js +0 -50
- package/src/util/http.js +0 -25
- package/src/util/image.js +0 -93
- package/src/util/links.js +0 -78
- package/src/util/lockfile.js +0 -35
- package/src/util/log.js +0 -149
- package/src/util/md.js +0 -61
- package/src/util/media.js +0 -40
- package/src/util/objs.js +0 -45
- package/src/util/os.js +0 -27
- package/src/util/output.js +0 -174
- package/src/util/paths.js +0 -21
- package/src/util/progress.js +0 -85
- package/src/util/promise.js +0 -29
- package/src/util/rc.js +0 -144
- package/src/util/request.js +0 -89
- package/src/util/s3.js +0 -92
- package/src/util/schema.js +0 -189
- package/src/util/screenshot.js +0 -37
- package/src/util/shell.js +0 -84
- package/src/util/size.js +0 -53
- package/src/util/spinner.js +0 -52
- package/src/util/strs.js +0 -73
- package/src/util/term.js +0 -28
- package/src/util/time.js +0 -29
- package/src/util/toml.js +0 -14
- package/src/util/video.js +0 -157
- package/src/util/zip.js +0 -88
- /package/{src/serve → assets}/favicon.ico +0 -0
package/src/util/argv.js
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
// [import]
|
|
4
|
-
|
|
5
|
-
const helpers = require("yargs/helpers");
|
|
6
|
-
|
|
7
|
-
// [import]
|
|
8
|
-
|
|
9
|
-
const cfgcode = require("../config/code");
|
|
10
|
-
const error = require("./error");
|
|
11
|
-
const output = require("./output");
|
|
12
|
-
|
|
13
|
-
// [use]
|
|
14
|
-
|
|
15
|
-
const abort = output.abort;
|
|
16
|
-
const ArcError = error.ArcError;
|
|
17
|
-
const hideBin = helpers.hideBin;
|
|
18
|
-
const parse = helpers.Parser;
|
|
19
|
-
|
|
20
|
-
// [declare]
|
|
21
|
-
|
|
22
|
-
// the --browser option of arc open and arc play.
|
|
23
|
-
const BROWSER = {
|
|
24
|
-
describe: "Open in a web browser",
|
|
25
|
-
type: "boolean",
|
|
26
|
-
};
|
|
27
|
-
// the -C, --cwd option of every project command.
|
|
28
|
-
const CWD = {
|
|
29
|
-
alias: "C",
|
|
30
|
-
default: ".",
|
|
31
|
-
describe: "Set the working directory",
|
|
32
|
-
type: "string",
|
|
33
|
-
};
|
|
34
|
-
// the -j, --json option, which prints one JSON document (OUTPUT.md).
|
|
35
|
-
const JSON_OUTPUT = {
|
|
36
|
-
alias: "j",
|
|
37
|
-
describe: "Format output as JSON",
|
|
38
|
-
type: "boolean",
|
|
39
|
-
};
|
|
40
|
-
// the -q, --quiet option, which prints only errors.
|
|
41
|
-
const QUIET = {
|
|
42
|
-
alias: "q",
|
|
43
|
-
describe: "Output only errors",
|
|
44
|
-
type: "boolean",
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
// [function]
|
|
48
|
-
|
|
49
|
-
// the arguments with an attached `-C<dir>` split into `-C <dir>`. yargs reads
|
|
50
|
-
// `-C./dir` as an option named `C./dir`, and `-Cdir` as the flags -C -d -i -r,
|
|
51
|
-
// so neither would reach the command as a directory.
|
|
52
|
-
const normalize = function (args) {
|
|
53
|
-
return args.flatMap((arg) => {
|
|
54
|
-
if (/^-C[^=]/u.test(arg)) {
|
|
55
|
-
return ["-C", arg.slice(2)];
|
|
56
|
-
}
|
|
57
|
-
return [arg];
|
|
58
|
-
});
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
// [function]
|
|
62
|
-
|
|
63
|
-
// the working directory `args` ask for, parsed as the command parses them,
|
|
64
|
-
// in every form: -C dir, -C=dir, -Cdir, --cwd dir, and --cwd=dir.
|
|
65
|
-
const cwd = function (args) {
|
|
66
|
-
const parsed = parse(normalize(args), {
|
|
67
|
-
alias: { cwd: ["C"] },
|
|
68
|
-
string: ["cwd"],
|
|
69
|
-
});
|
|
70
|
-
return parsed.cwd || ".";
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
// [function]
|
|
74
|
-
|
|
75
|
-
// whether `argv` passes --json, before the command parses its options.
|
|
76
|
-
const json = function (argv) {
|
|
77
|
-
return parse(normalize(hideBin(argv)), {
|
|
78
|
-
alias: { json: ["j"] },
|
|
79
|
-
boolean: ["json"],
|
|
80
|
-
}).json;
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
// [function]
|
|
84
|
-
|
|
85
|
-
// yargs' failure handler for a command with --json: an argument error is
|
|
86
|
-
// one JSON document when --json was passed (OUTPUT.md), and yargs' own help
|
|
87
|
-
// and message otherwise.
|
|
88
|
-
const fail = function (argv) {
|
|
89
|
-
const asJson = json(argv);
|
|
90
|
-
return (message, ex, cli) => {
|
|
91
|
-
if (ex) {
|
|
92
|
-
throw ex;
|
|
93
|
-
}
|
|
94
|
-
if (asJson) {
|
|
95
|
-
abort("", new ArcError(cfgcode.ARGUMENT_INVALID, message), {
|
|
96
|
-
json: asJson,
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
cli.showHelp("error");
|
|
100
|
-
console.error(`\n${message}`);
|
|
101
|
-
process.exit(1);
|
|
102
|
-
};
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
// [export]
|
|
106
|
-
|
|
107
|
-
module.exports = {
|
|
108
|
-
BROWSER,
|
|
109
|
-
CWD,
|
|
110
|
-
JSON_OUTPUT,
|
|
111
|
-
QUIET,
|
|
112
|
-
cwd,
|
|
113
|
-
fail,
|
|
114
|
-
json,
|
|
115
|
-
normalize,
|
|
116
|
-
};
|
package/src/util/bytes.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
// [import]
|
|
4
|
-
|
|
5
|
-
const phrase = require("../phrase");
|
|
6
|
-
const size = require("./size");
|
|
7
|
-
|
|
8
|
-
// [function]
|
|
9
|
-
|
|
10
|
-
const formatBytes = function (bytes) {
|
|
11
|
-
switch (true) {
|
|
12
|
-
case bytes >= size.gb(1):
|
|
13
|
-
return phrase.sizeGb(size.toGb(bytes).toFixed(1));
|
|
14
|
-
case bytes >= size.mb(1):
|
|
15
|
-
return phrase.sizeMb(size.toMb(bytes).toFixed(1));
|
|
16
|
-
case bytes >= size.kb(1):
|
|
17
|
-
return phrase.sizeKb(size.toKb(bytes).toFixed(1));
|
|
18
|
-
default:
|
|
19
|
-
return phrase.sizeB(size.toB(bytes));
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
// [export]
|
|
24
|
-
|
|
25
|
-
module.exports = { formatBytes };
|
package/src/util/chars.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
// [declare]
|
|
4
|
-
|
|
5
|
-
// characters that can't be seen, or would be misread, when printed alone.
|
|
6
|
-
const UNPRINTABLE = /[\p{M}\p{C}\p{Z}]/u;
|
|
7
|
-
|
|
8
|
-
// [function]
|
|
9
|
-
|
|
10
|
-
// a character as it's shown in a message: quoted, or as its code point when
|
|
11
|
-
// it can't be seen, like a combining accent.
|
|
12
|
-
const show = function (char) {
|
|
13
|
-
if (char !== " " && UNPRINTABLE.test(char)) {
|
|
14
|
-
const code = char.codePointAt(0).toString(16).toUpperCase();
|
|
15
|
-
return `U+${code.padStart(4, "0")}`;
|
|
16
|
-
}
|
|
17
|
-
return `'${char}'`;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
// [function]
|
|
21
|
-
|
|
22
|
-
// the characters in `str` that don't match `allowed`, a one-character
|
|
23
|
-
// pattern, each listed once, in order.
|
|
24
|
-
const invalid = function (str, allowed) {
|
|
25
|
-
return [...new Set([...str].filter((char) => !allowed.test(char)))];
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
// [export]
|
|
29
|
-
|
|
30
|
-
module.exports = { invalid, show };
|
package/src/util/command.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
// [function]
|
|
4
|
-
|
|
5
|
-
// workflow.build as the shell runs it: each command trimmed, blank ones
|
|
6
|
-
// dropped, and a list joined with `&&`. Blank when there's nothing to run.
|
|
7
|
-
const buildCommand = function (build) {
|
|
8
|
-
return [build]
|
|
9
|
-
.flat()
|
|
10
|
-
.filter((cmd) => typeof cmd === "string")
|
|
11
|
-
.map((cmd) => cmd.trim())
|
|
12
|
-
.filter(Boolean)
|
|
13
|
-
.join(" && ");
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
// [export]
|
|
17
|
-
|
|
18
|
-
module.exports = { buildCommand };
|
package/src/util/delay.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
// [function]
|
|
4
|
-
|
|
5
|
-
const backoff = function (elapsed, delay, factor, interval, maxDelay) {
|
|
6
|
-
const step = Math.floor(elapsed / interval);
|
|
7
|
-
return Math.min(delay * factor ** step, maxDelay);
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
// [function]
|
|
11
|
-
|
|
12
|
-
const sleep = function (delay) {
|
|
13
|
-
return new Promise((resolve) => {
|
|
14
|
-
setTimeout(resolve, delay);
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
// [function]
|
|
19
|
-
|
|
20
|
-
const wait = function (delay, next) {
|
|
21
|
-
return sleep(delay).then(next);
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
// [function]
|
|
25
|
-
|
|
26
|
-
// calls fn(value) until it resolves to something other than null, backing
|
|
27
|
-
// off by `factor` every `interval`, up to `maxDelay`. After `timeout`, it
|
|
28
|
-
// throws timeoutError(), the caller's own error, with its code.
|
|
29
|
-
const poll = function (
|
|
30
|
-
fn,
|
|
31
|
-
value,
|
|
32
|
-
{ delay, factor, interval, maxDelay, timeout, timeoutError },
|
|
33
|
-
) {
|
|
34
|
-
const started = Date.now();
|
|
35
|
-
const next = function () {
|
|
36
|
-
return fn(value).then((result) => {
|
|
37
|
-
if (result !== null) {
|
|
38
|
-
return result;
|
|
39
|
-
}
|
|
40
|
-
const elapsed = Date.now() - started;
|
|
41
|
-
if (elapsed >= timeout) {
|
|
42
|
-
throw timeoutError();
|
|
43
|
-
}
|
|
44
|
-
return wait(backoff(elapsed, delay, factor, interval, maxDelay), next);
|
|
45
|
-
});
|
|
46
|
-
};
|
|
47
|
-
return next();
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
// [export]
|
|
51
|
-
|
|
52
|
-
module.exports = { poll, sleep };
|
package/src/util/doc.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
// [import]
|
|
4
|
-
|
|
5
|
-
const jsdom = require("jsdom");
|
|
6
|
-
|
|
7
|
-
// [import]
|
|
8
|
-
|
|
9
|
-
const phrase = require("../phrase");
|
|
10
|
-
|
|
11
|
-
// [use]
|
|
12
|
-
|
|
13
|
-
const JSDOM = jsdom.JSDOM;
|
|
14
|
-
|
|
15
|
-
// [declare]
|
|
16
|
-
|
|
17
|
-
const COMMENT = 8;
|
|
18
|
-
const ELEMENT = 1;
|
|
19
|
-
|
|
20
|
-
// [function]
|
|
21
|
-
|
|
22
|
-
const checkAttrs = function (el, name, { allowed, hooks }, issues) {
|
|
23
|
-
for (const { name: attr, value } of el.attributes) {
|
|
24
|
-
if (!allowed[name].includes(attr)) {
|
|
25
|
-
issues.add(phrase.docAttrUnallowed(name, attr));
|
|
26
|
-
} else if (hooks[attr]) {
|
|
27
|
-
// a hook gets the value and its element, and returns true when the
|
|
28
|
-
// value is allowed, a message to report, or false for the generic one.
|
|
29
|
-
const result = hooks[attr](value, name);
|
|
30
|
-
if (result !== true) {
|
|
31
|
-
issues.add(
|
|
32
|
-
typeof result === "string"
|
|
33
|
-
? result
|
|
34
|
-
: phrase.docAttrInvalid(name, attr, value),
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
// [function]
|
|
42
|
-
|
|
43
|
-
const checkNode = function (node, opts, issues) {
|
|
44
|
-
if (node.nodeType === COMMENT) {
|
|
45
|
-
issues.add(phrase.docCommentUnallowed());
|
|
46
|
-
} else if (node.nodeType === ELEMENT) {
|
|
47
|
-
const name = node.nodeName.toLowerCase();
|
|
48
|
-
if (Object.hasOwn(opts.allowed, name)) {
|
|
49
|
-
checkAttrs(node, name, opts, issues);
|
|
50
|
-
} else {
|
|
51
|
-
issues.add(phrase.docTagUnallowed(name));
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
for (const child of node.childNodes) {
|
|
55
|
-
checkNode(child, opts, issues);
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
// [function]
|
|
60
|
-
|
|
61
|
-
// checks the description's HTML as written, before anything sanitizes it:
|
|
62
|
-
// every element must be allowed, with only its allowed attributes, each
|
|
63
|
-
// passing its hook. Each problem is reported once.
|
|
64
|
-
const check = function (str, { allowed, hooks = {} }) {
|
|
65
|
-
const issues = new Set();
|
|
66
|
-
checkNode(JSDOM.fragment(str), { allowed, hooks }, issues);
|
|
67
|
-
return [...issues];
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
// [export]
|
|
71
|
-
|
|
72
|
-
module.exports = { check };
|
package/src/util/error.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
// [import]
|
|
4
|
-
|
|
5
|
-
const cfgcode = require("../config/code");
|
|
6
|
-
const http = require("./http");
|
|
7
|
-
|
|
8
|
-
// [use]
|
|
9
|
-
|
|
10
|
-
const HttpError = http.HttpError;
|
|
11
|
-
|
|
12
|
-
// [class]
|
|
13
|
-
|
|
14
|
-
// a failure with its code (config/code.js), which scripts match on while the
|
|
15
|
-
// message stays free to change. An unknown code is a bug, so it throws.
|
|
16
|
-
// `data` goes beside the error in JSON, such as the issues that failed
|
|
17
|
-
// validation.
|
|
18
|
-
const ArcError = class extends Error {
|
|
19
|
-
|
|
20
|
-
// [constructor]
|
|
21
|
-
|
|
22
|
-
constructor(code, message, options) {
|
|
23
|
-
if (!cfgcode.ALL.has(code)) {
|
|
24
|
-
throw new TypeError(`Unknown error code: ${code}`);
|
|
25
|
-
}
|
|
26
|
-
const { data, ...rest } = options ?? {};
|
|
27
|
-
super(message, rest);
|
|
28
|
-
this.code = code;
|
|
29
|
-
this.data = data;
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
// [function]
|
|
34
|
-
|
|
35
|
-
// the code a failure reports: its own, api_refused for a request the API
|
|
36
|
-
// refused, or internal for a failure on Arcadible's side (a 5xx) and for
|
|
37
|
-
// anything else, which is a bug in the CLI.
|
|
38
|
-
const codeOf = function (ex) {
|
|
39
|
-
if (ex instanceof ArcError) {
|
|
40
|
-
return ex.code;
|
|
41
|
-
}
|
|
42
|
-
if (ex instanceof HttpError && !(ex.status >= 500)) {
|
|
43
|
-
return cfgcode.API_REFUSED;
|
|
44
|
-
}
|
|
45
|
-
return cfgcode.INTERNAL;
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
// [export]
|
|
49
|
-
|
|
50
|
-
module.exports = { ArcError, codeOf };
|
package/src/util/http.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
// [import]
|
|
4
|
-
|
|
5
|
-
const phrase = require("../phrase");
|
|
6
|
-
|
|
7
|
-
// [class]
|
|
8
|
-
|
|
9
|
-
const HttpError = class extends Error {
|
|
10
|
-
|
|
11
|
-
// [constructor]
|
|
12
|
-
|
|
13
|
-
// the API's error, `{ title, message }`. Both are optional: a response
|
|
14
|
-
// that isn't the API's own, such as a proxy's HTML error page, has neither.
|
|
15
|
-
constructor(status, { message, title } = {}) {
|
|
16
|
-
super(message);
|
|
17
|
-
this.status = status;
|
|
18
|
-
this.name = title || "HTTP Error";
|
|
19
|
-
this.message = phrase.httpError(this.name, this.status, message);
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
// [export]
|
|
24
|
-
|
|
25
|
-
module.exports = { HttpError };
|
package/src/util/image.js
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
// [import]
|
|
4
|
-
|
|
5
|
-
const path = require("node:path");
|
|
6
|
-
|
|
7
|
-
// [import]
|
|
8
|
-
|
|
9
|
-
const fs = require("fs-extra");
|
|
10
|
-
const imageSize = require("image-size").imageSize;
|
|
11
|
-
|
|
12
|
-
// [import]
|
|
13
|
-
|
|
14
|
-
const bytes = require("./bytes");
|
|
15
|
-
const cfgimage = require("../config/image");
|
|
16
|
-
const media = require("./media");
|
|
17
|
-
const phrase = require("../phrase");
|
|
18
|
-
|
|
19
|
-
// [use]
|
|
20
|
-
|
|
21
|
-
const checkAspect = media.checkAspect;
|
|
22
|
-
const checkSize = media.checkSize;
|
|
23
|
-
const extname = path.extname;
|
|
24
|
-
const formatBytes = bytes.formatBytes;
|
|
25
|
-
const MAX_READ = media.MAX_READ;
|
|
26
|
-
const readFileSync = fs.readFileSync; // eslint-disable-line no-sync
|
|
27
|
-
const statSync = fs.statSync; // eslint-disable-line no-sync
|
|
28
|
-
|
|
29
|
-
// [function]
|
|
30
|
-
|
|
31
|
-
const readPng = function (file) {
|
|
32
|
-
const { height, type, width } = imageSize(readFileSync(file));
|
|
33
|
-
if (type !== "png") {
|
|
34
|
-
throw new Error(`Unexpected image type: ${type}`);
|
|
35
|
-
}
|
|
36
|
-
return { height, width };
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
// [function]
|
|
40
|
-
|
|
41
|
-
// every rule the image breaks, after what it is, so one run reports them all.
|
|
42
|
-
// only a file that can't be read as a PNG stops the checks.
|
|
43
|
-
const checkPng = function (
|
|
44
|
-
file,
|
|
45
|
-
{ aspect, maxHeight, maxSize, maxWidth, minHeight, minWidth },
|
|
46
|
-
) {
|
|
47
|
-
const fileSize = statSync(file).size;
|
|
48
|
-
const issues = checkSize(fileSize, maxSize)
|
|
49
|
-
? []
|
|
50
|
-
: [phrase.imageSizeMax(formatBytes(maxSize))];
|
|
51
|
-
if (fileSize > MAX_READ) {
|
|
52
|
-
return issues;
|
|
53
|
-
}
|
|
54
|
-
let image = null;
|
|
55
|
-
try {
|
|
56
|
-
image = readPng(file);
|
|
57
|
-
} catch {
|
|
58
|
-
return [...issues, phrase.imageInvalid()];
|
|
59
|
-
}
|
|
60
|
-
const { height, width } = image;
|
|
61
|
-
if (minWidth && width < minWidth) {
|
|
62
|
-
issues.push(phrase.imageWidthMin(minWidth));
|
|
63
|
-
}
|
|
64
|
-
if (minHeight && height < minHeight) {
|
|
65
|
-
issues.push(phrase.imageHeightMin(minHeight));
|
|
66
|
-
}
|
|
67
|
-
if (maxWidth && width > maxWidth) {
|
|
68
|
-
issues.push(phrase.imageWidthMax(maxWidth));
|
|
69
|
-
}
|
|
70
|
-
if (maxHeight && height > maxHeight) {
|
|
71
|
-
issues.push(phrase.imageHeightMax(maxHeight));
|
|
72
|
-
}
|
|
73
|
-
if (!checkAspect(width, height, aspect)) {
|
|
74
|
-
issues.push(phrase.imageAspect(aspect));
|
|
75
|
-
}
|
|
76
|
-
return issues.length ? [phrase.imageFound(width, height), ...issues] : [];
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
// [function]
|
|
80
|
-
|
|
81
|
-
const check = function (file, { type, ...opts }) {
|
|
82
|
-
const checks = {
|
|
83
|
-
[cfgimage[".png"]]: checkPng,
|
|
84
|
-
};
|
|
85
|
-
const checkImage = checks[type];
|
|
86
|
-
return checkImage && cfgimage[extname(file)] === type
|
|
87
|
-
? checkImage(file, opts)
|
|
88
|
-
: [phrase.imageUnsupported()];
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
// [export]
|
|
92
|
-
|
|
93
|
-
module.exports = { check };
|
package/src/util/links.js
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
// [import]
|
|
4
|
-
|
|
5
|
-
const semver = require("semver");
|
|
6
|
-
|
|
7
|
-
// [import]
|
|
8
|
-
|
|
9
|
-
const cfguri = require("../config/uri");
|
|
10
|
-
|
|
11
|
-
// [use]
|
|
12
|
-
|
|
13
|
-
const prerelease = semver.prerelease;
|
|
14
|
-
|
|
15
|
-
// [declare]
|
|
16
|
-
|
|
17
|
-
const PRODUCTION = "production";
|
|
18
|
-
const STAGING = "staging";
|
|
19
|
-
|
|
20
|
-
// [function]
|
|
21
|
-
|
|
22
|
-
// the channel a version is published to: a prerelease goes to staging.
|
|
23
|
-
const channel = function (version) {
|
|
24
|
-
return prerelease(version) === null ? PRODUCTION : STAGING;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
// [function]
|
|
28
|
-
|
|
29
|
-
// a game's play link for a channel or version, by handle or id.
|
|
30
|
-
const playUrl = function (game, release = PRODUCTION) {
|
|
31
|
-
const target = release === PRODUCTION ? "" : `:${release}`;
|
|
32
|
-
return `${cfguri.HOST_HTTP_PLAY}/${game}${target}/`;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
// [function]
|
|
36
|
-
|
|
37
|
-
// a game's store page path, as the app and the web both address it.
|
|
38
|
-
const storePage = function (game) {
|
|
39
|
-
return `/play/${game}`;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
// [function]
|
|
43
|
-
|
|
44
|
-
// a game's store page on the web.
|
|
45
|
-
const storeUrl = function (game) {
|
|
46
|
-
return `${cfguri.HOST_HTTP_WWW}${storePage(game)}`;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
// [function]
|
|
50
|
-
|
|
51
|
-
// a game's page in Studio, on one of its tabs, such as `builds`.
|
|
52
|
-
const studioUrl = function (game, tab) {
|
|
53
|
-
return `${cfguri.HOST_HTTP_STUDIO}/games/${game}/${tab}`;
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
// [function]
|
|
57
|
-
|
|
58
|
-
// where a deployed version will be, once it's published: its channel, that
|
|
59
|
-
// channel's play link, and for production, its store page.
|
|
60
|
-
const published = function ({ handle, id, version }) {
|
|
61
|
-
const game = handle ?? id;
|
|
62
|
-
const release = channel(version);
|
|
63
|
-
const store = release === PRODUCTION ? storeUrl(game) : null;
|
|
64
|
-
return { channel: release, store, url: playUrl(game, release) };
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
// [export]
|
|
68
|
-
|
|
69
|
-
module.exports = {
|
|
70
|
-
PRODUCTION,
|
|
71
|
-
STAGING,
|
|
72
|
-
channel,
|
|
73
|
-
playUrl,
|
|
74
|
-
published,
|
|
75
|
-
storePage,
|
|
76
|
-
storeUrl,
|
|
77
|
-
studioUrl,
|
|
78
|
-
};
|
package/src/util/lockfile.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
// [import]
|
|
4
|
-
|
|
5
|
-
const fs = require("node:fs");
|
|
6
|
-
const path = require("node:path");
|
|
7
|
-
|
|
8
|
-
// [use]
|
|
9
|
-
|
|
10
|
-
const existsSync = fs.existsSync; // eslint-disable-line no-sync
|
|
11
|
-
const join = path.join;
|
|
12
|
-
|
|
13
|
-
// [declare]
|
|
14
|
-
|
|
15
|
-
// each package manager, and the lockfiles that mean a project uses it, in the
|
|
16
|
-
// order they're checked, as the release tools' install checks them.
|
|
17
|
-
const LOCKFILES = [
|
|
18
|
-
["npm", ["package-lock.json", "npm-shrinkwrap.json"]],
|
|
19
|
-
["pnpm", ["pnpm-lock.yaml"]],
|
|
20
|
-
["yarn", ["yarn.lock"]],
|
|
21
|
-
];
|
|
22
|
-
|
|
23
|
-
// [function]
|
|
24
|
-
|
|
25
|
-
// the package manager a project's lockfile names, or "" when it has none.
|
|
26
|
-
const detect = function (root) {
|
|
27
|
-
const found = LOCKFILES.find(([, names]) =>
|
|
28
|
-
names.some((name) => existsSync(join(root, name))),
|
|
29
|
-
);
|
|
30
|
-
return found ? found[0] : "";
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
// [export]
|
|
34
|
-
|
|
35
|
-
module.exports = { detect };
|