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,15 @@
1
+ "use strict";
2
+
3
+ // [import]
4
+
5
+ const inspectTool = require("../action/inspect/tool");
6
+
7
+ // [function]
8
+
9
+ const main = function (conf) {
10
+ return inspectTool(conf);
11
+ };
12
+
13
+ // [export]
14
+
15
+ module.exports = main;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ // [import]
4
+
5
+ const loginTool = require("../action/login/tool");
6
+
7
+ // [function]
8
+
9
+ const main = function ({ handler, ...conf }) {
10
+ return loginTool(conf, handler);
11
+ };
12
+
13
+ // [export]
14
+
15
+ module.exports = main;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ // [import]
4
+
5
+ const logoutTool = require("../action/logout/tool");
6
+
7
+ // [function]
8
+
9
+ const main = function (conf) {
10
+ return logoutTool(conf);
11
+ };
12
+
13
+ // [export]
14
+
15
+ module.exports = main;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ // [import]
4
+
5
+ const packTool = require("../action/pack/tool");
6
+
7
+ // [function]
8
+
9
+ const main = function (conf) {
10
+ return packTool(conf);
11
+ };
12
+
13
+ // [export]
14
+
15
+ module.exports = main;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ // [import]
4
+
5
+ const validateTool = require("../action/validate/tool");
6
+
7
+ // [function]
8
+
9
+ const main = function (conf) {
10
+ return validateTool(conf);
11
+ };
12
+
13
+ // [export]
14
+
15
+ module.exports = main;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ // [import]
4
+
5
+ const whoamiTool = require("../action/whoami/tool");
6
+
7
+ // [function]
8
+
9
+ const main = function ({ handler, ...conf }) {
10
+ return whoamiTool(conf, handler);
11
+ };
12
+
13
+ // [export]
14
+
15
+ module.exports = main;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ // [export]
4
+
5
+ module.exports = {
6
+ ALLOWED_ATTR: ["href", "target", "rel", "src", "alt", "title"],
7
+ ALLOWED_TAGS: [
8
+ "h3",
9
+ "h4",
10
+ "h5",
11
+ "h6",
12
+ "hr",
13
+ "p",
14
+ "ul",
15
+ "ol",
16
+ "li",
17
+ "pre",
18
+ "img",
19
+ "a",
20
+ "code",
21
+ "strong",
22
+ "b",
23
+ "em",
24
+ "i",
25
+ "br",
26
+ ],
27
+ };
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ // [declare]
4
+
5
+ const SLD = "arcadible";
6
+
7
+ // [export]
8
+
9
+ module.exports = {
10
+ HOST_HTTP_ACCOUNT: `https://account.${SLD}.com`,
11
+ HOST_HTTP_API: `https://api.${SLD}.com`,
12
+ HOST_HTTP_DEVELOPER: `https://developer.${SLD}.com`,
13
+ HOST_HTTP_WWW: `https://${SLD}.com`,
14
+ };
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ // [import]
4
+
5
+ const cfguri = require("./uri");
6
+
7
+ // [declare]
8
+
9
+ const SLD = "arcadible";
10
+
11
+ // [export]
12
+
13
+ module.exports = {
14
+ GETTING_STARTED: `${cfguri.HOST_HTTP_DEVELOPER}/guides/games/getting-started`,
15
+ LINK: `${cfguri.HOST_HTTP_ACCOUNT}/link`,
16
+ MANIFEST: `${cfguri.HOST_HTTP_DEVELOPER}/references/${SLD}-manifest`,
17
+ };
@@ -2,4 +2,9 @@
2
2
 
3
3
  // [export]
4
4
 
5
- module.exports = {};
5
+ module.exports = {
6
+ /* eslint-disable camelcase */
7
+ deploy_dir: ".arcadible-public",
8
+ skip_build: false,
9
+ /* eslint-enable camelcase */
10
+ };
@@ -12,6 +12,7 @@ const TOML = require("@iarna/toml");
12
12
  // [use]
13
13
 
14
14
  const join = path.join;
15
+ const pathExists = fs.pathExists;
15
16
  const readFile = fs.readFile;
16
17
 
17
18
  // [declare]
@@ -33,12 +34,10 @@ const parseToml = function (buf) {
33
34
  // [function]
34
35
 
35
36
  const parse = function (root) {
36
- return new Promise((resolve, reject) => {
37
- readFile(join(root, MANIFEST), "utf8")
38
- .then(parseToml)
39
- .then(resolve)
40
- .catch(reject);
41
- });
37
+ const file = join(root, MANIFEST);
38
+ return pathExists(file)
39
+ .then((exists) => (exists ? readFile(file, "utf8") : null))
40
+ .then((buf) => (buf === null ? {} : parseToml(buf)));
42
41
  };
43
42
 
44
43
  // [export]
@@ -10,7 +10,7 @@ const fs = require("fs-extra");
10
10
 
11
11
  // [import]
12
12
 
13
- const objs = require("./util/objs");
13
+ const objs = require("../util/objs");
14
14
 
15
15
  // [use]
16
16
 
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+
3
+ // [import]
4
+
5
+ const path = require("node:path");
6
+
7
+ // [import]
8
+
9
+ const fs = require("fs-extra");
10
+
11
+ // [use]
12
+
13
+ const join = path.join;
14
+ const pathExists = fs.pathExists;
15
+ const readFile = fs.readFile;
16
+
17
+ // [declare]
18
+
19
+ const PACKAGE = "package.json";
20
+
21
+ // [function]
22
+
23
+ const parseJson = function (buf) {
24
+ try {
25
+ return JSON.parse(buf);
26
+ } catch (ex) {
27
+ throw new Error(`Unable to parse ${PACKAGE}: ${ex.message}`, {
28
+ cause: ex,
29
+ });
30
+ }
31
+ };
32
+
33
+ // [function]
34
+
35
+ const extract = function (pkg) {
36
+ const game = { version: pkg.version || null };
37
+ return Object.fromEntries(
38
+ Object.entries({ game }).filter(([, value]) =>
39
+ Object.values(value).some(Boolean),
40
+ ),
41
+ );
42
+ };
43
+
44
+ // [function]
45
+
46
+ const parse = function (root) {
47
+ const file = join(root, PACKAGE);
48
+ return pathExists(file)
49
+ .then((exists) => (exists ? readFile(file, "utf8") : null))
50
+ .then((buf) => (buf === null ? {} : parseJson(buf)))
51
+ .then((pkg) => (Object.keys(pkg).length ? extract(pkg) : {}));
52
+ };
53
+
54
+ // [export]
55
+
56
+ module.exports = { parse };
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+
3
+ // [import]
4
+
5
+ const cfggame = require("../config/game");
6
+ const cfgworkflow = require("../config/workflow");
7
+ const manifest = require("./manifest");
8
+ const media = require("./media");
9
+ const pkg = require("./pkg");
10
+ const promise = require("../util/promise");
11
+ const readme = require("./readme");
12
+
13
+ // [function]
14
+
15
+ const configGame = function (readmeGame, mediaGame, pkgGame, manifestGame) {
16
+ return {
17
+ ...cfggame,
18
+ ...(readmeGame || {}),
19
+ ...(mediaGame || {}),
20
+ ...(pkgGame || {}),
21
+ ...(manifestGame || {}),
22
+ };
23
+ };
24
+
25
+ // [function]
26
+
27
+ const configWorkflow = function (manifestWorkflow) {
28
+ return {
29
+ ...cfgworkflow,
30
+ ...(manifestWorkflow || {}),
31
+ };
32
+ };
33
+
34
+ // [function]
35
+
36
+ const parse = function (root) {
37
+ const parsers = [
38
+ () => manifest.parse(root),
39
+ () => media.parse(root),
40
+ () => pkg.parse(root),
41
+ () => readme.parse(root),
42
+ ];
43
+ return promise
44
+ .serial(parsers)
45
+ .then(([manifestData, mediaData, pkgData, readmeData]) => {
46
+ const game = configGame(
47
+ readmeData.game,
48
+ mediaData.game,
49
+ pkgData.game,
50
+ manifestData.game,
51
+ );
52
+ const workflow = configWorkflow(manifestData.workflow);
53
+ return { game, workflow };
54
+ });
55
+ };
56
+
57
+ // [export]
58
+
59
+ module.exports = { parse };
@@ -10,21 +10,22 @@ const fs = require("fs-extra");
10
10
 
11
11
  // [import]
12
12
 
13
- const dom = require("./util/dom");
14
- const MD = require("./util/md");
15
- const objs = require("./util/objs");
16
- const strs = require("./util/strs");
13
+ const dom = require("../util/dom");
14
+ const MD = require("../util/md");
15
+ const objs = require("../util/objs");
16
+ const strs = require("../util/strs");
17
17
 
18
18
  // [use]
19
19
 
20
20
  const join = path.join;
21
+ const pathExists = fs.pathExists;
21
22
  const pruneEmpty = objs.pruneEmpty;
22
23
  const readFile = fs.readFile;
23
24
  const trimWhitespace = strs.trimWhitespace;
24
25
 
25
26
  // [declare]
26
27
 
27
- const README = "README.md";
28
+ const README = ["arcadible.md", "README.md"];
28
29
 
29
30
  // [function]
30
31
 
@@ -118,25 +119,34 @@ const extract = function (html) {
118
119
 
119
120
  // [function]
120
121
 
121
- const parseReadme = function (buf) {
122
+ const parseReadme = function (buf, file) {
122
123
  try {
123
124
  return extract(MD.parse(buf));
124
125
  } catch (ex) {
125
- throw new Error(`Unable to parse ${README}: ${ex.message}`, { cause: ex });
126
+ throw new Error(`Unable to parse ${file}: ${ex.message}`, {
127
+ cause: ex,
128
+ });
126
129
  }
127
130
  };
128
131
 
129
132
  // [function]
130
133
 
134
+ const findReadme = function (root) {
135
+ return Promise.all(
136
+ README.map((file) =>
137
+ pathExists(join(root, file)).then((exists) => (exists ? file : null)),
138
+ ),
139
+ ).then((files) => files.find(Boolean) || null);
140
+ };
141
+
142
+ // [function]
143
+
131
144
  const parse = function (root) {
132
- return new Promise((resolve, reject) => {
133
- readFile(join(root, README), "utf8")
134
- .then(parseReadme)
135
- .then(pruneEmpty)
136
- .then((game) => ({ game }))
137
- .then(resolve)
138
- .catch(reject);
139
- });
145
+ return findReadme(root)
146
+ .then((file) => (file ? readFile(join(root, file), "utf8") : null))
147
+ .then((buf) => (buf === null ? null : parseReadme(buf)))
148
+ .then(pruneEmpty)
149
+ .then((game) => ({ game: game || null }));
140
150
  };
141
151
 
142
152
  // [export]
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ // [export]
4
+
5
+ module.exports = {
6
+ input: {
7
+ default: ".",
8
+ message: "Project",
9
+ },
10
+ };
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+
3
+ // [declare]
4
+
5
+ const REPO = "arcadible";
6
+
7
+ // [export]
8
+
9
+ module.exports = {
10
+ select: {
11
+ choices: [
12
+ {
13
+ description: "Blank starter template.",
14
+ name: "Blank",
15
+ value: `${REPO}/starter`,
16
+ },
17
+ {
18
+ description: "Three.js starter template.",
19
+ name: "Three.js",
20
+ value: `${REPO}/starter-threejs`,
21
+ },
22
+ {
23
+ description: "Phaser starter template.",
24
+ name: "Phaser",
25
+ value: `${REPO}/starter-phaser`,
26
+ },
27
+ {
28
+ description: "PixiJS starter template.",
29
+ name: "PixiJS",
30
+ value: `${REPO}/starter-pixijs`,
31
+ },
32
+ {
33
+ description: "Babylon.js starter template.",
34
+ name: "Babylon.js",
35
+ value: `${REPO}/starter-babylonjs`,
36
+ },
37
+ ],
38
+ default: `${REPO}/starter`,
39
+ message: "Starter",
40
+ },
41
+ };
@@ -3,23 +3,28 @@
3
3
  // [import]
4
4
 
5
5
  const chalk = require("chalk");
6
+ const semver = require("semver");
6
7
  const z = require("zod");
7
8
 
8
9
  // [import]
9
10
 
10
- const audience = require("../config/audience");
11
+ const cfgaudience = require("../config/audience");
12
+ const cfggenre = require("../config/genre");
13
+ const cfghtml = require("../config/html");
14
+ const cfginput = require("../config/input");
15
+ const cfgorientation = require("../config/orientation");
16
+ const cfgurl = require("../config/url");
17
+ const cfgvisibility = require("../config/visibility");
11
18
  const dom = require("../util/dom");
12
- const genre = require("../config/genre");
13
- const input = require("../config/input");
14
- const orientation = require("../config/orientation");
15
- const visibility = require("../config/visibility");
19
+
20
+ // [use]
21
+
22
+ const validSemver = semver.valid;
16
23
 
17
24
  // [function]
18
25
 
19
26
  const reference = function (field) {
20
- return chalk.cyan.underline(
21
- `https://developer.arcadible.com/references/arcadible-manifest#${field}`,
22
- );
27
+ return chalk.cyan.underline(`${cfgurl.MANIFEST}#${field}`);
23
28
  };
24
29
 
25
30
  // [function]
@@ -93,7 +98,7 @@ const zYouTube = function () {
93
98
 
94
99
  const zAudience = function () {
95
100
  // const field = "game.audience";
96
- return z.optional(z.enum(audience));
101
+ return z.optional(z.enum(cfgaudience));
97
102
  };
98
103
 
99
104
  // [function]
@@ -141,7 +146,12 @@ const zDescription = function () {
141
146
  .min(1)
142
147
  .max(4000)
143
148
  .refine(
144
- (html) => html === dom.sanitizeAfm(html),
149
+ (str) =>
150
+ str ===
151
+ dom.sanitize(str, {
152
+ ALLOWED_ATTR: cfghtml.ALLOWED_ATTR,
153
+ ALLOWED_TAGS: cfghtml.ALLOWED_TAGS,
154
+ }),
145
155
  message(field, "Contains invalid elements."),
146
156
  ),
147
157
  );
@@ -158,7 +168,7 @@ const zGallery = function () {
158
168
 
159
169
  const zGenres = function () {
160
170
  // const field = "game.genres";
161
- return z.optional(z.array(z.enum(genre)).max(3));
171
+ return z.optional(z.array(z.enum(cfggenre)).max(3));
162
172
  };
163
173
 
164
174
  // [function]
@@ -193,14 +203,14 @@ const zIconVideo = function () {
193
203
 
194
204
  const zInputs = function () {
195
205
  // const field = "game.inputs";
196
- return z.optional(z.array(z.enum(input)).max(3));
206
+ return z.optional(z.array(z.enum(cfginput)).max(3));
197
207
  };
198
208
 
199
209
  // [function]
200
210
 
201
211
  const zOrientation = function () {
202
212
  // const field = "game.orientation";
203
- return z.optional(z.enum(orientation));
213
+ return z.optional(z.enum(cfgorientation));
204
214
  };
205
215
 
206
216
  // [function]
@@ -262,9 +272,21 @@ const zTrailer = function () {
262
272
 
263
273
  // [function]
264
274
 
275
+ const zVersion = function () {
276
+ const field = "game.version";
277
+ return z
278
+ .string()
279
+ .refine(
280
+ (value) => validSemver(value) !== null,
281
+ message(field, "Must be a valid semver."),
282
+ );
283
+ };
284
+
285
+ // [function]
286
+
265
287
  const zVisibility = function () {
266
288
  // const field = "game.visibility";
267
- return z.optional(z.enum(visibility));
289
+ return z.optional(z.enum(cfgvisibility));
268
290
  };
269
291
 
270
292
  // [function]
@@ -283,7 +305,7 @@ const zWordmarkAnimated = function () {
283
305
 
284
306
  // [function]
285
307
 
286
- const main = function (root) {
308
+ const main = function (value, { root }) {
287
309
  /* eslint-disable camelcase */
288
310
  return z.object({
289
311
  audience: zAudience(),
@@ -307,6 +329,7 @@ const main = function (root) {
307
329
  tagline: zTagline(),
308
330
  title: zTitle(),
309
331
  trailer: zTrailer(),
332
+ version: zVersion(),
310
333
  visibility: zVisibility(),
311
334
  wordmark: zWordmark(root),
312
335
  wordmark_animated: zWordmarkAnimated(root),
@@ -10,6 +10,10 @@ const chalk = require("chalk");
10
10
  const fs = require("fs-extra");
11
11
  const z = require("zod");
12
12
 
13
+ // [import]
14
+
15
+ const cfgurl = require("../config/url");
16
+
13
17
  // [use]
14
18
 
15
19
  const isAbsolute = path.isAbsolute;
@@ -24,9 +28,7 @@ const MEDIA = ".arcadible";
24
28
  // [function]
25
29
 
26
30
  const reference = function (field) {
27
- return chalk.cyan.underline(
28
- `https://developer.arcadible.com/references/arcadible-manifest#${field}`,
29
- );
31
+ return chalk.cyan.underline(`${cfgurl.MANIFEST}#${field}`);
30
32
  };
31
33
 
32
34
  // [function]
@@ -103,10 +105,10 @@ const zSkipBuild = function () {
103
105
 
104
106
  // [function]
105
107
 
106
- const main = function (root, workflow) {
108
+ const main = function (value, { root }) {
107
109
  /* eslint-disable camelcase */
108
110
  return z.object({
109
- deploy_dir: zDeployDir(root, workflow),
111
+ deploy_dir: zDeployDir(root, value),
110
112
  skip_build: zSkipBuild(),
111
113
  });
112
114
  /* eslint-enable camelcase */