mirror of
https://github.com/tauri-apps/tauri.git
synced 2024-09-22 05:39:53 +03:00
parent
16d39b3c0d
commit
6a179997b4
6
.changes/fix-template.md
Normal file
6
.changes/fix-template.md
Normal 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.
|
@ -7,7 +7,6 @@ export default {
|
||||
},
|
||||
ctx: {},
|
||||
tauri: {
|
||||
cli: null,
|
||||
embeddedServer: {
|
||||
active: true
|
||||
},
|
||||
|
@ -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)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user