arcadible 0.1.20 → 0.1.21

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 (44) hide show
  1. package/bin/arc-build.js +8 -6
  2. package/bin/arc-default.js +10 -7
  3. package/bin/arc-deploy.js +17 -16
  4. package/bin/arc-init.js +12 -7
  5. package/bin/arc-inspect.js +8 -6
  6. package/bin/arc-login.js +15 -8
  7. package/bin/arc-logout.js +8 -6
  8. package/bin/arc-open.js +14 -9
  9. package/bin/arc-pack.js +10 -9
  10. package/bin/arc-play.js +13 -9
  11. package/bin/arc-validate.js +9 -7
  12. package/bin/arc-whoami.js +13 -11
  13. package/bin/arc.js +7 -5
  14. package/package.json +1 -1
  15. package/product.json +9 -0
  16. package/src/account.js +8 -7
  17. package/src/action/deploy/tool-git.js +3 -3
  18. package/src/action/deploy/tool.js +6 -6
  19. package/src/action/init/manifest.js +3 -1
  20. package/src/action/inspect/media.js +6 -1
  21. package/src/action/pack/tool.js +10 -4
  22. package/src/action/predeploy/ac.js +47 -12
  23. package/src/action/predeploy/git.js +3 -1
  24. package/src/action/predeploy/pm.js +41 -0
  25. package/src/action/predeploy/tool-git.js +25 -5
  26. package/src/action/predeploy/tool.js +14 -7
  27. package/src/api.js +9 -3
  28. package/src/cli/deploy.js +2 -2
  29. package/src/cli/predeploy.js +2 -2
  30. package/src/config/package.js +5 -0
  31. package/src/config/product.js +5 -0
  32. package/src/config/uri.js +11 -7
  33. package/src/config/url.js +6 -1
  34. package/src/config/workflow.js +9 -1
  35. package/src/parser/manifest.js +3 -1
  36. package/src/parser/media.js +3 -1
  37. package/src/parser/readme.js +3 -1
  38. package/src/phrase.js +66 -9
  39. package/src/prompt/template.js +12 -13
  40. package/src/schema/game.js +5 -2
  41. package/src/schema/workflow.js +5 -2
  42. package/src/util/request.js +7 -5
  43. package/src/util/shell.js +39 -2
  44. package/src/util/video.js +5 -5
@@ -7,10 +7,10 @@ const predeployToolGit = require("../action/predeploy/tool-git");
7
7
 
8
8
  // [function]
9
9
 
10
- const main = function ({ git, handler, session, ...conf }) {
10
+ const main = function ({ current, git, handler, ...conf }) {
11
11
  return git
12
12
  ? predeployToolGit(conf, handler)
13
- : predeployTool(session, conf, handler);
13
+ : predeployTool(current, conf, handler);
14
14
  };
15
15
 
16
16
  // [export]
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ // [export]
4
+
5
+ module.exports = require("../../package.json");
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ // [export]
4
+
5
+ module.exports = require("../../product.json");
package/src/config/uri.js CHANGED
@@ -1,18 +1,22 @@
1
1
  "use strict";
2
2
 
3
+ // [import]
4
+
5
+ const cfgproduct = require("./product");
6
+
3
7
  // [declare]
4
8
 
5
- const DOMAIN = "arcadible";
6
- const PROTOCOL = DOMAIN;
9
+ const DOMAIN = cfgproduct.domain;
10
+ const PROTOCOL = cfgproduct.protocol;
7
11
 
8
12
  // [export]
9
13
 
10
14
  module.exports = {
11
15
  HOST_APP_PLAY: `${PROTOCOL}://play`,
12
16
  HOST_APP_STORE: `${PROTOCOL}://store`,
13
- HOST_HTTP_ACCOUNT: `https://account.${DOMAIN}.com`,
14
- HOST_HTTP_API: `https://api.${DOMAIN}.com`,
15
- HOST_HTTP_DEVELOPER: `https://developer.${DOMAIN}.com`,
16
- HOST_HTTP_PLAY: `https://play.${DOMAIN}.com`,
17
- HOST_HTTP_WWW: `https://${DOMAIN}.com`,
17
+ HOST_HTTP_ACCOUNT: `https://account.${DOMAIN}`,
18
+ HOST_HTTP_API: `https://api.${DOMAIN}`,
19
+ HOST_HTTP_DEVELOPER: `https://developer.${DOMAIN}`,
20
+ HOST_HTTP_PLAY: `https://play.${DOMAIN}`,
21
+ HOST_HTTP_WWW: `https://${DOMAIN}`,
18
22
  };
package/src/config/url.js CHANGED
@@ -2,12 +2,17 @@
2
2
 
3
3
  // [import]
4
4
 
5
+ const cfgproduct = require("./product");
5
6
  const cfguri = require("./uri");
6
7
 
8
+ // [declare]
9
+
10
+ const HANDLE = cfgproduct.handle;
11
+
7
12
  // [export]
8
13
 
9
14
  module.exports = {
10
15
  GETTING_STARTED: `${cfguri.HOST_HTTP_DEVELOPER}/guides/games/getting-started`,
11
16
  LINK: `${cfguri.HOST_HTTP_ACCOUNT}/link`,
12
- MANIFEST: `${cfguri.HOST_HTTP_DEVELOPER}/references/arcadible-manifest`,
17
+ MANIFEST: `${cfguri.HOST_HTTP_DEVELOPER}/references/${HANDLE}-manifest`,
13
18
  };
@@ -1,10 +1,18 @@
1
1
  "use strict";
2
2
 
3
+ // [import]
4
+
5
+ const cfgproduct = require("./product");
6
+
7
+ // [declare]
8
+
9
+ const HANDLE = cfgproduct.handle;
10
+
3
11
  // [export]
4
12
 
5
13
  module.exports = {
6
14
  /* eslint-disable camelcase */
7
15
  build: "",
8
- deploy_dir: ".arcadible-public",
16
+ deploy_dir: `.${HANDLE}-public`,
9
17
  /* eslint-enable camelcase */
10
18
  };
@@ -10,6 +10,7 @@ const fs = require("fs-extra");
10
10
 
11
11
  // [import]
12
12
 
13
+ const cfgproduct = require("../config/product");
13
14
  const objs = require("../util/objs");
14
15
  const phrase = require("../phrase");
15
16
  const TOML = require("../util/toml");
@@ -23,7 +24,8 @@ const readFile = fs.readFile;
23
24
 
24
25
  // [declare]
25
26
 
26
- const MANIFEST = "arcadible.toml";
27
+ const HANDLE = cfgproduct.handle;
28
+ const MANIFEST = `${HANDLE}.toml`;
27
29
 
28
30
  // [function]
29
31
 
@@ -10,6 +10,7 @@ const fs = require("fs-extra");
10
10
 
11
11
  // [import]
12
12
 
13
+ const cfgproduct = require("../config/product");
13
14
  const objs = require("../util/objs");
14
15
 
15
16
  // [use]
@@ -38,7 +39,8 @@ const ART = [
38
39
 
39
40
  // [declare]
40
41
 
41
- const MEDIA = ".arcadible";
42
+ const HANDLE = cfgproduct.handle;
43
+ const MEDIA = `.${HANDLE}`;
42
44
 
43
45
  // [function]
44
46
 
@@ -10,6 +10,7 @@ const fs = require("fs-extra");
10
10
 
11
11
  // [import]
12
12
 
13
+ const cfgproduct = require("../config/product");
13
14
  const dom = require("../util/dom");
14
15
  const MD = require("../util/md");
15
16
  const objs = require("../util/objs");
@@ -26,7 +27,8 @@ const trimWhitespace = strs.trimWhitespace;
26
27
 
27
28
  // [declare]
28
29
 
29
- const README = ["arcadible.md", "README.md"];
30
+ const HANDLE = cfgproduct.handle;
31
+ const README = [`${HANDLE}.md`, "README.md"];
30
32
 
31
33
  // [function]
32
34
 
package/src/phrase.js CHANGED
@@ -1,5 +1,49 @@
1
1
  "use strict";
2
2
 
3
+ // [import]
4
+
5
+ const cfgproduct = require("./config/product");
6
+
7
+ // [declare]
8
+
9
+ const TOOL = cfgproduct.tool;
10
+
11
+ // [function]
12
+
13
+ const cmdInit = function () {
14
+ return `\`${TOOL} init\``;
15
+ };
16
+
17
+ // [function]
18
+
19
+ const cmdInspect = function () {
20
+ return `\`${TOOL} inspect\``;
21
+ };
22
+
23
+ // [function]
24
+
25
+ const cmdLogin = function () {
26
+ return `\`${TOOL} login\``;
27
+ };
28
+
29
+ // [function]
30
+
31
+ const cmdValidate = function () {
32
+ return `\`${TOOL} validate\``;
33
+ };
34
+
35
+ // [function]
36
+
37
+ const gameExists = function (idOrHandle) {
38
+ return `Game exists: ${idOrHandle}`;
39
+ };
40
+
41
+ // [function]
42
+
43
+ const gameVersionExists = function (version) {
44
+ return `Game version exists: ${version}`;
45
+ };
46
+
3
47
  // [function]
4
48
 
5
49
  const gitChangesPresent = function () {
@@ -57,7 +101,7 @@ const gitVersionExists = function () {
57
101
  // [function]
58
102
 
59
103
  const issuesFound = function (count) {
60
- return `${count} ${count === 1 ? "issue" : "issues"} found. Run \`arc validate\` for details.`;
104
+ return `${count} ${count === 1 ? "issue" : "issues"} found. Run ${cmdValidate()} for details.`;
61
105
  };
62
106
 
63
107
  // [function]
@@ -80,6 +124,12 @@ const noGameId = function () {
80
124
 
81
125
  // [function]
82
126
 
127
+ const noLockFile = function () {
128
+ return "No lock file found.";
129
+ };
130
+
131
+ // [function]
132
+
83
133
  const noProductionBuild = function () {
84
134
  return "No production build found.";
85
135
  };
@@ -87,7 +137,7 @@ const noProductionBuild = function () {
87
137
  // [function]
88
138
 
89
139
  const notLoggedIn = function () {
90
- return "Not logged in. Run `arc login` to log in.";
140
+ return `Not logged in. Run ${cmdLogin()} to log in.`;
91
141
  };
92
142
 
93
143
  // [function]
@@ -128,25 +178,31 @@ const timedOut = function () {
128
178
 
129
179
  // [function]
130
180
 
131
- const unableToParse = function (file, message) {
132
- return `Unable to parse ${file}: ${message}`;
181
+ const unableToFind = function (file) {
182
+ return `Unable to find: ${file}`;
133
183
  };
134
184
 
135
185
  // [function]
136
186
 
137
- const uploadFailed = function (status) {
138
- return `Upload failed with status ${status}.`;
187
+ const unableToParse = function (file, message) {
188
+ return `Unable to parse ${file}: ${message}`;
139
189
  };
140
190
 
141
191
  // [function]
142
192
 
143
- const versionExists = function (version) {
144
- return `Version 'v${version}' already exists.`;
193
+ const uploadFailed = function (status) {
194
+ return `Upload failed with status ${status}.`;
145
195
  };
146
196
 
147
197
  // [export]
148
198
 
149
199
  module.exports = {
200
+ cmdInit,
201
+ cmdInspect,
202
+ cmdLogin,
203
+ cmdValidate,
204
+ gameExists,
205
+ gameVersionExists,
150
206
  gitChangesPresent,
151
207
  gitRemoteMissing,
152
208
  gitRepoMissing,
@@ -157,6 +213,7 @@ module.exports = {
157
213
  loginExpired,
158
214
  loginFailed,
159
215
  noGameId,
216
+ noLockFile,
160
217
  noProductionBuild,
161
218
  noVideoMetadata,
162
219
  noVideoTrack,
@@ -165,7 +222,7 @@ module.exports = {
165
222
  packageFileMissing,
166
223
  packageTooLarge,
167
224
  timedOut,
225
+ unableToFind,
168
226
  unableToParse,
169
227
  uploadFailed,
170
- versionExists,
171
228
  };
@@ -1,9 +1,13 @@
1
1
  "use strict";
2
2
 
3
+ // [import]
4
+
5
+ const cfgproduct = require("../config/product");
6
+
3
7
  // [declare]
4
8
 
5
- const OWNER = "arcadible";
6
- const REPO = "starter";
9
+ const HANDLE = cfgproduct.handle;
10
+ const STARTER = `${HANDLE}/starter`;
7
11
 
8
12
  // [export]
9
13
 
@@ -11,37 +15,32 @@ module.exports = {
11
15
  select: {
12
16
  choices: [
13
17
  {
14
- alias: "blank",
15
18
  description: "Blank JavaScript starter.",
16
19
  name: "Blank",
17
- value: `${OWNER}/${REPO}`,
20
+ value: STARTER,
18
21
  },
19
22
  {
20
- alias: "threejs",
21
23
  description: "Three.js starter.",
22
24
  name: "Three.js",
23
- value: `${OWNER}/${REPO}-threejs`,
25
+ value: `${STARTER}-threejs`,
24
26
  },
25
27
  {
26
- alias: "phaser",
27
28
  description: "Phaser starter.",
28
29
  name: "Phaser",
29
- value: `${OWNER}/${REPO}-phaser`,
30
+ value: `${STARTER}-phaser`,
30
31
  },
31
32
  {
32
- alias: "pixijs",
33
33
  description: "PixiJS starter.",
34
34
  name: "PixiJS",
35
- value: `${OWNER}/${REPO}-pixijs`,
35
+ value: `${STARTER}-pixijs`,
36
36
  },
37
37
  {
38
- alias: "babylonjs",
39
38
  description: "Babylon.js starter.",
40
39
  name: "Babylon.js",
41
- value: `${OWNER}/${REPO}-babylonjs`,
40
+ value: `${STARTER}-babylonjs`,
42
41
  },
43
42
  ],
44
- default: `${OWNER}/${REPO}`,
43
+ default: STARTER,
45
44
  message: "Template",
46
45
  },
47
46
  };
@@ -13,10 +13,12 @@ const cfggenre = require("../config/genre");
13
13
  const cfghtml = require("../config/html");
14
14
  const cfginput = require("../config/input");
15
15
  const cfgorientation = require("../config/orientation");
16
+ const cfgproduct = require("../config/product");
16
17
  const cfgurl = require("../config/url");
17
18
  const cfgvisibility = require("../config/visibility");
18
19
  const check = require("./check/game");
19
20
  const dom = require("../util/dom");
21
+ const phrase = require("../phrase");
20
22
  const size = require("../util/size");
21
23
  const strs = require("../util/strs");
22
24
 
@@ -34,7 +36,8 @@ const videoCheck = check.video;
34
36
 
35
37
  // [declare]
36
38
 
37
- const MEDIA = ".arcadible";
39
+ const HANDLE = cfgproduct.handle;
40
+ const MEDIA = `.${HANDLE}`;
38
41
 
39
42
  // [function]
40
43
 
@@ -305,7 +308,7 @@ const zId = function () {
305
308
  .string(
306
309
  message(field, [
307
310
  "Must be defined.",
308
- "Run `arc init` to generate a new game ID.",
311
+ `Run ${phrase.cmdInit()} to generate a new game ID.`,
309
312
  ]),
310
313
  )
311
314
  .uuid(message(field, ["Must be a valid UUID."]))
@@ -7,8 +7,10 @@ const z = require("zod");
7
7
 
8
8
  // [import]
9
9
 
10
+ const cfgproduct = require("../config/product");
10
11
  const cfgurl = require("../config/url");
11
12
  const check = require("./check/workflow");
13
+ const phrase = require("../phrase");
12
14
  const strs = require("../util/strs");
13
15
 
14
16
  // [use]
@@ -21,7 +23,8 @@ const isReservedCheck = check.isReserved;
21
23
 
22
24
  // [declare]
23
25
 
24
- const MEDIA = ".arcadible";
26
+ const HANDLE = cfgproduct.handle;
27
+ const MEDIA = `.${HANDLE}`;
25
28
 
26
29
  // [function]
27
30
 
@@ -71,7 +74,7 @@ const zDeployDir = function (root, { build }) {
71
74
  (file) => build || existsCheck(root, file),
72
75
  message(field, [
73
76
  "Must exist when no build step is defined.",
74
- "Run `arc inspect` for details.",
77
+ `Run ${phrase.cmdInspect()} for details.`,
75
78
  ]),
76
79
  );
77
80
  };
@@ -2,8 +2,9 @@
2
2
 
3
3
  // [import]
4
4
 
5
+ const cfgpackage = require("../config/package");
6
+ const cfgproduct = require("../config/product");
5
7
  const http = require("./http");
6
- const pkg = require("../../package.json");
7
8
 
8
9
  // [use]
9
10
 
@@ -11,8 +12,9 @@ const HttpError = http.HttpError;
11
12
 
12
13
  // [declare]
13
14
 
14
- const CLIENT_ID = "cli";
15
- const CLIENT_VERSION = pkg.version;
15
+ const CLIENT = cfgproduct.client;
16
+ const ID = cfgproduct.id;
17
+ const VERSION = cfgpackage.version;
16
18
 
17
19
  // [function]
18
20
 
@@ -29,8 +31,8 @@ const parse = function (resp) {
29
31
 
30
32
  const send = function (method, url, form, { token } = {}) {
31
33
  const headers = [
32
- ["X-Arcadible-Client-Id", CLIENT_ID],
33
- ["X-Arcadible-Client-Version", CLIENT_VERSION],
34
+ [`X-${CLIENT}-Client-Id`, ID],
35
+ [`X-${CLIENT}-Client-Version`, VERSION],
34
36
  ];
35
37
  if (token) {
36
38
  headers.push(["Authorization", `Bearer ${token}`]);
package/src/util/shell.js CHANGED
@@ -2,12 +2,49 @@
2
2
 
3
3
  // [import]
4
4
 
5
+ const cp = require("node:child_process");
6
+
7
+ // [import]
8
+
5
9
  const open = require("open");
6
10
 
11
+ // [use]
12
+
13
+ const execFile = cp.execFile;
14
+
15
+ // [function]
16
+
17
+ const canLaunch = function (scheme) {
18
+ return new Promise((resolve) => {
19
+ switch (process.platform) {
20
+ case "darwin":
21
+ execFile("open", ["-Ra", scheme], (err) => resolve(!err));
22
+ break;
23
+ case "win32":
24
+ execFile("reg", ["query", `HKCR\\${scheme}`], (err) => resolve(!err));
25
+ break;
26
+ case "linux":
27
+ execFile(
28
+ "xdg-mime",
29
+ ["query", "default", `x-scheme-handler/${scheme}`],
30
+ (err, stdout) => resolve(!err && Boolean(stdout.trim())),
31
+ );
32
+ break;
33
+ default:
34
+ resolve(false);
35
+ }
36
+ });
37
+ };
38
+
7
39
  // [function]
8
40
 
9
- const launch = function (uri) {
10
- open(uri).catch(() => {});
41
+ const launch = function (uri, fallback) {
42
+ const scheme = new URL(uri).protocol.slice(0, -1);
43
+ return scheme === "http" || scheme === "https"
44
+ ? open(uri).catch(() => {})
45
+ : canLaunch(scheme)
46
+ .then((can) => (can ? open(uri) : fallback && open(fallback)))
47
+ .catch(() => {});
11
48
  };
12
49
 
13
50
  // [export]
package/src/util/video.js CHANGED
@@ -46,12 +46,12 @@ const checkSize = function (file, maxSize) {
46
46
  const readMp4 = function (file) {
47
47
  const data = readFileSync(file);
48
48
  const mp4 = createFile();
49
- let error = null;
49
+ let err = null;
50
50
  let video = null;
51
51
  mp4.onReady = (info) => {
52
52
  const track = info.tracks.find((t) => t.video);
53
53
  if (!track?.video) {
54
- error = new Error(phrase.noVideoTrack());
54
+ err = new Error(phrase.noVideoTrack());
55
55
  return;
56
56
  }
57
57
  video = {
@@ -61,7 +61,7 @@ const readMp4 = function (file) {
61
61
  };
62
62
  };
63
63
  mp4.onError = (mod, msg) => {
64
- error = new Error(msg);
64
+ err = new Error(msg);
65
65
  };
66
66
  const buffer = data.buffer.slice(
67
67
  data.byteOffset,
@@ -70,8 +70,8 @@ const readMp4 = function (file) {
70
70
  buffer.fileStart = 0;
71
71
  mp4.appendBuffer(buffer);
72
72
  mp4.flush();
73
- if (error) {
74
- throw error;
73
+ if (err) {
74
+ throw err;
75
75
  }
76
76
  if (!video) {
77
77
  throw new Error(phrase.noVideoMetadata());