Skip to content

Commit 8a164d0

Browse files
authored
fix: CTA cache and vite build (#1806)
* use file as version for local links this also makes it closer to the production version and less likely to accidentally introudce an issue * always install latest without asking * work around issues with esbuild installing properly * test shouldn't run build-release on the cli * build cli.js and api outside of the test * try test on windows * change file * switch back to linux test * -y prompt not available on npm@6, remove * pipe
1 parent 8ef3b7a commit 8a164d0

7 files changed

Lines changed: 48 additions & 62 deletions

File tree

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+
Work around bugs between esbuild and npm by installing directly at the end of the sequence. Also default to using the latest on all of the installs instead of npx's cache.

.github/workflows/test-cta.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ on:
99
inputs:
1010
branch:
1111
default: "dev"
12+
platform:
13+
default: "ubuntu"
1214
pull_request:
1315
paths:
1416
- "tooling/create-tauri-app/**"
@@ -19,7 +21,7 @@ env:
1921
jobs:
2022
create-recipe-with-npm:
2123
name: "node@${{ matrix.node }} + npm@${{ matrix.manager }}: ${{ matrix.recipe }}"
22-
runs-on: ubuntu-latest
24+
runs-on: ${{ github.event.inputs.branch || 'ubuntu' }}-latest
2325

2426
strategy:
2527
fail-fast: false
@@ -45,9 +47,18 @@ jobs:
4547
npm-version: ${{ matrix.manager }}
4648
yarn-version: 1.22.5
4749
- name: install webkit2gtk
50+
if: (github.event.inputs.branch || 'ubuntu') == 'ubuntu'
4851
run: |
4952
sudo apt-get update
5053
sudo apt-get install -y libgtk-3-dev libgtksourceview-3.0-dev webkit2gtk-4.0 libappindicator3-dev
54+
- run: yarn
55+
working-directory: tooling/cli.js
56+
- run: yarn build
57+
working-directory: tooling/cli.js
58+
- run: yarn
59+
working-directory: tooling/api
60+
- run: yarn build
61+
working-directory: tooling/api
5162
- run: yarn
5263
working-directory: tooling/create-tauri-app
5364
- run: yarn build
@@ -60,7 +71,7 @@ jobs:
6071

6172
create-recipe-with-yarn:
6273
name: "node@${{ matrix.node }} + yarn@1: ${{ matrix.recipe }}"
63-
runs-on: ubuntu-latest
74+
runs-on: ${{ github.event.inputs.branch || 'ubuntu' }}-latest
6475

6576
strategy:
6677
fail-fast: false
@@ -81,6 +92,7 @@ jobs:
8192
node-version: ${{ matrix.node }}
8293
yarn-version: 1.22.5
8394
- name: install webkit2gtk
95+
if: (github.event.inputs.branch || 'ubuntu') == 'ubuntu'
8496
run: |
8597
sudo apt-get update
8698
sudo apt-get install -y libgtk-3-dev libgtksourceview-3.0-dev webkit2gtk-4.0 libappindicator3-dev

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

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import minimist from 'minimist'
66
import inquirer from 'inquirer'
77
import { bold, cyan, green, reset, yellow } from 'chalk'
88
import { platform } from 'os'
9-
import { resolve, join } from 'path'
9+
import { resolve, join, relative } from 'path'
1010
import { cra } from './recipes/react'
1111
import { vuecli } from './recipes/vue-cli'
1212
import { vanillajs } from './recipes/vanilla'
@@ -323,26 +323,19 @@ const runInit = async (argv: Argv): Promise<void> => {
323323
}
324324
}, [])
325325

326+
const tauriCLIVersion = !argv.dev
327+
? 'latest'
328+
: `file:${relative(appDirectory, join(__dirname, '../../cli.js'))}`
329+
326330
// Vue CLI plugin automatically runs these
327331
if (recipe.shortName !== 'vuecli') {
328332
logStep('Installing any additional needed dependencies')
329-
if (argv.dev) {
330-
await shell(packageManager, ['link', '@tauri-apps/cli'], {
331-
cwd: appDirectory
332-
})
333-
await shell(packageManager, ['link', '@tauri-apps/api'], {
334-
cwd: appDirectory
335-
})
336-
}
337-
338333
await install({
339334
appDir: appDirectory,
340335
dependencies: recipe.extraNpmDependencies,
341-
devDependencies: argv.dev
342-
? [...recipe.extraNpmDevDependencies]
343-
: [argv.dev ? '@tauri-apps/cli' : ''].concat(
344-
recipe.extraNpmDevDependencies
345-
),
336+
devDependencies: [`@tauri-apps/cli@${tauriCLIVersion}`].concat(
337+
recipe.extraNpmDevDependencies
338+
),
346339
packageManager
347340
})
348341

tooling/create-tauri-app/src/recipes/react.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export const cra: Recipe = {
8484
await shell(
8585
'npx',
8686
[
87-
'create-react-app',
87+
'create-react-app@latest',
8888
...(template === 'cra.ts' ? ['--template', 'typescript'] : []),
8989
`${cfg.appName}`,
9090
'--use-npm'

tooling/create-tauri-app/src/recipes/vite.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,23 +88,34 @@ const vite: Recipe = {
8888
cwd
8989
}
9090
)
91-
await shell('yarn', ['install'], { cwd })
9291
} else {
9392
await shell(
9493
'npx',
95-
['@vitejs/create-app', `${cfg.appName}`, '--template', `${template}`],
94+
[
95+
'@vitejs/create-app@latest',
96+
`${cfg.appName}`,
97+
'--template',
98+
`${template}`
99+
],
96100
{
97101
cwd
98102
}
99103
)
100-
await shell('npm', ['install'], { cwd })
101104
}
102105

103106
await afterViteCA(cwd, cfg.appName, template)
104107
},
105-
postInit: async ({ packageManager }) => {
108+
postInit: async ({ cwd, packageManager }) => {
109+
// we don't have a consistent way to rebuild and
110+
// esbuild has hit all the bugs and struggles to install on the postinstall
111+
await shell('node', ['./node_modules/esbuild/install.js'], { cwd })
112+
if (packageManager === 'yarn') {
113+
await shell('yarn', ['build'], { cwd })
114+
} else {
115+
await shell('npm', ['run', 'build'], { cwd })
116+
}
106117
console.log(`
107-
Your installation completed.
118+
Your installation completed. Change directories to \`${cwd}\`.
108119
To start, run ${packageManager === 'yarn' ? 'yarn' : 'npm run'} tauri ${
109120
packageManager === 'npm' ? '--' : ''
110121
} dev

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const vuecli: Recipe = {
2525
await shell(
2626
'npx',
2727
[
28-
'@vue/cli',
28+
'@vue/cli@latest',
2929
'create',
3030
`${cfg.appName}`,
3131
'--packageManager',

tooling/create-tauri-app/test/index.spec.ts

Lines changed: 3 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -20,45 +20,10 @@ const timeoutLong = 900000
2020
const timeoutLittleLonger = 930000
2121
const logOut = false ? 'inherit' : 'pipe'
2222

23-
beforeAll(async () => {
24-
const installCLI = await execa('yarn', [], {
25-
stdio: logOut,
26-
cwd: clijs,
27-
timeout: timeoutLong
28-
})
29-
30-
const buildCLI = await execa('yarn', ['build-release'], {
31-
stdio: logOut,
32-
cwd: clijs,
33-
timeout: timeoutLong
34-
})
35-
36-
const linkCLI = await execa('yarn', ['link'], {
37-
stdio: logOut,
38-
cwd: clijs,
39-
timeout: timeoutLong
40-
})
41-
42-
const installAPI = await execa('yarn', [], {
43-
stdio: logOut,
44-
cwd: api,
45-
timeout: timeoutLong
46-
})
47-
48-
const buildAPI = await execa('yarn', ['build'], {
49-
stdio: logOut,
50-
cwd: api,
51-
timeout: timeoutLong
52-
})
53-
54-
const linkAPI = await execa('yarn', ['link'], {
55-
stdio: logOut,
56-
cwd: path.join(api, 'dist'),
57-
timeout: timeoutLong
58-
})
59-
}, timeoutLittleLonger)
60-
6123
describe('CTA', () => {
24+
console.warn(
25+
'NOTE: You need to have installed and built cli.js and api before running the tests.'
26+
)
6227
describe.each(recipes.map((recipe) => [recipe, 'tauri-app']))(
6328
`%s recipe`,
6429
(recipe: string, appName: string) => {

0 commit comments

Comments
 (0)