Skip to content

Commit

Permalink
docs: Docker
Browse files Browse the repository at this point in the history
and fix notifier text (to not install globally)
  • Loading branch information
develar committed Jun 28, 2016
1 parent 00e8da8 commit 01abc3a
Show file tree
Hide file tree
Showing 16 changed files with 177 additions and 35 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.

6 changes: 5 additions & 1 deletion .idea/runConfigurations/CodeSignTest.xml

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

2 changes: 1 addition & 1 deletion docker/4/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM electronuserland/electron-builder:base

ENV NODE_VERSION 4.4.5
ENV NODE_VERSION 4.4.6

# https://github.com/npm/npm/issues/4531
RUN curl -SLO "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-x64.tar.xz" \
Expand Down
2 changes: 1 addition & 1 deletion docker/base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,4 @@ ENV BUNDLE_PATH="$GEM_HOME" \
ENV PATH $BUNDLE_BIN:$PATH
RUN mkdir -p "$GEM_HOME" "$BUNDLE_BIN" \
&& chmod 777 "$GEM_HOME" "$BUNDLE_BIN" \
&& mkdir -p /tmp/fpm && curl -L https://github.com/jordansissel/fpm/archive/5719990e1bbc3deeaea8a196d6aaa51421a058bd.tar.gz | tar -xz -C /tmp/fpm --strip-components 1 && cd /tmp/fpm && bundle install && make install && cd .. && rm -rf /tmp/fpm
&& mkdir -p /tmp/fpm && curl -L https://github.com/jordansissel/fpm/archive/103602c83215c0f7d18e32316268a3db38de5cc0.tar.gz | tar -xz -C /tmp/fpm --strip-components 1 && cd /tmp/fpm && bundle install && make install && cd .. && rm -rf /tmp/fpm
20 changes: 1 addition & 19 deletions docker/readme.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,4 @@
# Development machine

To build Linux:
```sh
docker run --rm -ti -v `pwd`:/project -v `pwd`/node_modules/.linux:/project/node_modules -v ~/.electron:/root/.electron electronuserland/electron-builder
```

To build windows:
```sh
docker run --rm -ti -v ${PWD}:/project -v ${PWD##*/}-node-modules:/project/node_modules -v ~/.electron:/root/.electron electronuserland/electron-builder:wine
```

Consider using `/test.sh` to install npm dependencies and run tests.

# CI Server

```sh
docker run --rm -v ${PWD}:/project -v ~/.electron:/root/.electron electronuserland/electron-builder:wine /test.sh
```
It is developer documentation. See [user documentation](https://github.com/electron-userland/electron-builder/wiki/docker).

# Build

Expand Down
15 changes: 15 additions & 0 deletions docs/Docker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
To build Linux or Windows (only if you don't have native dependencies) on any platform:

1. Run docker container:
```sh
docker run --rm -ti -v ${PWD}:/project -v ${PWD##*/}-node-modules:/project/node_modules -v ~/.electron:/root/.electron electronuserland/electron-builder:wine
```
2. Type in `npm install && npm prune && npm run dist`

If you don't have `dist` npm script in your `package.json`, call `./node_modules/.bin/build` directly.
Or to avoid second step, append to first command `/bin/bash -c "npm install && npm prune && npm run dist"`
If you don't need to build Windows, use image `electronuserland/electron-builder:latest` (wine is not installed in this image).

You can use `/test.sh` to install npm dependencies and run tests.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@
]
},
"devDependencies": {
"@types/chalk": "^0.4.22-alpha",
"@types/debug": "0.0.22-alpha",
"@types/mime": "0.0.22-alpha",
"@types/progress": "^1.1.21-alpha",
Expand Down
14 changes: 8 additions & 6 deletions src/build-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,22 @@ import { printErrorAndExit } from "./util/promise"
import { createYargs } from "./cliOptions"
import { readJson } from "fs-extra-p"
import * as path from "path"
import { dim, reset, green, cyan } from "chalk"

import updateNotifier = require("update-notifier")
import { warn } from "./util/log"

if (process.env.CI == null && process.env.NO_UPDATE_NOTIFIER == null) {
readJson(path.join(__dirname, "..", "package.json"))
.then(it => {
updateNotifier({
pkg: it
}).notify()
})
.catch(e => {
warn(`Cannot check updates: ${e}`)
const notifier = updateNotifier({pkg: it})
if (notifier.update != null) {
notifier.notify({
message: `Update available ${dim(notifier.update.current)}${reset(" → ")}${green(notifier.update.latest)} \nRun ${cyan("npm i electron-builder")} to update`
})
}
})
.catch(e => warn(`Cannot check updates: ${e}`))
}

build(<CliOptions>(createYargs().argv))
Expand Down
1 change: 1 addition & 0 deletions src/codeSign.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ export async function findIdentity(namePrefix: CertType, qualifier?: string): Pr
.then(it => it.trim().split(("\n"))),
])
.then(it => {
//noinspection SpellCheckingInspection
const array = it[0].concat(it[1])
.filter(it => !it.includes("(Missing required extension)") && !it.includes("valid identities found") && !it.includes("iPhone ") && !it.includes("com.apple.idms.appleid.prd."))
// remove 1)
Expand Down
11 changes: 9 additions & 2 deletions src/util/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { yellow, red } from "chalk"
import debugFactory = require("debug")
import IDebugger = debug.IDebugger
import { warn, task } from "./log"
import { createHash } from "crypto"

//noinspection JSUnusedLocalSymbols
const __awaiter = require("./awaiter")
Expand Down Expand Up @@ -64,9 +65,15 @@ export interface ExecOptions extends BaseExecOptions {
killSignal?: string
}

export function removePassword(input: string): string {
return input.replace(/(-P |pass:)([^ ]+)/, function (match, p1, p2) {
return `${p1}${createHash('sha256').update(p2).digest('hex')} (sha256 hash)`
})
}

export function exec(file: string, args?: Array<string> | null, options?: ExecOptions): BluebirdPromise<string> {
if (debug.enabled) {
debug(`Executing ${file} ${args == null ? "" : args.join(" ")}`)
debug(removePassword(`Executing ${file} ${args == null ? "" : args.join(" ")}`))
}

return new BluebirdPromise<string>((resolve, reject) => {
Expand All @@ -75,7 +82,7 @@ export function exec(file: string, args?: Array<string> | null, options?: ExecOp
resolve(stdout)
}
else {
let message = red(error.message)
let message = red(removePassword(error.message))
if (stdout.length !== 0) {
message += `\n${yellow(stdout)}`
}
Expand Down
2 changes: 1 addition & 1 deletion templates/nsis/readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
It is developer documentation. See [wiki](https://github.com/electron-userland/electron-builder/wiki/nsis).
It is developer documentation. See [user documentation](https://github.com/electron-userland/electron-builder/wiki/nsis).

http://www.mathiaswestin.net/2012/09/how-to-make-per-user-installation-with.html

Expand Down
6 changes: 6 additions & 0 deletions test/src/CodeSignTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
CSC_INSTALLER_LINK
} from "./helpers/codeSignData"
import { executeFinally, all } from "out/util/promise"
import { removePassword } from "out/util/util"

//noinspection JSUnusedLocalSymbols
const __awaiter = require("out/util/awaiter")
Expand All @@ -28,4 +29,9 @@ test.ifOsx("create keychain with installers", async () => {
assertThat(result.keychainName).not.empty()
assertThat(result.name).equal(CSC_NAME)
}), () => all([deleteKeychain(keychainName)]))
})

test.ifOsx("remove password from log", async () => {
assertThat(removePassword("seq -P foo -B")).equal("seq -P 2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae (sha256 hash) -B")
assertThat(removePassword("pass:foo")).equal("pass:2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae (sha256 hash)")
})
2 changes: 1 addition & 1 deletion test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"../typings/ansi-escapes.d.ts",
"../typings/appdmg.d.ts",
"../typings/asar.d.ts",
"../typings/chalk.d.ts",
"../typings/deep-assign.d.ts",
"../typings/electron-packager.d.ts",
"../typings/electron-winstaller-fixed.d.ts",
Expand All @@ -56,7 +57,6 @@
"../node_modules/fs-extra-p/bluebird.d.ts",
"out/electron-builder.d.ts",
"../node_modules/electron-osx-sign-tf/index.d.ts",
"../node_modules/@types/chalk/index.d.ts",
"../node_modules/@types/debug/index.d.ts",
"../node_modules/@types/mime/index.d.ts",
"../node_modules/@types/node/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"typings/ansi-escapes.d.ts",
"typings/appdmg.d.ts",
"typings/asar.d.ts",
"typings/chalk.d.ts",
"typings/deep-assign.d.ts",
"typings/electron-packager.d.ts",
"typings/electron-winstaller-fixed.d.ts",
Expand All @@ -57,7 +58,6 @@
"node_modules/7zip-bin/index.d.ts",
"node_modules/fs-extra-p/bluebird.d.ts",
"node_modules/electron-osx-sign-tf/index.d.ts",
"node_modules/@types/chalk/index.d.ts",
"node_modules/@types/debug/index.d.ts",
"node_modules/@types/mime/index.d.ts",
"node_modules/@types/node/index.d.ts",
Expand Down
123 changes: 123 additions & 0 deletions typings/chalk.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
// Type definitions for chalk v0.4.0
// Project: https://github.com/sindresorhus/chalk
// Definitions by: Diullei Gomes <https://github.com/Diullei>, Bart van der Schoor <https://github.com/Bartvds>, Nico Jansen <https://github.com/nicojs>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

declare namespace Chalk {

export var enabled: boolean;
export var supportsColor: boolean;
export var styles: ChalkStyleMap;

export function stripColor(value: string): any;
export function hasColor(str: string): boolean;

export interface ChalkChain extends ChalkStyle {
(...text: string[]): string;
}

export interface ChalkStyleElement {
open: string;
close: string;
}

// General
export var reset: ChalkChain;
export var bold: ChalkChain;
export var italic: ChalkChain;
export var underline: ChalkChain;
export var inverse: ChalkChain;
export var strikethrough: ChalkChain;
export var dim: ChalkChain;

// Text colors
export var black: ChalkChain;
export var red: ChalkChain;
export var green: ChalkChain;
export var yellow: ChalkChain;
export var blue: ChalkChain;
export var magenta: ChalkChain;
export var cyan: ChalkChain;
export var white: ChalkChain;
export var gray: ChalkChain;
export var grey: ChalkChain;

// Background colors
export var bgBlack: ChalkChain;
export var bgRed: ChalkChain;
export var bgGreen: ChalkChain;
export var bgYellow: ChalkChain;
export var bgBlue: ChalkChain;
export var bgMagenta: ChalkChain;
export var bgCyan: ChalkChain;
export var bgWhite: ChalkChain;


export interface ChalkStyle {
// General
reset: ChalkChain;
bold: ChalkChain;
italic: ChalkChain;
underline: ChalkChain;
inverse: ChalkChain;
strikethrough: ChalkChain;

// Text colors
black: ChalkChain;
red: ChalkChain;
green: ChalkChain;
yellow: ChalkChain;
blue: ChalkChain;
magenta: ChalkChain;
cyan: ChalkChain;
white: ChalkChain;
gray: ChalkChain;
grey: ChalkChain;

// Background colors
bgBlack: ChalkChain;
bgRed: ChalkChain;
bgGreen: ChalkChain;
bgYellow: ChalkChain;
bgBlue: ChalkChain;
bgMagenta: ChalkChain;
bgCyan: ChalkChain;
bgWhite: ChalkChain;
}

export interface ChalkStyleMap {
// General
reset: ChalkStyleElement;
bold: ChalkStyleElement;
italic: ChalkStyleElement;
underline: ChalkStyleElement;
inverse: ChalkStyleElement;
strikethrough: ChalkStyleElement;

// Text colors
black: ChalkStyleElement;
red: ChalkStyleElement;
green: ChalkStyleElement;
yellow: ChalkStyleElement;
blue: ChalkStyleElement;
magenta: ChalkStyleElement;
cyan: ChalkStyleElement;
white: ChalkStyleElement;
gray: ChalkStyleElement;

// Background colors
bgBlack: ChalkStyleElement;
bgRed: ChalkStyleElement;
bgGreen: ChalkStyleElement;
bgYellow: ChalkStyleElement;
bgBlue: ChalkStyleElement;
bgMagenta: ChalkStyleElement;
bgCyan: ChalkStyleElement;
bgWhite: ChalkStyleElement;
}
}

declare module "chalk" {
export = Chalk;
}

4 changes: 3 additions & 1 deletion typings/updateNotifier.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ declare module "update-notifier" {
}

interface Notifier {
notify(): void
notify(options: any): void

update: any
}

function updateNotifier(options: NotifyOptions): Notifier
Expand Down

0 comments on commit 01abc3a

Please sign in to comment.