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.
Files changed (320) hide show
  1. package/README.md +1 -0
  2. package/bin/arc.js +1 -85
  3. package/dist/account.js +197 -0
  4. package/dist/action/build/tool.js +61 -0
  5. package/dist/action/delete/tool.js +47 -0
  6. package/dist/action/deploy/rebuilt.js +25 -0
  7. package/dist/action/deploy/result.js +36 -0
  8. package/dist/action/deploy/timeout.js +18 -0
  9. package/dist/action/deploy/tool-git.js +49 -0
  10. package/dist/action/deploy/tool.js +49 -0
  11. package/dist/action/deploy/wait.js +104 -0
  12. package/dist/action/function/tool.js +127 -0
  13. package/dist/action/game.js +62 -0
  14. package/dist/action/init/manifest.js +64 -0
  15. package/dist/action/init/tool-patch.js +15 -0
  16. package/dist/action/init/tool.js +64 -0
  17. package/dist/action/inspect/tool.js +13 -0
  18. package/dist/action/key/tool.js +88 -0
  19. package/dist/action/login/flow.js +69 -0
  20. package/dist/action/login/tool.js +8 -0
  21. package/dist/action/logout/tool.js +8 -0
  22. package/dist/action/open/tool.js +30 -0
  23. package/dist/action/pack/limits.js +46 -0
  24. package/dist/action/pack/tool.js +148 -0
  25. package/dist/action/pack/unsound.js +51 -0
  26. package/dist/action/play/tool.js +84 -0
  27. package/dist/action/predeploy/ac.js +75 -0
  28. package/dist/action/predeploy/game.js +6 -0
  29. package/dist/action/predeploy/git.js +151 -0
  30. package/dist/action/predeploy/pm.js +20 -0
  31. package/dist/action/predeploy/published.js +54 -0
  32. package/dist/action/predeploy/secrets.js +35 -0
  33. package/dist/action/predeploy/tool-git.js +103 -0
  34. package/dist/action/predeploy/tool.js +14 -0
  35. package/dist/action/secret/tool.js +91 -0
  36. package/dist/action/serve/tool.js +270 -0
  37. package/dist/action/validate/checked.js +28 -0
  38. package/dist/action/validate/tool.js +56 -0
  39. package/dist/action/validate/unknown.js +58 -0
  40. package/dist/action/validate/unsound.js +99 -0
  41. package/dist/action/value/tool.js +216 -0
  42. package/dist/action/whoami/tool.js +7 -0
  43. package/dist/api.js +312 -0
  44. package/dist/arc.js +41 -0
  45. package/dist/cli/argv.js +61 -0
  46. package/dist/cli/channel.js +29 -0
  47. package/dist/cli/command.js +163 -0
  48. package/dist/cli/confirm.js +39 -0
  49. package/dist/cli/options.js +62 -0
  50. package/dist/cli/rc.js +103 -0
  51. package/dist/cli/yargs.js +40 -0
  52. package/dist/command/build.js +68 -0
  53. package/dist/command/delete.js +66 -0
  54. package/dist/command/deploy.js +308 -0
  55. package/dist/command/function/index.js +17 -0
  56. package/dist/command/function/pause.js +18 -0
  57. package/dist/command/function/resume.js +18 -0
  58. package/dist/command/function/run.js +41 -0
  59. package/dist/command/function/secret/index.js +15 -0
  60. package/dist/command/function/secret/list.js +27 -0
  61. package/dist/command/function/secret/name.js +8 -0
  62. package/dist/command/function/secret/remove.js +26 -0
  63. package/dist/command/function/secret/run.js +52 -0
  64. package/dist/command/function/secret/set.js +48 -0
  65. package/dist/command/function/status.js +40 -0
  66. package/dist/command/init.js +128 -0
  67. package/dist/command/inspect.js +39 -0
  68. package/dist/command/login.js +108 -0
  69. package/dist/command/logout.js +24 -0
  70. package/dist/command/open.js +49 -0
  71. package/dist/command/pack.js +90 -0
  72. package/dist/command/play.js +81 -0
  73. package/dist/command/serve.js +177 -0
  74. package/dist/command/server/index.js +17 -0
  75. package/dist/command/server/key/create.js +36 -0
  76. package/dist/command/server/key/index.js +15 -0
  77. package/dist/command/server/key/list.js +34 -0
  78. package/dist/command/server/key/revoke.js +24 -0
  79. package/dist/command/server/key/run.js +54 -0
  80. package/dist/command/validate.js +47 -0
  81. package/dist/command/value/get.js +21 -0
  82. package/dist/command/value/index.js +19 -0
  83. package/dist/command/value/key.js +8 -0
  84. package/dist/command/value/list.js +41 -0
  85. package/dist/command/value/remove.js +26 -0
  86. package/dist/command/value/set.js +62 -0
  87. package/dist/command/value/usage.js +69 -0
  88. package/dist/command/whoami.js +55 -0
  89. package/dist/commands.js +100 -0
  90. package/dist/config/ai.js +2 -0
  91. package/dist/config/art.js +13 -0
  92. package/dist/config/audience.js +2 -0
  93. package/dist/config/code.js +129 -0
  94. package/dist/config/file.js +13 -0
  95. package/dist/config/genre.js +19 -0
  96. package/{src → dist}/config/html.js +2 -7
  97. package/dist/config/image.js +5 -0
  98. package/dist/config/input.js +11 -0
  99. package/dist/config/json.js +23 -0
  100. package/dist/config/limit.js +14 -0
  101. package/dist/config/orientation.js +11 -0
  102. package/dist/config/package.js +8 -0
  103. package/dist/config/product.js +14 -0
  104. package/dist/config/template.js +37 -0
  105. package/dist/config/uri.js +18 -0
  106. package/dist/config/url.js +11 -0
  107. package/dist/config/video.js +5 -0
  108. package/dist/config/visibility.js +2 -0
  109. package/dist/config/workflow.js +7 -0
  110. package/dist/parser/env.js +61 -0
  111. package/dist/parser/given.js +8 -0
  112. package/dist/parser/manifest.js +45 -0
  113. package/dist/parser/media.js +57 -0
  114. package/dist/parser/project.js +129 -0
  115. package/dist/parser/readme-file.js +44 -0
  116. package/dist/parser/readme.js +70 -0
  117. package/dist/parser/sections.js +92 -0
  118. package/dist/parser/self.js +16 -0
  119. package/dist/phrase/account.js +35 -0
  120. package/dist/phrase/common.js +139 -0
  121. package/dist/phrase/deploy.js +192 -0
  122. package/dist/phrase/function.js +139 -0
  123. package/dist/phrase/game.js +27 -0
  124. package/dist/phrase/index.js +16 -0
  125. package/dist/phrase/init.js +53 -0
  126. package/dist/phrase/internal.js +61 -0
  127. package/dist/phrase/manifest.js +120 -0
  128. package/dist/phrase/media.js +90 -0
  129. package/dist/phrase/pack.js +69 -0
  130. package/dist/phrase/serve.js +84 -0
  131. package/dist/phrase/server.js +38 -0
  132. package/dist/phrase/value.js +55 -0
  133. package/dist/runner/bundle.js +45 -0
  134. package/dist/runner/entry.js +57 -0
  135. package/dist/runner/outbound.js +69 -0
  136. package/dist/schema/check/game.js +29 -0
  137. package/dist/schema/check/workflow.js +57 -0
  138. package/dist/schema/game.js +462 -0
  139. package/dist/schema/message.js +61 -0
  140. package/dist/schema/readme.js +27 -0
  141. package/dist/schema/runner.js +43 -0
  142. package/dist/schema/server.js +91 -0
  143. package/dist/schema/workflow.js +99 -0
  144. package/dist/serve/files.js +39 -0
  145. package/dist/serve/game.js +172 -0
  146. package/dist/serve/page.js +689 -0
  147. package/dist/serve/reload.js +55 -0
  148. package/dist/serve/remote.js +114 -0
  149. package/dist/serve/runner.js +303 -0
  150. package/dist/serve/server.js +169 -0
  151. package/dist/serve/ticket.js +232 -0
  152. package/dist/serve/values.js +317 -0
  153. package/dist/util/bytes.js +16 -0
  154. package/dist/util/chars.js +19 -0
  155. package/dist/util/command.js +11 -0
  156. package/dist/util/delay.js +36 -0
  157. package/dist/util/doc.js +59 -0
  158. package/dist/util/error.js +35 -0
  159. package/dist/util/http.js +13 -0
  160. package/dist/util/image.js +64 -0
  161. package/dist/util/links.js +45 -0
  162. package/dist/util/lockfile.js +17 -0
  163. package/dist/util/log.js +101 -0
  164. package/dist/util/md.js +37 -0
  165. package/dist/util/media.js +27 -0
  166. package/dist/util/objs.js +46 -0
  167. package/dist/util/os.js +13 -0
  168. package/dist/util/output.js +133 -0
  169. package/dist/util/paths.js +8 -0
  170. package/dist/util/progress.js +57 -0
  171. package/dist/util/promise.js +18 -0
  172. package/dist/util/request.js +103 -0
  173. package/dist/util/s3.js +67 -0
  174. package/dist/util/schema.js +151 -0
  175. package/dist/util/screenshot.js +24 -0
  176. package/dist/util/shape.js +49 -0
  177. package/dist/util/shell.js +64 -0
  178. package/dist/util/size.js +32 -0
  179. package/dist/util/spinner.js +35 -0
  180. package/dist/util/strs.js +46 -0
  181. package/dist/util/table.js +18 -0
  182. package/dist/util/term.js +21 -0
  183. package/dist/util/time.js +16 -0
  184. package/dist/util/toml.js +28 -0
  185. package/{src → dist}/util/uris.js +8 -14
  186. package/dist/util/video.js +113 -0
  187. package/dist/util/zip.js +62 -0
  188. package/npm-shrinkwrap.json +3256 -0
  189. package/package.json +41 -39
  190. package/bin/arc-build.js +0 -139
  191. package/bin/arc-default.js +0 -65
  192. package/bin/arc-deploy.js +0 -456
  193. package/bin/arc-init.js +0 -187
  194. package/bin/arc-inspect.js +0 -97
  195. package/bin/arc-login.js +0 -165
  196. package/bin/arc-logout.js +0 -75
  197. package/bin/arc-open.js +0 -104
  198. package/bin/arc-pack.js +0 -146
  199. package/bin/arc-play.js +0 -140
  200. package/bin/arc-serve.js +0 -214
  201. package/bin/arc-validate.js +0 -112
  202. package/bin/arc-whoami.js +0 -119
  203. package/src/account.js +0 -249
  204. package/src/action/build/tool.js +0 -80
  205. package/src/action/deploy/tool-git.js +0 -90
  206. package/src/action/deploy/tool.js +0 -88
  207. package/src/action/deploy/wait.js +0 -151
  208. package/src/action/init/manifest.js +0 -83
  209. package/src/action/init/tool-patch.js +0 -32
  210. package/src/action/init/tool.js +0 -97
  211. package/src/action/inspect/tool.js +0 -26
  212. package/src/action/login/flow.js +0 -101
  213. package/src/action/login/tool.js +0 -16
  214. package/src/action/logout/tool.js +0 -15
  215. package/src/action/open/tool.js +0 -38
  216. package/src/action/pack/limits.js +0 -51
  217. package/src/action/pack/tool.js +0 -171
  218. package/src/action/pack/unsound.js +0 -69
  219. package/src/action/play/tool.js +0 -109
  220. package/src/action/predeploy/ac.js +0 -112
  221. package/src/action/predeploy/git.js +0 -223
  222. package/src/action/predeploy/pm.js +0 -37
  223. package/src/action/predeploy/published.js +0 -82
  224. package/src/action/predeploy/tool-git.js +0 -154
  225. package/src/action/predeploy/tool.js +0 -29
  226. package/src/action/serve/tool.js +0 -209
  227. package/src/action/validate/checked.js +0 -37
  228. package/src/action/validate/tool.js +0 -67
  229. package/src/action/validate/unknown.js +0 -86
  230. package/src/action/validate/unsound.js +0 -138
  231. package/src/action/whoami/tool.js +0 -15
  232. package/src/api.js +0 -163
  233. package/src/cli/build.js +0 -15
  234. package/src/cli/deploy.js +0 -21
  235. package/src/cli/init.js +0 -17
  236. package/src/cli/inspect.js +0 -15
  237. package/src/cli/login.js +0 -15
  238. package/src/cli/logout.js +0 -15
  239. package/src/cli/open.js +0 -15
  240. package/src/cli/pack.js +0 -15
  241. package/src/cli/play.js +0 -15
  242. package/src/cli/predeploy.js +0 -21
  243. package/src/cli/serve.js +0 -15
  244. package/src/cli/validate.js +0 -15
  245. package/src/cli/whoami.js +0 -15
  246. package/src/config/ai.js +0 -5
  247. package/src/config/art.js +0 -16
  248. package/src/config/audience.js +0 -5
  249. package/src/config/code.js +0 -142
  250. package/src/config/file.js +0 -23
  251. package/src/config/genre.js +0 -22
  252. package/src/config/image.js +0 -7
  253. package/src/config/input.js +0 -14
  254. package/src/config/limit.js +0 -21
  255. package/src/config/orientation.js +0 -14
  256. package/src/config/package.js +0 -5
  257. package/src/config/product.js +0 -5
  258. package/src/config/template.js +0 -45
  259. package/src/config/uri.js +0 -27
  260. package/src/config/url.js +0 -20
  261. package/src/config/video.js +0 -7
  262. package/src/config/visibility.js +0 -5
  263. package/src/config/workflow.js +0 -18
  264. package/src/parser/env.js +0 -84
  265. package/src/parser/given.js +0 -17
  266. package/src/parser/manifest.js +0 -80
  267. package/src/parser/media.js +0 -90
  268. package/src/parser/project.js +0 -166
  269. package/src/parser/readme-file.js +0 -76
  270. package/src/parser/readme.js +0 -96
  271. package/src/parser/sections.js +0 -107
  272. package/src/parser/self.js +0 -27
  273. package/src/phrase.js +0 -1294
  274. package/src/schema/check/game.js +0 -61
  275. package/src/schema/check/workflow.js +0 -99
  276. package/src/schema/game.js +0 -649
  277. package/src/schema/message.js +0 -85
  278. package/src/schema/readme.js +0 -44
  279. package/src/schema/workflow.js +0 -150
  280. package/src/serve/files.js +0 -61
  281. package/src/serve/game.js +0 -191
  282. package/src/serve/page.js +0 -345
  283. package/src/serve/reload.js +0 -68
  284. package/src/serve/remote.js +0 -121
  285. package/src/serve/server.js +0 -128
  286. package/src/util/argv.js +0 -116
  287. package/src/util/bytes.js +0 -25
  288. package/src/util/chars.js +0 -30
  289. package/src/util/command.js +0 -18
  290. package/src/util/delay.js +0 -52
  291. package/src/util/doc.js +0 -72
  292. package/src/util/error.js +0 -50
  293. package/src/util/http.js +0 -25
  294. package/src/util/image.js +0 -93
  295. package/src/util/links.js +0 -78
  296. package/src/util/lockfile.js +0 -35
  297. package/src/util/log.js +0 -149
  298. package/src/util/md.js +0 -61
  299. package/src/util/media.js +0 -40
  300. package/src/util/objs.js +0 -45
  301. package/src/util/os.js +0 -27
  302. package/src/util/output.js +0 -174
  303. package/src/util/paths.js +0 -21
  304. package/src/util/progress.js +0 -85
  305. package/src/util/promise.js +0 -29
  306. package/src/util/rc.js +0 -144
  307. package/src/util/request.js +0 -89
  308. package/src/util/s3.js +0 -92
  309. package/src/util/schema.js +0 -189
  310. package/src/util/screenshot.js +0 -37
  311. package/src/util/shell.js +0 -84
  312. package/src/util/size.js +0 -53
  313. package/src/util/spinner.js +0 -52
  314. package/src/util/strs.js +0 -73
  315. package/src/util/term.js +0 -28
  316. package/src/util/time.js +0 -29
  317. package/src/util/toml.js +0 -14
  318. package/src/util/video.js +0 -157
  319. package/src/util/zip.js +0 -88
  320. /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 };
@@ -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
- };
@@ -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 };