arcadible 1.0.22 → 1.0.24

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 (308) hide show
  1. package/README.md +2 -1
  2. package/bin/arc.js +1 -85
  3. package/dist/account.js +197 -0
  4. package/dist/action/build/tool.js +65 -0
  5. package/dist/action/delete/tool.js +46 -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 +54 -0
  10. package/dist/action/deploy/tool.js +54 -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 +61 -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 +87 -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 +29 -0
  23. package/dist/action/pack/limits.js +46 -0
  24. package/dist/action/pack/tool.js +150 -0
  25. package/dist/action/pack/unsound.js +51 -0
  26. package/dist/action/play/tool.js +83 -0
  27. package/dist/action/predeploy/ac.js +75 -0
  28. package/dist/action/predeploy/game.js +12 -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 +108 -0
  34. package/dist/action/predeploy/tool.js +16 -0
  35. package/dist/action/secret/tool.js +91 -0
  36. package/dist/action/serve/tool.js +249 -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/whoami/tool.js +7 -0
  42. package/dist/api.js +160 -0
  43. package/dist/arc.js +41 -0
  44. package/dist/cli/argv.js +61 -0
  45. package/dist/cli/channel.js +29 -0
  46. package/dist/cli/command.js +163 -0
  47. package/dist/cli/confirm.js +39 -0
  48. package/dist/cli/options.js +62 -0
  49. package/dist/cli/rc.js +103 -0
  50. package/dist/cli/yargs.js +40 -0
  51. package/dist/command/build.js +68 -0
  52. package/dist/command/delete.js +66 -0
  53. package/dist/command/deploy.js +308 -0
  54. package/dist/command/function/index.js +17 -0
  55. package/dist/command/function/pause.js +18 -0
  56. package/dist/command/function/resume.js +18 -0
  57. package/dist/command/function/run.js +41 -0
  58. package/dist/command/function/secret/index.js +15 -0
  59. package/dist/command/function/secret/list.js +27 -0
  60. package/dist/command/function/secret/name.js +8 -0
  61. package/dist/command/function/secret/remove.js +26 -0
  62. package/dist/command/function/secret/run.js +52 -0
  63. package/dist/command/function/secret/set.js +48 -0
  64. package/dist/command/function/status.js +40 -0
  65. package/dist/command/init.js +128 -0
  66. package/dist/command/inspect.js +38 -0
  67. package/dist/command/login.js +108 -0
  68. package/dist/command/logout.js +24 -0
  69. package/dist/command/open.js +48 -0
  70. package/dist/command/pack.js +90 -0
  71. package/dist/command/play.js +80 -0
  72. package/dist/command/serve.js +176 -0
  73. package/dist/command/server/index.js +17 -0
  74. package/dist/command/server/key/create.js +36 -0
  75. package/dist/command/server/key/index.js +15 -0
  76. package/dist/command/server/key/list.js +34 -0
  77. package/dist/command/server/key/revoke.js +24 -0
  78. package/dist/command/server/key/run.js +54 -0
  79. package/dist/command/validate.js +47 -0
  80. package/dist/command/whoami.js +55 -0
  81. package/dist/commands.js +93 -0
  82. package/dist/config/ai.js +2 -0
  83. package/dist/config/art.js +13 -0
  84. package/dist/config/audience.js +2 -0
  85. package/dist/config/code.js +129 -0
  86. package/dist/config/file.js +13 -0
  87. package/dist/config/genre.js +19 -0
  88. package/{src → dist}/config/html.js +2 -7
  89. package/dist/config/image.js +5 -0
  90. package/dist/config/input.js +11 -0
  91. package/dist/config/json.js +23 -0
  92. package/dist/config/limit.js +14 -0
  93. package/dist/config/orientation.js +11 -0
  94. package/dist/config/package.js +8 -0
  95. package/dist/config/product.js +14 -0
  96. package/dist/config/template.js +37 -0
  97. package/dist/config/uri.js +18 -0
  98. package/dist/config/url.js +11 -0
  99. package/dist/config/video.js +5 -0
  100. package/dist/config/visibility.js +2 -0
  101. package/dist/config/workflow.js +7 -0
  102. package/dist/parser/env.js +61 -0
  103. package/dist/parser/given.js +8 -0
  104. package/dist/parser/manifest.js +45 -0
  105. package/dist/parser/media.js +57 -0
  106. package/dist/parser/project.js +129 -0
  107. package/dist/parser/readme-file.js +44 -0
  108. package/dist/parser/readme.js +70 -0
  109. package/dist/parser/sections.js +92 -0
  110. package/dist/parser/self.js +16 -0
  111. package/dist/phrase/account.js +35 -0
  112. package/dist/phrase/common.js +130 -0
  113. package/dist/phrase/deploy.js +184 -0
  114. package/dist/phrase/function.js +135 -0
  115. package/dist/phrase/game.js +27 -0
  116. package/dist/phrase/index.js +15 -0
  117. package/dist/phrase/init.js +53 -0
  118. package/dist/phrase/internal.js +61 -0
  119. package/dist/phrase/manifest.js +120 -0
  120. package/dist/phrase/media.js +90 -0
  121. package/dist/phrase/pack.js +69 -0
  122. package/dist/phrase/serve.js +84 -0
  123. package/dist/phrase/server.js +38 -0
  124. package/dist/runner/bundle.js +95 -0
  125. package/dist/runner/outbound.js +69 -0
  126. package/dist/schema/check/game.js +29 -0
  127. package/dist/schema/check/workflow.js +57 -0
  128. package/dist/schema/game.js +462 -0
  129. package/dist/schema/message.js +61 -0
  130. package/dist/schema/readme.js +27 -0
  131. package/dist/schema/runner.js +43 -0
  132. package/dist/schema/server.js +91 -0
  133. package/dist/schema/workflow.js +99 -0
  134. package/dist/serve/files.js +39 -0
  135. package/dist/serve/game.js +172 -0
  136. package/dist/serve/page.js +490 -0
  137. package/dist/serve/reload.js +55 -0
  138. package/dist/serve/remote.js +114 -0
  139. package/dist/serve/runner.js +296 -0
  140. package/dist/serve/server.js +163 -0
  141. package/dist/serve/ticket.js +232 -0
  142. package/dist/util/bytes.js +16 -0
  143. package/dist/util/chars.js +19 -0
  144. package/dist/util/command.js +11 -0
  145. package/dist/util/delay.js +36 -0
  146. package/dist/util/doc.js +59 -0
  147. package/dist/util/error.js +35 -0
  148. package/dist/util/http.js +13 -0
  149. package/dist/util/image.js +64 -0
  150. package/dist/util/links.js +45 -0
  151. package/dist/util/lockfile.js +17 -0
  152. package/dist/util/log.js +101 -0
  153. package/dist/util/md.js +37 -0
  154. package/dist/util/media.js +27 -0
  155. package/dist/util/objs.js +29 -0
  156. package/dist/util/os.js +13 -0
  157. package/dist/util/output.js +133 -0
  158. package/dist/util/paths.js +8 -0
  159. package/dist/util/progress.js +57 -0
  160. package/dist/util/promise.js +18 -0
  161. package/dist/util/request.js +91 -0
  162. package/dist/util/s3.js +67 -0
  163. package/dist/util/schema.js +151 -0
  164. package/dist/util/screenshot.js +24 -0
  165. package/dist/util/shell.js +64 -0
  166. package/dist/util/size.js +32 -0
  167. package/dist/util/spinner.js +35 -0
  168. package/dist/util/strs.js +46 -0
  169. package/dist/util/table.js +18 -0
  170. package/dist/util/term.js +21 -0
  171. package/dist/util/time.js +16 -0
  172. package/dist/util/toml.js +28 -0
  173. package/{src → dist}/util/uris.js +8 -14
  174. package/dist/util/video.js +113 -0
  175. package/dist/util/zip.js +62 -0
  176. package/npm-shrinkwrap.json +3256 -0
  177. package/package.json +42 -40
  178. package/bin/arc-build.js +0 -139
  179. package/bin/arc-default.js +0 -65
  180. package/bin/arc-deploy.js +0 -456
  181. package/bin/arc-init.js +0 -187
  182. package/bin/arc-inspect.js +0 -97
  183. package/bin/arc-login.js +0 -165
  184. package/bin/arc-logout.js +0 -75
  185. package/bin/arc-open.js +0 -104
  186. package/bin/arc-pack.js +0 -146
  187. package/bin/arc-play.js +0 -140
  188. package/bin/arc-serve.js +0 -214
  189. package/bin/arc-validate.js +0 -112
  190. package/bin/arc-whoami.js +0 -119
  191. package/src/account.js +0 -249
  192. package/src/action/build/tool.js +0 -80
  193. package/src/action/deploy/tool-git.js +0 -90
  194. package/src/action/deploy/tool.js +0 -88
  195. package/src/action/deploy/wait.js +0 -151
  196. package/src/action/init/manifest.js +0 -83
  197. package/src/action/init/tool-patch.js +0 -32
  198. package/src/action/init/tool.js +0 -97
  199. package/src/action/inspect/tool.js +0 -26
  200. package/src/action/login/flow.js +0 -101
  201. package/src/action/login/tool.js +0 -16
  202. package/src/action/logout/tool.js +0 -15
  203. package/src/action/open/tool.js +0 -38
  204. package/src/action/pack/limits.js +0 -51
  205. package/src/action/pack/tool.js +0 -171
  206. package/src/action/pack/unsound.js +0 -69
  207. package/src/action/play/tool.js +0 -109
  208. package/src/action/predeploy/ac.js +0 -112
  209. package/src/action/predeploy/git.js +0 -223
  210. package/src/action/predeploy/pm.js +0 -37
  211. package/src/action/predeploy/published.js +0 -82
  212. package/src/action/predeploy/tool-git.js +0 -154
  213. package/src/action/predeploy/tool.js +0 -29
  214. package/src/action/serve/tool.js +0 -209
  215. package/src/action/validate/checked.js +0 -37
  216. package/src/action/validate/tool.js +0 -67
  217. package/src/action/validate/unknown.js +0 -86
  218. package/src/action/validate/unsound.js +0 -138
  219. package/src/action/whoami/tool.js +0 -15
  220. package/src/api.js +0 -163
  221. package/src/cli/build.js +0 -15
  222. package/src/cli/deploy.js +0 -21
  223. package/src/cli/init.js +0 -17
  224. package/src/cli/inspect.js +0 -15
  225. package/src/cli/login.js +0 -15
  226. package/src/cli/logout.js +0 -15
  227. package/src/cli/open.js +0 -15
  228. package/src/cli/pack.js +0 -15
  229. package/src/cli/play.js +0 -15
  230. package/src/cli/predeploy.js +0 -21
  231. package/src/cli/serve.js +0 -15
  232. package/src/cli/validate.js +0 -15
  233. package/src/cli/whoami.js +0 -15
  234. package/src/config/ai.js +0 -5
  235. package/src/config/art.js +0 -16
  236. package/src/config/audience.js +0 -5
  237. package/src/config/code.js +0 -142
  238. package/src/config/file.js +0 -23
  239. package/src/config/genre.js +0 -22
  240. package/src/config/image.js +0 -7
  241. package/src/config/input.js +0 -14
  242. package/src/config/limit.js +0 -21
  243. package/src/config/orientation.js +0 -14
  244. package/src/config/package.js +0 -5
  245. package/src/config/product.js +0 -5
  246. package/src/config/template.js +0 -45
  247. package/src/config/uri.js +0 -27
  248. package/src/config/url.js +0 -20
  249. package/src/config/video.js +0 -7
  250. package/src/config/visibility.js +0 -5
  251. package/src/config/workflow.js +0 -18
  252. package/src/parser/env.js +0 -84
  253. package/src/parser/given.js +0 -17
  254. package/src/parser/manifest.js +0 -80
  255. package/src/parser/media.js +0 -90
  256. package/src/parser/project.js +0 -166
  257. package/src/parser/readme-file.js +0 -76
  258. package/src/parser/readme.js +0 -96
  259. package/src/parser/sections.js +0 -107
  260. package/src/parser/self.js +0 -27
  261. package/src/phrase.js +0 -1294
  262. package/src/schema/check/game.js +0 -61
  263. package/src/schema/check/workflow.js +0 -99
  264. package/src/schema/game.js +0 -649
  265. package/src/schema/message.js +0 -85
  266. package/src/schema/readme.js +0 -44
  267. package/src/schema/workflow.js +0 -150
  268. package/src/serve/files.js +0 -61
  269. package/src/serve/game.js +0 -191
  270. package/src/serve/page.js +0 -345
  271. package/src/serve/reload.js +0 -68
  272. package/src/serve/remote.js +0 -121
  273. package/src/serve/server.js +0 -128
  274. package/src/util/argv.js +0 -116
  275. package/src/util/bytes.js +0 -25
  276. package/src/util/chars.js +0 -30
  277. package/src/util/command.js +0 -18
  278. package/src/util/delay.js +0 -52
  279. package/src/util/doc.js +0 -72
  280. package/src/util/error.js +0 -50
  281. package/src/util/http.js +0 -25
  282. package/src/util/image.js +0 -93
  283. package/src/util/links.js +0 -78
  284. package/src/util/lockfile.js +0 -35
  285. package/src/util/log.js +0 -149
  286. package/src/util/md.js +0 -61
  287. package/src/util/media.js +0 -40
  288. package/src/util/objs.js +0 -45
  289. package/src/util/os.js +0 -27
  290. package/src/util/output.js +0 -174
  291. package/src/util/paths.js +0 -21
  292. package/src/util/progress.js +0 -85
  293. package/src/util/promise.js +0 -29
  294. package/src/util/rc.js +0 -144
  295. package/src/util/request.js +0 -89
  296. package/src/util/s3.js +0 -92
  297. package/src/util/schema.js +0 -189
  298. package/src/util/screenshot.js +0 -37
  299. package/src/util/shell.js +0 -84
  300. package/src/util/size.js +0 -53
  301. package/src/util/spinner.js +0 -52
  302. package/src/util/strs.js +0 -73
  303. package/src/util/term.js +0 -28
  304. package/src/util/time.js +0 -29
  305. package/src/util/toml.js +0 -14
  306. package/src/util/video.js +0 -157
  307. package/src/util/zip.js +0 -88
  308. /package/{src/serve → assets}/favicon.ico +0 -0
@@ -0,0 +1,80 @@
1
+ // [import]
2
+ import { resolve } from "node:path";
3
+ // [import]
4
+ import { GAME_ID_MISSING } from "../config/code.js";
5
+ import { defineCommand } from "../cli/command.js";
6
+ import { ArcError } from "../util/error.js";
7
+ import { gameIdMissing, noProductionRelease } from "../phrase/index.js";
8
+ import { pw } from "../util/log.js";
9
+ import { BROWSER, CWD, JSON_OUTPUT, QUIET } from "../cli/options.js";
10
+ import { launched, print } from "../util/output.js";
11
+ import { launch } from "../util/shell.js";
12
+ import { SpinnerWheel } from "../util/spinner.js";
13
+ import { playTool } from "../action/play/tool.js";
14
+ import { HOST_APP_PLAY } from "../config/uri.js";
15
+ // [function]
16
+ function handler({ quiet, sw, }) {
17
+ return {
18
+ onPlayFetch() {
19
+ sw.start(quiet);
20
+ },
21
+ };
22
+ }
23
+ // [export]
24
+ export default defineCommand({
25
+ name: "play",
26
+ options: {
27
+ release: {
28
+ alias: "r",
29
+ // without one, the action picks production, or staging when there's
30
+ // no production release yet (docs: arc-play.md).
31
+ defaultDescription: '"production"',
32
+ describe: "Release channel or version",
33
+ rc: true,
34
+ type: "string",
35
+ },
36
+ browser: BROWSER,
37
+ json: JSON_OUTPUT,
38
+ quiet: QUIET,
39
+ cwd: CWD,
40
+ },
41
+ positionals: {
42
+ game: {
43
+ default: "self",
44
+ describe: "Game handle or ID",
45
+ rc: true,
46
+ type: "string",
47
+ },
48
+ },
49
+ async run(argv, aborting) {
50
+ const sw = new SpinnerWheel("Opening… %s");
51
+ aborting.sw = sw;
52
+ const data = await playTool({
53
+ // strings from the command line; `.arcrc` can give anything.
54
+ game: argv.game ? String(argv.game) : null,
55
+ release: argv.release ? String(argv.release) : null,
56
+ root: resolve(process.cwd(), argv.cwd),
57
+ }, handler({ quiet: argv.json || argv.quiet, sw }));
58
+ const orientation = data?.orientation;
59
+ const url = data?.url;
60
+ if (!data || !orientation || !url) {
61
+ throw new ArcError(GAME_ID_MISSING, gameIdMissing());
62
+ }
63
+ sw.stop(true);
64
+ if (data.fallback && !argv.json && !argv.quiet) {
65
+ pw(noProductionRelease());
66
+ }
67
+ const where = await (argv.browser
68
+ ? launch(url)
69
+ : launch(`${HOST_APP_PLAY}/${String(orientation)}/${url}`, url));
70
+ if (argv.json) {
71
+ // where it opened (app, browser, or null when it couldn't), and the
72
+ // play link, which names the channel or version it plays.
73
+ print({ opened: where, url });
74
+ }
75
+ else if (!argv.quiet) {
76
+ launched(where, url);
77
+ }
78
+ },
79
+ summary: "Play a game",
80
+ });
@@ -0,0 +1,176 @@
1
+ // [import]
2
+ import { relative, resolve } from "node:path";
3
+ // [import]
4
+ import { ARGUMENT_INVALID } from "../config/code.js";
5
+ import { defineCommand } from "../cli/command.js";
6
+ import { ArcError } from "../util/error.js";
7
+ import * as phrase from "../phrase/index.js";
8
+ import { nlpw, p, pw, result } from "../util/log.js";
9
+ import { CWD, QUIET } from "../cli/options.js";
10
+ import { launched } from "../util/output.js";
11
+ import { launch } from "../util/shell.js";
12
+ import { SpinnerWheel } from "../util/spinner.js";
13
+ import { serveTool } from "../action/serve/tool.js";
14
+ import { SERVE_URL } from "../config/url.js";
15
+ // [declare]
16
+ const PORT = 4100;
17
+ // [function]
18
+ // fails unless the port is one a server can listen on.
19
+ function checkPort(port) {
20
+ if (Number.isInteger(port) && port > 0 && port < 65536) {
21
+ return Promise.resolve();
22
+ }
23
+ return Promise.reject(new ArcError(ARGUMENT_INVALID, phrase.portInvalid()));
24
+ }
25
+ // [function]
26
+ // the page --url names, as a URL, or a failure when it isn't an http one.
27
+ function checkUrl(url) {
28
+ if (url === null || typeof url === "undefined") {
29
+ return Promise.resolve(null);
30
+ }
31
+ try {
32
+ const parsed = new URL(String(url));
33
+ if (parsed.protocol === "http:" || parsed.protocol === "https:") {
34
+ return Promise.resolve(parsed.href);
35
+ }
36
+ }
37
+ catch {
38
+ // not a URL at all: refused below, as one that isn't http.
39
+ }
40
+ return Promise.reject(new ArcError(ARGUMENT_INVALID, phrase.urlInvalid()));
41
+ }
42
+ // [function]
43
+ // warns once for each of Arcadible's files that's a kept copy, or can't be
44
+ // had, rather than on every request.
45
+ function remoteWarnings({ quiet }) {
46
+ const warned = new Set();
47
+ return function (name, file, ex) {
48
+ const message = ex
49
+ ? phrase.remoteUnreachable(name)
50
+ : file?.kept && phrase.remoteKept(name, file.fetchedAt);
51
+ if (!message || quiet || warned.has(message)) {
52
+ return;
53
+ }
54
+ warned.add(message);
55
+ pw(message);
56
+ };
57
+ }
58
+ // [export]
59
+ export default defineCommand({
60
+ name: "serve",
61
+ options: {
62
+ port: {
63
+ alias: "p",
64
+ default: PORT,
65
+ describe: "Serve on this port",
66
+ rc: true,
67
+ type: "number",
68
+ },
69
+ build: {
70
+ default: true,
71
+ describe: "Run the build command first",
72
+ rc: true,
73
+ type: "boolean",
74
+ },
75
+ url: {
76
+ describe: "Frame another server's page instead of deploy_dir",
77
+ rc: true,
78
+ type: "string",
79
+ },
80
+ open: {
81
+ alias: "o",
82
+ default: false,
83
+ describe: "Open the play page in a web browser",
84
+ rc: true,
85
+ type: "boolean",
86
+ },
87
+ // run the game for a logged-in player of this name, the same one each
88
+ // run; without it, a guest. Left out of the help until tickets ship,
89
+ // with the docs.
90
+ player: { hidden: true, rc: true, type: "string" },
91
+ // serve a play page's host built here, for working on the host itself;
92
+ // without it, Arcadible's own. Left out of the help.
93
+ host: { hidden: true, rc: true, type: "string" },
94
+ quiet: QUIET,
95
+ cwd: CWD,
96
+ },
97
+ // resolves with nothing, so the process goes on serving until it's
98
+ // stopped.
99
+ async run(argv, aborting) {
100
+ const quiet = argv.quiet;
101
+ // `.arcrc` values are strings, and a flag that isn't a number is NaN.
102
+ const port = Number(argv.port);
103
+ const root = resolve(process.cwd(), argv.cwd);
104
+ const sw = new SpinnerWheel("Building… %s");
105
+ aborting.sw = sw;
106
+ await checkPort(port);
107
+ const url = await checkUrl(argv.url);
108
+ const served = await serveTool({
109
+ build: argv.build,
110
+ handler: {
111
+ onBuild: () => sw.start(quiet),
112
+ onReload() {
113
+ if (!quiet) {
114
+ p(phrase.reloaded());
115
+ }
116
+ },
117
+ onRemote: remoteWarnings({ quiet }),
118
+ onRunnerError(ex) {
119
+ pw(phrase.runnerFailed(ex.message));
120
+ },
121
+ onRunnerInstall() {
122
+ if (!quiet) {
123
+ p(phrase.runnerInstalling());
124
+ }
125
+ },
126
+ onRunnerStart({ ms }) {
127
+ if (!quiet) {
128
+ p(phrase.runnerStarted(ms));
129
+ }
130
+ },
131
+ },
132
+ host: typeof argv.host === "string" ? argv.host : undefined,
133
+ player: argv.player,
134
+ port,
135
+ root,
136
+ url,
137
+ });
138
+ sw.stop(true);
139
+ const stop = () => {
140
+ served.close();
141
+ process.exit(0);
142
+ };
143
+ process.once("SIGINT", stop);
144
+ process.once("SIGTERM", stop);
145
+ if (!quiet) {
146
+ const blocks = [
147
+ [phrase.playLabel(), `${served.page}/`],
148
+ [phrase.serveAlone(), served.game],
149
+ ...(served.runner ? [[phrase.runnerLabel(), served.runner.url]] : []),
150
+ ...(served.forServer
151
+ ? [[phrase.serveServer(), `ARCADIBLE_SERVE=${served.page}`]]
152
+ : []),
153
+ served.url
154
+ ? phrase.serveNextUrl()
155
+ : phrase.serveNext(relative(root, served.deployDir ?? root) || "."),
156
+ ];
157
+ result(phrase.served({
158
+ built: served.built,
159
+ url: served.url,
160
+ // the project's, as it has it: arc serve doesn't validate it.
161
+ version: served.version ? String(served.version) : null,
162
+ }), blocks);
163
+ if (served.probed && !served.probed.reachable) {
164
+ nlpw(phrase.urlUnreachable(served.url ?? ""));
165
+ }
166
+ else if (served.probed && !served.probed.frameable) {
167
+ nlpw(phrase.urlNotFrameable(served.url ?? "", SERVE_URL));
168
+ }
169
+ }
170
+ const where = argv.open ? await launch(`${served.page}/`) : false;
171
+ if (where !== false && !quiet) {
172
+ launched(where, `http://localhost:${port}/`);
173
+ }
174
+ },
175
+ summary: "Serve the game locally",
176
+ });
@@ -0,0 +1,17 @@
1
+ // arc server: a game's own server, the one its developer runs: the keys it
2
+ // proves itself to Arcadible with (./key/index.ts). It's left out of
3
+ // `arc --help` until keys ship, with the docs. Not `arc serve`, which runs
4
+ // the game on this machine: its help says so, since the two are a letter
5
+ // apart.
6
+ // [import]
7
+ import { defineCommand } from "../../cli/command.js";
8
+ import key from "./key/index.js";
9
+ import { serverNotServe } from "../../phrase/index.js";
10
+ // [export]
11
+ export default defineCommand({
12
+ commands: [key],
13
+ epilogue: serverNotServe(),
14
+ hidden: true,
15
+ name: "server",
16
+ summary: "Make, list, and revoke your server's keys",
17
+ });
@@ -0,0 +1,36 @@
1
+ // [import]
2
+ import { defineCommand } from "../../../cli/command.js";
3
+ import { keyCreated } from "../../../phrase/index.js";
4
+ import { pd } from "../../../util/log.js";
5
+ import { CHANNEL, CWD, JSON_OUTPUT, QUIET } from "../../../cli/options.js";
6
+ import { run } from "./run.js";
7
+ import { create } from "../../../action/key/tool.js";
8
+ // [export]
9
+ export default defineCommand({
10
+ name: "create",
11
+ options: {
12
+ json: JSON_OUTPUT,
13
+ quiet: QUIET,
14
+ cwd: CWD,
15
+ ...CHANNEL,
16
+ name: {
17
+ alias: "n",
18
+ describe: "A name to tell it from the game's other keys",
19
+ rc: true,
20
+ type: "string",
21
+ },
22
+ },
23
+ run(argv, aborting) {
24
+ return run(argv, aborting, (current, conf) => create(current, { ...conf, name: argv.name }), (made, quiet) => {
25
+ // the key alone on stdout; what's said about it on stderr. The key
26
+ // is the result, and it's had only now, so `--quiet` leaves out
27
+ // what's said about it and never the key: a key made and not shown
28
+ // would be one nobody holds.
29
+ process.stdout.write(`${made.key}\n`);
30
+ if (!quiet) {
31
+ pd(keyCreated(made));
32
+ }
33
+ }, "arc server key create", null, true);
34
+ },
35
+ summary: "Make a key, and print it once",
36
+ });
@@ -0,0 +1,15 @@
1
+ // arc server key: a game's keys, which its own server proves itself with
2
+ // to Arcadible. `create` prints the new key alone on stdout, since it's
3
+ // shown once and is what a script wants; everything else it says goes to
4
+ // stderr.
5
+ // [import]
6
+ import { defineCommand } from "../../../cli/command.js";
7
+ import create from "./create.js";
8
+ import list from "./list.js";
9
+ import revoke from "./revoke.js";
10
+ // [export]
11
+ export default defineCommand({
12
+ commands: [create, list, revoke],
13
+ name: "key",
14
+ summary: "Make, list, and revoke your server's keys",
15
+ });
@@ -0,0 +1,34 @@
1
+ // [import]
2
+ import { defineCommand } from "../../../cli/command.js";
3
+ import { keyNone } from "../../../phrase/index.js";
4
+ import { p } from "../../../util/log.js";
5
+ import { CHANNEL_SHOWS, CWD, JSON_OUTPUT, QUIET, } from "../../../cli/options.js";
6
+ import { run } from "./run.js";
7
+ import { day, table } from "../../../util/table.js";
8
+ import { list } from "../../../action/key/tool.js";
9
+ // [function]
10
+ // the keys as a table, a row each.
11
+ function rows(keys) {
12
+ return table([
13
+ ["ID", "NAME", "CHANNEL", "KEY", "MADE", "LAST USED"],
14
+ ...keys.map((each) => [
15
+ each.id,
16
+ each.name,
17
+ each.channel,
18
+ each.shown,
19
+ day(each.created_at),
20
+ day(each.used_at),
21
+ ]),
22
+ ]);
23
+ }
24
+ // [export]
25
+ export default defineCommand({
26
+ name: "list",
27
+ options: { json: JSON_OUTPUT, quiet: QUIET, cwd: CWD, ...CHANNEL_SHOWS },
28
+ run(argv, aborting) {
29
+ return run(argv, aborting, list, (keys) => {
30
+ p(keys.length ? rows(keys) : keyNone());
31
+ });
32
+ },
33
+ summary: "List the game's keys",
34
+ });
@@ -0,0 +1,24 @@
1
+ // [import]
2
+ import { defineCommand } from "../../../cli/command.js";
3
+ import { keyRevoked, keyRevokeQuestion } from "../../../phrase/index.js";
4
+ import { p } from "../../../util/log.js";
5
+ import { CWD, JSON_OUTPUT, QUIET, YES } from "../../../cli/options.js";
6
+ import { run } from "./run.js";
7
+ import { revoke } from "../../../action/key/tool.js";
8
+ // [export]
9
+ export default defineCommand({
10
+ name: "revoke",
11
+ options: { json: JSON_OUTPUT, quiet: QUIET, cwd: CWD, yes: YES },
12
+ positionals: {
13
+ id: { describe: "The key's id", required: true, type: "string" },
14
+ },
15
+ run(argv, aborting) {
16
+ return run(argv, aborting, (current, conf) => revoke(current, { ...conf, id: argv.id }), (gone) => {
17
+ p(keyRevoked(gone.id));
18
+ }, null, () => ({
19
+ question: keyRevokeQuestion(),
20
+ usage: `arc server key revoke ${argv.id}`,
21
+ }));
22
+ },
23
+ summary: "Revoke a key, by the id `list` shows",
24
+ });
@@ -0,0 +1,54 @@
1
+ // what `arc server key`'s commands share: running one as the logged-in
2
+ // account.
3
+ // [import]
4
+ import { resolve } from "node:path";
5
+ // [import]
6
+ import { ended } from "../../../account.js";
7
+ import { of } from "../../../cli/channel.js";
8
+ import { sure, } from "../../../cli/confirm.js";
9
+ import { confirmDeclined } from "../../../phrase/index.js";
10
+ import { p } from "../../../util/log.js";
11
+ import { print } from "../../../util/output.js";
12
+ import { SpinnerWheel } from "../../../util/spinner.js";
13
+ import { whoami } from "../../../action/whoami/tool.js";
14
+ // [function]
15
+ // runs one command as the logged-in account, and prints what `shown` makes
16
+ // of its result: nothing with `--quiet`, unless the command says its result
17
+ // is `kept` then too (`create`, whose key is had only once, so `shown` is
18
+ // told it's quiet and prints the key alone). `usage` is the command as it's typed, for one that changes
19
+ // something, which then needs a channel. `question(channel)` is asked first,
20
+ // for one that can't be undone (src/cli/confirm.ts). A session that was
21
+ // refused is refreshed, so the failure says to log in again.
22
+ export async function run(argv, aborting, command, shown, usage = null, question = null, kept = false) {
23
+ const json = argv.json;
24
+ const quiet = argv.quiet;
25
+ const sw = new SpinnerWheel("Checking… %s");
26
+ aborting.sw = sw;
27
+ const handler = {
28
+ onAccountRefresh(refresh) {
29
+ sw.start(json || quiet);
30
+ return refresh();
31
+ },
32
+ };
33
+ // the channel first, so a command given none says so before anything else
34
+ const where = of(argv, usage);
35
+ if (question && !(await sure(argv, question(where)))) {
36
+ // a no at the prompt changes nothing, and isn't a failure
37
+ if (!quiet) {
38
+ p(confirmDeclined());
39
+ }
40
+ return;
41
+ }
42
+ const current = await whoami({}, handler);
43
+ const result = await command(current, {
44
+ channel: where,
45
+ root: resolve(process.cwd(), argv.cwd),
46
+ }).catch(ended(current));
47
+ sw.stop(true);
48
+ if (json) {
49
+ print(result);
50
+ }
51
+ else if (!quiet || kept) {
52
+ shown(result, quiet);
53
+ }
54
+ }
@@ -0,0 +1,47 @@
1
+ // [import]
2
+ import { resolve } from "node:path";
3
+ // [import]
4
+ import { defineCommand } from "../cli/command.js";
5
+ import { listed, noIssuesFound } from "../phrase/index.js";
6
+ import { h, hdo, hs, hwo, p } from "../util/log.js";
7
+ import { CWD, JSON_OUTPUT, QUIET } from "../cli/options.js";
8
+ import { print } from "../util/output.js";
9
+ import { dereference, print as schemaPrint } from "../util/schema.js";
10
+ import { validateTool } from "../action/validate/tool.js";
11
+ // [export]
12
+ export default defineCommand({
13
+ name: "validate",
14
+ options: { json: JSON_OUTPUT, quiet: QUIET, cwd: CWD },
15
+ async run(argv) {
16
+ const { issues, warnings } = await validateTool({
17
+ root: resolve(process.cwd(), argv.cwd),
18
+ });
19
+ const count = issues.length;
20
+ if (argv.json) {
21
+ print({ issues, warnings });
22
+ }
23
+ else {
24
+ const [probs, refs] = dereference(issues);
25
+ const probcount = probs.length;
26
+ if (probcount) {
27
+ hdo(listed(probcount, "issue"));
28
+ p(probs.map((prob) => `✗ ${prob}`));
29
+ }
30
+ const warncount = argv.quiet ? 0 : warnings.length;
31
+ if (warncount) {
32
+ hwo(listed(warncount, "warning"));
33
+ p(warnings.map((each) => `⚠ ${schemaPrint(each)}`));
34
+ }
35
+ const refcount = refs.length;
36
+ if (refcount) {
37
+ h(listed(refcount, "reference"));
38
+ p(refs);
39
+ }
40
+ if (!count && !argv.quiet) {
41
+ hs(noIssuesFound());
42
+ }
43
+ }
44
+ return count ? 1 : 0;
45
+ },
46
+ summary: "Check the project for issues",
47
+ });
@@ -0,0 +1,55 @@
1
+ // [import]
2
+ import { SESSION_EXPIRED } from "../config/code.js";
3
+ import { defineCommand } from "../cli/command.js";
4
+ import { ArcError } from "../util/error.js";
5
+ import { noAccount } from "../phrase/index.js";
6
+ import { p } from "../util/log.js";
7
+ import { JSON_OUTPUT, QUIET } from "../cli/options.js";
8
+ import { print } from "../util/output.js";
9
+ import { SpinnerWheel } from "../util/spinner.js";
10
+ import { whoami } from "../action/whoami/tool.js";
11
+ // [function]
12
+ function handler({ json, quiet, sw, }) {
13
+ return {
14
+ onAccountRefresh(refresh) {
15
+ sw.start(json || quiet);
16
+ return refresh();
17
+ },
18
+ };
19
+ }
20
+ // [function]
21
+ // the logged-in account, or null for none: a session that can't be
22
+ // refreshed is no session, and `expired` is told why.
23
+ function account(handlers, expired) {
24
+ return whoami({}, handlers).catch((ex) => {
25
+ if (ex instanceof ArcError && ex.code === SESSION_EXPIRED) {
26
+ expired(ex.message);
27
+ return null;
28
+ }
29
+ throw ex;
30
+ });
31
+ }
32
+ // [export]
33
+ export default defineCommand({
34
+ name: "whoami",
35
+ options: { json: JSON_OUTPUT, quiet: QUIET },
36
+ async run(argv, aborting) {
37
+ const json = argv.json;
38
+ const sw = new SpinnerWheel("Checking… %s");
39
+ aborting.sw = sw;
40
+ // what's said for no account: that there's none, or why it ended.
41
+ let none = noAccount();
42
+ const current = await account(handler({ json, quiet: argv.quiet, sw }), (message) => {
43
+ none = message;
44
+ });
45
+ const user = current?.user;
46
+ sw.stop(true);
47
+ if (json) {
48
+ print({ user: user ?? null });
49
+ }
50
+ else if (!argv.quiet) {
51
+ p(user ? user.display_name : none);
52
+ }
53
+ },
54
+ summary: "Show the logged-in account",
55
+ });
@@ -0,0 +1,93 @@
1
+ // every command, in `arc --help`'s order, each loaded only when it's the one
2
+ // run. `summary` is the command's line in `arc --help`, and `hidden` leaves
3
+ // it out: both are here as well as in the command's own file, so the help
4
+ // is printed without loading any of them (test/unit/commands.test.mjs holds
5
+ // the two to each other).
6
+ //
7
+ // To add a command: write `src/command/<name>.ts` (or, for a family,
8
+ // `src/command/<name>/index.ts`), whose default export is
9
+ // `defineCommand(...)`, and give it an entry here with its loader:
10
+ //
11
+ // load: () => import("./command/<name>.js"),
12
+ import { title } from "./config/product.js";
13
+ // [declare]
14
+ export const COMMANDS = [
15
+ {
16
+ load: () => import("./command/init.js"),
17
+ name: "init",
18
+ summary: "Initialize a project",
19
+ },
20
+ {
21
+ load: () => import("./command/inspect.js"),
22
+ name: "inspect",
23
+ summary: "Print the resolved manifest",
24
+ },
25
+ {
26
+ load: () => import("./command/validate.js"),
27
+ name: "validate",
28
+ summary: "Check the project for issues",
29
+ },
30
+ {
31
+ load: () => import("./command/build.js"),
32
+ name: "build",
33
+ summary: "Run the project's build",
34
+ },
35
+ {
36
+ load: () => import("./command/pack.js"),
37
+ name: "pack",
38
+ summary: "Pack the game into a zip",
39
+ },
40
+ {
41
+ load: () => import("./command/serve.js"),
42
+ name: "serve",
43
+ summary: "Serve the game locally",
44
+ },
45
+ {
46
+ load: () => import("./command/deploy.js"),
47
+ name: "deploy",
48
+ summary: "Deploy the game",
49
+ },
50
+ {
51
+ load: () => import("./command/open.js"),
52
+ name: "open",
53
+ summary: "Open a game's store page",
54
+ },
55
+ {
56
+ load: () => import("./command/play.js"),
57
+ name: "play",
58
+ summary: "Play a game",
59
+ },
60
+ {
61
+ load: () => import("./command/delete.js"),
62
+ name: "delete",
63
+ summary: "Delete the game",
64
+ },
65
+ {
66
+ load: () => import("./command/login.js"),
67
+ name: "login",
68
+ summary: `Log in to ${title}`,
69
+ },
70
+ {
71
+ load: () => import("./command/whoami.js"),
72
+ name: "whoami",
73
+ summary: "Show the logged-in account",
74
+ },
75
+ {
76
+ load: () => import("./command/logout.js"),
77
+ name: "logout",
78
+ summary: `Log out of ${title}`,
79
+ },
80
+ // left out of `arc --help` until functions and keys ship, with the docs.
81
+ {
82
+ hidden: true,
83
+ load: () => import("./command/function/index.js"),
84
+ name: "function",
85
+ summary: "Pause, resume, and show the game's function, and its secrets",
86
+ },
87
+ {
88
+ hidden: true,
89
+ load: () => import("./command/server/index.js"),
90
+ name: "server",
91
+ summary: "Make, list, and revoke your server's keys",
92
+ },
93
+ ];
@@ -0,0 +1,2 @@
1
+ // [declare]
2
+ export const AI = ["unused", "generative"];
@@ -0,0 +1,13 @@
1
+ // [declare]
2
+ export const ART = [
3
+ "banner.png",
4
+ "banner_video.mp4",
5
+ "cover.png",
6
+ "cover_video.mp4",
7
+ "icon.png",
8
+ "icon_video.mp4",
9
+ "poster.png",
10
+ "poster_video.mp4",
11
+ "splash.png",
12
+ "splash_video.mp4",
13
+ ];
@@ -0,0 +1,2 @@
1
+ // [declare]
2
+ export const AUDIENCE = ["everyone", "mature"];