@latticexyz/cli 2.0.0-alpha.73 → 2.0.0-alpha.76
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/{chunk-MIGVHECZ.js → chunk-DO7OWTMM.js} +31 -6
- package/dist/{chunk-S7JI7355.js → chunk-MN3HYFJK.js} +2 -1
- package/dist/{chunk-QGY6YXME.js → chunk-XUNWAEP7.js} +4380 -4188
- package/dist/{chunk-PQLNWP7H.js → chunk-XXPMNFXC.js} +47 -45
- package/dist/config/index.d.ts +3 -2
- package/dist/config/index.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/mud.js +4 -4
- package/dist/mud2.js +4 -4
- package/dist/{parseStoreConfig-05533795.d.ts → parseStoreConfig-8aa69ac9.d.ts} +8 -0
- package/dist/render-solidity/index.d.ts +1 -1
- package/dist/render-solidity/index.js +1 -1
- package/dist/render-ts/index.d.ts +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +2 -2
- package/package.json +7 -7
- package/src/commands/tablegen.ts +4 -4
- package/src/commands/worldgen.ts +4 -2
- package/src/config/parseStoreConfig.ts +3 -0
- package/src/render-solidity/renderTableIndex.ts +15 -0
- package/src/render-solidity/tablegen.ts +12 -0
|
@@ -703,18 +703,43 @@ function renderTypesFromConfig(config) {
|
|
|
703
703
|
|
|
704
704
|
// src/render-solidity/tablegen.ts
|
|
705
705
|
import path3 from "path";
|
|
706
|
+
|
|
707
|
+
// src/render-solidity/renderTableIndex.ts
|
|
708
|
+
function renderTableIndex(options) {
|
|
709
|
+
return `${renderedSolidityHeader}
|
|
710
|
+
|
|
711
|
+
${renderList(options, ({ outputPath, tableName, renderOptions: { structName, staticResourceData } }) => {
|
|
712
|
+
const imports = [tableName];
|
|
713
|
+
if (structName)
|
|
714
|
+
imports.push(structName);
|
|
715
|
+
if (staticResourceData)
|
|
716
|
+
imports.push(`${tableName}TableId`);
|
|
717
|
+
return `import { ${imports.join(", ")} } from "./${outputPath}";`;
|
|
718
|
+
})}
|
|
719
|
+
`;
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
// src/render-solidity/tablegen.ts
|
|
723
|
+
import { rmSync } from "fs";
|
|
706
724
|
async function tablegen(config, outputBaseDirectory) {
|
|
707
725
|
const allTableOptions = getTableOptions(config);
|
|
726
|
+
const uniqueTableDirectories = new Set(allTableOptions.map(({ outputPath }) => path3.dirname(outputPath)));
|
|
727
|
+
for (const tableDir of uniqueTableDirectories) {
|
|
728
|
+
rmSync(path3.join(outputBaseDirectory, tableDir), { recursive: true, force: true });
|
|
729
|
+
}
|
|
708
730
|
for (const { outputPath, renderOptions } of allTableOptions) {
|
|
709
|
-
const
|
|
710
|
-
const
|
|
711
|
-
formatAndWriteSolidity(
|
|
731
|
+
const fullOutputPath2 = path3.join(outputBaseDirectory, outputPath);
|
|
732
|
+
const output2 = renderTable(renderOptions);
|
|
733
|
+
formatAndWriteSolidity(output2, fullOutputPath2, "Generated table");
|
|
712
734
|
}
|
|
713
735
|
if (Object.keys(config.enums).length > 0) {
|
|
714
|
-
const
|
|
715
|
-
const
|
|
716
|
-
formatAndWriteSolidity(
|
|
736
|
+
const fullOutputPath2 = path3.join(outputBaseDirectory, `${config.userTypesPath}.sol`);
|
|
737
|
+
const output2 = renderTypesFromConfig(config);
|
|
738
|
+
formatAndWriteSolidity(output2, fullOutputPath2, "Generated types file");
|
|
717
739
|
}
|
|
740
|
+
const fullOutputPath = path3.join(outputBaseDirectory, `Tables.sol`);
|
|
741
|
+
const output = renderTableIndex(allTableOptions);
|
|
742
|
+
formatAndWriteSolidity(output, fullOutputPath, "Generated table index");
|
|
718
743
|
}
|
|
719
744
|
|
|
720
745
|
export {
|
|
@@ -172,7 +172,8 @@ var StoreConfigUnrefined = z3.object({
|
|
|
172
172
|
namespace: zSelector.default(""),
|
|
173
173
|
storeImportPath: z3.string().default("@latticexyz/store/src/"),
|
|
174
174
|
tables: zTablesConfig,
|
|
175
|
-
userTypesPath: z3.string().default("Types")
|
|
175
|
+
userTypesPath: z3.string().default("Types"),
|
|
176
|
+
codegenDirectory: z3.string().default("codegen")
|
|
176
177
|
}).merge(zEnumsConfig);
|
|
177
178
|
var zStoreConfig = StoreConfigUnrefined.superRefine(validateStoreConfig);
|
|
178
179
|
function parseStoreConfig(config) {
|