refactor(cli.js): tauri icon with positional arg for icon path (#1600)

This commit is contained in:
Lucas Fernandes Nogueira 2021-04-23 11:10:49 -03:00 committed by GitHub
parent cfa74ebf68
commit 1e0b41e155
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 7 deletions

View File

@ -0,0 +1,5 @@
---
"cli.js": patch
---
The `tauri icon` command now accepts the icon path as the first positional argument instead of `--icon PATH`.

View File

@ -25,7 +25,6 @@ const argv = parseArgs(process.argv.slice(2), {
h: 'help',
l: 'log',
c: 'config',
i: 'icon',
t: 'target'
},
boolean: ['h', 'l']
@ -35,14 +34,14 @@ if (argv.help) {
console.log(`
Description
Create all the icons you need for your Tauri app.
The icon path is the source icon (png, 1240x1240 with transparency).
Usage
$ tauri icon
$ tauri icon [ICON-PATH]
Options
--help, -h Displays this message
--log, l Logging [boolean]
--icon, i Source icon (png, 1240x1240 with transparency)
--target, t Target folder (default: 'src-tauri/icons')
--compression, c Compression type [pngquant|optipng|zopfli]
`)
@ -50,7 +49,7 @@ if (argv.help) {
}
tauricon
.make(argv.i, argv.t, argv.c || 'optipng')
.make(argv._[0], argv.t, argv.c || 'optipng')
.then(() => {
// TODO: use logger module for prettier output
console.log('app:tauri (tauricon) Completed')

View File

@ -188,16 +188,19 @@ const tauricon = (exports.tauricon = {
return version
},
make: async function (
src: string = path.resolve(appDir, 'app-icon.png'),
src: string | undefined,
target: string = path.resolve(tauriDir, 'icons'),
strategy: string,
// TODO: proper type for options
options: { [index: string]: any }
) {
if (!src) {
src = path.resolve(appDir, 'app-icon.png')
}
const spinnerInterval = spinner()
options = options || settings.options.tauri
progress(`Building Tauri icns and ico from "${src}"`)
await this.validate(src, target)
progress('Building Tauri icns and ico')
await this.icns(src, target, options, strategy)
progress('Building Tauri png icons')
await this.build(src, target, options)

View File

@ -42,7 +42,7 @@ module.exports = {
},
externals: [
nodeExternals({
allowlist: ['imagemin', 'is-png', 'p-pipe']
allowlist: ['imagemin', 'is-png', 'p-pipe', 'file-type']
})
],
externalsPresets: { node: true }