From 71ea86a443f2585fa98edd79f2361bd85b380f0c Mon Sep 17 00:00:00 2001 From: David D <1168397+davedbase@users.noreply.github.com> Date: Wed, 22 Sep 2021 09:42:58 -0400 Subject: [PATCH] feat(cta): add SolidJS recipe (#2619) Co-authored-by: Amr Bashir <48618675+amrbashir@users.noreply.github.com> --- .changes/cta-solid-recipe.md | 5 ++ .github/workflows/test-cta.yml | 18 ++--- tooling/create-tauri-app/src/index.ts | 2 + tooling/create-tauri-app/src/recipes/solid.ts | 70 +++++++++++++++++++ tooling/create-tauri-app/test/spawn.test.mjs | 2 +- 5 files changed, 87 insertions(+), 10 deletions(-) create mode 100644 .changes/cta-solid-recipe.md create mode 100644 tooling/create-tauri-app/src/recipes/solid.ts diff --git a/.changes/cta-solid-recipe.md b/.changes/cta-solid-recipe.md new file mode 100644 index 000000000..6dccde7d7 --- /dev/null +++ b/.changes/cta-solid-recipe.md @@ -0,0 +1,5 @@ +--- +'create-tauri-app': patch +--- + +Add SolidJS recipe using the official template. diff --git a/.github/workflows/test-cta.yml b/.github/workflows/test-cta.yml index 85141d712..9e8a90d50 100644 --- a/.github/workflows/test-cta.yml +++ b/.github/workflows/test-cta.yml @@ -5,30 +5,30 @@ name: test create-tauri-app env: RUST_BACKTRACE: 1 - TAURI_RECIPE: 'vanillajs,cra,vite,ngcli' + TAURI_RECIPE: 'vanillajs,cra,vite,ngcli,solid' on: workflow_dispatch: inputs: platform: - default: "ubuntu" + default: 'ubuntu' pull_request: paths: - - "tooling/create-tauri-app/**" + - 'tooling/create-tauri-app/**' jobs: create-recipe-with-npm: - name: "node@${{ matrix.node }} + npm@${{ matrix.manager }}" + name: 'node@${{ matrix.node }} + npm@${{ matrix.manager }}' runs-on: ${{ github.event.inputs.platform || 'ubuntu' }}-latest strategy: fail-fast: false matrix: - node: ["14", "16"] - manager: ["7"] + node: ['14', '16'] + manager: ['7'] exclude: - - node: "16" - manager: "6" + - node: '16' + manager: '6' steps: - uses: actions/checkout@v2 @@ -61,7 +61,7 @@ jobs: - run: yarn test working-directory: tooling/create-tauri-app env: - TAURI_RUN_MANAGER: "npm" + TAURI_RUN_MANAGER: 'npm' # create-recipe-with-yarn: # name: "node@${{ matrix.node }} + yarn@1" diff --git a/tooling/create-tauri-app/src/index.ts b/tooling/create-tauri-app/src/index.ts index 0ff2b45bb..14a704d3e 100644 --- a/tooling/create-tauri-app/src/index.ts +++ b/tooling/create-tauri-app/src/index.ts @@ -14,6 +14,7 @@ import { vite } from './recipes/vite' import { dominator } from './recipes/dominator' import { ngcli } from './recipes/ng-cli' import { svelte } from './recipes/svelte' +import { solid } from './recipes/solid' import { install, checkPackageManager } from './dependency-manager' import { shell } from './shell' import { updatePackageJson } from './helpers/update-package-json' @@ -124,6 +125,7 @@ const allRecipes: Recipe[] = [ vuecli, ngcli, svelte, + solid, dominator ] diff --git a/tooling/create-tauri-app/src/recipes/solid.ts b/tooling/create-tauri-app/src/recipes/solid.ts new file mode 100644 index 000000000..ba9a3d062 --- /dev/null +++ b/tooling/create-tauri-app/src/recipes/solid.ts @@ -0,0 +1,70 @@ +// Copyright 2019-2021 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +import { shell } from '../shell' +import { Recipe } from '../types/recipe' + +const solid: Recipe = { + descriptiveName: { + name: 'Solid (https://github.com/solidjs/templates)', + value: 'solid' + }, + shortName: 'solid', + extraNpmDevDependencies: [], + extraNpmDependencies: [], + extraQuestions: ({ ci }) => { + return [ + { + type: 'list', + name: 'template', + message: 'Which Solid template would you like to use?', + choices: [ + 'js', + 'ts-bootstrap', + 'ts-minimal', + 'ts-router', + 'ts-windicss', + 'ts' + ], + default: 'ts', + loop: false, + when: !ci + } + ] + }, + configUpdate: ({ cfg, packageManager }) => ({ + ...cfg, + distDir: `../public`, + devPath: 'http://localhost:3000', + beforeDevCommand: `${ + packageManager === 'npm' ? 'npm run' : packageManager + } dev`, + beforeBuildCommand: `${ + packageManager === 'npm' ? 'npm run' : packageManager + } build` + }), + preInit: async ({ cwd, cfg, answers }) => { + let template = 'js' + if (answers) { + template = answers.template ? (answers.template as string) : 'js' + } + await shell( + 'npx', + ['degit', `solidjs/templates/${template}`, cfg.appName], + { cwd } + ) + }, + postInit: async ({ cfg, packageManager }) => { + console.log(` + Your installation completed. + $ cd ${cfg.appName} + $ ${packageManager} install + $ ${packageManager === 'npm' ? 'npm run' : packageManager} tauri dev + `) + + return await Promise.resolve() + } +} + +export { solid } diff --git a/tooling/create-tauri-app/test/spawn.test.mjs b/tooling/create-tauri-app/test/spawn.test.mjs index 5d5d3c6b7..0a7aea764 100644 --- a/tooling/create-tauri-app/test/spawn.test.mjs +++ b/tooling/create-tauri-app/test/spawn.test.mjs @@ -24,7 +24,7 @@ const api = path.resolve('../api/') const manager = process.env.TAURI_RUN_MANAGER || 'yarn' const recipes = process.env.TAURI_RECIPE ? process.env.TAURI_RECIPE.split(',') - : ['vanillajs', 'cra', 'vite', 'ngcli'] + : ['vanillajs', 'cra', 'vite', 'ngcli', 'solid'] const parallelize = process.env.TAURI_RECIPE_PARALLELIZE || false main(function* start() {