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,128 @@
|
|
|
1
|
+
// [import]
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
// [import]
|
|
4
|
+
import fs from "fs-extra";
|
|
5
|
+
import { select } from "@inquirer/prompts";
|
|
6
|
+
// [import]
|
|
7
|
+
import { TEMPLATE_MISSING } from "../config/code.js";
|
|
8
|
+
import { defineCommand } from "../cli/command.js";
|
|
9
|
+
import { ArcError } from "../util/error.js";
|
|
10
|
+
import { initialized, initializedNoStarter, templateMissing, } from "../phrase/index.js";
|
|
11
|
+
import { hs, p } from "../util/log.js";
|
|
12
|
+
import { CWD, JSON_OUTPUT, QUIET } from "../cli/options.js";
|
|
13
|
+
import { print } from "../util/output.js";
|
|
14
|
+
import { SpinnerWheel } from "../util/spinner.js";
|
|
15
|
+
import { choices, fallback, message } from "../config/template.js";
|
|
16
|
+
import { initTool } from "../action/init/tool.js";
|
|
17
|
+
import { initToolPatch } from "../action/init/tool-patch.js";
|
|
18
|
+
// [use]
|
|
19
|
+
const pathExists = fs.pathExists;
|
|
20
|
+
// [function]
|
|
21
|
+
function handler({ json, quiet, sw, }) {
|
|
22
|
+
return {
|
|
23
|
+
onInitBegin() {
|
|
24
|
+
sw.start(json || quiet);
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
// [function]
|
|
29
|
+
function patch(cwd, project) {
|
|
30
|
+
// project may be absolute, as action/init/tool.ts resolves it.
|
|
31
|
+
return pathExists(resolve(process.cwd(), cwd, project));
|
|
32
|
+
}
|
|
33
|
+
// [function]
|
|
34
|
+
async function prompt({ cwd, project, template, yes, }) {
|
|
35
|
+
const patched = await patch(cwd, project);
|
|
36
|
+
if (patched || yes) {
|
|
37
|
+
return { patch: patched, template: template ?? fallback };
|
|
38
|
+
}
|
|
39
|
+
if (!template) {
|
|
40
|
+
// without a terminal, the prompt would read end-of-input and exit.
|
|
41
|
+
if (!process.stdin.isTTY) {
|
|
42
|
+
throw new ArcError(TEMPLATE_MISSING, templateMissing());
|
|
43
|
+
}
|
|
44
|
+
const answer = await select({
|
|
45
|
+
choices,
|
|
46
|
+
default: fallback,
|
|
47
|
+
message,
|
|
48
|
+
});
|
|
49
|
+
return { patch: patched, template: answer };
|
|
50
|
+
}
|
|
51
|
+
return { patch: patched, template };
|
|
52
|
+
}
|
|
53
|
+
// [function]
|
|
54
|
+
// whether a prompt ended because it was cancelled (Ctrl+C).
|
|
55
|
+
function cancelled(ex) {
|
|
56
|
+
return ex instanceof Error && ex.name === "ExitPromptError";
|
|
57
|
+
}
|
|
58
|
+
// [export]
|
|
59
|
+
export default defineCommand({
|
|
60
|
+
name: "init",
|
|
61
|
+
options: {
|
|
62
|
+
template: {
|
|
63
|
+
alias: "t",
|
|
64
|
+
describe: [
|
|
65
|
+
"Project template",
|
|
66
|
+
"Public GitHub repository, or a folder in one (user/repo[/folder])",
|
|
67
|
+
].join("\n"),
|
|
68
|
+
rc: true,
|
|
69
|
+
type: "string",
|
|
70
|
+
},
|
|
71
|
+
yes: {
|
|
72
|
+
alias: "y",
|
|
73
|
+
default: false,
|
|
74
|
+
describe: "Accept prompt defaults",
|
|
75
|
+
rc: true,
|
|
76
|
+
type: "boolean",
|
|
77
|
+
},
|
|
78
|
+
json: JSON_OUTPUT,
|
|
79
|
+
quiet: QUIET,
|
|
80
|
+
cwd: CWD,
|
|
81
|
+
},
|
|
82
|
+
positionals: {
|
|
83
|
+
project: {
|
|
84
|
+
default: ".",
|
|
85
|
+
describe: "Project directory",
|
|
86
|
+
rc: true,
|
|
87
|
+
type: "string",
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
async run(argv, aborting) {
|
|
91
|
+
const json = argv.json;
|
|
92
|
+
const quiet = argv.quiet;
|
|
93
|
+
// a string from the command line; `.arcrc` can give anything.
|
|
94
|
+
const project = String(argv.project);
|
|
95
|
+
const prompted = await prompt({
|
|
96
|
+
cwd: argv.cwd,
|
|
97
|
+
project,
|
|
98
|
+
template: argv.template,
|
|
99
|
+
yes: argv.yes,
|
|
100
|
+
}).catch((ex) => {
|
|
101
|
+
if (cancelled(ex)) {
|
|
102
|
+
process.exit(130);
|
|
103
|
+
}
|
|
104
|
+
throw ex;
|
|
105
|
+
});
|
|
106
|
+
const sw = new SpinnerWheel("Initializing… %s");
|
|
107
|
+
aborting.sw = sw;
|
|
108
|
+
const conf = { project, root: resolve(process.cwd(), argv.cwd) };
|
|
109
|
+
const handlers = handler({ json, quiet, sw });
|
|
110
|
+
const made = prompted.patch
|
|
111
|
+
? await initToolPatch(conf, handlers)
|
|
112
|
+
: await initTool({ ...conf, template: String(prompted.template) }, handlers);
|
|
113
|
+
if (json) {
|
|
114
|
+
print({ project: made });
|
|
115
|
+
}
|
|
116
|
+
else if (!quiet) {
|
|
117
|
+
sw.stop(true);
|
|
118
|
+
hs(initialized());
|
|
119
|
+
if (prompted.patch) {
|
|
120
|
+
p(initializedNoStarter());
|
|
121
|
+
}
|
|
122
|
+
print(made, { nl: true, toml: true });
|
|
123
|
+
}
|
|
124
|
+
// degit sometimes hangs, so exit once stdout is written.
|
|
125
|
+
return 0;
|
|
126
|
+
},
|
|
127
|
+
summary: "Initialize a project",
|
|
128
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// [import]
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
// [import]
|
|
4
|
+
import { defineCommand } from "../cli/command.js";
|
|
5
|
+
import { textOf } from "../util/objs.js";
|
|
6
|
+
import { CWD, JSON_OUTPUT, QUIET } from "../cli/options.js";
|
|
7
|
+
import { print } from "../util/output.js";
|
|
8
|
+
import { inspectTool } from "../action/inspect/tool.js";
|
|
9
|
+
// [export]
|
|
10
|
+
export default defineCommand({
|
|
11
|
+
name: "inspect",
|
|
12
|
+
options: { json: JSON_OUTPUT, quiet: QUIET, cwd: CWD },
|
|
13
|
+
positionals: {
|
|
14
|
+
selector: {
|
|
15
|
+
default: null,
|
|
16
|
+
describe: "Property selector",
|
|
17
|
+
rc: true,
|
|
18
|
+
type: "string",
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
async run(argv) {
|
|
22
|
+
// a string from the command line; `.arcrc` can give anything.
|
|
23
|
+
const selector = argv.selector == null ? null : textOf(argv.selector);
|
|
24
|
+
const data = await inspectTool({
|
|
25
|
+
root: resolve(process.cwd(), argv.cwd),
|
|
26
|
+
selector,
|
|
27
|
+
});
|
|
28
|
+
if (argv.json) {
|
|
29
|
+
print(data);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
// with --quiet, whether the project can be read is the exit code's to
|
|
33
|
+
// say.
|
|
34
|
+
if (!argv.quiet) {
|
|
35
|
+
print(data, { key: selector, toml: true });
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
summary: "Print the resolved manifest",
|
|
39
|
+
});
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
// [import]
|
|
2
|
+
import qrcode from "qrcode-terminal";
|
|
3
|
+
// [import]
|
|
4
|
+
import { defineCommand } from "../cli/command.js";
|
|
5
|
+
import { LOGIN_FAILED } from "../config/code.js";
|
|
6
|
+
import { ArcError } from "../util/error.js";
|
|
7
|
+
import { loggedIn, loggingIn, loginFailed, pressEnterToOpen, } from "../phrase/index.js";
|
|
8
|
+
import { h, nlp, p, result } from "../util/log.js";
|
|
9
|
+
import { title } from "../config/product.js";
|
|
10
|
+
import { launch } from "../util/shell.js";
|
|
11
|
+
import { SpinnerWheel } from "../util/spinner.js";
|
|
12
|
+
import { login } from "../action/login/tool.js";
|
|
13
|
+
// [function]
|
|
14
|
+
function onLoginEnter(fn) {
|
|
15
|
+
const stdin = process.stdin;
|
|
16
|
+
if (!stdin.isTTY) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const cleanup = function () {
|
|
20
|
+
stdin.setRawMode(false);
|
|
21
|
+
stdin.pause();
|
|
22
|
+
stdin.removeAllListeners("data");
|
|
23
|
+
};
|
|
24
|
+
stdin.setRawMode(true);
|
|
25
|
+
stdin.resume();
|
|
26
|
+
stdin.once("data", (buf) => {
|
|
27
|
+
cleanup();
|
|
28
|
+
if (buf[0] === 3) {
|
|
29
|
+
process.kill(process.pid, "SIGINT");
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (buf[0] === 13) {
|
|
33
|
+
fn();
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
// [function]
|
|
38
|
+
// `shown` is called once the link is printed, so a failure after it starts
|
|
39
|
+
// after a blank line.
|
|
40
|
+
function handler({ browser, qrcode: qr, shown, sw, }) {
|
|
41
|
+
return {
|
|
42
|
+
onLoginCreated({ code: dac, secret, url }) {
|
|
43
|
+
sw.stop(true);
|
|
44
|
+
shown();
|
|
45
|
+
const link = `${url}/${secret}`;
|
|
46
|
+
p(loggingIn());
|
|
47
|
+
qrcode.generate(link, { small: true }, (code) => {
|
|
48
|
+
if (qr) {
|
|
49
|
+
p(code);
|
|
50
|
+
}
|
|
51
|
+
nlp(url);
|
|
52
|
+
h(dac.toUpperCase());
|
|
53
|
+
// a key press can only be read from a terminal.
|
|
54
|
+
if (browser && process.stdin.isTTY) {
|
|
55
|
+
nlp(pressEnterToOpen());
|
|
56
|
+
onLoginEnter(() => {
|
|
57
|
+
void launch(link);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
// [export]
|
|
65
|
+
export default defineCommand({
|
|
66
|
+
name: "login",
|
|
67
|
+
options: {
|
|
68
|
+
browser: {
|
|
69
|
+
default: true,
|
|
70
|
+
describe: "Open a web browser on Enter",
|
|
71
|
+
rc: true,
|
|
72
|
+
type: "boolean",
|
|
73
|
+
},
|
|
74
|
+
qrcode: {
|
|
75
|
+
default: true,
|
|
76
|
+
describe: "Show a QR code",
|
|
77
|
+
rc: true,
|
|
78
|
+
type: "boolean",
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
async run(argv, aborting) {
|
|
82
|
+
const sw = new SpinnerWheel("Logging in… %s");
|
|
83
|
+
aborting.sw = sw;
|
|
84
|
+
sw.start();
|
|
85
|
+
try {
|
|
86
|
+
const current = await login({}, handler({
|
|
87
|
+
browser: argv.browser,
|
|
88
|
+
qrcode: argv.qrcode,
|
|
89
|
+
shown() {
|
|
90
|
+
aborting.nl = true;
|
|
91
|
+
},
|
|
92
|
+
sw,
|
|
93
|
+
}));
|
|
94
|
+
const user = current?.user;
|
|
95
|
+
if (!user) {
|
|
96
|
+
throw new ArcError(LOGIN_FAILED, loginFailed());
|
|
97
|
+
}
|
|
98
|
+
sw.stop(true);
|
|
99
|
+
process.stdin.pause();
|
|
100
|
+
result(loggedIn(), [user.display_name], { nl: true });
|
|
101
|
+
}
|
|
102
|
+
catch (ex) {
|
|
103
|
+
process.stdin.pause();
|
|
104
|
+
throw ex;
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
summary: `Log in to ${title}`,
|
|
108
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// [import]
|
|
2
|
+
import { defineCommand } from "../cli/command.js";
|
|
3
|
+
import { loggedOut } from "../phrase/index.js";
|
|
4
|
+
import { hs } from "../util/log.js";
|
|
5
|
+
import { JSON_OUTPUT, QUIET } from "../cli/options.js";
|
|
6
|
+
import { print } from "../util/output.js";
|
|
7
|
+
import { title } from "../config/product.js";
|
|
8
|
+
import { logout } from "../action/logout/tool.js";
|
|
9
|
+
// [export]
|
|
10
|
+
export default defineCommand({
|
|
11
|
+
name: "logout",
|
|
12
|
+
options: { json: JSON_OUTPUT, quiet: QUIET },
|
|
13
|
+
async run(argv) {
|
|
14
|
+
// the account it logged out of, or null when no one was logged in.
|
|
15
|
+
const user = await logout();
|
|
16
|
+
if (argv.json) {
|
|
17
|
+
print({ user });
|
|
18
|
+
}
|
|
19
|
+
else if (!argv.quiet) {
|
|
20
|
+
hs(loggedOut());
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
summary: `Log out of ${title}`,
|
|
24
|
+
});
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// [import]
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
// [import]
|
|
4
|
+
import { GAME_ID_MISSING } from "../config/code.js";
|
|
5
|
+
import { defineCommand } from "../cli/command.js";
|
|
6
|
+
import { ArcError } from "../util/error.js";
|
|
7
|
+
import { gameIdMissing } from "../phrase/index.js";
|
|
8
|
+
import { textOf } from "../util/objs.js";
|
|
9
|
+
import { BROWSER, CWD, JSON_OUTPUT, QUIET } from "../cli/options.js";
|
|
10
|
+
import { launched, print } from "../util/output.js";
|
|
11
|
+
import { launch } from "../util/shell.js";
|
|
12
|
+
import { openTool } from "../action/open/tool.js";
|
|
13
|
+
import { HOST_APP_STORE } from "../config/uri.js";
|
|
14
|
+
// [export]
|
|
15
|
+
export default defineCommand({
|
|
16
|
+
name: "open",
|
|
17
|
+
options: { browser: BROWSER, json: JSON_OUTPUT, quiet: QUIET, cwd: CWD },
|
|
18
|
+
positionals: {
|
|
19
|
+
game: {
|
|
20
|
+
default: "self",
|
|
21
|
+
describe: "Game handle or ID",
|
|
22
|
+
rc: true,
|
|
23
|
+
type: "string",
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
async run(argv) {
|
|
27
|
+
const data = await openTool({
|
|
28
|
+
// a string from the command line; `.arcrc` can give anything.
|
|
29
|
+
game: argv.game ? textOf(argv.game) : null,
|
|
30
|
+
root: resolve(process.cwd(), argv.cwd),
|
|
31
|
+
});
|
|
32
|
+
if (!data) {
|
|
33
|
+
throw new ArcError(GAME_ID_MISSING, gameIdMissing());
|
|
34
|
+
}
|
|
35
|
+
const { page, url } = data;
|
|
36
|
+
const where = await (argv.browser
|
|
37
|
+
? launch(url)
|
|
38
|
+
: launch(`${HOST_APP_STORE}${page}`, url));
|
|
39
|
+
if (argv.json) {
|
|
40
|
+
// where it opened (app, browser, or null when it couldn't), and the
|
|
41
|
+
// store page's URL.
|
|
42
|
+
print({ opened: where, url });
|
|
43
|
+
}
|
|
44
|
+
else if (!argv.quiet) {
|
|
45
|
+
launched(where, url);
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
summary: "Open a game's store page",
|
|
49
|
+
});
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// [import]
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
// [import]
|
|
4
|
+
import { checked } from "../action/validate/checked.js";
|
|
5
|
+
import { defineCommand } from "../cli/command.js";
|
|
6
|
+
import { packed as packedHeading } from "../phrase/index.js";
|
|
7
|
+
import { hs, pw } from "../util/log.js";
|
|
8
|
+
import { CWD, JSON_OUTPUT, QUIET } from "../cli/options.js";
|
|
9
|
+
import { print, warn, warning } from "../util/output.js";
|
|
10
|
+
import { SpinnerWheel } from "../util/spinner.js";
|
|
11
|
+
import { packTool } from "../action/pack/tool.js";
|
|
12
|
+
// [use]
|
|
13
|
+
const resolve = path.resolve;
|
|
14
|
+
// [function]
|
|
15
|
+
// a path option's value: `.arcrc` can set it, to a string, or to anything in
|
|
16
|
+
// JSON, which is read as text. None is null.
|
|
17
|
+
function pathOf(value) {
|
|
18
|
+
return (value ?? null) === null ? null : String(value);
|
|
19
|
+
}
|
|
20
|
+
// [export]
|
|
21
|
+
export default defineCommand({
|
|
22
|
+
name: "pack",
|
|
23
|
+
options: {
|
|
24
|
+
input: {
|
|
25
|
+
alias: "i",
|
|
26
|
+
default: null,
|
|
27
|
+
describe: "Pack this directory instead of deploy_dir",
|
|
28
|
+
rc: true,
|
|
29
|
+
type: "string",
|
|
30
|
+
},
|
|
31
|
+
output: {
|
|
32
|
+
alias: "o",
|
|
33
|
+
default: null,
|
|
34
|
+
describe: "Write the zip to this path",
|
|
35
|
+
rc: true,
|
|
36
|
+
type: "string",
|
|
37
|
+
},
|
|
38
|
+
json: JSON_OUTPUT,
|
|
39
|
+
quiet: QUIET,
|
|
40
|
+
cwd: CWD,
|
|
41
|
+
},
|
|
42
|
+
async run(argv, aborting) {
|
|
43
|
+
const json = argv.json;
|
|
44
|
+
const quiet = argv.quiet;
|
|
45
|
+
const root = resolve(process.cwd(), argv.cwd);
|
|
46
|
+
// what --json lists under `warnings`: arc validate's, then the package's.
|
|
47
|
+
let warnings = [];
|
|
48
|
+
aborting.data = { warnings };
|
|
49
|
+
const packed = [];
|
|
50
|
+
let sw = new SpinnerWheel("Validating… %s");
|
|
51
|
+
aborting.sw = sw;
|
|
52
|
+
sw.start(json || quiet);
|
|
53
|
+
// the project, parsed once for both steps.
|
|
54
|
+
const parsed = await checked(root, (found) => {
|
|
55
|
+
warnings = found;
|
|
56
|
+
aborting.data = { warnings };
|
|
57
|
+
});
|
|
58
|
+
sw.stop(true);
|
|
59
|
+
warn(warnings, { json, quiet });
|
|
60
|
+
sw = new SpinnerWheel("Packing… %s");
|
|
61
|
+
aborting.sw = sw;
|
|
62
|
+
sw.start(json || quiet);
|
|
63
|
+
const artifact = await packTool({
|
|
64
|
+
input: pathOf(argv.input),
|
|
65
|
+
// the package's own, printed once it's packed.
|
|
66
|
+
onWarning({ code, message }) {
|
|
67
|
+
packed.push(warning(code, message));
|
|
68
|
+
},
|
|
69
|
+
output: pathOf(argv.output),
|
|
70
|
+
project: parsed,
|
|
71
|
+
root,
|
|
72
|
+
});
|
|
73
|
+
warnings = [...warnings, ...packed];
|
|
74
|
+
aborting.data = { warnings };
|
|
75
|
+
if (!json && !quiet && packed.length) {
|
|
76
|
+
sw.stop(true);
|
|
77
|
+
packed.forEach((each) => pw(each.message));
|
|
78
|
+
}
|
|
79
|
+
if (json) {
|
|
80
|
+
print({ artifact, warnings });
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
if (!quiet) {
|
|
84
|
+
sw.stop(true);
|
|
85
|
+
hs(packedHeading());
|
|
86
|
+
print(artifact, { nl: true, toml: true });
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
summary: "Pack the game into a zip",
|
|
90
|
+
});
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// [import]
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
// [import]
|
|
4
|
+
import { GAME_ID_MISSING } from "../config/code.js";
|
|
5
|
+
import { defineCommand } from "../cli/command.js";
|
|
6
|
+
import { ArcError } from "../util/error.js";
|
|
7
|
+
import { gameIdMissing, noProductionRelease } from "../phrase/index.js";
|
|
8
|
+
import { pw } from "../util/log.js";
|
|
9
|
+
import { textOf } from "../util/objs.js";
|
|
10
|
+
import { BROWSER, CWD, JSON_OUTPUT, QUIET } from "../cli/options.js";
|
|
11
|
+
import { launched, print } from "../util/output.js";
|
|
12
|
+
import { launch } from "../util/shell.js";
|
|
13
|
+
import { SpinnerWheel } from "../util/spinner.js";
|
|
14
|
+
import { playTool } from "../action/play/tool.js";
|
|
15
|
+
import { HOST_APP_PLAY } from "../config/uri.js";
|
|
16
|
+
// [function]
|
|
17
|
+
function handler({ quiet, sw, }) {
|
|
18
|
+
return {
|
|
19
|
+
onPlayFetch() {
|
|
20
|
+
sw.start(quiet);
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
// [export]
|
|
25
|
+
export default defineCommand({
|
|
26
|
+
name: "play",
|
|
27
|
+
options: {
|
|
28
|
+
release: {
|
|
29
|
+
alias: "r",
|
|
30
|
+
// without one, the action picks production, or staging when there's
|
|
31
|
+
// no production release yet (docs: arc-play.md).
|
|
32
|
+
defaultDescription: '"production"',
|
|
33
|
+
describe: "Release channel or version",
|
|
34
|
+
rc: true,
|
|
35
|
+
type: "string",
|
|
36
|
+
},
|
|
37
|
+
browser: BROWSER,
|
|
38
|
+
json: JSON_OUTPUT,
|
|
39
|
+
quiet: QUIET,
|
|
40
|
+
cwd: CWD,
|
|
41
|
+
},
|
|
42
|
+
positionals: {
|
|
43
|
+
game: {
|
|
44
|
+
default: "self",
|
|
45
|
+
describe: "Game handle or ID",
|
|
46
|
+
rc: true,
|
|
47
|
+
type: "string",
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
async run(argv, aborting) {
|
|
51
|
+
const sw = new SpinnerWheel("Opening… %s");
|
|
52
|
+
aborting.sw = sw;
|
|
53
|
+
const data = await playTool({
|
|
54
|
+
// strings from the command line; `.arcrc` can give anything.
|
|
55
|
+
game: argv.game ? textOf(argv.game) : null,
|
|
56
|
+
release: argv.release ? textOf(argv.release) : null,
|
|
57
|
+
root: resolve(process.cwd(), argv.cwd),
|
|
58
|
+
}, handler({ quiet: argv.json || argv.quiet, sw }));
|
|
59
|
+
const orientation = data?.orientation;
|
|
60
|
+
const url = data?.url;
|
|
61
|
+
if (!data || !orientation || !url) {
|
|
62
|
+
throw new ArcError(GAME_ID_MISSING, gameIdMissing());
|
|
63
|
+
}
|
|
64
|
+
sw.stop(true);
|
|
65
|
+
if (data.fallback && !argv.json && !argv.quiet) {
|
|
66
|
+
pw(noProductionRelease());
|
|
67
|
+
}
|
|
68
|
+
const where = await (argv.browser
|
|
69
|
+
? launch(url)
|
|
70
|
+
: launch(`${HOST_APP_PLAY}/${textOf(orientation)}/${url}`, url));
|
|
71
|
+
if (argv.json) {
|
|
72
|
+
// where it opened (app, browser, or null when it couldn't), and the
|
|
73
|
+
// play link, which names the channel or version it plays.
|
|
74
|
+
print({ opened: where, url });
|
|
75
|
+
}
|
|
76
|
+
else if (!argv.quiet) {
|
|
77
|
+
launched(where, url);
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
summary: "Play a game",
|
|
81
|
+
});
|