Skip to content

Commit

Permalink
feat: Advanced file copying supported for "files"
Browse files Browse the repository at this point in the history
Close #1096
  • Loading branch information
develar committed Jul 9, 2017
1 parent 217fc0e commit 2316381
Show file tree
Hide file tree
Showing 24 changed files with 400 additions and 314 deletions.
2 changes: 1 addition & 1 deletion docs/Auto Update.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ Emitted on progress. Only supported over Windows build, since `Squirrel.Mac` [do
* <a name="FileInfo-url"></a>**`url`** String
* <a name="FileInfo-sha2"></a>`sha2` String
* <a name="FileInfo-sha512"></a>`sha512` String
* <a name="FileInfo-headers"></a>`headers` Object
* <a name="FileInfo-headers"></a>`headers` [RequestHeaders](electron-builder-http#RequestHeaders)

<a name="Logger"></a>
### `Logger`
Expand Down
14 changes: 6 additions & 8 deletions docs/Options.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,18 +115,15 @@ Configuration Options
Please note — build resources is not packed into app. If you need to use some files, e.g. as tray icon, please include required files explicitly: `"files": ["**/*", "build/icon.*"]`
* <a name="MetadataDirectories-output"></a>`output` = `dist` String - The output directory.
* <a name="MetadataDirectories-app"></a>`app` String - The application directory (containing the application package.json), defaults to `app`, `www` or working directory.
* <a name="Config-files"></a>`files` Array&lt;String&gt; | String - A [glob patterns](#file-patterns) relative to the [app directory](#MetadataDirectories-app), which specifies which files to include when copying files to create the package.
* <a name="Config-files"></a>`files` Array&lt;String | [FilePattern](#FilePattern)&gt; | [FilePattern](#FilePattern) | String<a name="FilePattern"></a> - A [glob patterns](#file-patterns) relative to the [app directory](#MetadataDirectories-app), which specifies which files to include when copying files to create the package.

Development dependencies are never copied in any case. You don't need to ignore it explicitly.

Default pattern `**/*` **is not added to your custom** if some of your patterns is not ignore (i.e. not starts with `!`). `package.json` and `**/node_modules/**/*` (only production dependencies will be copied) is added to your custom in any case. All [default ignores](#default-file-pattern) are added in any case — you don't need to repeat it if you configure own patterns.

May be specified in the platform options (e.g. in the [mac](#MacOptions)).
* <a name="Config-extraResources"></a>`extraResources` Array&lt;String | [FilePattern](#FilePattern)&gt; | [FilePattern](#FilePattern) | String<a name="FilePattern"></a> - A [glob patterns](#file-patterns) 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 MacOS, `resources` for Linux/Windows).

Glob rules the same as for [files](#multiple-glob-patterns).

You may also specify custom source and destination directories by using JSON objects instead of simple glob patterns. Note this only works for [extraFiles](#Config-extraFiles) and [extraResources](#Config-extraResources).
You may also specify custom source and destination directories by using JSON objects instead of simple glob patterns.

```json
[
Expand All @@ -138,12 +135,13 @@ Configuration Options
]
```

`from` and `to` can be files and you can use this to [rename](https://github.com/electron-userland/electron-builder/issues/1119) a file while packaging.

You can use [file macros](#file-macros) in the `from` and `to` fields as well.
You can use [file macros](#file-macros) in the `from` and `to` fields as well. `from` and `to` can be files and you can use this to [rename](https://github.com/electron-userland/electron-builder/issues/1119) a file while packaging.
* <a name="FilePattern-from"></a>`from` String - The source path relative to the project directory.
* <a name="FilePattern-to"></a>`to` String - The destination path relative to the app's content directory for `extraFiles` and the app's resource directory for `extraResources`.
* <a name="FilePattern-filter"></a>`filter` Array&lt;String&gt; | String - The [glob patterns](#file-patterns).
* <a name="Config-extraResources"></a>`extraResources` Array&lt;String | [FilePattern](#FilePattern)&gt; | [FilePattern](#FilePattern) | String - A [glob patterns](#file-patterns) 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 MacOS, `resources` for Linux/Windows).

File patterns (and support for `from` and `to` fields) the same as for [files](#multiple-glob-patterns).
* <a name="Config-extraFiles"></a>`extraFiles` Array&lt;String | [FilePattern](#FilePattern)&gt; | [FilePattern](#FilePattern) | String - The same as [extraResources](#Config-extraResources) but copy into the app's content directory (`Contents` for MacOS, root directory for Linux/Windows).
* <a name="Config-fileAssociations"></a>`fileAssociations` Array&lt;[FileAssociation](#FileAssociation)&gt; | [FileAssociation](#FileAssociation)<a name="FileAssociation"></a> - The file associations.
* <a name="FileAssociation-ext"></a>**`ext`** String | Array&lt;String&gt; - The extension (minus the leading period). e.g. `png`.
Expand Down
8 changes: 4 additions & 4 deletions docs/api/electron-builder-http.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@

| Param | Type |
| --- | --- |
| callback | <code>function</code> |
| callback | <code>any</code> |

<a name="module_electron-builder-http.DigestTransform+_transform"></a>
#### `digestTransform._transform(chunk, encoding, callback)`
Expand All @@ -260,7 +260,7 @@
| --- | --- |
| chunk | <code>any</code> |
| encoding | <code>String</code> |
| callback | <code>function</code> |
| callback | <code>any</code> |

<a name="HttpError"></a>
### HttpError ⇐ <code>Error</code>
Expand Down Expand Up @@ -303,7 +303,7 @@

| Param | Type |
| --- | --- |
| callback | <code>function</code> |
| callback | <code>any</code> |

<a name="module_electron-builder-http.ProgressCallbackTransform+_transform"></a>
#### `progressCallbackTransform._transform(chunk, encoding, callback)`
Expand All @@ -313,7 +313,7 @@
| --- | --- |
| chunk | <code>any</code> |
| encoding | <code>String</code> |
| callback | <code>function</code> |
| callback | <code>any</code> |

<a name="module_electron-builder-http.configureRequestOptions"></a>
### `electron-builder-http.configureRequestOptions(options, token, method)` ⇒ <code>module:http.RequestOptions</code>
Expand Down
103 changes: 52 additions & 51 deletions docs/api/electron-builder.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,16 @@
<dd></dd>
<dt><a href="#module_electron-builder/out/publish/PublishManager">electron-builder/out/publish/PublishManager</a></dt>
<dd></dd>
<dt><a href="#module_electron-builder/out/util/asarUtil">electron-builder/out/util/asarUtil</a></dt>
<dd></dd>
<dt><a href="#module_electron-builder/out/util/flags">electron-builder/out/util/flags</a></dt>
<dd></dd>
<dt><a href="#module_electron-builder/out/util/packageDependencies">electron-builder/out/util/packageDependencies</a></dt>
<dd></dd>
<dt><a href="#module_electron-builder/out/util/timer">electron-builder/out/util/timer</a></dt>
<dd></dd>
<dt><a href="#module_electron-builder/out/util/yarn">electron-builder/out/util/yarn</a></dt>
<dd></dd>
<dt><a href="#module_electron-builder/out/windowsCodeSign">electron-builder/out/windowsCodeSign</a></dt>
<dd></dd>
</dl>
Expand All @@ -30,16 +36,13 @@
* [electron-builder](#module_electron-builder)
* [`.AfterPackContext`](#AfterPackContext)
* [`.ArtifactCreated`](#ArtifactCreated)
* [`.BuildInfo`](#BuildInfo)
* [`.afterPack(context)`](#module_electron-builder.BuildInfo+afterPack) ⇒ <code>Promise&lt;void&gt;</code>
* [`.dispatchArtifactCreated(event)`](#module_electron-builder.BuildInfo+dispatchArtifactCreated)
* [`.BuildResult`](#BuildResult)
* [`.CommonLinuxOptions`](#CommonLinuxOptions)
* [`.CommonNsisOptions`](#CommonNsisOptions)
* [`.ForgeOptions`](#ForgeOptions)
* [`.LinuxTargetSpecificOptions`](#LinuxTargetSpecificOptions) ⇐ <code>[CommonLinuxOptions](#CommonLinuxOptions)</code>
* [`.PlatformSpecificBuildOptions`](#PlatformSpecificBuildOptions) ⇐ <code>[TargetSpecificOptions](#TargetSpecificOptions)</code>
* [.Packager](#Packager) ⇐ <code>[BuildInfo](#BuildInfo)</code>
* [.Packager](#Packager)
* [`.addAfterPackHandler(handler)`](#module_electron-builder.Packager+addAfterPackHandler)
* [`.afterPack(context)`](#module_electron-builder.Packager+afterPack) ⇒ <code>Promise&lt;void&gt;</code>
* [`.artifactCreated(handler)`](#module_electron-builder.Packager+artifactCreated) ⇒ <code>[Packager](#Packager)</code>
Expand Down Expand Up @@ -89,46 +92,6 @@
| safeArtifactName| <code>String</code> |
| publishConfig| <code>[PublishConfiguration](Publishing-Artifacts#PublishConfiguration)</code> |

<a name="BuildInfo"></a>
### `BuildInfo`
**Kind**: interface of [<code>electron-builder</code>](Options#module_electron-builder)
**Properties**

| Name | Type |
| --- | --- |
| **options**| <code>[PackagerOptions](Options#PackagerOptions)</code> |
| **metadata**| <code>[Metadata](Options#Metadata)</code> |
| **config**| <code>[Config](Options#Config)</code> |
| **projectDir**| <code>String</code> |
| **appDir**| <code>String</code> |
| **isTwoPackageJsonProjectLayoutUsed**| <code>Boolean</code> |
| **appInfo**| <code>[AppInfo](#AppInfo)</code> |
| **tempDirManager**| <code>module:electron-builder-util/out/tmp.TmpDir</code> |
| **repositoryInfo**| <code>Promise&lt; \| [SourceRepositoryInfo](#SourceRepositoryInfo)&gt;</code> |
| **isPrepackedAppAsar**| <code>Boolean</code> |
| **cancellationToken**| <code>[CancellationToken](electron-builder-http#CancellationToken)</code> |


* [`.BuildInfo`](#BuildInfo)
* [`.afterPack(context)`](#module_electron-builder.BuildInfo+afterPack) ⇒ <code>Promise&lt;void&gt;</code>
* [`.dispatchArtifactCreated(event)`](#module_electron-builder.BuildInfo+dispatchArtifactCreated)

<a name="module_electron-builder.BuildInfo+afterPack"></a>
#### `buildInfo.afterPack(context)` ⇒ <code>Promise&lt;void&gt;</code>
**Kind**: instance method of [<code>BuildInfo</code>](#BuildInfo)

| Param | Type |
| --- | --- |
| context | <code>[AfterPackContext](#AfterPackContext)</code> |

<a name="module_electron-builder.BuildInfo+dispatchArtifactCreated"></a>
#### `buildInfo.dispatchArtifactCreated(event)`
**Kind**: instance method of [<code>BuildInfo</code>](#BuildInfo)

| Param | Type |
| --- | --- |
| event | <code>[ArtifactCreated](#ArtifactCreated)</code> |

<a name="BuildResult"></a>
### `BuildResult`
**Kind**: interface of [<code>electron-builder</code>](Options#module_electron-builder)
Expand Down Expand Up @@ -195,7 +158,7 @@

| Name | Type |
| --- | --- |
| files| <code>Array&lt;String&gt;</code> \| <code>String</code> \| <code>null</code> |
| files| <code>Array&lt;String \| [FilePattern](Options#FilePattern)&gt;</code> \| <code>[FilePattern](Options#FilePattern)</code> \| <code>String</code> \| <code>null</code> |
| extraFiles| <code>Array&lt;String \| [FilePattern](Options#FilePattern)&gt;</code> \| <code>[FilePattern](Options#FilePattern)</code> \| <code>String</code> \| <code>null</code> |
| extraResources| <code>Array&lt;String \| [FilePattern](Options#FilePattern)&gt;</code> \| <code>[FilePattern](Options#FilePattern)</code> \| <code>String</code> \| <code>null</code> |
| asarUnpack| <code>Array&lt;String&gt;</code> \| <code>String</code> \| <code>null</code> |
Expand All @@ -206,9 +169,8 @@
| forceCodeSigning| <code>Boolean</code> |

<a name="Packager"></a>
### Packager ⇐ <code>[BuildInfo](#BuildInfo)</code>
### Packager
**Kind**: class of [<code>electron-builder</code>](Options#module_electron-builder)
**Extends**: <code>[BuildInfo](#BuildInfo)</code>
**Properties**

| Name | Type |
Expand All @@ -224,9 +186,10 @@
| tempDirManager = <code>new TmpDir()</code>| <code>module:electron-builder-util/out/tmp.TmpDir</code> |
| options| <code>[PackagerOptions](Options#PackagerOptions)</code> |
| **repositoryInfo**| <code>Promise&lt; \| [SourceRepositoryInfo](#SourceRepositoryInfo)&gt;</code> |
| **productionDeps**| <code>[Lazy](electron-builder-http#Lazy)&lt;Array&lt;module:electron-builder/out/util/packageDependencies.Dependency&gt;&gt;</code> |


* [.Packager](#Packager) ⇐ <code>[BuildInfo](#BuildInfo)</code>
* [.Packager](#Packager)
* [`.addAfterPackHandler(handler)`](#module_electron-builder.Packager+addAfterPackHandler)
* [`.afterPack(context)`](#module_electron-builder.Packager+afterPack) ⇒ <code>Promise&lt;void&gt;</code>
* [`.artifactCreated(handler)`](#module_electron-builder.Packager+artifactCreated) ⇒ <code>[Packager](#Packager)</code>
Expand All @@ -244,7 +207,6 @@
<a name="module_electron-builder.Packager+afterPack"></a>
#### `packager.afterPack(context)` ⇒ <code>Promise&lt;void&gt;</code>
**Kind**: instance method of [<code>Packager</code>](#Packager)
**Overrides**: [<code>afterPack</code>](#module_electron-builder.BuildInfo+afterPack)

| Param | Type |
| --- | --- |
Expand All @@ -264,7 +226,6 @@
<a name="module_electron-builder.Packager+dispatchArtifactCreated"></a>
#### `packager.dispatchArtifactCreated(event)`
**Kind**: instance method of [<code>Packager</code>](#Packager)
**Overrides**: [<code>dispatchArtifactCreated</code>](#module_electron-builder.BuildInfo+dispatchArtifactCreated)

| Param | Type |
| --- | --- |
Expand Down Expand Up @@ -733,7 +694,7 @@

| Name | Type |
| --- | --- |
| progress = <code>(&lt;TtyWriteStream&gt;process.stdout).isTTY ? new MultiProgress() : null</code>| <code>null</code> \| <code>[MultiProgress](electron-publish#MultiProgress)</code> |
| progress = <code>(process.stdout as TtyWriteStream).isTTY ? new MultiProgress() : null</code>| <code>null</code> \| <code>[MultiProgress](electron-publish#MultiProgress)</code> |


* [.PublishManager](#PublishManager) ⇐ <code>[PublishContext](electron-publish#PublishContext)</code>
Expand Down Expand Up @@ -787,6 +748,20 @@
| publishConfigs | <code>Array&lt;[PublishConfiguration](Publishing-Artifacts#PublishConfiguration)&gt;</code> \| <code>null</code> |
| arch | <code>[Arch](#Arch)</code> \| <code>null</code> |

<a name="module_electron-builder/out/util/asarUtil"></a>
## electron-builder/out/util/asarUtil
<a name="module_electron-builder/out/util/asarUtil.copyFileOrData"></a>
### `electron-builder/out/util/asarUtil.copyFileOrData(fileCopier, data, src, destination, stats)` ⇒ <code>Promise&lt;void&gt;</code>
**Kind**: method of [<code>electron-builder/out/util/asarUtil</code>](#module_electron-builder/out/util/asarUtil)

| Param | Type |
| --- | --- |
| fileCopier | <code>module:electron-builder-util/out/fs.FileCopier</code> |
| data | <code>String</code> \| <code>Buffer</code> \| <code>undefined</code> \| <code>null</code> |
| src | <code>String</code> |
| destination | <code>String</code> |
| stats | <code>module:fs.Stats</code> |

<a name="module_electron-builder/out/util/flags"></a>
## electron-builder/out/util/flags

Expand All @@ -808,6 +783,16 @@
<a name="module_electron-builder/out/util/flags.isUseSystemWine"></a>
### `electron-builder/out/util/flags.isUseSystemWine()` ⇒ <code>Boolean</code>
**Kind**: method of [<code>electron-builder/out/util/flags</code>](#module_electron-builder/out/util/flags)
<a name="module_electron-builder/out/util/packageDependencies"></a>
## electron-builder/out/util/packageDependencies
<a name="module_electron-builder/out/util/packageDependencies.createLazyProductionDeps"></a>
### `electron-builder/out/util/packageDependencies.createLazyProductionDeps(projectDir)` ⇒ <code>[Lazy](electron-builder-http#Lazy)&lt;Array&lt;module:electron-builder/out/util/packageDependencies.Dependency&gt;&gt;</code>
**Kind**: method of [<code>electron-builder/out/util/packageDependencies</code>](#module_electron-builder/out/util/packageDependencies)

| Param | Type |
| --- | --- |
| projectDir | <code>String</code> |

<a name="module_electron-builder/out/util/timer"></a>
## electron-builder/out/util/timer

Expand All @@ -830,6 +815,22 @@
| --- | --- |
| label | <code>String</code> |

<a name="module_electron-builder/out/util/yarn"></a>
## electron-builder/out/util/yarn
<a name="RebuildOptions"></a>
### `RebuildOptions`
**Kind**: interface of [<code>electron-builder/out/util/yarn</code>](#module_electron-builder/out/util/yarn)
**Properties**

| Name | Type |
| --- | --- |
| **frameworkInfo**| <code>module:electron-builder/out/util/yarn.DesktopFrameworkInfo</code> |
| productionDeps| <code>[Lazy](electron-builder-http#Lazy)&lt;Array&lt;module:electron-builder/out/util/packageDependencies.Dependency&gt;&gt;</code> |
| platform| <code>String</code> |
| arch| <code>String</code> |
| buildFromSource| <code>Boolean</code> |
| additionalArgs| <code>Array&lt;String&gt;</code> \| <code>null</code> |

<a name="module_electron-builder/out/windowsCodeSign"></a>
## electron-builder/out/windowsCodeSign
<a name="SignOptions"></a>
Expand Down
2 changes: 1 addition & 1 deletion packages/electron-builder-util/src/fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export async function walk(initialDirPath: string, filter?: Filter | null, consu
const dirs: Array<string> = []
// our handler is async, but we should add sorted files, so, we add file to result not in the mapper, but after map
const sortedFilePaths = await BluebirdPromise.map(childNames, name => {
if (name === ".DS_Store") {
if (name === ".DS_Store" || name === ".gitkeep") {
return null
}

Expand Down
Loading

0 comments on commit 2316381

Please sign in to comment.