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
package/bin/arc-deploy.js DELETED
@@ -1,456 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
-
4
- // [import]
5
-
6
- const path = require("node:path");
7
-
8
- // [import]
9
-
10
- const hideBin = require("yargs/helpers").hideBin;
11
- const yargs = require("yargs/yargs");
12
-
13
- // [import]
14
-
15
- const args = require("../src/util/argv");
16
- const build = require("../src/cli/build");
17
- const cfgcode = require("../src/config/code");
18
- const cfgpackage = require("../src/config/package");
19
- const cfgproduct = require("../src/config/product");
20
- const checked = require("../src/action/validate/checked");
21
- const deploy = require("../src/cli/deploy");
22
- const error = require("../src/util/error");
23
- const links = require("../src/util/links");
24
- const log = require("../src/util/log");
25
- const output = require("../src/util/output");
26
- const pack = require("../src/cli/pack");
27
- const phrase = require("../src/phrase");
28
- const predeploy = require("../src/cli/predeploy");
29
- const progress = require("../src/util/progress");
30
- const project = require("../src/parser/project");
31
- const rc = require("../src/util/rc");
32
- const spinner = require("../src/util/spinner");
33
- const validate = require("../src/cli/validate");
34
- const wait = require("../src/action/deploy/wait");
35
- const whoami = require("../src/cli/whoami");
36
-
37
- // [use]
38
-
39
- const abort = output.abort;
40
- const ArcError = error.ArcError;
41
- const findRc = rc.findRc;
42
- const print = output.print;
43
- const ProgressBar = progress.ProgressBar;
44
- const resolve = path.resolve;
45
- const SpinnerWheel = spinner.SpinnerWheel;
46
- const warn = output.warn;
47
- const warning = output.warning;
48
-
49
- // [declare]
50
-
51
- const COMMAND = "deploy";
52
- const TOOL = cfgproduct.tool;
53
- const SUBMITTING = `Submitting ${progress.FORMAT}`;
54
- const VERSION = cfgpackage.version;
55
- // how long `--wait` waits, in seconds. A git release waits on its GitHub
56
- // workflow first.
57
- const TIMEOUT = { direct: 300, git: 900 };
58
-
59
- // [define]
60
-
61
- const conf = {
62
- json: false,
63
- method: "direct",
64
- quiet: false,
65
- wait: true,
66
- ...findRc(TOOL, COMMAND, process.argv),
67
- };
68
-
69
- // [function]
70
-
71
- // `warnings` collects what --json lists, such as a version that couldn't be
72
- // checked.
73
- const handler = function ({ json, pb, quiet, sw, warnings }) {
74
- return {
75
- onAccountRefresh(refresh) {
76
- sw.start(json || quiet);
77
- return refresh();
78
- },
79
- onDeployBegin() {
80
- if (!json && !quiet && pb) {
81
- pb.start();
82
- }
83
- },
84
- onPredeployBegin() {
85
- sw.start(json || quiet);
86
- },
87
- onUploadProgress(step) {
88
- if (!json && !quiet) {
89
- if (pb) {
90
- pb.increment(step);
91
- }
92
- }
93
- },
94
- onWarning({ code, message }) {
95
- warnings.push(warning(code, message));
96
- if (!json && !quiet) {
97
- sw.stop(true);
98
- if (pb) {
99
- pb.stop();
100
- }
101
- log.pw(message);
102
- sw.start(false);
103
- if (pb) {
104
- pb.start();
105
- }
106
- }
107
- },
108
- };
109
- };
110
-
111
- // [function]
112
-
113
- // what was deployed, whether workflow.build ran, where it will be once it's
114
- // published (the store only shows production), and what happens next. Once
115
- // waited on, it's published, so it says so.
116
- const report = function (
117
- { built, channel, store, tag, url, version },
118
- { git, published },
119
- ) {
120
- let heading = git
121
- ? phrase.tagPushed(tag)
122
- : phrase.buildSubmitted(version.to, channel, built);
123
- let next = git
124
- ? phrase.buildPublishingGit(channel)
125
- : phrase.buildPublishing();
126
- if (published) {
127
- heading = phrase.releasePublished(version.to, channel, built);
128
- next = null;
129
- }
130
- log.result(heading, [
131
- store ? [phrase.storeLabel(), store] : null,
132
- [phrase.playLabel(), url],
133
- next,
134
- ]);
135
- };
136
-
137
- // [function]
138
-
139
- // the release, as `--json` prints it.
140
- const releaseJson = function (row) {
141
- if (!row) {
142
- return null;
143
- }
144
- return {
145
- build: row.build,
146
- channel: row.channel,
147
- id: row.id,
148
- message: row.message,
149
- reason: row.reason,
150
- status: row.status,
151
- version: row.version,
152
- };
153
- };
154
-
155
- // [function]
156
-
157
- // waits on the release, then reports it: published, or failed or timed out,
158
- // which exit 1. `result` is what the deploy prints.
159
- const waitAndReport = async function (
160
- current,
161
- deployed,
162
- result,
163
- { git, json, quiet, root, since, timeout },
164
- ) {
165
- let sw = new SpinnerWheel(phrase.releaseWaiting(git));
166
- sw.start(json || quiet);
167
- let building = git;
168
- let waited = null;
169
- try {
170
- waited = await wait(
171
- current,
172
- deployed,
173
- { git, root, since, timeout },
174
- {
175
- onRelease() {
176
- // found: GitHub Actions is done, and Arcadible publishes it now.
177
- if (building) {
178
- building = false;
179
- sw.stop(true);
180
- sw = new SpinnerWheel(phrase.releaseWaiting(false));
181
- sw.start(json || quiet);
182
- }
183
- },
184
- },
185
- );
186
- } catch (ex) {
187
- sw.stop(true);
188
- throw ex;
189
- }
190
- const { actions, release, studio, timedOut } = waited;
191
- const data = { ...result, release: releaseJson(release) };
192
- if (timedOut) {
193
- const found = Boolean(release);
194
- const reason = phrase.releaseTimedOut(result.version.to, timeout, {
195
- actions,
196
- found,
197
- git,
198
- studio,
199
- });
200
- abort(phrase.waitTimedOut(), new ArcError(cfgcode.WAIT_TIMED_OUT, reason), {
201
- data,
202
- json,
203
- sw,
204
- });
205
- return;
206
- }
207
- if (release.status === "failed") {
208
- const reason = phrase.releaseFailed(release, studio);
209
- abort(phrase.releaseFailedHeading(), new Error(reason), {
210
- code: release.reason ?? cfgcode.INTERNAL,
211
- data,
212
- json,
213
- sw,
214
- });
215
- return;
216
- }
217
- sw.stop(true);
218
- if (json) {
219
- print(data);
220
- } else if (!quiet) {
221
- report(result, { git, published: true });
222
- }
223
- };
224
-
225
- // [function]
226
-
227
- // fails unless the timeout is a number of seconds above 0: otherwise the
228
- // wait would never end.
229
- const checkTimeout = function (timeout) {
230
- if (Number.isFinite(timeout) && timeout > 0) {
231
- return Promise.resolve();
232
- }
233
- return Promise.reject(
234
- new ArcError(cfgcode.ARGUMENT_INVALID, phrase.timeoutInvalid()),
235
- );
236
- };
237
-
238
- // [function]
239
-
240
- const start = function (argv) {
241
- const git = argv.method === "git";
242
- const json = argv.json;
243
- const quiet = argv.quiet;
244
- // `.arcrc` values are strings, and a flag that isn't a number is NaN.
245
- const timeout = Number(argv.timeout ?? TIMEOUT[git ? "git" : "direct"]);
246
- const root = resolve(process.cwd(), argv.cwd);
247
- let pb = null;
248
- // whether the handle rules held the handle back from this release, so the
249
- // game's links are by id.
250
- let held = false;
251
- // the project, parsed once and given to each step. A build can write files
252
- // the manifest reads, such as art, so it's parsed again after one runs.
253
- let parsed = null;
254
- // what --json lists under `warnings`: arc validate's, then the deploy's.
255
- const warnings = [];
256
- let sw = new SpinnerWheel("Validating… %s");
257
- sw.start(json || quiet);
258
- return checkTimeout(timeout)
259
- .then(() =>
260
- checked(root, (found) => {
261
- warnings.push(...found);
262
- }),
263
- )
264
- .then((proj) => {
265
- parsed = proj;
266
- sw.stop(true);
267
- warn(warnings, { json, quiet });
268
- sw = new SpinnerWheel("Checking… %s");
269
- // git deploys need no login, and never use one: anyone who can push to
270
- // the repository can release, and the Arcadible GitHub App publishes
271
- // the release. Every call is public, so it's the same for whoever runs
272
- // it, and the saved session isn't read, or refreshed.
273
- if (git) {
274
- return null;
275
- }
276
- return whoami({ handler: handler({ json, pb, quiet, sw, warnings }) });
277
- })
278
- .then((current) => {
279
- if (!current && !git) {
280
- throw new ArcError(cfgcode.NOT_LOGGED_IN, phrase.notLoggedIn());
281
- }
282
- sw.stop(true);
283
- sw = new SpinnerWheel("Preparing… %s");
284
- return Promise.all([
285
- // whoami
286
- current,
287
- // predeploy
288
- predeploy({
289
- current,
290
- git,
291
- handler: handler({ json, pb, quiet, sw, warnings }),
292
- project: parsed,
293
- root,
294
- }),
295
- ]);
296
- })
297
- .then(([current, predeployed]) => {
298
- sw.stop(true);
299
- held = predeployed.held ?? false;
300
- sw = new SpinnerWheel("Building… %s");
301
- sw.start(git || json || quiet);
302
- return Promise.all([
303
- // whoami
304
- current,
305
- // build
306
- git ? null : build({ project: parsed, root }),
307
- ]);
308
- })
309
- .then(([current, artifact]) =>
310
- Promise.all([current, artifact, artifact ? project(root) : parsed]),
311
- )
312
- .then(([current, artifact, proj]) =>
313
- Promise.all([
314
- current,
315
- artifact,
316
- proj,
317
- proj === parsed ? null : validate({ project: proj, root }),
318
- ]),
319
- )
320
- .then(([current, artifact, proj, validated]) => {
321
- const count = validated?.issues.length ?? 0;
322
- if (count) {
323
- throw new ArcError(
324
- cfgcode.VALIDATION_FAILED,
325
- phrase.issuesAfterBuild(count),
326
- { data: { issues: validated.issues } },
327
- );
328
- }
329
- parsed = proj;
330
- sw.stop(true);
331
- sw = new SpinnerWheel("Packing… %s");
332
- sw.start(git || json || quiet);
333
- return Promise.all([
334
- // whoami
335
- current,
336
- // pack
337
- git
338
- ? null
339
- : pack({
340
- input: artifact?.path,
341
- onWarning: handler({ json, pb, quiet, sw, warnings }).onWarning,
342
- project: parsed,
343
- root,
344
- }),
345
- // build: whether workflow.build ran
346
- Boolean(artifact),
347
- ]);
348
- })
349
- .then(([current, artifact, built]) => {
350
- sw.stop(true);
351
- if (!json && !quiet && !git) {
352
- pb = new ProgressBar(artifact.size, SUBMITTING);
353
- }
354
- return Promise.all([
355
- // whoami
356
- current,
357
- // deploy
358
- deploy({
359
- artifact,
360
- current,
361
- git,
362
- handler: handler({ json, pb, quiet, sw, warnings }),
363
- project: parsed,
364
- root,
365
- }),
366
- built,
367
- // when the release started, to find a git one by
368
- Date.now(),
369
- ]);
370
- })
371
- .then(([current, deployed, built, since]) => {
372
- if (pb) {
373
- pb.stop();
374
- }
375
- // the game and release are for waiting, not printing.
376
- const shown = {
377
- ...deployed,
378
- ...(held
379
- ? links.published({ id: deployed.game, version: deployed.version.to })
380
- : {}),
381
- };
382
- delete shown.game;
383
- delete shown.release;
384
- const result = { ...(git ? shown : { built, ...shown }), warnings };
385
- sw.stop(true);
386
- if (argv.wait) {
387
- return waitAndReport(current, deployed, result, {
388
- git,
389
- json,
390
- quiet,
391
- root,
392
- since,
393
- timeout,
394
- });
395
- }
396
- if (json) {
397
- print(result);
398
- } else if (!quiet) {
399
- report(result, { git });
400
- }
401
- return null;
402
- })
403
- .catch((ex) =>
404
- abort(phrase.aborted(COMMAND), ex, { data: { warnings }, json, pb, sw }),
405
- );
406
- };
407
-
408
- // [function]
409
-
410
- const main = function (argv) {
411
- return start(
412
- yargs(args.normalize(hideBin(argv)))
413
- .scriptName(`${TOOL} ${COMMAND}`)
414
- .usage("$0 [method] [options]")
415
- .command("$0 [method]", false, (cli) =>
416
- cli.positional("method", {
417
- choices: ["direct", "git"],
418
- default: conf.method,
419
- describe: "Deploy method",
420
- type: "string",
421
- }),
422
- )
423
- .option("json", { ...args.JSON_OUTPUT, default: conf.json })
424
- .option("quiet", { ...args.QUIET, default: conf.quiet })
425
- .option("wait", {
426
- alias: "w",
427
- default: conf.wait,
428
- describe: "Wait until it's published or fails",
429
- type: "boolean",
430
- })
431
- .option("timeout", {
432
- default: conf.timeout,
433
- defaultDescription: "300, or 900 for git",
434
- describe: "Seconds to wait",
435
- type: "number",
436
- })
437
- .option("cwd", args.CWD)
438
- .help("help")
439
- .alias("help", "h")
440
- .version(VERSION)
441
- .alias("version", "v")
442
- .fail(args.fail(argv))
443
- .strict()
444
- .parse(),
445
- );
446
- };
447
-
448
- // [start]
449
-
450
- if (require.main === module) {
451
- main(process.argv);
452
- }
453
-
454
- // [export]
455
-
456
- module.exports = { main };
package/bin/arc-init.js DELETED
@@ -1,187 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
-
4
- // [import]
5
-
6
- const path = require("node:path");
7
-
8
- // [import]
9
-
10
- const fs = require("fs-extra");
11
- const hideBin = require("yargs/helpers").hideBin;
12
- const prompts = require("@inquirer/prompts");
13
- const yargs = require("yargs/yargs");
14
-
15
- // [import]
16
-
17
- const args = require("../src/util/argv");
18
- const cfgcode = require("../src/config/code");
19
- const cfgpackage = require("../src/config/package");
20
- const cfgproduct = require("../src/config/product");
21
- const cfgtemplate = require("../src/config/template");
22
- const error = require("../src/util/error");
23
- const init = require("../src/cli/init");
24
- const log = require("../src/util/log");
25
- const output = require("../src/util/output");
26
- const phrase = require("../src/phrase");
27
- const rc = require("../src/util/rc");
28
- const spinner = require("../src/util/spinner");
29
-
30
- // [use]
31
-
32
- const abort = output.abort;
33
- const ArcError = error.ArcError;
34
- const exit = output.exit;
35
- const findRc = rc.findRc;
36
- const pathExists = fs.pathExists;
37
- const print = output.print;
38
- const resolve = path.resolve;
39
- const select = prompts.select;
40
- const SpinnerWheel = spinner.SpinnerWheel;
41
-
42
- // [declare]
43
-
44
- const COMMAND = "init";
45
- const TOOL = cfgproduct.tool;
46
- const VERSION = cfgpackage.version;
47
-
48
- // [define]
49
-
50
- const conf = {
51
- json: false,
52
- project: ".",
53
- quiet: false,
54
- yes: false,
55
- ...findRc(TOOL, COMMAND, process.argv),
56
- };
57
-
58
- // [function]
59
-
60
- const handler = function ({ json, quiet, sw }) {
61
- return {
62
- onInitBegin() {
63
- sw.start(json || quiet);
64
- },
65
- };
66
- };
67
-
68
- // [function]
69
-
70
- const start = function (argv) {
71
- const json = argv.json;
72
- const quiet = argv.quiet;
73
- const sw = new SpinnerWheel("Initializing… %s");
74
- return init({
75
- handler: handler({ json, quiet, sw }),
76
- patch: argv.patch,
77
- project: argv.project,
78
- root: resolve(process.cwd(), argv.cwd),
79
- template: argv.template,
80
- })
81
- .then((project) => {
82
- if (json) {
83
- print({ project });
84
- } else if (!quiet) {
85
- sw.stop(true);
86
- log.hs(phrase.initialized());
87
- if (argv.patch) {
88
- log.p(phrase.initializedNoStarter());
89
- }
90
- print(project, { nl: true, toml: true });
91
- }
92
- // degit sometimes hangs, so exit once stdout is written.
93
- return exit(0);
94
- })
95
- .catch((ex) => abort(phrase.aborted(COMMAND), ex, { json, sw }));
96
- };
97
-
98
- // [function]
99
-
100
- const patch = function (cwd, project) {
101
- // project may be absolute, as action/init/tool.js resolves it.
102
- return pathExists(resolve(process.cwd(), cwd, project));
103
- };
104
-
105
- // [function]
106
-
107
- const prompt = async function ({ yes, ...argv }) {
108
- const opts = { ...argv };
109
- opts.patch = await patch(opts.cwd, opts.project);
110
- if (opts.patch || yes) {
111
- opts.template ??= cfgtemplate.default;
112
- return opts;
113
- }
114
- if (!opts.template) {
115
- // without a terminal, the prompt would read end-of-input and exit.
116
- if (!process.stdin.isTTY) {
117
- throw new ArcError(cfgcode.TEMPLATE_MISSING, phrase.templateMissing());
118
- }
119
- opts.template = await select(cfgtemplate);
120
- }
121
- return opts;
122
- };
123
-
124
- // [function]
125
-
126
- const inquire = function (argv) {
127
- return prompt(argv)
128
- .then(start)
129
- .catch((ex) => {
130
- if (ex?.name === "ExitPromptError") {
131
- process.exit(130);
132
- }
133
- abort(phrase.aborted(COMMAND), ex, { json: argv.json });
134
- });
135
- };
136
-
137
- // [function]
138
-
139
- const main = function (argv) {
140
- return inquire(
141
- yargs(args.normalize(hideBin(argv)))
142
- .scriptName(`${TOOL} ${COMMAND}`)
143
- .usage("$0 [project] [options]")
144
- .command("$0 [project]", false, (cli) =>
145
- cli.positional("project", {
146
- default: conf.project,
147
- describe: "Project directory",
148
- type: "string",
149
- }),
150
- )
151
- .option("template", {
152
- alias: "t",
153
- default: conf.template,
154
- describe: [
155
- "Project template",
156
- "Public GitHub repository, or a folder in one (user/repo[/folder])",
157
- ].join("\n"),
158
- type: "string",
159
- })
160
- .option("yes", {
161
- alias: "y",
162
- default: conf.yes,
163
- describe: "Accept prompt defaults",
164
- type: "boolean",
165
- })
166
- .option("json", { ...args.JSON_OUTPUT, default: conf.json })
167
- .option("quiet", { ...args.QUIET, default: conf.quiet })
168
- .option("cwd", args.CWD)
169
- .help("help")
170
- .alias("help", "h")
171
- .version(VERSION)
172
- .alias("version", "v")
173
- .fail(args.fail(argv))
174
- .strict()
175
- .parse(),
176
- );
177
- };
178
-
179
- // [start]
180
-
181
- if (require.main === module) {
182
- main(process.argv);
183
- }
184
-
185
- // [export]
186
-
187
- module.exports = { main };