arcadible 0.0.1 → 0.1.1

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 (66) hide show
  1. package/README.md +3 -0
  2. package/bin/arc-default.js +57 -0
  3. package/bin/arc-deploy.js +117 -0
  4. package/bin/arc-init.js +196 -0
  5. package/bin/arc-inspect.js +107 -0
  6. package/bin/arc-login.js +127 -0
  7. package/bin/arc-logout.js +58 -0
  8. package/bin/arc-pack.js +126 -0
  9. package/bin/arc-validate.js +114 -0
  10. package/bin/arc-whoami.js +111 -0
  11. package/bin/arc.js +64 -0
  12. package/package.json +49 -1
  13. package/src/action/deploy/tool.js +11 -0
  14. package/src/action/deploy-git/git.js +23 -0
  15. package/src/action/deploy-git/release.js +74 -0
  16. package/src/action/deploy-git/tool.js +11 -0
  17. package/src/action/init/tool.js +44 -0
  18. package/src/action/inspect/tool.js +25 -0
  19. package/src/action/login/flow.js +94 -0
  20. package/src/action/login/tool.js +16 -0
  21. package/src/action/logout/tool.js +15 -0
  22. package/src/action/pack/tool.js +60 -0
  23. package/src/action/validate/tool.js +39 -0
  24. package/src/action/whoami/tool.js +15 -0
  25. package/src/api.js +39 -0
  26. package/src/cli/deploy.js +17 -0
  27. package/src/cli/index.js +25 -0
  28. package/src/cli/init.js +15 -0
  29. package/src/cli/inspect.js +15 -0
  30. package/src/cli/login.js +15 -0
  31. package/src/cli/logout.js +15 -0
  32. package/src/cli/pack.js +15 -0
  33. package/src/cli/validate.js +15 -0
  34. package/src/cli/whoami.js +15 -0
  35. package/src/config/audience.js +5 -0
  36. package/src/config/game.js +5 -0
  37. package/src/config/genre.js +22 -0
  38. package/src/config/html.js +27 -0
  39. package/src/config/input.js +14 -0
  40. package/src/config/orientation.js +14 -0
  41. package/src/config/uri.js +14 -0
  42. package/src/config/url.js +17 -0
  43. package/src/config/visibility.js +5 -0
  44. package/src/config/workflow.js +5 -0
  45. package/src/parser/manifest.js +46 -0
  46. package/src/parser/media.js +96 -0
  47. package/src/parser/project.js +55 -0
  48. package/src/parser/readme.js +144 -0
  49. package/src/prompt/project.js +10 -0
  50. package/src/prompt/template.js +37 -0
  51. package/src/schema/game.js +324 -0
  52. package/src/schema/workflow.js +119 -0
  53. package/src/user.js +91 -0
  54. package/src/util/dom.js +27 -0
  55. package/src/util/log.js +99 -0
  56. package/src/util/md.js +24 -0
  57. package/src/util/objs.js +28 -0
  58. package/src/util/os.js +24 -0
  59. package/src/util/output.js +46 -0
  60. package/src/util/promise.js +29 -0
  61. package/src/util/rc.js +41 -0
  62. package/src/util/request.js +62 -0
  63. package/src/util/schema.js +25 -0
  64. package/src/util/strs.js +21 -0
  65. package/src/util/time.js +79 -0
  66. package/src/util/zip.js +59 -0
@@ -0,0 +1,126 @@
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 log = require("../src/util/log");
16
+ const output = require("../src/util/output");
17
+ const pack = require("../src/cli/pack");
18
+ const pkg = require("../package.json");
19
+ const rc = require("../src/util/rc");
20
+ const validate = require("../src/cli/validate");
21
+
22
+ // [use]
23
+
24
+ const findRc = rc.findRc;
25
+ const print = output.print;
26
+ const resolve = path.resolve;
27
+
28
+ // [declare]
29
+
30
+ const CMD = "arc";
31
+ const SUBCMD = "pack";
32
+
33
+ // [define]
34
+
35
+ const conf = {
36
+ json: false,
37
+ output: "package.zip",
38
+ quiet: false,
39
+ ...findRc(CMD, SUBCMD, process.argv, ["--cwd", "-C"]),
40
+ };
41
+
42
+ // [function]
43
+
44
+ const start = function (argv) {
45
+ const json = argv.json;
46
+ const quiet = argv.quiet;
47
+ const root = resolve(process.cwd(), argv.cwd);
48
+ return validate({ root })
49
+ .then((issues) => {
50
+ const valid = !issues.length;
51
+ if (!valid) {
52
+ throw new Error("Validation failed. Run `arc validate` for details.");
53
+ }
54
+ return pack({ output: argv.output, root });
55
+ })
56
+ .then((data) => {
57
+ if (json) {
58
+ print({ artifact: data });
59
+ return;
60
+ }
61
+ if (!quiet) {
62
+ log.hs("Packed.");
63
+ print(data, { toml: true });
64
+ }
65
+ })
66
+ .catch((ex) => {
67
+ const message = ex.message;
68
+ if (json) {
69
+ print({ error: { message } });
70
+ } else {
71
+ log.hd("Pack aborted.");
72
+ log.p(message);
73
+ }
74
+ process.exit(1);
75
+ });
76
+ };
77
+
78
+ // [function]
79
+
80
+ const main = function (argv) {
81
+ return start(
82
+ yargs(hideBin(argv))
83
+ .scriptName(`${CMD} ${SUBCMD}`)
84
+ .usage("$0 [options]")
85
+ .option("output", {
86
+ alias: "o",
87
+ default: conf.output,
88
+ describe: "Set the output path.",
89
+ type: "string",
90
+ })
91
+ .option("json", {
92
+ alias: "j",
93
+ default: conf.json,
94
+ describe: "Format output as JSON.",
95
+ type: "boolean",
96
+ })
97
+ .option("quiet", {
98
+ alias: "q",
99
+ default: conf.quiet,
100
+ describe: "Output only errors.",
101
+ type: "boolean",
102
+ })
103
+ .option("cwd", {
104
+ alias: "C",
105
+ default: ".",
106
+ describe: "Set the working directory.",
107
+ type: "string",
108
+ })
109
+ .help("help")
110
+ .alias("help", "h")
111
+ .version(pkg.version)
112
+ .alias("version", "v")
113
+ .strict()
114
+ .parse(),
115
+ );
116
+ };
117
+
118
+ // [main]
119
+
120
+ if (require.main === module) {
121
+ main(process.argv);
122
+ }
123
+
124
+ // [export]
125
+
126
+ module.exports = { main };
@@ -0,0 +1,114 @@
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 log = require("../src/util/log");
16
+ const output = require("../src/util/output");
17
+ const pkg = require("../package.json");
18
+ const rc = require("../src/util/rc");
19
+ const validate = require("../src/cli/validate");
20
+
21
+ // [use]
22
+
23
+ const findRc = rc.findRc;
24
+ const print = output.print;
25
+ const resolve = path.resolve;
26
+
27
+ // [declare]
28
+
29
+ const CMD = "arc";
30
+ const SUBCMD = "validate";
31
+
32
+ // [define]
33
+
34
+ const conf = {
35
+ json: false,
36
+ quiet: false,
37
+ ...findRc(CMD, SUBCMD, process.argv, ["--cwd", "-C"]),
38
+ };
39
+
40
+ // [function]
41
+
42
+ const start = function (argv) {
43
+ const json = argv.json;
44
+ const quiet = argv.quiet;
45
+ return validate({ root: resolve(process.cwd(), argv.cwd) })
46
+ .then((issues) => {
47
+ const valid = !issues.length;
48
+ if (json) {
49
+ print({ issues });
50
+ } else if (valid) {
51
+ if (!quiet) {
52
+ log.hs("Passed.");
53
+ }
54
+ } else {
55
+ log.hd("Failed.");
56
+ log.p(issues.map((error) => `✖ ${error}`));
57
+ }
58
+ process.exit(valid ? 0 : 1);
59
+ })
60
+ .catch((ex) => {
61
+ const message = ex.message;
62
+ if (json) {
63
+ print({ error: { message } });
64
+ } else {
65
+ log.hd("Validate aborted.");
66
+ log.p(message);
67
+ }
68
+ process.exit(1);
69
+ });
70
+ };
71
+
72
+ // [function]
73
+
74
+ const main = function (argv) {
75
+ return start(
76
+ yargs(hideBin(argv))
77
+ .scriptName(`${CMD} ${SUBCMD}`)
78
+ .usage("$0 [options]")
79
+ .option("json", {
80
+ alias: "j",
81
+ default: conf.json,
82
+ describe: "Format output as JSON.",
83
+ type: "boolean",
84
+ })
85
+ .option("quiet", {
86
+ alias: "q",
87
+ default: conf.quiet,
88
+ describe: "Output only errors.",
89
+ type: "boolean",
90
+ })
91
+ .option("cwd", {
92
+ alias: "C",
93
+ default: ".",
94
+ describe: "Set the working directory.",
95
+ type: "string",
96
+ })
97
+ .help("help")
98
+ .alias("help", "h")
99
+ .version(pkg.version)
100
+ .alias("version", "v")
101
+ .strict()
102
+ .parse(),
103
+ );
104
+ };
105
+
106
+ // [main]
107
+
108
+ if (require.main === module) {
109
+ main(process.argv);
110
+ }
111
+
112
+ // [export]
113
+
114
+ module.exports = { main };
@@ -0,0 +1,111 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ // [import]
5
+
6
+ const hideBin = require("yargs/helpers").hideBin;
7
+ const yargs = require("yargs/yargs");
8
+
9
+ // [import]
10
+
11
+ const log = require("../src/util/log");
12
+ const output = require("../src/util/output");
13
+ const pkg = require("../package.json");
14
+ const rc = require("../src/util/rc");
15
+ const whoami = require("../src/cli/whoami");
16
+
17
+ // [use]
18
+
19
+ const findRc = rc.findRc;
20
+ const print = output.print;
21
+
22
+ // [declare]
23
+
24
+ const CMD = "arc";
25
+ const SUBCMD = "whoami";
26
+
27
+ // [define]
28
+
29
+ const conf = {
30
+ json: false,
31
+ ...findRc(CMD, SUBCMD, process.argv, ["--cwd", "-C"]),
32
+ };
33
+
34
+ // [function]
35
+
36
+ const handler = function ({ json }) {
37
+ return {
38
+ onRefresh(refresh) {
39
+ if (!json) {
40
+ log.p("Checking login...");
41
+ }
42
+ return refresh(true);
43
+ },
44
+ };
45
+ };
46
+
47
+ // [function]
48
+
49
+ const start = function (argv) {
50
+ const json = argv.json;
51
+ return whoami({ handler: handler({ json }) })
52
+ .then((current) => {
53
+ if (!current || !current.profile) {
54
+ if (json) {
55
+ print({ profile: null });
56
+ } else {
57
+ log.p("Not logged in.");
58
+ }
59
+ return;
60
+ }
61
+ const profile = current.profile;
62
+ if (json) {
63
+ print({ profile });
64
+ } else {
65
+ log.p("Logged in as:");
66
+ log.hs(profile.display_name);
67
+ }
68
+ })
69
+ .catch((ex) => {
70
+ const message = ex.message;
71
+ if (json) {
72
+ print({ error: { message } });
73
+ } else {
74
+ log.hd("Whoami aborted.");
75
+ log.p(message);
76
+ }
77
+ process.exit(1);
78
+ });
79
+ };
80
+
81
+ // [function]
82
+
83
+ const main = function (argv) {
84
+ return start(
85
+ yargs(hideBin(argv))
86
+ .scriptName(`${CMD} ${SUBCMD}`)
87
+ .usage("$0 [options]")
88
+ .option("json", {
89
+ alias: "j",
90
+ default: conf.json,
91
+ describe: "Format output as JSON.",
92
+ type: "boolean",
93
+ })
94
+ .help("help")
95
+ .alias("help", "h")
96
+ .version(pkg.version)
97
+ .alias("version", "v")
98
+ .strict()
99
+ .parse(),
100
+ );
101
+ };
102
+
103
+ // [main]
104
+
105
+ if (require.main === module) {
106
+ main(process.argv);
107
+ }
108
+
109
+ // [export]
110
+
111
+ module.exports = { main };
package/bin/arc.js ADDED
@@ -0,0 +1,64 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ // [import]
5
+
6
+ const fs = require("fs-extra");
7
+
8
+ // [import]
9
+
10
+ const log = require("../src/util/log");
11
+ const pkg = require("../package.json");
12
+
13
+ // [use]
14
+
15
+ const pathExists = fs.pathExists;
16
+
17
+ // [declare]
18
+
19
+ const CMD = "arc";
20
+
21
+ // [function]
22
+
23
+ const dispatch = function (argv) {
24
+ const args = [...argv];
25
+ const subcmds = Object.keys(pkg.bin)
26
+ .filter((key) => key !== CMD)
27
+ .map((key) => key.slice(CMD.length + 1));
28
+ if (!subcmds.includes(args[2])) {
29
+ args.splice(2, 0, "default");
30
+ }
31
+ return args;
32
+ };
33
+
34
+ // [function]
35
+
36
+ const normalize = function (argv) {
37
+ const args = [...argv];
38
+ args[1] = args[1].endsWith(".js")
39
+ ? args[1].replace(/\.js$/u, `-${args[2]}.js`)
40
+ : args[1].concat(`-${args[2]}`);
41
+ args.splice(2, 1);
42
+ return args;
43
+ };
44
+
45
+ // [function]
46
+
47
+ const main = function (argv, load) {
48
+ const args = normalize(dispatch(argv));
49
+ pathExists(args[1], (err, exists) => {
50
+ if (err || !exists) {
51
+ log.hd("Command aborted.");
52
+ log.p(`Unable to find: ${args[1]}`);
53
+ process.exit(1);
54
+ }
55
+ const command = load(args[1]);
56
+ command.main(args);
57
+ });
58
+ };
59
+
60
+ // [main]
61
+
62
+ if (require.main === module) {
63
+ main(process.argv, require);
64
+ }
package/package.json CHANGED
@@ -1,5 +1,53 @@
1
1
  {
2
+ "bin": {
3
+ "arc": "bin/arc.js",
4
+ "arc-deploy": "bin/arc-deploy.js",
5
+ "arc-init": "bin/arc-init.js",
6
+ "arc-inspect": "bin/arc-inspect.js",
7
+ "arc-login": "bin/arc-login.js",
8
+ "arc-logout": "bin/arc-logout.js",
9
+ "arc-pack": "bin/arc-pack.js",
10
+ "arc-validate": "bin/arc-validate.js",
11
+ "arc-whoami": "bin/arc-whoami.js"
12
+ },
13
+ "dependencies": {
14
+ "@iarna/toml": "^2.2.5",
15
+ "@inquirer/prompts": "^8.5.2",
16
+ "adm-zip": "^0.5.16",
17
+ "chalk": "^4.1.2",
18
+ "degit": "^2.8.6",
19
+ "dompurify": "^3.3.1",
20
+ "dot-prop": "^6.0.1",
21
+ "fs-extra": "^11.3.2",
22
+ "image-size": "^2.0.2",
23
+ "jsdom": "^27.3.0",
24
+ "marked": "^17.0.1",
25
+ "mp4box": "^2.3.0",
26
+ "open": "^8.4.2",
27
+ "rc": "^1.2.8",
28
+ "yargs": "^17.7.2",
29
+ "zod": "^4.1.13"
30
+ },
31
+ "description": "The Arcadible command-line interface.",
32
+ "engines": {
33
+ "node": ">=24.11.1"
34
+ },
35
+ "exports": {
36
+ "./deploy": "./src/cli/deploy.js",
37
+ "./init": "./src/cli/init.js",
38
+ "./inspect": "./src/cli/inspect.js",
39
+ "./login": "./src/cli/login.js",
40
+ "./logout": "./src/cli/logout.js",
41
+ "./pack": "./src/cli/pack.js",
42
+ "./validate": "./src/cli/validate.js",
43
+ "./whoami": "./src/cli/whoami.js"
44
+ },
45
+ "keywords": [
46
+ "arcadible",
47
+ "cli"
48
+ ],
2
49
  "license": "Apache-2.0",
50
+ "main": "./src/cli/index.js",
3
51
  "name": "arcadible",
4
- "version": "0.0.1"
52
+ "version": "0.1.1"
5
53
  }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ // [function]
4
+
5
+ const main = function () {
6
+ return Promise.reject(new Error("Unimplemented command."));
7
+ };
8
+
9
+ // [export]
10
+
11
+ module.exports = main;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ // [import]
4
+
5
+ const execFile = require("node:child_process").execFile;
6
+
7
+ // [function]
8
+
9
+ const isDirty = function (root, cb) {
10
+ execFile("git", ["-C", root, "diff", "--quiet"], (err) => {
11
+ if (err) {
12
+ cb(true);
13
+ return;
14
+ }
15
+ execFile("git", ["-C", root, "diff", "--cached", "--quiet"], (err) => {
16
+ cb(Boolean(err));
17
+ });
18
+ });
19
+ };
20
+
21
+ // [export]
22
+
23
+ module.exports = { isDirty };
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+
3
+ // [import]
4
+
5
+ const execFile = require("node:child_process").execFile;
6
+
7
+ // [import]
8
+
9
+ const strs = require("../../util/strs");
10
+
11
+ // [use]
12
+
13
+ const trimWhitespace = strs.trimWhitespace;
14
+
15
+ // [declare]
16
+
17
+ const RE_TAG_EXISTS = /tag\s+'([^']+)'\s+already\s+exists/iu;
18
+
19
+ // [function]
20
+
21
+ const knownErr = function (stdErr) {
22
+ const tagExists = stdErr.match(RE_TAG_EXISTS);
23
+ if (tagExists) {
24
+ return [
25
+ `Git tag exists: ${tagExists[1]}`,
26
+ "The package version has been synchronized.",
27
+ "Try again.",
28
+ ].join("\n");
29
+ }
30
+ return stdErr;
31
+ };
32
+
33
+ // [function]
34
+
35
+ const npm = function (root, pre, preId) {
36
+ return [
37
+ "--prefix",
38
+ root,
39
+ "version",
40
+ pre ? "prerelease" : "patch",
41
+ "--preid",
42
+ preId,
43
+ "-m",
44
+ pre ? "Prerelease v%s" : "Release v%s",
45
+ ];
46
+ };
47
+
48
+ // [function]
49
+
50
+ const git = function (root) {
51
+ return ["-C", root, "push", "--follow-tags"];
52
+ };
53
+
54
+ // [function]
55
+
56
+ const main = function (root, { pre, preId }, cb) {
57
+ execFile("npm", npm(root, pre, preId), (err, stdOut, stdErr) => {
58
+ if (err) {
59
+ cb(new Error(knownErr(stdErr), { cause: err }));
60
+ return;
61
+ }
62
+ execFile("git", git(root), (err) => {
63
+ if (err) {
64
+ cb(new Error(knownErr(stdErr), { cause: err }));
65
+ return;
66
+ }
67
+ cb(null, trimWhitespace(stdOut));
68
+ });
69
+ });
70
+ };
71
+
72
+ // [export]
73
+
74
+ module.exports = main;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ // [function]
4
+
5
+ const main = function () {
6
+ return Promise.reject(new Error("Unimplemented command."));
7
+ };
8
+
9
+ // [export]
10
+
11
+ module.exports = main;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+
3
+ // [import]
4
+
5
+ const path = require("node:path");
6
+
7
+ // [import]
8
+
9
+ const degit = require("degit");
10
+ const fs = require("fs-extra");
11
+
12
+ // [use]
13
+
14
+ const pathExists = fs.pathExists;
15
+ const remove = fs.remove;
16
+ const resolve = path.resolve;
17
+
18
+ // [function]
19
+
20
+ const init = function (src, dest, { onBegin, onInfo }) {
21
+ onBegin({ dest, src });
22
+ return degit(src, { cache: false, force: true, verbose: false })
23
+ .on("info", onInfo)
24
+ .clone(dest)
25
+ .then(() => remove(resolve(dest, "LICENSE")));
26
+ };
27
+
28
+ // [function]
29
+
30
+ const main = function ({ force, project, root, template }, handler) {
31
+ const dest = resolve(root, project);
32
+ return pathExists(dest)
33
+ .then((exists) => {
34
+ if (exists && !force) {
35
+ throw new Error("Directory exists. Run with `--force` to overwrite.");
36
+ }
37
+ return init(template, dest, handler);
38
+ })
39
+ .then(() => ({ path: dest }));
40
+ };
41
+
42
+ // [export]
43
+
44
+ module.exports = main;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ // [import]
4
+
5
+ const dotProp = require("dot-prop");
6
+
7
+ // [import]
8
+
9
+ const project = require("../../parser/project");
10
+
11
+ // [function]
12
+
13
+ const inspect = function (proj, key) {
14
+ return key ? dotProp.get(proj, key, null) : proj;
15
+ };
16
+
17
+ // [function]
18
+
19
+ const main = function ({ key, root }) {
20
+ return project.parse(root).then((proj) => inspect(proj, key));
21
+ };
22
+
23
+ // [export]
24
+
25
+ module.exports = main;