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
@@ -1,154 +0,0 @@
1
- "use strict";
2
-
3
- // [import]
4
-
5
- const api = require("../../api");
6
- const cfgcode = require("../../config/code");
7
- const error = require("../../util/error");
8
- const git = require("./git");
9
- const given = require("../../parser/given");
10
- const links = require("../../util/links");
11
- const phrase = require("../../phrase");
12
- const pm = require("./pm");
13
- const published = require("./published");
14
-
15
- // [use]
16
-
17
- const ArcError = error.ArcError;
18
- const ensureClean = git.ensureClean;
19
- const ensureLockFile = pm.ensureLockFile;
20
- const ensureRemote = git.ensureRemote;
21
- const ensureRepo = git.ensureRepo;
22
- const ensureRoot = git.ensureRoot;
23
- const ensureTagFree = git.ensureTagFree;
24
- const ensureWorkflow = git.ensureWorkflow;
25
- const originRepo = git.originRepo;
26
- const studioUrl = links.studioUrl;
27
-
28
- // [function]
29
-
30
- // a public lookup's answer: found (200, with its data), missing (404), or
31
- // null for any other answer, such as when the API can't be reached.
32
- const answerOf = function (request) {
33
- return request.then(
34
- (data) => ({ data, status: 200 }),
35
- (err) => (err.status === 404 ? { status: 404 } : null),
36
- );
37
- };
38
-
39
- // [function]
40
-
41
- // what Arcadible would refuse in the release, refused before the tag is pushed: a
42
- // game that was never deployed (a release can't create one), a version
43
- // that's already published, and a handle that isn't the game's (only a
44
- // direct deploy changes one, so a collaborator's push can't). The lookups
45
- // are public, so this needs no login.
46
- // when Arcadible can't be reached, it warns and pushes anyway: a release
47
- // shouldn't depend on the API, and Arcadible still checks.
48
- const ensurePublishable = function ({ handle, id, version }, handler) {
49
- return Promise.all([
50
- answerOf(api.discoverGame(id)),
51
- answerOf(api.discoverGameBuild(id, version)),
52
- ]).then(([game, build]) => {
53
- if (game?.status === 404) {
54
- throw new ArcError(
55
- cfgcode.GAME_NOT_DEPLOYED,
56
- phrase.gameNotDeployed(handle ?? id),
57
- );
58
- }
59
- if (game === null || build === null) {
60
- if (handler.onWarning) {
61
- handler.onWarning({
62
- code: cfgcode.WARNING.VERSION_UNCHECKED,
63
- message: phrase.versionUnchecked(version),
64
- });
65
- }
66
- return null;
67
- }
68
- if (build.status === 200) {
69
- return published.refuse(id, version);
70
- }
71
- const current = game.data?.handle ?? null;
72
- if ((handle ?? null) !== current) {
73
- throw new ArcError(
74
- cfgcode.GAME_HANDLE_CHANGED,
75
- phrase.gameHandleChanged(handle, current),
76
- );
77
- }
78
- return null;
79
- });
80
- };
81
-
82
- // [function]
83
-
84
- // the project's checks: a lockfile when there's a package.json, and a clean
85
- // repository, whose root is the project, with the release workflow and a
86
- // reachable origin.
87
- const ensureProject = function (root) {
88
- return ensureLockFile(root)
89
- .then(() => ensureRepo(root))
90
- .then(() => ensureRoot(root))
91
- .then(() => ensureClean(root))
92
- .then(() => ensureWorkflow(root))
93
- .then(() => ensureRemote(root));
94
- };
95
-
96
- // [function]
97
-
98
- // fails when origin isn't the game's connected repository, which Arcadible
99
- // would refuse (repo_not_connected) once GitHub Actions had built it. It's
100
- // asked by name, which needs no login, so it checks whoever pushes. Skipped
101
- // when origin is a path on this machine, or Arcadible can't be reached.
102
- const ensureConnected = function (root, { handle, id }) {
103
- let repo = null;
104
- return originRepo(root)
105
- .then((found) => {
106
- repo = found;
107
- return repo
108
- ? answerOf(api.discoverGameRepo(id, repo.owner, repo.name))
109
- : null;
110
- })
111
- .then((connected) => {
112
- if (connected?.status === 404) {
113
- throw new ArcError(
114
- cfgcode.REPO_NOT_CONNECTED,
115
- phrase.repoNotConnected(
116
- handle ?? id,
117
- `${repo.owner}/${repo.name}`,
118
- studioUrl(id, "repository"),
119
- ),
120
- );
121
- }
122
- });
123
- };
124
-
125
- // [function]
126
-
127
- // the release's checks: its tag is free, Arcadible would publish it, and
128
- // origin is its connected repository. resolves with the version.
129
- const ensureRelease = function (root, game, handler) {
130
- return ensureTagFree(root, game.version)
131
- .then(() => ensurePublishable(game, handler))
132
- .then(() => ensureConnected(root, game))
133
- .then(() => ({ to: game.version }));
134
- };
135
-
136
- // [function]
137
-
138
- // a git deploy needs no login, and never uses one: anyone who can push can
139
- // release, and so can tools other than arc. Every lookup is public, so its
140
- // answer is the same whoever runs it, and true when it's asked; the release
141
- // pipeline has the final word.
142
- const main = function (conf, { onPredeployBegin, ...handler }) {
143
- const root = conf.root;
144
- if (onPredeployBegin) {
145
- onPredeployBegin();
146
- }
147
- return given(conf)
148
- .then(({ game }) => Promise.all([game, ensureProject(root)]))
149
- .then(([game]) => ensureRelease(root, game, handler));
150
- };
151
-
152
- // [export]
153
-
154
- module.exports = main;
@@ -1,29 +0,0 @@
1
- "use strict";
2
-
3
- // [import]
4
-
5
- const ac = require("./ac");
6
- const given = require("../../parser/given");
7
-
8
- // [use]
9
-
10
- const ensureId = ac.ensureId;
11
- const ensureUnpublished = ac.ensureUnpublished;
12
-
13
- // [function]
14
-
15
- // a direct deploy needs a login. Each lookup uses its token or not, as it
16
- // needs, and its answer is true when it's asked.
17
- const main = function (current, conf, { onPredeployBegin, ...handler }) {
18
- if (onPredeployBegin) {
19
- onPredeployBegin({ root: conf.root });
20
- }
21
- return given(conf)
22
- .then(({ game }) => ensureId(current, game, handler))
23
- .then((game) => ensureUnpublished(current, game))
24
- .then((game) => ({ held: game.held, to: game.version }));
25
- };
26
-
27
- // [export]
28
-
29
- module.exports = main;
@@ -1,209 +0,0 @@
1
- "use strict";
2
- // arc serve: builds the project unless told not to, then serves deploy_dir
3
- // framed in a local play page (src/serve), reloading the game when deploy_dir
4
- // changes.
5
-
6
- // [import]
7
-
8
- const path = require("node:path");
9
- const timers = require("node:timers/promises");
10
-
11
- // [import]
12
-
13
- const fs = require("fs-extra");
14
-
15
- // [import]
16
-
17
- const buildTool = require("../build/tool");
18
- const cfgcode = require("../../config/code");
19
- const cfgproduct = require("../../config/product");
20
- const cfguri = require("../../config/uri");
21
- const commands = require("../../util/command");
22
- const error = require("../../util/error");
23
- const files = require("../../serve/files");
24
- const given = require("../../parser/given");
25
- const media = require("../../parser/media");
26
- const os = require("../../util/os");
27
- const phrase = require("../../phrase");
28
- const reload = require("../../serve/reload");
29
- const remote = require("../../serve/remote");
30
- const server = require("../../serve/server");
31
-
32
- // [use]
33
-
34
- const ArcError = error.ArcError;
35
- const buildCommand = commands.buildCommand;
36
- const configDir = os.configDir;
37
- const dirFiles = files.dirFiles;
38
- const join = path.join;
39
- const pathExists = fs.pathExists;
40
- const readFile = fs.promises.readFile;
41
- const relative = path.relative;
42
- const remoteFiles = remote.remoteFiles;
43
- const resolvePath = path.resolve;
44
- const serve = server.serve;
45
- const sleep = timers.setTimeout;
46
- const watchDir = reload.watchDir;
47
-
48
- // [declare]
49
-
50
- // what build.channel says while served locally (docs: arc-serve.md).
51
- const CHANNEL = "local";
52
- // the saves of a game with no id yet, kept apart from any other's.
53
- const UNNAMED = "local";
54
-
55
- // [declare]
56
-
57
- // the headers a page needs for the play page to frame it: the play page is
58
- // cross-origin isolated, so a cross-origin frame must be too, and allow it.
59
- const FRAMEABLE = {
60
- "cross-origin-embedder-policy": ["credentialless", "require-corp"],
61
- "cross-origin-resource-policy": ["cross-origin"],
62
- };
63
-
64
- // [declare]
65
-
66
- // how long `url` has to answer before it counts as unreachable: a server
67
- // that takes the connection and never answers would otherwise hold `arc
68
- // serve` for minutes.
69
- const PROBE_MS = 10000;
70
-
71
- // [function]
72
-
73
- // what `url` says when asked: `{ reachable, frameable }`, where `frameable`
74
- // says whether it sends the headers the play page needs to frame it.
75
- const probe = async function (url) {
76
- try {
77
- // null when it hasn't answered in time
78
- const res = await Promise.race([
79
- fetch(url, { method: "GET" }),
80
- sleep(PROBE_MS, null, { ref: false }),
81
- ]);
82
- if (!res) {
83
- return { frameable: false, reachable: false };
84
- }
85
- await res.body?.cancel();
86
- const frameable = Object.entries(FRAMEABLE).every(([name, values]) =>
87
- values.includes(res.headers.get(name)?.trim().toLowerCase()),
88
- );
89
- return { frameable, reachable: true };
90
- } catch {
91
- return { frameable: false, reachable: false };
92
- }
93
- };
94
-
95
- // [function]
96
-
97
- // the project's store icon, .arcadible/icon.png, or null: found by its exact
98
- // name, as `arc deploy` finds it, each time it's asked for.
99
- const storeIcon = function (root) {
100
- return async () => {
101
- const { game } = await media(root);
102
- return game.icon ? readFile(join(root, game.icon)) : null;
103
- };
104
- };
105
-
106
- // [function]
107
-
108
- // the loading screen's art: the project's splash, else its banner, else its
109
- // cover, as the play page picks it, or null; each time it's asked for.
110
- const storeArt = function (root) {
111
- return async () => {
112
- const { game } = await media(root);
113
- const file = game.splash ?? game.banner ?? game.cover;
114
- return file ? readFile(join(root, file)) : null;
115
- };
116
- };
117
-
118
- // [function]
119
-
120
- // listens, turning a port in use into its code.
121
- const listen = async function (options) {
122
- try {
123
- return await serve(options);
124
- } catch (ex) {
125
- if (ex.code === "EADDRINUSE") {
126
- throw new ArcError(cfgcode.PORT_IN_USE, phrase.portInUse(options.port), {
127
- cause: ex,
128
- });
129
- }
130
- throw ex;
131
- }
132
- };
133
-
134
- // [function]
135
-
136
- // serves the project at `conf.root`. `conf.build` false skips the build, and
137
- // `conf.url` frames that server's page instead of serving deploy_dir.
138
- // `conf.handler` hears `onBuild()` as a build starts, `onRemote(name, file,
139
- // error)` for each of Arcadible's files, and `onReload()` for each reload.
140
- // resolves with `{ page, game, built, deployDir, url, probed, version,
141
- // close() }`, where `probed` is what `conf.url` answered.
142
- const main = async function (conf) {
143
- const { port, root, url } = conf;
144
- const handler = {
145
- onBuild() {},
146
- onReload() {},
147
- onRemote() {},
148
- ...conf.handler,
149
- };
150
- const project = await given(conf);
151
- const game = project.game;
152
- const options = {
153
- art: storeArt(root),
154
- icon: storeIcon(root),
155
- info: {
156
- channel: CHANNEL,
157
- id: game.id ?? UNNAMED,
158
- title: game.title ?? game.handle ?? cfgproduct.title,
159
- version: game.version ?? null,
160
- },
161
- onRemote: handler.onRemote,
162
- port,
163
- remote: remoteFiles({
164
- dir: join(configDir(), cfgproduct.tool, "sdk"),
165
- host: cfguri.HOST_HTTP_PLAY,
166
- sdk: cfguri.ARCADIBLE_SDK,
167
- }),
168
- };
169
- const version = game.version ?? null;
170
- if (url) {
171
- const served = await listen({ ...options, src: url });
172
- const probed = await probe(url);
173
- return { ...served, built: false, deployDir: null, probed, url, version };
174
- }
175
- const built =
176
- conf.build !== false && Boolean(buildCommand(project.workflow.build));
177
- if (built) {
178
- handler.onBuild();
179
- await buildTool({ project, root });
180
- }
181
- const deployDir = resolvePath(root, project.workflow.deploy_dir);
182
- if (!(await pathExists(deployDir))) {
183
- throw new ArcError(
184
- cfgcode.DEPLOY_DIR_MISSING,
185
- phrase.deployDirMissing(relative(root, deployDir) || "."),
186
- );
187
- }
188
- const served = await listen({ ...options, files: dirFiles(deployDir) });
189
- const stop = watchDir(deployDir, () => {
190
- served.reload();
191
- handler.onReload();
192
- });
193
- return {
194
- ...served,
195
- built,
196
- close() {
197
- stop();
198
- served.close();
199
- },
200
- deployDir,
201
- probed: null,
202
- url: null,
203
- version,
204
- };
205
- };
206
-
207
- // [export]
208
-
209
- module.exports = main;
@@ -1,37 +0,0 @@
1
- "use strict";
2
-
3
- // [import]
4
-
5
- const cfgcode = require("../../config/code");
6
- const error = require("../../util/error");
7
- const phrase = require("../../phrase");
8
- const project = require("../../parser/project");
9
- const validateTool = require("./tool");
10
-
11
- // [use]
12
-
13
- const ArcError = error.ArcError;
14
-
15
- // [function]
16
-
17
- // parses and validates the project at `root` for a command that goes on from
18
- // it (arc build, arc pack, arc deploy): resolves with the parsed project, or
19
- // rejects as validation_failed with its issues in `data`. `onWarnings` gets
20
- // the warnings either way, for --json to list beside the result or the error.
21
- const checked = async function (root, onWarnings) {
22
- const parsed = await project(root);
23
- const { issues, warnings } = await validateTool({ project: parsed, root });
24
- onWarnings(warnings);
25
- if (issues.length) {
26
- throw new ArcError(
27
- cfgcode.VALIDATION_FAILED,
28
- phrase.issuesFound(issues.length),
29
- { data: { issues } },
30
- );
31
- }
32
- return parsed;
33
- };
34
-
35
- // [export]
36
-
37
- module.exports = checked;
@@ -1,67 +0,0 @@
1
- "use strict";
2
-
3
- // [import]
4
-
5
- const game = require("../../schema/game");
6
- const given = require("../../parser/given");
7
- const readme = require("../../schema/readme");
8
- const readmeFile = require("../../parser/readme-file");
9
- const schema = require("../../util/schema");
10
- const sections = require("../../parser/sections");
11
- const unknown = require("./unknown");
12
- const unsound = require("./unsound");
13
- const workflow = require("../../schema/workflow");
14
-
15
- // [use]
16
-
17
- const validator = schema.validator;
18
-
19
- // [define]
20
-
21
- const gameValidator = validator("game", game);
22
- const readmeValidator = validator("game", readme);
23
- const workflowValidator = validator("workflow", workflow);
24
-
25
- // [function]
26
-
27
- // the README's structure, for its validator, or null without a README.
28
- const structure = function (root) {
29
- return readmeFile.read(root).then((file) => {
30
- if (!file) {
31
- return null;
32
- }
33
- const { rules, trailing } = sections.split(file.doc);
34
- return { file: file.file, rules, trailing };
35
- });
36
- };
37
-
38
- // [function]
39
-
40
- const validate = function (proj, readmeStructure, { root }) {
41
- const results = [
42
- gameValidator(proj.game, { root }),
43
- workflowValidator(proj.workflow, { root }),
44
- ];
45
- if (readmeStructure) {
46
- const { file, ...value } = readmeStructure;
47
- results.push(readmeValidator(value, { file }));
48
- }
49
- return results.flatMap((result) => result.issues).sort(schema.compare);
50
- };
51
-
52
- // [function]
53
-
54
- // the project's issues, which fail it, and its warnings, which don't.
55
- const main = function (conf) {
56
- const root = conf.root;
57
- return Promise.all([given(conf), structure(root), unknown(root)]).then(
58
- ([proj, readmeStructure, warnings]) => ({
59
- issues: validate(proj, readmeStructure, { root }),
60
- warnings: [...warnings, ...unsound(proj)].sort(schema.compare),
61
- }),
62
- );
63
- };
64
-
65
- // [export]
66
-
67
- module.exports = main;
@@ -1,86 +0,0 @@
1
- "use strict";
2
-
3
- // [import]
4
-
5
- const cfgcode = require("../../config/code");
6
- const game = require("../../schema/game");
7
- const manifest = require("../../parser/manifest");
8
- const objs = require("../../util/objs");
9
- const phrase = require("../../phrase");
10
- const strs = require("../../util/strs");
11
- const workflow = require("../../schema/workflow");
12
-
13
- // [use]
14
-
15
- const closest = strs.closest;
16
- const isTable = objs.isTable;
17
- const WARNING = cfgcode.WARNING;
18
-
19
- // [function]
20
-
21
- // the fields each table takes, from its schema.
22
- const known = function (root) {
23
- return {
24
- game: Object.keys(game({}, { root }).shape),
25
- workflow: Object.keys(workflow({}, { root }).shape),
26
- };
27
- };
28
-
29
- // [function]
30
-
31
- // a warning, in an issue's shape: Arcadible ignores what it doesn't know, so
32
- // it's reported without failing, with the name it might have meant.
33
- const warning = function (path, message, near) {
34
- return {
35
- code: WARNING.FIELD_UNKNOWN,
36
- details: near ? [phrase.didYouMean(near)] : [],
37
- link: null,
38
- message,
39
- path,
40
- };
41
- };
42
-
43
- // [function]
44
-
45
- // a value outside any table, such as a `handle` above `[game]`: the field
46
- // it is, in the table that takes it, if any.
47
- const untabled = function (fields, name) {
48
- const table = Object.keys(fields).find((each) => fields[each].includes(name));
49
- return warning(
50
- name,
51
- phrase.unknownField(),
52
- table ? `${table}.${name}` : null,
53
- );
54
- };
55
-
56
- // [function]
57
-
58
- // the tables and fields in arcadible.toml that Arcadible doesn't know, such
59
- // as a misspelled `genre`, as warnings.
60
- const main = function (root) {
61
- const fields = known(root);
62
- const tables = Object.keys(fields);
63
- return manifest(root).then((conf) =>
64
- Object.entries(conf).flatMap(([table, values]) => {
65
- if (!isTable(values)) {
66
- return Object.hasOwn(fields, table) ? [] : [untabled(fields, table)];
67
- }
68
- if (!Object.hasOwn(fields, table)) {
69
- return [warning(table, phrase.unknownTable(), closest(table, tables))];
70
- }
71
- return Object.keys(values)
72
- .filter((field) => !fields[table].includes(field))
73
- .map((field) =>
74
- warning(
75
- `${table}.${field}`,
76
- phrase.unknownField(),
77
- closest(field, fields[table]),
78
- ),
79
- );
80
- }),
81
- );
82
- };
83
-
84
- // [export]
85
-
86
- module.exports = main;