Prechádzať zdrojové kódy

feat(cta): add SolidJS recipe (#2619)

Co-authored-by: Amr Bashir <48618675+amrbashir@users.noreply.github.com>
David D 3 rokov pred
rodič
commit
71ea86a443

+ 5 - 0
.changes/cta-solid-recipe.md

@@ -0,0 +1,5 @@
+---
+'create-tauri-app': patch
+---
+
+Add SolidJS recipe using the official template.

+ 9 - 9
.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"

+ 2 - 0
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
 ]
 

+ 70 - 0
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 }

+ 1 - 1
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() {