From 45b503bb4fddc8082655e8a626e9a96e068000ff Mon Sep 17 00:00:00 2001 From: Everton Fraga Date: Tue, 20 Mar 2018 12:07:09 -0300 Subject: [PATCH 1/3] Refactoring upload-queue task; Prettier code style changes --- .travis.yml | 2 +- gulpTasks/building.js | 170 ++++++++++++++++++++-------------------- gulpTasks/publishing.js | 54 +++++++------ gulpfile.js | 77 ++++++++---------- package.json | 2 +- 5 files changed, 149 insertions(+), 156 deletions(-) diff --git a/.travis.yml b/.travis.yml index cb09ae641..3636581eb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -95,7 +95,7 @@ script: - if [[ $GULP_PLATFORM != "win" ]]; then gulp test; fi after_success: - - if [[ $TRAVIS_BRANCH == "master" ]]; then gulp uploadQueue --$GULP_PLATFORM && gulp uploadQueue --wallet --$GULP_PLATFORM; fi + - if [[ $TRAVIS_BRANCH == "master" ]]; then gulp upload-queue --$GULP_PLATFORM && gulp upload-queue --wallet --$GULP_PLATFORM; fi notifications: diff --git a/gulpTasks/building.js b/gulpTasks/building.js index 212030a82..a7348dada 100644 --- a/gulpTasks/building.js +++ b/gulpTasks/building.js @@ -1,68 +1,68 @@ -const _ = require('underscore'); -const builder = require('electron-builder'); -const del = require('del'); -const exec = require('child_process').exec; -const fs = require('fs'); -const gulp = require('gulp'); -const babel = require('gulp-babel'); -const options = require('../gulpfile.js').options; -const path = require('path'); -const Q = require('bluebird'); -const shell = require('shelljs'); -const version = require('../package.json').version; +const _ = require("underscore"); +const builder = require("electron-builder"); +const del = require("del"); +const exec = require("child_process").exec; +const fs = require("fs"); +const gulp = require("gulp"); +const babel = require("gulp-babel"); +const options = require("../gulpfile.js").options; +const path = require("path"); +const Q = require("bluebird"); +const shell = require("shelljs"); +const version = require("../package.json").version; const type = options.type; -const applicationName = options.wallet ? 'Ethereum Wallet' : 'Mist'; +const applicationName = options.wallet ? "Ethereum Wallet" : "Mist"; -gulp.task('clean-dist', cb => { - return del([`./dist_${type}`, './meteor-dapp-wallet'], cb); +gulp.task("clean-dist", cb => { + return del([`./dist_${type}`, "./meteor-dapp-wallet"], cb); }); -gulp.task('copy-app-source-files', () => { +gulp.task("copy-app-source-files", () => { return gulp .src( [ - 'node_modules/**/*', - './clientBinaries.json', - './tests/**/*.*', + "node_modules/**/*", + "./clientBinaries.json", + "./tests/**/*.*", `./icons/${type}/*`, - './sounds/*', - './errorPages/*', - 'customProtocols.js', - '!node_modules/electron/', - '!node_modules/electron/**/*', - '!./tests/wallet/*', - '!./tests/mist/*', - '!./tests/unit/*' + "./sounds/*", + "./errorPages/*", + "customProtocols.js", + "!node_modules/electron/", + "!node_modules/electron/**/*", + "!./tests/wallet/*", + "!./tests/mist/*", + "!./tests/unit/*" ], { - base: './' + base: "./" } ) .pipe(gulp.dest(`./dist_${type}/app`)); }); -gulp.task('transpile-main', () => { +gulp.task("transpile-main", () => { return gulp - .src('./main.js') - .pipe(babel({ presets: ['es2016-node5'] })) + .src("./main.js") + .pipe(babel({ presets: ["es2016-node5"] })) .pipe(gulp.dest(`./dist_${type}/app`)); }); -gulp.task('transpile-modules', () => { +gulp.task("transpile-modules", () => { return gulp - .src('./modules/**') - .pipe(babel({ presets: ['es2016-node5'] })) + .src("./modules/**") + .pipe(babel({ presets: ["es2016-node5"] })) .pipe(gulp.dest(`./dist_${type}/app/modules`)); }); -gulp.task('copy-build-folder-files', () => { +gulp.task("copy-build-folder-files", () => { return gulp - .src([`./icons/${type}/*`, './interface/public/images/dmg-background.jpg']) + .src([`./icons/${type}/*`, "./interface/public/images/dmg-background.jpg"]) .pipe(gulp.dest(`./dist_${type}/build`)); }); -gulp.task('switch-production', cb => { +gulp.task("switch-production", cb => { fs.writeFile( `./dist_${type}/app/config.json`, JSON.stringify({ @@ -73,15 +73,15 @@ gulp.task('switch-production', cb => { ); }); -gulp.task('bundling-interface', cb => { +gulp.task("bundling-interface", cb => { const bundle = additionalCommands => { exec( `cd interface \ && meteor-build-client ${path.join( - '..', + "..", `dist_${type}`, - 'app', - 'interface' + "app", + "interface" )} -p "" \ ${additionalCommands}`, (err, stdout) => { @@ -91,9 +91,9 @@ gulp.task('bundling-interface', cb => { ); }; - if (type === 'wallet') { - if (options.walletSource === 'local') { - console.log('Use local wallet at ../meteor-dapp-wallet/app'); + if (type === "wallet") { + if (options.walletSource === "local") { + console.log("Use local wallet at ../meteor-dapp-wallet/app"); bundle(`&& cd ../../meteor-dapp-wallet/app \ && meteor-build-client ../../mist/dist_${type}/app/interface/wallet -p ""`); } else { @@ -114,53 +114,53 @@ gulp.task('bundling-interface', cb => { } }); -gulp.task('copy-i18n', () => { +gulp.task("copy-i18n", () => { return gulp - .src(['./interface/i18n/*.*', './interface/project-tap.i18n'], { - base: './' + .src(["./interface/i18n/*.*", "./interface/project-tap.i18n"], { + base: "./" }) .pipe(gulp.dest(`./dist_${type}/app`)); }); -gulp.task('build-dist', cb => { - const appPackageJson = _.extend({}, require('../package.json'), { +gulp.task("build-dist", cb => { + const appPackageJson = _.extend({}, require("../package.json"), { // eslint-disable-line global-require - name: applicationName.replace(/\s/, ''), + name: applicationName.replace(/\s/, ""), productName: applicationName, description: applicationName, - homepage: 'https://github.com/ethereum/mist', + homepage: "https://github.com/ethereum/mist", build: { appId: `org.ethereum.${type}`, asar: true, directories: { - buildResources: '../build', - output: '../dist' + buildResources: "../build", + output: "../dist" }, linux: { - category: 'WebBrowser', + category: "WebBrowser", icon: `./app/${type}/icons`, - target: ['zip'] + target: ["zip"] }, win: { - target: ['zip'] + target: ["zip"] }, mac: { - category: 'public.app-category.productivity' + category: "public.app-category.productivity" }, dmg: { - background: '../build/dmg-background.jpg', + background: "../build/dmg-background.jpg", iconSize: 128, contents: [ { x: 441, y: 448, - type: 'link', - path: '/Applications' + type: "link", + path: "/Applications" }, { x: 441, y: 142, - type: 'file' + type: "file" } ] } @@ -168,9 +168,9 @@ gulp.task('build-dist', cb => { }); fs.writeFileSync( - path.join(__dirname, `../dist_${type}`, 'app', 'package.json'), + path.join(__dirname, `../dist_${type}`, "app", "package.json"), JSON.stringify(appPackageJson, null, 2), - 'utf-8' + "utf-8" ); const targets = []; @@ -180,17 +180,17 @@ gulp.task('build-dist', cb => { builder .build({ - targets: builder.createTargets(targets, null, 'all'), - projectDir: path.join(__dirname, `../dist_${type}`, 'app'), - publish: 'never', + targets: builder.createTargets(targets, null, "all"), + projectDir: path.join(__dirname, `../dist_${type}`, "app"), + publish: "never", config: { afterPack(params) { return Q.try(() => { shell.cp( [ - path.join(__dirname, '..', 'LICENSE'), - path.join(__dirname, '..', 'README.md'), - path.join(__dirname, '..', 'AUTHORS') + path.join(__dirname, "..", "LICENSE"), + path.join(__dirname, "..", "README.md"), + path.join(__dirname, "..", "AUTHORS") ], params.appOutDir ); @@ -206,16 +206,16 @@ gulp.task('build-dist', cb => { }); }); -gulp.task('release-dist', done => { - const distPath = path.join(__dirname, `../dist_${type}`, 'dist'); - const releasePath = path.join(__dirname, `../dist_${type}`, 'release'); +gulp.task("release-dist", done => { + const distPath = path.join(__dirname, `../dist_${type}`, "dist"); + const releasePath = path.join(__dirname, `../dist_${type}`, "release"); - shell.rm('-rf', releasePath); - shell.mkdir('-p', releasePath); + shell.rm("-rf", releasePath); + shell.mkdir("-p", releasePath); - const appNameHypen = applicationName.replace(/\s/, '-'); - const appNameNoSpace = applicationName.replace(/\s/, ''); - const versionDashed = version.replace(/\./g, '-'); + const appNameHypen = applicationName.replace(/\s/, "-"); + const appNameNoSpace = applicationName.replace(/\s/, ""); + const versionDashed = version.replace(/\./g, "-"); const cp = (inputPath, outputPath) => { console.info( @@ -232,7 +232,7 @@ gulp.task('release-dist', done => { _.each(options.activePlatforms, platform => { switch (platform) { // eslint-disable-line default-case - case 'win': + case "win": cp( `${applicationName}-${version}-ia32-win.zip`, `${appNameHypen}-win32-${versionDashed}.zip` @@ -242,13 +242,13 @@ gulp.task('release-dist', done => { `${appNameHypen}-win64-${versionDashed}.zip` ); break; - case 'mac': + case "mac": cp( `${applicationName}-${version}.dmg`, `${appNameHypen}-macosx-${versionDashed}.dmg` ); break; - case 'linux': + case "linux": // .deb have underscore separators cp( `${appNameNoSpace}_${version}_i386.deb`, @@ -272,18 +272,18 @@ gulp.task('release-dist', done => { } }); - console.info('∆∆∆ Listing release files ***'); - console.info(shell.ls('-l', releasePath).map(e => e.name)); + console.info("∆∆∆ Listing release files ***"); + console.info(shell.ls("-l", releasePath).map(e => e.name)); done(); }); -gulp.task('build-nsis', done => { +gulp.task("build-nsis", done => { if (!options.win) return done(); const typeString = `-DTYPE=${type}`; - const appNameString = `-DAPPNAME=${applicationName.replace(/\s/, '-')}`; - const versionParts = version.split('.'); + const appNameString = `-DAPPNAME=${applicationName.replace(/\s/, "-")}`; + const versionParts = version.split("."); const versionString = `-DVERSIONMAJOR=${versionParts[0]} -DVERSIONMINOR=${ versionParts[1] } -DVERSIONBUILD=${versionParts[2]}`; diff --git a/gulpTasks/publishing.js b/gulpTasks/publishing.js index 41bb6833d..08fd9662b 100644 --- a/gulpTasks/publishing.js +++ b/gulpTasks/publishing.js @@ -1,29 +1,31 @@ -const _ = require('underscore'); -const Q = require('bluebird'); -const fs = require('fs'); -const githubUpload = Q.promisify(require('gh-release-assets')); -const got = require('got'); -const gulp = require('gulp'); -const options = require('../gulpfile.js').options; -const path = require('path'); -const shell = require('shelljs'); -const version = require('../package.json').version; +const _ = require("underscore"); +const Q = require("bluebird"); +const fs = require("fs"); +const githubUpload = Q.promisify(require("gh-release-assets")); +const got = require("got"); +const gulp = require("gulp"); +const options = require("../gulpfile.js").options; +const path = require("path"); +const shell = require("shelljs"); +const version = require("../package.json").version; const checksums = []; const type = options.type; -gulp.task('checksums', cb => { +gulp.task("upload-queue", gulp.series("checksums", "upload-binaries")); + +gulp.task("checksums", cb => { const releasePath = `./dist_${type}/release`; const files = fs.readdirSync(releasePath); let command; - let argument = ''; + let argument = ""; - if (process.platform === 'win32') { - command = 'certUtil -hashfile'; - argument = 'SHA256'; + if (process.platform === "win32") { + command = "certUtil -hashfile"; + argument = "SHA256"; } else { - command = 'shasum -a 256'; + command = "shasum -a 256"; } files.forEach(file => { @@ -42,14 +44,14 @@ gulp.task('checksums', cb => { cb(); }); -gulp.task('upload-binaries', cb => { +gulp.task("upload-binaries", cb => { // if CI detected only upload if on master branch - if (process.env.CI && process.env.TRAVIS_BRANCH !== 'master') return; + if (process.env.CI && process.env.TRAVIS_BRANCH !== "master") return; // personal access token (public_repo) must be set using travis' ENVs const GITHUB_TOKEN = process.env.GITHUB_TOKEN; - console.info('Checking Github releases...'); + console.info("Checking Github releases..."); // query github releases got( @@ -59,7 +61,7 @@ gulp.task('upload-binaries', cb => { // filter draft with current version's tag .then(res => { const draft = - res.body[_.indexOf(_.pluck(res.body, 'tag_name'), `v${version}`)]; + res.body[_.indexOf(_.pluck(res.body, "tag_name"), `v${version}`)]; if (draft === undefined) throw new Error( @@ -77,14 +79,14 @@ gulp.task('upload-binaries', cb => { const filePaths = _.map(files, file => { return path.join(dir, file); }); - console.log('Upload files: ', filePaths); + console.log("Upload files: ", filePaths); // check if draft already contains target binaries // note: github replaces spaces in filenames with dots const existingAssets = _.intersection( files.map(file => { - return file.replace(/\s/g, '.'); + return file.replace(/\s/g, "."); }), - _.pluck(draft.assets, 'name') + _.pluck(draft.assets, "name") ); if (!_.isEmpty(existingAssets)) throw new Error( @@ -107,16 +109,16 @@ gulp.task('upload-binaries', cb => { // append checksums to draft text .then(() => { console.info( - 'Appending checksums to release notes...', + "Appending checksums to release notes...", checksums ); if (draft.body && checksums) { const checksumRows = checksums .map(e => { - const line = e.replace('\n', '').split(' '); + const line = e.replace("\n", "").split(" "); return `${line[1]} | \`${line[0]}\``; }) - .join('\n'); + .join("\n"); got.patch( `https://api.github.com/repos/ethereum/mist/releases/${ draft.id diff --git a/gulpfile.js b/gulpfile.js index c37652df2..6383fa786 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -4,40 +4,40 @@ strict, prefer-spread */ -const _ = require('underscore'); -const gulp = require('gulp'); -const minimist = require('minimist'); -const runSeq = require('run-sequence'); +const _ = require("underscore"); +const gulp = require("gulp"); +const minimist = require("minimist"); +const runSeq = require("run-sequence"); // available crossplatform builds let platforms; -if (process.platform === 'darwin') { - platforms = ['mac', 'linux', 'win']; -} else if (process.platform === 'win32') { - platforms = ['win']; +if (process.platform === "darwin") { + platforms = ["mac", "linux", "win"]; +} else if (process.platform === "win32") { + platforms = ["win"]; } else { - platforms = ['linux', 'win']; + platforms = ["linux", "win"]; } // parse commandline arguments const args = process.argv.slice(2); const options = minimist(args, { - string: ['walletSource', 'test', 'skipTasks'], - boolean: _.flatten(['wallet', platforms]), + string: ["walletSource", "test", "skipTasks"], + boolean: _.flatten(["wallet", platforms]), default: { wallet: false, - walletSource: 'master', - test: 'basic', - skipTasks: '' + walletSource: "master", + test: "basic", + skipTasks: "" } }); // echo version info and usage hints -console.log('Mist version:', require('./package.json').version); -console.log('Electron version:', require('electron/package.json').version); +console.log("Mist version:", require("./package.json").version); +console.log("Electron version:", require("electron/package.json").version); -if (_.isEmpty(_.intersection(args, ['--wallet']))) { - console.log('Many gulp tasks can be run in wallet mode using: --wallet'); +if (_.isEmpty(_.intersection(args, ["--wallet"]))) { + console.log("Many gulp tasks can be run in wallet mode using: --wallet"); } const platformFlags = platforms.map(platform => { @@ -45,7 +45,7 @@ const platformFlags = platforms.map(platform => { }); if (_.isEmpty(_.intersection(args, platformFlags))) { console.log( - `To specify a platform (default: all) use: ${platformFlags.join(' ')}` + `To specify a platform (default: all) use: ${platformFlags.join(" ")}` ); _.each(platforms, platform => { options[platform] = true; @@ -53,7 +53,7 @@ if (_.isEmpty(_.intersection(args, platformFlags))) { } // prepare global variables (shared with other gulp task files) -options.type = options.wallet ? 'wallet' : 'mist'; +options.type = options.wallet ? "wallet" : "mist"; options.platforms = platforms; options.activePlatforms = _.keys( _.pick(_.pick(options, platforms), key => { @@ -64,30 +64,21 @@ options.activePlatforms = _.keys( exports.options = options; // import gulp tasks -require('require-dir')('./gulpTasks'); +require("require-dir")("./gulpTasks"); -gulp.task('uploadQueue', cb => { - const tasks = []; - - tasks.push('checksums'); - tasks.push('upload-binaries'); - - runSeq.apply(null, _.flatten([tasks, cb])); -}); - -const skipTasks = options.skipTasks.replace(/\s/g, '').split(','); +const skipTasks = options.skipTasks.replace(/\s/g, "").split(","); const tasks = [ - 'clean-dist', - 'copy-app-source-files', - 'transpile-main', - 'transpile-modules', - 'copy-build-folder-files', - 'switch-production', - 'bundling-interface', - 'copy-i18n', - 'build-dist', - 'release-dist', - 'build-nsis' + "clean-dist", + "copy-app-source-files", + "transpile-main", + "transpile-modules", + "copy-build-folder-files", + "switch-production", + "bundling-interface", + "copy-i18n", + "build-dist", + "release-dist", + "build-nsis" ].filter(task => !skipTasks.includes(task)); -gulp.task('default', gulp.series(tasks)); +gulp.task("default", gulp.series(tasks)); diff --git a/package.json b/package.json index a06f9b32c..1c67c850c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "Mist", - "version": "0.9.4", + "version": "0.10.0", "license": "GPL-3.0", "author": "Ethereum Mist Team ", "repository": { From 586c83883ccce4a87bcf0587485144be9af0f74f Mon Sep 17 00:00:00 2001 From: Everton Fraga Date: Tue, 20 Mar 2018 12:52:45 -0300 Subject: [PATCH 2/3] Changing task delegation order --- gulpTasks/publishing.js | 2 -- gulpfile.js | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gulpTasks/publishing.js b/gulpTasks/publishing.js index 08fd9662b..dff7a983f 100644 --- a/gulpTasks/publishing.js +++ b/gulpTasks/publishing.js @@ -12,8 +12,6 @@ const version = require("../package.json").version; const checksums = []; const type = options.type; -gulp.task("upload-queue", gulp.series("checksums", "upload-binaries")); - gulp.task("checksums", cb => { const releasePath = `./dist_${type}/release`; const files = fs.readdirSync(releasePath); diff --git a/gulpfile.js b/gulpfile.js index 6383fa786..183f855eb 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -66,6 +66,8 @@ exports.options = options; // import gulp tasks require("require-dir")("./gulpTasks"); +gulp.task("upload-queue", gulp.series("checksums", "upload-binaries")); + const skipTasks = options.skipTasks.replace(/\s/g, "").split(","); const tasks = [ "clean-dist", From d50cf3eff3a812f1131fe33105a29fbadd8fa5bc Mon Sep 17 00:00:00 2001 From: Everton Fraga Date: Wed, 21 Mar 2018 13:21:22 -0300 Subject: [PATCH 3/3] Prettier formatting: single-quotes --- gulpTasks/building.js | 170 ++++++++++++++++++++-------------------- gulpTasks/publishing.js | 52 ++++++------ gulpfile.js | 70 ++++++++--------- 3 files changed, 146 insertions(+), 146 deletions(-) diff --git a/gulpTasks/building.js b/gulpTasks/building.js index a7348dada..212030a82 100644 --- a/gulpTasks/building.js +++ b/gulpTasks/building.js @@ -1,68 +1,68 @@ -const _ = require("underscore"); -const builder = require("electron-builder"); -const del = require("del"); -const exec = require("child_process").exec; -const fs = require("fs"); -const gulp = require("gulp"); -const babel = require("gulp-babel"); -const options = require("../gulpfile.js").options; -const path = require("path"); -const Q = require("bluebird"); -const shell = require("shelljs"); -const version = require("../package.json").version; +const _ = require('underscore'); +const builder = require('electron-builder'); +const del = require('del'); +const exec = require('child_process').exec; +const fs = require('fs'); +const gulp = require('gulp'); +const babel = require('gulp-babel'); +const options = require('../gulpfile.js').options; +const path = require('path'); +const Q = require('bluebird'); +const shell = require('shelljs'); +const version = require('../package.json').version; const type = options.type; -const applicationName = options.wallet ? "Ethereum Wallet" : "Mist"; +const applicationName = options.wallet ? 'Ethereum Wallet' : 'Mist'; -gulp.task("clean-dist", cb => { - return del([`./dist_${type}`, "./meteor-dapp-wallet"], cb); +gulp.task('clean-dist', cb => { + return del([`./dist_${type}`, './meteor-dapp-wallet'], cb); }); -gulp.task("copy-app-source-files", () => { +gulp.task('copy-app-source-files', () => { return gulp .src( [ - "node_modules/**/*", - "./clientBinaries.json", - "./tests/**/*.*", + 'node_modules/**/*', + './clientBinaries.json', + './tests/**/*.*', `./icons/${type}/*`, - "./sounds/*", - "./errorPages/*", - "customProtocols.js", - "!node_modules/electron/", - "!node_modules/electron/**/*", - "!./tests/wallet/*", - "!./tests/mist/*", - "!./tests/unit/*" + './sounds/*', + './errorPages/*', + 'customProtocols.js', + '!node_modules/electron/', + '!node_modules/electron/**/*', + '!./tests/wallet/*', + '!./tests/mist/*', + '!./tests/unit/*' ], { - base: "./" + base: './' } ) .pipe(gulp.dest(`./dist_${type}/app`)); }); -gulp.task("transpile-main", () => { +gulp.task('transpile-main', () => { return gulp - .src("./main.js") - .pipe(babel({ presets: ["es2016-node5"] })) + .src('./main.js') + .pipe(babel({ presets: ['es2016-node5'] })) .pipe(gulp.dest(`./dist_${type}/app`)); }); -gulp.task("transpile-modules", () => { +gulp.task('transpile-modules', () => { return gulp - .src("./modules/**") - .pipe(babel({ presets: ["es2016-node5"] })) + .src('./modules/**') + .pipe(babel({ presets: ['es2016-node5'] })) .pipe(gulp.dest(`./dist_${type}/app/modules`)); }); -gulp.task("copy-build-folder-files", () => { +gulp.task('copy-build-folder-files', () => { return gulp - .src([`./icons/${type}/*`, "./interface/public/images/dmg-background.jpg"]) + .src([`./icons/${type}/*`, './interface/public/images/dmg-background.jpg']) .pipe(gulp.dest(`./dist_${type}/build`)); }); -gulp.task("switch-production", cb => { +gulp.task('switch-production', cb => { fs.writeFile( `./dist_${type}/app/config.json`, JSON.stringify({ @@ -73,15 +73,15 @@ gulp.task("switch-production", cb => { ); }); -gulp.task("bundling-interface", cb => { +gulp.task('bundling-interface', cb => { const bundle = additionalCommands => { exec( `cd interface \ && meteor-build-client ${path.join( - "..", + '..', `dist_${type}`, - "app", - "interface" + 'app', + 'interface' )} -p "" \ ${additionalCommands}`, (err, stdout) => { @@ -91,9 +91,9 @@ gulp.task("bundling-interface", cb => { ); }; - if (type === "wallet") { - if (options.walletSource === "local") { - console.log("Use local wallet at ../meteor-dapp-wallet/app"); + if (type === 'wallet') { + if (options.walletSource === 'local') { + console.log('Use local wallet at ../meteor-dapp-wallet/app'); bundle(`&& cd ../../meteor-dapp-wallet/app \ && meteor-build-client ../../mist/dist_${type}/app/interface/wallet -p ""`); } else { @@ -114,53 +114,53 @@ gulp.task("bundling-interface", cb => { } }); -gulp.task("copy-i18n", () => { +gulp.task('copy-i18n', () => { return gulp - .src(["./interface/i18n/*.*", "./interface/project-tap.i18n"], { - base: "./" + .src(['./interface/i18n/*.*', './interface/project-tap.i18n'], { + base: './' }) .pipe(gulp.dest(`./dist_${type}/app`)); }); -gulp.task("build-dist", cb => { - const appPackageJson = _.extend({}, require("../package.json"), { +gulp.task('build-dist', cb => { + const appPackageJson = _.extend({}, require('../package.json'), { // eslint-disable-line global-require - name: applicationName.replace(/\s/, ""), + name: applicationName.replace(/\s/, ''), productName: applicationName, description: applicationName, - homepage: "https://github.com/ethereum/mist", + homepage: 'https://github.com/ethereum/mist', build: { appId: `org.ethereum.${type}`, asar: true, directories: { - buildResources: "../build", - output: "../dist" + buildResources: '../build', + output: '../dist' }, linux: { - category: "WebBrowser", + category: 'WebBrowser', icon: `./app/${type}/icons`, - target: ["zip"] + target: ['zip'] }, win: { - target: ["zip"] + target: ['zip'] }, mac: { - category: "public.app-category.productivity" + category: 'public.app-category.productivity' }, dmg: { - background: "../build/dmg-background.jpg", + background: '../build/dmg-background.jpg', iconSize: 128, contents: [ { x: 441, y: 448, - type: "link", - path: "/Applications" + type: 'link', + path: '/Applications' }, { x: 441, y: 142, - type: "file" + type: 'file' } ] } @@ -168,9 +168,9 @@ gulp.task("build-dist", cb => { }); fs.writeFileSync( - path.join(__dirname, `../dist_${type}`, "app", "package.json"), + path.join(__dirname, `../dist_${type}`, 'app', 'package.json'), JSON.stringify(appPackageJson, null, 2), - "utf-8" + 'utf-8' ); const targets = []; @@ -180,17 +180,17 @@ gulp.task("build-dist", cb => { builder .build({ - targets: builder.createTargets(targets, null, "all"), - projectDir: path.join(__dirname, `../dist_${type}`, "app"), - publish: "never", + targets: builder.createTargets(targets, null, 'all'), + projectDir: path.join(__dirname, `../dist_${type}`, 'app'), + publish: 'never', config: { afterPack(params) { return Q.try(() => { shell.cp( [ - path.join(__dirname, "..", "LICENSE"), - path.join(__dirname, "..", "README.md"), - path.join(__dirname, "..", "AUTHORS") + path.join(__dirname, '..', 'LICENSE'), + path.join(__dirname, '..', 'README.md'), + path.join(__dirname, '..', 'AUTHORS') ], params.appOutDir ); @@ -206,16 +206,16 @@ gulp.task("build-dist", cb => { }); }); -gulp.task("release-dist", done => { - const distPath = path.join(__dirname, `../dist_${type}`, "dist"); - const releasePath = path.join(__dirname, `../dist_${type}`, "release"); +gulp.task('release-dist', done => { + const distPath = path.join(__dirname, `../dist_${type}`, 'dist'); + const releasePath = path.join(__dirname, `../dist_${type}`, 'release'); - shell.rm("-rf", releasePath); - shell.mkdir("-p", releasePath); + shell.rm('-rf', releasePath); + shell.mkdir('-p', releasePath); - const appNameHypen = applicationName.replace(/\s/, "-"); - const appNameNoSpace = applicationName.replace(/\s/, ""); - const versionDashed = version.replace(/\./g, "-"); + const appNameHypen = applicationName.replace(/\s/, '-'); + const appNameNoSpace = applicationName.replace(/\s/, ''); + const versionDashed = version.replace(/\./g, '-'); const cp = (inputPath, outputPath) => { console.info( @@ -232,7 +232,7 @@ gulp.task("release-dist", done => { _.each(options.activePlatforms, platform => { switch (platform) { // eslint-disable-line default-case - case "win": + case 'win': cp( `${applicationName}-${version}-ia32-win.zip`, `${appNameHypen}-win32-${versionDashed}.zip` @@ -242,13 +242,13 @@ gulp.task("release-dist", done => { `${appNameHypen}-win64-${versionDashed}.zip` ); break; - case "mac": + case 'mac': cp( `${applicationName}-${version}.dmg`, `${appNameHypen}-macosx-${versionDashed}.dmg` ); break; - case "linux": + case 'linux': // .deb have underscore separators cp( `${appNameNoSpace}_${version}_i386.deb`, @@ -272,18 +272,18 @@ gulp.task("release-dist", done => { } }); - console.info("∆∆∆ Listing release files ***"); - console.info(shell.ls("-l", releasePath).map(e => e.name)); + console.info('∆∆∆ Listing release files ***'); + console.info(shell.ls('-l', releasePath).map(e => e.name)); done(); }); -gulp.task("build-nsis", done => { +gulp.task('build-nsis', done => { if (!options.win) return done(); const typeString = `-DTYPE=${type}`; - const appNameString = `-DAPPNAME=${applicationName.replace(/\s/, "-")}`; - const versionParts = version.split("."); + const appNameString = `-DAPPNAME=${applicationName.replace(/\s/, '-')}`; + const versionParts = version.split('.'); const versionString = `-DVERSIONMAJOR=${versionParts[0]} -DVERSIONMINOR=${ versionParts[1] } -DVERSIONBUILD=${versionParts[2]}`; diff --git a/gulpTasks/publishing.js b/gulpTasks/publishing.js index dff7a983f..41bb6833d 100644 --- a/gulpTasks/publishing.js +++ b/gulpTasks/publishing.js @@ -1,29 +1,29 @@ -const _ = require("underscore"); -const Q = require("bluebird"); -const fs = require("fs"); -const githubUpload = Q.promisify(require("gh-release-assets")); -const got = require("got"); -const gulp = require("gulp"); -const options = require("../gulpfile.js").options; -const path = require("path"); -const shell = require("shelljs"); -const version = require("../package.json").version; +const _ = require('underscore'); +const Q = require('bluebird'); +const fs = require('fs'); +const githubUpload = Q.promisify(require('gh-release-assets')); +const got = require('got'); +const gulp = require('gulp'); +const options = require('../gulpfile.js').options; +const path = require('path'); +const shell = require('shelljs'); +const version = require('../package.json').version; const checksums = []; const type = options.type; -gulp.task("checksums", cb => { +gulp.task('checksums', cb => { const releasePath = `./dist_${type}/release`; const files = fs.readdirSync(releasePath); let command; - let argument = ""; + let argument = ''; - if (process.platform === "win32") { - command = "certUtil -hashfile"; - argument = "SHA256"; + if (process.platform === 'win32') { + command = 'certUtil -hashfile'; + argument = 'SHA256'; } else { - command = "shasum -a 256"; + command = 'shasum -a 256'; } files.forEach(file => { @@ -42,14 +42,14 @@ gulp.task("checksums", cb => { cb(); }); -gulp.task("upload-binaries", cb => { +gulp.task('upload-binaries', cb => { // if CI detected only upload if on master branch - if (process.env.CI && process.env.TRAVIS_BRANCH !== "master") return; + if (process.env.CI && process.env.TRAVIS_BRANCH !== 'master') return; // personal access token (public_repo) must be set using travis' ENVs const GITHUB_TOKEN = process.env.GITHUB_TOKEN; - console.info("Checking Github releases..."); + console.info('Checking Github releases...'); // query github releases got( @@ -59,7 +59,7 @@ gulp.task("upload-binaries", cb => { // filter draft with current version's tag .then(res => { const draft = - res.body[_.indexOf(_.pluck(res.body, "tag_name"), `v${version}`)]; + res.body[_.indexOf(_.pluck(res.body, 'tag_name'), `v${version}`)]; if (draft === undefined) throw new Error( @@ -77,14 +77,14 @@ gulp.task("upload-binaries", cb => { const filePaths = _.map(files, file => { return path.join(dir, file); }); - console.log("Upload files: ", filePaths); + console.log('Upload files: ', filePaths); // check if draft already contains target binaries // note: github replaces spaces in filenames with dots const existingAssets = _.intersection( files.map(file => { - return file.replace(/\s/g, "."); + return file.replace(/\s/g, '.'); }), - _.pluck(draft.assets, "name") + _.pluck(draft.assets, 'name') ); if (!_.isEmpty(existingAssets)) throw new Error( @@ -107,16 +107,16 @@ gulp.task("upload-binaries", cb => { // append checksums to draft text .then(() => { console.info( - "Appending checksums to release notes...", + 'Appending checksums to release notes...', checksums ); if (draft.body && checksums) { const checksumRows = checksums .map(e => { - const line = e.replace("\n", "").split(" "); + const line = e.replace('\n', '').split(' '); return `${line[1]} | \`${line[0]}\``; }) - .join("\n"); + .join('\n'); got.patch( `https://api.github.com/repos/ethereum/mist/releases/${ draft.id diff --git a/gulpfile.js b/gulpfile.js index 183f855eb..0847767a9 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -4,40 +4,40 @@ strict, prefer-spread */ -const _ = require("underscore"); -const gulp = require("gulp"); -const minimist = require("minimist"); -const runSeq = require("run-sequence"); +const _ = require('underscore'); +const gulp = require('gulp'); +const minimist = require('minimist'); +const runSeq = require('run-sequence'); // available crossplatform builds let platforms; -if (process.platform === "darwin") { - platforms = ["mac", "linux", "win"]; -} else if (process.platform === "win32") { - platforms = ["win"]; +if (process.platform === 'darwin') { + platforms = ['mac', 'linux', 'win']; +} else if (process.platform === 'win32') { + platforms = ['win']; } else { - platforms = ["linux", "win"]; + platforms = ['linux', 'win']; } // parse commandline arguments const args = process.argv.slice(2); const options = minimist(args, { - string: ["walletSource", "test", "skipTasks"], - boolean: _.flatten(["wallet", platforms]), + string: ['walletSource', 'test', 'skipTasks'], + boolean: _.flatten(['wallet', platforms]), default: { wallet: false, - walletSource: "master", - test: "basic", - skipTasks: "" + walletSource: 'master', + test: 'basic', + skipTasks: '' } }); // echo version info and usage hints -console.log("Mist version:", require("./package.json").version); -console.log("Electron version:", require("electron/package.json").version); +console.log('Mist version:', require('./package.json').version); +console.log('Electron version:', require('electron/package.json').version); -if (_.isEmpty(_.intersection(args, ["--wallet"]))) { - console.log("Many gulp tasks can be run in wallet mode using: --wallet"); +if (_.isEmpty(_.intersection(args, ['--wallet']))) { + console.log('Many gulp tasks can be run in wallet mode using: --wallet'); } const platformFlags = platforms.map(platform => { @@ -45,7 +45,7 @@ const platformFlags = platforms.map(platform => { }); if (_.isEmpty(_.intersection(args, platformFlags))) { console.log( - `To specify a platform (default: all) use: ${platformFlags.join(" ")}` + `To specify a platform (default: all) use: ${platformFlags.join(' ')}` ); _.each(platforms, platform => { options[platform] = true; @@ -53,7 +53,7 @@ if (_.isEmpty(_.intersection(args, platformFlags))) { } // prepare global variables (shared with other gulp task files) -options.type = options.wallet ? "wallet" : "mist"; +options.type = options.wallet ? 'wallet' : 'mist'; options.platforms = platforms; options.activePlatforms = _.keys( _.pick(_.pick(options, platforms), key => { @@ -64,23 +64,23 @@ options.activePlatforms = _.keys( exports.options = options; // import gulp tasks -require("require-dir")("./gulpTasks"); +require('require-dir')('./gulpTasks'); -gulp.task("upload-queue", gulp.series("checksums", "upload-binaries")); +gulp.task('upload-queue', gulp.series('checksums', 'upload-binaries')); -const skipTasks = options.skipTasks.replace(/\s/g, "").split(","); +const skipTasks = options.skipTasks.replace(/\s/g, '').split(','); const tasks = [ - "clean-dist", - "copy-app-source-files", - "transpile-main", - "transpile-modules", - "copy-build-folder-files", - "switch-production", - "bundling-interface", - "copy-i18n", - "build-dist", - "release-dist", - "build-nsis" + 'clean-dist', + 'copy-app-source-files', + 'transpile-main', + 'transpile-modules', + 'copy-build-folder-files', + 'switch-production', + 'bundling-interface', + 'copy-i18n', + 'build-dist', + 'release-dist', + 'build-nsis' ].filter(task => !skipTasks.includes(task)); -gulp.task("default", gulp.series(tasks)); +gulp.task('default', gulp.series(tasks));