fix(tauri.js) default config is invalid closes #777 (#785)

This commit is contained in:
Lucas Fernandes Nogueira 2020-07-09 10:40:31 -03:00 committed by GitHub
parent 16d39b3c0d
commit 6a179997b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 41 additions and 33 deletions

6
.changes/fix-template.md Normal file
View File

@ -0,0 +1,6 @@
---
"tauri.js": patch
---
Fixes the wrong `cli` value on the template that's used by `tauri init`.
Also fixes the template test.

View File

@ -7,7 +7,6 @@ export default {
},
ctx: {},
tauri: {
cli: null,
embeddedServer: {
active: true
},

View File

@ -1,44 +1,45 @@
const fixtureSetup = require('../fixtures/app-test-setup')
const { resolve } = require('path')
const { rmdirSync, existsSync, writeFileSync, readFileSync } = require('fs')
const {
resolve
} = require('path')
const {
writeFileSync,
readFileSync
} = require('fs')
describe('[CLI] tauri.js template', () => {
it('init a project and builds it', done => {
it('init a project and builds it', async () => {
const cwd = process.cwd()
try {
const fixturePath = resolve(__dirname, '../fixtures/empty')
const tauriFixturePath = resolve(fixturePath, 'src-tauri')
const fixturePath = resolve(__dirname, '../fixtures/empty')
const tauriFixturePath = resolve(fixturePath, 'src-tauri')
fixtureSetup.initJest('empty')
fixtureSetup.initJest('empty')
process.chdir(fixturePath)
process.chdir(fixturePath)
const init = require('api/init')
init({
directory: process.cwd(),
force: 'all',
tauriPath: resolve(__dirname, '../../../../..')
})
const init = require('api/init')
init({
directory: process.cwd(),
force: 'all',
tauriPath: resolve(__dirname, '../../../../..')
})
process.chdir(tauriFixturePath)
process.chdir(tauriFixturePath)
const manifestPath = resolve(tauriFixturePath, 'Cargo.toml')
const manifestFile = readFileSync(manifestPath).toString()
writeFileSync(manifestPath, `workspace = { }\n\n${manifestFile}`)
} catch (e) {
done(e)
}
const manifestPath = resolve(tauriFixturePath, 'Cargo.toml')
const manifestFile = readFileSync(manifestPath).toString()
writeFileSync(manifestPath, `workspace = { }\n\n${manifestFile}`)
const build = require('api/build')
build({
await build({
tauri: {
bundle: {
targets: ['deb', 'osx', 'msi', 'appimage'] // we can't bundle dmg on CI so we remove it here
}
}
}).promise.then(() => {
writeFileSync('a.b', 'finished')
process.chdir(cwd)
done()
}).catch(done)
})
})
})

View File

@ -5,10 +5,10 @@ const mockFixtureDir = path.resolve(__dirname, '../fixtures')
module.exports.fixtureDir = mockFixtureDir
function mockResolvePath (basePath, dir) {
return dir && path.isAbsolute(dir)
? dir
: path.resolve(basePath, dir)
function mockResolvePath(basePath, dir) {
return dir && path.isAbsolute(dir) ?
dir :
path.resolve(basePath, dir)
}
module.exports.initJest = (mockFixture) => {
@ -36,8 +36,6 @@ module.exports.initJest = (mockFixture) => {
}
}
})
jest.spyOn(process, 'exit').mockImplementation(() => {})
}
module.exports.startServer = (onSuccess) => {
@ -62,7 +60,8 @@ module.exports.startServer = (onSuccess) => {
renameFileWithDir: null,
listen: null
}
function addResponse (response) {
function addResponse(response) {
responses[response.cmd] = true
if (!Object.values(responses).some(c => c === null)) {
server.close(onSuccess)
@ -107,5 +106,8 @@ module.exports.startServer = (onSuccess) => {
const port = 7000
const server = app.listen(port)
return { server, responses }
return {
server,
responses
}
}