arcadible 0.1.17 → 0.1.18

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/package.json CHANGED
@@ -58,5 +58,5 @@
58
58
  "license": "Apache-2.0",
59
59
  "main": "./src/cli/index.js",
60
60
  "name": "arcadible",
61
- "version": "0.1.17"
61
+ "version": "0.1.18"
62
62
  }
@@ -31,16 +31,16 @@ const POLL = {
31
31
 
32
32
  const postFlow = function ({ expiresAt, secret, type }) {
33
33
  const form = new FormData();
34
- form.append("expires_at", expiresAt.toISOString());
35
34
  form.append("secret", secret);
36
35
  form.append("type", type);
36
+ form.append("expires_at", expiresAt.toISOString());
37
37
  return api.postFlow(form);
38
38
  };
39
39
 
40
40
  // [function]
41
41
 
42
- const getFlow = function ({ id, secret: token }) {
43
- return api.getFlow(id, { token });
42
+ const flow = function ({ id, secret: token }) {
43
+ return api.flow(id, { token });
44
44
  };
45
45
 
46
46
  // [function]
@@ -56,8 +56,8 @@ const createFlow = function ({ expiresAt, secret, type }, onLoginCreated) {
56
56
 
57
57
  // [function]
58
58
 
59
- const pollFlow = function ({ id, secret }, onLoginPoll) {
60
- return getFlow({ id, secret }).then(({ data, status }) => {
59
+ const pollFlow = function (value, onLoginPoll) {
60
+ return flow(value).then(({ data, status }) => {
61
61
  if (onLoginPoll) {
62
62
  onLoginPoll({ status });
63
63
  }
@@ -89,7 +89,7 @@ const main = function ({ onLoginCreated, onLoginPoll }) {
89
89
  ).then(({ id }) => {
90
90
  const timeout = Math.max(0, expiresAt.getTime() - Date.now() - time.s(15));
91
91
  return poll(
92
- (flow) => pollFlow(flow, onLoginPoll),
92
+ (value) => pollFlow(value, onLoginPoll),
93
93
  { id, secret },
94
94
  { ...POLL, timeout },
95
95
  );
@@ -31,7 +31,7 @@ const uploadBuild = function (
31
31
 
32
32
  const ensureVersion = function (session, { id, version }, cb) {
33
33
  const token = session?.access_token;
34
- return api.getGameBuild(id, version, { token }).then(
34
+ return api.gameBuild(id, version, { token }).then(
35
35
  () => cb(new Error(phrase.versionExists(version))),
36
36
  (err) => {
37
37
  if (err.status === 404) {
package/src/api.js CHANGED
@@ -18,39 +18,39 @@ const endpoint = function (path) {
18
18
 
19
19
  // [function]
20
20
 
21
- const postAuthRefresh = function (form, options) {
22
- return request.post(endpoint("/auth/refresh"), form, options);
21
+ const postAuthRefresh = function (form, opts) {
22
+ return request.post(endpoint("/auth/refresh"), form, opts);
23
23
  };
24
24
 
25
25
  // [function]
26
26
 
27
- const postFlow = function (form, options) {
28
- return request.post(endpoint("/flows"), form, options);
27
+ const postFlow = function (form, opts) {
28
+ return request.post(endpoint("/flows"), form, opts);
29
29
  };
30
30
 
31
31
  // [function]
32
32
 
33
- const getFlow = function (flow, options) {
34
- return request.get(endpoint(`/flows/${flow}`), options);
33
+ const flow = function (id, opts) {
34
+ return request.get(endpoint(`/flows/${id}`), opts);
35
35
  };
36
36
 
37
37
  // [function]
38
38
 
39
- const postUpload = function (form, options) {
40
- return request.post(endpoint("/uploads"), form, options);
39
+ const postUpload = function (form, opts) {
40
+ return request.post(endpoint("/uploads"), form, opts);
41
41
  };
42
42
 
43
43
  // [function]
44
44
 
45
- const getGameBuild = function (game, version, options) {
46
- return request.get(endpoint(`/games/${game}/builds/${version}`), options);
45
+ const gameBuild = function (id, version, opts) {
46
+ return request.get(endpoint(`/games/${id}/builds/${version}`), opts);
47
47
  };
48
48
 
49
49
  // [export]
50
50
 
51
51
  module.exports = {
52
- getFlow,
53
- getGameBuild,
52
+ flow,
53
+ gameBuild,
54
54
  postAuthRefresh,
55
55
  postFlow,
56
56
  postUpload,
@@ -10,7 +10,7 @@ module.exports = {
10
10
  select: {
11
11
  choices: [
12
12
  {
13
- description: "Zero-build static starter.",
13
+ description: "Plain JavaScript starter.",
14
14
  name: "Default",
15
15
  value: `${REPO}/starter`,
16
16
  },
@@ -30,7 +30,7 @@ const formatBytes = function (bytes) {
30
30
 
31
31
  // [function]
32
32
 
33
- const formatValue = function (value, options, type) {
33
+ const formatValue = function (value, opts, type) {
34
34
  if (type === "percentage") {
35
35
  return value;
36
36
  }
@@ -27,39 +27,46 @@ const parse = function (resp) {
27
27
 
28
28
  // [function]
29
29
 
30
- const send = function (method, url, body, { token } = {}) {
31
- const headers = {
32
- "X-Arc-Client-Id": CLIENT_ID,
33
- "X-Arc-Client-Version": CLIENT_VERSION,
34
- };
30
+ const send = function (method, url, form, { token } = {}) {
31
+ const headers = [
32
+ ["X-Arcadible-Client-Id", CLIENT_ID],
33
+ ["X-Arcadible-Client-Version", CLIENT_VERSION],
34
+ ];
35
35
  if (token) {
36
- headers.authorization = `Bearer ${token}`;
36
+ headers.push(["Authorization", `Bearer ${token}`]);
37
37
  }
38
- return fetch(url, { body, headers, method }).then(parse);
38
+ if (form) {
39
+ headers.push(["Content-Type", "application/json"]);
40
+ }
41
+ return fetch(url, {
42
+ body: form ? JSON.stringify(Object.fromEntries(form)) : null,
43
+ headers,
44
+ method,
45
+ }).then(parse);
39
46
  };
40
47
 
41
48
  // [function]
42
49
 
43
- const get = function (url, options) {
44
- return send("GET", url, null, options);
50
+ const get = function (url, opts) {
51
+ return send("GET", url, null, opts);
45
52
  };
46
53
 
47
54
  // [function]
48
55
 
49
- const post = function (url, body, options) {
50
- return send("POST", url, body, options);
56
+ const post = function (url, form, opts) {
57
+ return send("POST", url, form, opts);
51
58
  };
52
59
 
53
60
  // [function]
54
61
 
55
- const patch = function (url, body, options) {
56
- return send("PATCH", url, body, options);
62
+ const patch = function (url, form, opts) {
63
+ return send("PATCH", url, form, opts);
57
64
  };
58
65
 
59
66
  // [function]
60
67
 
61
- const del = function (url, options) {
62
- return send("DELETE", url, null, options);
68
+ const del = function (url, opts) {
69
+ return send("DELETE", url, null, opts);
63
70
  };
64
71
 
65
72
  // [export]
package/src/util/s3.js CHANGED
@@ -16,7 +16,7 @@ const request = https.request;
16
16
 
17
17
  // [function]
18
18
 
19
- const requestOptions = function (size) {
19
+ const requestOpts = function (size) {
20
20
  return {
21
21
  headers: {
22
22
  "Content-Length": size,
@@ -29,7 +29,7 @@ const requestOptions = function (size) {
29
29
  // [function]
30
30
 
31
31
  const upload = function (url, { path, size }, onProgress, cb) {
32
- const req = request(url, requestOptions(size), (resp) => {
32
+ const req = request(url, requestOpts(size), (resp) => {
33
33
  resp.resume();
34
34
  const status = resp.statusCode;
35
35
  if (status >= 200 && status < 300) {