Skip to content

Commit

Permalink
docs: Icons
Browse files Browse the repository at this point in the history
  • Loading branch information
develar committed Aug 17, 2017
1 parent ed4d8d0 commit 2781371
Show file tree
Hide file tree
Showing 9 changed files with 164 additions and 116 deletions.
1 change: 1 addition & 0 deletions .idea/dictionaries/develar.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ Platform specific `7zip-bin-*` packages are `optionalDependencies`, which may re
```
See [all options](https://github.com/electron-userland/electron-builder/wiki/Options).

3. Create a directory [build](https://github.com/electron-userland/electron-builder/wiki/Options#MetadataDirectories-buildResources) in the root of the project and save a `background.png` (macOS DMG background), `icon.icns` (macOS app icon) and `icon.ico` (Windows app icon) into it.

<a id="user-content-linuxIcon" class="anchor" href="#linuxIcon" aria-hidden="true"></a>The Linux icon set will be generated automatically based on the macOS `icns` file (or you can put them into the `build/icons` directory if you want to specify them yourself. The filename must contain the size (e.g. `32x32.png`) of the icon).
3. Add [icons](https://github.com/electron-userland/electron-builder/wiki/Icons).

4. Add the [scripts](https://docs.npmjs.com/cli/run-script) key to the development `package.json`:
```json
Expand Down
1 change: 1 addition & 0 deletions docs/Home.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
**Basics**

* [[Options]]
* [[Icons]]
* [[Auto Update]]
* [[Code Signing]]
* [[Publishing Artifacts]]
Expand Down
43 changes: 43 additions & 0 deletions docs/Icons.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
Recommended tools: [MakeAppIcon](https://makeappicon.com/), [AppIcon Generator](http://www.tweaknow.com/appicongenerator.php).

## macOS

Files

* `icon.icns` (macOS app icon). Icon size should be at least 512x512.
* `background.png` (macOS DMG background).

need to be placed in the [build](https://github.com/electron-userland/electron-builder/wiki/Options#MetadataDirectories-buildResources) directory.

## Windows (NSIS)

* `icon.ico` (Windows app icon). Icon size should be at least 256x256.

need to be placed in the [build](https://github.com/electron-userland/electron-builder/wiki/Options#MetadataDirectories-buildResources) directory.

## Linux

Linux icon set will be generated automatically based on the macOS `icns` file.

Or you can put them into the `build/icons` directory if you want to specify them yourself.
The filename must contain the size (e.g. `32x32.png`) of the icon). Recommended sizes: 16, 24, 32, 48, 64, 96, 128, 512, 1024 (or just 512).

## AppX

AppX assets need to be placed in the `appx` folder in the [build](https://github.com/electron-userland/electron-builder/wiki/Options#MetadataDirectories-buildResources) directory.

The assets should follow these naming conventions:

- Logo: `StoreLogo.png`
- Square150x150Logo: `Square150x150Logo.png`
- Square44x44Logo: `Square44x44Logo.png`
- Wide310x150Logo: `Wide310x150Logo.png`
- *Optional* BadgeLogo: `BadgeLogo.png`
- *Optional* Square310x310Logo: `LargeTile.png`
- *Optional* Square71x71Logo: `SmallTile.png`
- *Optional* SplashScreen: `SplashScreen.png`

All official AppX asset types are supported by the build process. These assets can include scaled assets by using `target size` and `scale` in the name.
See [Guidelines for tile and icon assets](https://docs.microsoft.com/en-us/windows/uwp/controls-and-patterns/tiles-and-notifications-app-assets) for more information.

Default assets will be used for `Logo`, `Square150x150Logo`, `Square44x44Logo` and `Wide310x150Logo` if not provided. For assets marked `Optional`, these assets will not be listed in the manifest file if not provided.
1 change: 1 addition & 0 deletions docs/_Sidebar.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
**Basics**

* [[Options]]
* [[Icons]]
* [[Auto Update]]
* [[Code Signing]]
* [[Publishing Artifacts]]
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"ajv-keywords": "^2.1.0",
"archiver": "^2.0.0",
"async-exit-hook": "^2.0.1",
"aws-sdk": "^2.98.0",
"aws-sdk": "^2.100.0",
"bluebird-lst": "^1.0.3",
"chalk": "^2.1.0",
"chromium-pickle-js": "^0.2.0",
Expand Down Expand Up @@ -74,7 +74,7 @@
"@types/dotenv": "^4.0.0",
"@types/ini": "^1.3.29",
"@types/jest": "^20.0.7",
"@types/js-yaml": "^3.9.0",
"@types/js-yaml": "^3.9.1",
"@types/source-map-support": "^0.4.0",
"@types/xml2js": "^0.4.0",
"babel-preset-ts-node4-bluebird": "^0.1.0",
Expand Down
24 changes: 14 additions & 10 deletions packages/electron-builder/src/targets/appx.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import BluebirdPromise from "bluebird-lst"
import _debug from "debug"
import { Arch, asArray, getArchSuffix, spawn, use } from "electron-builder-util"
import { copyDir, copyFile } from "electron-builder-util/out/fs"
import { orIfFileNotExist } from "electron-builder-util/out/promise"
import { emptyDir, readdir, readFile, writeFile } from "fs-extra-p"
import { copyDir, copyOrLinkFile } from "electron-builder-util/out/fs"
import { emptyDir, mkdir, readdir, readFile, writeFile } from "fs-extra-p"
import * as path from "path"
import { deepAssign } from "read-config-file/out/deepAssign"
import { Target } from "../core"
Expand Down Expand Up @@ -59,17 +58,23 @@ export default class AppXTarget extends Target {
const preAppx = path.join(this.outDir, `pre-appx-${getArchSuffix(arch)}`)
await emptyDir(preAppx)

const resourceList = await packager.resourceList
if (resourceList.includes(APPX_ASSETS_DIR_NAME)) {
await copyDir(path.join(packager.buildResourcesDir, APPX_ASSETS_DIR_NAME), path.join(preAppx, "assets"))
const assetOutDir = path.join(preAppx, "assets")
const userAssetDir = await packager.getResource(undefined, APPX_ASSETS_DIR_NAME)
let userAssets: Array<string>
if (userAssetDir == null) {
userAssets = []
}
else {
userAssets = (await readdir(userAssetDir)).filter(it => !it.startsWith(".") && !it.endsWith(".db") && it.includes("."))
await mkdir(assetOutDir)
await BluebirdPromise.map(userAssets, it => copyOrLinkFile(path.join(userAssetDir, it), path.join(assetOutDir, it)))
}

const userAssets = await orIfFileNotExist(readdir(path.join(packager.buildResourcesDir, APPX_ASSETS_DIR_NAME)), [])
const vendorPath = await getSignVendorPath()
const taskManager = new AsyncTaskManager(packager.info.cancellationToken)
taskManager.addTask(BluebirdPromise.map(Object.keys(vendorAssetsForDefaultAssets), defaultAsset => {
if (!isDefaultAssetIncluded(userAssets, defaultAsset)) {
return copyFile(path.join(vendorPath, "appxAssets", vendorAssetsForDefaultAssets[defaultAsset]), path.join(preAppx, "assets", defaultAsset))
return copyOrLinkFile(path.join(vendorPath, "appxAssets", vendorAssetsForDefaultAssets[defaultAsset]), path.join(assetOutDir, defaultAsset))
}
return null
}))
Expand Down Expand Up @@ -215,12 +220,11 @@ function splashScreenTag(userAssets: Array<string>): string {
}

function isDefaultAssetIncluded(userAssets: Array<string>, defaultAsset: string) {
const defaultAssetName = defaultAsset.split(".")[0]
const defaultAssetName = defaultAsset.substring(0, defaultAsset.indexOf("."))
return userAssets.some(it => it.includes(defaultAssetName))
}

function isScaledAssetsProvided(userAssets: Array<string>) {
// noinspection SpellCheckingInspection
return userAssets.some(it => it.includes(".scale-") || it.includes(".targetsize-"))
}

Expand Down
2 changes: 1 addition & 1 deletion packages/electron-publisher-s3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
],
"dependencies": {
"fs-extra-p": "^4.4.0",
"aws-sdk": "^2.98.0",
"aws-sdk": "^2.100.0",
"mime": "^1.3.6",
"electron-publish": "~0.0.0-semantic-release",
"electron-builder-util": "~0.0.0-semantic-release",
Expand Down
Loading

0 comments on commit 2781371

Please sign in to comment.