Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: move tablegen to store and worldgen to world, update javascript build/export setup #640

Merged
merged 31 commits into from
Apr 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
9179ed8
feat: move tablegen to store and worldgen to world
dk1a Apr 18, 2023
a633a77
chore: sort-package-json
dk1a Apr 18, 2023
ea11712
fix(network): fix store typechain imports
dk1a Apr 18, 2023
2f3a768
fix(world): add missing package
dk1a Apr 18, 2023
9a97d95
fix(services): skipLibCheck
dk1a Apr 18, 2023
6baa352
fix: fix typechain imports
dk1a Apr 18, 2023
62f7df7
fix: attempt tsconfig changes
dk1a Apr 18, 2023
62ffffe
build: try different import
dk1a Apr 18, 2023
db8544a
fix: try externalizing solidity parser
dk1a Apr 18, 2023
272ffb6
Merge branch 'main' into dk1a/separate-tablegen
dk1a Apr 18, 2023
89eac07
build: try building worldgen script
dk1a Apr 18, 2023
e503b77
build: try to externalize solidity parser more
dk1a Apr 18, 2023
e69d2a4
build: fix solidity parser
alvrs Apr 19, 2023
c53ae94
build(cli): switch from tsup to vite
alvrs Apr 19, 2023
08dbb40
build: fix build
alvrs Apr 19, 2023
32de306
build(cli): make mud.js executable for local use
alvrs Apr 19, 2023
322e761
test: fix tests
alvrs Apr 19, 2023
330832d
test: fix types
alvrs Apr 19, 2023
801a36b
refactor: replace typescript rollup plugin with tsc, align versions, …
alvrs Apr 19, 2023
23c000a
chore: update vite
alvrs Apr 20, 2023
0b39141
chore: self-review
alvrs Apr 20, 2023
0579170
refactor(common): move common-codegen to common/codegen
alvrs Apr 20, 2023
875bbbf
test(network): fix jest
alvrs Apr 20, 2023
3bb29bf
build(common): fix output path
alvrs Apr 20, 2023
dc33d1b
chore: sort package.json
alvrs Apr 20, 2023
84106ad
Merge branch 'main' into dk1a/separate-tablegen
alvrs Apr 20, 2023
77487c0
refactor: remove .js from ts imports
alvrs Apr 20, 2023
4f1209a
fix: add missing awaits
alvrs Apr 20, 2023
63d3b58
Revert "refactor: remove .js from ts imports"
alvrs Apr 20, 2023
f801ba9
fix(common): bundle execa
dk1a Apr 20, 2023
c64640d
build(cli): fix typo in dev script
dk1a Apr 20, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ jobs:
uses: ./.github/actions/setup

- name: Run codegen
run: pnpm codegen
run: pnpm build:codegen

- name: Outdated files, run `pnpm codegen` and commit them
- name: Outdated files, run `pnpm build:codegen` and commit them
uses: ./.github/actions/require-empty-diff

- name: Generate gas reports
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ jobs:
uses: ./.github/actions/setup

- name: Run codegen
run: pnpm codegen
run: pnpm build:codegen

- name: Outdated files, run `pnpm codegen` and commit them
- name: Outdated files, run `pnpm build:codegen` and commit them
uses: ./.github/actions/require-empty-diff

- name: Generate gas reports
Expand Down
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@
"url": "https://github.com/latticexyz/mud.git"
},
"scripts": {
"build": "pnpm pnpm recursive run build",
"build": "pnpm recursive run build",
"build:codegen": "pnpm recursive run build:codegen",
"build:docs": "pnpm recursive run docs && pnpm prettier --write '**/*.md' && pnpm run --filter docs build:prepare && pnpm run --filter docs build",
"codegen": "pnpm codegen:tablegen && pnpm codegen:worldgen",
"codegen:tablegen": "pnpm recursive run tablegen",
"codegen:worldgen": "pnpm recursive run worldgen",
"commit": "cz",
"entry:dist": "lerna run prepack",
"entry:src": "lerna run postpack",
Expand Down
1 change: 0 additions & 1 deletion packages/cli/contracts/src/codegen/Types.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
pragma solidity >=0.8.0;

/* Autogenerated file. Do not edit manually. */

enum Enum1 {
E1,
E2,
Expand Down
25 changes: 15 additions & 10 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,38 @@
},
"license": "MIT",
"type": "module",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"exports": {
".": "./dist/index.js"
},
"types": "src/index.ts",
"bin": {
"mud": "./dist/mud.js",
"mud2": "./dist/mud2.js"
},
"scripts": {
"build": "tsup",
"build": "pnpm run build:js && chmod +x ./dist/mud.js",
"build:js": "vite build",
"codegen": "tsx ./scripts/codegen.ts",
"dev": "tsup --watch",
"dev": "vite build --watch",
"lint": "eslint . --ext .ts",
"release": "npm publish --access=public",
"test": "tsc --noEmit && pnpm test:contracts",
"test:contracts": "pnpm codegen && forge test"
"test": "pnpm test:typescript && pnpm test:contracts",
"test:contracts": "pnpm codegen && forge test",
"test:typescript": "tsc --noEmit"
},
"dependencies": {
"@ethersproject/abi": "^5.7.0",
"@ethersproject/providers": "^5.7.2",
"@improbable-eng/grpc-web": "^0.15.0",
"@improbable-eng/grpc-web-node-http-transport": "^0.15.0",
"@latticexyz/common": "workspace:*",
"@latticexyz/config": "workspace:*",
"@latticexyz/schema-type": "workspace:*",
"@latticexyz/services": "workspace:*",
"@latticexyz/solecs": "workspace:*",
"@latticexyz/std-contracts": "workspace:*",
"@latticexyz/store": "workspace:*",
"@latticexyz/world": "workspace:*",
"@solidity-parser/parser": "^0.16.0",
"@typechain/ethers-v5": "^10.2.0",
"chalk": "^5.0.1",
"chokidar": "^3.5.3",
Expand All @@ -50,8 +54,6 @@
"nice-grpc-web": "^2.0.1",
"openurl": "^1.1.1",
"path": "^0.12.7",
"prettier": "^2.8.4",
"prettier-plugin-solidity": "^1.1.2",
"table": "^6.8.1",
"typechain": "^8.1.1",
"typescript": "^4.9.5",
Expand All @@ -64,9 +66,12 @@
"@types/glob": "^7.2.0",
"@types/node": "^17.0.34",
"@types/openurl": "^1.0.0",
"@types/rollup-plugin-peer-deps-external": "^2.2.1",
"@types/yargs": "^17.0.10",
"tsup": "^6.6.3",
"rollup-plugin-peer-deps-external": "^2.2.4",
"rollup-plugin-preserve-shebang": "^1.0.1",
"tsx": "^3.12.6",
"vite": "^4.3.0",
"vitest": "^0.29.8"
},
"gitHead": "914a1e0ae4a573d685841ca2ea921435057deb8f"
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/scripts/codegen.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import path from "path";
import { storeConfig, parseStoreConfig } from "@latticexyz/config";
import { tablegen } from "../src/render-solidity/tablegen.js";
import { tablegen } from "@latticexyz/store";
import { logError } from "../src/utils/errors.js";
import { getSrcDirectory } from "../src/utils/foundry.js";
import { getSrcDirectory } from "@latticexyz/common/foundry";

// This config is used only for tests
const config = storeConfig({
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/deploy-v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { loadStoreConfig, loadWorldConfig } from "@latticexyz/config";
import { MUDError } from "@latticexyz/config";
import { deploy } from "../utils/deploy-v2.js";
import { logError } from "../utils/errors.js";
import { forge, getRpcUrl, getSrcDirectory } from "../utils/foundry.js";
import { forge, getRpcUrl, getSrcDirectory } from "@latticexyz/common/foundry";
import { mkdirSync, writeFileSync } from "fs";
import { getChainId } from "../utils/getChainId.js";

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/deprecated/call-system.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { getTestDirectory } from "@latticexyz/common/foundry";
import { defaultAbiCoder as abi } from "ethers/lib/utils.js";
import path from "path";
import type { CommandModule } from "yargs";
import { execLog } from "../../utils/deprecated/index.js";
import { getTestDirectory } from "../../utils/foundry.js";

type Options = {
rpc?: string;
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/deprecated/deploy-contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { CommandModule } from "yargs";
import { DeployOptions, generateAndDeploy, hsr } from "../../utils/deprecated/index.js";
import openurl from "openurl";
import chalk from "chalk";
import { getSrcDirectory } from "../../utils/foundry.js";
import { getSrcDirectory } from "@latticexyz/common/foundry";

type Options = DeployOptions & {
watch?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/deprecated/test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { CommandModule } from "yargs";
import { execLog, generateLibDeploy, resetLibDeploy } from "../../utils/deprecated/index.js";
import { getTestDirectory } from "../../utils/foundry.js";
import { getTestDirectory } from "@latticexyz/common/foundry";

type Options = {
forgeOpts?: string;
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/deprecated/trace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { readFileSync } from "fs";
import { Contract } from "ethers";
import { JsonRpcProvider } from "@ethersproject/providers";
import WorldAbi from "@latticexyz/solecs/abi/World.json" assert { type: "json" };
import { getSrcDirectory } from "../../utils/foundry.js";
import { getSrcDirectory } from "@latticexyz/common/foundry";
import path from "path";
import { componentsDir, systemsDir } from "../../utils/deprecated/constants.js";

Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commands/tablegen.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import path from "path";
import type { CommandModule } from "yargs";
import { loadStoreConfig } from "@latticexyz/config";
import { tablegen } from "../render-solidity/tablegen.js";
import { getSrcDirectory } from "../utils/index.js";
import { tablegen } from "@latticexyz/store";
import { getSrcDirectory } from "@latticexyz/common/foundry";

type Options = {
configPath?: string;
Expand Down
3 changes: 1 addition & 2 deletions packages/cli/src/commands/test-v2.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import type { CommandModule } from "yargs";
import { deployHandler, DeployOptions } from "./deploy-v2.js";
import { yDeployOptions } from "./deploy-v2.js";
import { anvil, forge, getRpcUrl, getTestDirectory } from "../utils/foundry.js";
import { anvil, forge, getRpcUrl } from "@latticexyz/common/foundry";
import chalk from "chalk";
import { rmSync, writeFileSync } from "fs";
import path from "path";

type Options = DeployOptions & { port?: number; worldAddress?: string; forgeOptions?: string };

Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commands/worldgen.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { CommandModule } from "yargs";
import { loadStoreConfig, loadWorldConfig } from "@latticexyz/config";
import { getSrcDirectory } from "../utils/foundry.js";
import { worldgen } from "@latticexyz/world";
import { getSrcDirectory } from "@latticexyz/common/foundry";
import glob from "glob";
import path, { basename } from "path";
import { worldgen } from "../render-solidity/worldgen.js";
import { rmSync } from "fs";

type Options = {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export {};
export * from "./render-ts";
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ declare module "protobufjs/minimal" {
export const Writer: any;
export type Writer = any;
}
declare module "rollup-plugin-preserve-shebang";
10 changes: 0 additions & 10 deletions packages/cli/src/render-solidity/index.ts

This file was deleted.

19 changes: 0 additions & 19 deletions packages/cli/src/render-solidity/renderTypes.ts

This file was deleted.

116 changes: 0 additions & 116 deletions packages/cli/src/render-solidity/types.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/cli/src/render-ts/recsV1TableOptions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { StoreConfig } from "@latticexyz/config";
import { resolveAbiOrUserType } from "../render-solidity/userType.js";
import { resolveAbiOrUserType } from "@latticexyz/common/codegen";
import { schemaTypesToRecsTypeStrings } from "./schemaTypesToRecsTypeStrings.js";
import { RecsV1TableOptions } from "./types.js";

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/render-ts/tsgen.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import path from "path";
import { StoreConfig } from "@latticexyz/config";
import { formatAndWriteTypescript } from "@latticexyz/common/codegen";
import { getRecsV1TableOptions } from "../render-ts/recsV1TableOptions.js";
import { renderRecsV1Tables } from "../render-ts/renderRecsV1Tables.js";
import { formatAndWriteTypescript } from "../utils/formatAndWrite.js";

export async function tsgen(config: StoreConfig, outDirectory: string) {
const fullOutputPath = path.join(outDirectory, `contractComponents.ts`);
Expand Down
Loading