diff --git a/.changeset/eleven-lies-behave.md b/.changeset/eleven-lies-behave.md
new file mode 100644
index 00000000..99efb3cf
--- /dev/null
+++ b/.changeset/eleven-lies-behave.md
@@ -0,0 +1,5 @@
+---
+'vite-plugin-watch-and-run': patch
+---
+
+watch can look at an array of globs now
diff --git a/.changeset/polite-ghosts-carry.md b/.changeset/polite-ghosts-carry.md
new file mode 100644
index 00000000..72a0b68e
--- /dev/null
+++ b/.changeset/polite-ghosts-carry.md
@@ -0,0 +1,5 @@
+---
+'vite-plugin-kit-routes': patch
+---
+
+init plugin
diff --git a/packages/vite-plugin-kit-routes/.eslintrc.cjs b/packages/vite-plugin-kit-routes/.eslintrc.cjs
new file mode 100644
index 00000000..13b901e0
--- /dev/null
+++ b/packages/vite-plugin-kit-routes/.eslintrc.cjs
@@ -0,0 +1,3 @@
+module.exports = {
+ extends: ['eslint-config-kitql'],
+}
diff --git a/packages/vite-plugin-kit-routes/.gitignore b/packages/vite-plugin-kit-routes/.gitignore
new file mode 100644
index 00000000..ac7211b4
--- /dev/null
+++ b/packages/vite-plugin-kit-routes/.gitignore
@@ -0,0 +1,11 @@
+.DS_Store
+node_modules
+/build
+/dist
+/.svelte-kit
+/package
+.env
+.env.*
+!.env.example
+vite.config.js.timestamp-*
+vite.config.ts.timestamp-*
diff --git a/packages/vite-plugin-kit-routes/.npmrc b/packages/vite-plugin-kit-routes/.npmrc
new file mode 100644
index 00000000..b6f27f13
--- /dev/null
+++ b/packages/vite-plugin-kit-routes/.npmrc
@@ -0,0 +1 @@
+engine-strict=true
diff --git a/packages/vite-plugin-kit-routes/CHANGELOG.md b/packages/vite-plugin-kit-routes/CHANGELOG.md
new file mode 100644
index 00000000..1e9f0478
--- /dev/null
+++ b/packages/vite-plugin-kit-routes/CHANGELOG.md
@@ -0,0 +1 @@
+# vite-plugin-kit-routes
diff --git a/packages/vite-plugin-kit-routes/README.md b/packages/vite-plugin-kit-routes/README.md
new file mode 100644
index 00000000..db0c1cd7
--- /dev/null
+++ b/packages/vite-plugin-kit-routes/README.md
@@ -0,0 +1,5 @@
+# ⚡vite-plugin-watch-and-run
+
+_Part of [KitQL](https://github.com/jycouet/kitql#kitql), a set of tools helping **you** building efficient apps in a fast way._
+
+### 👉 Check the [⚡Doc⚡](https://kitql.dev/docs/tools/06_vite-plugin-kit-routes)
diff --git a/packages/vite-plugin-kit-routes/package.json b/packages/vite-plugin-kit-routes/package.json
new file mode 100644
index 00000000..a31a386f
--- /dev/null
+++ b/packages/vite-plugin-kit-routes/package.json
@@ -0,0 +1,65 @@
+{
+ "name": "vite-plugin-kit-routes",
+ "description": "vite-plugin that will help you maintain your routes in a single file",
+ "keywords": [
+ "vite"
+ ],
+ "version": "0.0.1",
+ "license": "MIT",
+ "type": "module",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/jycouet/kitql",
+ "directory": "packages/vite-plugin-kit-routes",
+ "homepage": "https://github.com/jycouet/kitql/tree/main/packages/vite-plugin-kit-routes#readme"
+ },
+ "scripts": {
+ "prepare": "svelte-kit sync",
+ "dev": "vite dev",
+ "build": "vite build && svelte-package && node ../../scripts/package.js",
+ "preview": "vite preview",
+ "package": "svelte-package && publint",
+ "check": "svelte-check --tsconfig ./tsconfig.json",
+ "check:watch": "svelte-check --tsconfig ./tsconfig.json --watch",
+ "test": "vitest",
+ "test:ci": "vitest --coverage",
+ "lint": "kitql-lint",
+ "format": "kitql-lint --fix"
+ },
+ "devDependencies": {
+ "eslint-config-kitql": "workspace:*",
+ "@sveltejs/adapter-auto": "2.1.0",
+ "@sveltejs/kit": "1.25.2",
+ "@sveltejs/package": "2.2.2",
+ "publint": "0.2.4",
+ "svelte": "4.2.1",
+ "svelte-check": "3.5.2",
+ "tslib": "2.6.2",
+ "typescript": "5.2.2",
+ "vite": "4.4.2",
+ "vitest": "0.34.6"
+ },
+ "dependencies": {
+ "@kitql/helpers": "workspace:*",
+ "vite-plugin-watch-and-run": "workspace:*"
+ },
+ "sideEffects": false,
+ "publishConfig": {
+ "directory": "dist",
+ "access": "public"
+ },
+ "files": [
+ "dist",
+ "!dist/**/*.test.*",
+ "!dist/**/*.spec.*"
+ ],
+ "svelte": "./dist/index.js",
+ "types": "./dist/index.d.ts",
+ "exports": {
+ ".": {
+ "types": "./dist/index.d.ts",
+ "default": "./dist/index.js",
+ "svelte": "./dist/index.js"
+ }
+ }
+}
diff --git a/packages/vite-plugin-kit-routes/src/app.d.ts b/packages/vite-plugin-kit-routes/src/app.d.ts
new file mode 100644
index 00000000..0425013a
--- /dev/null
+++ b/packages/vite-plugin-kit-routes/src/app.d.ts
@@ -0,0 +1,12 @@
+// See https://kit.svelte.dev/docs/types#app
+// for information about these interfaces
+declare global {
+ namespace App {
+ // interface Error {}
+ // interface Locals {}
+ // interface PageData {}
+ // interface Platform {}
+ }
+}
+
+export {}
diff --git a/packages/vite-plugin-kit-routes/src/app.html b/packages/vite-plugin-kit-routes/src/app.html
new file mode 100644
index 00000000..85d6c8f6
--- /dev/null
+++ b/packages/vite-plugin-kit-routes/src/app.html
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+ %sveltekit.head%
+
+
+ %sveltekit.body%
+
+
diff --git a/packages/vite-plugin-kit-routes/src/lib/ROUTES.ts b/packages/vite-plugin-kit-routes/src/lib/ROUTES.ts
new file mode 100644
index 00000000..8e330af1
--- /dev/null
+++ b/packages/vite-plugin-kit-routes/src/lib/ROUTES.ts
@@ -0,0 +1,30 @@
+export const PAGES = {
+ '/': (sp?: Record) => {
+ return `/${appendSp(sp)}`
+ },
+ '/site/[id]': (id: string, sp?: Record) => {
+ return `/site/${id}${appendSp(sp)}`
+ },
+ '/site/[param]/[yop]': (param: string, yop: string, sp?: Record) => {
+ return `/site/${param}/${yop}${appendSp(sp)}`
+ },
+}
+
+// TODO: SERVERS methods?
+export const SERVERS = {
+ '/site/[id]/one': (id: string, sp?: Record) => {
+ return `/site/${id}/one${appendSp(sp)}`
+ },
+}
+
+// TODO: name actions
+export const ACTIONS = {
+ '/site/[id]/two/[hello]': (id: string, hello: string) => {
+ return `/site/${id}/two/${hello}`
+ },
+}
+
+const appendSp = (sp?: Record) => {
+ if (sp === undefined) return ''
+ return `?${new URLSearchParams(sp || {}).toString()}`
+}
diff --git a/packages/vite-plugin-kit-routes/src/lib/fs.ts b/packages/vite-plugin-kit-routes/src/lib/fs.ts
new file mode 100644
index 00000000..56ead09b
--- /dev/null
+++ b/packages/vite-plugin-kit-routes/src/lib/fs.ts
@@ -0,0 +1,26 @@
+import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'
+import { dirname, join } from 'node:path'
+
+export function read(pathFile: string) {
+ return readFileSync(pathFile, { encoding: 'utf8' })
+}
+
+export function write(pathFile: string, data: string[]) {
+ const fullDataToWrite = Array.isArray(data) ? data.join('\n') : data
+ createFolderIfNotExists(dirname(pathFile))
+ // Don't write if nothing changed!
+ if (existsSync(pathFile)) {
+ const currentFileData = read(pathFile)
+ if (fullDataToWrite === currentFileData) {
+ return false
+ }
+ }
+ writeFileSync(join(pathFile), fullDataToWrite)
+ return true
+}
+
+function createFolderIfNotExists(dir: string) {
+ if (!existsSync(dir)) {
+ mkdirSync(dir, { recursive: true })
+ }
+}
diff --git a/packages/vite-plugin-kit-routes/src/lib/index.ts b/packages/vite-plugin-kit-routes/src/lib/index.ts
new file mode 100644
index 00000000..2754bb93
--- /dev/null
+++ b/packages/vite-plugin-kit-routes/src/lib/index.ts
@@ -0,0 +1,150 @@
+import { readdirSync } from 'fs'
+import { spawn } from 'node:child_process'
+import { green, Log, yellow } from '@kitql/helpers'
+import type { Plugin } from 'vite'
+import watch_and_run from 'vite-plugin-watch-and-run'
+import { write } from './fs.js'
+
+export type Options = {
+ /**
+ * run command after file updated
+ *
+ * @example
+ * ```ts
+ * 'npm exec prettier ./src/lib/ROUTES.ts -- -w'
+ * ```
+ */
+ post_update_run?: string
+
+ /**
+ * @default 'src/lib/ROUTES.ts'
+ */
+ generated_file_path?: string
+}
+
+function generated_file_path(params?: Options) {
+ return params?.generated_file_path ?? 'src/lib/ROUTES.ts'
+}
+
+// const routes_path = 'src/lib/ROUTES.ts'
+const log = new Log('Kit Routes')
+
+const getFiles = (dirPath: string, lookFor: '+page.svelte' | '+page.server.ts' | '+server.ts') => {
+ const files = readdirSync(dirPath, { recursive: true }) as string[]
+ return files
+ .filter(file => file.endsWith(lookFor))
+ .map(file => `/` + file.replace(`/${lookFor}`, '').replace(lookFor, ''))
+}
+
+export function extractParamsFromPath(path: string): string[] {
+ // Use a regular expression to match parameter placeholders like '[param]'
+ const paramPattern = /\[([^\]]+)]/g
+ const params = []
+
+ let match
+ while ((match = paramPattern.exec(path)) !== null) {
+ // The matched parameter name is in the first capturing group
+ params.push(match[1])
+ }
+
+ return params
+}
+
+const run = (params?: Options) => {
+ const files_pages = getFiles(`${process.cwd()}/src/routes`, '+page.svelte')
+ const files_server_pages = getFiles(`${process.cwd()}/src/routes`, '+page.server.ts')
+ const files_server = getFiles(`${process.cwd()}/src/routes`, '+server.ts')
+
+ const result = write(generated_file_path(params), [
+ `export const PAGES = {
+ ${files_pages
+ .map(file_path => {
+ const params = extractParamsFromPath(file_path).map(c => `${c}: string`)
+ params.push(`sp?: Record`)
+ return (
+ `"${file_path}": (${params.join(', ')}) => ` +
+ `{ return \`${file_path.replaceAll('[', '${').replaceAll(']', '}')}\${appendSp(sp)}\` }`
+ )
+ })
+ .join(',\n ')}
+}
+
+// TODO: SERVERS methods?
+export const SERVERS = {
+ ${files_server
+ .map(file_path => {
+ const params = extractParamsFromPath(file_path).map(c => `${c}: string`)
+ params.push(`sp?: Record`)
+ return (
+ `"${file_path}": (${params.join(', ')}) => ` +
+ `{ return \`${file_path.replaceAll('[', '${').replaceAll(']', '}')}\${appendSp(sp)}\` }`
+ )
+ })
+ .join(',\n ')}
+}
+
+// TODO: name actions
+export const ACTIONS = {
+ ${files_server_pages
+ .map(file_path => {
+ const params = extractParamsFromPath(file_path).map(c => `${c}: string`)
+ return (
+ `"${file_path}": (${params.join(', ')}) => ` +
+ `{ return \`${file_path.replaceAll('[', '${').replaceAll(']', '}')}\` }`
+ )
+ })
+ .join(',\n ')}
+}
+
+const appendSp = (sp?: Record) => {
+ if (sp === undefined) return ''
+ return \`?\${new URLSearchParams(sp || {}).toString()}\`
+}
+`,
+ ])
+
+ // TODO: optimize this later. We want to write the new file only if different after prettier?! (having a tmp file somewhere?)
+ if (params?.post_update_run) {
+ log.info(`${yellow(`post_update_run`)} "${green(params?.post_update_run)}" running...`)
+ const child = spawn(params.post_update_run, { shell: true })
+ child.stdout.on('data', data => {
+ if (data.toString()) {
+ log.info(data.toString())
+ }
+ })
+ child.stderr.on('data', data => {
+ log.error(data.toString())
+ })
+ child.on('close', code => {
+ if (result) {
+ log.success(`${yellow(generated_file_path(params))} updated`)
+ }
+ })
+ } else {
+ if (result) {
+ log.success(`${yellow(generated_file_path(params))} updated`)
+ }
+ }
+}
+
+export function kitRoutes(params?: Options): Plugin[] {
+ return [
+ // Run the thing at startup
+ {
+ name: 'kit-routes',
+ configureServer() {
+ run(params)
+ },
+ },
+
+ // Run the thing when any change in a +page.svelte (add, remove, ...)
+ watch_and_run([
+ {
+ name: 'kit-routes-watch',
+ logs: [],
+ watch: ['**/+page.svelte', '**/+page.server.ts', '**/+server.ts'],
+ run: () => run(params),
+ },
+ ]),
+ ]
+}
diff --git a/packages/vite-plugin-kit-routes/src/lib/plugins.spec.ts b/packages/vite-plugin-kit-routes/src/lib/plugins.spec.ts
new file mode 100644
index 00000000..83eae417
--- /dev/null
+++ b/packages/vite-plugin-kit-routes/src/lib/plugins.spec.ts
@@ -0,0 +1,31 @@
+import { describe, expect, it } from 'vitest'
+import { extractParamsFromPath } from './index.js'
+
+describe('vite-plugin-kit-routes', () => {
+ it('get id', async () => {
+ expect(extractParamsFromPath('/site/[id]')).toMatchInlineSnapshot(`
+ [
+ "id",
+ ]
+ `)
+ })
+
+ it('get params & id', async () => {
+ expect(extractParamsFromPath('/site/[param]/[id]')).toMatchInlineSnapshot(`
+ [
+ "param",
+ "id",
+ ]
+ `)
+ })
+
+ it('get params & id', async () => {
+ expect(extractParamsFromPath('/[param]site/[yop](group)/[id]')).toMatchInlineSnapshot(`
+ [
+ "param",
+ "yop",
+ "id",
+ ]
+ `)
+ })
+})
diff --git a/packages/vite-plugin-kit-routes/src/routes/+layout.svelte b/packages/vite-plugin-kit-routes/src/routes/+layout.svelte
new file mode 100644
index 00000000..8007a9ed
--- /dev/null
+++ b/packages/vite-plugin-kit-routes/src/routes/+layout.svelte
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+vite-plugin-kit-routes
+
+
+
+
+
+
+
+
diff --git a/packages/vite-plugin-kit-routes/src/routes/+page.svelte b/packages/vite-plugin-kit-routes/src/routes/+page.svelte
new file mode 100644
index 00000000..277f8e93
--- /dev/null
+++ b/packages/vite-plugin-kit-routes/src/routes/+page.svelte
@@ -0,0 +1 @@
+Home
diff --git a/packages/vite-plugin-kit-routes/src/routes/site/[id]/+page.svelte b/packages/vite-plugin-kit-routes/src/routes/site/[id]/+page.svelte
new file mode 100644
index 00000000..5f468cf2
--- /dev/null
+++ b/packages/vite-plugin-kit-routes/src/routes/site/[id]/+page.svelte
@@ -0,0 +1 @@
+site [id]
diff --git a/packages/vite-plugin-kit-routes/src/routes/site/[id]/one/+server.ts b/packages/vite-plugin-kit-routes/src/routes/site/[id]/one/+server.ts
new file mode 100644
index 00000000..3b431288
--- /dev/null
+++ b/packages/vite-plugin-kit-routes/src/routes/site/[id]/one/+server.ts
@@ -0,0 +1,5 @@
+import type { RequestHandler } from './$types'
+
+export const GET: RequestHandler = async () => {
+ return new Response()
+}
diff --git a/packages/vite-plugin-kit-routes/src/routes/site/[id]/two/[hello]/+page.server.ts b/packages/vite-plugin-kit-routes/src/routes/site/[id]/two/[hello]/+page.server.ts
new file mode 100644
index 00000000..e69de29b
diff --git a/packages/vite-plugin-kit-routes/src/routes/site/[param]/[yop]/+page.svelte b/packages/vite-plugin-kit-routes/src/routes/site/[param]/[yop]/+page.svelte
new file mode 100644
index 00000000..6779db80
--- /dev/null
+++ b/packages/vite-plugin-kit-routes/src/routes/site/[param]/[yop]/+page.svelte
@@ -0,0 +1 @@
+site [param] [yop]
diff --git a/packages/vite-plugin-kit-routes/static/favicon.png b/packages/vite-plugin-kit-routes/static/favicon.png
new file mode 100644
index 00000000..825b9e65
Binary files /dev/null and b/packages/vite-plugin-kit-routes/static/favicon.png differ
diff --git a/packages/vite-plugin-kit-routes/svelte.config.js b/packages/vite-plugin-kit-routes/svelte.config.js
new file mode 100644
index 00000000..18b47166
--- /dev/null
+++ b/packages/vite-plugin-kit-routes/svelte.config.js
@@ -0,0 +1,18 @@
+import adapter from '@sveltejs/adapter-auto'
+import { vitePreprocess } from '@sveltejs/kit/vite'
+
+/** @type {import('@sveltejs/kit').Config} */
+const config = {
+ // Consult https://kit.svelte.dev/docs/integrations#preprocessors
+ // for more information about preprocessors
+ preprocess: vitePreprocess(),
+
+ kit: {
+ // adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list.
+ // If your environment is not supported or you settled on a specific environment, switch out the adapter.
+ // See https://kit.svelte.dev/docs/adapters for more information about adapters.
+ adapter: adapter(),
+ },
+}
+
+export default config
diff --git a/packages/vite-plugin-kit-routes/tsconfig.json b/packages/vite-plugin-kit-routes/tsconfig.json
new file mode 100644
index 00000000..9a9b2ea3
--- /dev/null
+++ b/packages/vite-plugin-kit-routes/tsconfig.json
@@ -0,0 +1,14 @@
+{
+ "extends": "./.svelte-kit/tsconfig.json",
+ "compilerOptions": {
+ "allowJs": true,
+ "checkJs": true,
+ "esModuleInterop": true,
+ "forceConsistentCasingInFileNames": true,
+ "resolveJsonModule": true,
+ "skipLibCheck": true,
+ "sourceMap": true,
+ "strict": true,
+ "moduleResolution": "NodeNext"
+ }
+}
diff --git a/packages/vite-plugin-kit-routes/vite.config.ts b/packages/vite-plugin-kit-routes/vite.config.ts
new file mode 100644
index 00000000..b5450314
--- /dev/null
+++ b/packages/vite-plugin-kit-routes/vite.config.ts
@@ -0,0 +1,18 @@
+import { sveltekit } from '@sveltejs/kit/vite'
+import { defineConfig } from 'vite'
+import { kitRoutes } from './src/lib/index.js'
+
+export default defineConfig({
+ plugins: [
+ sveltekit(),
+ // demo
+ kitRoutes({
+ // for testing
+ // generated_file_path: 'src/lib/ROUTES2.ts',
+ post_update_run: 'npm exec prettier ./src/lib/ROUTES.ts -- -w',
+ }),
+ ],
+ test: {
+ include: ['src/**/*.{test,spec}.{js,ts}'],
+ },
+})
diff --git a/packages/vite-plugin-watch-and-run/src/lib/index.ts b/packages/vite-plugin-watch-and-run/src/lib/index.ts
index 0b205883..9ceb377b 100644
--- a/packages/vite-plugin-watch-and-run/src/lib/index.ts
+++ b/packages/vite-plugin-watch-and-run/src/lib/index.ts
@@ -11,7 +11,7 @@ export type Options = {
/**
* watch files to trigger the run action (glob format)
*/
- watch?: string
+ watch?: string | string[]
/**
* watch files to trigger the run action (function format)
@@ -69,7 +69,7 @@ export type StateDetail = {
delay: number
isRunning: boolean
watchFile?: (filepath: string) => boolean | Promise
- watch?: string
+ watch?: string | string[]
name?: string | null
shell: string | boolean
formatErrors?: (e: unknown, afterError?: (e: Error) => void) => void
diff --git a/packages/vite-plugin-watch-and-run/src/lib/micromatch.spec.ts b/packages/vite-plugin-watch-and-run/src/lib/micromatch.spec.ts
new file mode 100644
index 00000000..98d0766b
--- /dev/null
+++ b/packages/vite-plugin-watch-and-run/src/lib/micromatch.spec.ts
@@ -0,0 +1,59 @@
+// micromatch.isMatch(absolutePath, info.watch)
+
+import micromatch from 'micromatch'
+import { describe, expect, it } from 'vitest'
+
+describe('micromatch', () => {
+ it('1', async () => {
+ expect(
+ micromatch.isMatch(
+ '/home/asbPath/site/[id]/one/[hello]/+page.server.ts',
+ '**/+page.server.ts',
+ ),
+ ).toBe(true)
+ })
+
+ it('2', async () => {
+ expect(
+ micromatch.isMatch(
+ '/home/asbPath/site/[id]/one/[hello]/+page.server.ts',
+ '**/(+page.server.ts)',
+ ),
+ ).toBe(true)
+ })
+
+ it('3', async () => {
+ expect(
+ micromatch.isMatch('/home/asbPath/site/[id]/one/[hello]/+page.server.ts', [
+ '**/+page.server.ts',
+ '**/+page.svelte',
+ ]),
+ ).toBe(true)
+ })
+
+ it('4', async () => {
+ expect(
+ micromatch.isMatch('/home/asbPath/site/[id]/one/[hello]/+page.server.ts', [
+ '**/+page.svelte',
+ ]),
+ ).toBe(false)
+ })
+
+ it('5', async () => {
+ expect(
+ micromatch.isMatch('/home/asbPath/site/[id]/one/[hello]/+page.svelte', [
+ '**/+page.server.ts',
+ '**/+page.svelte',
+ ]),
+ ).toBe(true)
+ })
+
+ it('5', async () => {
+ expect(
+ micromatch.isMatch('/home/asbPath/site/[id]/one/[hello]/+page.svelteNOT', [
+ '**/+page.server.ts',
+ '**/+page.svelte',
+ ]),
+ ).toBe(false)
+ })
+})
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index e5d6bcdb..f1d90c4c 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -155,6 +155,50 @@ importers:
version: 0.34.0
publishDirectory: dist
+ packages/vite-plugin-kit-routes:
+ dependencies:
+ '@kitql/helpers':
+ specifier: workspace:*
+ version: link:../helpers/dist
+ vite-plugin-watch-and-run:
+ specifier: workspace:*
+ version: link:../vite-plugin-watch-and-run/dist
+ devDependencies:
+ '@sveltejs/adapter-auto':
+ specifier: 2.1.0
+ version: 2.1.0(@sveltejs/kit@1.25.2)
+ '@sveltejs/kit':
+ specifier: 1.25.2
+ version: 1.25.2(svelte@4.2.1)(vite@4.4.2)
+ '@sveltejs/package':
+ specifier: 2.2.2
+ version: 2.2.2(svelte@4.2.1)(typescript@5.2.2)
+ eslint-config-kitql:
+ specifier: workspace:*
+ version: link:../eslint-config-kitql
+ publint:
+ specifier: 0.2.4
+ version: 0.2.4
+ svelte:
+ specifier: 4.2.1
+ version: 4.2.1
+ svelte-check:
+ specifier: 3.5.2
+ version: 3.5.2(svelte@4.2.1)
+ tslib:
+ specifier: 2.6.2
+ version: 2.6.2
+ typescript:
+ specifier: 5.2.2
+ version: 5.2.2
+ vite:
+ specifier: 4.4.2
+ version: 4.4.2
+ vitest:
+ specifier: 0.34.6
+ version: 0.34.6
+ publishDirectory: dist
+
packages/vite-plugin-watch-and-run:
dependencies:
'@kitql/helpers':
diff --git a/scripts/package.js b/scripts/package.js
index 27b998ea..53b10a1d 100644
--- a/scripts/package.js
+++ b/scripts/package.js
@@ -14,6 +14,17 @@ const packageDirPath = process.cwd()
const packageJsonPath = path.join(packageDirPath, 'package.json')
const pkg = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'))
+// getting vite-plugin-watch-and-run version (should be generated by the build script)
+const pkgVitePluginWatchAndRun = JSON.parse(
+ fs.readFileSync(
+ path.join(packageDirPath, '../vite-plugin-watch-and-run', 'package.json'),
+ 'utf-8',
+ ),
+)
+if (pkg?.dependencies?.['vite-plugin-watch-and-run']) {
+ pkg.dependencies['vite-plugin-watch-and-run'] = pkgVitePluginWatchAndRun.version
+}
+
// getting @kitql/helpers version (should be generated by the build script)
const pkgHelper = JSON.parse(
fs.readFileSync(path.join(packageDirPath, '../helpers', 'package.json'), 'utf-8'),
diff --git a/website/src/pages/docs/tools/06_vite-plugin-kit-routes.mdx b/website/src/pages/docs/tools/06_vite-plugin-kit-routes.mdx
new file mode 100644
index 00000000..bf7214ef
--- /dev/null
+++ b/website/src/pages/docs/tools/06_vite-plugin-kit-routes.mdx
@@ -0,0 +1,36 @@
+import { Callout } from '@theguild/components'
+
+# ⚡How to - `vite-plugin-kit-routes`
+
+Never be out of sync with your routes again 🥳
+
+## Installation
+
+```sh npm2yarn
+npm i -D vite-plugin-kit-routes
+```
+
+## Configuration
+
+Add the plugin like this:
+
+```js filename="vite.config.js"
+import { kitRoutes } from 'vite-plugin-kit-routes'
+
+/** @type {import('vite').UserConfig} */
+const config = {
+ plugins: [
+ // This is the plugin to add
+ kitRoutes()
+ ]
+}
+
+export default config
+```
+
+It will create a file `./src/lib/ROUTES.ts` at the start of your dev server & any update of any of
+your `+page.svelte`.
+
+## Side Notes
+
+- It's very early, things might change! 😉
diff --git a/website/src/pages/docs/tools/_meta.ts b/website/src/pages/docs/tools/_meta.ts
index 59926046..8232f964 100644
--- a/website/src/pages/docs/tools/_meta.ts
+++ b/website/src/pages/docs/tools/_meta.ts
@@ -1,5 +1,6 @@
export default {
'04_helpers': 'Helpers',
'03_vite-plugin-watch-and-run': 'Vite - Watch and Run',
+ '06_vite-plugin-kit-routes': 'Vite - Kit Routes',
'05_handles': 'SvelteKit - Handles',
}