فهرست منبع

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

Lucas Fernandes Nogueira 4 سال پیش
والد
کامیت
1e0b41e155
4فایلهای تغییر یافته به همراه14 افزوده شده و 7 حذف شده
  1. 5 0
      .changes/tauri-icon-cli.md
  2. 3 4
      tooling/cli.js/bin/tauri-icon.js
  3. 5 2
      tooling/cli.js/src/api/tauricon.ts
  4. 1 1
      tooling/cli.js/webpack.config.js

+ 5 - 0
.changes/tauri-icon-cli.md

@@ -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`.

+ 3 - 4
tooling/cli.js/bin/tauri-icon.js

@@ -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')

+ 5 - 2
tooling/cli.js/src/api/tauricon.ts

@@ -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)

+ 1 - 1
tooling/cli.js/webpack.config.js

@@ -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 }