Skip to content

Commit

Permalink
docs: demonstrate sv migrate over prior commands
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann committed Oct 19, 2024
1 parent 206e96d commit 22292dc
Show file tree
Hide file tree
Showing 13 changed files with 38 additions and 26 deletions.
6 changes: 6 additions & 0 deletions .changeset/early-emus-pump.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'svelte-migrate': patch
'@sveltejs/package': patch
---

docs: demonstrate sv migrate over prior commands
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ If you want to test against an existing project, you can use [pnpm `overrides`](

Entry points to be aware of are:

- [`packages/create-svelte`](https://github.com/sveltejs/kit/tree/main/packages/create-svelte) - code that's run when you create a new project with `npm create svelte@latest`
- [`packages/create-svelte`](https://github.com/sveltejs/kit/tree/main/packages/create-svelte) - code that's run when you create a new project with `npx sv create`
- [`packages/package`](https://github.com/sveltejs/kit/tree/main/packages/package) - for the `svelte-package` command
- [`packages/kit/src/core`](https://github.com/sveltejs/kit/tree/main/packages/kit/src/core) - code that's called at dev/build-time
- [`packages/kit/src/core/sync`](https://github.com/sveltejs/kit/tree/main/packages/kit/src/core/sync) - for `svelte-kit sync`, which regenerates routing info and type definitions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
title: Creating a project
---

The easiest way to start building a SvelteKit app is to run `npm create`:
The easiest way to start building a SvelteKit app is to run `npx sv create`:

```bash
npm create svelte@latest my-app
npx sv create my-app
cd my-app
npm install
npm run dev
Expand Down
6 changes: 3 additions & 3 deletions documentation/docs/10-getting-started/30-project-structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ my-project/
└ vite.config.js
```

You'll also find common files like `.gitignore` and `.npmrc` (and `.prettierrc` and `eslint.config.js` and so on, if you chose those options when running `npm create svelte@latest`).
You'll also find common files like `.gitignore` and `.npmrc` (and `.prettierrc` and `eslint.config.js` and so on, if you chose those options when running `npx sv create`).

## Project files

Expand Down Expand Up @@ -71,15 +71,15 @@ If you added [Playwright](https://playwright.dev/) for browser testing when you

Your `package.json` file must include `@sveltejs/kit`, `svelte` and `vite` as `devDependencies`.

When you create a project with `npm create svelte@latest`, you'll also notice that `package.json` includes `"type": "module"`. This means that `.js` files are interpreted as native JavaScript modules with `import` and `export` keywords. Legacy CommonJS files need a `.cjs` file extension.
When you create a project with `npx sv create`, you'll also notice that `package.json` includes `"type": "module"`. This means that `.js` files are interpreted as native JavaScript modules with `import` and `export` keywords. Legacy CommonJS files need a `.cjs` file extension.

### svelte.config.js

This file contains your Svelte and SvelteKit [configuration](configuration).

### tsconfig.json

This file (or `jsconfig.json`, if you prefer type-checked `.js` files over `.ts` files) configures TypeScript, if you added typechecking during `npm create svelte@latest`. Since SvelteKit relies on certain configuration being set a specific way, it generates its own `.svelte-kit/tsconfig.json` file which your own config `extends`.
This file (or `jsconfig.json`, if you prefer type-checked `.js` files over `.ts` files) configures TypeScript, if you added typechecking during `npx sv create`. Since SvelteKit relies on certain configuration being set a specific way, it generates its own `.svelte-kit/tsconfig.json` file which your own config `extends`.

### vite.config.js

Expand Down
2 changes: 1 addition & 1 deletion documentation/docs/25-build-and-deploy/30-adapter-auto.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Zero-config deployments
---

When you create a new SvelteKit project with `npm create svelte@latest`, it installs [`adapter-auto`](https://github.com/sveltejs/kit/tree/main/packages/adapter-auto) by default. This adapter automatically installs and uses the correct adapter for supported environments when you deploy:
When you create a new SvelteKit project with `npx sv create`, it installs [`adapter-auto`](https://github.com/sveltejs/kit/tree/main/packages/adapter-auto) by default. This adapter automatically installs and uses the correct adapter for supported environments when you deploy:

- [`@sveltejs/adapter-cloudflare`](adapter-cloudflare) for [Cloudflare Pages](https://developers.cloudflare.com/pages/)
- [`@sveltejs/adapter-netlify`](adapter-netlify) for [Netlify](https://netlify.com/)
Expand Down
6 changes: 3 additions & 3 deletions documentation/docs/30-advanced/70-packaging.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Packaging
---

You can use SvelteKit to build apps as well as component libraries, using the `@sveltejs/package` package (`npm create svelte` has an option to set this up for you).
You can use SvelteKit to build apps as well as component libraries, using the `@sveltejs/package` package (`npx sv create` has an option to set this up for you).

When you're creating an app, the contents of `src/routes` is the public-facing stuff; [`src/lib`]($lib) contains your app's internal library.

Expand Down Expand Up @@ -59,7 +59,7 @@ Read more about it [here](https://docs.npmjs.com/cli/v9/configuring-npm/package-

### exports

The `"exports"` field contains the package's entry points. If you set up a new library project through `npm create svelte@latest`, it's set to a single export, the package root:
The `"exports"` field contains the package's entry points. If you set up a new library project through `npx sv create`, it's set to a single export, the package root:

```json
{
Expand Down Expand Up @@ -157,7 +157,7 @@ This will treat only the specified files as having side effects.

## TypeScript

You should ship type definitions for your library even if you don't use TypeScript yourself so that people who do get proper intellisense when using your library. `@sveltejs/package` makes the process of generating types mostly opaque to you. By default, when packaging your library, type definitions are auto-generated for JavaScript, TypeScript and Svelte files. All you need to ensure is that the `types` condition in the [exports](#Anatomy-of-a-package.json-exports) map points to the correct files. When initialising a library project through `npm create svelte@latest`, this is automatically setup for the root export.
You should ship type definitions for your library even if you don't use TypeScript yourself so that people who do get proper intellisense when using your library. `@sveltejs/package` makes the process of generating types mostly opaque to you. By default, when packaging your library, type definitions are auto-generated for JavaScript, TypeScript and Svelte files. All you need to ensure is that the `types` condition in the [exports](#Anatomy-of-a-package.json-exports) map points to the correct files. When initialising a library project through `npx sv create`, this is automatically setup for the root export.

If you have something else than a root export however — for example providing a `your-library/foo` import — you need to take additional care for providing type definitions. Unfortunately, TypeScript by default will _not_ resolve the `types` condition for an export like `{ "./foo": { "types": "./dist/foo.d.ts", ... }}`. Instead, it will search for a `foo.d.ts` relative to the root of your library (i.e. `your-library/foo.d.ts` instead of `your-library/dist/foo.d.ts`). To fix this, you have two options:

Expand Down
16 changes: 11 additions & 5 deletions documentation/docs/60-appendix/20-integrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,17 @@ export default {

## Adders

Run `npx svelte-add` to setup many different complex integrations with a single command including:
- CSS - Tailwind, Bootstrap, Bulma
- database - Drizzle ORM
- markdown - mdsvex
- Storybook
Run `npx sv add` to setup many different complex integrations with a single command including:
- prettier (formatting)
- eslint (linting)
- vitest (unit testing)
- playwright (e2e testing)
- lucia (auth)
- tailwind (CSS)
- drizzle (DB)
- paraglide (i18n)
- mdsvex (markdown)
- storybook (frontend workshop)

## Directory

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Migrating to SvelteKit v2
---

Upgrading from SvelteKit version 1 to version 2 should be mostly seamless. There are a few breaking changes to note, which are listed here. You can use `npx svelte-migrate@latest sveltekit-2` to migrate some of these changes automatically.
Upgrading from SvelteKit version 1 to version 2 should be mostly seamless. There are a few breaking changes to note, which are listed here. You can use `npx sv migrate sveltekit-2` to migrate some of these changes automatically.

We highly recommend upgrading to the most recent 1.x version before upgrading to 2.0, so that you can take advantage of targeted deprecation warnings. We also recommend [updating to Svelte 4](https://svelte.dev/docs/v4-migration-guide) first: Later versions of SvelteKit 1.x support it, and SvelteKit 2.0 requires it.

Expand Down
2 changes: 1 addition & 1 deletion packages/kit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ This is the [SvelteKit](https://kit.svelte.dev) framework and CLI.
The quickest way to get started is via the [create-svelte](https://github.com/sveltejs/kit/tree/main/packages/create-svelte) package:

```bash
npm create svelte@latest my-app
npx sv create my-app
cd my-app
npm install
npm run dev
Expand Down
6 changes: 3 additions & 3 deletions packages/migrate/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

A CLI for migrating Svelte(Kit) codebases.

Run it using
Run it directly using:

```
npx svelte-migrate [migration]
```

Or if you're using `pnpm`:
Or via the unified Svlete CLI with:

```
pnpm dlx svelte-migrate [migration]
npx sv migrate [migration]
```

## Migrations
Expand Down
8 changes: 4 additions & 4 deletions packages/migrate/migrations/svelte-5/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export async function migrate() {
colors
.bold()
.yellow(
'\nDetected Svelte 3. You need to upgrade to Svelte version 4 first (`npx svelte-migrate svelte-4`).\n'
'\nDetected Svelte 3. You need to upgrade to Svelte version 4 first (`npx sv migrate svelte-4`).\n'
)
);
const response = await prompts({
Expand All @@ -47,7 +47,7 @@ export async function migrate() {
colors
.bold()
.green(
'svelte-4 migration complete. Check that everything is ok, then run `npx svelte-migrate svelte-5` again to continue the Svelte 5 migration.\n'
'svelte-4 migration complete. Check that everything is ok, then run `npx sv migrate svelte-5` again to continue the Svelte 5 migration.\n'
)
);
process.exit(0);
Expand All @@ -60,7 +60,7 @@ export async function migrate() {
colors
.bold()
.yellow(
'\nDetected SvelteKit 1. You need to upgrade to SvelteKit version 2 first (`npx svelte-migrate sveltekit-2`).\n'
'\nDetected SvelteKit 1. You need to upgrade to SvelteKit version 2 first (`npx sv migrate sveltekit-2`).\n'
)
);
const response = await prompts({
Expand All @@ -77,7 +77,7 @@ export async function migrate() {
colors
.bold()
.green(
'sveltekit-2 migration complete. Check that everything is ok, then run `npx svelte-migrate svelte-5` again to continue the Svelte 5 migration.\n'
'sveltekit-2 migration complete. Check that everything is ok, then run `npx sv migrate svelte-5` again to continue the Svelte 5 migration.\n'
)
);
process.exit(0);
Expand Down
2 changes: 1 addition & 1 deletion packages/migrate/migrations/sveltekit-2/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export async function migrate() {
colors
.bold()
.yellow(
'\nSvelteKit 2 requires Svelte 4 or newer. We recommend running the `svelte-4` migration first (`npx svelte-migrate svelte-4`).\n'
'\nSvelteKit 2 requires Svelte 4 or newer. We recommend running the `svelte-4` migration first (`npx sv migrate svelte-4`).\n'
)
);
const response = await prompts({
Expand Down
2 changes: 1 addition & 1 deletion packages/package/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Create Svelte packages, build and push them to npm. This is part of the [SvelteK
The quickest way to get started is via the [create-svelte](https://github.com/sveltejs/kit/tree/main/packages/create-svelte) package:

```bash
npm create svelte@latest my-app
npm sv create my-app
cd my-app
npm install
npm run dev
Expand Down

0 comments on commit 22292dc

Please sign in to comment.