Skip to content

Commit

Permalink
feat(cta): add SolidJS recipe (#2619)
Browse files Browse the repository at this point in the history
Co-authored-by: Amr Bashir <48618675+amrbashir@users.noreply.github.com>
  • Loading branch information
davedbase and amrbashir committed Sep 22, 2021
1 parent 943e6fe commit 71ea86a
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .changes/cta-solid-recipe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'create-tauri-app': patch
---

Add SolidJS recipe using the official template.
18 changes: 9 additions & 9 deletions .github/workflows/test-cta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions tooling/create-tauri-app/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -124,6 +125,7 @@ const allRecipes: Recipe[] = [
vuecli,
ngcli,
svelte,
solid,
dominator
]

Expand Down
70 changes: 70 additions & 0 deletions tooling/create-tauri-app/src/recipes/solid.ts
Original file line number Diff line number Diff line change
@@ -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 }
2 changes: 1 addition & 1 deletion tooling/create-tauri-app/test/spawn.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 71ea86a

Please sign in to comment.