|
| 1 | +// Copyright 2019-2021 Tauri Programme within The Commons Conservancy |
| 2 | +// SPDX-License-Identifier: Apache-2.0 |
| 3 | +// SPDX-License-Identifier: MIT |
| 4 | + |
| 5 | +import { shell } from '../shell' |
| 6 | +import { Recipe } from '../types/recipe' |
| 7 | + |
| 8 | +const solid: Recipe = { |
| 9 | + descriptiveName: { |
| 10 | + name: 'Solid (https://github.com/solidjs/templates)', |
| 11 | + value: 'solid' |
| 12 | + }, |
| 13 | + shortName: 'solid', |
| 14 | + extraNpmDevDependencies: [], |
| 15 | + extraNpmDependencies: [], |
| 16 | + extraQuestions: ({ ci }) => { |
| 17 | + return [ |
| 18 | + { |
| 19 | + type: 'list', |
| 20 | + name: 'template', |
| 21 | + message: 'Which Solid template would you like to use?', |
| 22 | + choices: [ |
| 23 | + 'js', |
| 24 | + 'ts-bootstrap', |
| 25 | + 'ts-minimal', |
| 26 | + 'ts-router', |
| 27 | + 'ts-windicss', |
| 28 | + 'ts' |
| 29 | + ], |
| 30 | + default: 'ts', |
| 31 | + loop: false, |
| 32 | + when: !ci |
| 33 | + } |
| 34 | + ] |
| 35 | + }, |
| 36 | + configUpdate: ({ cfg, packageManager }) => ({ |
| 37 | + ...cfg, |
| 38 | + distDir: `../public`, |
| 39 | + devPath: 'http://localhost:3000', |
| 40 | + beforeDevCommand: `${ |
| 41 | + packageManager === 'npm' ? 'npm run' : packageManager |
| 42 | + } dev`, |
| 43 | + beforeBuildCommand: `${ |
| 44 | + packageManager === 'npm' ? 'npm run' : packageManager |
| 45 | + } build` |
| 46 | + }), |
| 47 | + preInit: async ({ cwd, cfg, answers }) => { |
| 48 | + let template = 'js' |
| 49 | + if (answers) { |
| 50 | + template = answers.template ? (answers.template as string) : 'js' |
| 51 | + } |
| 52 | + await shell( |
| 53 | + 'npx', |
| 54 | + ['degit', `solidjs/templates/${template}`, cfg.appName], |
| 55 | + { cwd } |
| 56 | + ) |
| 57 | + }, |
| 58 | + postInit: async ({ cfg, packageManager }) => { |
| 59 | + console.log(` |
| 60 | + Your installation completed. |
| 61 | + $ cd ${cfg.appName} |
| 62 | + $ ${packageManager} install |
| 63 | + $ ${packageManager === 'npm' ? 'npm run' : packageManager} tauri dev |
| 64 | + `) |
| 65 | + |
| 66 | + return await Promise.resolve() |
| 67 | + } |
| 68 | +} |
| 69 | + |
| 70 | +export { solid } |
0 commit comments