template.spec.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. const fixtureSetup = require('../fixtures/app-test-setup')
  2. const { resolve } = require('path')
  3. const { writeFileSync, readFileSync } = require('fs')
  4. describe('[CLI] cli.js template', () => {
  5. it('init a project and builds it', async () => {
  6. const cwd = process.cwd()
  7. const fixturePath = resolve(__dirname, '../fixtures/empty')
  8. const tauriFixturePath = resolve(fixturePath, 'src-tauri')
  9. fixtureSetup.initJest('empty')
  10. process.chdir(fixturePath)
  11. const { init, build } = require('dist/api/cli')
  12. const { promise } = await init({
  13. directory: process.cwd(),
  14. force: true,
  15. tauriPath: resolve(__dirname, '../../../../..'),
  16. ci: true
  17. })
  18. await promise
  19. process.chdir(tauriFixturePath)
  20. const manifestPath = resolve(tauriFixturePath, 'Cargo.toml')
  21. const manifestFile = readFileSync(manifestPath).toString()
  22. writeFileSync(manifestPath, `workspace = { }\n\n${manifestFile}`)
  23. const { promise: buildPromise } = await build({
  24. config: {
  25. tauri: {
  26. bundle: {
  27. targets: ['deb', 'app', 'msi', 'appimage'] // we can't bundle dmg on CI so we remove it here
  28. }
  29. }
  30. }
  31. })
  32. await buildPromise
  33. process.chdir(cwd)
  34. })
  35. })