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.
- package/README.md +3 -0
- package/bin/arc-default.js +57 -0
- package/bin/arc-deploy.js +117 -0
- package/bin/arc-init.js +196 -0
- package/bin/arc-inspect.js +107 -0
- package/bin/arc-login.js +127 -0
- package/bin/arc-logout.js +58 -0
- package/bin/arc-pack.js +126 -0
- package/bin/arc-validate.js +114 -0
- package/bin/arc-whoami.js +111 -0
- package/bin/arc.js +64 -0
- package/package.json +49 -1
- package/src/action/deploy/tool.js +11 -0
- package/src/action/deploy-git/git.js +23 -0
- package/src/action/deploy-git/release.js +74 -0
- package/src/action/deploy-git/tool.js +11 -0
- package/src/action/init/tool.js +44 -0
- package/src/action/inspect/tool.js +25 -0
- package/src/action/login/flow.js +94 -0
- package/src/action/login/tool.js +16 -0
- package/src/action/logout/tool.js +15 -0
- package/src/action/pack/tool.js +60 -0
- package/src/action/validate/tool.js +39 -0
- package/src/action/whoami/tool.js +15 -0
- package/src/api.js +39 -0
- package/src/cli/deploy.js +17 -0
- package/src/cli/index.js +25 -0
- package/src/cli/init.js +15 -0
- package/src/cli/inspect.js +15 -0
- package/src/cli/login.js +15 -0
- package/src/cli/logout.js +15 -0
- package/src/cli/pack.js +15 -0
- package/src/cli/validate.js +15 -0
- package/src/cli/whoami.js +15 -0
- package/src/config/audience.js +5 -0
- package/src/config/game.js +5 -0
- package/src/config/genre.js +22 -0
- package/src/config/html.js +27 -0
- package/src/config/input.js +14 -0
- package/src/config/orientation.js +14 -0
- package/src/config/uri.js +14 -0
- package/src/config/url.js +17 -0
- package/src/config/visibility.js +5 -0
- package/src/config/workflow.js +5 -0
- package/src/parser/manifest.js +46 -0
- package/src/parser/media.js +96 -0
- package/src/parser/project.js +55 -0
- package/src/parser/readme.js +144 -0
- package/src/prompt/project.js +10 -0
- package/src/prompt/template.js +37 -0
- package/src/schema/game.js +324 -0
- package/src/schema/workflow.js +119 -0
- package/src/user.js +91 -0
- package/src/util/dom.js +27 -0
- package/src/util/log.js +99 -0
- package/src/util/md.js +24 -0
- package/src/util/objs.js +28 -0
- package/src/util/os.js +24 -0
- package/src/util/output.js +46 -0
- package/src/util/promise.js +29 -0
- package/src/util/rc.js +41 -0
- package/src/util/request.js +62 -0
- package/src/util/schema.js +25 -0
- package/src/util/strs.js +21 -0
- package/src/util/time.js +79 -0
- package/src/util/zip.js +59 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// [import]
|
|
4
|
+
|
|
5
|
+
const crypto = require("node:crypto");
|
|
6
|
+
|
|
7
|
+
// [import]
|
|
8
|
+
|
|
9
|
+
const api = require("../../api");
|
|
10
|
+
const cfgurl = require("../../config/url");
|
|
11
|
+
const time = require("../../util/time");
|
|
12
|
+
|
|
13
|
+
// [use]
|
|
14
|
+
|
|
15
|
+
const randomUUID = crypto.randomUUID;
|
|
16
|
+
|
|
17
|
+
// [function]
|
|
18
|
+
|
|
19
|
+
const postFlow = function ({ expiresAt, token, type }) {
|
|
20
|
+
const form = new FormData();
|
|
21
|
+
form.append("expires_at", expiresAt.toISOString());
|
|
22
|
+
form.append("token", token);
|
|
23
|
+
form.append("type", type);
|
|
24
|
+
return api.postFlow(form);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// [function]
|
|
28
|
+
|
|
29
|
+
const getFlow = function ({ id, token }) {
|
|
30
|
+
return api.getFlow(id, { token });
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
// [function]
|
|
34
|
+
|
|
35
|
+
const createFlow = function ({ expiresAt, token, type }, onCreated) {
|
|
36
|
+
return postFlow({ expiresAt, token, type }).then(({ code, id }) => {
|
|
37
|
+
if (onCreated) {
|
|
38
|
+
onCreated({ code, url: cfgurl.LINK });
|
|
39
|
+
}
|
|
40
|
+
return { id };
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
// [function]
|
|
45
|
+
|
|
46
|
+
const pollFlow = function ({ id, token }, onPoll) {
|
|
47
|
+
return getFlow({ id, token }).then(({ data, status }) => {
|
|
48
|
+
if (onPoll) {
|
|
49
|
+
onPoll({ status });
|
|
50
|
+
}
|
|
51
|
+
switch (status) {
|
|
52
|
+
case "pending":
|
|
53
|
+
return null;
|
|
54
|
+
case "completed":
|
|
55
|
+
return data;
|
|
56
|
+
case "failed":
|
|
57
|
+
throw new Error("Login flow failed.");
|
|
58
|
+
default:
|
|
59
|
+
throw new Error("Login flow expired.");
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
// [function]
|
|
65
|
+
|
|
66
|
+
const main = function ({ onCreated, onPoll }) {
|
|
67
|
+
const expiresAt = new Date(Date.now() + time.m(5));
|
|
68
|
+
const token = randomUUID();
|
|
69
|
+
return createFlow(
|
|
70
|
+
{
|
|
71
|
+
expiresAt,
|
|
72
|
+
token,
|
|
73
|
+
type: "cli-login",
|
|
74
|
+
},
|
|
75
|
+
onCreated,
|
|
76
|
+
).then(({ id }) => {
|
|
77
|
+
const timeout = Math.max(0, expiresAt.getTime() - Date.now() - time.s(15));
|
|
78
|
+
return time.poll(
|
|
79
|
+
(flow) => pollFlow(flow, onPoll),
|
|
80
|
+
{ id, token },
|
|
81
|
+
{
|
|
82
|
+
delay: time.s(3),
|
|
83
|
+
factor: 2,
|
|
84
|
+
interval: time.s(30),
|
|
85
|
+
maxDelay: time.s(15),
|
|
86
|
+
timeout,
|
|
87
|
+
},
|
|
88
|
+
);
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
// [export]
|
|
93
|
+
|
|
94
|
+
module.exports = main;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// [import]
|
|
4
|
+
|
|
5
|
+
const flow = require("./flow");
|
|
6
|
+
const user = require("../../user");
|
|
7
|
+
|
|
8
|
+
// [function]
|
|
9
|
+
|
|
10
|
+
const main = function (conf, handler) {
|
|
11
|
+
return flow(handler).then(user.save);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
// [export]
|
|
15
|
+
|
|
16
|
+
module.exports = main;
|
|
@@ -0,0 +1,60 @@
|
|
|
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
|
+
// [import]
|
|
12
|
+
|
|
13
|
+
const project = require("../../parser/project");
|
|
14
|
+
const Zip = require("../../util/zip");
|
|
15
|
+
|
|
16
|
+
// [use]
|
|
17
|
+
|
|
18
|
+
const pathExists = fs.pathExists;
|
|
19
|
+
const pathParse = path.parse;
|
|
20
|
+
const resolve = path.resolve;
|
|
21
|
+
|
|
22
|
+
// [declare]
|
|
23
|
+
|
|
24
|
+
const MANIFEST = "arcadible.json";
|
|
25
|
+
const MEDIA = ".arcadible";
|
|
26
|
+
|
|
27
|
+
// [function]
|
|
28
|
+
|
|
29
|
+
const pack = function (name, game, { deployPath, mediaPath, zipPath }) {
|
|
30
|
+
const zip = new Zip(name);
|
|
31
|
+
return Promise.all([pathExists(deployPath), pathExists(mediaPath)])
|
|
32
|
+
.then(([existsDeploy, existsMedia]) => {
|
|
33
|
+
if (existsDeploy) {
|
|
34
|
+
zip.addDir(deployPath);
|
|
35
|
+
}
|
|
36
|
+
if (existsMedia) {
|
|
37
|
+
zip.addDir(mediaPath, MEDIA);
|
|
38
|
+
}
|
|
39
|
+
zip.addJson(MANIFEST, { game });
|
|
40
|
+
zip.write(zipPath);
|
|
41
|
+
return zip.stat();
|
|
42
|
+
})
|
|
43
|
+
.then((stat) => ({ path: zipPath, ...stat }));
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
// [function]
|
|
47
|
+
|
|
48
|
+
const main = function ({ output, root }) {
|
|
49
|
+
return project.parse(root).then(({ game, workflow }) =>
|
|
50
|
+
pack(pathParse(output).name, game, {
|
|
51
|
+
deployPath: resolve(root, workflow.deploy_dir),
|
|
52
|
+
mediaPath: resolve(root, MEDIA),
|
|
53
|
+
zipPath: resolve(root, output),
|
|
54
|
+
}),
|
|
55
|
+
);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
// [export]
|
|
59
|
+
|
|
60
|
+
module.exports = main;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// [import]
|
|
4
|
+
|
|
5
|
+
const game = require("../../schema/game");
|
|
6
|
+
const project = require("../../parser/project");
|
|
7
|
+
const schema = require("../../util/schema");
|
|
8
|
+
const workflow = require("../../schema/workflow");
|
|
9
|
+
|
|
10
|
+
// [use]
|
|
11
|
+
|
|
12
|
+
const validator = schema.validator;
|
|
13
|
+
|
|
14
|
+
// [define]
|
|
15
|
+
|
|
16
|
+
const gameValidator = validator("game", game);
|
|
17
|
+
const workflowValidator = validator("workflow", workflow);
|
|
18
|
+
|
|
19
|
+
// [function]
|
|
20
|
+
|
|
21
|
+
const validate = function (proj, { root }) {
|
|
22
|
+
const issues = [
|
|
23
|
+
gameValidator(proj.game, { root }),
|
|
24
|
+
workflowValidator(proj.workflow, { root }),
|
|
25
|
+
]
|
|
26
|
+
.filter((result) => result.issues.length)
|
|
27
|
+
.flatMap((result) => result.issues);
|
|
28
|
+
return issues;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
// [function]
|
|
32
|
+
|
|
33
|
+
const main = function ({ root }) {
|
|
34
|
+
return project.parse(root).then((proj) => validate(proj, { root }));
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// [export]
|
|
38
|
+
|
|
39
|
+
module.exports = main;
|
package/src/api.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// [import]
|
|
4
|
+
|
|
5
|
+
const cfguri = require("./config/uri");
|
|
6
|
+
const request = require("./util/request");
|
|
7
|
+
|
|
8
|
+
// [declare]
|
|
9
|
+
|
|
10
|
+
const API_HOST = cfguri.HOST_HTTP_API;
|
|
11
|
+
const API_VERSION = "v1";
|
|
12
|
+
|
|
13
|
+
// [function]
|
|
14
|
+
|
|
15
|
+
const endpoint = function (path) {
|
|
16
|
+
return `${API_HOST}/${API_VERSION}${path}`;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
// [function]
|
|
20
|
+
|
|
21
|
+
const authRefresh = function (form, options) {
|
|
22
|
+
return request.post(endpoint("/auth/refresh"), form, options);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// [function]
|
|
26
|
+
|
|
27
|
+
const getFlow = function (id, options) {
|
|
28
|
+
return request.get(endpoint(`/flows/${id}`), options);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
// [function]
|
|
32
|
+
|
|
33
|
+
const postFlow = function (form, options) {
|
|
34
|
+
return request.post(endpoint("/flows"), form, options);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// [export]
|
|
38
|
+
|
|
39
|
+
module.exports = { authRefresh, getFlow, postFlow };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// [import]
|
|
4
|
+
|
|
5
|
+
const deployGitTool = require("../action/deploy-git/tool");
|
|
6
|
+
const deployTool = require("../action/deploy/tool");
|
|
7
|
+
|
|
8
|
+
// [function]
|
|
9
|
+
|
|
10
|
+
const main = function ({ git, ...conf }) {
|
|
11
|
+
const tool = git ? deployGitTool : deployTool;
|
|
12
|
+
return tool(conf);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
// [export]
|
|
16
|
+
|
|
17
|
+
module.exports = main;
|
package/src/cli/index.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// [import]
|
|
4
|
+
|
|
5
|
+
const deploy = require("./deploy");
|
|
6
|
+
const init = require("./init");
|
|
7
|
+
const inspect = require("./inspect");
|
|
8
|
+
const login = require("./login");
|
|
9
|
+
const logout = require("./logout");
|
|
10
|
+
const pack = require("./pack");
|
|
11
|
+
const validate = require("./validate");
|
|
12
|
+
const whoami = require("./whoami");
|
|
13
|
+
|
|
14
|
+
// [export]
|
|
15
|
+
|
|
16
|
+
module.exports = {
|
|
17
|
+
deploy,
|
|
18
|
+
init,
|
|
19
|
+
inspect,
|
|
20
|
+
login,
|
|
21
|
+
logout,
|
|
22
|
+
pack,
|
|
23
|
+
validate,
|
|
24
|
+
whoami,
|
|
25
|
+
};
|
package/src/cli/init.js
ADDED
package/src/cli/login.js
ADDED
package/src/cli/pack.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// [export]
|
|
4
|
+
|
|
5
|
+
module.exports = [
|
|
6
|
+
"action",
|
|
7
|
+
"adventure",
|
|
8
|
+
"arcade",
|
|
9
|
+
"board",
|
|
10
|
+
"card",
|
|
11
|
+
"casino",
|
|
12
|
+
"casual",
|
|
13
|
+
"music",
|
|
14
|
+
"puzzle",
|
|
15
|
+
"racing",
|
|
16
|
+
"rpg",
|
|
17
|
+
"simulation",
|
|
18
|
+
"sports",
|
|
19
|
+
"strategy",
|
|
20
|
+
"trivia",
|
|
21
|
+
"word",
|
|
22
|
+
];
|
|
@@ -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
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// [import]
|
|
4
|
+
|
|
5
|
+
const path = require("node:path");
|
|
6
|
+
|
|
7
|
+
// [import]
|
|
8
|
+
|
|
9
|
+
const fs = require("fs-extra");
|
|
10
|
+
const TOML = require("@iarna/toml");
|
|
11
|
+
|
|
12
|
+
// [use]
|
|
13
|
+
|
|
14
|
+
const join = path.join;
|
|
15
|
+
const readFile = fs.readFile;
|
|
16
|
+
|
|
17
|
+
// [declare]
|
|
18
|
+
|
|
19
|
+
const MANIFEST = "arcadible.toml";
|
|
20
|
+
|
|
21
|
+
// [function]
|
|
22
|
+
|
|
23
|
+
const parseToml = function (buf) {
|
|
24
|
+
try {
|
|
25
|
+
return TOML.parse(buf);
|
|
26
|
+
} catch (ex) {
|
|
27
|
+
throw new Error(`Unable to parse ${MANIFEST}: ${ex.message}`, {
|
|
28
|
+
cause: ex,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
// [function]
|
|
34
|
+
|
|
35
|
+
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
|
+
});
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
// [export]
|
|
45
|
+
|
|
46
|
+
module.exports = { parse };
|