arcadible 1.0.27 → 1.0.29

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/dist/account.js CHANGED
@@ -9,7 +9,7 @@ import { HttpError } from "./util/http.js";
9
9
  import { sessionExpired } from "./phrase/index.js";
10
10
  import { deepSort, isTable } from "./util/objs.js";
11
11
  import { configDir } from "./util/os.js";
12
- import { title, tool } from "./config/product.js";
12
+ import { title } from "./config/product.js";
13
13
  // [declare]
14
14
  const DIR_MODE = 0o700;
15
15
  const FILE = "account.json";
@@ -19,9 +19,8 @@ const FILE_MODE = 0o600;
19
19
  const REJECTED = [400, 401, 403];
20
20
  // [declare]
21
21
  const TOKEN_USER = { display_name: `${title} Token`, id: null };
22
- const TOOL = tool;
23
22
  // [define]
24
- const dir = join(configDir(), TOOL);
23
+ const dir = configDir();
25
24
  const file = join(dir, FILE);
26
25
  // [function]
27
26
  // whether a failure is the file system's, with this code, such as ENOENT.
@@ -18,7 +18,7 @@ import * as phrase from "../../phrase/index.js";
18
18
  import { media } from "../../parser/media.js";
19
19
  import { textOf } from "../../util/objs.js";
20
20
  import { configDir } from "../../util/os.js";
21
- import { title, tool } from "../../config/product.js";
21
+ import { title } from "../../config/product.js";
22
22
  import { watchDir } from "../../serve/reload.js";
23
23
  import { remoteFiles } from "../../serve/remote.js";
24
24
  import { serve } from "../../serve/server.js";
@@ -165,20 +165,20 @@ export async function serveTool(conf) {
165
165
  version: game.version ?? null,
166
166
  },
167
167
  // arc serve's own tickets, signed with a key kept beside the session
168
- keyFile: join(configDir(), tool, "ticket-key.json"),
168
+ keyFile: join(configDir(), "ticket-key.json"),
169
169
  onRemote: handler.onRemote,
170
170
  player,
171
171
  port,
172
172
  root,
173
173
  remote: remoteFiles({
174
- dir: join(configDir(), tool, "sdk"),
174
+ dir: join(configDir(), "sdk"),
175
175
  host: HOST_HTTP_PLAY,
176
176
  sdk: ARCADIBLE_SDK,
177
177
  }),
178
178
  ...(runs && runnerMain
179
179
  ? {
180
180
  runner: {
181
- dir: join(configDir(), tool, "runner"),
181
+ dir: join(configDir(), "runner"),
182
182
  handler: {
183
183
  onError: handler.onRunnerError,
184
184
  onInstall: handler.onRunnerInstall,
@@ -87,6 +87,7 @@ function zOrigins() {
87
87
  const field = "server_origins";
88
88
  return z.optional(z
89
89
  .array(zOrigin())
90
+ .min(1, message(field, ["Must not be empty.", "Leave the field out instead."]))
90
91
  .max(MAX_SERVERS, message(field, [`Must have at most ${MAX_SERVERS} items.`]))
91
92
  .refine((items) => new Set(items).size === items.length, message(field, ["Must not repeat an item."], ISSUE.DUPLICATE)));
92
93
  }
@@ -128,7 +129,7 @@ export function client() {
128
129
  code: "custom",
129
130
  path: ["outbound_hosts"],
130
131
  ...message("outbound_hosts", [
131
- `Must be, with client.server_origins, at most ${MAX_NAMES_LENGTH} characters together.`,
132
+ `Must be, with client.server_origins, at most ${MAX_NAMES_LENGTH.toLocaleString("en-US")} characters together.`,
132
133
  ], ISSUE.TOO_LONG),
133
134
  });
134
135
  }
@@ -67,6 +67,9 @@ function zHost(message, field, what) {
67
67
  export function zHosts(message, field, what) {
68
68
  return z.optional(z
69
69
  .array(zHost(message, field, what))
70
+ // an empty list is no list, as every list in the manifest is: leave
71
+ // the field out instead
72
+ .min(1, message(field, ["Must not be empty.", "Leave the field out instead."]))
70
73
  .max(MAX_HOSTS, message(field, [`Must have at most ${MAX_HOSTS} items.`]))
71
74
  .refine((items) => new Set(items).size === items.length, message(field, ["Must not repeat an item."], ISSUE.DUPLICATE)));
72
75
  }
@@ -8,7 +8,7 @@ import { messages } from "./message.js";
8
8
  const message = messages("function");
9
9
  // what a runner without `main` is told.
10
10
  const REQUIRED = message("main", [
11
- "Must be set: the path of the function's code, such as server/index.ts.",
11
+ "Must be set: the path of the function's code, such as function/index.ts.",
12
12
  ]).message;
13
13
  // a secret's name, as an environment variable is named.
14
14
  const SECRET = /^[A-Z][A-Z0-9_]*$/u;
@@ -19,6 +19,7 @@ function zNames(field, pattern, line) {
19
19
  .array(z
20
20
  .string()
21
21
  .regex(pattern, message(field, [line], ISSUE.CHARACTERS_INVALID)))
22
+ .min(1, message(field, ["Must not be empty.", "Leave the field out instead."]))
22
23
  .refine((items) => new Set(items).size === items.length, message(field, ["Must not repeat an item."], ISSUE.DUPLICATE)));
23
24
  }
24
25
  // [function]
package/dist/util/os.js CHANGED
@@ -1,13 +1,24 @@
1
1
  // [import]
2
2
  import { homedir } from "node:os";
3
- import { join } from "node:path";
3
+ import { join, resolve } from "node:path";
4
+ // [import]
5
+ import { tool } from "../config/product.js";
4
6
  // [function]
5
- // on Windows, the machine's own folder (%LOCALAPPDATA%), not the roaming one:
6
- // the session is a credential, and the SDK's copy a cache, neither of which
7
- // should follow a roaming profile to other machines
7
+ // arc's own folder, which holds the session and arc serve's key and caches:
8
+ // ARCADIBLE_CONFIG_DIR when it's set (left out of the developer docs on
9
+ // purpose, as ARCADIBLE_TOKEN is: it gives an agent or a test a folder of its
10
+ // own), or else ~/.config/arc, or on Windows the machine's own folder
11
+ // (%LOCALAPPDATA%\arc), not the roaming one: the session is a credential, and
12
+ // the SDK's copy a cache, neither of which should follow a roaming profile to
13
+ // other machines
8
14
  export function configDir() {
15
+ const dir = process.env["ARCADIBLE_CONFIG_DIR"];
16
+ if (dir) {
17
+ return resolve(dir);
18
+ }
9
19
  if (process.platform === "win32") {
10
- return process.env["LOCALAPPDATA"] || join(homedir(), "AppData", "Local");
20
+ const local = process.env["LOCALAPPDATA"] || join(homedir(), "AppData", "Local");
21
+ return join(local, tool);
11
22
  }
12
- return join(homedir(), ".config");
23
+ return join(homedir(), ".config", tool);
13
24
  }
@@ -43,7 +43,7 @@
43
43
  },
44
44
  "license": "Apache-2.0",
45
45
  "name": "arcadible",
46
- "version": "1.0.27"
46
+ "version": "1.0.29"
47
47
  },
48
48
  "node_modules/@asamuzakjp/css-color": {
49
49
  "dependencies": {
@@ -3252,5 +3252,5 @@
3252
3252
  }
3253
3253
  },
3254
3254
  "requires": true,
3255
- "version": "1.0.27"
3255
+ "version": "1.0.29"
3256
3256
  }
package/package.json CHANGED
@@ -67,5 +67,5 @@
67
67
  "test": "tsc && npm run lint && node --test \"test/**/*.test.js\" \"test/**/*.test.mjs\""
68
68
  },
69
69
  "type": "module",
70
- "version": "1.0.27"
70
+ "version": "1.0.29"
71
71
  }