Skip to content

Commit

Permalink
refactor: move to util
Browse files Browse the repository at this point in the history
  • Loading branch information
develar committed Jun 22, 2016
1 parent a17eb8b commit 7c81164
Show file tree
Hide file tree
Showing 42 changed files with 84 additions and 84 deletions.
2 changes: 1 addition & 1 deletion docs/Options.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ Windows specific build options.

| Name | Description
| --- | ---
| target | <a name="WinBuildOptions-target"></a>Target package type: list of `squirrel`, `7z`, `zip`, `tar.xz`, `tar.lz`, `tar.gz`, `tar.bz2`. Defaults to `squirrel`.
| target | <a name="WinBuildOptions-target"></a>Target package type: list of `squirrel`, `nsis`, `7z`, `zip`, `tar.xz`, `tar.lz`, `tar.gz`, `tar.bz2`. Defaults to `squirrel`.
| iconUrl | <a name="WinBuildOptions-iconUrl"></a><p>*Squirrel.Windows-only.* A URL to an ICO file to use as the application icon (displayed in Control Panel &gt; Programs and Features). Defaults to the Electron icon.</p> <p>Please note — [local icon file url is not accepted](https://github.com/atom/grunt-electron-installer/issues/73), must be https/http.</p> <ul> <li>If you don’t plan to build windows installer, you can omit it.</li> <li>If your project repository is public on GitHub, it will be <code>https://github.com/${u}/${p}/blob/master/build/icon.ico?raw=true</code> by default.</li> </ul>
| loadingGif | <a name="WinBuildOptions-loadingGif"></a><p>*Squirrel.Windows-only.* The path to a .gif file to display during install. <code>build/install-spinner.gif</code> will be used if exists (it is a recommended way to set) (otherwise [default](https://github.com/electron/windows-installer/blob/master/resources/install-spinner.gif)).</p>
| msi | <a name="WinBuildOptions-msi"></a>*Squirrel.Windows-only.* Whether to create an MSI installer. Defaults to `false` (MSI is not created).
Expand Down
6 changes: 3 additions & 3 deletions src/appInfo.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { ElectronPackagerOptions } from "electron-packager-tf"
import { DevMetadata, AppMetadata } from "./metadata"
import { warn } from "./log"
import { warn } from "./util/log"
import { smarten } from "./platformPackager"
import { isEmptyOrSpaces } from "./util"
import { isEmptyOrSpaces } from "./util/util"
import { getRepositoryInfo } from "./repositoryInfo"

//noinspection JSUnusedLocalSymbols
const __awaiter = require("./awaiter")
const __awaiter = require("./util/awaiter")

export class AppInfo {
readonly description = smarten(this.metadata.description)
Expand Down
4 changes: 2 additions & 2 deletions src/asarUtil.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { AsarFileInfo, listPackage, statFile, AsarOptions, AsarFileMetadata, createPackageFromFiles } from "asar"
import { statOrNull } from "./util"
import { statOrNull } from "./util/util"
import { lstat, readdir } from "fs-extra-p"
import { Promise as BluebirdPromise } from "bluebird"
import * as path from "path"
import { Stats } from "fs"
import pathSorter = require("path-sort")

//noinspection JSUnusedLocalSymbols
const __awaiter = require("./awaiter")
const __awaiter = require("./util/awaiter")

const concurrency = {concurrency: 50}

Expand Down
4 changes: 2 additions & 2 deletions src/build-cli.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#! /usr/bin/env node

import { build, CliOptions } from "./builder"
import { printErrorAndExit } from "./promise"
import { printErrorAndExit } from "./util/promise"
import { createYargs } from "./cliOptions"
import { readJson } from "fs-extra-p"
import * as path from "path"

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

if (process.env.CI == null && process.env.NO_UPDATE_NOTIFIER == null) {
readJson(path.join(__dirname, "..", "package.json"))
Expand Down
8 changes: 4 additions & 4 deletions src/builder.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { Packager, normalizePlatforms } from "./packager"
import { PackagerOptions } from "./platformPackager"
import { PublishOptions, Publisher, GitHubPublisher } from "./gitHubPublisher"
import { executeFinally } from "./promise"
import { executeFinally } from "./util/promise"
import { Promise as BluebirdPromise } from "bluebird"
import { isEmptyOrSpaces } from "./util"
import { log, warn } from "./log"
import { isEmptyOrSpaces } from "./util/util"
import { log, warn } from "./util/log"
import { Platform, Arch, archFromString } from "./metadata"
import { getRepositoryInfo } from "./repositoryInfo"

//noinspection JSUnusedLocalSymbols
const __awaiter = require("./awaiter")
const __awaiter = require("./util/awaiter")

export async function createPublisher(packager: Packager, options: PublishOptions, isPublishOptionGuessed: boolean = false): Promise<Publisher | null> {
const info = await getRepositoryInfo(packager.metadata, packager.devMetadata)
Expand Down
2 changes: 1 addition & 1 deletion src/cleanup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Promise as BluebirdPromise } from "bluebird"
import * as path from "path"

//noinspection JSUnusedLocalSymbols
const __awaiter = require("./awaiter")
const __awaiter = require("./util/awaiter")

async function main() {
const dir = path.join(homedir(), ".cache", "fpm")
Expand Down
8 changes: 4 additions & 4 deletions src/codeSign.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { exec, getTempName } from "./util"
import { exec, getTempName } from "./util/util"
import { deleteFile, outputFile, copy, rename } from "fs-extra-p"
import { download } from "./httpRequest"
import { download } from "./util/httpRequest"
import { tmpdir } from "os"
import * as path from "path"
import { executeFinally, all } from "./promise"
import { executeFinally, all } from "./util/promise"
import { Promise as BluebirdPromise } from "bluebird"
import { randomBytes } from "crypto"
import { homedir } from "os"

//noinspection JSUnusedLocalSymbols
const __awaiter = require("./awaiter")
const __awaiter = require("./util/awaiter")

export const appleCertificatePrefixes = ["Developer ID Application:", "3rd Party Mac Developer Application:", "Developer ID Installer:", "3rd Party Mac Developer Installer:"]

Expand Down
6 changes: 3 additions & 3 deletions src/gitHubPublisher.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Release, Asset } from "gh-release"
import { isEmptyOrSpaces } from "./util"
import { log, warn } from "./log"
import { isEmptyOrSpaces } from "./util/util"
import { log, warn } from "./util/log"
import { basename } from "path"
import { parse as parseUrl } from "url"
import * as mime from "mime"
Expand All @@ -13,7 +13,7 @@ import progressStream = require("progress-stream")
import ProgressBar = require("progress")

//noinspection JSUnusedLocalSymbols
const __awaiter = require("./awaiter")
const __awaiter = require("./util/awaiter")

export interface Publisher {
upload(file: string, artifactName?: string): Promise<any>
Expand Down
4 changes: 2 additions & 2 deletions src/gitHubRequest.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import * as https from "https"
import { RequestOptions } from "https"
import { IncomingMessage, ClientRequest } from "http"
import { addTimeOutHandler } from "./httpRequest"
import { addTimeOutHandler } from "./util/httpRequest"
import { Promise as BluebirdPromise } from "bluebird"

const __awaiter = require("./awaiter")
const __awaiter = require("./util/awaiter")
Array.isArray(__awaiter)

export function gitHubRequest<T>(path: string, token: string | null, data: { [name: string]: any; } | null = null, method: string = "GET"): BluebirdPromise<T> {
Expand Down
6 changes: 3 additions & 3 deletions src/install-app-deps.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#! /usr/bin/env node

import { computeDefaultAppDirectory, installDependencies, getElectronVersion, readPackageJson, use } from "./util"
import { printErrorAndExit } from "./promise"
import { computeDefaultAppDirectory, installDependencies, getElectronVersion, readPackageJson, use } from "./util/util"
import { printErrorAndExit } from "./util/promise"
import * as path from "path"
import { Promise as BluebirdPromise } from "bluebird"
import { DevMetadata } from "./metadata"
import yargs = require("yargs")

//noinspection JSUnusedLocalSymbols
const __awaiter = require("./awaiter")
const __awaiter = require("./util/awaiter")

const args: any = yargs
.option("arch", {
Expand Down
2 changes: 1 addition & 1 deletion src/linuxPackager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { FpmTarget } from "./targets/fpm"
import { createCommonTarget, DEFAULT_TARGET } from "./targets/targetFactory"

//noinspection JSUnusedLocalSymbols
const __awaiter = require("./awaiter")
const __awaiter = require("./util/awaiter")

export const installPrefix = "/opt"

Expand Down
6 changes: 3 additions & 3 deletions src/osxPackager.ts → src/macPackager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ import { PlatformPackager, BuildInfo, Target } from "./platformPackager"
import { Platform, MasBuildOptions, Arch, MacOptions } from "./metadata"
import * as path from "path"
import { Promise as BluebirdPromise } from "bluebird"
import { isEmptyOrSpaces } from "./util"
import { log, warn, task } from "./log"
import { isEmptyOrSpaces } from "./util/util"
import { log, warn, task } from "./util/log"
import { createKeychain, deleteKeychain, CodeSigningInfo, generateKeychainName, findIdentity, appleCertificatePrefixes, CertType } from "./codeSign"
import deepAssign = require("deep-assign")
import { signAsync, flatAsync, BaseSignOptions, SignOptions, FlatOptions } from "electron-osx-sign-tf"
import { DmgTarget } from "./targets/dmg"
import { createCommonTarget, DEFAULT_TARGET } from "./targets/targetFactory"

//noinspection JSUnusedLocalSymbols
const __awaiter = require("./awaiter")
const __awaiter = require("./util/awaiter")

export default class MacPackager extends PlatformPackager<MacOptions> {
codeSigningInfo: Promise<CodeSigningInfo | null>
Expand Down
2 changes: 1 addition & 1 deletion src/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ export interface WinBuildOptions extends PlatformSpecificBuildOptions {
readonly certificatePassword?: string

/*
Target package type: list of `squirrel`, `7z`, `zip`, `tar.xz`, `tar.lz`, `tar.gz`, `tar.bz2`. Defaults to `squirrel`.
Target package type: list of `squirrel`, `nsis`, `7z`, `zip`, `tar.xz`, `tar.lz`, `tar.gz`, `tar.bz2`. Defaults to `squirrel`.
*/
readonly target?: Array<string> | null

Expand Down
12 changes: 6 additions & 6 deletions src/packager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import * as path from "path"
import {
computeDefaultAppDirectory, installDependencies, getElectronVersion, readPackageJson, use,
exec, isEmptyOrSpaces
} from "./util"
import { all, executeFinally } from "./promise"
} from "./util/util"
import { all, executeFinally } from "./util/promise"
import { EventEmitter } from "events"
import { Promise as BluebirdPromise } from "bluebird"
import { AppMetadata, DevMetadata, Platform, Arch } from "./metadata"
Expand All @@ -13,13 +13,13 @@ import * as errorMessages from "./errorMessages"
import * as util from "util"
import deepAssign = require("deep-assign")
import semver = require("semver")
import { warn, log } from "./log"
import { warn, log } from "./util/log"
import { AppInfo } from "./appInfo"
import MacPackager from "./osxPackager"
import MacPackager from "./macPackager"
import { createTargets } from "./targets/targetFactory"

//noinspection JSUnusedLocalSymbols
const __awaiter = require("./awaiter")
const __awaiter = require("./util/awaiter")

function addHandler(emitter: EventEmitter, event: string, handler: Function) {
emitter.on(event, handler)
Expand Down Expand Up @@ -120,7 +120,7 @@ export class Packager implements BuildInfo {
switch (platform) {
case Platform.MAC:
{
const helperClass: typeof MacPackager = require("./osxPackager").default
const helperClass: typeof MacPackager = require("./macPackager").default
return new helperClass(this, cleanupTasks)
}

Expand Down
6 changes: 3 additions & 3 deletions src/platformPackager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ import { Promise as BluebirdPromise } from "bluebird"
import * as path from "path"
import { pack, ElectronPackagerOptions, userIgnoreFilter } from "electron-packager-tf"
import { readdir, unlink, remove, realpath } from "fs-extra-p"
import { statOrNull, use } from "./util"
import { statOrNull, use } from "./util/util"
import { Packager } from "./packager"
import { AsarOptions } from "asar"
import { archiveApp } from "./targets/archive"
import { Minimatch } from "minimatch"
import { checkFileInPackage, createAsarArchive } from "./asarUtil"
import deepAssign = require("deep-assign")
import { warn, log, task } from "./log"
import { warn, log, task } from "./util/log"
import { AppInfo } from "./appInfo"
import { listDependencies, createFilter, copyFiltered } from "./util/filter"

//noinspection JSUnusedLocalSymbols
const __awaiter = require("./awaiter")
const __awaiter = require("./util/awaiter")

export interface PackagerOptions {
targets?: Map<Platform, Map<Arch, string[]>>
Expand Down
2 changes: 1 addition & 1 deletion src/repositoryInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { AppMetadata, Metadata } from "./metadata"
import * as path from "path"

//noinspection JSUnusedLocalSymbols
const __awaiter = require("./awaiter")
const __awaiter = require("./util/awaiter")

export interface RepositorySlug {
user: string
Expand Down
4 changes: 2 additions & 2 deletions src/targets/archive.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { spawn, debug, debug7zArgs } from "../util"
import { spawn, debug, debug7zArgs } from "../util/util"
import { CompressionLevel } from "../metadata"
import * as path from "path"
import { unlink } from "fs-extra-p"
import { path7za } from "7zip-bin"

//noinspection JSUnusedLocalSymbols
const __awaiter = require("../awaiter")
const __awaiter = require("../util/awaiter")

class CompressionDescriptor {
constructor(public flag: string, public env: string, public minLevel: string, public maxLevel: string = "-9") {
Expand Down
6 changes: 3 additions & 3 deletions src/targets/dmg.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import deepAssign = require("deep-assign")
import * as path from "path"
import { log } from "../log"
import { log } from "../util/log"
import { Target, PlatformPackager } from "../platformPackager"
import { MacOptions, DmgOptions } from "../metadata"
import { Promise as BluebirdPromise } from "bluebird"
import { debug, use } from "../util"
import { debug, use } from "../util/util"
import appdmg = require("appdmg")

//noinspection JSUnusedLocalSymbols
const __awaiter = require("../awaiter")
const __awaiter = require("../util/awaiter")

export class DmgTarget extends Target {
private readonly options: DmgOptions
Expand Down
4 changes: 2 additions & 2 deletions src/targets/fpm.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { LinuxBuildOptions, Arch } from "../metadata"
import { smarten, Target, PlatformPackager } from "../platformPackager"
import { use, getTempName, debug, exec } from "../util"
import { use, getTempName, debug, exec } from "../util/util"
import { installPrefix } from "../linuxPackager"
import * as path from "path"
import { downloadFpm } from "../util/binDownload"
Expand All @@ -11,7 +11,7 @@ import { Promise as BluebirdPromise } from "bluebird"
const template = require("lodash.template")

//noinspection JSUnusedLocalSymbols
const __awaiter = require("../awaiter")
const __awaiter = require("../util/awaiter")

export class FpmTarget extends Target {
private readonly options = Object.assign({}, this.packager.platformSpecificBuildOptions, (<any>this.packager.devMetadata.build)[this.name])
Expand Down
6 changes: 3 additions & 3 deletions src/targets/nsis.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { WinPackager } from "../winPackager"
import { Arch, NsisOptions } from "../metadata"
import { exec, debug } from "../util"
import { exec, debug } from "../util/util"
import * as path from "path"
import { Promise as BluebirdPromise } from "bluebird"
import { getBin } from "../util/binDownload"
import { v5 as uuid5 } from "uuid-1345"
import { getArchSuffix, Target } from "../platformPackager"
import { archiveApp } from "./archive"
import { subTask } from "../log"
import { subTask } from "../util/log"
import sanitizeFileName = require("sanitize-filename")
import semver = require("semver")

//noinspection JSUnusedLocalSymbols
const __awaiter = require("../awaiter")
const __awaiter = require("../util/awaiter")

const NSIS_VERSION = "nsis-3.0.0-rc.1.2"
//noinspection SpellCheckingInspection
Expand Down
4 changes: 2 additions & 2 deletions src/targets/squirrelWindows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { getArchSuffix, Target } from "../platformPackager"
import { Arch, WinBuildOptions } from "../metadata"
import { createWindowsInstaller, convertVersion } from "electron-winstaller-fixed"
import * as path from "path"
import { warn } from "../log"
import { warn } from "../util/log"
import { emptyDir } from "fs-extra-p"
import { getRepositoryInfo } from "../repositoryInfo"

//noinspection JSUnusedLocalSymbols
const __awaiter = require("../awaiter")
const __awaiter = require("../util/awaiter")

export default class SquirrelWindowsTarget extends Target {
constructor(private packager: WinPackager) {
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions src/util/binDownload.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { statOrNull, spawn, debug, debug7zArgs, getTempName } from "../util"
import { statOrNull, spawn, debug, debug7zArgs, getTempName } from "./util"
import { rename, remove, unlink, emptyDir } from "fs-extra-p"
import { download } from "../httpRequest"
import { download } from "./httpRequest"
import { path7za } from "7zip-bin"
import * as path from "path"
import { homedir } from "os"
import { Promise as BluebirdPromise } from "bluebird"

//noinspection JSUnusedLocalSymbols
const __awaiter = require("../awaiter")
const __awaiter = require("./awaiter")

const versionToPromise = new Map<string, BluebirdPromise<string>>()

Expand Down
4 changes: 2 additions & 2 deletions src/util/filter.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { copy } from "fs-extra-p"
import { Minimatch } from "minimatch"
import { exec } from "../util"
import { exec } from "./util"
import * as path from "path"

//noinspection JSUnusedLocalSymbols
const __awaiter = require("../awaiter")
const __awaiter = require("./awaiter")

// we use relative path to avoid canonical path issue - e.g. /tmp vs /private/tmp
export function copyFiltered(src: string, destination: string, filter: (file: string) => boolean, dereference: boolean = false): Promise<any> {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions src/winPackager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import { Promise as BluebirdPromise } from "bluebird"
import { PlatformPackager, BuildInfo, getArchSuffix, Target } from "./platformPackager"
import { Platform, WinBuildOptions, Arch } from "./metadata"
import * as path from "path"
import { log, warn, task } from "./log"
import { log, warn, task } from "./util/log"
import { deleteFile, open, close, read } from "fs-extra-p"
import { sign, SignOptions } from "signcode-tf"
import SquirrelWindowsTarget from "./targets/squirrelWindows"
import NsisTarget from "./targets/nsis"
import { DEFAULT_TARGET, createCommonTarget, DIR_TARGET } from "./targets/targetFactory"

//noinspection JSUnusedLocalSymbols
const __awaiter = require("./awaiter")
const __awaiter = require("./util/awaiter")

export interface FileCodeSigningInfo {
readonly file: string
Expand Down
Loading

0 comments on commit 7c81164

Please sign in to comment.