Skip to content

Commit c0f42ad

Browse files
authored
feat(cta): prompt users to install @tauri-apps/api package (#2251)
1 parent 718d951 commit c0f42ad

3 files changed

Lines changed: 19 additions & 10 deletions

File tree

.changes/cta-prompt-api.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+
`create-tauri-app` will prompt users to install `@tauri-apps/api` npm package.

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ interface Responses {
113113
appName: string
114114
tauri: { window: { title: string } }
115115
recipeName: string
116+
installApi: boolean
116117
}
117118

118119
const allRecipes: Recipe[] = [vanillajs, cra, vite, vuecli, ngcli, svelte]
@@ -174,7 +175,8 @@ const runInit = async (argv: Argv): Promise<void> => {
174175
const defaults = {
175176
appName: 'tauri-app',
176177
tauri: { window: { title: 'Tauri App' } },
177-
recipeName: 'vanillajs'
178+
recipeName: 'vanillajs',
179+
installApi: true
178180
}
179181

180182
// prompt initial questions
@@ -201,6 +203,13 @@ const runInit = async (argv: Argv): Promise<void> => {
201203
choices: recipeDescriptiveNames,
202204
default: defaults.recipeName,
203205
when: !argv.ci && !argv.r
206+
},
207+
{
208+
type: 'confirm',
209+
name: 'installApi',
210+
message: 'Add "@tauri-apps/api" npm package?',
211+
default: true,
212+
when: !argv.ci
204213
}
205214
])
206215
.catch((error: { isTtyError: boolean }) => {
@@ -218,6 +227,7 @@ const runInit = async (argv: Argv): Promise<void> => {
218227
const {
219228
appName,
220229
recipeName,
230+
installApi,
221231
tauri: {
222232
window: { title }
223233
}
@@ -334,7 +344,9 @@ const runInit = async (argv: Argv): Promise<void> => {
334344
logStep('Installing any additional needed dependencies')
335345
await install({
336346
appDir: appDirectory,
337-
dependencies: recipe.extraNpmDependencies,
347+
dependencies: [installApi ? '@tauri-apps/api@latest' : ''].concat(
348+
recipe.extraNpmDependencies
349+
),
338350
devDependencies: [`@tauri-apps/cli@${tauriCLIVersion}`].concat(
339351
recipe.extraNpmDevDependencies
340352
),

tooling/create-tauri-app/src/recipes/ng-cli.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,13 @@ const ngcli: Recipe = {
4444
type: 'confirm',
4545
name: 'material',
4646
message: 'Add Angular Material (https://material.angular.io/)?',
47-
validate: (input: string) => {
48-
return input.toLowerCase() === 'yes'
49-
},
50-
loop: false,
5147
when: !ci
5248
},
5349
{
5450
type: 'confirm',
5551
name: 'eslint',
5652
message:
5753
'Add Angular ESLint (https://github.com/angular-eslint/angular-eslint)?',
58-
validate: (input: string) => {
59-
return input.toLowerCase() === 'yes'
60-
},
61-
loop: false,
6254
when: !ci
6355
}
6456
]

0 commit comments

Comments
 (0)