Skip to content
This repository has been archived by the owner on Apr 24, 2020. It is now read-only.

Commit

Permalink
feat: Add Capacitor support
Browse files Browse the repository at this point in the history
  • Loading branch information
rstoenescu committed Oct 8, 2019
1 parent 8f6614c commit 769a75d
Show file tree
Hide file tree
Showing 10 changed files with 720 additions and 38 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.DS_Store

# Runtime data
pids
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

# @quasar/icon-genie

This node module outputs a set of **SQUARE** favicons, webicons, pwa-icons and electron-icons as well as iOS, Windows Store and MacOS icons from an original 1240x1240 square icon that retains transparency and also **minifies** the assets. It will also create splash screens for Cordova and even a minified svg.
This node module outputs a set of **SQUARE** favicons, webicons, pwa-icons and electron-icons as well as iOS, Windows Store and MacOS icons from an original 1240x1240 square icon that retains transparency and also **minifies** the assets. It will also create splash screens for Cordova/Capacitor and even a minified svg.

It works cross-platform to generate those pesky `.icns` and `.ico` files used by Electron apps and in the case of the latter preferred by some browsers and webscrapers (favicon.ico) - even though modern development guidelines for Apple and Windows recommend using `.png`.

Expand Down Expand Up @@ -46,13 +46,13 @@ If you are on Windows and seeing an error the likes of `pngquant failed to build
$ npm install --global --production windows-build-tools
```

The most important part (and indeed the only reason to use this extension) is pointing it at your shiny icon (and splashscreen if you are building for Cordova.) So the first thing you are reminded of is that you need to do that!
The most important part (and indeed the only reason to use this extension) is pointing it at your shiny icon (and splashscreen if you are building for Cordova/Capacitor.) So the first thing you are reminded of is that you need to do that!

```
--------------------------- ATTENTION! -----------------------------
You must replace app-icon.png in the root folder of your project.
If you plan on building for Cordova, you must also replace the
If you plan on building for Cordova/Capacitor, you must also replace the
app-splashscreen.png image in the same place. File details:
-> app-icon.png 1240x1240 (with transparency)
Expand All @@ -75,7 +75,7 @@ Then choose a minification strategy:
You will be asked the same question for production. Our recommendation is to choose `optipng`. It has the best time / quality trade-off for a lossless minification - but `zopfli` WILL shave off a bit more bytes (at the cost of taking much, much longer).

You will also be asked for a background color. This is used in the few cases that a background is required, as with Cordova splashscreens and Cordova iOS icons.
You will also be asked for a background color. This is used in the few cases that a background is required, as with Cordova/Capacitor splashscreens and Cordova/Capacitor iOS icons.

### Triggering
The first time you start Quasar, icon-genie will create the images needed for the specific app artifacts. They will not automatically be added to git, so you will need to manage that yourself.
Expand Down
7 changes: 5 additions & 2 deletions bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ useful for other build pipelines.
Flags:
-p, --preset Choose a preset output or make your own
[minify|splash|svg|svgduochrome|favicon]
[spa|pwa|cordova|electron|bex|kitchensink|custom]
[spa|pwa|cordova|capacitor|electron|bex|kitchensink|custom]
-s, --source Your source image as a large square png
-t, --target The destination directory for the files created
-o, --options Path to file that overrides defaults (if custom)
Expand All @@ -61,7 +61,7 @@ if (!args.preset) {
console.log('You must choose a preset or declare custom.')
console.log(
' -p, --preset [minify|splash|svg|favicon]\n' +
' [kitchensink|spa|pwa|cordova|electron|custom]\n'
' [kitchensink|spa|pwa|cordova|capacitor|electron|custom]\n'
)
process.exit(0)
}
Expand Down Expand Up @@ -121,6 +121,9 @@ switch (args.preset) {
case 'cordova':
icongenie.cordova(args.source, args.target, args.minify)
break
case 'capacitor':
icongenie.capacitor(args.source, args.target, args.minify)
break
case 'electron':
icongenie.electron(args.source, args.target, args.minify)
break
Expand Down
3 changes: 0 additions & 3 deletions lib/cordova.js

This file was deleted.

64 changes: 44 additions & 20 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,29 @@ let icongenie = exports.icongenie = {
progress('Icon Genie Finished Cordova')
clearInterval(spinnerInterval)
},
capacitor: async function(src, target, strategy, options, splashSrc) {
const spinnerInterval = spinner()
try {
if (!splashSrc) splashSrc = src
options = options || settings.options.capacitor
await this.validate(src, target)
progress('Building Capacitor splash images')
await this.splash(src, splashSrc, target, options)
progress('Building Capacitor icons')
await this.build(src, target, options)
if (strategy) {
progress(`Minifying assets with ${strategy}`)
await this.minify(target, options, strategy, 'batch')
} else {
console.log('no minify strategy')
}
} catch (e) {
console.log('Capacitor: failed', e)
// throw e
}
progress('Icon Genie Finished Capacitor')
clearInterval(spinnerInterval)
},
electron: async function(src, target, strategy, options) {
const spinnerInterval = spinner()
try {
Expand Down Expand Up @@ -295,32 +318,33 @@ let icongenie = exports.icongenie = {
}
progress('Icon Genie Finished SPA')
clearInterval(spinnerInterval)
},
},
bex: async function(src, target, strategy, options) {
const spinnerInterval = spinner()
try {
options = options || settings.options.bex
await this.validate(src, target)
progress('Building Browser Extension icons')
await this.build(src, target, options)
if (strategy) {
progress(`Minifying assets with ${strategy}`)
await this.minify(target, options, strategy, 'batch')
} else {
console.log('no minify strategy')
const spinnerInterval = spinner()
try {
options = options || settings.options.bex
await this.validate(src, target)
progress('Building Browser Extension icons')
await this.build(src, target, options)
if (strategy) {
progress(`Minifying assets with ${strategy}`)
await this.minify(target, options, strategy, 'batch')
} else {
console.log('no minify strategy')
}
} catch (e) {
console.log('BEX: failed', e)
// throw e
}
} catch (e) {
console.log('BEX: failed', e)
// throw e
}
progress('Icon Genie Finished BEX')
clearInterval(spinnerInterval)
},
progress('Icon Genie Finished BEX')
clearInterval(spinnerInterval)
},
kitchensink: async function(src, target, strategy) {
await this.pwa(src, path.join(target, '/src/statics'), strategy)
await this.spa(src, path.join(target, '/src/statics'), strategy)
await this.electron(src, path.join(target + '/src-electron/icons'), strategy)
await this.cordova(src, path.join(target + '/src-cordova/res'), strategy)
await this.capacitor(src, path.join(target + '/src-capacitor'), strategy)
await this.bex(src, path.join(target + '/src-browser-ext/icons'), strategy)
},

Expand Down Expand Up @@ -463,7 +487,7 @@ let icongenie = exports.icongenie = {
* @param {string} mode - singlefile, single directory or batch
*/
minify: async function(target, options, strategy, mode) {
let cmd, chain
let cmd
let minify = settings.options.minify
if (!minify.available.find(x => x === strategy)) {
strategy = minify.type
Expand Down
Loading

0 comments on commit 769a75d

Please sign in to comment.