arcadible 1.0.51 → 1.0.52

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.
@@ -3,12 +3,13 @@
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
5
  import { deleteGameFunctionSecret, gameFunctionSecrets, putGameFunctionSecret, } from "../../api.js";
6
- import { ARGUMENT_INVALID, GAME_NOT_FOUND, SECRET_QUOTA_FULL, SECRET_NOT_FOUND, SECRET_TOO_LARGE, } from "../../config/code.js";
6
+ import { ARGUMENT_INVALID, GAME_NOT_FOUND, SECRET_QUOTA_FULL, SECRET_NOT_FOUND, SECRET_TOO_LARGE, WARNING, } from "../../config/code.js";
7
7
  import { SECRET_NAME } from "../../config/limit.js";
8
8
  import { ArcError } from "../../util/error.js";
9
9
  import { channelOf, gameOf, headersOf, isRefused, REFUSED, needOf, ownedRead, } from "../game.js";
10
10
  import { iso } from "../../util/time.js";
11
- import { gameNotOwned, secretQuotaFull, secretNameInvalid, secretNotFound, secretTooLarge, secretValueInvalid, } from "../../phrase/index.js";
11
+ import { given } from "../../parser/given.js";
12
+ import { gameNotOwned, secretQuotaFull, secretNameInvalid, secretNotFound, secretTooLarge, secretUndeclared, secretValueInvalid, } from "../../phrase/index.js";
12
13
  // [declare]
13
14
  const VALUE_MAX = 4096;
14
15
  // [function]
@@ -21,11 +22,23 @@ function nameOf(name) {
21
22
  }
22
23
  // [function]
23
24
  // sets a secret, as `{ name, channel }`. `value()` resolves with its value,
24
- // asked for only once the rest holds, so nothing is typed for a refusal.
25
- export async function set(current, { channel, name, value, ...conf }) {
25
+ // asked for only once the rest holds, so nothing is typed for a refusal. A
26
+ // name the manifest's `function.secrets` doesn't declare is set all the
27
+ // same, since a later release may declare it, and warned of: until one
28
+ // does, the function can't read it, as only declared secrets are sealed
29
+ // into a build.
30
+ export async function set(current, { channel, name, onWarning, value, ...conf }) {
26
31
  const named = nameOf(name);
27
32
  const where = needOf(channel);
28
- const id = await gameOf(conf);
33
+ const parsed = await given(conf);
34
+ const id = await gameOf({ ...conf, project: parsed });
35
+ const declared = parsed.function?.secrets;
36
+ if (!(Array.isArray(declared) && declared.includes(named)) && onWarning) {
37
+ onWarning({
38
+ code: WARNING.SECRET_UNDECLARED,
39
+ message: secretUndeclared(named),
40
+ });
41
+ }
29
42
  const headers = headersOf(current);
30
43
  const secret = await value();
31
44
  if (typeof secret !== "string" || secret === "") {
@@ -3,7 +3,8 @@
3
3
  import { defineCommand } from "../../../cli/command.js";
4
4
  import { password } from "../../../cli/prompt.js";
5
5
  import { secretPrompt, secretSet } from "../../../phrase/index.js";
6
- import { p } from "../../../util/log.js";
6
+ import { p, pw } from "../../../util/log.js";
7
+ import { warning } from "../../../util/output.js";
7
8
  import { NAME } from "./name.js";
8
9
  import { CHANNEL, CWD, JSON_OUTPUT, QUIET } from "../../../cli/options.js";
9
10
  import { run } from "./run.js";
@@ -36,11 +37,22 @@ export default defineCommand({
36
37
  options: { ...CHANNEL, json: JSON_OUTPUT, quiet: QUIET, cwd: CWD },
37
38
  positionals: { name: NAME },
38
39
  run(argv, aborting) {
40
+ // what --json lists under `warnings`, beside the result or the error:
41
+ // a name the manifest doesn't declare (secret_undeclared), printed at
42
+ // once otherwise, before the value is asked for.
43
+ const warnings = [];
44
+ aborting.data = { warnings };
39
45
  return run(argv, aborting, (current, conf) => set(current, {
40
46
  ...conf,
41
47
  name: argv.name,
48
+ onWarning({ code, message }) {
49
+ warnings.push(warning(code, message));
50
+ if (!argv.json && !argv.quiet) {
51
+ pw(message);
52
+ }
53
+ },
42
54
  value: () => valueOf(argv.name, argv.json),
43
- }), (kept) => {
55
+ }).then((kept) => ({ ...kept, warnings })), (kept) => {
44
56
  p(secretSet(kept));
45
57
  }, `arc function secret set ${argv.name}`);
46
58
  },
@@ -136,6 +136,7 @@ export const WARNING = {
136
136
  PACKAGE_FILE_PRIVATE: "package_file_private",
137
137
  SCREENSHOT_NAME_INVALID: "screenshot_name_invalid",
138
138
  SDK_SCRIPT_PATH: "sdk_script_path",
139
+ SECRET_UNDECLARED: "secret_undeclared",
139
140
  SECRET_UNSET: "secret_unset",
140
141
  VERSION_UNCHECKED: "version_unchecked",
141
142
  };
@@ -114,6 +114,14 @@ export function secretSet({ channel, name, }) {
114
114
  return `Set ${name} for ${channel}.\nThe game's function has it within a minute.`;
115
115
  }
116
116
  // [function]
117
+ // a secret set by a name the project's manifest doesn't declare, which
118
+ // `arc function secret set` warns of (secret_undeclared): only declared
119
+ // secrets are sealed into a build, so no release reads it until one
120
+ // declares it.
121
+ export function secretUndeclared(name) {
122
+ return `Secret ${name} isn't in the manifest's [function] secrets.\nThe game's function reads it once a release declares it there.`;
123
+ }
124
+ // [function]
117
125
  // a secret a build declares that has no value on the channel it goes to,
118
126
  // which `arc deploy` warns of (action/predeploy/secrets.ts).
119
127
  export function secretUnset({ channel, name, }) {
@@ -42,7 +42,7 @@
42
42
  },
43
43
  "license": "Apache-2.0",
44
44
  "name": "arcadible",
45
- "version": "1.0.51"
45
+ "version": "1.0.52"
46
46
  },
47
47
  "node_modules/@cacheable/memory": {
48
48
  "dependencies": {
@@ -2433,5 +2433,5 @@
2433
2433
  }
2434
2434
  },
2435
2435
  "requires": true,
2436
- "version": "1.0.51"
2436
+ "version": "1.0.52"
2437
2437
  }
package/package.json CHANGED
@@ -68,5 +68,5 @@
68
68
  "test": "tsc && npm run lint && node --test \"test/**/*.test.js\" \"test/**/*.test.mjs\""
69
69
  },
70
70
  "type": "module",
71
- "version": "1.0.51"
71
+ "version": "1.0.52"
72
72
  }