2021-08-11 20:00:35 +03:00
|
|
|
import * as fixtureSetup from '../fixtures/app-test-setup.js'
|
|
|
|
import { resolve, dirname } from 'path'
|
|
|
|
import { writeFileSync, readFileSync } from 'fs'
|
|
|
|
import { init, build } from 'dist/api/cli'
|
|
|
|
import { fileURLToPath } from 'url'
|
|
|
|
|
|
|
|
const currentDirName = dirname(fileURLToPath(import.meta.url))
|
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-11 20:00:35 +03:00
|
|
|
const fixturePath = resolve(currentDirName, '../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-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-11 20:00:35 +03:00
|
|
|
tauriPath: resolve(currentDirName, '../../../../..'),
|
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
|
|
|
})
|
|
|
|
})
|