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
@@ -0,0 +1,308 @@
1
+ // [import]
2
+ import path from "node:path";
3
+ import { ended } from "../account.js";
4
+ import { checked } from "../action/validate/checked.js";
5
+ import { INTERNAL, NOT_LOGGED_IN, WAIT_TIMED_OUT } from "../config/code.js";
6
+ import { defineCommand } from "../cli/command.js";
7
+ import { ArcError } from "../util/error.js";
8
+ import { buildPublishing, buildPublishingGit, buildSubmitted, notLoggedIn, playLabel, releaseFailed, releaseFailedHeading, releasePublished, releaseTimedOut, releaseWaiting, storeLabel, tagPushed, waitTimedOut, } from "../phrase/index.js";
9
+ import { pw, result as logResult } from "../util/log.js";
10
+ import { CWD, JSON_OUTPUT, QUIET } from "../cli/options.js";
11
+ import { abort, print, warn, warning } from "../util/output.js";
12
+ import { FORMAT, ProgressBar } from "../util/progress.js";
13
+ import { rebuilt } from "../action/deploy/rebuilt.js";
14
+ import { releaseJson, resultOf } from "../action/deploy/result.js";
15
+ import { SpinnerWheel } from "../util/spinner.js";
16
+ import { checkTimeout, TIMEOUT } from "../action/deploy/timeout.js";
17
+ import { buildTool } from "../action/build/tool.js";
18
+ import { deployTool, } from "../action/deploy/tool.js";
19
+ import { packTool } from "../action/pack/tool.js";
20
+ import { predeployTool } from "../action/predeploy/tool.js";
21
+ import { whoami } from "../action/whoami/tool.js";
22
+ import { deployToolGit } from "../action/deploy/tool-git.js";
23
+ import { predeployToolGit, } from "../action/predeploy/tool-git.js";
24
+ import { wait } from "../action/deploy/wait.js";
25
+ // [use]
26
+ const resolve = path.resolve;
27
+ // [declare]
28
+ const COMMAND = "deploy";
29
+ const SUBMITTING = `Submitting ${FORMAT}`;
30
+ // [function]
31
+ // `warnings` collects what --json lists, such as a version that couldn't be
32
+ // checked.
33
+ function handler({ json, pb, quiet, sw, warnings, }) {
34
+ return {
35
+ onAccountRefresh(refresh) {
36
+ sw.start(json || quiet);
37
+ return refresh();
38
+ },
39
+ onDeployBegin() {
40
+ if (!json && !quiet && pb) {
41
+ pb.start(0);
42
+ }
43
+ },
44
+ onPredeployBegin() {
45
+ sw.start(json || quiet);
46
+ },
47
+ onUploadProgress(step) {
48
+ if (!json && !quiet) {
49
+ if (pb) {
50
+ pb.increment(step);
51
+ }
52
+ }
53
+ },
54
+ onWarning({ code, message }) {
55
+ warnings.push(warning(code, message));
56
+ if (!json && !quiet) {
57
+ sw.stop(true);
58
+ if (pb) {
59
+ pb.stop();
60
+ }
61
+ pw(message);
62
+ sw.start(false);
63
+ if (pb) {
64
+ pb.start(0);
65
+ }
66
+ }
67
+ },
68
+ };
69
+ }
70
+ // [function]
71
+ // the checks a deploy makes before it builds, by its method. A session the
72
+ // API refuses is ended (`ended`).
73
+ function predeploy({ current, git, handler: handlers, ...conf }) {
74
+ return (git
75
+ ? predeployToolGit(conf, handlers)
76
+ : predeployTool(current, conf, handlers)).catch(ended(current));
77
+ }
78
+ // [function]
79
+ // the deploy itself, by its method: a direct deploy is the one with a
80
+ // package to send. A session the API refuses is ended (`ended`).
81
+ function deploy({ artifact, current, handler: handlers, ...conf }) {
82
+ return (artifact
83
+ ? deployTool(current, artifact, conf, handlers)
84
+ : deployToolGit(conf, handlers)).catch(ended(current));
85
+ }
86
+ // [function]
87
+ // what was deployed, whether workflow.build ran, where it will be once it's
88
+ // published (the store only shows production), and what happens next. Once
89
+ // waited on, it's published, so it says so.
90
+ function report({ built, channel, store, tag, url, version }, { git, published }) {
91
+ let heading = git
92
+ ? tagPushed(String(tag))
93
+ : buildSubmitted(version.to, channel, built);
94
+ let next = git
95
+ ? buildPublishingGit(channel)
96
+ : buildPublishing();
97
+ if (published) {
98
+ heading = releasePublished(version.to, channel, built);
99
+ next = null;
100
+ }
101
+ logResult(heading, [
102
+ store ? [storeLabel(), store] : null,
103
+ [playLabel(), url],
104
+ next,
105
+ ]);
106
+ }
107
+ // [function]
108
+ // waits on the release, then reports it: published, or failed or timed out,
109
+ // which exit 1. `result` is what the deploy prints.
110
+ async function waitAndReport(current, deployed, result, { git, json, quiet, root, since, timeout, }) {
111
+ let sw = new SpinnerWheel(releaseWaiting(git));
112
+ sw.start(json || quiet);
113
+ let building = git;
114
+ let waited;
115
+ try {
116
+ waited = await wait(current, deployed, { git, root, since, timeout }, {
117
+ onRelease() {
118
+ // found: GitHub Actions is done, and Arcadible publishes it now.
119
+ if (building) {
120
+ building = false;
121
+ sw.stop(true);
122
+ sw = new SpinnerWheel(releaseWaiting(false));
123
+ sw.start(json || quiet);
124
+ }
125
+ },
126
+ });
127
+ }
128
+ catch (ex) {
129
+ sw.stop(true);
130
+ throw ex;
131
+ }
132
+ const { actions, studio } = waited;
133
+ const data = { ...result, release: releaseJson(waited.release) };
134
+ if (waited.timedOut) {
135
+ const found = Boolean(waited.release);
136
+ const reason = releaseTimedOut(result.version.to, timeout, {
137
+ actions,
138
+ found,
139
+ git,
140
+ studio,
141
+ });
142
+ await abort(waitTimedOut(), new ArcError(WAIT_TIMED_OUT, reason), {
143
+ data,
144
+ json,
145
+ sw,
146
+ });
147
+ return;
148
+ }
149
+ const release = waited.release;
150
+ if (release.status === "failed") {
151
+ const reason = releaseFailed(release, studio);
152
+ await abort(releaseFailedHeading(), new Error(reason), {
153
+ code: release.reason ?? INTERNAL,
154
+ data,
155
+ json,
156
+ sw,
157
+ });
158
+ return;
159
+ }
160
+ sw.stop(true);
161
+ if (json) {
162
+ print(data);
163
+ }
164
+ else if (!quiet) {
165
+ report(result, { git, published: true });
166
+ }
167
+ }
168
+ // [function]
169
+ // a new spinner, which the error path clears from here on.
170
+ function spinner(aborting, text) {
171
+ const sw = new SpinnerWheel(text);
172
+ aborting.sw = sw;
173
+ return sw;
174
+ }
175
+ // [export]
176
+ export default defineCommand({
177
+ name: COMMAND,
178
+ options: {
179
+ json: JSON_OUTPUT,
180
+ quiet: QUIET,
181
+ wait: {
182
+ alias: "w",
183
+ default: true,
184
+ describe: "Wait until it's published or fails",
185
+ rc: true,
186
+ type: "boolean",
187
+ },
188
+ timeout: {
189
+ defaultDescription: "300, or 900 for git",
190
+ describe: "Seconds to wait",
191
+ rc: true,
192
+ type: "number",
193
+ },
194
+ cwd: CWD,
195
+ },
196
+ positionals: {
197
+ method: {
198
+ choices: ["direct", "git"],
199
+ default: "direct",
200
+ describe: "Deploy method",
201
+ rc: true,
202
+ type: "string",
203
+ },
204
+ },
205
+ async run(argv, aborting) {
206
+ const git = argv.method === "git";
207
+ const json = argv.json;
208
+ const quiet = argv.quiet;
209
+ // `.arcrc` values are strings, and a flag that isn't a number is NaN.
210
+ const timeout = Number(argv.timeout ?? TIMEOUT[git ? "git" : "direct"]);
211
+ const root = resolve(process.cwd(), argv.cwd);
212
+ let pb = null;
213
+ // what --json lists under `warnings`: arc validate's, then the deploy's.
214
+ const warnings = [];
215
+ aborting.data = { warnings };
216
+ let sw = spinner(aborting, "Validating… %s");
217
+ sw.start(json || quiet);
218
+ await checkTimeout(timeout);
219
+ // the project, parsed once and given to each step. A build can write files
220
+ // the manifest reads, such as art, so it's parsed again after one runs.
221
+ let parsed = await checked(root, (found) => {
222
+ warnings.push(...found);
223
+ });
224
+ sw.stop(true);
225
+ warn(warnings, { json, quiet });
226
+ sw = spinner(aborting, "Checking… %s");
227
+ // git deploys need no login, and never use one: anyone who can push to
228
+ // the repository can release, and the Arcadible GitHub App publishes
229
+ // the release. Every call is public, so it's the same for whoever runs
230
+ // it, and the saved session isn't read, or refreshed.
231
+ const current = git
232
+ ? null
233
+ : await whoami({}, handler({ json, pb, quiet, sw, warnings }));
234
+ if (!current && !git) {
235
+ throw new ArcError(NOT_LOGGED_IN, notLoggedIn());
236
+ }
237
+ sw.stop(true);
238
+ sw = spinner(aborting, "Preparing… %s");
239
+ const predeployed = await predeploy({
240
+ current,
241
+ git,
242
+ handler: handler({ json, pb, quiet, sw, warnings }),
243
+ project: parsed,
244
+ root,
245
+ });
246
+ sw.stop(true);
247
+ // whether the handle rules held the handle back from this release, so the
248
+ // game's links are by id.
249
+ const held = predeployed.held ?? false;
250
+ sw = spinner(aborting, "Building… %s");
251
+ sw.start(git || json || quiet);
252
+ const output = git ? null : await buildTool({ project: parsed, root });
253
+ if (output) {
254
+ parsed = await rebuilt(root);
255
+ }
256
+ sw.stop(true);
257
+ sw = spinner(aborting, "Packing… %s");
258
+ sw.start(git || json || quiet);
259
+ const artifact = git
260
+ ? null
261
+ : await packTool({
262
+ input: output?.path,
263
+ onWarning: handler({ json, pb, quiet, sw, warnings }).onWarning,
264
+ project: parsed,
265
+ root,
266
+ });
267
+ // build: whether workflow.build ran
268
+ const built = Boolean(output);
269
+ sw.stop(true);
270
+ if (!json && !quiet && artifact) {
271
+ pb = new ProgressBar(artifact.size, SUBMITTING);
272
+ aborting.pb = pb;
273
+ }
274
+ const deploying = deploy({
275
+ artifact,
276
+ current,
277
+ handler: handler({ json, pb, quiet, sw, warnings }),
278
+ project: parsed,
279
+ root,
280
+ });
281
+ // when the release started, to find a git one by
282
+ const since = Date.now();
283
+ const deployed = await deploying;
284
+ if (pb) {
285
+ pb.stop();
286
+ }
287
+ const result = resultOf(deployed, { built, git, held, warnings });
288
+ sw.stop(true);
289
+ if (argv.wait) {
290
+ await waitAndReport(current, deployed, result, {
291
+ git,
292
+ json,
293
+ quiet,
294
+ root,
295
+ since,
296
+ timeout,
297
+ });
298
+ return;
299
+ }
300
+ if (json) {
301
+ print(result);
302
+ }
303
+ else if (!quiet) {
304
+ report(result, { git });
305
+ }
306
+ },
307
+ summary: "Deploy the game",
308
+ });
@@ -0,0 +1,17 @@
1
+ // arc function: a game's function, the server code Arcadible runs for it:
2
+ // paused and resumed on a channel by the game's owner, with no release, and
3
+ // its secrets (./secret/index.ts). All of it is left out of `arc --help`
4
+ // until functions ship, with the docs.
5
+ // [import]
6
+ import { defineCommand } from "../../cli/command.js";
7
+ import secret from "./secret/index.js";
8
+ import pause from "./pause.js";
9
+ import resume from "./resume.js";
10
+ import status from "./status.js";
11
+ // [export]
12
+ export default defineCommand({
13
+ commands: [pause, resume, status, secret],
14
+ hidden: true,
15
+ name: "function",
16
+ summary: "Pause, resume, and show the game's function, and its secrets",
17
+ });
@@ -0,0 +1,18 @@
1
+ // [import]
2
+ import { defineCommand } from "../../cli/command.js";
3
+ import { functionPaused } from "../../phrase/index.js";
4
+ import { p } from "../../util/log.js";
5
+ import { CHANNEL, CWD, JSON_OUTPUT, QUIET } from "../../cli/options.js";
6
+ import { run } from "./run.js";
7
+ import { pause } from "../../action/function/tool.js";
8
+ // [export]
9
+ export default defineCommand({
10
+ name: "pause",
11
+ options: { ...CHANNEL, json: JSON_OUTPUT, quiet: QUIET, cwd: CWD },
12
+ run(argv, aborting) {
13
+ return run(argv, aborting, pause, (paused) => {
14
+ p(functionPaused(paused));
15
+ }, "arc function pause");
16
+ },
17
+ summary: "Pause the game's function on a channel",
18
+ });
@@ -0,0 +1,18 @@
1
+ // [import]
2
+ import { defineCommand } from "../../cli/command.js";
3
+ import { functionResumed } from "../../phrase/index.js";
4
+ import { p } from "../../util/log.js";
5
+ import { CHANNEL, CWD, JSON_OUTPUT, QUIET } from "../../cli/options.js";
6
+ import { run } from "./run.js";
7
+ import { resume } from "../../action/function/tool.js";
8
+ // [export]
9
+ export default defineCommand({
10
+ name: "resume",
11
+ options: { ...CHANNEL, json: JSON_OUTPUT, quiet: QUIET, cwd: CWD },
12
+ run(argv, aborting) {
13
+ return run(argv, aborting, resume, (resumed) => {
14
+ p(functionResumed(resumed));
15
+ }, "arc function resume");
16
+ },
17
+ summary: "Resume the game's function on a channel",
18
+ });
@@ -0,0 +1,41 @@
1
+ // what `arc function`'s own commands share: running one as the logged-in
2
+ // account.
3
+ // [import]
4
+ import { resolve as resolvePath } from "node:path";
5
+ // [import]
6
+ import { ended } from "../../account.js";
7
+ import { of } from "../../cli/channel.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
+ // runs one command as the logged-in account, and prints what `shown` makes
13
+ // of its result. `usage` is the command as it's typed, for one that changes
14
+ // something, which then needs a channel. A session that was refused is
15
+ // refreshed, so the failure says to log in again.
16
+ export async function run(argv, aborting, command, shown, usage = null) {
17
+ const json = argv.json;
18
+ const quiet = argv.quiet;
19
+ const sw = new SpinnerWheel("Checking… %s");
20
+ aborting.sw = sw;
21
+ const handler = {
22
+ onAccountRefresh(refresh) {
23
+ sw.start(json || quiet);
24
+ return refresh();
25
+ },
26
+ };
27
+ // the channel first, so a command given none says so before anything else
28
+ const where = of(argv, usage);
29
+ const current = await whoami({}, handler);
30
+ sw.stop(true);
31
+ const result = await command(current, {
32
+ channel: where,
33
+ root: resolvePath(process.cwd(), argv.cwd),
34
+ }).catch(ended(current));
35
+ if (json) {
36
+ print(result);
37
+ }
38
+ else if (!quiet) {
39
+ shown(result);
40
+ }
41
+ }
@@ -0,0 +1,15 @@
1
+ // arc function secret: a function's secrets, the values a game's function
2
+ // needs and its repository mustn't hold. `set` takes the value from standard
3
+ // input, or asks for it at a terminal, so it's never an argument, in a
4
+ // shell's history or a process list.
5
+ // [import]
6
+ import { defineCommand } from "../../../cli/command.js";
7
+ import list from "./list.js";
8
+ import remove from "./remove.js";
9
+ import set from "./set.js";
10
+ // [export]
11
+ export default defineCommand({
12
+ commands: [set, list, remove],
13
+ name: "secret",
14
+ summary: "Set, list, and remove the function's secrets",
15
+ });
@@ -0,0 +1,27 @@
1
+ // [import]
2
+ import { defineCommand } from "../../../cli/command.js";
3
+ import { secretNone } 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/secret/tool.js";
9
+ // [function]
10
+ // the secrets as a table, a row each.
11
+ function rows(secrets) {
12
+ return table([
13
+ ["NAME", "CHANNEL", "SET"],
14
+ ...secrets.map((each) => [each.name, each.channel, day(each.updated_at)]),
15
+ ]);
16
+ }
17
+ // [export]
18
+ export default defineCommand({
19
+ name: "list",
20
+ options: { ...CHANNEL_SHOWS, json: JSON_OUTPUT, quiet: QUIET, cwd: CWD },
21
+ run(argv, aborting) {
22
+ return run(argv, aborting, list, (secrets) => {
23
+ p(secrets.length ? rows(secrets) : secretNone());
24
+ });
25
+ },
26
+ summary: "List the game's secrets, never their values",
27
+ });
@@ -0,0 +1,8 @@
1
+ // [import]
2
+ // [declare]
3
+ // `<name>`, of the commands that take one secret.
4
+ export const NAME = {
5
+ describe: "The secret's name, as the manifest declares it",
6
+ required: true,
7
+ type: "string",
8
+ };
@@ -0,0 +1,26 @@
1
+ // [import]
2
+ import { defineCommand } from "../../../cli/command.js";
3
+ import { secretRemoved, secretRemoveQuestion } from "../../../phrase/index.js";
4
+ import { p } from "../../../util/log.js";
5
+ import { NAME } from "./name.js";
6
+ import { CHANNEL, CWD, JSON_OUTPUT, QUIET, YES } from "../../../cli/options.js";
7
+ import { run } from "./run.js";
8
+ import { remove } from "../../../action/secret/tool.js";
9
+ // [export]
10
+ export default defineCommand({
11
+ name: "remove",
12
+ options: { ...CHANNEL, json: JSON_OUTPUT, quiet: QUIET, cwd: CWD, yes: YES },
13
+ positionals: { name: NAME },
14
+ run(argv, aborting) {
15
+ return run(argv, aborting, (current, conf) => remove(current, { ...conf, name: argv.name }), (gone) => {
16
+ p(secretRemoved(gone));
17
+ }, `arc function secret remove ${argv.name}`, (where) => ({
18
+ question: secretRemoveQuestion({
19
+ channel: String(where),
20
+ name: argv.name,
21
+ }),
22
+ usage: `arc function secret remove ${argv.name} --${where}`,
23
+ }));
24
+ },
25
+ summary: "Remove a secret",
26
+ });
@@ -0,0 +1,52 @@
1
+ // what `arc function secret`'s commands share: running one as the logged-in
2
+ // account.
3
+ // [import]
4
+ import { resolve as resolvePath } 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. `usage` is the command as it's typed, for one that changes
17
+ // something, which then needs a channel. `question(channel)` is asked first,
18
+ // for one that can't be undone (src/cli/confirm.ts). A session that was
19
+ // refused is refreshed, so the failure says to log in again.
20
+ export async function run(argv, aborting, command, shown, usage = null, question = null) {
21
+ const json = argv.json;
22
+ const quiet = argv.quiet;
23
+ const sw = new SpinnerWheel("Checking… %s");
24
+ aborting.sw = sw;
25
+ const handler = {
26
+ onAccountRefresh(refresh) {
27
+ sw.start(json || quiet);
28
+ return refresh();
29
+ },
30
+ };
31
+ // the channel first, so a command given none says so before anything else
32
+ const where = of(argv, usage);
33
+ if (question && !(await sure(argv, question(where)))) {
34
+ // a no at the prompt changes nothing, and isn't a failure
35
+ if (!quiet) {
36
+ p(confirmDeclined());
37
+ }
38
+ return;
39
+ }
40
+ const current = await whoami({}, handler);
41
+ sw.stop(true);
42
+ const result = await command(current, {
43
+ channel: where,
44
+ root: resolvePath(process.cwd(), argv.cwd),
45
+ }).catch(ended(current));
46
+ if (json) {
47
+ print(result);
48
+ }
49
+ else if (!quiet) {
50
+ shown(result);
51
+ }
52
+ }
@@ -0,0 +1,48 @@
1
+ // [import]
2
+ import { password } from "@inquirer/prompts";
3
+ // [import]
4
+ import { defineCommand } from "../../../cli/command.js";
5
+ import { secretPrompt, secretSet } from "../../../phrase/index.js";
6
+ import { p } from "../../../util/log.js";
7
+ import { NAME } from "./name.js";
8
+ import { CHANNEL, CWD, JSON_OUTPUT, QUIET } from "../../../cli/options.js";
9
+ import { run } from "./run.js";
10
+ import { set } from "../../../action/secret/tool.js";
11
+ // [function]
12
+ // a secret's value: typed at a terminal, unseen, or all of standard input,
13
+ // without the line end a shell's `echo` adds. With `--json` there's no one
14
+ // to ask (src/cli/confirm.ts), so at a terminal it's no value, which fails
15
+ // as an empty standard input does.
16
+ function valueOf(name, json) {
17
+ if (process.stdin.isTTY) {
18
+ return json
19
+ ? Promise.resolve("")
20
+ : password({ mask: true, message: secretPrompt(name) });
21
+ }
22
+ return new Promise((resolve, reject) => {
23
+ const chunks = [];
24
+ process.stdin.on("data", (chunk) => chunks.push(chunk));
25
+ process.stdin.on("error", reject);
26
+ process.stdin.on("end", () => {
27
+ resolve(Buffer.concat(chunks)
28
+ .toString("utf8")
29
+ .replace(/\r?\n$/u, ""));
30
+ });
31
+ });
32
+ }
33
+ // [export]
34
+ export default defineCommand({
35
+ name: "set",
36
+ options: { ...CHANNEL, json: JSON_OUTPUT, quiet: QUIET, cwd: CWD },
37
+ positionals: { name: NAME },
38
+ run(argv, aborting) {
39
+ return run(argv, aborting, (current, conf) => set(current, {
40
+ ...conf,
41
+ name: argv.name,
42
+ value: () => valueOf(argv.name, argv.json),
43
+ }), (kept) => {
44
+ p(secretSet(kept));
45
+ }, `arc function secret set ${argv.name}`);
46
+ },
47
+ summary: "Set a secret, its value from standard input",
48
+ });
@@ -0,0 +1,40 @@
1
+ // [import]
2
+ import { defineCommand } from "../../cli/command.js";
3
+ import { functionMonth, functionState } 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 { table } from "../../util/table.js";
8
+ import { status } from "../../action/function/tool.js";
9
+ // [function]
10
+ // a count as it's read: 1,000,000.
11
+ function count(value) {
12
+ return value.toLocaleString("en-US");
13
+ }
14
+ // [function]
15
+ // each channel's function as a table, a row each.
16
+ function rows(channels) {
17
+ return table([
18
+ ["CHANNEL", "STATUS", "REQUESTS"],
19
+ ...channels.map((each) => [
20
+ each.channel,
21
+ functionState(each),
22
+ count(each.requests),
23
+ ]),
24
+ ]);
25
+ }
26
+ // [export]
27
+ export default defineCommand({
28
+ name: "status",
29
+ options: { ...CHANNEL_SHOWS, json: JSON_OUTPUT, quiet: QUIET, cwd: CWD },
30
+ run(argv, aborting) {
31
+ return run(argv, aborting, status, ({ channels, month }) => {
32
+ p(rows(channels));
33
+ p(functionMonth({
34
+ allowance: month.allowance === null ? null : count(month.allowance),
35
+ requests: count(month.requests),
36
+ }));
37
+ });
38
+ },
39
+ summary: "Show whether the game's function is running, and its usage this month",
40
+ });