@latticexyz/cli 1.33.1 → 1.35.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022-present Lattice Labs Ltd.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -16,26 +16,6 @@ var __copyProps = (to, from, except, desc2) => {
16
16
  return to;
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var __async = (__this, __arguments, generator) => {
20
- return new Promise((resolve, reject) => {
21
- var fulfilled = (value) => {
22
- try {
23
- step(generator.next(value));
24
- } catch (e) {
25
- reject(e);
26
- }
27
- };
28
- var rejected = (value) => {
29
- try {
30
- step(generator.throw(value));
31
- } catch (e) {
32
- reject(e);
33
- }
34
- };
35
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
36
- step((generator = generator.apply(__this, __arguments)).next());
37
- });
38
- };
39
19
 
40
20
  // src/commands/bulkupload.ts
41
21
  var bulkupload_exports = {};
@@ -54,14 +34,14 @@ var builder = (yargs) => yargs.options({
54
34
  worldAddress: { type: "string", demandOption: true, desc: "Contract address of the World to upload to" },
55
35
  rpc: { type: "string", demandOption: true, desc: "JSON RPC endpoint" }
56
36
  });
57
- var handler = (argv) => __async(void 0, null, function* () {
58
- const { execa } = yield importExeca;
37
+ var handler = async (argv) => {
38
+ const { execa } = await importExeca;
59
39
  const { statePath, worldAddress, rpc } = argv;
60
40
  console.log("Uploading state at ", statePath, "to", worldAddress, "on", rpc);
61
41
  const url = __dirname + "/../../src/contracts/BulkUpload.sol";
62
42
  console.log("Using BulkUpload script from", url);
63
43
  try {
64
- yield execa("forge", [
44
+ await execa("forge", [
65
45
  "script",
66
46
  "--sig",
67
47
  '"run(string, address)"',
@@ -75,7 +55,7 @@ var handler = (argv) => __async(void 0, null, function* () {
75
55
  console.error(e);
76
56
  }
77
57
  process.exit(0);
78
- });
58
+ };
79
59
  // Annotate the CommonJS export names for ESM import in node:
80
60
  0 && (module.exports = {
81
61
  builder,
@@ -25,26 +25,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
25
25
  mod
26
26
  ));
27
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
- var __async = (__this, __arguments, generator) => {
29
- return new Promise((resolve, reject) => {
30
- var fulfilled = (value) => {
31
- try {
32
- step(generator.next(value));
33
- } catch (e) {
34
- reject(e);
35
- }
36
- };
37
- var rejected = (value) => {
38
- try {
39
- step(generator.throw(value));
40
- } catch (e) {
41
- reject(e);
42
- }
43
- };
44
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
45
- step((generator = generator.apply(__this, __arguments)).next());
46
- });
47
- };
48
28
 
49
29
  // ../../node_modules/bn.js/lib/bn.js
50
30
  var require_bn = __commonJS({
@@ -204014,19 +203994,17 @@ function deferred() {
204014
203994
  }
204015
203995
 
204016
203996
  // src/utils/exec.ts
204017
- function execLog(command2, options) {
204018
- return __async(this, null, function* () {
204019
- console.log("Cmd:");
204020
- console.log([command2, ...options].join(" "));
204021
- const [resolve, , promise] = deferred();
204022
- const child = (0, import_child_process.spawn)(command2, options, { stdio: [process.stdin, process.stdout, process.stderr] });
204023
- child.on("exit", (code) => resolve({ exitCode: code != null ? code : 0, child }));
204024
- return promise;
204025
- });
203997
+ async function execLog(command2, options) {
203998
+ console.log("Cmd:");
203999
+ console.log([command2, ...options].join(" "));
204000
+ const [resolve, , promise] = deferred();
204001
+ const child = (0, import_child_process.spawn)(command2, options, { stdio: [process.stdin, process.stdout, process.stderr] });
204002
+ child.on("exit", (code) => resolve({ exitCode: code ?? 0, child }));
204003
+ return promise;
204026
204004
  }
204027
204005
 
204028
204006
  // src/utils/ids.ts
204029
- var IDregex = new RegExp(new RegExp('(?<=uint256 constant ID = uint256\\(keccak256\\(")(.*)(?="\\))'));
204007
+ var IDregex = new RegExp(/(?<=uint256 constant ID = uint256\(keccak256\(")(.*)(?="\))/);
204030
204008
 
204031
204009
  // src/utils/codegen.ts
204032
204010
  var import_promises = require("fs/promises");
@@ -204504,7 +204482,7 @@ var contractsDir2 = __dirname + "/../../src/contracts";
204504
204482
 
204505
204483
  // src/utils/hsr.ts
204506
204484
  var import_chokidar = __toESM(require_chokidar());
204507
- var ImportsRegex = new RegExp(new RegExp('(?<=import ").*(?=";)|(?<=from ").*(?=";)', "g"));
204485
+ var ImportsRegex = new RegExp(/(?<=import ").*(?=";)|(?<=from ").*(?=";)/g);
204508
204486
 
204509
204487
  // src/commands/call-system.ts
204510
204488
  var command = "call-system";
@@ -204525,18 +204503,17 @@ var builder = (yargs) => yargs.options({
204525
204503
  },
204526
204504
  debug: { type: "boolean", description: "open debugger" }
204527
204505
  });
204528
- var handler = (argv) => __async(void 0, null, function* () {
204529
- var _a;
204506
+ var handler = async (argv) => {
204530
204507
  const { rpc, caller, world, systemId, argTypes, args, calldata, broadcast, callerPrivateKey, debug } = argv;
204531
- const encodedArgs = (_a = calldata != null ? calldata : argTypes && args && import_utils.defaultAbiCoder.encode(argTypes, args)) != null ? _a : "";
204532
- yield execLog("forge", [
204508
+ const encodedArgs = calldata ?? (argTypes && args && import_utils.defaultAbiCoder.encode(argTypes, args)) ?? "";
204509
+ await execLog("forge", [
204533
204510
  "script",
204534
204511
  "--fork-url",
204535
- rpc != null ? rpc : "http://localhost:8545",
204512
+ rpc ?? "http://localhost:8545",
204536
204513
  "--sig",
204537
204514
  "debug(address,address,string,bytes,bool)",
204538
204515
  "src/test/utils/Debug.sol",
204539
- caller != null ? caller : "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266",
204516
+ caller ?? "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266",
204540
204517
  world,
204541
204518
  systemId || "",
204542
204519
  encodedArgs,
@@ -204547,7 +204524,7 @@ var handler = (argv) => __async(void 0, null, function* () {
204547
204524
  debug ? "--debug" : ""
204548
204525
  ]);
204549
204526
  process.exit(0);
204550
- });
204527
+ };
204551
204528
  // Annotate the CommonJS export names for ESM import in node:
204552
204529
  0 && (module.exports = {
204553
204530
  builder,
@@ -25,26 +25,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
25
25
  mod
26
26
  ));
27
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
- var __async = (__this, __arguments, generator) => {
29
- return new Promise((resolve, reject) => {
30
- var fulfilled = (value) => {
31
- try {
32
- step(generator.next(value));
33
- } catch (e) {
34
- reject(e);
35
- }
36
- };
37
- var rejected = (value) => {
38
- try {
39
- step(generator.throw(value));
40
- } catch (e) {
41
- reject(e);
42
- }
43
- };
44
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
45
- step((generator = generator.apply(__this, __arguments)).next());
46
- });
47
- };
48
28
 
49
29
  // ../../node_modules/ejs/lib/utils.js
50
30
  var require_utils = __commonJS({
@@ -180792,7 +180772,7 @@ __export(codegen_libdeploy_exports, {
180792
180772
  module.exports = __toCommonJS(codegen_libdeploy_exports);
180793
180773
 
180794
180774
  // src/utils/ids.ts
180795
- var IDregex = new RegExp(new RegExp('(?<=uint256 constant ID = uint256\\(keccak256\\(")(.*)(?="\\))'));
180775
+ var IDregex = new RegExp(/(?<=uint256 constant ID = uint256\(keccak256\(")(.*)(?="\))/);
180796
180776
 
180797
180777
  // src/utils/codegen.ts
180798
180778
  var import_promises = require("fs/promises");
@@ -180800,21 +180780,20 @@ var import_ejs = __toESM(require_ejs());
180800
180780
  var import_path = __toESM(require("path"));
180801
180781
  var contractsDir = import_path.default.join(__dirname, "../../src/contracts");
180802
180782
  var stubLibDeploy = (0, import_promises.readFile)(import_path.default.join(contractsDir, "LibDeployStub.sol"));
180803
- function generateLibDeploy(configPath, out, systems) {
180804
- return __async(this, null, function* () {
180805
- const config = JSON.parse(yield (0, import_promises.readFile)(configPath, { encoding: "utf8" }));
180806
- if (systems) {
180807
- const systemsArray = Array.isArray(systems) ? systems : [systems];
180808
- config.systems = config.systems.filter((system) => systemsArray.includes(system.name));
180809
- }
180810
- console.log(`Deploy config:
180783
+ async function generateLibDeploy(configPath, out, systems) {
180784
+ const config = JSON.parse(await (0, import_promises.readFile)(configPath, { encoding: "utf8" }));
180785
+ config.initializers ??= [];
180786
+ if (systems) {
180787
+ const systemsArray = Array.isArray(systems) ? systems : [systems];
180788
+ config.systems = config.systems.filter((system) => systemsArray.includes(system.name));
180789
+ }
180790
+ console.log(`Deploy config:
180811
180791
  `, JSON.stringify(config, null, 2));
180812
- console.log("Generating deployment script");
180813
- const LibDeploy = yield import_ejs.default.renderFile(import_path.default.join(contractsDir, "LibDeploy.ejs"), config, { async: true });
180814
- const libDeployPath = import_path.default.join(out, "LibDeploy.sol");
180815
- yield (0, import_promises.writeFile)(libDeployPath, LibDeploy);
180816
- return libDeployPath;
180817
- });
180792
+ console.log("Generating deployment script");
180793
+ const LibDeploy = await import_ejs.default.renderFile(import_path.default.join(contractsDir, "LibDeploy.ejs"), config, { async: true });
180794
+ const libDeployPath = import_path.default.join(out, "LibDeploy.sol");
180795
+ await (0, import_promises.writeFile)(libDeployPath, LibDeploy);
180796
+ return libDeployPath;
180818
180797
  }
180819
180798
 
180820
180799
  // src/utils/types.ts
@@ -181286,7 +181265,7 @@ var contractsDir2 = __dirname + "/../../src/contracts";
181286
181265
 
181287
181266
  // src/utils/hsr.ts
181288
181267
  var import_chokidar = __toESM(require_chokidar());
181289
- var ImportsRegex = new RegExp(new RegExp('(?<=import ").*(?=";)|(?<=from ").*(?=";)', "g"));
181268
+ var ImportsRegex = new RegExp(/(?<=import ").*(?=";)|(?<=from ").*(?=";)/g);
181290
181269
 
181291
181270
  // src/commands/codegen-libdeploy.ts
181292
181271
  var command = "codegen-libdeploy";
@@ -181296,11 +181275,11 @@ var builder = (yargs) => yargs.options({
181296
181275
  out: { type: "string", default: ".", desc: "Output directory for LibDeploy.sol" },
181297
181276
  systems: { type: "string", desc: "Only generate deploy code for the given systems" }
181298
181277
  });
181299
- var handler = (args) => __async(void 0, null, function* () {
181278
+ var handler = async (args) => {
181300
181279
  const { config, out, systems } = args;
181301
- yield generateLibDeploy(config, out, systems);
181280
+ await generateLibDeploy(config, out, systems);
181302
181281
  process.exit(0);
181303
- });
181282
+ };
181304
181283
  // Annotate the CommonJS export names for ESM import in node:
181305
181284
  0 && (module.exports = {
181306
181285
  builder,
@@ -25,26 +25,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
25
25
  mod
26
26
  ));
27
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
- var __async = (__this, __arguments, generator) => {
29
- return new Promise((resolve, reject) => {
30
- var fulfilled = (value) => {
31
- try {
32
- step(generator.next(value));
33
- } catch (e) {
34
- reject(e);
35
- }
36
- };
37
- var rejected = (value) => {
38
- try {
39
- step(generator.throw(value));
40
- } catch (e) {
41
- reject(e);
42
- }
43
- };
44
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
45
- step((generator = generator.apply(__this, __arguments)).next());
46
- });
47
- };
48
28
 
49
29
  // ../../node_modules/ejs/lib/utils.js
50
30
  var require_utils = __commonJS({
@@ -180806,19 +180786,17 @@ function deferred() {
180806
180786
  }
180807
180787
 
180808
180788
  // src/utils/exec.ts
180809
- function execLog(command2, options) {
180810
- return __async(this, null, function* () {
180811
- console.log("Cmd:");
180812
- console.log([command2, ...options].join(" "));
180813
- const [resolve, , promise] = deferred();
180814
- const child = (0, import_child_process.spawn)(command2, options, { stdio: [process.stdin, process.stdout, process.stderr] });
180815
- child.on("exit", (code) => resolve({ exitCode: code != null ? code : 0, child }));
180816
- return promise;
180817
- });
180789
+ async function execLog(command2, options) {
180790
+ console.log("Cmd:");
180791
+ console.log([command2, ...options].join(" "));
180792
+ const [resolve, , promise] = deferred();
180793
+ const child = (0, import_child_process.spawn)(command2, options, { stdio: [process.stdin, process.stdout, process.stderr] });
180794
+ child.on("exit", (code) => resolve({ exitCode: code ?? 0, child }));
180795
+ return promise;
180818
180796
  }
180819
180797
 
180820
180798
  // src/utils/ids.ts
180821
- var IDregex = new RegExp(new RegExp('(?<=uint256 constant ID = uint256\\(keccak256\\(")(.*)(?="\\))'));
180799
+ var IDregex = new RegExp(/(?<=uint256 constant ID = uint256\(keccak256\(")(.*)(?="\))/);
180822
180800
 
180823
180801
  // src/utils/codegen.ts
180824
180802
  var import_promises = require("fs/promises");
@@ -181296,7 +181274,7 @@ var contractsDir2 = __dirname + "/../../src/contracts";
181296
181274
 
181297
181275
  // src/utils/hsr.ts
181298
181276
  var import_chokidar = __toESM(require_chokidar());
181299
- var ImportsRegex = new RegExp(new RegExp('(?<=import ").*(?=";)|(?<=from ").*(?=";)', "g"));
181277
+ var ImportsRegex = new RegExp(/(?<=import ").*(?=";)|(?<=from ").*(?=";)/g);
181300
181278
 
181301
181279
  // node_modules/chalk/source/vendor/ansi-styles/index.js
181302
181280
  var ANSI_BACKGROUND_OFFSET = 10;
@@ -181772,19 +181750,19 @@ var desc = "Sets up a mud project into <name>. Requires yarn.";
181772
181750
  var builder = (yargs) => yargs.options({
181773
181751
  template: { type: "string", desc: "Template to be used (available: [minimal])", default: "minimal" }
181774
181752
  }).positional("name", { type: "string", default: "mud-app" });
181775
- var handler = (argv) => __async(void 0, null, function* () {
181753
+ var handler = async (argv) => {
181776
181754
  const { name, template } = argv;
181777
181755
  console.log(source_default.yellow.bold("Creating new mud project in", name));
181778
- let result = yield execLog("git", ["clone", `https://github.com/latticexyz/mud-template-${template}`, name]);
181756
+ let result = await execLog("git", ["clone", `https://github.com/latticexyz/mud-template-${template}`, name]);
181779
181757
  if (result.exitCode != 0)
181780
181758
  process.exit(result.exitCode);
181781
181759
  console.log(source_default.yellow.bold("Installing dependencies..."));
181782
- result = yield execLog("yarn", ["--cwd", `./${name}`]);
181760
+ result = await execLog("yarn", ["--cwd", `./${name}`]);
181783
181761
  if (result.exitCode != 0)
181784
181762
  process.exit(result.exitCode);
181785
181763
  console.log(source_default.yellow.bold(`Done! Run \`yarn dev\` in ${name} to get started.`));
181786
181764
  process.exit(0);
181787
- });
181765
+ };
181788
181766
  // Annotate the CommonJS export names for ESM import in node:
181789
181767
  0 && (module.exports = {
181790
181768
  builder,