@everyprotocol/every-cli 0.1.6 → 0.1.7

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/cmds/pick.js CHANGED
@@ -3,14 +3,22 @@ import path from "node:path";
3
3
  import jp from "jsonpath";
4
4
  import * as _ from "lodash-es";
5
5
  import { Command } from "commander";
6
+ import { loadMergedConfig } from "../config.js";
6
7
  const DEFAULT_DIR = "./register";
8
+ const DEFAULT_UNIVERSE = "anvil";
7
9
  const STATIC_RULES = {
10
+ // config
11
+ "universe.id": { file: "config://universe.json", root: "$", field: "id" },
12
+ "universe.sreg": { file: "config://universe.json", root: "$", field: "contracts.SetRegistry" },
13
+ "universe.oreg": { file: "config://universe.json", root: "$", field: "contracts.OmniRegistry" },
14
+ "universe.kreg": { file: "config://universe.json", root: "$", field: "contracts.KindRegistry" },
15
+ "universe.ereg": { file: "config://universe.json", root: "$", field: "contracts.ElementRegistry" },
16
+ "universe.minter": { file: "config://universe.json", root: "$", field: "contracts.ObjectMinter" },
17
+ "universe.rpc": { file: "config://universe.json", root: "$", field: "rpc" },
18
+ "universe.observer": { file: "config://universe.json", root: "$", field: "observer" },
8
19
  // contract
9
- "deploy.addr": {
10
- file: "deploy.json",
11
- root: "$",
12
- field: "deployedTo",
13
- },
20
+ "deploy.addr": { file: "deploy.json", root: "$", field: "deployedTo" },
21
+ "contract.addr": { file: "contract.json", root: "$", field: "deployedTo" },
14
22
  // kind
15
23
  "kind.id": { file: "kind.json", root: "$.events[?(@.name=='KindRegistered')].data", field: "id" },
16
24
  "kind.rev": { file: "kind.json", root: "$.events[?(@.name=='KindRegistered')].data.desc", field: "rev" },
@@ -99,13 +107,24 @@ export const pickCmd = new Command("pick")
99
107
  .description("Pick values from outputs")
100
108
  .argument("<keys...>", "Keys to resolve")
101
109
  .option("--from <dir>", "Output directory", DEFAULT_DIR)
110
+ .option("-u, --universe <name>", "Universe name", DEFAULT_UNIVERSE)
102
111
  .action(function (keys) {
103
- const { from } = this.opts();
104
- const dir = from || DEFAULT_DIR;
112
+ const { from, universe } = this.opts();
105
113
  const loadJsonCache = _.memoize((rel) => {
106
- const full = path.join(dir, rel);
114
+ if (rel == "config://universe.json") {
115
+ return loadUniverseConfig(universe);
116
+ }
117
+ const full = path.join(from, rel);
107
118
  return loadJson(full);
108
119
  });
109
120
  const outputs = keys.map((key) => pickOnce(loadJsonCache, key));
110
121
  console.log(outputs.join(" "));
111
122
  });
123
+ function loadUniverseConfig(universe) {
124
+ const config = loadMergedConfig();
125
+ const uniConf = config.universes?.[universe];
126
+ if (!uniConf) {
127
+ throw new Error(`config for universe ${universe} not found`);
128
+ }
129
+ return uniConf;
130
+ }
@@ -7,11 +7,10 @@ export const privateKey = new Option("-k, --private-key <key>", "Private key to
7
7
  export const foundry = new Option("-f, --foundry", "Use foundry keystores (~/.foundry/keystores)");
8
8
  export const universe = new Option("-u, --universe <universe>", "Universe name").default("anvil");
9
9
  export const network = new Option("-n, --network <network>", "Network name").default("dev");
10
- export const json = new Option("-j, --json [file]", "Output result as JSON to stdout or file, implies --quiet");
10
+ export const json = new Option("-j, --json [file]", "Output result as JSON to stdout or file");
11
11
  export const quiet = new Option("-q, --quiet", "Suppress info messages");
12
- export const noQuiet = new Option("--no-quiet", "Force info messages even when --json is set");
13
12
  export const keystoreOptions = [account, password, passwordFile, foundry];
14
- export const outputOptions = [json, quiet, noQuiet];
13
+ export const outputOptions = [json, quiet];
15
14
  export const writeOptions = [universe, account, password, passwordFile, foundry];
16
15
  Command.prototype.addCommands = function (commands) {
17
16
  commands.forEach((cmd) => this.addCommand(cmd));
@@ -29,7 +28,7 @@ Command.prototype.addKeystoreOptions = function () {
29
28
  return this.addOptions([account, password, passwordFile, foundry]);
30
29
  };
31
30
  Command.prototype.addOutputOptions = function () {
32
- return this.addOptions([json, quiet, noQuiet]);
31
+ return this.addOptions([json, quiet]);
33
32
  };
34
33
  Command.prototype.addWriteOptions = function () {
35
34
  return this.addKeystoreOptions().addOption(universe);
package/dist/logger.js CHANGED
@@ -5,7 +5,7 @@ export class Logger {
5
5
  quiet;
6
6
  json;
7
7
  constructor(opts = {}) {
8
- this.quiet = opts.quiet ?? !!opts.json;
8
+ this.quiet = opts.quiet ?? false;
9
9
  this.json = opts.json ?? false;
10
10
  }
11
11
  log(...args) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@everyprotocol/every-cli",
3
3
  "type": "module",
4
- "version": "0.1.6",
4
+ "version": "0.1.7",
5
5
  "files": [
6
6
  "dist/",
7
7
  "abis/",