mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-04-01 10:01:07 +02:00
5
.changes/cta-svelte-recipe.md
Normal file
5
.changes/cta-svelte-recipe.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"create-tauri-app": patch
|
||||
---
|
||||
|
||||
Add Svelte recipe using the official template.
|
||||
@@ -12,6 +12,7 @@ import { vuecli } from './recipes/vue-cli'
|
||||
import { vanillajs } from './recipes/vanilla'
|
||||
import { vite } from './recipes/vite'
|
||||
import { ngcli } from './recipes/ng-cli'
|
||||
import { svelte } from './recipes/svelte'
|
||||
import { install, checkPackageManager } from './dependency-manager'
|
||||
import { shell } from './shell'
|
||||
import { addTauriScript } from './helpers/add-tauri-script'
|
||||
@@ -114,7 +115,7 @@ interface Responses {
|
||||
recipeName: string
|
||||
}
|
||||
|
||||
const allRecipes: Recipe[] = [vanillajs, cra, vite, vuecli, ngcli]
|
||||
const allRecipes: Recipe[] = [vanillajs, cra, vite, vuecli, ngcli, svelte]
|
||||
|
||||
const recipeByShortName = (name: string): Recipe | undefined =>
|
||||
allRecipes.find((r) => r.shortName === name)
|
||||
|
||||
69
tooling/create-tauri-app/src/recipes/svelte.ts
Normal file
69
tooling/create-tauri-app/src/recipes/svelte.ts
Normal file
@@ -0,0 +1,69 @@
|
||||
// Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import { join } from 'path'
|
||||
import { shell } from '../shell'
|
||||
import { Recipe } from '../types/recipe'
|
||||
|
||||
const svelte: Recipe = {
|
||||
descriptiveName: {
|
||||
name: 'Svelte (https://github.com/sveltejs/template)',
|
||||
value: 'svelte'
|
||||
},
|
||||
shortName: 'svelte',
|
||||
extraNpmDevDependencies: [],
|
||||
extraNpmDependencies: [],
|
||||
extraQuestions: () => {
|
||||
return [
|
||||
{
|
||||
type: 'confirm',
|
||||
name: 'typescript',
|
||||
message: 'Enable Typescript?',
|
||||
default: true,
|
||||
loop: false
|
||||
}
|
||||
]
|
||||
},
|
||||
configUpdate: ({ cfg, packageManager }) => ({
|
||||
...cfg,
|
||||
distDir: `../public`,
|
||||
devPath: 'http://localhost:5000',
|
||||
beforeDevCommand: `${packageManager === 'yarn' ? 'yarn' : 'npm run'} dev`,
|
||||
beforeBuildCommand: `${
|
||||
packageManager === 'yarn' ? 'yarn' : 'npm run'
|
||||
} build`
|
||||
}),
|
||||
preInit: async ({ cwd, cfg, answers }) => {
|
||||
let typescript = false
|
||||
if (answers) {
|
||||
typescript = !!answers.typescript
|
||||
}
|
||||
|
||||
await shell('npx', ['degit', 'sveltejs/template', `${cfg.appName}`], {
|
||||
cwd
|
||||
})
|
||||
|
||||
// Add Typescript
|
||||
if (typescript) {
|
||||
await shell('node', ['scripts/setupTypeScript.js'], {
|
||||
cwd: join(cwd, cfg.appName)
|
||||
})
|
||||
}
|
||||
},
|
||||
postInit: async ({ cfg, packageManager }) => {
|
||||
console.log(`
|
||||
Your installation completed.
|
||||
To start, run the dev script:
|
||||
|
||||
$ cd ${cfg.appName}
|
||||
$ ${packageManager === 'yarn' ? 'yarn' : 'npm run'} tauri ${
|
||||
packageManager === 'npm' ? '-- ' : ''
|
||||
}dev
|
||||
`)
|
||||
|
||||
return await Promise.resolve()
|
||||
}
|
||||
}
|
||||
|
||||
export { svelte }
|
||||
Reference in New Issue
Block a user