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

fix(templates): fix templates tsc errors and add test #2036

Merged
merged 7 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/actions/setup-prerequisites/action.yml
@@ -0,0 +1,21 @@
name: Setup prerequisites
description: Setup pnpm, Node.js, and Foundry
runs:
using: composite
steps:
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8.x

- name: Setup node
uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
registry-url: https://registry.npmjs.org
cache: pnpm

- name: Setup foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
18 changes: 2 additions & 16 deletions .github/actions/setup/action.yml
Expand Up @@ -3,22 +3,8 @@ description: Common setup steps used by our workflows
runs:
using: composite
steps:
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8.x

- name: Setup node
uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
registry-url: https://registry.npmjs.org
cache: pnpm

- name: Setup foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Setup prerequisites
uses: ./.github/actions/setup-prerequisites

# pnpm no longer runs this before the actual install (https://github.com/pnpm/pnpm/issues/3760)
# but we need to create some placeholder files like bins so that the install step can find them and put references to them in the right spot
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/snapshot.yml
Expand Up @@ -53,3 +53,9 @@ jobs:
docker:
uses: ./.github/workflows/docker.yml
needs: release-snapshot

test-snapshot:
uses: ./.github/workflows/test-published-packages.yml
needs: release-snapshot
with:
tag-or-version: ${{ github.ref_name }}
35 changes: 35 additions & 0 deletions .github/workflows/test-published-packages.yml
@@ -0,0 +1,35 @@
name: Test published packages

on:
workflow_call:
inputs:
tag-or-version:
required: true
type: string
workflow_dispatch:
inputs:
tag-or-version:
required: true
type: string

jobs:
test-create-mud-project:
name: Test create-mud project
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
template: [vanilla, react, react-ecs, phaser, threejs]

steps:
- uses: actions/checkout@v3
with:
sparse-checkout: .github

- name: Setup
uses: ./.github/actions/setup-prerequisites

- name: Test
run: |
pnpm create mud@${{ inputs.tag-or-version }} project --template ${{ matrix.template }}
pnpm --dir project run test
2 changes: 2 additions & 0 deletions templates/phaser/package.json
Expand Up @@ -13,6 +13,8 @@
},
"devDependencies": {
"@latticexyz/cli": "link:../../packages/cli",
"@types/debug": "4.1.7",
"@types/prettier": "2.7.2",
"@typescript-eslint/eslint-plugin": "5.46.1",
"@typescript-eslint/parser": "5.46.1",
"eslint": "8.29.0",
Expand Down
2 changes: 2 additions & 0 deletions templates/react-ecs/package.json
Expand Up @@ -13,6 +13,8 @@
},
"devDependencies": {
"@latticexyz/cli": "link:../../packages/cli",
"@types/debug": "4.1.7",
"@types/prettier": "2.7.2",
"@typescript-eslint/eslint-plugin": "5.46.1",
"@typescript-eslint/parser": "5.46.1",
"eslint": "8.29.0",
Expand Down
2 changes: 2 additions & 0 deletions templates/react/package.json
Expand Up @@ -13,6 +13,8 @@
},
"devDependencies": {
"@latticexyz/cli": "link:../../packages/cli",
"@types/debug": "4.1.7",
"@types/prettier": "2.7.2",
"@typescript-eslint/eslint-plugin": "5.46.1",
"@typescript-eslint/parser": "5.46.1",
"eslint": "8.29.0",
Expand Down
2 changes: 2 additions & 0 deletions templates/threejs/package.json
Expand Up @@ -13,6 +13,8 @@
},
"devDependencies": {
"@latticexyz/cli": "link:../../packages/cli",
"@types/debug": "4.1.7",
"@types/prettier": "2.7.2",
"@typescript-eslint/eslint-plugin": "5.46.1",
"@typescript-eslint/parser": "5.46.1",
"eslint": "8.29.0",
Expand Down
2 changes: 2 additions & 0 deletions templates/vanilla/package.json
Expand Up @@ -13,6 +13,8 @@
},
"devDependencies": {
"@latticexyz/cli": "link:../../packages/cli",
"@types/debug": "4.1.7",
"@types/prettier": "2.7.2",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

likewise here, I don't think we're using any of these packages directly, but getting this via the cli dep?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cli is not relevant to this diff.
prettier and debug are added as dependencies at the workspace root because both contracts and client require them. Similarly, typescript is also a dependency in the workspace root.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And both contracts and client use the TS files from common (via typesVersions), and common uses prettier and debug.

"@typescript-eslint/eslint-plugin": "5.46.1",
"@typescript-eslint/parser": "5.46.1",
"eslint": "8.29.0",
Expand Down
1 change: 1 addition & 0 deletions templates/vanilla/packages/client/package.json
Expand Up @@ -24,6 +24,7 @@
"viem": "1.14.0"
},
"devDependencies": {
"@types/react-dom": "18.2.7",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume any TS errors here come from @latticexyz/dev-tools, but it doesn't make sense to me why we'd need to add the dependency here if the dev tools is compiled. Maybe there's something off with dev tools exports of types? Or with tsconfig for either dev tools or vanilla template?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your review!

dev-tools is compiled into JS files, but I confirmed that TS files are referred to by template projects based on their tsconfig.json.

"exports": {
".": "./dist/index.js"
},
"types": "src/index.ts",

With moduleResolution: node/node10, the types field is prioritized over the exports field.

Other templates, except for vanilla, already include @types/react-dom as dependencies.

"vite": "^4.2.1",
"wait-port": "^1.0.4"
}
Expand Down