tauri/tooling/cli.js/bin/tauri.js

105 lines
3.0 KiB
JavaScript
Raw Normal View History

#!/usr/bin/env node
feat(license): SPDX Headers (#1449) * chore(licenses): api Signed-off-by: Daniel Thompson-Yvetot <denjell@mailscript.com> * chore(licenses): scripts Signed-off-by: Daniel Thompson-Yvetot <denjell@mailscript.com> * chore(license): cli/core Signed-off-by: Daniel Thompson-Yvetot <denjell@mailscript.com> * chore(license): cli/tauri-bundler Signed-off-by: Daniel Thompson-Yvetot <denjell@mailscript.com> * chore(license): workflows Signed-off-by: Daniel Thompson-Yvetot <denjell@mailscript.com> * chore(license): require license_template in rust Signed-off-by: Daniel Thompson-Yvetot <denjell@mailscript.com> * chore(license): core/tauri Signed-off-by: Daniel Thompson-Yvetot <denjell@mailscript.com> * chore(license): core/tauri-api Signed-off-by: Daniel Thompson-Yvetot <denjell@mailscript.com> * chore(license): core/tauri-build Signed-off-by: Daniel Thompson-Yvetot <denjell@mailscript.com> * chore(license): core/tauri-codegen Signed-off-by: Daniel Thompson-Yvetot <denjell@mailscript.com> * chore(license): core/tauri-macros Signed-off-by: Daniel Thompson-Yvetot <denjell@mailscript.com> * chore(license): core/tauri-updater Signed-off-by: Daniel Thompson-Yvetot <denjell@mailscript.com> * chore(license): core/tauri-utils Signed-off-by: Daniel Thompson-Yvetot <denjell@mailscript.com> * chore(license): examples Signed-off-by: Daniel Thompson-Yvetot <denjell@mailscript.com> * chore(license): cli/tauri.js Signed-off-by: Daniel Thompson-Yvetot <denjell@mailscript.com> * chore(license): changefile Signed-off-by: Daniel Thompson-Yvetot <denjell@mailscript.com> * chore(license): place both licenses in root Signed-off-by: Daniel Thompson-Yvetot <denjell@mailscript.com> * chore(license): package.json SPDX Signed-off-by: Daniel Thompson-Yvetot <denjell@mailscript.com> * chore(license): SPDX everywhere Signed-off-by: Daniel Thompson-Yvetot <denjell@mailscript.com> * fix(tauri.js): tests more time for ubuntu Signed-off-by: Daniel Thompson-Yvetot <denjell@mailscript.com> * chore(license): commons conservancy language Signed-off-by: Daniel Thompson-Yvetot <denjell@mailscript.com> * chore(license): add spdx file Signed-off-by: Daniel Thompson-Yvetot <denjell@mailscript.com> * fix(license): clippy Signed-off-by: Daniel Thompson-Yvetot <denjell@mailscript.com> * chore(license): language Signed-off-by: Daniel Thompson-Yvetot <denjell@mailscript.com>
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
const chalk = require('chalk')
const pkg = require('../package.json')
const updateNotifier = require('update-notifier')
const cmds = ['icon', 'deps']
const rustCliCmds = ['dev', 'build', 'init', 'info', 'sign']
const cmd = process.argv[2]
/**
* @description This is the bootstrapper that in turn calls subsequent
* Tauri Commands
*
* @param {string|array} command
*/
const tauri = function (command) {
// notifying updates.
if (!(process.argv || []).some((arg) => arg === '--no-update-notifier')) {
updateNotifier({
pkg,
updateCheckInterval: 0
}).notify()
}
if (typeof command === 'object') {
// technically we just care about an array
command = command[0]
}
2019-12-24 15:47:15 +03:00
if (rustCliCmds.includes(command)) {
const { runOnRustCli } = require('../dist/helpers/rust-cli')
if (process.argv && !process.env.test) {
process.argv.splice(0, 3)
}
runOnRustCli(
command,
(process.argv || []).filter((v) => v !== '--no-update-notifier')
).promise.then(() => {
if (command === 'init') {
const {
installDependencies
} = require('../dist/api/dependency-manager')
return installDependencies()
}
})
} 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'`)}
${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
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
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(', ')}.`)
}
}
}
module.exports = {
tauri
}
tauri(cmd)