|
| 1 | +# SV Contributing Guide |
| 2 | + |
| 3 | +## Workflow |
| 4 | + |
| 5 | +We follow the standard fork-based workflow: |
| 6 | + |
| 7 | +1. **Fork** this repository to your GitHub account. |
| 8 | +2. **Clone** your fork locally. |
| 9 | +3. **Create a new branch** for your change: |
| 10 | + `git checkout -b your-feature-name` |
| 11 | +4. **Commit and push** your changes to your branch. |
| 12 | +5. **Open a pull request** from your branch to the `main` branch of this repository. |
| 13 | + |
| 14 | +Please keep your pull requests focused to feature or issue. Focused smaller changes are easier to review and faster to merge. |
| 15 | + |
| 16 | +## Preparing |
| 17 | +This is a monorepo, meaning the repo holds multiple packages. It requires the use of [pnpm](https://pnpm.io/). You can [install pnpm](https://pnpm.io/installation) with: |
| 18 | + |
| 19 | +```bash |
| 20 | +npm i -g pnpm |
| 21 | +``` |
| 22 | + |
| 23 | +For running certain packages and tests locally you will need to install [docker](https://docs.docker.com/get-started/get-docker). |
| 24 | +Linux users, you will have to ensure 'sudo' is not required. See [docker post install](https://docs.docker.com/engine/install/linux-postinstall/) |
| 25 | + |
| 26 | +`pnpm` commands run in the project's root directory will run on all sub-projects. You can checkout the code and install the dependencies with: |
| 27 | + |
| 28 | +```bash |
| 29 | +cd cli |
| 30 | +pnpm install |
| 31 | +``` |
| 32 | + |
| 33 | +## Build and run |
| 34 | +To build the project and all packages. Run the 'build' script: |
| 35 | + |
| 36 | +```bash |
| 37 | +# from root of project |
| 38 | +pnpm build |
| 39 | +``` |
| 40 | +This outputs into /packages/PACKAGE/dist/. |
| 41 | + |
| 42 | +Run the 'cli' package: |
| 43 | +```bash |
| 44 | +pnpm sv |
| 45 | +``` |
| 46 | + |
| 47 | +Run build with watch mode: |
| 48 | +```bash |
| 49 | +pnpm dev |
| 50 | +``` |
| 51 | + |
| 52 | +## Testing |
| 53 | + |
| 54 | +For each add-on we have integration tests setup. These install the deps, build the app, run the dev server and then run a few small snippets against the add-on to see if the changes introduced by the add-on are working as expected. |
| 55 | + |
| 56 | +Run all tests: |
| 57 | +```bash |
| 58 | +# from root of project |
| 59 | +pnpm test |
| 60 | +``` |
| 61 | + |
| 62 | +Run tests with vitest ui: |
| 63 | +```bash |
| 64 | +# from root of project |
| 65 | +pnpm test:ui |
| 66 | +``` |
| 67 | + |
| 68 | +Run package specific tests by specifying a project flag to the package and running the test command. Eg: |
| 69 | +```bash |
| 70 | +pnpm test --project core # addons / create / migrate / etc. |
| 71 | +``` |
| 72 | + |
| 73 | +To run a individual test. `cd` into the package. Run the local `test` script to that package, with a path arg to the individual peice you want tested. Eg: |
| 74 | +```bash |
| 75 | +pnpm test [path-to-test] |
| 76 | +``` |
| 77 | + |
| 78 | +To debug a failing test. A good starting point is to `cd` into the failing tests dir. Proceed to `build` it. Then `preview` it. From here you will have increased information to help in the debug process. Eg: |
| 79 | +```bash |
| 80 | +# Each test is a standalone app |
| 81 | +cd .test-output/addons/[addon-test]/[test-id] |
| 82 | +pnpm build |
| 83 | +pnpm preview |
| 84 | +``` |
| 85 | + |
| 86 | +## Style Guide |
| 87 | + |
| 88 | +### Coding style |
| 89 | + |
| 90 | +There are a few guidelines we follow: |
| 91 | + |
| 92 | +- Ensure `pnpm lint` and `pnpm check` pass. You can run `pnpm format` to format the code |
| 93 | +- linting |
| 94 | +```bash |
| 95 | +# from root of project |
| 96 | +pnpm lint |
| 97 | +``` |
| 98 | +- formatting |
| 99 | +```bash |
| 100 | +# from root of project |
| 101 | +pnpm format |
| 102 | +``` |
| 103 | +- type checking |
| 104 | +```bash |
| 105 | +# from root of project |
| 106 | +pnpm check |
| 107 | +``` |
| 108 | + |
| 109 | +## svelte-migrate |
| 110 | +To run svelte-migrate locally: |
| 111 | +```bash |
| 112 | +# from root of project |
| 113 | +node ./packages/migrate/bin.js |
| 114 | +``` |
| 115 | + |
| 116 | +## Generating changelogs |
| 117 | +Only publish a change set if it is in 'sv' or 'svelte-migrate' as all other packages are bundled. |
| 118 | +For changes to be reflected in package changelogs: |
| 119 | +```bash |
| 120 | +# from root of project |
| 121 | +pnpm changeset:publish |
| 122 | +``` |
0 commit comments