Skip to content

Commit

Permalink
feat: files option
Browse files Browse the repository at this point in the history
BREAKING CHANGE: prune by default, hidden files are not copied by default anymore
  • Loading branch information
develar committed Jun 8, 2016
1 parent 5853514 commit 0f7624d
Show file tree
Hide file tree
Showing 8 changed files with 229 additions and 87 deletions.
15 changes: 11 additions & 4 deletions docs/Options.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,17 @@ Here documented only `electron-builder` specific options:
| app-category-type | <a name="BuildMetadata-app-category-type"></a><p>*OS X-only.* The application category type, as shown in the Finder via *View -&gt; Arrange by Application Category* when viewing the Applications directory.</p> <p>For example, <code>app-category-type=public.app-category.developer-tools</code> will set the application category to *Developer Tools*.</p> <p>Valid values are listed in [Apple’s documentation](https://developer.apple.com/library/ios/documentation/General/Reference/InfoPlistKeyReference/Articles/LaunchServicesKeys.html#//apple_ref/doc/uid/TP40009250-SW8).</p>
| asar | <a name="BuildMetadata-asar"></a><p>Whether to package the application’s source code into an archive, using [Electron’s archive format](https://github.com/electron/asar). Defaults to <code>true</code>. Reasons why you may want to disable this feature are described in [an application packaging tutorial in Electron’s documentation](http://electron.atom.io/docs/latest/tutorial/application-packaging/#limitations-on-node-api/).</p> <p>Or you can pass object of any asar options.</p>
| productName | <a name="BuildMetadata-productName"></a>See [AppMetadata.productName](#AppMetadata-productName).
| extraResources | <a name="BuildMetadata-extraResources"></a><p>A [glob expression](https://www.npmjs.com/package/glob#glob-primer), when specified, copy the file or directory with matching names directly into the app’s resources directory (<code>Contents/Resources</code> for OS X, <code>resources</code> for Linux/Windows). [Multiple patterns](#multiple-glob-patterns) are supported.</p> <p>You can use <code>${os}</code> (expanded to osx, linux or win according to current platform) and <code>${arch}</code> in the pattern.</p> <p>If directory matched, all contents are copied. So, you can just specify <code>foo</code> to copy <code>&lt;project_dir&gt;/foo</code> directory.</p> <p>May be specified in the platform options (e.g. in the <code>build.osx</code>).</p>
| extraFiles | <a name="BuildMetadata-extraFiles"></a>The same as [extraResources](#BuildMetadata-extraResources) but copy into the app's content directory (`Contents` for OS X, `` for Linux/Windows).
| files | <a name="BuildMetadata-files"></a><p>A [glob patterns](https://www.npmjs.com/package/glob#glob-primer) relative to the [app directory](#MetadataDirectories-app), which specifies which files to include when copying files to create the package. Defaults to <code>\*\*\/\*</code> (i.e. [hidden files are ignored by default](https://www.npmjs.com/package/glob#dots)).</p> <p>[Multiple patterns](#multiple-glob-patterns) are supported. You can use <code>${os}</code> (expanded to osx, linux or win according to current platform) and <code>${arch}</code> in the pattern.</p> <p>If directory matched, all contents are copied. So, you can just specify <code>foo</code> to copy <code>foo</code> directory.</p> <p>Remember that default pattern <code>\*\*\/\*</code> is not added to your custom, so, you have to add it explicitly — e.g. <code>[&quot;\*\*\/\*&quot;, &quot;!ignoreMe${/\*}&quot;]</code>.</p> <p>May be specified in the platform options (e.g. in the <code>build.osx</code>).</p>
| extraResources | <a name="BuildMetadata-extraResources"></a><p>A [glob patterns](https://www.npmjs.com/package/glob#glob-primer) relative to the project directory, when specified, copy the file or directory with matching names directly into the app’s resources directory (<code>Contents/Resources</code> for OS X, <code>resources</code> for Linux/Windows).</p> <p>Glob rules the same as for [files](#BuildMetadata-files).</p>
| extraFiles | <a name="BuildMetadata-extraFiles"></a>The same as [extraResources](#BuildMetadata-extraResources) but copy into the app's content directory (`Contents` for OS X, root directory for Linux/Windows).
| osx | <a name="BuildMetadata-osx"></a>See [.build.osx](#OsXBuildOptions).
| mas | <a name="BuildMetadata-mas"></a>See [.build.mas](#MasBuildOptions).
| win | <a name="BuildMetadata-win"></a>See [.build.win](#LinuxBuildOptions).
| linux | <a name="BuildMetadata-linux"></a>See [.build.linux](#LinuxBuildOptions).
| compression | <a name="BuildMetadata-compression"></a>The compression level, one of `store`, `normal`, `maximum` (default: `normal`). If you want to rapidly test build, `store` can reduce build time significantly.
| afterPack | <a name="BuildMetadata-afterPack"></a>*programmatic API only* The function to be run after pack (but before pack into distributable format and sign). Promise must be returned.
| npmRebuild | <a name="BuildMetadata-npmRebuild"></a>Whether to rebuild native dependencies (`npm rebuild`) before starting to package the app. Defaults to `true`.
| npmPrune | <a name="BuildMetadata-npmPrune"></a><p>Whether to [prune](https://docs.npmjs.com/cli/prune) native dependencies (<code>npm prune --production</code>) before starting to package the app. Defaults to <code>true</code> if [two package.json structure](https://github.com/electron-userland/electron-builder#two-packagejson-structure) is not used.</p>
| npmRebuild | <a name="BuildMetadata-npmRebuild"></a>Whether to [rebuild](https://docs.npmjs.com/cli/rebuild) native dependencies (`npm rebuild`) before starting to package the app. Defaults to `true`.

<a name="OsXBuildOptions"></a>
### `.build.osx`
Expand Down Expand Up @@ -134,4 +136,9 @@ MAS (Mac Application Store) specific options (in addition to `build.osx`).
// unless it's foo/bar.js
"foo/bar.js",
]
```
```

## Excluding directories

Remember that `!doNotCopyMe/**/*` would match the files *in* the `doNotCopyMe` directory, but not the directory itself, so the [empty directory](https://github.com/gulpjs/gulp/issues/165#issuecomment-32613179) would be created.
Solution — use macro `${/*}`, e.g. `!doNotCopyMe${/*}`.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@
"debug": "^2.2.0",
"deep-assign": "^2.0.0",
"electron-osx-sign-tf": "0.6.0",
"electron-packager-tf": "~7.3.0",
"electron-packager-tf": "~7.3.2",
"electron-winstaller-fixed": "~2.9.6",
"fs-extra-p": "^1.0.1",
"fs-extra-p": "^1.0.2",
"glob": "^7.0.3",
"hosted-git-info": "^2.1.5",
"image-size": "^0.5.0",
Expand Down
33 changes: 25 additions & 8 deletions src/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,21 +108,29 @@ export interface BuildMetadata {
readonly productName?: string | null

/**
A [glob expression](https://www.npmjs.com/package/glob#glob-primer), when specified, copy the file or directory with matching names directly into the app's resources directory (`Contents/Resources` for OS X, `resources` for Linux/Windows).
[Multiple patterns](#multiple-glob-patterns) are supported.
A [glob patterns](https://www.npmjs.com/package/glob#glob-primer) relative to the [app directory](#MetadataDirectories-app), which specifies which files to include when copying files to create the package. Defaults to `\*\*\/\*` (i.e. [hidden files are ignored by default](https://www.npmjs.com/package/glob#dots)).
You can use `${os}` (expanded to osx, linux or win according to current platform) and `${arch}` in the pattern.
[Multiple patterns](#multiple-glob-patterns) are supported. You can use `${os}` (expanded to osx, linux or win according to current platform) and `${arch}` in the pattern.
If directory matched, all contents are copied. So, you can just specify `foo` to copy `<project_dir>/foo` directory.
If directory matched, all contents are copied. So, you can just specify `foo` to copy `foo` directory.
Remember that default pattern `\*\*\/\*` is not added to your custom, so, you have to add it explicitly — e.g. `["\*\*\/\*", "!ignoreMe${/\*}"]`.
May be specified in the platform options (e.g. in the `build.osx`).
*/
readonly extraResources?: Array<string> | null
readonly files?: Array<string> | string | null

/**
The same as [extraResources](#BuildMetadata-extraResources) but copy into the app's content directory (`Contents` for OS X, `` for Linux/Windows).
A [glob patterns](https://www.npmjs.com/package/glob#glob-primer) relative to the project directory, when specified, copy the file or directory with matching names directly into the app's resources directory (`Contents/Resources` for OS X, `resources` for Linux/Windows).
Glob rules the same as for [files](#BuildMetadata-files).
*/
readonly extraFiles?: Array<string> | null
readonly extraResources?: Array<string> | string | null

/**
The same as [extraResources](#BuildMetadata-extraResources) but copy into the app's content directory (`Contents` for OS X, root directory for Linux/Windows).
*/
readonly extraFiles?: Array<string> | string | null

/*
See [.build.osx](#OsXBuildOptions).
Expand Down Expand Up @@ -157,7 +165,15 @@ export interface BuildMetadata {
readonly afterPack?: (context: AfterPackContext) => Promise<any> | null

/*
Whether to rebuild native dependencies (`npm rebuild`) before starting to package the app. Defaults to `true`.
Whether to [prune](https://docs.npmjs.com/cli/prune) native dependencies (`npm prune --production`) before starting to package the app.
Defaults to `true` if [two package.json structure](https://github.com/electron-userland/electron-builder#two-packagejson-structure) is not used.
*/
readonly npmPrune?: boolean
// deprecated
readonly prune?: boolean

/*
Whether to [rebuild](https://docs.npmjs.com/cli/rebuild) native dependencies (`npm rebuild`) before starting to package the app. Defaults to `true`.
*/
readonly npmRebuild?: boolean
}
Expand Down Expand Up @@ -346,6 +362,7 @@ export interface MetadataDirectories {
}

export interface PlatformSpecificBuildOptions {
readonly files?: Array<string> | null
readonly extraFiles?: Array<string> | null
readonly extraResources?: Array<string> | null

Expand Down
Loading

0 comments on commit 0f7624d

Please sign in to comment.