2021-08-17 02:15:49 +03:00
|
|
|
const fixtureSetup = require('../fixtures/app-test-setup')
|
|
|
|
const { resolve } = require('path')
|
|
|
|
const { writeFileSync, readFileSync } = require('fs')
|
2020-03-09 23:57:27 +03:00
|
|
|
|
2021-04-12 07:59:25 +03:00
|
|
|
describe('[CLI] cli.js template', () => {
|
2020-07-09 16:40:31 +03:00
|
|
|
it('init a project and builds it', async () => {
|
2020-03-09 23:57:27 +03:00
|
|
|
const cwd = process.cwd()
|
2021-08-17 02:15:49 +03:00
|
|
|
const fixturePath = resolve(__dirname, '../fixtures/empty')
|
2020-07-09 16:40:31 +03:00
|
|
|
const tauriFixturePath = resolve(fixturePath, 'src-tauri')
|
2020-03-09 23:57:27 +03:00
|
|
|
|
2020-07-09 16:40:31 +03:00
|
|
|
fixtureSetup.initJest('empty')
|
2020-03-09 23:57:27 +03:00
|
|
|
|
2020-07-09 16:40:31 +03:00
|
|
|
process.chdir(fixturePath)
|
2020-03-09 23:57:27 +03:00
|
|
|
|
2021-08-17 02:15:49 +03:00
|
|
|
const { init, build } = require('dist/api/cli')
|
2021-04-14 16:50:15 +03:00
|
|
|
const { promise } = await init({
|
2020-07-09 16:40:31 +03:00
|
|
|
directory: process.cwd(),
|
2021-03-25 01:21:03 +03:00
|
|
|
force: true,
|
2021-08-17 02:15:49 +03:00
|
|
|
tauriPath: resolve(__dirname, '../../../../..'),
|
2021-03-25 01:21:03 +03:00
|
|
|
ci: true
|
2021-04-14 16:50:15 +03:00
|
|
|
})
|
|
|
|
await promise
|
2020-03-09 23:57:27 +03:00
|
|
|
|
2020-07-09 16:40:31 +03:00
|
|
|
process.chdir(tauriFixturePath)
|
2020-03-09 23:57:27 +03:00
|
|
|
|
2020-07-09 16:40:31 +03:00
|
|
|
const manifestPath = resolve(tauriFixturePath, 'Cargo.toml')
|
|
|
|
const manifestFile = readFileSync(manifestPath).toString()
|
2021-06-22 16:47:45 +03:00
|
|
|
writeFileSync(manifestPath, `workspace = { }\n${manifestFile}`)
|
2020-03-09 23:57:27 +03:00
|
|
|
|
2021-06-04 06:57:00 +03:00
|
|
|
const { promise: buildPromise } = await build()
|
2021-04-14 16:50:15 +03:00
|
|
|
await buildPromise
|
2021-01-30 18:15:47 +03:00
|
|
|
process.chdir(cwd)
|
2020-03-09 23:57:27 +03:00
|
|
|
})
|
|
|
|
})
|