@latticexyz/cli 1.35.0 → 1.36.1
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/commands/call-system.js +2259 -1805
- package/dist/commands/deploy-contracts.js +30 -10
- package/dist/commands/deploy.js +28 -9
- package/dist/commands/system-types.js +2208 -1757
- package/dist/commands/test.js +2192 -1740
- package/dist/commands/trace.js +2345 -1887
- package/dist/commands/types.js +28 -9
- package/package.json +6 -6
- package/src/commands/call-system.ts +5 -1
- package/src/commands/deploy-contracts.ts +3 -1
- package/src/commands/system-types.ts +4 -10
- package/src/commands/test.ts +3 -3
- package/src/commands/trace.ts +9 -4
- package/src/utils/build.ts +6 -4
- package/src/utils/constants.ts +2 -0
- package/src/utils/forgeConfig.ts +45 -0
- package/src/utils/types.ts +8 -5
|
@@ -217178,18 +217178,33 @@ function execa(file, args, options) {
|
|
|
217178
217178
|
// src/utils/build.ts
|
|
217179
217179
|
var import_fs2 = require("fs");
|
|
217180
217180
|
var import_path2 = __toESM(require("path"));
|
|
217181
|
-
|
|
217181
|
+
|
|
217182
|
+
// src/utils/forgeConfig.ts
|
|
217183
|
+
async function getForgeConfig() {
|
|
217184
|
+
const { stdout } = await execa("forge", ["config", "--json"], { stdio: ["inherit", "pipe", "pipe"] });
|
|
217185
|
+
return JSON.parse(stdout);
|
|
217186
|
+
}
|
|
217187
|
+
async function getSrcDirectory() {
|
|
217188
|
+
return (await getForgeConfig()).src;
|
|
217189
|
+
}
|
|
217190
|
+
async function getOutDirectory() {
|
|
217191
|
+
return (await getForgeConfig()).out;
|
|
217192
|
+
}
|
|
217193
|
+
|
|
217194
|
+
// src/utils/build.ts
|
|
217195
|
+
async function forgeBuild(options) {
|
|
217182
217196
|
if (options?.clear) {
|
|
217197
|
+
const out = await getOutDirectory();
|
|
217183
217198
|
console.log("Clearing forge build output directory", out);
|
|
217184
217199
|
(0, import_fs2.rmSync)(out, { recursive: true, force: true });
|
|
217185
217200
|
}
|
|
217186
217201
|
console.log("Running forge build");
|
|
217187
|
-
const child = execa("forge", ["build"
|
|
217202
|
+
const child = execa("forge", ["build"], {
|
|
217188
217203
|
stdio: ["inherit", "pipe", "inherit"]
|
|
217189
217204
|
});
|
|
217190
217205
|
return (await child).stdout;
|
|
217191
217206
|
}
|
|
217192
|
-
function
|
|
217207
|
+
function getContractsInDirectory(dir, exclude) {
|
|
217193
217208
|
return (0, import_fs2.readdirSync)(dir).filter((item) => item.includes(".sol")).map((item) => item.replace(".sol", "")).filter((item) => !exclude?.includes(item));
|
|
217194
217209
|
}
|
|
217195
217210
|
function copyAbi(inDir, outDir, contract) {
|
|
@@ -217204,7 +217219,7 @@ function filterAbi(abiIn = "./out", abiOut = "./abi", exclude = ["Component", "I
|
|
|
217204
217219
|
(0, import_fs2.rmSync)(abiOut, { recursive: true, force: true });
|
|
217205
217220
|
(0, import_fs2.mkdirSync)(abiOut);
|
|
217206
217221
|
const include = ["Component", "System", "World", "LibQuery"];
|
|
217207
|
-
const contracts =
|
|
217222
|
+
const contracts = getContractsInDirectory(abiIn, exclude).filter((item) => include.find((i) => item.includes(i)));
|
|
217208
217223
|
console.log("Selected ABIs: ", contracts);
|
|
217209
217224
|
for (const contract of contracts) {
|
|
217210
217225
|
if (contract.includes(".t"))
|
|
@@ -217214,6 +217229,9 @@ function filterAbi(abiIn = "./out", abiOut = "./abi", exclude = ["Component", "I
|
|
|
217214
217229
|
console.log("Successfully moved selected ABIs to ./abi");
|
|
217215
217230
|
}
|
|
217216
217231
|
|
|
217232
|
+
// src/utils/constants.ts
|
|
217233
|
+
var systemsDir = "systems";
|
|
217234
|
+
|
|
217217
217235
|
// src/utils/types.ts
|
|
217218
217236
|
async function generateAbiTypes(inputDir, outputDir, options) {
|
|
217219
217237
|
if (options?.clear) {
|
|
@@ -217231,7 +217249,7 @@ async function generateAbiTypes(inputDir, outputDir, options) {
|
|
|
217231
217249
|
});
|
|
217232
217250
|
console.log(`Successfully generated ${result.filesGenerated} files`);
|
|
217233
217251
|
}
|
|
217234
|
-
async function generateSystemTypes(
|
|
217252
|
+
async function generateSystemTypes(outputDir, options) {
|
|
217235
217253
|
if (options?.clear) {
|
|
217236
217254
|
console.log("Clearing system type output files", outputDir);
|
|
217237
217255
|
(0, import_fs3.rmSync)(import_path3.default.join(outputDir, "/SystemTypes.ts"), { force: true });
|
|
@@ -217243,7 +217261,8 @@ async function generateSystemTypes(inputDir, outputDir, options) {
|
|
|
217243
217261
|
let systems = [];
|
|
217244
217262
|
let ids = [];
|
|
217245
217263
|
let typePaths = [];
|
|
217246
|
-
const
|
|
217264
|
+
const srcDir = await getSrcDirectory();
|
|
217265
|
+
const systemsPath = import_path3.default.join(srcDir, systemsDir, "*.sol");
|
|
217247
217266
|
const [resolve, , promise] = deferred();
|
|
217248
217267
|
(0, import_glob.default)(systemsPath, {}, (_, matches) => {
|
|
217249
217268
|
systems = matches.map((path6) => {
|
|
@@ -217305,13 +217324,13 @@ ${systems.map((system, index) => ` "${ids[index]}": ${system}.abi,`).join("\n")
|
|
|
217305
217324
|
async function generateTypes(abiDir, outputDir = "./types", options) {
|
|
217306
217325
|
if (!abiDir) {
|
|
217307
217326
|
console.log("Compiling contracts");
|
|
217308
|
-
const buildOutput =
|
|
217327
|
+
const buildOutput = await getOutDirectory();
|
|
217309
217328
|
abiDir = "./abi";
|
|
217310
|
-
await forgeBuild(
|
|
217329
|
+
await forgeBuild(options);
|
|
217311
217330
|
filterAbi(buildOutput, abiDir);
|
|
217312
217331
|
}
|
|
217313
217332
|
await generateAbiTypes(abiDir, import_path3.default.join(outputDir, "ethers-contracts"), options);
|
|
217314
|
-
await generateSystemTypes(
|
|
217333
|
+
await generateSystemTypes(outputDir, options);
|
|
217315
217334
|
}
|
|
217316
217335
|
|
|
217317
217336
|
// src/utils/deploy.ts
|
|
@@ -217943,7 +217962,8 @@ var handler = async (args) => {
|
|
|
217943
217962
|
}
|
|
217944
217963
|
if (args.watch) {
|
|
217945
217964
|
const { config, rpc, gasPrice } = args;
|
|
217946
|
-
|
|
217965
|
+
const srcDir = await getSrcDirectory();
|
|
217966
|
+
hsr(srcDir, async (systems) => {
|
|
217947
217967
|
try {
|
|
217948
217968
|
return await generateAndDeploy({
|
|
217949
217969
|
config,
|
package/dist/commands/deploy.js
CHANGED
|
@@ -270319,18 +270319,33 @@ function execa(file, args, options) {
|
|
|
270319
270319
|
// src/utils/build.ts
|
|
270320
270320
|
var import_fs2 = require("fs");
|
|
270321
270321
|
var import_path2 = __toESM(require("path"));
|
|
270322
|
-
|
|
270322
|
+
|
|
270323
|
+
// src/utils/forgeConfig.ts
|
|
270324
|
+
async function getForgeConfig() {
|
|
270325
|
+
const { stdout } = await execa("forge", ["config", "--json"], { stdio: ["inherit", "pipe", "pipe"] });
|
|
270326
|
+
return JSON.parse(stdout);
|
|
270327
|
+
}
|
|
270328
|
+
async function getSrcDirectory() {
|
|
270329
|
+
return (await getForgeConfig()).src;
|
|
270330
|
+
}
|
|
270331
|
+
async function getOutDirectory() {
|
|
270332
|
+
return (await getForgeConfig()).out;
|
|
270333
|
+
}
|
|
270334
|
+
|
|
270335
|
+
// src/utils/build.ts
|
|
270336
|
+
async function forgeBuild(options) {
|
|
270323
270337
|
if (options?.clear) {
|
|
270338
|
+
const out = await getOutDirectory();
|
|
270324
270339
|
console.log("Clearing forge build output directory", out);
|
|
270325
270340
|
(0, import_fs2.rmSync)(out, { recursive: true, force: true });
|
|
270326
270341
|
}
|
|
270327
270342
|
console.log("Running forge build");
|
|
270328
|
-
const child = execa("forge", ["build"
|
|
270343
|
+
const child = execa("forge", ["build"], {
|
|
270329
270344
|
stdio: ["inherit", "pipe", "inherit"]
|
|
270330
270345
|
});
|
|
270331
270346
|
return (await child).stdout;
|
|
270332
270347
|
}
|
|
270333
|
-
function
|
|
270348
|
+
function getContractsInDirectory(dir, exclude) {
|
|
270334
270349
|
return (0, import_fs2.readdirSync)(dir).filter((item) => item.includes(".sol")).map((item) => item.replace(".sol", "")).filter((item) => !exclude?.includes(item));
|
|
270335
270350
|
}
|
|
270336
270351
|
function copyAbi(inDir, outDir, contract) {
|
|
@@ -270345,7 +270360,7 @@ function filterAbi(abiIn = "./out", abiOut = "./abi", exclude = ["Component", "I
|
|
|
270345
270360
|
(0, import_fs2.rmSync)(abiOut, { recursive: true, force: true });
|
|
270346
270361
|
(0, import_fs2.mkdirSync)(abiOut);
|
|
270347
270362
|
const include = ["Component", "System", "World", "LibQuery"];
|
|
270348
|
-
const contracts =
|
|
270363
|
+
const contracts = getContractsInDirectory(abiIn, exclude).filter((item) => include.find((i) => item.includes(i)));
|
|
270349
270364
|
console.log("Selected ABIs: ", contracts);
|
|
270350
270365
|
for (const contract of contracts) {
|
|
270351
270366
|
if (contract.includes(".t"))
|
|
@@ -270355,6 +270370,9 @@ function filterAbi(abiIn = "./out", abiOut = "./abi", exclude = ["Component", "I
|
|
|
270355
270370
|
console.log("Successfully moved selected ABIs to ./abi");
|
|
270356
270371
|
}
|
|
270357
270372
|
|
|
270373
|
+
// src/utils/constants.ts
|
|
270374
|
+
var systemsDir = "systems";
|
|
270375
|
+
|
|
270358
270376
|
// src/utils/types.ts
|
|
270359
270377
|
async function generateAbiTypes(inputDir, outputDir, options) {
|
|
270360
270378
|
if (options?.clear) {
|
|
@@ -270372,7 +270390,7 @@ async function generateAbiTypes(inputDir, outputDir, options) {
|
|
|
270372
270390
|
});
|
|
270373
270391
|
console.log(`Successfully generated ${result.filesGenerated} files`);
|
|
270374
270392
|
}
|
|
270375
|
-
async function generateSystemTypes(
|
|
270393
|
+
async function generateSystemTypes(outputDir, options) {
|
|
270376
270394
|
if (options?.clear) {
|
|
270377
270395
|
console.log("Clearing system type output files", outputDir);
|
|
270378
270396
|
(0, import_fs3.rmSync)(import_path3.default.join(outputDir, "/SystemTypes.ts"), { force: true });
|
|
@@ -270384,7 +270402,8 @@ async function generateSystemTypes(inputDir, outputDir, options) {
|
|
|
270384
270402
|
let systems = [];
|
|
270385
270403
|
let ids = [];
|
|
270386
270404
|
let typePaths = [];
|
|
270387
|
-
const
|
|
270405
|
+
const srcDir = await getSrcDirectory();
|
|
270406
|
+
const systemsPath = import_path3.default.join(srcDir, systemsDir, "*.sol");
|
|
270388
270407
|
const [resolve, , promise] = deferred();
|
|
270389
270408
|
(0, import_glob.default)(systemsPath, {}, (_, matches) => {
|
|
270390
270409
|
systems = matches.map((path6) => {
|
|
@@ -270446,13 +270465,13 @@ ${systems.map((system, index) => ` "${ids[index]}": ${system}.abi,`).join("\n")
|
|
|
270446
270465
|
async function generateTypes(abiDir, outputDir = "./types", options) {
|
|
270447
270466
|
if (!abiDir) {
|
|
270448
270467
|
console.log("Compiling contracts");
|
|
270449
|
-
const buildOutput =
|
|
270468
|
+
const buildOutput = await getOutDirectory();
|
|
270450
270469
|
abiDir = "./abi";
|
|
270451
|
-
await forgeBuild(
|
|
270470
|
+
await forgeBuild(options);
|
|
270452
270471
|
filterAbi(buildOutput, abiDir);
|
|
270453
270472
|
}
|
|
270454
270473
|
await generateAbiTypes(abiDir, import_path3.default.join(outputDir, "ethers-contracts"), options);
|
|
270455
|
-
await generateSystemTypes(
|
|
270474
|
+
await generateSystemTypes(outputDir, options);
|
|
270456
270475
|
}
|
|
270457
270476
|
|
|
270458
270477
|
// src/utils/deploy.ts
|