Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Development dependencies are never copied #477

Merged
merged 4 commits into from
Jun 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

2 changes: 1 addition & 1 deletion .idea/runConfigurations/BuildTest.xml

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

4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
osx_image: xcode7
osx_image: xcode7.3

matrix:
include:
Expand All @@ -13,7 +13,6 @@ language: c
cache:
directories:
- node_modules
- test/testApp/node_modules
- $HOME/.electron
- $HOME/.cache/fpm

Expand All @@ -23,6 +22,7 @@ before_install:

install:
- nvm install $NODE_VERSION
- nvm use --delete-prefix $NODE_VERSION
- if [[ "$TRAVIS_OS_NAME" == "osx" && "$NODE_VERSION" == "4" ]]; then npm install npm -g ; fi
- npm install
- npm prune
Expand Down
34 changes: 27 additions & 7 deletions docs/Options.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ 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).</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 (i.e. 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>Development dependencies are never copied in any case. You don’t need to ignore it explicitly.</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. 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`.

<a name="OsXBuildOptions"></a>
### `.build.osx`
Expand Down Expand Up @@ -107,16 +107,36 @@ MAS (Mac Application Store) specific options (in addition to `build.osx`).
| synopsis | <a name="LinuxBuildOptions-synopsis"></a>*deb-only.* The [short description](https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Description).
| maintainer | <a name="LinuxBuildOptions-maintainer"></a>The maintainer. Defaults to [author](#AppMetadata-author).
| vendor | <a name="LinuxBuildOptions-vendor"></a>The vendor. Defaults to [author](#AppMetadata-author).
| compression | <a name="LinuxBuildOptions-compression"></a>*deb-only.* The compression type, one of `gz`, `bzip2`, `xz` (default: `xz`).
| compression | <a name="LinuxBuildOptions-compression"></a>*deb-only.* The compression type, one of `gz`, `bzip2`, `xz`. Defaults to `xz`.
| depends | <a name="LinuxBuildOptions-depends"></a>Package dependencies. Defaults to `["libappindicator1", "libnotify-bin"]`.
| target | <a name="LinuxBuildOptions-target"></a><p>Target package type: list of <code>default</code>, <code>deb</code>, <code>rpm</code>, <code>freebsd</code>, <code>pacman</code>, <code>p5p</code>, <code>apk</code>, <code>7z</code>, <code>zip</code>, <code>tar.xz</code>, <code>tar.lz</code>, <code>tar.gz</code>, <code>tar.bz2</code>. Defaults to <code>default</code> (<code>deb</code>).</p> <p>Only <code>deb</code> is tested. Feel free to file issues for <code>rpm</code> and other package formats.</p>

<a name="MetadataDirectories"></a>
## `.directories`
| Name | Description
| --- | ---
| buildResources | <a name="MetadataDirectories-buildResources"></a>The path to build resources, default `build`.
| output | <a name="MetadataDirectories-output"></a>The output directory, default `dist`.
| app | <a name="MetadataDirectories-app"></a>The application directory (containing the application package.json), default `app`, `www` or working directory.
| buildResources | <a name="MetadataDirectories-buildResources"></a>The path to build resources, defaults to `build`.
| output | <a name="MetadataDirectories-output"></a>The output directory, defaults to `dist`.
| app | <a name="MetadataDirectories-app"></a>The application directory (containing the application package.json), defaults to `app`, `www` or working directory.

<!-- end of generated block -->


# Multiple Glob Patterns
```js
[
// match all files
"**/*",

// except for js files in the foo/ directory
"!foo/*.js",

// 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${/*}`.
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,19 @@
"asar": "^0.11.0",
"bluebird": "^3.4.0",
"chalk": "^1.1.3",
"compare-versions": "^2.0.1",
"compare-versions": "^2.0.2",
"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",
"lodash.template": "^4.2.5",
"mime": "^1.3.4",
"minimatch": "^3.0.0",
"progress": "^1.1.8",
"progress-stream": "^1.2.0",
"read-package-json": "^2.0.4",
Expand Down Expand Up @@ -106,10 +107,10 @@
"pre-git": "^3.8.4",
"semantic-release": "^6.3.0",
"should": "^9.0.0",
"ts-babel": "^0.8.6",
"ts-babel": "^1.0.2",
"tsconfig-glob": "^0.4.3",
"tslint": "3.10.0-dev.2",
"typescript": "1.9.0-dev.20160520-1.0",
"typescript": "1.9.0-dev.20160607-1.0",
"whitespace": "^2.0.0"
},
"babel": {
Expand Down
55 changes: 0 additions & 55 deletions src/globby.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ export { Packager } from "./packager"
export { PackagerOptions, ArtifactCreated, DIR_TARGET, BuildInfo } from "./platformPackager"
export { BuildOptions, build, createPublisher, CliOptions, createTargets } from "./builder"
export { PublishOptions, Publisher } from "./gitHubPublisher"
export { AppMetadata, DevMetadata, Platform, Arch, archFromString, getProductName, BuildMetadata, OsXBuildOptions, WinBuildOptions, LinuxBuildOptions } from "./metadata"
export { AppMetadata, DevMetadata, Platform, Arch, archFromString, getProductName, BuildMetadata, OsXBuildOptions, WinBuildOptions, LinuxBuildOptions, CompressionLevel } from "./metadata"
4 changes: 2 additions & 2 deletions src/linuxPackager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class LinuxPackager extends PlatformPackager<LinuxBuildOptions> {
}
}

protected get supportedTargets(): Array<string> {
get supportedTargets(): Array<string> {
return ["deb", "rpm", "sh", "freebsd", "pacman", "apk", "p5p"]
}

Expand All @@ -66,7 +66,7 @@ export class LinuxPackager extends PlatformPackager<LinuxBuildOptions> {

promises.push(this.computeDesktop(tempDir))

return [].concat(...await BluebirdPromise.all(promises))
return Array.prototype.concat.apply([], await BluebirdPromise.all(promises))
}

async pack(outDir: string, arch: Arch, targets: Array<string>, postAsyncTasks: Array<Promise<any>>): Promise<any> {
Expand Down
61 changes: 41 additions & 20 deletions src/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ export interface AuthorMetadata {
readonly email: string
}

export type CompressionLevel = "store" | "normal" | "maximum"

/*
## `.build`
*/
Expand Down Expand Up @@ -108,20 +110,30 @@ 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).
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)).

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

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 `foo` directory.

If directory matched, all contents are copied. So, you can just specify `foo` to copy `<project_dir>/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 (i.e. in the `build.osx`).
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 All @@ -146,7 +158,7 @@ export interface BuildMetadata {
/*
The compression level, one of `store`, `normal`, `maximum` (default: `normal`). If you want to rapidly test build, `store` can reduce build time significantly.
*/
readonly compression?: "store" | "normal" | "maximum" | null
readonly compression?: CompressionLevel | null

readonly "build-version"?: string | null

Expand All @@ -155,8 +167,16 @@ export interface BuildMetadata {
*/
readonly afterPack?: (context: AfterPackContext) => Promise<any> | null

// /*
// Whether to [prune](https://docs.npmjs.com/cli/prune) dependencies (`npm prune --production`) before starting to package the app.
// Defaults to `false`.
// */
// readonly npmPrune?: boolean
// deprecated
// readonly prune?: boolean

/*
Whether to rebuild native dependencies (`npm rebuild`) before starting to package the app. Defaults to `true`.
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 @@ -307,7 +327,7 @@ export interface LinuxBuildOptions extends PlatformSpecificBuildOptions {
afterRemove?: string | null

/*
*deb-only.* The compression type, one of `gz`, `bzip2`, `xz` (default: `xz`).
*deb-only.* The compression type, one of `gz`, `bzip2`, `xz`. Defaults to `xz`.
*/
readonly compression?: string | null

Expand All @@ -329,22 +349,23 @@ export interface LinuxBuildOptions extends PlatformSpecificBuildOptions {
*/
export interface MetadataDirectories {
/*
The path to build resources, default `build`.
The path to build resources, defaults to `build`.
*/
readonly buildResources?: string | null

/*
The output directory, default `dist`.
The output directory, defaults to `dist`.
*/
readonly output?: string | null

/*
The application directory (containing the application package.json), default `app`, `www` or working directory.
The application directory (containing the application package.json), defaults to `app`, `www` or working directory.
*/
readonly app?: string | null
}

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

Expand All @@ -354,9 +375,9 @@ export interface PlatformSpecificBuildOptions {
}

export class Platform {
public static OSX = new Platform("osx", "osx", "darwin")
public static LINUX = new Platform("linux", "linux", "linux")
public static WINDOWS = new Platform("windows", "win", "win32")
static OSX = new Platform("osx", "osx", "darwin")
static LINUX = new Platform("linux", "linux", "linux")
static WINDOWS = new Platform("windows", "win", "win32")

constructor(public name: string, public buildConfigurationKey: string, public nodeName: string) {
}
Expand All @@ -369,19 +390,19 @@ export class Platform {
return this.name
}

public createTarget(type?: string | null, ...archs: Array<Arch>): Map<Platform, Map<Arch, Array<string>>> {
createTarget(type?: string | Array<string> | null, ...archs: Array<Arch>): Map<Platform, Map<Arch, Array<string>>> {
const archToType = new Map()
for (let arch of (archs == null || archs.length === 0 ? [archFromString(process.arch)] : archs)) {
archToType.set(arch, type == null ? [] : [type])
archToType.set(arch, type == null ? [] : (Array.isArray(type) ? type : [type]))
}
return new Map([[this, archToType]])
}

public static current(): Platform {
static current(): Platform {
return Platform.fromString(process.platform)
}

public static fromString(name: string): Platform {
static fromString(name: string): Platform {
switch (name) {
case Platform.OSX.nodeName:
case Platform.OSX.name:
Expand Down
Loading