arcadible 0.1.0 → 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/bin/arc-default.js +33 -32
  2. package/bin/arc-deploy.js +73 -42
  3. package/bin/arc-init.js +196 -0
  4. package/bin/arc-inspect.js +65 -44
  5. package/bin/arc-login.js +127 -0
  6. package/bin/arc-logout.js +58 -0
  7. package/bin/arc-pack.js +82 -49
  8. package/bin/arc-validate.js +114 -0
  9. package/bin/arc-whoami.js +111 -0
  10. package/bin/arc.js +20 -15
  11. package/package.json +20 -9
  12. package/src/action/deploy/tool.js +11 -0
  13. package/src/{util/arc.js → action/deploy-git/release.js} +3 -3
  14. package/src/action/deploy-git/tool.js +11 -0
  15. package/src/action/init/tool.js +44 -0
  16. package/src/action/inspect/tool.js +25 -0
  17. package/src/action/login/flow.js +94 -0
  18. package/src/action/login/tool.js +16 -0
  19. package/src/action/logout/tool.js +15 -0
  20. package/src/action/pack/tool.js +60 -0
  21. package/src/action/validate/tool.js +39 -0
  22. package/src/action/whoami/tool.js +15 -0
  23. package/src/api.js +39 -0
  24. package/src/cli/deploy.js +17 -0
  25. package/src/cli/index.js +25 -0
  26. package/src/cli/init.js +15 -0
  27. package/src/cli/inspect.js +15 -0
  28. package/src/cli/login.js +15 -0
  29. package/src/cli/logout.js +15 -0
  30. package/src/cli/pack.js +15 -0
  31. package/src/cli/validate.js +15 -0
  32. package/src/cli/whoami.js +15 -0
  33. package/src/config/html.js +27 -0
  34. package/src/config/uri.js +14 -0
  35. package/src/config/url.js +17 -0
  36. package/src/{media.js → parser/media.js} +1 -1
  37. package/src/parser/project.js +55 -0
  38. package/src/{readme.js → parser/readme.js} +4 -4
  39. package/src/prompt/project.js +10 -0
  40. package/src/prompt/template.js +37 -0
  41. package/src/schema/game.js +20 -15
  42. package/src/schema/workflow.js +7 -5
  43. package/src/user.js +91 -0
  44. package/src/util/dom.js +10 -36
  45. package/src/util/log.js +2 -2
  46. package/src/util/md.js +2 -2
  47. package/src/util/objs.js +3 -1
  48. package/src/util/os.js +24 -0
  49. package/src/util/output.js +46 -0
  50. package/src/util/request.js +62 -0
  51. package/src/util/schema.js +25 -0
  52. package/src/util/time.js +79 -0
  53. package/bin/arc-check.js +0 -74
  54. package/npm-shrinkwrap.json +0 -988
  55. package/src/cmd/check.js +0 -26
  56. package/src/cmd/deploy.js +0 -22
  57. package/src/cmd/index.js +0 -12
  58. package/src/cmd/inspect.js +0 -26
  59. package/src/cmd/pack.js +0 -24
  60. package/src/cmd-check/index.js +0 -57
  61. package/src/cmd-deploy/index.js +0 -43
  62. package/src/cmd-inspect/index.js +0 -53
  63. package/src/cmd-pack/index.js +0 -83
  64. package/src/project.js +0 -62
  65. /package/src/{util → action/deploy-git}/git.js +0 -0
  66. /package/src/{manifest.js → parser/manifest.js} +0 -0
@@ -0,0 +1,58 @@
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 logout = require("../src/cli/logout");
13
+ const pkg = require("../package.json");
14
+
15
+ // [declare]
16
+
17
+ const CMD = "arc";
18
+ const SUBCMD = "logout";
19
+
20
+ // [function]
21
+
22
+ const start = function () {
23
+ return logout()
24
+ .then(() => {
25
+ log.hs("Logged out.");
26
+ })
27
+ .catch((ex) => {
28
+ log.hd("Logout aborted.");
29
+ log.p(ex.message);
30
+ process.exit(1);
31
+ });
32
+ };
33
+
34
+ // [function]
35
+
36
+ const main = function (argv) {
37
+ return start(
38
+ yargs(hideBin(argv))
39
+ .scriptName(`${CMD} ${SUBCMD}`)
40
+ .usage("$0 [options]")
41
+ .help("help")
42
+ .alias("help", "h")
43
+ .version(pkg.version)
44
+ .alias("version", "v")
45
+ .strict()
46
+ .parse(),
47
+ );
48
+ };
49
+
50
+ // [main]
51
+
52
+ if (require.main === module) {
53
+ main(process.argv);
54
+ }
55
+
56
+ // [export]
57
+
58
+ module.exports = { main };
package/bin/arc-pack.js CHANGED
@@ -12,15 +12,17 @@ const yargs = require("yargs/yargs");
12
12
 
13
13
  // [import]
14
14
 
15
- const pack = require("../src/cmd/pack");
15
+ const log = require("../src/util/log");
16
+ const output = require("../src/util/output");
17
+ const pack = require("../src/cli/pack");
16
18
  const pkg = require("../package.json");
17
19
  const rc = require("../src/util/rc");
20
+ const validate = require("../src/cli/validate");
18
21
 
19
22
  // [use]
20
23
 
21
- const dirname = path.dirname;
22
24
  const findRc = rc.findRc;
23
- const join = path.join;
25
+ const print = output.print;
24
26
  const resolve = path.resolve;
25
27
 
26
28
  // [declare]
@@ -32,62 +34,93 @@ const SUBCMD = "pack";
32
34
 
33
35
  const conf = {
34
36
  json: false,
35
- out: "package.zip",
37
+ output: "package.zip",
36
38
  quiet: false,
37
39
  ...findRc(CMD, SUBCMD, process.argv, ["--cwd", "-C"]),
38
40
  };
39
41
 
40
42
  // [function]
41
43
 
42
- const fixBin = function (argv) {
43
- argv[1] = join(dirname(argv[1]), CMD);
44
- return hideBin(argv);
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
+ });
45
76
  };
46
77
 
47
78
  // [function]
48
79
 
49
- const start = function (cli) {
50
- const argv = cli.parse();
51
- pack({
52
- json: argv.json,
53
- out: argv.out,
54
- quiet: argv.quiet,
55
- root: resolve(process.cwd(), argv.cwd),
56
- });
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
+ );
57
116
  };
58
117
 
59
- // [start]
118
+ // [main]
60
119
 
61
- start(
62
- yargs(fixBin(process.argv))
63
- .usage(`${CMD} ${SUBCMD} [options]`)
64
- .option("out", {
65
- alias: "o",
66
- default: conf.out,
67
- describe: "Write to the specified path.",
68
- type: "string",
69
- })
70
- .option("json", {
71
- alias: "j",
72
- default: conf.json,
73
- describe: "Format standard output in JSON.",
74
- type: "boolean",
75
- })
76
- .option("quiet", {
77
- alias: "q",
78
- default: conf.quiet,
79
- describe: "Suppress standard output and show only errors.",
80
- type: "boolean",
81
- })
82
- .option("cwd", {
83
- alias: "C",
84
- default: ".",
85
- describe: "Run in the specified path.",
86
- type: "string",
87
- })
88
- .help("help")
89
- .alias("help", "h")
90
- .version(pkg.version)
91
- .alias("version", "v")
92
- .strict(),
93
- );
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 CHANGED
@@ -20,40 +20,45 @@ const CMD = "arc";
20
20
 
21
21
  // [function]
22
22
 
23
- const fixBin = function (argv) {
23
+ const dispatch = function (argv) {
24
+ const args = [...argv];
24
25
  const subcmds = Object.keys(pkg.bin)
25
26
  .filter((key) => key !== CMD)
26
27
  .map((key) => key.slice(CMD.length + 1));
27
- if (!subcmds.includes(argv[2])) {
28
- argv.splice(2, 0, "default");
28
+ if (!subcmds.includes(args[2])) {
29
+ args.splice(2, 0, "default");
29
30
  }
30
- return argv;
31
+ return args;
31
32
  };
32
33
 
33
34
  // [function]
34
35
 
35
36
  const normalize = function (argv) {
36
- argv[1] = argv[1].endsWith(".js")
37
- ? argv[1].replace(/\.js$/u, `-${argv[2]}.js`)
38
- : argv[1].concat(`-${argv[2]}`);
39
- argv.splice(2, 1);
40
- return 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;
41
43
  };
42
44
 
43
45
  // [function]
44
46
 
45
- const start = function (argv, cb) {
46
- const args = normalize(fixBin(argv));
47
+ const main = function (argv, load) {
48
+ const args = normalize(dispatch(argv));
47
49
  pathExists(args[1], (err, exists) => {
48
50
  if (err || !exists) {
49
51
  log.hd("Command aborted.");
50
- log.pdnl(`Unable to find: ${args[1]}`);
52
+ log.p(`Unable to find: ${args[1]}`);
51
53
  process.exit(1);
52
54
  }
53
- cb(args[1]);
55
+ const command = load(args[1]);
56
+ command.main(args);
54
57
  });
55
58
  };
56
59
 
57
- // [start]
60
+ // [main]
58
61
 
59
- start(process.argv, require);
62
+ if (require.main === module) {
63
+ main(process.argv, require);
64
+ }
package/package.json CHANGED
@@ -1,22 +1,29 @@
1
1
  {
2
2
  "bin": {
3
3
  "arc": "bin/arc.js",
4
- "arc-check": "bin/arc-check.js",
5
- "arc-default": "bin/arc-default.js",
6
4
  "arc-deploy": "bin/arc-deploy.js",
5
+ "arc-init": "bin/arc-init.js",
7
6
  "arc-inspect": "bin/arc-inspect.js",
8
- "arc-pack": "bin/arc-pack.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"
9
12
  },
10
13
  "dependencies": {
11
14
  "@iarna/toml": "^2.2.5",
15
+ "@inquirer/prompts": "^8.5.2",
12
16
  "adm-zip": "^0.5.16",
13
17
  "chalk": "^4.1.2",
18
+ "degit": "^2.8.6",
14
19
  "dompurify": "^3.3.1",
20
+ "dot-prop": "^6.0.1",
15
21
  "fs-extra": "^11.3.2",
16
22
  "image-size": "^2.0.2",
17
23
  "jsdom": "^27.3.0",
18
24
  "marked": "^17.0.1",
19
25
  "mp4box": "^2.3.0",
26
+ "open": "^8.4.2",
20
27
  "rc": "^1.2.8",
21
28
  "yargs": "^17.7.2",
22
29
  "zod": "^4.1.13"
@@ -26,17 +33,21 @@
26
33
  "node": ">=24.11.1"
27
34
  },
28
35
  "exports": {
29
- "./check": "./src/cmd/check.js",
30
- "./deploy": "./src/cmd/deploy.js",
31
- "./inspect": "./src/cmd/inspect.js",
32
- "./pack": "./src/cmd/pack.js"
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"
33
44
  },
34
45
  "keywords": [
35
46
  "arcadible",
36
47
  "cli"
37
48
  ],
38
49
  "license": "Apache-2.0",
39
- "main": "./src/cmd/index.js",
50
+ "main": "./src/cli/index.js",
40
51
  "name": "arcadible",
41
- "version": "0.1.0"
52
+ "version": "0.1.1"
42
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;
@@ -6,7 +6,7 @@ const execFile = require("node:child_process").execFile;
6
6
 
7
7
  // [import]
8
8
 
9
- const strs = require("./strs");
9
+ const strs = require("../../util/strs");
10
10
 
11
11
  // [use]
12
12
 
@@ -53,7 +53,7 @@ const git = function (root) {
53
53
 
54
54
  // [function]
55
55
 
56
- const deploy = function (root, { pre, preId }, cb) {
56
+ const main = function (root, { pre, preId }, cb) {
57
57
  execFile("npm", npm(root, pre, preId), (err, stdOut, stdErr) => {
58
58
  if (err) {
59
59
  cb(new Error(knownErr(stdErr), { cause: err }));
@@ -71,4 +71,4 @@ const deploy = function (root, { pre, preId }, cb) {
71
71
 
72
72
  // [export]
73
73
 
74
- module.exports = { deploy };
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;