diff --git a/cli b/cli new file mode 120000 index 00000000..dbd43d78 --- /dev/null +++ b/cli @@ -0,0 +1 @@ +repos/cli \ No newline at end of file diff --git a/documentation/docs/10-introduction/10-overview.md b/documentation/docs/10-introduction/10-overview.md new file mode 100644 index 00000000..6928e186 --- /dev/null +++ b/documentation/docs/10-introduction/10-overview.md @@ -0,0 +1,15 @@ +--- +title: Overview +--- + +The command line interface (CLI), `sv`, is a toolkit for creating and maintaining Svelte applications. + +## Usage + +The easiest way to run `sv` is with [`npx`](https://docs.npmjs.com/cli/v8/commands/npx) (or the equivalent command if you're using a different package manager — for example, `pnpx` if you're using [pnpm](https://pnpm.io/)): + +```bash +npx sv +``` + +If you're inside a project where `sv` is already installed, this will use the local installation, otherwise it will download the latest version and run it without installing it, which is particularly useful for [`sv create`](sv-create). diff --git a/documentation/docs/10-introduction/index.md b/documentation/docs/10-introduction/index.md new file mode 100644 index 00000000..8f14f7a7 --- /dev/null +++ b/documentation/docs/10-introduction/index.md @@ -0,0 +1,3 @@ +--- +title: Introduction +--- diff --git a/documentation/docs/20-commands/10-sv-create.md b/documentation/docs/20-commands/10-sv-create.md new file mode 100644 index 00000000..dda153d5 --- /dev/null +++ b/documentation/docs/20-commands/10-sv-create.md @@ -0,0 +1,37 @@ +--- +title: sv create +--- + +`sv create` sets up a new SvelteKit project, with options to [setup additional functionality](sv-add#Official-adders). + +## Usage + +```bash +npx sv create +``` + +```bash +npx sv create ./my/path +``` + +## Available options + +| Option | option values | default | description | +| ------------- | ------------------------------- | --------- | ---------------------------------------------------------- | +| --check-types | typescript \| checkjs \| none | typescipt | determine if type checking should be added to this project | +| --template | skeleton \| skeletonlib \| demo | skeleton | project template | +| --no-adders | - | - | skips interactive adder installer | +| --no-install | - | - | skips installing dependencies | + +## Programmatic interface + +```js +// TODO: this gives type checking errors in the docs site when not commented out. Need to release sv, install it in the site, and uncomment this. +// import { create } from 'sv'; + +// // todo: check if this is right +// create(cwd, { +// // add your options here +// // todo: list available option +// }); +``` diff --git a/documentation/docs/20-commands/20-sv-add.md b/documentation/docs/20-commands/20-sv-add.md new file mode 100644 index 00000000..5a96e06b --- /dev/null +++ b/documentation/docs/20-commands/20-sv-add.md @@ -0,0 +1,63 @@ +--- +title: sv add +--- + +`sv add` updates your code to add new functionality to an existing project. + +## Usage + +```bash +npx sv add +``` + +```bash +npx sv add tailwindcss +``` + +```bash +npx sv add tailwindcss --cwd ./my/path +``` + +## Available options + +| Option | option values | default | description | +| ------------------ | ------------------------------------------ | ------- | -------------------------------------------- | +| -C, --cwd | - | ./ | path to the root of your svelte(kit) project | +| --no-install | - | - | skips installing dependencies | +| --no-preconditions | - | - | skips checking preconditions | +| --no-preconditions | - | - | skips checking preconditions | +| --community | [community adder names](#community-adders) | - | adds community adders | + +## Official adders + +- auth +- drizzle +- eslint +- mdsvex +- paraglide +- playwright +- prettier +- routify +- storybook +- tailwindcss +- vitest + +## Community adders + +> The Svelte maintainers have not reviewed community adders for malicious code. Use at your discretion. + +```bash +npx sv add --community # interactive community adder selection +``` + +```bash +npx sv add --community shadcn-svelte #test +``` + +```bash +npx sv add --community shadcn-svelte --cwd ./my/path +``` + +```bash +npx sv add --community npm:your-custom-adder-published-to-npm --cwd ./my/path +``` diff --git a/documentation/docs/20-commands/30-sv-check.md b/documentation/docs/20-commands/30-sv-check.md new file mode 100644 index 00000000..5a2dba5c --- /dev/null +++ b/documentation/docs/20-commands/30-sv-check.md @@ -0,0 +1,125 @@ +--- +title: sv check +--- + +Provides CLI diagnostics checks for: + +- Unused CSS +- Svelte A11y hints +- JavaScript/TypeScript compiler errors + +Requires Node 16 or later. + +### Usage: + +#### Local / in your project + +Installation: + +`npm i svelte-check --save-dev` + +Package.json: + +```json +{ + // ... + "scripts": { + "sv": "npx sv" + // ... + }, + // ... + "devDependencies": { + "svelte-check": "..." + // ... + } +} +``` + +Usage: + +`npm run sv check` + +### Args: + +| Flag | Description | +| --------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `--workspace ` | Path to your workspace. All subdirectories except node_modules and those listed in `--ignore` are checked | +| `--output ` | +| `--watch` | Will not exit after one pass but keep watching files for changes and rerun diagnostics | +| `--preserveWatchOutput` | Do not clear the screen in watch mode | +| `--tsconfig ` | Pass a path to a tsconfig or jsconfig file. The path can be relative to the workspace path or absolute. Doing this means that only files matched by the files/include/exclude pattern of the config file are diagnosed. It also means that errors from TypeScript and JavaScript files are reported. If not given, will do an upwards traversal looking for the next jsconfig/tsconfig.json | +| `--no-tsconfig` | Use this if you only want to check the Svelte files found in the current directory and below and ignore any JS/TS files (they will not be type-checked) | +| `--ignore ` | Only has an effect when used in conjunction with `--no-tsconfig`. Files/folders to ignore - relative to workspace root, comma-separated, inside quotes. Example: `--ignore "dist,build"`. When used in conjunction with `--tsconfig`, this will only have effect on the files watched, not on the files that are diagnosed, which is then determined by the `tsconfig.json` | +| `--fail-on-warnings` | Will also exit with error code when there are warnings | +| `--compiler-warnings ` | A list of Svelte compiler warning codes. Each entry defines whether that warning should be ignored or treated as an error. Warnings are comma-separated, between warning code and error level is a colon; all inside quotes. Example: `--compiler-warnings "css-unused-selector:ignore,unused-export-let:error"` | +| `--diagnostic-sources ` | A list of diagnostic sources which should run diagnostics on your code. Possible values are `js` (includes TS), `svelte`, `css`. Comma-separated, inside quotes. By default all are active. Example: `--diagnostic-sources "js,svelte"` | +| `--threshold ` | Filters the diagnostics to display. `error` will output only errors while `warning` will output warnings and errors. | + +### FAQ + +#### Why is there no option to only check specific files (for example only staged files)? + +`svelte-check` needs to know the whole project to do valid checks. Imagine you alter a component property `export let foo` to `export let bar`, but you don't update any of the component usages. They all have errors now but you would not catch them if you only run checks on changed files. + +### More docs, preprocessor setup and troubleshooting + +[See here](/docs/README.md). + +### Machine-Readable Output + +Setting the `--output` to `machine` or `machine-verbose` will format output in a way that is easier to read +by machines, e.g. inside CI pipelines, for code quality checks, etc. + +Each row corresponds to a new record. Rows are made up of columns that are separated by a +single space character. The first column of every row contains a timestamp in milliseconds +which can be used for monitoring purposes. The second column gives us the "row type", based +on which the number and types of subsequent columns may differ. + +The first row is of type `START` and contains the workspace folder (wrapped in quotes). + +###### Example: + +``` +1590680325583 START "/home/user/language-tools/packages/language-server/test/plugins/typescript/testfiles" +``` + +Any number of `ERROR` or `WARNING` records may follow. Their structure is identical and depends on the output argoument. + +If the argument is `machine` it will tell us the filename, the starting line and column numbers, and the error message. The filename is relative to the workspace directory. The filename and the message are both wrapped in quotes. + +###### Example: + +``` +1590680326283 ERROR "codeactions.svelte" 1:16 "Cannot find module 'blubb' or its corresponding type declarations." +1590680326778 WARNING "imported-file.svelte" 0:37 "Component has unused export property 'prop'. If it is for external reference only, please consider using `export const prop`" +``` + +If the argument is `machine-verbose` it will tell us the filename, the starting line and column numbers, the ending line and column numbers, the error message, the code of diagnostic, the human-friendly description of the code and the human-friendly source of the diagnostic (eg. svelte/typescript). The filename is relative to the workspace directory. Each diagnostic is represented as an [ndjson](https://en.wikipedia.org/wiki/JSON_streaming#Newline-Delimited_JSON) line prefixed by the timestamp of the log. + +###### Example: + +``` +1590680326283 {"type":"ERROR","fn":"codeaction.svelte","start":{"line":1,"character":16},"end":{"line":1,"character":23},"message":"Cannot find module 'blubb' or its corresponding type declarations.","code":2307,"source":"js"} +1590680326778 {"type":"WARNING","filename":"imported-file.svelte","start":{"line":0,"character":37},"end":{"line":0,"character":51},"message":"Component has unused export property 'prop'. If it is for external reference only, please consider using `export +const prop`","code":"unused-export-let","source":"svelte"} +``` + +The output concludes with a `COMPLETED` message that summarizes total numbers of files, errors and warnings that were encountered during the check. + +###### Example: + +``` +1590680326807 COMPLETED 20 FILES 21 ERRORS 1 WARNINGS 3 FILES_WITH_PROBLEMS +``` + +If the application experiences a runtime error, this error will appear as a `FAILURE` record. + +###### Example: + +``` +1590680328921 FAILURE "Connection closed" +``` + +### Credits + +- Vue's [VTI](https://github.com/vuejs/vetur/tree/master/vti) which laid the foundation for `svelte-check` diff --git a/documentation/docs/20-commands/40-sv-migrate.md b/documentation/docs/20-commands/40-sv-migrate.md new file mode 100644 index 00000000..7550b446 --- /dev/null +++ b/documentation/docs/20-commands/40-sv-migrate.md @@ -0,0 +1,27 @@ +--- +title: sv migrate +--- + +A CLI for migrating Svelte(Kit) codebases. + +Run it using + +``` +npx sv migrate [migration] +``` + +## Migrations + +| Migration | From | To | Guide | +| ------------- | --------------------- | --------------------- | --------------------------------------------------------------- | +| `svelte-5` | Svelte 4 | Svelte 5 | [Website](https://svelte.dev/docs/v5-migration-guide) | +| `sveltekit-2` | SvelteKit 1.0 | SvelteKit 2.0 | [Website](https://kit.svelte.dev/docs/migrating-to-sveltekit-2) | +| `svelte-4` | Svelte 3 | Svelte 4 | [Website](https://svelte.dev/docs/v4-migration-guide) | +| `package` | `@sveltejs/package@1` | `@sveltejs/package@2` | [#8922](https://github.com/sveltejs/kit/pull/8922) | +| `routes` | SvelteKit pre-1.0 | SvelteKit 1.0 | [#5774](https://github.com/sveltejs/kit/discussions/5774) | + +Some migrations may annotate your codebase with tasks for completion that you can find by searching for `@migration`. + +## Changelog + +[The Changelog for this package is available on GitHub](https://github.com/sveltejs/kit/blob/main/packages/migrate/CHANGELOG.md). diff --git a/documentation/docs/20-commands/index.md b/documentation/docs/20-commands/index.md new file mode 100644 index 00000000..877406c0 --- /dev/null +++ b/documentation/docs/20-commands/index.md @@ -0,0 +1,3 @@ +--- +title: Commands +--- diff --git a/documentation/docs/30-community-adders/10-usage.md b/documentation/docs/30-community-adders/10-usage.md new file mode 100644 index 00000000..ee7479a9 --- /dev/null +++ b/documentation/docs/30-community-adders/10-usage.md @@ -0,0 +1,28 @@ +--- +title: Usage +--- + +## Before we begin + +> The Svelte maintainers have not reviewed community adders for malicious code. Use at your discretion. + +That being said, we still want the community to be able to enhance the experience while creating new projects. That's why everyone is allowed to create community adders. The documentation for creating a new community adder can be found [here](docs) + +## Usage + +```bash +npx sv add --community # interactive list +npx sv add --community supabase # apply supabase adder +npx sv add --community npm:your-npm-package # apply any adder from npm +npx sv add --community file:./path-to-your-adder # for local testing +``` + +## Requirements + +technical requirements: + +- all adders must have exactly one dependency: `@sveltejs/add-core` +- if they need to include any other dependencies they will need to do some bundling on their side +- the major version of the referenced `@sveltejs/add-core` library must match with the major version `sv` the user is currently executing + +See [submission](submission#requirements) to find additional requirements if you want list your community adder inside `sv` for the ease of use of other community members diff --git a/documentation/docs/30-community-adders/20-docs.md b/documentation/docs/30-community-adders/20-docs.md new file mode 100644 index 00000000..b624dbf6 --- /dev/null +++ b/documentation/docs/30-community-adders/20-docs.md @@ -0,0 +1,13 @@ +--- +title: Docs +--- + +## Community adder template + +We have a [community adder template](https://github.com/sveltejs/cli/tree/main/community-adder-template) that lives inside our GitHub monorepo. This should be a starting point for all new community adders. + +We do not provide any TS template, as the types provided by all the helper methods we expose should be enough to fulfill your needs! If you still want to use TypeScript, that's totally fine as well. + +## Basic usage + +We have 5 common files: `index.js`, `config/adder.js`, `config/options.js`, `config/check.js`, `config/test.js`. Please check official adders for examples and do not be shy about asking questions in the GitHub issues or on Discord. diff --git a/documentation/docs/30-community-adders/30-submission.md b/documentation/docs/30-community-adders/30-submission.md new file mode 100644 index 00000000..89e34b57 --- /dev/null +++ b/documentation/docs/30-community-adders/30-submission.md @@ -0,0 +1,18 @@ +--- +title: Submission +--- + +Community adders are still in development. We'd love to help get the first few released. Please open an issue or find us on Discord to discuss how to develop your adder and get it included. + +## Requirements + +- must benefit the overall ecosystem and community rather than being individually tailored +- should be a best-in-class tool that is ideally widely used in the community +- open source tools are generally preferred to commercial offerings + +## Process + +- create a fork of `sveltejs/cli` +- list your file in the `community-adders` directory +- create a PR +- wait for the the next release of `sv` diff --git a/documentation/docs/30-community-adders/index.md b/documentation/docs/30-community-adders/index.md new file mode 100644 index 00000000..1ab3606e --- /dev/null +++ b/documentation/docs/30-community-adders/index.md @@ -0,0 +1,3 @@ +--- +title: Community adders +--- diff --git a/documentation/docs/index.md b/documentation/docs/index.md new file mode 100644 index 00000000..5f81cc86 --- /dev/null +++ b/documentation/docs/index.md @@ -0,0 +1,3 @@ +--- +title: CLI +---