2019-08-20 00:09:29 +03:00
|
|
|
#!/usr/bin/env node
|
2021-04-11 01:09:09 +03:00
|
|
|
// Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
// SPDX-License-Identifier: MIT
|
2019-08-20 00:09:29 +03:00
|
|
|
|
2021-04-12 00:11:27 +03:00
|
|
|
const chalk = require('chalk')
|
|
|
|
const pkg = require('../package.json')
|
|
|
|
const updateNotifier = require('update-notifier')
|
|
|
|
|
2021-04-01 21:46:59 +03:00
|
|
|
const cmds = ['icon', 'deps']
|
2021-04-05 20:51:17 +03:00
|
|
|
const rustCliCmds = ['dev', 'build', 'init', 'info', 'sign']
|
2019-08-20 00:09:29 +03:00
|
|
|
|
|
|
|
const cmd = process.argv[2]
|
2019-11-18 00:30:14 +03:00
|
|
|
/**
|
|
|
|
* @description This is the bootstrapper that in turn calls subsequent
|
|
|
|
* Tauri Commands
|
|
|
|
*
|
|
|
|
* @param {string|array} command
|
|
|
|
*/
|
2021-04-14 04:09:13 +03:00
|
|
|
const tauri = async function (command) {
|
2021-04-12 00:11:27 +03:00
|
|
|
// notifying updates.
|
|
|
|
if (!(process.argv || []).some((arg) => arg === '--no-update-notifier')) {
|
|
|
|
updateNotifier({
|
|
|
|
pkg,
|
|
|
|
updateCheckInterval: 0
|
|
|
|
}).notify()
|
|
|
|
}
|
|
|
|
|
2020-08-19 05:36:46 +03:00
|
|
|
if (typeof command === 'object') {
|
|
|
|
// technically we just care about an array
|
2019-11-18 00:30:14 +03:00
|
|
|
command = command[0]
|
|
|
|
}
|
2019-12-24 15:47:15 +03:00
|
|
|
|
2021-01-30 18:15:47 +03:00
|
|
|
if (rustCliCmds.includes(command)) {
|
|
|
|
const { runOnRustCli } = require('../dist/helpers/rust-cli')
|
|
|
|
if (process.argv && !process.env.test) {
|
|
|
|
process.argv.splice(0, 3)
|
|
|
|
}
|
2021-04-14 04:09:13 +03:00
|
|
|
;(
|
|
|
|
await runOnRustCli(
|
|
|
|
command,
|
|
|
|
(process.argv || []).filter((v) => v !== '--no-update-notifier')
|
|
|
|
)
|
2021-04-12 00:11:27 +03:00
|
|
|
).promise.then(() => {
|
2021-03-25 01:21:03 +03:00
|
|
|
if (command === 'init') {
|
|
|
|
const {
|
|
|
|
installDependencies
|
|
|
|
} = require('../dist/api/dependency-manager')
|
|
|
|
return installDependencies()
|
|
|
|
}
|
|
|
|
})
|
2021-04-12 00:11:27 +03:00
|
|
|
} else {
|
|
|
|
if (
|
|
|
|
!command ||
|
|
|
|
command === '-h' ||
|
|
|
|
command === '--help' ||
|
|
|
|
command === 'help'
|
|
|
|
) {
|
|
|
|
console.log(`
|
|
|
|
${chalk.cyan(`
|
|
|
|
:oooodddoooo; ;oddl, ,ol, ,oc, ,ldoooooooc, ,oc,
|
|
|
|
';;;cxOx:;;;' ;xOxxko' :kx: lkd, :xkl;;;;:okx: lkd,
|
|
|
|
'dOo' 'oOd;:xkc :kx: lkd, :xx: ;xkc lkd,
|
|
|
|
'dOo' ckx: lkx; :kx: lkd, :xx: :xkc lkd,
|
|
|
|
'dOo' ;xkl ,dko' :kx: lkd, :xx:.....xko, lkd,
|
|
|
|
'dOo' 'oOd, :xkc :kx: lkd, :xx:,;cokko' lkd,
|
|
|
|
'dOo' ckk: lkx; :kx: lkd, :xx: ckkc lkd,
|
|
|
|
'dOo' ;xOl lko; :xkl;,....;oOd, :xx: :xkl' lkd,
|
|
|
|
'okl' 'kd' 'xx' 'dxxxddddxxo' :dd; ;dxc 'xo'`)}
|
2021-01-30 18:15:47 +03:00
|
|
|
|
2021-04-12 00:11:27 +03:00
|
|
|
${chalk.yellow('Description')}
|
|
|
|
This is the Tauri CLI
|
|
|
|
${chalk.yellow('Usage')}
|
|
|
|
$ tauri ${[...rustCliCmds, ...cmds].join('|')}
|
|
|
|
${chalk.yellow('Options')}
|
|
|
|
--help, -h Displays this message
|
|
|
|
--version, -v Displays the Tauri CLI version
|
|
|
|
`)
|
2019-12-24 15:47:15 +03:00
|
|
|
|
2021-04-12 00:11:27 +03:00
|
|
|
process.exit(0)
|
|
|
|
// eslint-disable-next-line no-unreachable
|
|
|
|
return false // do this for node consumers and tests
|
|
|
|
}
|
2019-12-24 15:47:15 +03:00
|
|
|
|
2021-04-12 00:11:27 +03:00
|
|
|
if (command === '-v' || command === '--version') {
|
|
|
|
console.log(`${pkg.version}`)
|
|
|
|
return false // do this for node consumers and tests
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cmds.includes(command)) {
|
|
|
|
if (process.argv && !process.env.test) {
|
|
|
|
process.argv.splice(2, 1)
|
|
|
|
}
|
|
|
|
console.log(`[tauri]: running ${command}`)
|
|
|
|
require(`./tauri-${command}`)
|
|
|
|
} else {
|
|
|
|
console.log(`Invalid command ${command}. Use one of ${cmds.join(', ')}.`)
|
2019-11-16 21:51:46 +03:00
|
|
|
}
|
|
|
|
}
|
2019-08-20 00:09:29 +03:00
|
|
|
}
|
2021-04-12 00:11:27 +03:00
|
|
|
|
2020-07-16 00:01:37 +03:00
|
|
|
module.exports = {
|
|
|
|
tauri
|
|
|
|
}
|
2019-11-16 21:51:46 +03:00
|
|
|
|
2021-04-14 04:09:13 +03:00
|
|
|
tauri(cmd).catch((e) => {
|
|
|
|
throw e
|
|
|
|
})
|