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.
- package/README.md +1 -0
- package/bin/arc.js +1 -85
- package/dist/account.js +197 -0
- package/dist/action/build/tool.js +61 -0
- package/dist/action/delete/tool.js +47 -0
- package/dist/action/deploy/rebuilt.js +25 -0
- package/dist/action/deploy/result.js +36 -0
- package/dist/action/deploy/timeout.js +18 -0
- package/dist/action/deploy/tool-git.js +49 -0
- package/dist/action/deploy/tool.js +49 -0
- package/dist/action/deploy/wait.js +104 -0
- package/dist/action/function/tool.js +127 -0
- package/dist/action/game.js +62 -0
- package/dist/action/init/manifest.js +64 -0
- package/dist/action/init/tool-patch.js +15 -0
- package/dist/action/init/tool.js +64 -0
- package/dist/action/inspect/tool.js +13 -0
- package/dist/action/key/tool.js +88 -0
- package/dist/action/login/flow.js +69 -0
- package/dist/action/login/tool.js +8 -0
- package/dist/action/logout/tool.js +8 -0
- package/dist/action/open/tool.js +30 -0
- package/dist/action/pack/limits.js +46 -0
- package/dist/action/pack/tool.js +148 -0
- package/dist/action/pack/unsound.js +51 -0
- package/dist/action/play/tool.js +84 -0
- package/dist/action/predeploy/ac.js +75 -0
- package/dist/action/predeploy/game.js +6 -0
- package/dist/action/predeploy/git.js +151 -0
- package/dist/action/predeploy/pm.js +20 -0
- package/dist/action/predeploy/published.js +54 -0
- package/dist/action/predeploy/secrets.js +35 -0
- package/dist/action/predeploy/tool-git.js +103 -0
- package/dist/action/predeploy/tool.js +14 -0
- package/dist/action/secret/tool.js +91 -0
- package/dist/action/serve/tool.js +270 -0
- package/dist/action/validate/checked.js +28 -0
- package/dist/action/validate/tool.js +56 -0
- package/dist/action/validate/unknown.js +58 -0
- package/dist/action/validate/unsound.js +99 -0
- package/dist/action/value/tool.js +216 -0
- package/dist/action/whoami/tool.js +7 -0
- package/dist/api.js +312 -0
- package/dist/arc.js +41 -0
- package/dist/cli/argv.js +61 -0
- package/dist/cli/channel.js +29 -0
- package/dist/cli/command.js +163 -0
- package/dist/cli/confirm.js +39 -0
- package/dist/cli/options.js +62 -0
- package/dist/cli/rc.js +103 -0
- package/dist/cli/yargs.js +40 -0
- package/dist/command/build.js +68 -0
- package/dist/command/delete.js +66 -0
- package/dist/command/deploy.js +308 -0
- package/dist/command/function/index.js +17 -0
- package/dist/command/function/pause.js +18 -0
- package/dist/command/function/resume.js +18 -0
- package/dist/command/function/run.js +41 -0
- package/dist/command/function/secret/index.js +15 -0
- package/dist/command/function/secret/list.js +27 -0
- package/dist/command/function/secret/name.js +8 -0
- package/dist/command/function/secret/remove.js +26 -0
- package/dist/command/function/secret/run.js +52 -0
- package/dist/command/function/secret/set.js +48 -0
- package/dist/command/function/status.js +40 -0
- package/dist/command/init.js +128 -0
- package/dist/command/inspect.js +39 -0
- package/dist/command/login.js +108 -0
- package/dist/command/logout.js +24 -0
- package/dist/command/open.js +49 -0
- package/dist/command/pack.js +90 -0
- package/dist/command/play.js +81 -0
- package/dist/command/serve.js +177 -0
- package/dist/command/server/index.js +17 -0
- package/dist/command/server/key/create.js +36 -0
- package/dist/command/server/key/index.js +15 -0
- package/dist/command/server/key/list.js +34 -0
- package/dist/command/server/key/revoke.js +24 -0
- package/dist/command/server/key/run.js +54 -0
- package/dist/command/validate.js +47 -0
- package/dist/command/value/get.js +21 -0
- package/dist/command/value/index.js +19 -0
- package/dist/command/value/key.js +8 -0
- package/dist/command/value/list.js +41 -0
- package/dist/command/value/remove.js +26 -0
- package/dist/command/value/set.js +62 -0
- package/dist/command/value/usage.js +69 -0
- package/dist/command/whoami.js +55 -0
- package/dist/commands.js +100 -0
- package/dist/config/ai.js +2 -0
- package/dist/config/art.js +13 -0
- package/dist/config/audience.js +2 -0
- package/dist/config/code.js +129 -0
- package/dist/config/file.js +13 -0
- package/dist/config/genre.js +19 -0
- package/{src → dist}/config/html.js +2 -7
- package/dist/config/image.js +5 -0
- package/dist/config/input.js +11 -0
- package/dist/config/json.js +23 -0
- package/dist/config/limit.js +14 -0
- package/dist/config/orientation.js +11 -0
- package/dist/config/package.js +8 -0
- package/dist/config/product.js +14 -0
- package/dist/config/template.js +37 -0
- package/dist/config/uri.js +18 -0
- package/dist/config/url.js +11 -0
- package/dist/config/video.js +5 -0
- package/dist/config/visibility.js +2 -0
- package/dist/config/workflow.js +7 -0
- package/dist/parser/env.js +61 -0
- package/dist/parser/given.js +8 -0
- package/dist/parser/manifest.js +45 -0
- package/dist/parser/media.js +57 -0
- package/dist/parser/project.js +129 -0
- package/dist/parser/readme-file.js +44 -0
- package/dist/parser/readme.js +70 -0
- package/dist/parser/sections.js +92 -0
- package/dist/parser/self.js +16 -0
- package/dist/phrase/account.js +35 -0
- package/dist/phrase/common.js +139 -0
- package/dist/phrase/deploy.js +192 -0
- package/dist/phrase/function.js +139 -0
- package/dist/phrase/game.js +27 -0
- package/dist/phrase/index.js +16 -0
- package/dist/phrase/init.js +53 -0
- package/dist/phrase/internal.js +61 -0
- package/dist/phrase/manifest.js +120 -0
- package/dist/phrase/media.js +90 -0
- package/dist/phrase/pack.js +69 -0
- package/dist/phrase/serve.js +84 -0
- package/dist/phrase/server.js +38 -0
- package/dist/phrase/value.js +55 -0
- package/dist/runner/bundle.js +45 -0
- package/dist/runner/entry.js +57 -0
- package/dist/runner/outbound.js +69 -0
- package/dist/schema/check/game.js +29 -0
- package/dist/schema/check/workflow.js +57 -0
- package/dist/schema/game.js +462 -0
- package/dist/schema/message.js +61 -0
- package/dist/schema/readme.js +27 -0
- package/dist/schema/runner.js +43 -0
- package/dist/schema/server.js +91 -0
- package/dist/schema/workflow.js +99 -0
- package/dist/serve/files.js +39 -0
- package/dist/serve/game.js +172 -0
- package/dist/serve/page.js +689 -0
- package/dist/serve/reload.js +55 -0
- package/dist/serve/remote.js +114 -0
- package/dist/serve/runner.js +303 -0
- package/dist/serve/server.js +169 -0
- package/dist/serve/ticket.js +232 -0
- package/dist/serve/values.js +317 -0
- package/dist/util/bytes.js +16 -0
- package/dist/util/chars.js +19 -0
- package/dist/util/command.js +11 -0
- package/dist/util/delay.js +36 -0
- package/dist/util/doc.js +59 -0
- package/dist/util/error.js +35 -0
- package/dist/util/http.js +13 -0
- package/dist/util/image.js +64 -0
- package/dist/util/links.js +45 -0
- package/dist/util/lockfile.js +17 -0
- package/dist/util/log.js +101 -0
- package/dist/util/md.js +37 -0
- package/dist/util/media.js +27 -0
- package/dist/util/objs.js +46 -0
- package/dist/util/os.js +13 -0
- package/dist/util/output.js +133 -0
- package/dist/util/paths.js +8 -0
- package/dist/util/progress.js +57 -0
- package/dist/util/promise.js +18 -0
- package/dist/util/request.js +103 -0
- package/dist/util/s3.js +67 -0
- package/dist/util/schema.js +151 -0
- package/dist/util/screenshot.js +24 -0
- package/dist/util/shape.js +49 -0
- package/dist/util/shell.js +64 -0
- package/dist/util/size.js +32 -0
- package/dist/util/spinner.js +35 -0
- package/dist/util/strs.js +46 -0
- package/dist/util/table.js +18 -0
- package/dist/util/term.js +21 -0
- package/dist/util/time.js +16 -0
- package/dist/util/toml.js +28 -0
- package/{src → dist}/util/uris.js +8 -14
- package/dist/util/video.js +113 -0
- package/dist/util/zip.js +62 -0
- package/npm-shrinkwrap.json +3256 -0
- package/package.json +41 -39
- package/bin/arc-build.js +0 -139
- package/bin/arc-default.js +0 -65
- package/bin/arc-deploy.js +0 -456
- package/bin/arc-init.js +0 -187
- package/bin/arc-inspect.js +0 -97
- package/bin/arc-login.js +0 -165
- package/bin/arc-logout.js +0 -75
- package/bin/arc-open.js +0 -104
- package/bin/arc-pack.js +0 -146
- package/bin/arc-play.js +0 -140
- package/bin/arc-serve.js +0 -214
- package/bin/arc-validate.js +0 -112
- package/bin/arc-whoami.js +0 -119
- package/src/account.js +0 -249
- package/src/action/build/tool.js +0 -80
- package/src/action/deploy/tool-git.js +0 -90
- package/src/action/deploy/tool.js +0 -88
- package/src/action/deploy/wait.js +0 -151
- package/src/action/init/manifest.js +0 -83
- package/src/action/init/tool-patch.js +0 -32
- package/src/action/init/tool.js +0 -97
- package/src/action/inspect/tool.js +0 -26
- package/src/action/login/flow.js +0 -101
- package/src/action/login/tool.js +0 -16
- package/src/action/logout/tool.js +0 -15
- package/src/action/open/tool.js +0 -38
- package/src/action/pack/limits.js +0 -51
- package/src/action/pack/tool.js +0 -171
- package/src/action/pack/unsound.js +0 -69
- package/src/action/play/tool.js +0 -109
- package/src/action/predeploy/ac.js +0 -112
- package/src/action/predeploy/git.js +0 -223
- package/src/action/predeploy/pm.js +0 -37
- package/src/action/predeploy/published.js +0 -82
- package/src/action/predeploy/tool-git.js +0 -154
- package/src/action/predeploy/tool.js +0 -29
- package/src/action/serve/tool.js +0 -209
- package/src/action/validate/checked.js +0 -37
- package/src/action/validate/tool.js +0 -67
- package/src/action/validate/unknown.js +0 -86
- package/src/action/validate/unsound.js +0 -138
- package/src/action/whoami/tool.js +0 -15
- package/src/api.js +0 -163
- package/src/cli/build.js +0 -15
- package/src/cli/deploy.js +0 -21
- package/src/cli/init.js +0 -17
- package/src/cli/inspect.js +0 -15
- package/src/cli/login.js +0 -15
- package/src/cli/logout.js +0 -15
- package/src/cli/open.js +0 -15
- package/src/cli/pack.js +0 -15
- package/src/cli/play.js +0 -15
- package/src/cli/predeploy.js +0 -21
- package/src/cli/serve.js +0 -15
- package/src/cli/validate.js +0 -15
- package/src/cli/whoami.js +0 -15
- package/src/config/ai.js +0 -5
- package/src/config/art.js +0 -16
- package/src/config/audience.js +0 -5
- package/src/config/code.js +0 -142
- package/src/config/file.js +0 -23
- package/src/config/genre.js +0 -22
- package/src/config/image.js +0 -7
- package/src/config/input.js +0 -14
- package/src/config/limit.js +0 -21
- package/src/config/orientation.js +0 -14
- package/src/config/package.js +0 -5
- package/src/config/product.js +0 -5
- package/src/config/template.js +0 -45
- package/src/config/uri.js +0 -27
- package/src/config/url.js +0 -20
- package/src/config/video.js +0 -7
- package/src/config/visibility.js +0 -5
- package/src/config/workflow.js +0 -18
- package/src/parser/env.js +0 -84
- package/src/parser/given.js +0 -17
- package/src/parser/manifest.js +0 -80
- package/src/parser/media.js +0 -90
- package/src/parser/project.js +0 -166
- package/src/parser/readme-file.js +0 -76
- package/src/parser/readme.js +0 -96
- package/src/parser/sections.js +0 -107
- package/src/parser/self.js +0 -27
- package/src/phrase.js +0 -1294
- package/src/schema/check/game.js +0 -61
- package/src/schema/check/workflow.js +0 -99
- package/src/schema/game.js +0 -649
- package/src/schema/message.js +0 -85
- package/src/schema/readme.js +0 -44
- package/src/schema/workflow.js +0 -150
- package/src/serve/files.js +0 -61
- package/src/serve/game.js +0 -191
- package/src/serve/page.js +0 -345
- package/src/serve/reload.js +0 -68
- package/src/serve/remote.js +0 -121
- package/src/serve/server.js +0 -128
- package/src/util/argv.js +0 -116
- package/src/util/bytes.js +0 -25
- package/src/util/chars.js +0 -30
- package/src/util/command.js +0 -18
- package/src/util/delay.js +0 -52
- package/src/util/doc.js +0 -72
- package/src/util/error.js +0 -50
- package/src/util/http.js +0 -25
- package/src/util/image.js +0 -93
- package/src/util/links.js +0 -78
- package/src/util/lockfile.js +0 -35
- package/src/util/log.js +0 -149
- package/src/util/md.js +0 -61
- package/src/util/media.js +0 -40
- package/src/util/objs.js +0 -45
- package/src/util/os.js +0 -27
- package/src/util/output.js +0 -174
- package/src/util/paths.js +0 -21
- package/src/util/progress.js +0 -85
- package/src/util/promise.js +0 -29
- package/src/util/rc.js +0 -144
- package/src/util/request.js +0 -89
- package/src/util/s3.js +0 -92
- package/src/util/schema.js +0 -189
- package/src/util/screenshot.js +0 -37
- package/src/util/shell.js +0 -84
- package/src/util/size.js +0 -53
- package/src/util/spinner.js +0 -52
- package/src/util/strs.js +0 -73
- package/src/util/term.js +0 -28
- package/src/util/time.js +0 -29
- package/src/util/toml.js +0 -14
- package/src/util/video.js +0 -157
- package/src/util/zip.js +0 -88
- /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,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
|
+
});
|