From e3a58997f71384d6390fca67cb9b6c1992a1b6f5 Mon Sep 17 00:00:00 2001 From: develar Date: Mon, 22 Aug 2016 19:56:00 +0200 Subject: [PATCH] feat: add node-gyp-rebuild #683 --- package.json | 3 ++- src/node-gyp-rebuild.ts | 34 +++++++++++++++++++++++++++++++ src/packager.ts | 2 +- src/publish/gitHubPublisher.ts | 7 +++++++ test/src/ArtifactPublisherTest.ts | 2 ++ 5 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 src/node-gyp-rebuild.ts diff --git a/package.json b/package.json index 5a88f92f63f..b6f80e5d8b2 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,8 @@ "bin": { "build": "./out/build-cli.js", "cleanup": "./out/cleanup.js", - "install-app-deps": "./out/install-app-deps.js" + "install-app-deps": "./out/install-app-deps.js", + "node-gyp-rebuild": "./out/node-gyp-rebuild.js" }, "scripts": { "compile": "npm run compile-production && npm run compile-test && npm run compile-updater", diff --git a/src/node-gyp-rebuild.ts b/src/node-gyp-rebuild.ts new file mode 100644 index 00000000000..008ff005754 --- /dev/null +++ b/src/node-gyp-rebuild.ts @@ -0,0 +1,34 @@ +#! /usr/bin/env node + +import { getElectronVersion, exec, getGypEnv } from "./util/util" +import { printErrorAndExit } from "./util/promise" +import * as path from "path" +import yargs = require("yargs") +import { readPackageJson } from "./util/readPackageJson" +import { log } from "./util/log" + +//noinspection JSUnusedLocalSymbols +const __awaiter = require("./util/awaiter") + +const args: any = yargs + .option("arch", { + choices: ["ia32", "x64"], + }).argv + +const projectDir = process.cwd() +const devPackageFile = path.join(projectDir, "package.json") + +async function main() { + const arch = args.arch || process.arch + log(`Execute node-gyp rebuild for arch ${arch}`) + await exec(process.platform === "win32" ? "node-gyp.cmd" : "node-gyp", ["rebuild"], { + env: getGypEnv(await getElectronVersion(await readPackageJson(devPackageFile), devPackageFile), arch), + }) +} + +try { + main() +} +catch (e) { + printErrorAndExit(e) +} \ No newline at end of file diff --git a/src/packager.ts b/src/packager.ts index b808ed88d91..751ade574e8 100644 --- a/src/packager.ts +++ b/src/packager.ts @@ -216,7 +216,7 @@ export class Packager implements BuildInfo { private async installAppDependencies(platform: Platform, arch: Arch): Promise { if (this.devMetadata.build.nodeGypRebuild === true) { - log("Execute node-gyp rebuild") + log(`Execute node-gyp rebuild for arch ${Arch[arch]}`) await exec(process.platform === "win32" ? "node-gyp.cmd" : "node-gyp", ["rebuild"], { env: getGypEnv(this.electronVersion, Arch[arch]), }) diff --git a/src/publish/gitHubPublisher.ts b/src/publish/gitHubPublisher.ts index e8f76b07166..4171100677f 100644 --- a/src/publish/gitHubPublisher.ts +++ b/src/publish/gitHubPublisher.ts @@ -184,4 +184,11 @@ export class GitHubPublisher implements Publisher { warn(`Cannot delete release ${release.id}`) } + + // async deleteOldReleases() { + // const releases = await githubRequest>(`/repos/${this.owner}/${this.repo}/releases`, this.token) + // for (let release of releases) { + // await githubRequest(`/repos/${this.owner}/${this.repo}/releases/${release.id}`, this.token, null, "DELETE") + // } + // } } \ No newline at end of file diff --git a/test/src/ArtifactPublisherTest.ts b/test/src/ArtifactPublisherTest.ts index 7bc28591851..cabd5ccb1ba 100644 --- a/test/src/ArtifactPublisherTest.ts +++ b/test/src/ArtifactPublisherTest.ts @@ -104,6 +104,8 @@ testAndIgnoreApiRate("incorrect tag name", async () => { prerelease: true, publish: "onTagOrDraft", }) + + // await publisher.deleteOldReleases() try { await publisher.releasePromise //noinspection ExceptionCaughtLocallyJS