Skip to content

Commit

Permalink
chore: check in types (sveltejs#11229)
Browse files Browse the repository at this point in the history
* chore: check in types

To ensure that changes to code/types doesn't result in unwanted changes in type generation, or that bumps to dts-buddy don't cause unwanted regressions, we're checking in the generated types. Types should be committed as-is (don't format it with prettier!). CI is enhanced to check that git sees no changed files after generating the types, which would mean types have changed.

* see if this fails

* nice it works

* this is unnecessary now

* update contributing

* prettier formatting getting in the way

* Update packages/kit/.prettierignore

Co-authored-by: Ben McCann <[email protected]>

* Update .github/workflows/ci.yml

Co-authored-by: Rich Harris <[email protected]>

---------

Co-authored-by: Rich Harris <[email protected]>
Co-authored-by: Ben McCann <[email protected]>
  • Loading branch information
3 people authored Dec 9, 2023
1 parent 6818dd4 commit f9b5c1f
Show file tree
Hide file tree
Showing 6 changed files with 2,168 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm run lint
- run: cd packages/kit && pnpm prepublishOnly
- run: cd packages/kit && pnpm prepublishOnly && { [ "`git status --porcelain=v1`" == "" ] || echo "Generated types have changed — please run prepublishOnly locally and commit the changes after you have reviewed them"; }
- run: pnpm run check
Tests:
runs-on: ${{ matrix.os }}
Expand Down
38 changes: 21 additions & 17 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ If you want to test against an existing project, you can use [pnpm `overrides`](

```jsonc
{
// ...
"pnpm": {
"overrides": {
"@sveltejs/kit": "link:../path/to/svelte-kit/packages/kit",
// additionally/optional the adapter you're using
"@sveltejs/adapter-auto": "link:../path/to/svelte-kit/packages/adapter-auto"
}
}
// ...
"pnpm": {
"overrides": {
"@sveltejs/kit": "link:../path/to/svelte-kit/packages/kit",
// additionally/optional the adapter you're using
"@sveltejs/adapter-auto": "link:../path/to/svelte-kit/packages/adapter-auto"
}
}
}
```

Expand Down Expand Up @@ -87,15 +87,15 @@ If you would like to test local changes to Vite or another dependency, you can b

```jsonc
{
// ...
"dependencies": {
"vite": "^4.0.0"
},
"pnpm": {
"overrides": {
"vite": "link:../path/to/vite/packages/vite"
}
}
// ...
"dependencies": {
"vite": "^4.0.0"
},
"pnpm": {
"overrides": {
"vite": "link:../path/to/vite/packages/vite"
}
}
}
```

Expand Down Expand Up @@ -124,6 +124,10 @@ git config core.hookspath .githooks

For changes to be reflected in package changelogs, run `pnpm changeset` and follow the prompts.

### Type changes

If your PR changes the generated types of SvelteKit, run `pnpm generate:types` inside `packages/kit` and commit the new output (don't format it with Prettier!). Review the changes carefully to ensure there are no unwanted changes. If you don't commit type changes, CI will fail.

## Releases

The [Changesets GitHub action](https://github.com/changesets/action#with-publishing) will create and update a PR that applies changesets and publishes new versions of changed packages to npm.
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
"precommit": "pnpm format && pnpm lint",
"changeset:version": "changeset version && pnpm -r generate:version && git add --all",
"changeset:release": "changeset publish",
"start": "cd sites/kit.svelte.dev && npm run dev",
"postinstall": "pnpm -r generate:types"
"start": "cd sites/kit.svelte.dev && npm run dev"
},
"devDependencies": {
"@changesets/cli": "^2.26.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
!/src/core/adapt/fixtures/*/.svelte-kit
!/test/node_modules
/test/apps/basics/test/errors.json
/types
/types/*.map
.custom-out-dir

# these are already ignored by the top level .gitignore
Expand Down
1 change: 1 addition & 0 deletions packages/kit/.prettierignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
test/build-errors/apps/syntax-error/src/routes/+page.svelte
/types
Loading

0 comments on commit f9b5c1f

Please sign in to comment.