tauri-init.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. const parseArgs = require('minimist')
  2. const tauriCreate = require('./tauri-create')
  3. /**
  4. * init is an alias for create -r none, same as
  5. * creating a fresh tauri project with no UI recipe applied.
  6. *
  7. * @type {object}
  8. * @property {boolean} h
  9. * @property {boolean} help
  10. * @property {string|boolean} f
  11. * @property {string|boolean} force
  12. * @property {boolean} l
  13. * @property {boolean} log
  14. * @property {boolean} d
  15. * @property {boolean} directory
  16. */
  17. function main(cliArgs) {
  18. const argv = parseArgs(cliArgs, {
  19. alias: {
  20. h: 'help',
  21. },
  22. boolean: ['h']
  23. })
  24. if (argv.help) {
  25. printUsage()
  26. process.exit(0)
  27. }
  28. // delegate actual work to create command
  29. tauriCreate([...cliArgs, '-r', 'none'])
  30. }
  31. function printUsage() {
  32. console.log(`
  33. Description
  34. Inits the Tauri template. If Tauri cannot find the tauri.conf.json
  35. it will create one.
  36. Usage
  37. $ tauri init
  38. Options
  39. --help, -h Displays this message
  40. --ci Skip prompts
  41. --force, -f Force init to overwrite [conf|template|all]
  42. --log, -l Logging [boolean]
  43. --directory, -d Set target directory for init
  44. --tauri-path, -t Path of the Tauri project to use (relative to the cwd)
  45. --app-name, -A Name of your Tauri application
  46. --window-title, -W Window title of your Tauri application
  47. --dist-dir, -D Web assets location, relative to <project-dir>/src-tauri
  48. --dev-path, -P Url of your dev server
  49. `)
  50. }
  51. module.exports = main