arcadible 0.1.0 → 0.1.2

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 (69) hide show
  1. package/bin/arc-default.js +32 -32
  2. package/bin/arc-deploy.js +113 -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 +81 -49
  8. package/bin/arc-validate.js +115 -0
  9. package/bin/arc-whoami.js +111 -0
  10. package/bin/arc.js +20 -15
  11. package/package.json +22 -9
  12. package/src/action/deploy/tool.js +11 -0
  13. package/src/action/deploy-git/git.js +192 -0
  14. package/src/action/deploy-git/tool.js +86 -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/config/workflow.js +6 -1
  37. package/src/{manifest.js → parser/manifest.js} +5 -6
  38. package/src/{media.js → parser/media.js} +1 -1
  39. package/src/parser/pkg.js +56 -0
  40. package/src/parser/project.js +59 -0
  41. package/src/{readme.js → parser/readme.js} +25 -15
  42. package/src/prompt/project.js +10 -0
  43. package/src/prompt/starter.js +41 -0
  44. package/src/schema/game.js +38 -15
  45. package/src/schema/workflow.js +7 -5
  46. package/src/user.js +91 -0
  47. package/src/util/dom.js +10 -36
  48. package/src/util/log.js +44 -3
  49. package/src/util/md.js +2 -2
  50. package/src/util/objs.js +14 -2
  51. package/src/util/os.js +24 -0
  52. package/src/util/output.js +54 -0
  53. package/src/util/request.js +62 -0
  54. package/src/util/schema.js +25 -0
  55. package/src/util/time.js +79 -0
  56. package/bin/arc-check.js +0 -74
  57. package/npm-shrinkwrap.json +0 -988
  58. package/src/cmd/check.js +0 -26
  59. package/src/cmd/deploy.js +0 -22
  60. package/src/cmd/index.js +0 -12
  61. package/src/cmd/inspect.js +0 -26
  62. package/src/cmd/pack.js +0 -24
  63. package/src/cmd-check/index.js +0 -57
  64. package/src/cmd-deploy/index.js +0 -43
  65. package/src/cmd-inspect/index.js +0 -53
  66. package/src/cmd-pack/index.js +0 -83
  67. package/src/project.js +0 -62
  68. package/src/util/arc.js +0 -74
  69. package/src/util/git.js +0 -23
@@ -0,0 +1,127 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ // [import]
5
+
6
+ const hideBin = require("yargs/helpers").hideBin;
7
+ const open = require("open");
8
+ const yargs = require("yargs/yargs");
9
+
10
+ // [import]
11
+
12
+ const log = require("../src/util/log");
13
+ const login = require("../src/cli/login");
14
+ const pkg = require("../package.json");
15
+ const rc = require("../src/util/rc");
16
+
17
+ // [use]
18
+
19
+ const findRc = rc.findRc;
20
+
21
+ // [declare]
22
+
23
+ const CMD = "arc";
24
+ const SUBCMD = "login";
25
+
26
+ // [define]
27
+
28
+ const conf = {
29
+ browser: true,
30
+ ...findRc(CMD, SUBCMD, process.argv, ["--cwd", "-C"]),
31
+ };
32
+
33
+ // [function]
34
+
35
+ const onEnter = function (fn) {
36
+ const stdin = process.stdin;
37
+ if (!stdin.isTTY) {
38
+ return;
39
+ }
40
+ const cleanup = function () {
41
+ stdin.setRawMode(false);
42
+ stdin.pause();
43
+ stdin.removeAllListeners("data");
44
+ };
45
+ stdin.setRawMode(true);
46
+ stdin.resume();
47
+ stdin.once("data", (buf) => {
48
+ cleanup();
49
+ if (buf[0] === 3) {
50
+ process.kill(process.pid, "SIGINT");
51
+ return;
52
+ }
53
+ if (buf[0] === 13) {
54
+ fn();
55
+ }
56
+ });
57
+ };
58
+
59
+ // [function]
60
+
61
+ const handler = function ({ browser }) {
62
+ return {
63
+ onCreated({ code, url }) {
64
+ log.p(url);
65
+ log.h(code.toUpperCase());
66
+ if (browser) {
67
+ log.p("");
68
+ log.p("Press Enter to open the URL.");
69
+ onEnter(() => {
70
+ open(url).catch(() => {});
71
+ });
72
+ }
73
+ },
74
+ onPoll() {},
75
+ };
76
+ };
77
+
78
+ // [function]
79
+
80
+ const start = function (argv) {
81
+ const browser = argv.browser;
82
+ log.pnl("Starting login...");
83
+ return login({ handler: handler({ browser }) })
84
+ .then(({ profile }) => {
85
+ process.stdin.pause();
86
+ log.p("");
87
+ log.p("Logged in as:");
88
+ log.hs(profile.display_name);
89
+ })
90
+ .catch((ex) => {
91
+ process.stdin.pause();
92
+ log.hd("Login aborted.");
93
+ log.p(ex.message);
94
+ process.exit(1);
95
+ });
96
+ };
97
+
98
+ // [function]
99
+
100
+ const main = function (argv) {
101
+ return start(
102
+ yargs(hideBin(argv))
103
+ .scriptName(`${CMD} ${SUBCMD}`)
104
+ .usage("$0 [options]")
105
+ .option("browser", {
106
+ default: conf.browser,
107
+ describe: "Open a web browser automatically.",
108
+ type: "boolean",
109
+ })
110
+ .help("help")
111
+ .alias("help", "h")
112
+ .version(pkg.version)
113
+ .alias("version", "v")
114
+ .strict()
115
+ .parse(),
116
+ );
117
+ };
118
+
119
+ // [main]
120
+
121
+ if (require.main === module) {
122
+ main(process.argv);
123
+ }
124
+
125
+ // [export]
126
+
127
+ module.exports = { main };
@@ -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,92 @@ 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("Validate 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
+ }
64
+ })
65
+ .catch((ex) => {
66
+ const message = ex.message;
67
+ if (json) {
68
+ print({ error: { message } });
69
+ } else {
70
+ log.hd("Pack aborted.");
71
+ log.p(message);
72
+ }
73
+ process.exit(1);
74
+ });
45
75
  };
46
76
 
47
77
  // [function]
48
78
 
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
- });
79
+ const main = function (argv) {
80
+ return start(
81
+ yargs(hideBin(argv))
82
+ .scriptName(`${CMD} ${SUBCMD}`)
83
+ .usage("$0 [options]")
84
+ .option("output", {
85
+ alias: "o",
86
+ default: conf.output,
87
+ describe: "Set the output path.",
88
+ type: "string",
89
+ })
90
+ .option("json", {
91
+ alias: "j",
92
+ default: conf.json,
93
+ describe: "Format output as JSON.",
94
+ type: "boolean",
95
+ })
96
+ .option("quiet", {
97
+ alias: "q",
98
+ default: conf.quiet,
99
+ describe: "Output only errors.",
100
+ type: "boolean",
101
+ })
102
+ .option("cwd", {
103
+ alias: "C",
104
+ default: ".",
105
+ describe: "Set the working directory.",
106
+ type: "string",
107
+ })
108
+ .help("help")
109
+ .alias("help", "h")
110
+ .version(pkg.version)
111
+ .alias("version", "v")
112
+ .strict()
113
+ .parse(),
114
+ );
57
115
  };
58
116
 
59
- // [start]
117
+ // [main]
60
118
 
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
- );
119
+ if (require.main === module) {
120
+ main(process.argv);
121
+ }
122
+
123
+ // [export]
124
+
125
+ module.exports = { main };
@@ -0,0 +1,115 @@
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 count = issues.length;
48
+ const term = count === 1 ? "issue" : "issues";
49
+ if (json) {
50
+ print({ issues });
51
+ } else if (!quiet) {
52
+ if (count) {
53
+ log.hd(`${count} ${term} found.`);
54
+ log.p(issues.map((error) => `✗ ${error}`));
55
+ } else {
56
+ log.hs("Validated.");
57
+ }
58
+ }
59
+ process.exit(count ? 1 : 0);
60
+ })
61
+ .catch((ex) => {
62
+ const message = ex.message;
63
+ if (json) {
64
+ print({ error: { message } });
65
+ } else {
66
+ log.hd("Validate aborted.");
67
+ log.p(message);
68
+ }
69
+ process.exit(1);
70
+ });
71
+ };
72
+
73
+ // [function]
74
+
75
+ const main = function (argv) {
76
+ return start(
77
+ yargs(hideBin(argv))
78
+ .scriptName(`${CMD} ${SUBCMD}`)
79
+ .usage("$0 [options]")
80
+ .option("json", {
81
+ alias: "j",
82
+ default: conf.json,
83
+ describe: "Format output as JSON.",
84
+ type: "boolean",
85
+ })
86
+ .option("quiet", {
87
+ alias: "q",
88
+ default: conf.quiet,
89
+ describe: "Output only errors.",
90
+ type: "boolean",
91
+ })
92
+ .option("cwd", {
93
+ alias: "C",
94
+ default: ".",
95
+ describe: "Set the working directory.",
96
+ type: "string",
97
+ })
98
+ .help("help")
99
+ .alias("help", "h")
100
+ .version(pkg.version)
101
+ .alias("version", "v")
102
+ .strict()
103
+ .parse(),
104
+ );
105
+ };
106
+
107
+ // [main]
108
+
109
+ if (require.main === module) {
110
+ main(process.argv);
111
+ }
112
+
113
+ // [export]
114
+
115
+ 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,23 +1,32 @@
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",
21
+ "fast-json-stable-stringify": "^2.1.0",
15
22
  "fs-extra": "^11.3.2",
16
23
  "image-size": "^2.0.2",
17
24
  "jsdom": "^27.3.0",
18
25
  "marked": "^17.0.1",
19
26
  "mp4box": "^2.3.0",
27
+ "open": "^8.4.2",
20
28
  "rc": "^1.2.8",
29
+ "semver": "^7.7.3",
21
30
  "yargs": "^17.7.2",
22
31
  "zod": "^4.1.13"
23
32
  },
@@ -26,17 +35,21 @@
26
35
  "node": ">=24.11.1"
27
36
  },
28
37
  "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"
38
+ "./deploy": "./src/cli/deploy.js",
39
+ "./init": "./src/cli/init.js",
40
+ "./inspect": "./src/cli/inspect.js",
41
+ "./login": "./src/cli/login.js",
42
+ "./logout": "./src/cli/logout.js",
43
+ "./pack": "./src/cli/pack.js",
44
+ "./validate": "./src/cli/validate.js",
45
+ "./whoami": "./src/cli/whoami.js"
33
46
  },
34
47
  "keywords": [
35
48
  "arcadible",
36
49
  "cli"
37
50
  ],
38
51
  "license": "Apache-2.0",
39
- "main": "./src/cmd/index.js",
52
+ "main": "./src/cli/index.js",
40
53
  "name": "arcadible",
41
- "version": "0.1.0"
54
+ "version": "0.1.2"
42
55
  }