arcadible 1.0.24 → 1.0.26

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 (54) hide show
  1. package/dist/action/build/tool.js +6 -10
  2. package/dist/action/delete/tool.js +2 -1
  3. package/dist/action/deploy/tool-git.js +4 -9
  4. package/dist/action/deploy/tool.js +3 -8
  5. package/dist/action/deploy/wait.js +1 -1
  6. package/dist/action/function/tool.js +6 -6
  7. package/dist/action/game.js +3 -2
  8. package/dist/action/key/tool.js +6 -5
  9. package/dist/action/open/tool.js +2 -1
  10. package/dist/action/pack/tool.js +13 -15
  11. package/dist/action/play/tool.js +2 -1
  12. package/dist/action/predeploy/ac.js +3 -3
  13. package/dist/action/predeploy/game.js +2 -8
  14. package/dist/action/predeploy/secrets.js +2 -2
  15. package/dist/action/predeploy/tool-git.js +3 -8
  16. package/dist/action/predeploy/tool.js +1 -3
  17. package/dist/action/secret/tool.js +4 -4
  18. package/dist/action/serve/tool.js +26 -5
  19. package/dist/action/value/tool.js +216 -0
  20. package/dist/api.js +190 -38
  21. package/dist/command/inspect.js +2 -1
  22. package/dist/command/open.js +2 -1
  23. package/dist/command/play.js +4 -3
  24. package/dist/command/serve.js +3 -2
  25. package/dist/command/value/get.js +21 -0
  26. package/dist/command/value/index.js +19 -0
  27. package/dist/command/value/key.js +8 -0
  28. package/dist/command/value/list.js +41 -0
  29. package/dist/command/value/remove.js +26 -0
  30. package/dist/command/value/set.js +62 -0
  31. package/dist/command/value/usage.js +69 -0
  32. package/dist/commands.js +8 -1
  33. package/dist/phrase/common.js +9 -0
  34. package/dist/phrase/deploy.js +9 -1
  35. package/dist/phrase/function.js +6 -2
  36. package/dist/phrase/index.js +1 -0
  37. package/dist/phrase/server.js +1 -1
  38. package/dist/phrase/value.js +55 -0
  39. package/dist/runner/bundle.js +10 -60
  40. package/dist/runner/entry.js +57 -0
  41. package/dist/runner/outbound.js +1 -1
  42. package/dist/schema/workflow.js +1 -1
  43. package/dist/serve/page.js +205 -6
  44. package/dist/serve/runner.js +9 -2
  45. package/dist/serve/server.js +7 -1
  46. package/dist/serve/ticket.js +2 -2
  47. package/dist/serve/values.js +317 -0
  48. package/dist/util/objs.js +17 -0
  49. package/dist/util/progress.js +13 -1
  50. package/dist/util/request.js +15 -3
  51. package/dist/util/schema.js +1 -1
  52. package/dist/util/shape.js +49 -0
  53. package/npm-shrinkwrap.json +2 -2
  54. package/package.json +1 -1
@@ -4,12 +4,11 @@ import { resolve as resolvePath } from "node:path";
4
4
  // [import]
5
5
  import { pathExists } from "fs-extra";
6
6
  // [import]
7
- import { BUILD_FAILED } from "../../config/code.js";
8
- import { given } from "../../parser/given.js";
9
- import * as phrase from "../../phrase/index.js";
10
7
  import { BUILT, bundle } from "../../runner/bundle.js";
8
+ import { BUILD_FAILED } from "../../config/code.js";
11
9
  import { buildCommand } from "../../util/command.js";
12
10
  import { ArcError } from "../../util/error.js";
11
+ import * as phrase from "../../phrase/index.js";
13
12
  // [function]
14
13
  // a build's output has no limit: exec's default maxBuffer, 1 MB, would kill a
15
14
  // verbose build that otherwise succeeds. `exec` is called through the module,
@@ -34,7 +33,7 @@ function build(command, { cwdPath, outputPath }) {
34
33
  return command
35
34
  ? execBuild(command, { cwdPath })
36
35
  .then(() => pathExists(outputPath))
37
- .then((exists) => (exists ? { path: outputPath } : { missing: outputPath }))
36
+ .then((exists) => exists ? { path: outputPath } : { missing: outputPath })
38
37
  : Promise.resolve(null);
39
38
  }
40
39
  // [function]
@@ -51,14 +50,11 @@ function buildRunner(root, main) {
51
50
  }
52
51
  // [function]
53
52
  // builds the project: its own build, then its runner, when it has one. The
54
- // result is the build's, with `function`, the bundle's path, beside it. The
55
- // project is one that passed validation, so its deploy_dir is a path.
56
- export async function buildTool(conf) {
57
- const root = conf.root;
58
- const { function: runner, workflow } = await given(conf);
53
+ // result is the build's, with `function`, the bundle's path, beside it.
54
+ export async function buildTool({ project: { function: runner, workflow }, root, }) {
59
55
  const artifact = await build(buildCommand(workflow.build), {
60
56
  cwdPath: root,
61
- outputPath: resolvePath(root, String(workflow.deploy_dir)),
57
+ outputPath: resolvePath(root, workflow.deploy_dir),
62
58
  });
63
59
  const bundled = await buildRunner(root, runner?.main);
64
60
  return bundled ? { ...artifact, function: bundled } : artifact;
@@ -7,6 +7,7 @@ import { ArcError } from "../../util/error.js";
7
7
  import { headersOf, isStatus } from "../game.js";
8
8
  import { given } from "../../parser/given.js";
9
9
  import { gameIdMissing, gameUndeletable } from "../../phrase/index.js";
10
+ import { textOf } from "../../util/objs.js";
10
11
  // [function]
11
12
  // a value of the manifest's as a name, when it's text with something in it.
12
13
  function text(value) {
@@ -20,7 +21,7 @@ export function named(conf) {
20
21
  if (!game.id) {
21
22
  throw new ArcError(GAME_ID_MISSING, gameIdMissing());
22
23
  }
23
- const id = String(game.id);
24
+ const id = textOf(game.id);
24
25
  return { id, title: text(game.title) ?? text(game.handle) ?? id };
25
26
  });
26
27
  }
@@ -3,7 +3,6 @@ import { GIT_TAG_CREATE_FAILED, GIT_TAG_PUSH_FAILED, } from "../../config/code.j
3
3
  import { ArcError } from "../../util/error.js";
4
4
  import { releasing } from "../predeploy/game.js";
5
5
  import { git, stderrOf, tagOf } from "../predeploy/git.js";
6
- import { given } from "../../parser/given.js";
7
6
  import { gitTagCreateFailed, gitTagPushFailed, versionPrerelease, versionRelease, } from "../../phrase/index.js";
8
7
  import { channel, PRODUCTION, published, } from "../../util/links.js";
9
8
  // [function]
@@ -38,14 +37,10 @@ export function deployToolGit(conf, { onDeployBegin }) {
38
37
  if (onDeployBegin) {
39
38
  onDeployBegin();
40
39
  }
41
- return given(conf)
42
- .then(({ game: parsed }) => {
43
- const game = releasing(parsed);
44
- return createTag(conf.root, game.version)
45
- .then(() => pushTag(conf.root, game.version))
46
- .then(() => game);
47
- })
48
- .then((game) => ({
40
+ const game = releasing(conf.project.game);
41
+ return createTag(conf.root, game.version)
42
+ .then(() => pushTag(conf.root, game.version))
43
+ .then(() => ({
49
44
  ...published(game),
50
45
  game: game.id,
51
46
  tag: tagOf(game.version),
@@ -3,7 +3,6 @@ import { auth, postUpload } from "../../api.js";
3
3
  import { DEPLOY_RATE_LIMITED, GAME_UNAVAILABLE } from "../../config/code.js";
4
4
  import { ArcError } from "../../util/error.js";
5
5
  import { releasing } from "../predeploy/game.js";
6
- import { given } from "../../parser/given.js";
7
6
  import { HttpError } from "../../util/http.js";
8
7
  import { deployRateLimited, gameUnavailable } from "../../phrase/index.js";
9
8
  import { published } from "../../util/links.js";
@@ -17,7 +16,7 @@ function uploadBuild(current, artifact, { id, version }, onProgress) {
17
16
  form.append("version", version);
18
17
  form.append("sha256", artifact.sha256);
19
18
  form.append("size", String(artifact.size));
20
- return postUpload(form, null, auth(current?.session?.access_token)).then((upload) => s3Upload(upload.upload_url, artifact, onProgress).then(() => upload), (err) => {
19
+ return postUpload(form, null, auth(current?.session.access_token)).then((upload) => s3Upload(upload.upload_url, artifact, onProgress).then(() => upload), (err) => {
21
20
  // the API refuses a game that was deleted or is another account's
22
21
  // (403), and the same version deployed again within 5 minutes (429).
23
22
  if (err instanceof HttpError && err.status === 403) {
@@ -38,12 +37,8 @@ export function deployTool(current, artifact, conf, { onDeployBegin, onUploadPro
38
37
  if (onDeployBegin) {
39
38
  onDeployBegin({ root: conf.root });
40
39
  }
41
- return given(conf)
42
- .then(({ game: parsed }) => {
43
- const game = releasing(parsed);
44
- return uploadBuild(current, artifact, game, onUploadProgress).then((upload) => ({ game, upload }));
45
- })
46
- .then(({ game, upload }) => ({
40
+ const game = releasing(conf.project.game);
41
+ return uploadBuild(current, artifact, game, onUploadProgress).then((upload) => ({
47
42
  ...published(game),
48
43
  game: game.id,
49
44
  // a direct deploy's release shares its upload's id, which `--wait`
@@ -90,7 +90,7 @@ export function wait(current, deployed, { git: isGit, root, since, timeout }, {
90
90
  const game = deployed.game;
91
91
  const find = isGit || !("release" in deployed)
92
92
  ? findGit({ game, since, version: deployed.version.to })
93
- : findDirect(deployed.release, auth(current?.session?.access_token));
93
+ : findDirect(deployed.release, auth(current?.session.access_token));
94
94
  return Promise.all([
95
95
  pollRelease(find, timeout, onRelease),
96
96
  isGit ? actionsUrl(root) : null,
@@ -2,7 +2,7 @@
2
2
  // build's, without a release, by the game's owner. Arcadible can pause one
3
3
  // too, and so can its allowance, spent: a pause has a reason, and an owner
4
4
  // lifts only their own.
5
- import { deleteGamePause, discoverGameBuilds, gamePauses, gameUsages, putGamePause, } from "../../api.js";
5
+ import { deleteGameFunctionPause, discoverGameBuilds, gameFunctionPauses, gameFunctionUsages, putGameFunctionPause, } from "../../api.js";
6
6
  import { API_REFUSED, GAME_UNAVAILABLE } from "../../config/code.js";
7
7
  import { ArcError } from "../../util/error.js";
8
8
  import { channelOf, CHANNELS, gameOf, headersOf, isStatus, needOf, } from "../game.js";
@@ -48,7 +48,7 @@ export async function pause(current, { channel, ...conf }) {
48
48
  const id = await gameOf(conf);
49
49
  const headers = headersOf(current);
50
50
  try {
51
- const kept = await putGamePause(id, where, null, headers);
51
+ const kept = await putGameFunctionPause(id, where, null, headers);
52
52
  return {
53
53
  channel: kept.channel,
54
54
  function: await hasFunction(id, where),
@@ -75,7 +75,7 @@ export async function resume(current, { channel, ...conf }) {
75
75
  const headers = headersOf(current);
76
76
  let lifted = true;
77
77
  try {
78
- await deleteGamePause(id, where, null, headers);
78
+ await deleteGameFunctionPause(id, where, null, headers);
79
79
  }
80
80
  catch (err) {
81
81
  if (!isStatus(err, 404)) {
@@ -83,7 +83,7 @@ export async function resume(current, { channel, ...conf }) {
83
83
  }
84
84
  lifted = false;
85
85
  }
86
- const paused = pausedOf(await gamePauses(id, null, headers), where);
86
+ const paused = pausedOf(await gameFunctionPauses(id, null, headers), where);
87
87
  if (!lifted) {
88
88
  throw new ArcError(API_REFUSED, functionNotPaused({ channel: where, paused }));
89
89
  }
@@ -102,8 +102,8 @@ export async function status(current, { channel, ...conf }) {
102
102
  const id = await gameOf(conf);
103
103
  const headers = headersOf(current);
104
104
  const [pauses, usages] = await Promise.all([
105
- gamePauses(id, null, headers),
106
- gameUsages(id, null, headers),
105
+ gameFunctionPauses(id, null, headers),
106
+ gameFunctionUsages(id, null, headers),
107
107
  ]);
108
108
  const shown = CHANNELS.filter((each) => !where || each === where);
109
109
  // asked once the owner's reads have answered, so another account's game
@@ -8,6 +8,7 @@ import { ArcError } from "../util/error.js";
8
8
  import { given } from "../parser/given.js";
9
9
  import { HttpError } from "../util/http.js";
10
10
  import { channelInvalid, gameIdMissing, notLoggedIn } from "../phrase/index.js";
11
+ import { textOf } from "../util/objs.js";
11
12
  // [declare]
12
13
  export const CHANNELS = ["production", "staging"];
13
14
  // [function]
@@ -20,7 +21,7 @@ export function gameOf(conf) {
20
21
  if (!game.id) {
21
22
  throw new ArcError(GAME_ID_MISSING, gameIdMissing());
22
23
  }
23
- return String(game.id);
24
+ return textOf(game.id);
24
25
  });
25
26
  }
26
27
  // [function]
@@ -52,7 +53,7 @@ export function headersOf(current) {
52
53
  if (!current) {
53
54
  throw new ArcError(NOT_LOGGED_IN, notLoggedIn());
54
55
  }
55
- return auth(current.session?.access_token);
56
+ return auth(current.session.access_token);
56
57
  }
57
58
  // [function]
58
59
  // whether a failure is the API's refusal with this status.
@@ -1,7 +1,7 @@
1
1
  // a game's keys: what its own server proves itself to Arcadible with. A key
2
2
  // is for one game and one channel, made by the game's owner, shown once, and
3
3
  // revoked at once. Nothing here keeps one.
4
- import { deleteGameKey, gameKeys, postGameKey, } from "../../api.js";
4
+ import { deleteKey, gameKeys, postGameKey, } from "../../api.js";
5
5
  import { API_REFUSED, ARGUMENT_INVALID, GAME_UNAVAILABLE, } from "../../config/code.js";
6
6
  import { ArcError } from "../../util/error.js";
7
7
  import { channelOf, gameOf, headersOf, isStatus, needOf } from "../game.js";
@@ -68,12 +68,13 @@ export async function list(current, { channel, ...conf }) {
68
68
  }
69
69
  // [function]
70
70
  // revokes the key with this id, and resolves with `{ id }`. One that's gone
71
- // already, isn't the game's, or isn't an id at all is the same to its owner:
72
- // not found.
71
+ // already, isn't the account's, or isn't an id at all is the same to its
72
+ // owner: not found. A key is addressed by its own id, so the project only
73
+ // has to name a game.
73
74
  export async function revoke(current, { id, ...conf }) {
74
- const game = await gameOf(conf);
75
+ await gameOf(conf);
75
76
  try {
76
- const gone = await deleteGameKey(game, id, null, headersOf(current));
77
+ const gone = await deleteKey(id, null, headersOf(current));
77
78
  return { id: gone.id };
78
79
  }
79
80
  catch (err) {
@@ -1,5 +1,6 @@
1
1
  // [import]
2
2
  import { storePage, storeUrl } from "../../util/links.js";
3
+ import { textOf } from "../../util/objs.js";
3
4
  import { self } from "../../parser/self.js";
4
5
  // [function]
5
6
  // the store page's path, which the app opens, and its URL on the web. `id`
@@ -9,7 +10,7 @@ function openUrl(id) {
9
10
  if (!id) {
10
11
  return null;
11
12
  }
12
- const game = String(id);
13
+ const game = textOf(id);
13
14
  return { page: storePage(game), url: storeUrl(game) };
14
15
  }
15
16
  // [function]
@@ -7,7 +7,6 @@ import { BUILT, PACKED } from "../../runner/bundle.js";
7
7
  import { DEPLOY_DIR_MISSING, PACKAGE_INDEX_MISSING, PACKAGE_PATH_RESERVED, PACKAGE_TOO_LARGE, PATH_NOT_FOUND, } from "../../config/code.js";
8
8
  import { ArcError } from "../../util/error.js";
9
9
  import { MEDIA, PACKAGED } from "../../config/file.js";
10
- import { given } from "../../parser/given.js";
11
10
  import { deployDirMissing, packageIndexMissing, packagePathReserved, packageTooLarge, runnerNotBuilt, unableToFind, } from "../../phrase/index.js";
12
11
  import { ZIP_SIZE } from "../../config/limit.js";
13
12
  import { check, measure } from "./limits.js";
@@ -132,19 +131,18 @@ function pack(name, game, { deployDir, inputPath, mediaPath, onWarning, outputPa
132
131
  // its deploy_dir is a path.
133
132
  export function packTool({ input, onWarning, output, ...conf }) {
134
133
  const root = conf.root;
135
- return given(conf).then(({ function: runner, game, server, workflow }) => {
136
- const name = String(game.handle ?? game.id);
137
- const file = output ?? `${OUTPUT}/${name}-v${String(game.version)}.zip`;
138
- const deployDir = resolve(root, String(workflow.deploy_dir));
139
- const inputPath = resolve(root, input ?? String(workflow.deploy_dir));
140
- return pack(parse(file).name, game, {
141
- deployDir: inputPath === deployDir,
142
- inputPath,
143
- mediaPath: resolve(root, MEDIA),
144
- onWarning,
145
- outputPath: resolve(root, file),
146
- runner: runner ? { built: resolve(root, BUILT), table: runner } : null,
147
- server,
148
- });
134
+ const { function: runner, game, server, workflow } = conf.project;
135
+ const name = game.handle ?? game.id;
136
+ const file = output ?? `${OUTPUT}/${name}-v${game.version}.zip`;
137
+ const deployDir = resolve(root, workflow.deploy_dir);
138
+ const inputPath = resolve(root, input ?? workflow.deploy_dir);
139
+ return pack(parse(file).name, game, {
140
+ deployDir: inputPath === deployDir,
141
+ inputPath,
142
+ mediaPath: resolve(root, MEDIA),
143
+ onWarning,
144
+ outputPath: resolve(root, file),
145
+ runner: runner ? { built: resolve(root, BUILT), table: runner } : null,
146
+ server,
149
147
  });
150
148
  }
@@ -5,6 +5,7 @@ import { ArcError } from "../../util/error.js";
5
5
  import { HttpError } from "../../util/http.js";
6
6
  import { gameNotFound } from "../../phrase/index.js";
7
7
  import { playUrl, PRODUCTION, STAGING } from "../../util/links.js";
8
+ import { textOf } from "../../util/objs.js";
8
9
  import { self } from "../../parser/self.js";
9
10
  // [function]
10
11
  // the game, `select`ed, or null when the API can't be reached. It rejects
@@ -63,7 +64,7 @@ function playSelf(root, release) {
63
64
  return Promise.resolve([null, null]);
64
65
  }
65
66
  // a handle or an id as the manifest has it.
66
- const id = String(named);
67
+ const id = textOf(named);
67
68
  return Promise.all([
68
69
  release ? null : findGame(id, "id"),
69
70
  target(id, game.orientation, release),
@@ -21,7 +21,7 @@ function ensureOwned(current, id) {
21
21
  return discoverGame(id).then((game) => {
22
22
  // a token's account isn't known yet; the server checks ownership when
23
23
  // it authorizes the upload.
24
- if (!current?.token && game.account !== current?.user?.id) {
24
+ if (!current?.token && game.account !== current?.user.id) {
25
25
  throw new ArcError(GAME_UNAVAILABLE, gameUnavailable(id));
26
26
  }
27
27
  }, ignoreMissing);
@@ -41,7 +41,7 @@ function ensureHandle(current, { handle, id, version }, handler) {
41
41
  handler.onWarning({ code, message });
42
42
  }
43
43
  };
44
- return gameHandle(id, handle, { channel: channel(version) }, auth(current?.session?.access_token)).then(({ status }) => {
44
+ return gameHandle(id, handle, { channel: channel(version) }, auth(current?.session.access_token)).then(({ status }) => {
45
45
  if (status === "taken") {
46
46
  throw new ArcError(GAME_HANDLE_TAKEN, gameHandleTaken(handle));
47
47
  }
@@ -69,7 +69,7 @@ export function ensureId(current, game, handler) {
69
69
  // resolves with the game, or fails when its version is already published.
70
70
  export function ensureUnpublished(current, game) {
71
71
  const { id, version } = game;
72
- return gameBuild(id, version, null, auth(current?.session?.access_token))
72
+ return gameBuild(id, version, null, auth(current?.session.access_token))
73
73
  .then(() => refuse(id, version), ignoreMissing)
74
74
  .then(() => game);
75
75
  }
@@ -1,12 +1,6 @@
1
1
  // [import]
2
2
  // [function]
3
- // the fields a release goes by, of a project that passed validation, so its
4
- // id and version are strings, and its handle is one when it has one. Each is
5
- // read as it's written into a path or a message, as text.
3
+ // the fields a release goes by, of a project that passed validation.
6
4
  export function releasing(game) {
7
- return {
8
- handle: (game.handle ?? null) === null ? null : String(game.handle),
9
- id: String(game.id),
10
- version: String(game.version),
11
- };
5
+ return { handle: game.handle ?? null, id: game.id, version: game.version };
12
6
  }
@@ -7,7 +7,7 @@
7
7
  // Nothing calls this yet: what it finds is a warning, a warning has a code,
8
8
  // and a code has an entry on the public Errors page, which says nothing of
9
9
  // functions until they ship (TODO.md, Agreed next).
10
- import { auth, gameSecrets } from "../../api.js";
10
+ import { auth, gameFunctionSecrets } from "../../api.js";
11
11
  import { channel } from "../../util/links.js";
12
12
  // [function]
13
13
  // the names `declared` (the manifest's `function.secrets`) that have no
@@ -23,7 +23,7 @@ export async function unset(current, { id, version }, declared) {
23
23
  return { channel: where, names: [] };
24
24
  }
25
25
  try {
26
- const secrets = await gameSecrets(id, null, auth(current?.session?.access_token));
26
+ const secrets = await gameFunctionSecrets(id, null, auth(current?.session.access_token));
27
27
  const set = new Set((secrets ?? [])
28
28
  .filter((secret) => secret.channel === where)
29
29
  .map((secret) => secret.name));
@@ -4,7 +4,6 @@ import { GAME_HANDLE_CHANGED, GAME_NOT_DEPLOYED, REPO_NOT_CONNECTED, WARNING, }
4
4
  import { ArcError } from "../../util/error.js";
5
5
  import { releasing } from "./game.js";
6
6
  import { ensureClean, ensureRemote, ensureRepo, ensureRoot, ensureTagFree, ensureWorkflow, originRepo, } from "./git.js";
7
- import { given } from "../../parser/given.js";
8
7
  import { HttpError } from "../../util/http.js";
9
8
  import { gameHandleChanged, gameNotDeployed, repoNotConnected, versionUnchecked, } from "../../phrase/index.js";
10
9
  import { studioUrl } from "../../util/links.js";
@@ -44,7 +43,7 @@ function ensurePublishable({ handle, id, version }, handler) {
44
43
  if (build.status === 200) {
45
44
  return refuse(id, version);
46
45
  }
47
- const current = game.data?.handle ?? null;
46
+ const current = game.data.handle ?? null;
48
47
  if (handle !== current) {
49
48
  throw new ArcError(GAME_HANDLE_CHANGED, gameHandleChanged(handle, current));
50
49
  }
@@ -99,10 +98,6 @@ export function predeployToolGit(conf, { onPredeployBegin, ...handler }) {
99
98
  if (onPredeployBegin) {
100
99
  onPredeployBegin();
101
100
  }
102
- return given(conf)
103
- .then(({ game }) => {
104
- const releases = releasing(game);
105
- return ensureProject(root).then(() => releases);
106
- })
107
- .then((game) => ensureRelease(root, game, handler));
101
+ const game = releasing(conf.project.game);
102
+ return ensureProject(root).then(() => ensureRelease(root, game, handler));
108
103
  }
@@ -1,7 +1,6 @@
1
1
  // [import]
2
2
  import { ensureId, ensureUnpublished } from "./ac.js";
3
3
  import { releasing } from "./game.js";
4
- import { given } from "../../parser/given.js";
5
4
  // [function]
6
5
  // a direct deploy needs a login. Each lookup uses its token or not, as it
7
6
  // needs, and its answer is true when it's asked.
@@ -9,8 +8,7 @@ export function predeployTool(current, conf, { onPredeployBegin, ...handler }) {
9
8
  if (onPredeployBegin) {
10
9
  onPredeployBegin({ root: conf.root });
11
10
  }
12
- return given(conf)
13
- .then(({ game }) => ensureId(current, releasing(game), handler))
11
+ return ensureId(current, releasing(conf.project.game), handler)
14
12
  .then((game) => ensureUnpublished(current, game))
15
13
  .then((game) => ({ held: game.held, to: game.version }));
16
14
  }
@@ -2,7 +2,7 @@
2
2
  // mustn't hold, such as another service's key. Each is for one game and one
3
3
  // channel, by the name the manifest declares (function.secrets), set by the
4
4
  // game's owner, and never shown again. Nothing here keeps one.
5
- import { deleteGameSecret, gameSecrets, putGameSecret } from "../../api.js";
5
+ import { deleteGameFunctionSecret, gameFunctionSecrets, putGameFunctionSecret, } from "../../api.js";
6
6
  import { API_REFUSED, ARGUMENT_INVALID, GAME_UNAVAILABLE, } from "../../config/code.js";
7
7
  import { ArcError } from "../../util/error.js";
8
8
  import { channelOf, gameOf, headersOf, isStatus, needOf } from "../game.js";
@@ -37,7 +37,7 @@ export async function set(current, { channel, name, value, ...conf }) {
37
37
  const form = new FormData();
38
38
  form.append("value", secret);
39
39
  try {
40
- const kept = await putGameSecret(id, where, named, form, null, headers);
40
+ const kept = await putGameFunctionSecret(id, where, named, form, null, headers);
41
41
  return { channel: kept.channel, name: kept.name };
42
42
  }
43
43
  catch (err) {
@@ -61,7 +61,7 @@ export async function list(current, { channel, ...conf }) {
61
61
  const where = channelOf(channel);
62
62
  const id = await gameOf(conf);
63
63
  const headers = headersOf(current);
64
- const secrets = await gameSecrets(id, null, headers);
64
+ const secrets = await gameFunctionSecrets(id, null, headers);
65
65
  return (secrets ?? [])
66
66
  .filter((secret) => !where || secret.channel === where)
67
67
  .map((secret) => ({
@@ -79,7 +79,7 @@ export async function remove(current, { channel, name, ...conf }) {
79
79
  const id = await gameOf(conf);
80
80
  const headers = headersOf(current);
81
81
  try {
82
- const gone = await deleteGameSecret(id, where, named, null, headers);
82
+ const gone = await deleteGameFunctionSecret(id, where, named, null, headers);
83
83
  return { channel: gone.channel, name: gone.name };
84
84
  }
85
85
  catch (err) {
@@ -15,6 +15,7 @@ import { dirFiles } from "../../serve/files.js";
15
15
  import { given } from "../../parser/given.js";
16
16
  import * as phrase from "../../phrase/index.js";
17
17
  import { media } from "../../parser/media.js";
18
+ import { textOf } from "../../util/objs.js";
18
19
  import { configDir } from "../../util/os.js";
19
20
  import { title, tool } from "../../config/product.js";
20
21
  import { watchDir } from "../../serve/reload.js";
@@ -103,6 +104,12 @@ async function listen(options) {
103
104
  }
104
105
  }
105
106
  // [function]
107
+ // a value of the manifest's as text, when it's text: the project is as it
108
+ // was parsed.
109
+ function text(value) {
110
+ return typeof value === "string" && value ? value : null;
111
+ }
112
+ // [function]
106
113
  // the strings of a list the manifest has, or none: the project is as it was
107
114
  // parsed, and arc serve doesn't validate it.
108
115
  function strings(value) {
@@ -141,17 +148,18 @@ export async function serveTool(conf) {
141
148
  // the game's runner, when the project has one: its code, where its runtime
142
149
  // is kept, and who hears how it's doing
143
150
  const runs = project.function;
144
- if (runs && typeof runs.main !== "string") {
151
+ const main = runs?.main;
152
+ if (runs && typeof main !== "string") {
145
153
  throw new TypeError("function.main must be a path.");
146
154
  }
147
- const runnerMain = runs ? resolvePath(root, String(runs.main)) : null;
155
+ const runnerMain = typeof main === "string" ? resolvePath(root, main) : null;
148
156
  const options = {
149
157
  art: storeArt(root),
150
158
  icon: storeIcon(root),
151
159
  info: {
152
160
  channel: CHANNEL,
153
161
  id: game.id ?? UNNAMED,
154
- title: String(game.title ?? game.handle ?? title),
162
+ title: text(game.title) ?? text(game.handle) ?? title,
155
163
  version: game.version ?? null,
156
164
  },
157
165
  // arc serve's own tickets, signed with a key kept beside the session
@@ -159,6 +167,7 @@ export async function serveTool(conf) {
159
167
  onRemote: handler.onRemote,
160
168
  player,
161
169
  port,
170
+ root,
162
171
  remote: remoteFiles({
163
172
  dir: join(configDir(), tool, "sdk"),
164
173
  host: HOST_HTTP_PLAY,
@@ -217,12 +226,24 @@ export async function serveTool(conf) {
217
226
  version,
218
227
  };
219
228
  }
229
+ // arc serve validates nothing, so a deploy_dir that isn't a path is said
230
+ // as what it is, a folder that isn't there
231
+ const dir = project.workflow.deploy_dir;
232
+ if (typeof dir !== "string") {
233
+ throw new ArcError(DEPLOY_DIR_MISSING, phrase.deployDirMissing(textOf(dir) || "deploy_dir"));
234
+ }
220
235
  const built = conf.build !== false && Boolean(buildCommand(project.workflow.build));
221
236
  if (built) {
222
237
  handler.onBuild();
223
- await buildTool({ project, root });
238
+ await buildTool({
239
+ project: {
240
+ function: project.function,
241
+ workflow: { build: project.workflow.build, deploy_dir: dir },
242
+ },
243
+ root,
244
+ });
224
245
  }
225
- const deployDir = resolvePath(root, String(project.workflow.deploy_dir));
246
+ const deployDir = resolvePath(root, dir);
226
247
  if (!(await pathExists(deployDir))) {
227
248
  throw new ArcError(DEPLOY_DIR_MISSING, phrase.deployDirMissing(relative(root, deployDir) || "."));
228
249
  }