Skip to content

Commit 71ea86a

Browse files
davedbaseamrbashir
andauthored
feat(cta): add SolidJS recipe (#2619)
Co-authored-by: Amr Bashir <48618675+amrbashir@users.noreply.github.com>
1 parent 943e6fe commit 71ea86a

5 files changed

Lines changed: 87 additions & 10 deletions

File tree

.changes/cta-solid-recipe.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'create-tauri-app': patch
3+
---
4+
5+
Add SolidJS recipe using the official template.

.github/workflows/test-cta.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,30 @@
55
name: test create-tauri-app
66
env:
77
RUST_BACKTRACE: 1
8-
TAURI_RECIPE: 'vanillajs,cra,vite,ngcli'
8+
TAURI_RECIPE: 'vanillajs,cra,vite,ngcli,solid'
99

1010
on:
1111
workflow_dispatch:
1212
inputs:
1313
platform:
14-
default: "ubuntu"
14+
default: 'ubuntu'
1515
pull_request:
1616
paths:
17-
- "tooling/create-tauri-app/**"
17+
- 'tooling/create-tauri-app/**'
1818

1919
jobs:
2020
create-recipe-with-npm:
21-
name: "node@${{ matrix.node }} + npm@${{ matrix.manager }}"
21+
name: 'node@${{ matrix.node }} + npm@${{ matrix.manager }}'
2222
runs-on: ${{ github.event.inputs.platform || 'ubuntu' }}-latest
2323

2424
strategy:
2525
fail-fast: false
2626
matrix:
27-
node: ["14", "16"]
28-
manager: ["7"]
27+
node: ['14', '16']
28+
manager: ['7']
2929
exclude:
30-
- node: "16"
31-
manager: "6"
30+
- node: '16'
31+
manager: '6'
3232

3333
steps:
3434
- uses: actions/checkout@v2
@@ -61,7 +61,7 @@ jobs:
6161
- run: yarn test
6262
working-directory: tooling/create-tauri-app
6363
env:
64-
TAURI_RUN_MANAGER: "npm"
64+
TAURI_RUN_MANAGER: 'npm'
6565

6666
# create-recipe-with-yarn:
6767
# name: "node@${{ matrix.node }} + yarn@1"

tooling/create-tauri-app/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { vite } from './recipes/vite'
1414
import { dominator } from './recipes/dominator'
1515
import { ngcli } from './recipes/ng-cli'
1616
import { svelte } from './recipes/svelte'
17+
import { solid } from './recipes/solid'
1718
import { install, checkPackageManager } from './dependency-manager'
1819
import { shell } from './shell'
1920
import { updatePackageJson } from './helpers/update-package-json'
@@ -124,6 +125,7 @@ const allRecipes: Recipe[] = [
124125
vuecli,
125126
ngcli,
126127
svelte,
128+
solid,
127129
dominator
128130
]
129131

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
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 }

tooling/create-tauri-app/test/spawn.test.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const api = path.resolve('../api/')
2424
const manager = process.env.TAURI_RUN_MANAGER || 'yarn'
2525
const recipes = process.env.TAURI_RECIPE
2626
? process.env.TAURI_RECIPE.split(',')
27-
: ['vanillajs', 'cra', 'vite', 'ngcli']
27+
: ['vanillajs', 'cra', 'vite', 'ngcli', 'solid']
2828
const parallelize = process.env.TAURI_RECIPE_PARALLELIZE || false
2929

3030
main(function* start() {

0 commit comments

Comments
 (0)