From c9602172fa5bdde3ce29e92cba1b30d0e30bef13 Mon Sep 17 00:00:00 2001 From: Tony Anziano Date: Mon, 8 Oct 2018 13:37:55 -0700 Subject: [PATCH 01/35] WIP cleaning up gulp file. --- packages/app/main/gulpfile.common.js | 0 packages/app/main/gulpfile.linux.js | 0 packages/app/main/gulpfile.mac.js | 0 packages/app/main/gulpfile.windows.js | 0 4 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 packages/app/main/gulpfile.common.js create mode 100644 packages/app/main/gulpfile.linux.js create mode 100644 packages/app/main/gulpfile.mac.js create mode 100644 packages/app/main/gulpfile.windows.js diff --git a/packages/app/main/gulpfile.common.js b/packages/app/main/gulpfile.common.js new file mode 100644 index 000000000..e69de29bb diff --git a/packages/app/main/gulpfile.linux.js b/packages/app/main/gulpfile.linux.js new file mode 100644 index 000000000..e69de29bb diff --git a/packages/app/main/gulpfile.mac.js b/packages/app/main/gulpfile.mac.js new file mode 100644 index 000000000..e69de29bb diff --git a/packages/app/main/gulpfile.windows.js b/packages/app/main/gulpfile.windows.js new file mode 100644 index 000000000..e69de29bb From d4fc9c837fe0bfa5fdccf0404fd56ccd3f04372b Mon Sep 17 00:00:00 2001 From: Tony Anziano Date: Mon, 8 Oct 2018 15:34:10 -0700 Subject: [PATCH 02/35] Refactored linux gulp processes. --- packages/app/main/gulpfile.common.js | 53 ++++++++++++++++++++ packages/app/main/gulpfile.linux.js | 74 ++++++++++++++++++++++++++++ 2 files changed, 127 insertions(+) diff --git a/packages/app/main/gulpfile.common.js b/packages/app/main/gulpfile.common.js index e69de29bb..cf90ee845 100644 --- a/packages/app/main/gulpfile.common.js +++ b/packages/app/main/gulpfile.common.js @@ -0,0 +1,53 @@ +const packageJson = require('./package.json'); + +/** Gets an environment variable with the provided name */ +function getEnvironmentVar(name, defaultValue = undefined) { + return (process.env[name] === undefined) ? defaultValue : process.env[name] +} + +/** Returns the Electron Mirror URL from where electron is downloaded */ +function getElectronMirrorUrl() { + return `${getEnvironmentVar("ELECTRON_MIRROR", defaultElectronMirror)}${getEnvironmentVar("ELECTRON_VERSION", defaultElectronVersion)}`; +} + +/** Publishes files to GitHub + * @param {string[]} filelist List of filenames to publish +*/ +async function publishFiles(filelist) { + var CancellationToken = require('electron-builder-http/out/CancellationToken').CancellationToken; + var GitHubPublisher = require('electron-publish/out/gitHubPublisher').GitHubPublisher; + var publishConfig = replacePublishEnvironmentVars(require('./scripts/config/publish.json')); + + const context = { + cancellationToken: new CancellationToken(), + progress: null + }; + + const publisher = new GitHubPublisher( + context, + publishConfig, + packageJson.version, { + publish: "always", + draft: true, + prerelease: false + } + ); + const errorlist = []; + + const uploads = filelist.map(file => { + return publisher.upload({ file }) + .catch((err) => { + errorlist.push(err.response ? `Failed to upload ${file}, http status code ${err.response.statusCode}` : err); + return Promise.resolve(); + }); + }); + + return await Promise.all(uploads) + .then(() => errorlist.forEach(err => console.error(err))); +} + +module.exports = { + getEnvironmentVar, + getElectronMirrorUrl, + publishFiles +}; diff --git a/packages/app/main/gulpfile.linux.js b/packages/app/main/gulpfile.linux.js index e69de29bb..3797f0065 100644 --- a/packages/app/main/gulpfile.linux.js +++ b/packages/app/main/gulpfile.linux.js @@ -0,0 +1,74 @@ +const gulp = require('gulp'); +const common = require('./gulpfile.common.js'); +const packageJson = require('./package.json'); + +/** Package the emulator using electron-builder + * and output artifacts to /dist/ + */ +gulp.task('package', async () => { + var rename = require('gulp-rename'); + var builder = require('electron-builder'); + const config = getConfig("linux"); + const { getElectronMirrorUrl } = common; + + console.log(`Electron mirror: ${getElectronMirrorUrl()}`); + + // create packaged artifacts + const filenames = await builder.build({ + targets: builder.Platform.LINUX.createTarget(["deb", "AppImage"], builder.Arch.ia32, builder.Arch.x64), + config + }); + + // rename and move the files to the /dist/ directory + await new Promise(resolve => { + gulp + .src(filenames, { allowEmpty: true }) + .pipe(rename(path => { + path.basename = setReleaseFilename(path.basename, { + replaceWhitespace: true + }); + })) + .pipe(gulp.dest('./dist')) + .on('end', resolve); + }); + + /* + return builder.build({ + targets: builder.Platform.LINUX.createTarget(["deb", "AppImage"], builder.Arch.ia32, builder.Arch.x64), + config + }).then((filenames) => { + return gulp.src(filenames, { allowEmpty: true }) + .pipe(rename(function (path) { + path.basename = setReleaseFilename(path.basename, { + replaceWhitespace: true + }); + })) + .pipe(gulp.dest('./dist')); + }).then(() => { + // Wait for the files to be written to disk and closed. + return delay(10000); + });*/ +}); + +/** Publish the artifacts in /dist/ to GitHub */ +gulp.task('publish', async () => { + const filesToPublish = getFilesFromDist(); + await publishFiles(filesToPublish); +}); + +/** Returns the names of the packaged artifacts in /dist/ */ +function getFilesFromDist(options = {}) { + options = extend({}, { + basename: packageJson.packagename, + version: packageJson.version, + }, options); + const path = './dist'; + + const filelist = []; + filelist.push(`${path}/${options.basename}-${options.version}-i386.AppImage`); + filelist.push(`${path}/${options.basename}-${options.version}-x86_64.AppImage`); + filelist.push(`${path}/${options.basename}_${options.version}_i386.deb`); + filelist.push(`${path}/${options.basename}_${options.version}_amd64.deb`); + + return filelist; +} From 7af1c6ca4473778cac8efd4d87fef78a520db51a Mon Sep 17 00:00:00 2001 From: Tony Anziano Date: Mon, 8 Oct 2018 15:37:56 -0700 Subject: [PATCH 03/35] Changing package name for testing. --- packages/app/main/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/app/main/package.json b/packages/app/main/package.json index 3273c6c86..5830c8911 100644 --- a/packages/app/main/package.json +++ b/packages/app/main/package.json @@ -1,7 +1,7 @@ { "name": "@bfemulator/main", "packagename": "Botframework-Emulator", - "version": "4.0.0-preview", + "version": "4.0.0-preview-linux-test", "private": true, "description": "Development tool for the Microsoft Bot Framework. Allows developers to test and debug bots on localhost.", "main": "./app/server/main.js", From 6fccb44a03818dc2ccaed7cb6b83d11a280f6bd4 Mon Sep 17 00:00:00 2001 From: Tony Anziano Date: Mon, 8 Oct 2018 15:53:12 -0700 Subject: [PATCH 04/35] Correcting some missing references. --- packages/app/main/gulpfile.common.js | 59 ++++++++++++++++++++++++++++ packages/app/main/gulpfile.linux.js | 32 ++++++++++++++- 2 files changed, 90 insertions(+), 1 deletion(-) diff --git a/packages/app/main/gulpfile.common.js b/packages/app/main/gulpfile.common.js index cf90ee845..df3998695 100644 --- a/packages/app/main/gulpfile.common.js +++ b/packages/app/main/gulpfile.common.js @@ -5,11 +5,68 @@ function getEnvironmentVar(name, defaultValue = undefined) { return (process.env[name] === undefined) ? defaultValue : process.env[name] } +/** Replaces an environment variable */ +function replaceEnvironmentVar(str, name, defaultValue = undefined) { + const value = getEnvironmentVar(name, defaultValue); + if (value === undefined) + throw new Error(`Required environment variable missing: ${name}`); + return str.replace(new RegExp('\\${' + name + '}', 'g'), value); +} + +/** Replaces a packaging-related environment variable */ +function replacePackageEnvironmentVars(obj) { + let str = JSON.stringify(obj); + str = replaceEnvironmentVar(str, "ELECTRON_MIRROR", defaultElectronMirror); + str = replaceEnvironmentVar(str, "ELECTRON_VERSION", defaultElectronVersion); + str = replaceEnvironmentVar(str, "appId", appId); + return JSON.parse(str); +} + +/** Replaces a publishing-related environment variable */ +function replacePublishEnvironmentVars(obj) { + let str = JSON.stringify(obj); + str = replaceEnvironmentVar(str, "GH_TOKEN"); + str = replaceEnvironmentVar(str, "githubAccountName", githubAccountName); + str = replaceEnvironmentVar(str, "githubRepoName", githubRepoName); + return JSON.parse(str); +} + /** Returns the Electron Mirror URL from where electron is downloaded */ function getElectronMirrorUrl() { return `${getEnvironmentVar("ELECTRON_MIRROR", defaultElectronMirror)}${getEnvironmentVar("ELECTRON_VERSION", defaultElectronVersion)}`; } +/** Gets the config file for a specific platform */ +function getConfig(platform, target) { + return extend({}, + replacePackageEnvironmentVars(require('./scripts/config/common.json')), + replacePackageEnvironmentVars(require(`./scripts/config/${platform}.json`)), + (target ? replacePackageEnvironmentVars(require(`./scripts/config/${platform}-${target}.json`)) : {}) + ); +} + +/** _.extend */ +function extend(...sources) { + let output = {}; + sources.forEach(source => { + extend1(output, source); + }); + return output; +} + +function extend1(destination, source) { + for (var property in source) { + if (source[property] && source[property].constructor && + source[property].constructor === Object) { + destination[property] = destination[property] || {}; + arguments.callee(destination[property], source[property]); + } else { + destination[property] = source[property]; + } + } + return destination; +}; + /** Publishes files to GitHub * @param {string[]} filelist List of filenames to publish */ @@ -47,7 +104,9 @@ async function publishFiles(filelist) { } module.exports = { + getConfig, getEnvironmentVar, getElectronMirrorUrl, + extend, publishFiles }; diff --git a/packages/app/main/gulpfile.linux.js b/packages/app/main/gulpfile.linux.js index 3797f0065..9d6393d10 100644 --- a/packages/app/main/gulpfile.linux.js +++ b/packages/app/main/gulpfile.linux.js @@ -8,7 +8,7 @@ const packageJson = require('./package.json'); gulp.task('package', async () => { var rename = require('gulp-rename'); var builder = require('electron-builder'); - const config = getConfig("linux"); + const config = getConfig('linux'); const { getElectronMirrorUrl } = common; console.log(`Electron mirror: ${getElectronMirrorUrl()}`); @@ -58,6 +58,7 @@ gulp.task('publish', async () => { /** Returns the names of the packaged artifacts in /dist/ */ function getFilesFromDist(options = {}) { + const { extend } = common; options = extend({}, { basename: packageJson.packagename, version: packageJson.version, @@ -72,3 +73,32 @@ function getFilesFromDist(options = {}) { return filelist; } + +function setReleaseFilename(filename, options = {}) { + const { extend } = common; + options = extend({}, { + lowerCase: true, + replaceWhitespace: true, + fixBasename: true, + replaceName: false, + srcName: null, + dstName: null + }, + options + ); + if (options.replaceName && options.srcName && options.dstName) { + filename = filename.replace(options.srcName, options.dstName); + } + if (options.lowerCase) { + filename = filename.toLowerCase(); + } + if (options.replaceWhitespace) { + filename = filename.replace(/\s/g, '-'); + } + if (options.fixBasename) { + // renames build artifacts like 'bot-framework_{version}.*' or 'main_{version}.*' + // to '{package name in package.json}_{version}.*' + filename = filename.replace(/(bot[-|\s]framework)?(main)?/, pjson.packagename); + } + return filename; +} From 50fdfb26003c73b46971d115524aac5ff0c0fc46 Mon Sep 17 00:00:00 2001 From: Tony Anziano Date: Mon, 8 Oct 2018 16:01:51 -0700 Subject: [PATCH 05/35] Fixed bad reference. --- packages/app/main/gulpfile.linux.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/app/main/gulpfile.linux.js b/packages/app/main/gulpfile.linux.js index 9d6393d10..f5515f2d5 100644 --- a/packages/app/main/gulpfile.linux.js +++ b/packages/app/main/gulpfile.linux.js @@ -6,10 +6,10 @@ const packageJson = require('./package.json'); * and output artifacts to /dist/ */ gulp.task('package', async () => { + const { getElectronMirrorUrl, getConfig } = common; var rename = require('gulp-rename'); var builder = require('electron-builder'); const config = getConfig('linux'); - const { getElectronMirrorUrl } = common; console.log(`Electron mirror: ${getElectronMirrorUrl()}`); From 318380a3e467b7f45fcd4c90f90c991423176acd Mon Sep 17 00:00:00 2001 From: Tony Anziano Date: Mon, 8 Oct 2018 16:09:51 -0700 Subject: [PATCH 06/35] Added missing constants. --- packages/app/main/gulpfile.common.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/app/main/gulpfile.common.js b/packages/app/main/gulpfile.common.js index df3998695..0a1343b84 100644 --- a/packages/app/main/gulpfile.common.js +++ b/packages/app/main/gulpfile.common.js @@ -1,5 +1,11 @@ const packageJson = require('./package.json'); +const defaultElectronMirror = 'https://github.com/electron/electron/releases/download/v'; +const defaultElectronVersion = pjson.devDependencies["electron"]; +const githubAccountName = "Microsoft"; +const githubRepoName = "BotFramework-Emulator"; +const appId = "F3C061A6-FE81-4548-82ED-C1171D9856BB"; + /** Gets an environment variable with the provided name */ function getEnvironmentVar(name, defaultValue = undefined) { return (process.env[name] === undefined) ? defaultValue : process.env[name] From 1f1a91b0cc8483b119e65b82d54ac9851c98e2b8 Mon Sep 17 00:00:00 2001 From: Tony Anziano Date: Mon, 8 Oct 2018 16:15:57 -0700 Subject: [PATCH 07/35] Fixed bad variable name. --- packages/app/main/gulpfile.common.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/app/main/gulpfile.common.js b/packages/app/main/gulpfile.common.js index 0a1343b84..747be5cb9 100644 --- a/packages/app/main/gulpfile.common.js +++ b/packages/app/main/gulpfile.common.js @@ -1,7 +1,7 @@ const packageJson = require('./package.json'); const defaultElectronMirror = 'https://github.com/electron/electron/releases/download/v'; -const defaultElectronVersion = pjson.devDependencies["electron"]; +const defaultElectronVersion = packageJson.devDependencies["electron"]; const githubAccountName = "Microsoft"; const githubRepoName = "BotFramework-Emulator"; const appId = "F3C061A6-FE81-4548-82ED-C1171D9856BB"; From 2e4a9a92129dc8ebf968512e170f761f0244793c Mon Sep 17 00:00:00 2001 From: Tony Anziano Date: Mon, 8 Oct 2018 16:35:46 -0700 Subject: [PATCH 08/35] Fixed old variable reference. --- packages/app/main/gulpfile.linux.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/app/main/gulpfile.linux.js b/packages/app/main/gulpfile.linux.js index f5515f2d5..7e2ca9c2d 100644 --- a/packages/app/main/gulpfile.linux.js +++ b/packages/app/main/gulpfile.linux.js @@ -98,7 +98,7 @@ function setReleaseFilename(filename, options = {}) { if (options.fixBasename) { // renames build artifacts like 'bot-framework_{version}.*' or 'main_{version}.*' // to '{package name in package.json}_{version}.*' - filename = filename.replace(/(bot[-|\s]framework)?(main)?/, pjson.packagename); + filename = filename.replace(/(bot[-|\s]framework)?(main)?/, packageJson.packagename); } return filename; } From d2ff35d181b379226acdb9ac599db4d131c57b1b Mon Sep 17 00:00:00 2001 From: Tony Anziano Date: Mon, 8 Oct 2018 16:46:32 -0700 Subject: [PATCH 09/35] Fixed missing import in publish task. --- packages/app/main/gulpfile.linux.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/app/main/gulpfile.linux.js b/packages/app/main/gulpfile.linux.js index 7e2ca9c2d..eea55bc6e 100644 --- a/packages/app/main/gulpfile.linux.js +++ b/packages/app/main/gulpfile.linux.js @@ -52,6 +52,7 @@ gulp.task('package', async () => { /** Publish the artifacts in /dist/ to GitHub */ gulp.task('publish', async () => { + const { publishFiles } = common; const filesToPublish = getFilesFromDist(); await publishFiles(filesToPublish); }); From ea7e1990f6f78b622a6a7b135b208889491fd999 Mon Sep 17 00:00:00 2001 From: Tony Anziano Date: Tue, 9 Oct 2018 10:37:06 -0700 Subject: [PATCH 10/35] Trying to diagnose environment variable issue. --- packages/app/main/gulpfile.common.js | 2 +- packages/app/main/gulpfile.linux.js | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/app/main/gulpfile.common.js b/packages/app/main/gulpfile.common.js index 747be5cb9..f8b100102 100644 --- a/packages/app/main/gulpfile.common.js +++ b/packages/app/main/gulpfile.common.js @@ -6,7 +6,7 @@ const githubAccountName = "Microsoft"; const githubRepoName = "BotFramework-Emulator"; const appId = "F3C061A6-FE81-4548-82ED-C1171D9856BB"; -/** Gets an environment variable with the provided name */ +/** Gets an environment variable value with the provided name */ function getEnvironmentVar(name, defaultValue = undefined) { return (process.env[name] === undefined) ? defaultValue : process.env[name] } diff --git a/packages/app/main/gulpfile.linux.js b/packages/app/main/gulpfile.linux.js index eea55bc6e..23de9ba51 100644 --- a/packages/app/main/gulpfile.linux.js +++ b/packages/app/main/gulpfile.linux.js @@ -52,6 +52,9 @@ gulp.task('package', async () => { /** Publish the artifacts in /dist/ to GitHub */ gulp.task('publish', async () => { + for (const key in Object.keys(process.env)) { + console.log(`${key}: ${process.env[key]}`); + } const { publishFiles } = common; const filesToPublish = getFilesFromDist(); await publishFiles(filesToPublish); From 067f2ae9669333df3d790c3b543647838f842895 Mon Sep 17 00:00:00 2001 From: Tony Anziano Date: Tue, 9 Oct 2018 11:11:29 -0700 Subject: [PATCH 11/35] More WIP for env. --- packages/app/main/gulpfile.linux.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/app/main/gulpfile.linux.js b/packages/app/main/gulpfile.linux.js index 23de9ba51..52c5ef56a 100644 --- a/packages/app/main/gulpfile.linux.js +++ b/packages/app/main/gulpfile.linux.js @@ -52,9 +52,9 @@ gulp.task('package', async () => { /** Publish the artifacts in /dist/ to GitHub */ gulp.task('publish', async () => { - for (const key in Object.keys(process.env)) { + Object.keys(process.env).forEach(key => { console.log(`${key}: ${process.env[key]}`); - } + }); const { publishFiles } = common; const filesToPublish = getFilesFromDist(); await publishFiles(filesToPublish); From 12ef7fdebb5634a77f9659510fd6d1fa2647f396 Mon Sep 17 00:00:00 2001 From: Tony Anziano Date: Tue, 9 Oct 2018 11:40:03 -0700 Subject: [PATCH 12/35] Finished initial refactoring of Linux build process. --- packages/app/main/gulpfile.linux.js | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/packages/app/main/gulpfile.linux.js b/packages/app/main/gulpfile.linux.js index 52c5ef56a..1926e183b 100644 --- a/packages/app/main/gulpfile.linux.js +++ b/packages/app/main/gulpfile.linux.js @@ -24,37 +24,15 @@ gulp.task('package', async () => { gulp .src(filenames, { allowEmpty: true }) .pipe(rename(path => { - path.basename = setReleaseFilename(path.basename, { - replaceWhitespace: true - }); + path.basename = setReleaseFilename(path.basename); })) .pipe(gulp.dest('./dist')) .on('end', resolve); }); - - /* - return builder.build({ - targets: builder.Platform.LINUX.createTarget(["deb", "AppImage"], builder.Arch.ia32, builder.Arch.x64), - config - }).then((filenames) => { - return gulp.src(filenames, { allowEmpty: true }) - .pipe(rename(function (path) { - path.basename = setReleaseFilename(path.basename, { - replaceWhitespace: true - }); - })) - .pipe(gulp.dest('./dist')); - }).then(() => { - // Wait for the files to be written to disk and closed. - return delay(10000); - });*/ }); /** Publish the artifacts in /dist/ to GitHub */ gulp.task('publish', async () => { - Object.keys(process.env).forEach(key => { - console.log(`${key}: ${process.env[key]}`); - }); const { publishFiles } = common; const filesToPublish = getFilesFromDist(); await publishFiles(filesToPublish); @@ -78,6 +56,7 @@ function getFilesFromDist(options = {}) { return filelist; } +/** Sets the packaged artifact filename */ function setReleaseFilename(filename, options = {}) { const { extend } = common; options = extend({}, { From 54be615a67d82f9d1459b26a4fe0544ffb622e73 Mon Sep 17 00:00:00 2001 From: Tony Anziano Date: Tue, 9 Oct 2018 12:27:37 -0700 Subject: [PATCH 13/35] WIP on Windows Build Refactoring. --- packages/app/main/gulpfile.common.js | 9 +- packages/app/main/gulpfile.linux.js | 8 +- packages/app/main/gulpfile.windows.js | 138 ++++++++++++++++++++++++++ packages/app/main/package.json | 2 +- 4 files changed, 151 insertions(+), 6 deletions(-) diff --git a/packages/app/main/gulpfile.common.js b/packages/app/main/gulpfile.common.js index f8b100102..e8c0b6b41 100644 --- a/packages/app/main/gulpfile.common.js +++ b/packages/app/main/gulpfile.common.js @@ -109,10 +109,17 @@ async function publishFiles(filelist) { .then(() => errorlist.forEach(err => console.error(err))); } +/** Hashes a file asynchronously */ +function hashFileAsync(filename, algo = 'sha512', encoding = 'base64') { + var builderUtil = require('builder-util'); + return builderUtil.hashFile(filename, algo, encoding); +} + module.exports = { + extend, getConfig, getEnvironmentVar, getElectronMirrorUrl, - extend, + hashFileAsync, publishFiles }; diff --git a/packages/app/main/gulpfile.linux.js b/packages/app/main/gulpfile.linux.js index 1926e183b..fdbf173a8 100644 --- a/packages/app/main/gulpfile.linux.js +++ b/packages/app/main/gulpfile.linux.js @@ -7,15 +7,15 @@ const packageJson = require('./package.json'); */ gulp.task('package', async () => { const { getElectronMirrorUrl, getConfig } = common; - var rename = require('gulp-rename'); - var builder = require('electron-builder'); + const rename = require('gulp-rename'); + const builder = require('electron-builder'); const config = getConfig('linux'); console.log(`Electron mirror: ${getElectronMirrorUrl()}`); - // create packaged artifacts + // create build artifacts const filenames = await builder.build({ - targets: builder.Platform.LINUX.createTarget(["deb", "AppImage"], builder.Arch.ia32, builder.Arch.x64), + targets: builder.Platform.LINUX.createTarget(['deb', 'AppImage'], builder.Arch.ia32, builder.Arch.x64), config }); diff --git a/packages/app/main/gulpfile.windows.js b/packages/app/main/gulpfile.windows.js index e69de29bb..725a3c9ea 100644 --- a/packages/app/main/gulpfile.windows.js +++ b/packages/app/main/gulpfile.windows.js @@ -0,0 +1,138 @@ +const common = require('./gulpfile.common.js'); + +/** Package the emulator using electron-builder */ +gulp.task('stage', async () => { + const { getConfig, getElectronMirrorUrl } = common; + const builder = require('electron-builder'); + const config = getConfig('windows', 'dir'); + + console.log(`Electron mirror: ${getElectronMirrorUrl()}`); + + // create build artifacts + await builder.build({ + targets: builder.Platform.WINDOWS.createTarget(['dir'], builder.Arch.ia32, builder.Arch.x64), + config + }); +}); + +/** Creates the emulator binaries */ +gulp.task('redist:binaries', async () => { + const { getConfig, getElectronMirrorUrl } = common; + var rename = require('gulp-rename'); + var builder = require('electron-builder'); + const config = getConfig("windows", "nsis"); + + console.log(`Electron mirror: ${getElectronMirrorUrl()}`); + + // create build artifacts + const filenames = await builder.build({ + targets: builder.Platform.WINDOWS.createTarget(["nsis"], builder.Arch.ia32), + config, + prepackaged: './dist/win-ia32-unpacked' + }); + + // rename and move the files to the /dist/ directory + await new Promise(resolve => { + gulp + .src(filenames, { allowEmpty: true }) + .pipe(rename(path => { + path.basename = setReleaseFilename(path.basename); + })) + .pipe(gulp.dest('./dist')) + .on('end', resolve); + }); + + /*return builder.build({ + targets: builder.Platform.WINDOWS.createTarget(["nsis"], builder.Arch.ia32), + config, + prepackaged: './dist/win-ia32-unpacked' + }).then((filenames) => { + return gulp.src(filenames, { allowEmpty: true }) + .pipe(rename(function (path) { + path.basename = setReleaseFilename(path.basename, { + replaceWhitespace: true + }); + })) + .pipe(gulp.dest('./dist')); + }).then(() => { + // Wait for the files to be written to disk and closed. + return delay(10000); + });*/ +}); + +/** Writes the build metadata to latest.yml */ +gulp.task('redist:metadata-only', async () => { + const { getConfig, hashFileAsync } = common; + const config = getConfig('windows', 'nsis'); + const releaseFilename = config.nsis.artifactName.replace('${version}', pjson.version); + const sha512 = await hashFileAsync(`./dist/${releaseFilename}`); + const sha2 = await hashFileAsync(`./dist/${releaseFilename}`, 'sha256', 'hex'); + const releaseDate = new Date().toISOString(); + + writeYamlMetadataFile( + releaseFilename, + 'latest.yml', + './dist', + sha512, + releaseDate, + { sha2 } + ); + + /* + return Promise.all([sha512, sha2]) + .then((values) => { + writeYamlMetadataFile(releaseFilename, 'latest.yml', './dist', values[0], releaseDate, { sha2: values[1] }); + });*/ +}); + +/** Creates the emulator binaries and creates the metadata .yml file */ +gulp.task('redist', + gulp.series('redist:binaries', 'redist:metadata-only') +); + +/** Sets the packaged artifact filename */ +function setReleaseFilename(filename, options = {}) { + const { extend } = common; + options = extend({}, { + lowerCase: true, + replaceWhitespace: true, + fixBasename: true, + replaceName: false, + srcName: null, + dstName: null + }, + options + ); + if (options.replaceName && options.srcName && options.dstName) { + filename = filename.replace(options.srcName, options.dstName); + } + if (options.lowerCase) { + filename = filename.toLowerCase(); + } + if (options.replaceWhitespace) { + filename = filename.replace(/\s/g, '-'); + } + if (options.fixBasename) { + // renames build artifacts like 'bot-framework_{version}.*' or 'main_{version}.*' + // to '{package name in package.json}_{version}.*' + filename = filename.replace(/(bot[-|\s]framework)?(main)?/, packageJson.packagename); + } + return filename; +} + +/** Writes the .yml metadata file */ +function writeYamlMetadataFile(releaseFilename, yamlFilename, path, fileHash, releaseDate, extra = {}) { + var fsp = require('fs-extra'); + var yaml = require('js-yaml'); + + const ymlInfo = { + version: pjson.version, + releaseDate: releaseDate, + githubArtifactName: releaseFilename, + path: releaseFilename, + sha512: fileHash + }; + const obj = extend({}, ymlInfo, extra); + const ymlStr = yaml.safeDump(obj); + fsp.writeFileSync(`./${path}/${yamlFilename}`, ymlStr); +} diff --git a/packages/app/main/package.json b/packages/app/main/package.json index 833d91390..e264fac41 100644 --- a/packages/app/main/package.json +++ b/packages/app/main/package.json @@ -1,7 +1,7 @@ { "name": "@bfemulator/main", "packagename": "Botframework-Emulator", - "version": "4.0.0-preview-linux-test", + "version": "4.0.0-preview-windows-test", "private": true, "description": "Development tool for the Microsoft Bot Framework. Allows developers to test and debug bots on localhost.", "main": "./app/server/main.js", From 9ab890a1e4d668ef0c95d487e38c6babd282d583 Mon Sep 17 00:00:00 2001 From: Tony Anziano Date: Tue, 9 Oct 2018 13:54:32 -0700 Subject: [PATCH 14/35] Added missing gulp import. --- packages/app/main/gulpfile.windows.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/app/main/gulpfile.windows.js b/packages/app/main/gulpfile.windows.js index 725a3c9ea..a8cbee89a 100644 --- a/packages/app/main/gulpfile.windows.js +++ b/packages/app/main/gulpfile.windows.js @@ -1,4 +1,5 @@ const common = require('./gulpfile.common.js'); +const gulp = require('gulp'); /** Package the emulator using electron-builder */ gulp.task('stage', async () => { From 60d2569d5ed8d00564cb65bec438714ef50f16c5 Mon Sep 17 00:00:00 2001 From: Tony Anziano Date: Tue, 9 Oct 2018 16:04:58 -0700 Subject: [PATCH 15/35] Fixed missing packageJson reference. --- packages/app/main/gulpfile.windows.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/app/main/gulpfile.windows.js b/packages/app/main/gulpfile.windows.js index a8cbee89a..5a5ed8443 100644 --- a/packages/app/main/gulpfile.windows.js +++ b/packages/app/main/gulpfile.windows.js @@ -1,5 +1,6 @@ const common = require('./gulpfile.common.js'); const gulp = require('gulp'); +const packageJson = require('./package.json'); /** Package the emulator using electron-builder */ gulp.task('stage', async () => { From 09a4b784ff7162f36cbfb9b3cf3790f27151dedc Mon Sep 17 00:00:00 2001 From: Tony Anziano Date: Tue, 9 Oct 2018 16:29:00 -0700 Subject: [PATCH 16/35] Fixed incorrect package.json reference.' --- packages/app/main/gulpfile.windows.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/app/main/gulpfile.windows.js b/packages/app/main/gulpfile.windows.js index 5a5ed8443..4749308df 100644 --- a/packages/app/main/gulpfile.windows.js +++ b/packages/app/main/gulpfile.windows.js @@ -66,7 +66,7 @@ gulp.task('redist:binaries', async () => { gulp.task('redist:metadata-only', async () => { const { getConfig, hashFileAsync } = common; const config = getConfig('windows', 'nsis'); - const releaseFilename = config.nsis.artifactName.replace('${version}', pjson.version); + const releaseFilename = config.nsis.artifactName.replace('${version}', packageJson.version); const sha512 = await hashFileAsync(`./dist/${releaseFilename}`); const sha2 = await hashFileAsync(`./dist/${releaseFilename}`, 'sha256', 'hex'); const releaseDate = new Date().toISOString(); From 50853e99cab3a69c16fb05e60957f8e6ba2ead75 Mon Sep 17 00:00:00 2001 From: Tony Anziano Date: Tue, 9 Oct 2018 16:51:47 -0700 Subject: [PATCH 17/35] Fixed bad variable in utility function. --- packages/app/main/gulpfile.windows.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/app/main/gulpfile.windows.js b/packages/app/main/gulpfile.windows.js index 4749308df..f8f27a14b 100644 --- a/packages/app/main/gulpfile.windows.js +++ b/packages/app/main/gulpfile.windows.js @@ -17,7 +17,7 @@ gulp.task('stage', async () => { }); }); -/** Creates the emulator binaries */ +/** Creates the emulator installers */ gulp.task('redist:binaries', async () => { const { getConfig, getElectronMirrorUrl } = common; var rename = require('gulp-rename'); @@ -26,7 +26,7 @@ gulp.task('redist:binaries', async () => { console.log(`Electron mirror: ${getElectronMirrorUrl()}`); - // create build artifacts + // create installers const filenames = await builder.build({ targets: builder.Platform.WINDOWS.createTarget(["nsis"], builder.Arch.ia32), config, @@ -87,7 +87,7 @@ gulp.task('redist:metadata-only', async () => { });*/ }); -/** Creates the emulator binaries and creates the metadata .yml file */ +/** Creates the emulator installers and the metadata .yml file */ gulp.task('redist', gulp.series('redist:binaries', 'redist:metadata-only') ); @@ -128,8 +128,8 @@ function writeYamlMetadataFile(releaseFilename, yamlFilename, path, fileHash, re var yaml = require('js-yaml'); const ymlInfo = { - version: pjson.version, - releaseDate: releaseDate, + version: packageJson.version, + releaseDate, githubArtifactName: releaseFilename, path: releaseFilename, sha512: fileHash From cd2eeb572ff3088d9c6e217a72eaac8bee121374 Mon Sep 17 00:00:00 2001 From: Tony Anziano Date: Tue, 9 Oct 2018 17:42:31 -0700 Subject: [PATCH 18/35] Fixed extend import. --- packages/app/main/gulpfile.windows.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/app/main/gulpfile.windows.js b/packages/app/main/gulpfile.windows.js index f8f27a14b..b452e7ba3 100644 --- a/packages/app/main/gulpfile.windows.js +++ b/packages/app/main/gulpfile.windows.js @@ -124,6 +124,7 @@ function setReleaseFilename(filename, options = {}) { /** Writes the .yml metadata file */ function writeYamlMetadataFile(releaseFilename, yamlFilename, path, fileHash, releaseDate, extra = {}) { + const { extend } = common; var fsp = require('fs-extra'); var yaml = require('js-yaml'); From 3abb4fd08a592fd1373aba06cd62c41e37585972 Mon Sep 17 00:00:00 2001 From: Tony Anziano Date: Wed, 10 Oct 2018 10:51:43 -0700 Subject: [PATCH 19/35] WIP on refactoring mac build process. --- packages/app/main/gulpfile.common.js | 2 + packages/app/main/gulpfile.mac.js | 139 +++++++++++++++++++++++++++ packages/app/main/package.json | 2 +- 3 files changed, 142 insertions(+), 1 deletion(-) diff --git a/packages/app/main/gulpfile.common.js b/packages/app/main/gulpfile.common.js index e8c0b6b41..5daba486e 100644 --- a/packages/app/main/gulpfile.common.js +++ b/packages/app/main/gulpfile.common.js @@ -120,6 +120,8 @@ module.exports = { getConfig, getEnvironmentVar, getElectronMirrorUrl, + githubAccountName, + githubRepoName, hashFileAsync, publishFiles }; diff --git a/packages/app/main/gulpfile.mac.js b/packages/app/main/gulpfile.mac.js index e69de29bb..25e7ac703 100644 --- a/packages/app/main/gulpfile.mac.js +++ b/packages/app/main/gulpfile.mac.js @@ -0,0 +1,139 @@ +const gulp = require('gulp'); +const common = require('./gulpfile.common.js'); +const packageJson = require('./package.json'); + +/** Package the emulator using electron-builder */ +gulp.task('stage', async () => { + const { getElectronMirrorUrl, getConfig } = common; + const builder = require('electron-builder'); + const config = getConfig('mac', 'dir'); + + console.log(`Electron mirror: ${getElectronMirrorUrl()}`); + + // create build artifacts + await builder.build({ + targets: builder.Platform.MAC.createTarget(['dir']), + config + }); +}); + +/** Creates the emulator installers */ +gulp.task('redist:binaries', async () => { + const { getElectronMirrorUrl, getConfig } = common; + const rename = require('gulp-rename'); + const builder = require('electron-builder'); + const config = getConfig(mac); + + console.log(`Electron mirror: ${getElectronMirrorUrl()}`); + + // create installers + const filenames = await builder.build({ + targets: builder.Platform.MAC.createTarget([zip, dmg]), + config, + prepackaged: './dist/mac' + }); + + // rename and move the files to the /dist/ directory + await new Promise(resolve => { + gulp + .src(filenames, { allowEmpty: true }) + .pipe(rename(path => { + path.basename = setReleaseFilename(path.basename); + })) + .pipe(gulp.dest('./dist')) + .on('end', resolve); + }); + + /*return builder.build({ + targets: builder.Platform.MAC.createTarget([zip, dmg]), + config, + prepackaged: './dist/mac' + }).then((filenames) => { + return gulp.src(filenames, { allowEmpty: true }) + .pipe(rename(function (path) { + path.basename = setReleaseFilename(path.basename, { + replaceWhitespace: true, + fixMacBinaryNames: true + }); + })) + .pipe(gulp.dest('./dist')); + }).then(() => { + // Wait for the files to be written to disk and closed. + return delay(10000); + });*/ +}); + +/** Creates the .yml and .json metadata files */ +gulp.task('redist:metadata-only', async () => { + const { hashFileAsync } = common; + const releaseFilename = `${packageJson.packagename}-${packageJson.version}-mac.zip`; + const releaseHash = await hashFileAsync(`./dist/${releaseFilename}`); + const releaseDate = new Date().toISOString(); + + writeJsonMetadataFile(releaseFilename, 'latest-mac.json', './dist', releaseDate); + writeYamlMetadataFile(releaseFilename, 'latest-mac.yml', './dist', releaseHash, releaseDate); +}); + +/** Sets the packaged artifact filenames */ +function setReleaseFilename(filename, options = {}) { + const { extend } = common; + options = extend({}, { + lowerCase: true, + replaceWhitespace: true, + fixBasename: true, + replaceName: false, + srcName: null, + dstName: null + }, + options); + if (options.replaceName && options.srcName && options.dstName) { + filename = filename.replace(options.srcName, options.dstName); + } + if (options.lowerCase) { + filename = filename.toLowerCase(); + } + if (options.replaceWhitespace) { + filename = filename.replace(/\s/g, '-'); + } + if (options.fixBasename) { + // renames build artifacts like 'bot-framework_{version}.*' or 'main_{version}.*' + // to '{package name in package.json}_{version}.*' + filename = filename.replace(/(bot[-|\s]framework)?(main)?/, packageJson.packagename); + } + // "Bot Framework Emulator-{version}.*" is being renamed to "Botframework-Emulator-emulator-{version}.*" + // This resolves that issue + filename = filename.replace(/Botframework-Emulator-emulator/, packageJson.packagename); + + return filename; +} + +/** Writes the .yml metadata file */ +function writeYamlMetadataFile(releaseFilename, yamlFilename, path, fileHash, releaseDate, extra = {}) { + const { extend } = common; + const fsp = require('fs-extra'); + const yaml = require('js-yaml'); + + const ymlInfo = { + version: packageJson.version, + releaseDate, + githubArtifactName: releaseFilename, + path: releaseFilename, + sha512: fileHash + }; + const obj = extend({}, ymlInfo, extra); + const ymlStr = yaml.safeDump(obj); + fsp.writeFileSync(`./${path}/${yamlFilename}`, ymlStr); +} + +/** Writes the .json metadata file */ +function writeJsonMetadataFile(releaseFilename, jsonFilename, path, releaseDate) { + const fsp = require('fs-extra'); + const { githubAccountName, githubRepoName } = common; + + const jsonInfo = { + version: packageJson.version, + releaseDate, + url: `https://github.com/${githubAccountName}/${githubRepoName}/releases/v${packageJson.version}/${releaseFilename}` + }; + fsp.outputJsonSync(`./${path}/${jsonFilename}`, jsonInfo, { spaces: 2 }); +} diff --git a/packages/app/main/package.json b/packages/app/main/package.json index e264fac41..da0405b22 100644 --- a/packages/app/main/package.json +++ b/packages/app/main/package.json @@ -1,7 +1,7 @@ { "name": "@bfemulator/main", "packagename": "Botframework-Emulator", - "version": "4.0.0-preview-windows-test", + "version": "4.0.0-preview-mac-test", "private": true, "description": "Development tool for the Microsoft Bot Framework. Allows developers to test and debug bots on localhost.", "main": "./app/server/main.js", From 857b9c7d9b06bb05769b8fda86d17859cf6d022f Mon Sep 17 00:00:00 2001 From: Tony Anziano Date: Wed, 10 Oct 2018 10:59:51 -0700 Subject: [PATCH 20/35] Fixed incorrect variable. --- packages/app/main/gulpfile.mac.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/app/main/gulpfile.mac.js b/packages/app/main/gulpfile.mac.js index 25e7ac703..f1a549f06 100644 --- a/packages/app/main/gulpfile.mac.js +++ b/packages/app/main/gulpfile.mac.js @@ -22,7 +22,7 @@ gulp.task('redist:binaries', async () => { const { getElectronMirrorUrl, getConfig } = common; const rename = require('gulp-rename'); const builder = require('electron-builder'); - const config = getConfig(mac); + const config = getConfig('mac'); console.log(`Electron mirror: ${getElectronMirrorUrl()}`); From a0c1c395d07eaebb59d92e248f511026f6285f72 Mon Sep 17 00:00:00 2001 From: Tony Anziano Date: Wed, 10 Oct 2018 11:43:34 -0700 Subject: [PATCH 21/35] Fixed string that should have been quoted. --- packages/app/main/gulpfile.mac.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/app/main/gulpfile.mac.js b/packages/app/main/gulpfile.mac.js index f1a549f06..9ee5d433c 100644 --- a/packages/app/main/gulpfile.mac.js +++ b/packages/app/main/gulpfile.mac.js @@ -28,7 +28,7 @@ gulp.task('redist:binaries', async () => { // create installers const filenames = await builder.build({ - targets: builder.Platform.MAC.createTarget([zip, dmg]), + targets: builder.Platform.MAC.createTarget(['zip', 'dmg']), config, prepackaged: './dist/mac' }); From 786b0ff62ba4cb81075e5a6f30f73eb81b87c33f Mon Sep 17 00:00:00 2001 From: Tony Anziano Date: Wed, 10 Oct 2018 12:23:36 -0700 Subject: [PATCH 22/35] Got rid of old master gulp file. --- packages/app/main/gulpfile.common.js | 64 +++ packages/app/main/gulpfile.js | 772 --------------------------- packages/app/main/gulpfile.mac.js | 18 - packages/app/main/package.json | 4 +- 4 files changed, 66 insertions(+), 792 deletions(-) delete mode 100644 packages/app/main/gulpfile.js diff --git a/packages/app/main/gulpfile.common.js b/packages/app/main/gulpfile.common.js index 5daba486e..1772acff0 100644 --- a/packages/app/main/gulpfile.common.js +++ b/packages/app/main/gulpfile.common.js @@ -1,4 +1,5 @@ const packageJson = require('./package.json'); +const gulp = require ('gulp'); const defaultElectronMirror = 'https://github.com/electron/electron/releases/download/v'; const defaultElectronVersion = packageJson.devDependencies["electron"]; @@ -6,6 +7,69 @@ const githubAccountName = "Microsoft"; const githubRepoName = "BotFramework-Emulator"; const appId = "F3C061A6-FE81-4548-82ED-C1171D9856BB"; +/** Copies extension json files into built */ +gulp.task('copy-extension-stubs', function () { + return gulp + .src('./src/extensions/**/*') + .pipe(gulp.dest('./app/extensions')); +}); + +/** Checks all files for missing GitHub copyright text and reports missing files */ +gulp.task('verify:copyright', function () { + const lernaRoot = '../../../'; + const lernaJson = require(join(lernaRoot, 'lerna.json')); + const files = lernaJson.packages.filter(p => !/\/custom-/.test(p)).map(dir => join(lernaRoot, dir, '**/*.@(js|jsx|ts|tsx)')); + const filesWithoutCopyright = []; + let count = 0; + let scanned = 0; + + return gulp + .src(files, { buffer: false }) + .pipe(through2( + (file, _, callback) => { + const filename = file.history[0]; + + count++; + + if ( + // TODO: Instead of using pattern, we should use .gitignore + !/[\\\/](build|built|lib|node_modules)[\\\/]/.test(filename) + && !file.isDirectory() + ) { + callback(null, file); + } else { + callback(); + } + } + )) + .pipe(buffer()) + .pipe(through2( + (file, _, callback) => { + const filename = file.history[0]; + const first1000 = file.contents.toString('utf8', 0, 1000); + + if (!~first1000.indexOf('Copyright (c) Microsoft Corporation')) { + filesWithoutCopyright.push(relative(process.cwd(), filename)); + } + + scanned++; + + callback(); + }, + callback => { + log.info(`Verified ${chalk.magenta(scanned)} out of ${chalk.magenta(count)} files with copyright header`); + + if (filesWithoutCopyright.length) { + log.error(chalk.red('Copyright header is missing from the following files:')); + filesWithoutCopyright.forEach(filename => log.error(chalk.magenta(filename))); + callback(new Error('missing copyright header')); + } else { + callback(); + } + } + )); +}); + /** Gets an environment variable value with the provided name */ function getEnvironmentVar(name, defaultValue = undefined) { return (process.env[name] === undefined) ? defaultValue : process.env[name] diff --git a/packages/app/main/gulpfile.js b/packages/app/main/gulpfile.js deleted file mode 100644 index 589863450..000000000 --- a/packages/app/main/gulpfile.js +++ /dev/null @@ -1,772 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// Licensed under the MIT license. -// -// Microsoft Bot Framework: http://botframework.com -// -// Bot Framework Emulator Github: -// https://github.com/Microsoft/BotFramwork-Emulator -// -// Copyright (c) Microsoft Corporation -// All rights reserved. -// -// MIT License: -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -const { join, relative } = require('path'); -const buffer = require('vinyl-buffer'); -const chalk = require('chalk'); -const gulp = require('gulp'); -const log = require('fancy-log'); -const pjson = require('./package.json'); -const shell = require('gulp-shell'); -const through2 = require('through2').obj; - -const defaultElectronMirror = 'https://github.com/electron/electron/releases/download/v'; -const defaultElectronVersion = pjson.devDependencies["electron"]; -const githubAccountName = "Microsoft"; -const githubRepoName = "BotFramework-Emulator"; -const appId = "F3C061A6-FE81-4548-82ED-C1171D9856BB"; - -//============================================================================ -// BUILD -//============================================================================ - -//---------------------------------------------------------------------------- -gulp.task('clean', function () { - const clean = require('gulp-clean'); - return gulp.src('./app/', { read: false, allowEmpty: true }) - .pipe(clean()); -}); - -//---------------------------------------------------------------------------- -gulp.task('copy-extension-stubs', function () { - return gulp - .src('./src/extensions/**/*') - .pipe(gulp.dest('./app/extensions')); -}); - -//============================================================================ -// GET-LICENSES -//============================================================================ - -//---------------------------------------------------------------------------- -gulp.task('get-licenses', function () { - const licenses = require('license-list'); - const source = require('vinyl-source-stream'); - const lerna = require('../../../lerna.json'); - const stream = source('../../../ThirdPartyLicenses.txt'); - - const formatLicense = (pkgInfo) => { - const formatLicenseFile = () => { - if (typeof pkgInfo.licenseFile === 'string') { - return pkgInfo.licenseFile.split(/\n/).map(line => `\t${line}`).join('\n'); - } else { - return '\tLICENSE file does not exist'; - } - } - return `${pkgInfo.name}@${pkgInfo.version} (${pkgInfo.license})\n\n${formatLicenseFile()}\n\n`; - } - - const tasks = lerna.packages.map(package => licenses(`../../../${package}`), { dev: false }); - - return Promise.all(tasks) - .then(values => { - const main = values[0]; - const client = values[1]; - const packages = { - ...main, - ...client - }; - const keys = Object.keys(packages).sort().filter(key => - !key.startsWith(`${pjson.name}@`) && - !key.startsWith('@bfemulator')) - keys.forEach(pkgId => { - const pkgInfo = packages[pkgId]; - stream.write(formatLicense(pkgInfo)); - }) - stream.end(); - stream.pipe(gulp.dest('.')); - }) - .catch(err => { - console.log(err) - }); -}); - -//============================================================================ -// STAGE -// Stages the application folder from which redistributables are built. -//============================================================================ - -//============================================================================ -// STAGE:WINDOWS - -//---------------------------------------------------------------------------- -gulp.task('stage:windows', function () { - var builder = require('electron-builder'); - const config = getConfig("windows", "dir"); - console.log(`Electron mirror: ${getElectronMirrorUrl()}`); - return builder.build({ - targets: builder.Platform.WINDOWS.createTarget(["dir"], builder.Arch.ia32, builder.Arch.x64), - config - }); -}); - -//============================================================================ -// STAGE:MAC - -//---------------------------------------------------------------------------- -gulp.task('stage:mac', function () { - var builder = require('electron-builder'); - const config = getConfig("mac", "dir"); - console.log(`Electron mirror: ${getElectronMirrorUrl()}`); - return builder.build({ - targets: builder.Platform.MAC.createTarget(["dir"]), - config - }); -}); - -//============================================================================ -// STAGE:LINUX - -//---------------------------------------------------------------------------- -gulp.task('stage:linux', function () { - var builder = require('electron-builder'); - const config = getConfig("linux", "dir"); - console.log(`Electron mirror: ${getElectronMirrorUrl()}`); - return builder.build({ - targets: builder.Platform.LINUX.createTarget(["dir"]), - config - }); -}); - -//============================================================================ -// REDIST -// Builds a redistributable from the staged application folder. -//============================================================================ - -//---------------------------------------------------------------------------- -function hashFileAsync(filename, algo = 'sha512', encoding = 'base64') { - var builderUtil = require('builder-util'); - return builderUtil.hashFile(filename, algo, encoding); -} - -//---------------------------------------------------------------------------- -function writeYamlMetadataFile(releaseFilename, yamlFilename, path, fileHash, releaseDate, extra = {}) { - var fsp = require('fs-extra'); - var yaml = require('js-yaml'); - - const ymlInfo = { - version: pjson.version, - releaseDate: releaseDate, - githubArtifactName: releaseFilename, - path: releaseFilename, - sha512: fileHash - }; - const obj = extend({}, ymlInfo, extra); - const ymlStr = yaml.safeDump(obj); - fsp.writeFileSync(`./${path}/${yamlFilename}`, ymlStr); -} - -//---------------------------------------------------------------------------- -function writeJsonMetadataFile(releaseFilename, jsonFilename, path, releaseDate) { - var fsp = require('fs-extra'); - - const jsonInfo = { - version: pjson.version, - releaseDate: releaseDate, - url: `https://github.com/${githubAccountName}/${githubRepoName}/releases/v${pjson.version}/${releaseFilename}` - }; - fsp.outputJsonSync(`./${path}/${jsonFilename}`, jsonInfo, { spaces: 2 }); -} - -//============================================================================ -// REDIST:WINDOWS-NSIS - -//---------------------------------------------------------------------------- -gulp.task('redist:windows-nsis:binaries', function () { - var rename = require('gulp-rename'); - var builder = require('electron-builder'); - const config = getConfig("windows", "nsis"); - console.log(`Electron mirror: ${getElectronMirrorUrl()}`); - return builder.build({ - targets: builder.Platform.WINDOWS.createTarget(["nsis"], builder.Arch.ia32), - config, - prepackaged: './dist/win-ia32-unpacked' - }).then((filenames) => { - return gulp.src(filenames, { allowEmpty: true }) - .pipe(rename(function (path) { - path.basename = setReleaseFilename(path.basename, { - replaceWhitespace: true - }); - })) - .pipe(gulp.dest('./dist')); - }).then(() => { - // Wait for the files to be written to disk and closed. - return delay(10000); - }); -}); - -//---------------------------------------------------------------------------- -gulp.task('redist:windows-nsis:metadata-only', function () { - const config = getConfig("windows", "nsis"); - const releaseFilename = config.nsis.artifactName.replace('${version}', pjson.version); - const sha512 = hashFileAsync(`./dist/${releaseFilename}`); - const sha2 = hashFileAsync(`./dist/${releaseFilename}`, 'sha256', 'hex'); - const releaseDate = new Date().toISOString(); - - return Promise.all([sha512, sha2]) - .then((values) => { - writeYamlMetadataFile(releaseFilename, 'latest.yml', './dist', values[0], releaseDate, { sha2: values[1] }); - }); -}); - -//---------------------------------------------------------------------------- -gulp.task('redist:windows-nsis:metadata', - gulp.series('redist:windows-nsis:binaries', 'redist:windows-nsis:metadata-only')); - -//---------------------------------------------------------------------------- -gulp.task('redist:windows-nsis', gulp.series('redist:windows-nsis:metadata')); - -//============================================================================ -// REDIST:WINDOWS-SQUIRREL - -//---------------------------------------------------------------------------- -gulp.task('redist:windows-squirrel', function () { - var rename = require('gulp-rename'); - var builder = require('electron-builder'); - const config = getConfig("windows", "squirrel"); - console.log(`Electron mirror: ${getElectronMirrorUrl()}`); - return builder.build({ - targets: builder.Platform.WINDOWS.createTarget(["squirrel"], builder.Arch.x64), - config, - prepackaged: './dist/win-ia32-unpacked' - }).then((filenames) => { - return gulp.src(filenames, { allowEmpty: true }) - .pipe(rename(function (path) { - path.basename = setReleaseFilename(path.basename, { - lowerCase: false, - replaceName: true, - replaceWhitespace: true, - srcName: config.productName, - dstName: config.squirrelWindows.name - }); - })) - .pipe(gulp.dest('./dist')); - }).then(() => { - // Wait for the files to be written to disk and closed. - return delay(10000); - }); -}); - -//============================================================================ -// REDIST:MAC - -//---------------------------------------------------------------------------- -gulp.task('redist:mac:binaries', function () { - var rename = require('gulp-rename'); - var builder = require('electron-builder'); - const config = getConfig("mac"); - console.log(`Electron mirror: ${getElectronMirrorUrl()}`); - return builder.build({ - targets: builder.Platform.MAC.createTarget(["zip", "dmg"]), - config, - prepackaged: './dist/mac' - }).then((filenames) => { - return gulp.src(filenames, { allowEmpty: true }) - .pipe(rename(function (path) { - path.basename = setReleaseFilename(path.basename, { - replaceWhitespace: true, - fixMacBinaryNames: true - }); - })) - .pipe(gulp.dest('./dist')); - }).then(() => { - // Wait for the files to be written to disk and closed. - return delay(10000); - }); -}); - -//---------------------------------------------------------------------------- -gulp.task('redist:mac:metadata-only', function () { - const releaseFilename = `${pjson.packagename}-${pjson.version}-mac.zip`; - const releaseHash = hashFileAsync(`./dist/${releaseFilename}`); - const releaseDate = new Date().toISOString(); - - writeJsonMetadataFile(releaseFilename, 'latest-mac.json', './dist', releaseDate); - return releaseHash.then((hashValue) => { - writeYamlMetadataFile(releaseFilename, 'latest-mac.yml', './dist', hashValue, releaseDate); - }); -}); - -//---------------------------------------------------------------------------- -gulp.task('redist:mac:metadata', - gulp.series('redist:mac:binaries', 'redist:mac:metadata-only')); - -//---------------------------------------------------------------------------- -gulp.task('redist:mac', gulp.series('redist:mac:metadata')); - -//============================================================================ -// REDIST:LINUX - -//---------------------------------------------------------------------------- -gulp.task('redist:linux', function () { - var rename = require('gulp-rename'); - var builder = require('electron-builder'); - const config = getConfig("linux"); - console.log(`Electron mirror: ${getElectronMirrorUrl()}`); - return builder.build({ - targets: builder.Platform.LINUX.createTarget(["deb", "AppImage"], builder.Arch.ia32, builder.Arch.x64), - config, - prepackaged: './dist/linux-unpacked' - }).then((filenames) => { - return gulp.src(filenames, { allowEmpty: true }) - .pipe(rename(function (path) { - path.basename = setReleaseFilename(path.basename, { - replaceWhitespace: true - }); - })) - .pipe(gulp.dest('./dist')); - }).then(() => { - // Wait for the files to be written to disk and closed. - return delay(10000); - }); -}); - -//============================================================================ -// PACKAGE -// Stages and builds redist in a single step. -//============================================================================ - -//============================================================================ -// PACKAGE:WINDOWS-NSIS - -//---------------------------------------------------------------------------- -gulp.task('package:windows-nsis:binaries', function () { - var rename = require('gulp-rename'); - var builder = require('electron-builder'); - const config = getConfig("windows", "nsis"); - console.log(`Electron mirror: ${getElectronMirrorUrl()}`); - return builder.build({ - targets: builder.Platform.WINDOWS.createTarget(["nsis"], builder.Arch.ia32, builder.Arch.x64), - config - }).then((filenames) => { - return gulp.src(filenames, { allowEmpty: true }) - .pipe(rename(function (path) { - path.basename = setReleaseFilename(path.basename, { - replaceWhitespace: true - }); - })) - .pipe(gulp.dest('./dist')); - }).then(() => { - // Wait for the files to be written to disk and closed. - return delay(10000); - }); -}); - -//---------------------------------------------------------------------------- -gulp.task('package:windows-nsis:metadata', gulp.series('package:windows-nsis:binaries', function () { - const config = getConfig("windows", "nsis"); - const releaseFilename = `${config.productName}-Setup-${pjson.version}.exe`; - const sha512 = hashFileAsync(`./dist/${releaseFilename}`); - const sha2 = hashFileAsync(`./dist/${releaseFilename}`, 'sha256', 'hex'); - const releaseDate = new Date().toISOString(); - - return Promise.all([sha512, sha2]) - .then((values) => { - writeYamlMetadataFile(releaseFilename, 'latest.yml', './dist', values[0], releaseDate, { sha2: values[1] }); - }); -})); - -//---------------------------------------------------------------------------- -gulp.task('package:windows-nsis', gulp.series('package:windows-nsis:metadata')); - -//============================================================================ -// PACKAGE:WINDOWS-SQUIRREL - -//---------------------------------------------------------------------------- -gulp.task('package:windows-squirrel', function () { - var rename = require('gulp-rename'); - var builder = require('electron-builder'); - const config = getConfig("windows", "squirrel"); - console.log(`Electron mirror: ${getElectronMirrorUrl()}`); - return builder.build({ - targets: builder.Platform.WINDOWS.createTarget(["squirrel"], builder.Arch.x64), - config - }).then((filenames) => { - return gulp.src(filenames, { allowEmpty: true }) - .pipe(rename(function (path) { - path.basename = setReleaseFilename(path.basename, { - lowerCase: false, - replaceName: true, - replaceWhitespace: true, - srcName: config.productName, - dstName: config.squirrelWindows.name - }); - })) - .pipe(gulp.dest('./dist')); - }).then(() => { - // Wait for the files to be written to disk and closed. - return delay(10000); - }); -}); - -//============================================================================ -// PACKAGE:MAC - -//---------------------------------------------------------------------------- -gulp.task('package:mac:binaries', function () { - var rename = require('gulp-rename'); - var builder = require('electron-builder'); - const config = getConfig("mac"); - console.log(`Electron mirror: ${getElectronMirrorUrl()}`); - return builder.build({ - targets: builder.Platform.MAC.createTarget(["zip"]), - config - }).then((filenames) => { - return gulp.src(filenames, { allowEmpty: true }) - .pipe(rename(function (path) { - path.basename = setReleaseFilename(path.basename, { - replaceWhitespace: true - }); - })) - .pipe(gulp.dest('./dist')); - }).then(() => { - // Wait for the files to be written to disk and closed. - return delay(10000); - }); -}); - -//---------------------------------------------------------------------------- -gulp.task('package:mac:metadata', gulp.series('package:mac:binaries', function () { - const config = getConfig("mac"); - const releaseFilename = `${config.productName}-${pjson.version}-mac.zip`; - const releaseHash = hashFileAsync(`./dist/${releaseFilename}`); - const releaseDate = new Date().toISOString(); - - writeJsonMetadataFile(releaseFilename, 'latest-mac.json', './dist', releaseDate); - return releaseHash.then((hashValue) => { - writeYamlMetadataFile(releaseFilename, 'latest-mac.yml', './dist', hashValue, releaseDate); - }); -})); - -//---------------------------------------------------------------------------- -gulp.task('package:mac', gulp.series('package:mac:metadata')); - -//============================================================================ -// PACKAGE:LINUX - -//---------------------------------------------------------------------------- -gulp.task('package:linux', function () { - var rename = require('gulp-rename'); - var builder = require('electron-builder'); - const config = getConfig("linux"); - console.log(`Electron mirror: ${getElectronMirrorUrl()}`); - return builder.build({ - targets: builder.Platform.LINUX.createTarget(["deb", "AppImage"], builder.Arch.ia32, builder.Arch.x64), - config - }).then((filenames) => { - return gulp.src(filenames, { allowEmpty: true }) - .pipe(rename(function (path) { - path.basename = setReleaseFilename(path.basename, { - replaceWhitespace: true - }); - })) - .pipe(gulp.dest('./dist')); - }).then(() => { - // Wait for the files to be written to disk and closed. - return delay(10000); - }); -}); - - -//============================================================================ -// PUBLISH -//============================================================================ - -//---------------------------------------------------------------------------- -function publishFiles(filelist) { - var CancellationToken = require('electron-builder-http/out/CancellationToken').CancellationToken; - var GitHubPublisher = require('electron-publish/out/gitHubPublisher').GitHubPublisher; - var publishConfig = replacePublishEnvironmentVars(require('./scripts/config/publish.json')); - - const context = { - cancellationToken: new CancellationToken(), - progress: null - }; - const publisher = new GitHubPublisher( - context, - publishConfig, - pjson.version, { - publish: "always", - draft: true, - prerelease: false - }); - const errorlist = []; - - const uploads = filelist.map(file => { - return publisher.upload({ file }) - .catch((err) => { - errorlist.push(err.response ? `Failed to upload ${file}, http status code ${err.response.statusCode}` : err); - return Promise.resolve(); - }); - }); - - return Promise.all(uploads) - .then(() => errorlist.forEach((err) => console.error(err))); -} - -//---------------------------------------------------------------------------- -gulp.task('publish:windows-nsis', function () { - const filelist = getFileList("windows", "nsis"); - return publishFiles(filelist); -}); - -//---------------------------------------------------------------------------- -gulp.task('publish:windows-squirrel', function () { - const basename = require('./scripts/config/windows-squirrel.json').squirrelWindows.name; - const filelist = getFileList("windows", "squirrel", { - basename, - }); - return publishFiles(filelist); -}); - -//---------------------------------------------------------------------------- -gulp.task('publish:mac', function () { - const filelist = getFileList("mac"); - return publishFiles(filelist); -}); - -//---------------------------------------------------------------------------- -gulp.task('publish:linux', function () { - const filelist = getFileList("linux"); - return publishFiles(filelist); -}); - - -//============================================================================ -// VERIFY:COPYRIGHT - -//---------------------------------------------------------------------------- -gulp.task('verify:copyright', function () { - const lernaRoot = '../../../'; - const lernaJson = require(join(lernaRoot, 'lerna.json')); - const files = lernaJson.packages.filter(p => !/\/custom-/.test(p)).map(dir => join(lernaRoot, dir, '**/*.@(js|jsx|ts|tsx)')); - const filesWithoutCopyright = []; - let count = 0; - let scanned = 0; - - return gulp - .src(files, { buffer: false }) - .pipe(through2( - (file, _, callback) => { - const filename = file.history[0]; - - count++; - - if ( - // TODO: Instead of using pattern, we should use .gitignore - !/[\\\/](build|built|lib|node_modules)[\\\/]/.test(filename) - && !file.isDirectory() - ) { - callback(null, file); - } else { - callback(); - } - } - )) - .pipe(buffer()) - .pipe(through2( - (file, _, callback) => { - const filename = file.history[0]; - const first1000 = file.contents.toString('utf8', 0, 1000); - - if (!~first1000.indexOf('Copyright (c) Microsoft Corporation')) { - filesWithoutCopyright.push(relative(process.cwd(), filename)); - } - - scanned++; - - callback(); - }, - callback => { - log.info(`Verified ${chalk.magenta(scanned)} out of ${chalk.magenta(count)} files with copyright header`); - - if (filesWithoutCopyright.length) { - log.error(chalk.red('Copyright header is missing from the following files:')); - filesWithoutCopyright.forEach(filename => log.error(chalk.magenta(filename))); - callback(new Error('missing copyright header')); - } else { - callback(); - } - } - )); -}); - -//============================================================================ -// UTILS -//============================================================================ - -//---------------------------------------------------------------------------- -function getConfig(platform, target) { - return extend({}, - replacePackageEnvironmentVars(require('./scripts/config/common.json')), - replacePackageEnvironmentVars(require(`./scripts/config/${platform}.json`)), - (target ? replacePackageEnvironmentVars(require(`./scripts/config/${platform}-${target}.json`)) : {}) - ); -} - -//---------------------------------------------------------------------------- -function getFileList(platform, target, options = {}) { - options = extend({}, { - basename: pjson.packagename, - version: pjson.version, - }, options); - const path = './dist'; - const filelist = []; - switch (`${platform}-${target || ''}`) { - case "windows-nsis": - filelist.push(`${path}/latest.yml`); - filelist.push(`${path}/${options.basename}-setup-${options.version}.exe`); - //filelist.push(`${path}/${options.basename}-${options.version}-win.zip`); - //filelist.push(`${path}/${options.basename}-${options.version}-ia32-win.zip`); - break; - - case "windows-squirrel": - filelist.push(`${path}/RELEASES`); - //filelist.push(`${options.path}${options.basename}-Setup-${options.version}.exe`); - filelist.push(`${path}/${options.basename}-${options.version}-full.nupkg`); - break; - - case "mac-": - filelist.push(`${path}/latest-mac.yml`); - filelist.push(`${path}/latest-mac.json`); - filelist.push(`${path}/${options.basename}-${options.version}-mac.zip`); - filelist.push(`${path}/${options.basename}-${options.version}.dmg`); - break; - - case "linux-": - filelist.push(`${path}/${options.basename}-${options.version}-i386.AppImage`); - filelist.push(`${path}/${options.basename}-${options.version}-x86_64.AppImage`); - filelist.push(`${path}/${options.basename}_${options.version}_i386.deb`); - filelist.push(`${path}/${options.basename}_${options.version}_amd64.deb`); - break; - } - return filelist; -} - -//---------------------------------------------------------------------------- -function setReleaseFilename(filename, options = {}) { - options = extend({}, { - lowerCase: true, - replaceWhitespace: true, - fixBasename: true, - replaceName: false, - srcName: null, - dstName: null, - fixMacBinaryNames: false - }, - options); - if (options.replaceName && options.srcName && options.dstName) { - filename = filename.replace(options.srcName, options.dstName); - } - if (options.lowerCase) { - filename = filename.toLowerCase(); - } - if (options.replaceWhitespace) { - filename = filename.replace(/\s/g, '-'); - } - if (options.fixBasename) { - // renames build artifacts like 'bot-framework_{version}.*' or 'main_{version}.*' - // to '{package name in package.json}_{version}.*' - filename = filename.replace(/(bot[-|\s]framework)?(main)?/, pjson.packagename); - } - if (options.fixMacBinaryNames) { - // "Bot Framework Emulator-{version}.*" is being renamed to "Botframework-Emulator-emulator-{version}.*" - // This resolves that issue - filename = filename.replace(/Botframework-Emulator-emulator/, pjson.packagename); - } - return filename; -} - -//---------------------------------------------------------------------------- -function getEnvironmentVar(name, defaultValue = undefined) { - return (process.env[name] === undefined) ? defaultValue : process.env[name] -} - -//---------------------------------------------------------------------------- -function replaceEnvironmentVar(str, name, defaultValue = undefined) { - let value = getEnvironmentVar(name, defaultValue); - if (value === undefined) - throw new Error(`Required environment variable missing: ${name}`); - return str.replace(new RegExp('\\${' + name + '}', 'g'), value); -} - -//---------------------------------------------------------------------------- -function replacePackageEnvironmentVars(obj) { - let str = JSON.stringify(obj); - str = replaceEnvironmentVar(str, "ELECTRON_MIRROR", defaultElectronMirror); - str = replaceEnvironmentVar(str, "ELECTRON_VERSION", defaultElectronVersion); - str = replaceEnvironmentVar(str, "appId", appId); - return JSON.parse(str); -} - -//---------------------------------------------------------------------------- -function replacePublishEnvironmentVars(obj) { - let str = JSON.stringify(obj); - str = replaceEnvironmentVar(str, "GH_TOKEN"); - str = replaceEnvironmentVar(str, "githubAccountName", githubAccountName); - str = replaceEnvironmentVar(str, "githubRepoName", githubRepoName); - return JSON.parse(str); -} - -//---------------------------------------------------------------------------- -function getElectronMirrorUrl() { - return `${getEnvironmentVar("ELECTRON_MIRROR", defaultElectronMirror)}${getEnvironmentVar("ELECTRON_VERSION", defaultElectronVersion)}`; -} - -//---------------------------------------------------------------------------- -function delay(ms, result) { - return new Promise((resolve, reject) => setTimeout(resolve, ms, result)); -} - -//---------------------------------------------------------------------------- -function extend1(destination, source) { - for (var property in source) { - if (source[property] && source[property].constructor && - source[property].constructor === Object) { - destination[property] = destination[property] || {}; - arguments.callee(destination[property], source[property]); - } else { - destination[property] = source[property]; - } - } - return destination; -}; - -//---------------------------------------------------------------------------- -function extend(...sources) { - let output = {}; - sources.forEach(source => { - extend1(output, source); - }); - return output; -} diff --git a/packages/app/main/gulpfile.mac.js b/packages/app/main/gulpfile.mac.js index 9ee5d433c..e80c0f1ca 100644 --- a/packages/app/main/gulpfile.mac.js +++ b/packages/app/main/gulpfile.mac.js @@ -43,24 +43,6 @@ gulp.task('redist:binaries', async () => { .pipe(gulp.dest('./dist')) .on('end', resolve); }); - - /*return builder.build({ - targets: builder.Platform.MAC.createTarget([zip, dmg]), - config, - prepackaged: './dist/mac' - }).then((filenames) => { - return gulp.src(filenames, { allowEmpty: true }) - .pipe(rename(function (path) { - path.basename = setReleaseFilename(path.basename, { - replaceWhitespace: true, - fixMacBinaryNames: true - }); - })) - .pipe(gulp.dest('./dist')); - }).then(() => { - // Wait for the files to be written to disk and closed. - return delay(10000); - });*/ }); /** Creates the .yml and .json metadata files */ diff --git a/packages/app/main/package.json b/packages/app/main/package.json index da0405b22..b4f13fb84 100644 --- a/packages/app/main/package.json +++ b/packages/app/main/package.json @@ -8,14 +8,14 @@ "homepage": "https://github.com/Microsoft/BotFramework-Emulator", "scripts": { "build": "run-s lint build:electron", - "build:electron": "babel ./src --out-dir app/server --extensions \".ts,.tsx\" --ignore \"**/*.spec.ts\" && gulp copy-extension-stubs", + "build:electron": "babel ./src --out-dir app/server --extensions \".ts,.tsx\" --ignore \"**/*.spec.ts\" && gulp --gulpfile gulpfile.common.js copy-extension-stubs", "lint": "tslint --project tsconfig.json", "start": "concurrently --kill-others --names \"electron,react-app\" --success first \"npm run start:electron:dev\" \"npm run start:react-app\"", "start:electron": "./node_modules/.bin/electron --inspect=7777 .", "start:electron:dev": "cross-env ELECTRON_TARGET_URL=http://localhost:3000/ npm run start:electron", "start:react-app": "cd ../client && npm start", "test": "jest", - "verify": "gulp verify:copyright" + "verify": "gulp --gulpfile gulpfile.common.js verify:copyright" }, "keywords": [ "microsoft", From 0569ca14869acce096e0b0adace3d8534795d0da Mon Sep 17 00:00:00 2001 From: Tony Anziano Date: Wed, 10 Oct 2018 12:34:56 -0700 Subject: [PATCH 23/35] Testing out artifact naming. --- packages/app/main/gulpfile.mac.js | 14 +++++++++++--- packages/app/main/package.json | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/app/main/gulpfile.mac.js b/packages/app/main/gulpfile.mac.js index e80c0f1ca..cdf09b724 100644 --- a/packages/app/main/gulpfile.mac.js +++ b/packages/app/main/gulpfile.mac.js @@ -58,7 +58,15 @@ gulp.task('redist:metadata-only', async () => { /** Sets the packaged artifact filenames */ function setReleaseFilename(filename, options = {}) { - const { extend } = common; + const { getEnvironmentVar } = common; + const releaseVersion = getEnvironmentVar('EMU_VERSION', packageJson.version); + const releasePlatform = getEnvironmentVar('EMU_PLATFORM'); + if (!releasePlatform) { + throw new Error('Environment variable EMU_PLATFORM missing. Please retry with valid value.'); + } + const releaseName = `${packageJson.packagename}-${releaseVersion}-${releasePlatform}`; + + /*const { extend } = common; options = extend({}, { lowerCase: true, replaceWhitespace: true, @@ -84,9 +92,9 @@ function setReleaseFilename(filename, options = {}) { } // "Bot Framework Emulator-{version}.*" is being renamed to "Botframework-Emulator-emulator-{version}.*" // This resolves that issue - filename = filename.replace(/Botframework-Emulator-emulator/, packageJson.packagename); + filename = filename.replace(/Botframework-Emulator-emulator/, packageJson.packagename);*/ - return filename; + return releaseName; } /** Writes the .yml metadata file */ diff --git a/packages/app/main/package.json b/packages/app/main/package.json index b4f13fb84..3507f7afb 100644 --- a/packages/app/main/package.json +++ b/packages/app/main/package.json @@ -1,6 +1,6 @@ { "name": "@bfemulator/main", - "packagename": "Botframework-Emulator", + "packagename": "BotFramework-Emulator", "version": "4.0.0-preview-mac-test", "private": true, "description": "Development tool for the Microsoft Bot Framework. Allows developers to test and debug bots on localhost.", From bb2125da2f5911c1e6fbe59270b4cf44ba5c4aa6 Mon Sep 17 00:00:00 2001 From: Tony Anziano Date: Wed, 10 Oct 2018 12:46:48 -0700 Subject: [PATCH 24/35] WIP artifact naming. --- packages/app/main/gulpfile.mac.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/app/main/gulpfile.mac.js b/packages/app/main/gulpfile.mac.js index cdf09b724..9bb53edf4 100644 --- a/packages/app/main/gulpfile.mac.js +++ b/packages/app/main/gulpfile.mac.js @@ -48,7 +48,7 @@ gulp.task('redist:binaries', async () => { /** Creates the .yml and .json metadata files */ gulp.task('redist:metadata-only', async () => { const { hashFileAsync } = common; - const releaseFilename = `${packageJson.packagename}-${packageJson.version}-mac.zip`; + const releaseFilename = `${setReleaseFilename(null)}.zip`; const releaseHash = await hashFileAsync(`./dist/${releaseFilename}`); const releaseDate = new Date().toISOString(); From 93a068ab8b78579978d62c901e6c32d5baad9aaf Mon Sep 17 00:00:00 2001 From: Tony Anziano Date: Wed, 10 Oct 2018 15:28:19 -0700 Subject: [PATCH 25/35] Setting up nightly compatibility. --- packages/app/main/gulpfile.mac.js | 34 +++---------------------------- packages/app/main/package.json | 2 +- 2 files changed, 4 insertions(+), 32 deletions(-) diff --git a/packages/app/main/gulpfile.mac.js b/packages/app/main/gulpfile.mac.js index 9bb53edf4..27a6b5133 100644 --- a/packages/app/main/gulpfile.mac.js +++ b/packages/app/main/gulpfile.mac.js @@ -38,7 +38,7 @@ gulp.task('redist:binaries', async () => { gulp .src(filenames, { allowEmpty: true }) .pipe(rename(path => { - path.basename = setReleaseFilename(path.basename); + path.basename = getReleaseFileName(); })) .pipe(gulp.dest('./dist')) .on('end', resolve); @@ -48,7 +48,7 @@ gulp.task('redist:binaries', async () => { /** Creates the .yml and .json metadata files */ gulp.task('redist:metadata-only', async () => { const { hashFileAsync } = common; - const releaseFilename = `${setReleaseFilename(null)}.zip`; + const releaseFilename = `${getReleaseFileName()}.zip`; const releaseHash = await hashFileAsync(`./dist/${releaseFilename}`); const releaseDate = new Date().toISOString(); @@ -57,7 +57,7 @@ gulp.task('redist:metadata-only', async () => { }); /** Sets the packaged artifact filenames */ -function setReleaseFilename(filename, options = {}) { +function getReleaseFileName() { const { getEnvironmentVar } = common; const releaseVersion = getEnvironmentVar('EMU_VERSION', packageJson.version); const releasePlatform = getEnvironmentVar('EMU_PLATFORM'); @@ -66,34 +66,6 @@ function setReleaseFilename(filename, options = {}) { } const releaseName = `${packageJson.packagename}-${releaseVersion}-${releasePlatform}`; - /*const { extend } = common; - options = extend({}, { - lowerCase: true, - replaceWhitespace: true, - fixBasename: true, - replaceName: false, - srcName: null, - dstName: null - }, - options); - if (options.replaceName && options.srcName && options.dstName) { - filename = filename.replace(options.srcName, options.dstName); - } - if (options.lowerCase) { - filename = filename.toLowerCase(); - } - if (options.replaceWhitespace) { - filename = filename.replace(/\s/g, '-'); - } - if (options.fixBasename) { - // renames build artifacts like 'bot-framework_{version}.*' or 'main_{version}.*' - // to '{package name in package.json}_{version}.*' - filename = filename.replace(/(bot[-|\s]framework)?(main)?/, packageJson.packagename); - } - // "Bot Framework Emulator-{version}.*" is being renamed to "Botframework-Emulator-emulator-{version}.*" - // This resolves that issue - filename = filename.replace(/Botframework-Emulator-emulator/, packageJson.packagename);*/ - return releaseName; } diff --git a/packages/app/main/package.json b/packages/app/main/package.json index 3507f7afb..f5d5d16d8 100644 --- a/packages/app/main/package.json +++ b/packages/app/main/package.json @@ -1,7 +1,7 @@ { "name": "@bfemulator/main", "packagename": "BotFramework-Emulator", - "version": "4.0.0-preview-mac-test", + "version": "4.0.0-preview", "private": true, "description": "Development tool for the Microsoft Bot Framework. Allows developers to test and debug bots on localhost.", "main": "./app/server/main.js", From 8bc8ecfe67b4bc00d723a07e73acc5d981833e9b Mon Sep 17 00:00:00 2001 From: Tony Anziano Date: Wed, 10 Oct 2018 17:22:44 -0700 Subject: [PATCH 26/35] WIP nightly on linux. --- packages/app/main/gulpfile.linux.js | 55 +++++++++-------------------- packages/app/main/gulpfile.mac.js | 6 ++-- 2 files changed, 20 insertions(+), 41 deletions(-) diff --git a/packages/app/main/gulpfile.linux.js b/packages/app/main/gulpfile.linux.js index fdbf173a8..d74731314 100644 --- a/packages/app/main/gulpfile.linux.js +++ b/packages/app/main/gulpfile.linux.js @@ -24,7 +24,7 @@ gulp.task('package', async () => { gulp .src(filenames, { allowEmpty: true }) .pipe(rename(path => { - path.basename = setReleaseFilename(path.basename); + path.basename = getReleaseFilename(path.basename); })) .pipe(gulp.dest('./dist')) .on('end', resolve); @@ -39,49 +39,28 @@ gulp.task('publish', async () => { }); /** Returns the names of the packaged artifacts in /dist/ */ -function getFilesFromDist(options = {}) { - const { extend } = common; - options = extend({}, { - basename: packageJson.packagename, - version: packageJson.version, - }, options); +function getFilesFromDist() { const path = './dist'; + const baseName = getReleaseFilename(); const filelist = []; - filelist.push(`${path}/${options.basename}-${options.version}-i386.AppImage`); - filelist.push(`${path}/${options.basename}-${options.version}-x86_64.AppImage`); - filelist.push(`${path}/${options.basename}_${options.version}_i386.deb`); - filelist.push(`${path}/${options.basename}_${options.version}_amd64.deb`); + filelist.push(`${path}/${baseName}-i386.AppImage`); + filelist.push(`${path}/${baseName}-x86_64.AppImage`); + filelist.push(`${path}/${baseName}_i386.deb`); + filelist.push(`${path}/${baseName}_amd64.deb`); return filelist; } -/** Sets the packaged artifact filename */ -function setReleaseFilename(filename, options = {}) { - const { extend } = common; - options = extend({}, { - lowerCase: true, - replaceWhitespace: true, - fixBasename: true, - replaceName: false, - srcName: null, - dstName: null - }, - options - ); - if (options.replaceName && options.srcName && options.dstName) { - filename = filename.replace(options.srcName, options.dstName); +/** Sets the packaged artifact filenames */ +function getReleaseFilename() { + const { getEnvironmentVar } = common; + const releaseVersion = getEnvironmentVar('EMU_VERSION', packageJson.version); + const releasePlatform = getEnvironmentVar('EMU_PLATFORM'); + if (!releasePlatform) { + throw new Error('Environment variable EMU_PLATFORM missing. Please retry with valid value.'); } - if (options.lowerCase) { - filename = filename.toLowerCase(); - } - if (options.replaceWhitespace) { - filename = filename.replace(/\s/g, '-'); - } - if (options.fixBasename) { - // renames build artifacts like 'bot-framework_{version}.*' or 'main_{version}.*' - // to '{package name in package.json}_{version}.*' - filename = filename.replace(/(bot[-|\s]framework)?(main)?/, packageJson.packagename); - } - return filename; + const releaseName = `${packageJson.packagename}-${releaseVersion}-${releasePlatform}`; + + return releaseName; } diff --git a/packages/app/main/gulpfile.mac.js b/packages/app/main/gulpfile.mac.js index 27a6b5133..b2fbed3d1 100644 --- a/packages/app/main/gulpfile.mac.js +++ b/packages/app/main/gulpfile.mac.js @@ -38,7 +38,7 @@ gulp.task('redist:binaries', async () => { gulp .src(filenames, { allowEmpty: true }) .pipe(rename(path => { - path.basename = getReleaseFileName(); + path.basename = getReleaseFilename(); })) .pipe(gulp.dest('./dist')) .on('end', resolve); @@ -48,7 +48,7 @@ gulp.task('redist:binaries', async () => { /** Creates the .yml and .json metadata files */ gulp.task('redist:metadata-only', async () => { const { hashFileAsync } = common; - const releaseFilename = `${getReleaseFileName()}.zip`; + const releaseFilename = `${getReleaseFilename()}.zip`; const releaseHash = await hashFileAsync(`./dist/${releaseFilename}`); const releaseDate = new Date().toISOString(); @@ -57,7 +57,7 @@ gulp.task('redist:metadata-only', async () => { }); /** Sets the packaged artifact filenames */ -function getReleaseFileName() { +function getReleaseFilename() { const { getEnvironmentVar } = common; const releaseVersion = getEnvironmentVar('EMU_VERSION', packageJson.version); const releasePlatform = getEnvironmentVar('EMU_PLATFORM'); From fddefe1c28d65c959e1adfca4a7774243b974127 Mon Sep 17 00:00:00 2001 From: Tony Anziano Date: Wed, 10 Oct 2018 21:08:26 -0700 Subject: [PATCH 27/35] Linux publish is done in VSTS now. --- packages/app/main/gulpfile.common.js | 48 +------------------ packages/app/main/gulpfile.linux.js | 21 -------- packages/app/main/scripts/config/publish.json | 6 --- 3 files changed, 1 insertion(+), 74 deletions(-) delete mode 100644 packages/app/main/scripts/config/publish.json diff --git a/packages/app/main/gulpfile.common.js b/packages/app/main/gulpfile.common.js index 1772acff0..821000797 100644 --- a/packages/app/main/gulpfile.common.js +++ b/packages/app/main/gulpfile.common.js @@ -92,15 +92,6 @@ function replacePackageEnvironmentVars(obj) { return JSON.parse(str); } -/** Replaces a publishing-related environment variable */ -function replacePublishEnvironmentVars(obj) { - let str = JSON.stringify(obj); - str = replaceEnvironmentVar(str, "GH_TOKEN"); - str = replaceEnvironmentVar(str, "githubAccountName", githubAccountName); - str = replaceEnvironmentVar(str, "githubRepoName", githubRepoName); - return JSON.parse(str); -} - /** Returns the Electron Mirror URL from where electron is downloaded */ function getElectronMirrorUrl() { return `${getEnvironmentVar("ELECTRON_MIRROR", defaultElectronMirror)}${getEnvironmentVar("ELECTRON_VERSION", defaultElectronVersion)}`; @@ -137,42 +128,6 @@ function extend1(destination, source) { return destination; }; -/** Publishes files to GitHub - * @param {string[]} filelist List of filenames to publish -*/ -async function publishFiles(filelist) { - var CancellationToken = require('electron-builder-http/out/CancellationToken').CancellationToken; - var GitHubPublisher = require('electron-publish/out/gitHubPublisher').GitHubPublisher; - var publishConfig = replacePublishEnvironmentVars(require('./scripts/config/publish.json')); - - const context = { - cancellationToken: new CancellationToken(), - progress: null - }; - - const publisher = new GitHubPublisher( - context, - publishConfig, - packageJson.version, { - publish: "always", - draft: true, - prerelease: false - } - ); - const errorlist = []; - - const uploads = filelist.map(file => { - return publisher.upload({ file }) - .catch((err) => { - errorlist.push(err.response ? `Failed to upload ${file}, http status code ${err.response.statusCode}` : err); - return Promise.resolve(); - }); - }); - - return await Promise.all(uploads) - .then(() => errorlist.forEach(err => console.error(err))); -} - /** Hashes a file asynchronously */ function hashFileAsync(filename, algo = 'sha512', encoding = 'base64') { var builderUtil = require('builder-util'); @@ -186,6 +141,5 @@ module.exports = { getElectronMirrorUrl, githubAccountName, githubRepoName, - hashFileAsync, - publishFiles + hashFileAsync }; diff --git a/packages/app/main/gulpfile.linux.js b/packages/app/main/gulpfile.linux.js index d74731314..d5e50dcc7 100644 --- a/packages/app/main/gulpfile.linux.js +++ b/packages/app/main/gulpfile.linux.js @@ -31,27 +31,6 @@ gulp.task('package', async () => { }); }); -/** Publish the artifacts in /dist/ to GitHub */ -gulp.task('publish', async () => { - const { publishFiles } = common; - const filesToPublish = getFilesFromDist(); - await publishFiles(filesToPublish); -}); - -/** Returns the names of the packaged artifacts in /dist/ */ -function getFilesFromDist() { - const path = './dist'; - const baseName = getReleaseFilename(); - - const filelist = []; - filelist.push(`${path}/${baseName}-i386.AppImage`); - filelist.push(`${path}/${baseName}-x86_64.AppImage`); - filelist.push(`${path}/${baseName}_i386.deb`); - filelist.push(`${path}/${baseName}_amd64.deb`); - - return filelist; -} - /** Sets the packaged artifact filenames */ function getReleaseFilename() { const { getEnvironmentVar } = common; diff --git a/packages/app/main/scripts/config/publish.json b/packages/app/main/scripts/config/publish.json deleted file mode 100644 index 614028901..000000000 --- a/packages/app/main/scripts/config/publish.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "provider": "github", - "owner": "${githubAccountName}", - "repo": "${githubRepoName}", - "token": "${GH_TOKEN}" -} \ No newline at end of file From ce15cd09918c194d02fe9bf1a74247156883c7e3 Mon Sep 17 00:00:00 2001 From: Tony Anziano Date: Thu, 11 Oct 2018 14:29:32 -0700 Subject: [PATCH 28/35] WIP windows nightly. --- packages/app/main/gulpfile.windows.js | 60 +++++---------------------- 1 file changed, 10 insertions(+), 50 deletions(-) diff --git a/packages/app/main/gulpfile.windows.js b/packages/app/main/gulpfile.windows.js index b452e7ba3..cdf07f34c 100644 --- a/packages/app/main/gulpfile.windows.js +++ b/packages/app/main/gulpfile.windows.js @@ -38,28 +38,11 @@ gulp.task('redist:binaries', async () => { gulp .src(filenames, { allowEmpty: true }) .pipe(rename(path => { - path.basename = setReleaseFilename(path.basename); + path.basename = getReleaseFilename(); })) .pipe(gulp.dest('./dist')) .on('end', resolve); }); - - /*return builder.build({ - targets: builder.Platform.WINDOWS.createTarget(["nsis"], builder.Arch.ia32), - config, - prepackaged: './dist/win-ia32-unpacked' - }).then((filenames) => { - return gulp.src(filenames, { allowEmpty: true }) - .pipe(rename(function (path) { - path.basename = setReleaseFilename(path.basename, { - replaceWhitespace: true - }); - })) - .pipe(gulp.dest('./dist')); - }).then(() => { - // Wait for the files to be written to disk and closed. - return delay(10000); - });*/ }); /** Writes the build metadata to latest.yml */ @@ -79,12 +62,6 @@ gulp.task('redist:metadata-only', async () => { releaseDate, { sha2 } ); - - /* - return Promise.all([sha512, sha2]) - .then((values) => { - writeYamlMetadataFile(releaseFilename, 'latest.yml', './dist', values[0], releaseDate, { sha2: values[1] }); - });*/ }); /** Creates the emulator installers and the metadata .yml file */ @@ -93,33 +70,16 @@ gulp.task('redist', ); /** Sets the packaged artifact filename */ -function setReleaseFilename(filename, options = {}) { - const { extend } = common; - options = extend({}, { - lowerCase: true, - replaceWhitespace: true, - fixBasename: true, - replaceName: false, - srcName: null, - dstName: null - }, - options - ); - if (options.replaceName && options.srcName && options.dstName) { - filename = filename.replace(options.srcName, options.dstName); - } - if (options.lowerCase) { - filename = filename.toLowerCase(); +function getReleaseFilename() { + const { getEnvironmentVar } = common; + const releaseVersion = getEnvironmentVar('EMU_VERSION', packageJson.version); + const releasePlatform = getEnvironmentVar('EMU_PLATFORM'); + if (!releasePlatform) { + throw new Error('Environment variable EMU_PLATFORM missing. Please retry with valid value.'); } - if (options.replaceWhitespace) { - filename = filename.replace(/\s/g, '-'); - } - if (options.fixBasename) { - // renames build artifacts like 'bot-framework_{version}.*' or 'main_{version}.*' - // to '{package name in package.json}_{version}.*' - filename = filename.replace(/(bot[-|\s]framework)?(main)?/, packageJson.packagename); - } - return filename; + const releaseName = `${packageJson.packagename}-${releaseVersion}-${releasePlatform}`; + + return releaseName; } /** Writes the .yml metadata file */ From 290903c2464c3497c482fd7329bf071fdc98a860 Mon Sep 17 00:00:00 2001 From: Tony Anziano Date: Thu, 11 Oct 2018 14:53:11 -0700 Subject: [PATCH 29/35] Correcting setup.exe windows artifact name.' --- packages/app/main/scripts/config/windows-nsis.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/app/main/scripts/config/windows-nsis.json b/packages/app/main/scripts/config/windows-nsis.json index f7d195c87..2a4525046 100644 --- a/packages/app/main/scripts/config/windows-nsis.json +++ b/packages/app/main/scripts/config/windows-nsis.json @@ -5,7 +5,7 @@ "perMachine": true, "allowElevation": true, "packElevateHelper": true, - "artifactName": "botframework-emulator-setup-${version}.exe", + "artifactName": "BotFramework-Emulator-${version}-windows-setup.exe", "unicode": true, "runAfterFinish": true, "installerIcon": "./scripts/config/resources/icon.ico", From 9971e6207e11c9f1e73e0e79939d6367fb97053e Mon Sep 17 00:00:00 2001 From: Tony Anziano Date: Fri, 12 Oct 2018 09:36:37 -0700 Subject: [PATCH 30/35] Changing package version to test one-off builds. --- packages/app/main/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/app/main/package.json b/packages/app/main/package.json index f5d5d16d8..1103f7bc4 100644 --- a/packages/app/main/package.json +++ b/packages/app/main/package.json @@ -1,7 +1,7 @@ { "name": "@bfemulator/main", "packagename": "BotFramework-Emulator", - "version": "4.0.0-preview", + "version": "4.0.0-preview-one-off-win", "private": true, "description": "Development tool for the Microsoft Bot Framework. Allows developers to test and debug bots on localhost.", "main": "./app/server/main.js", From f43a8ab0622460adc002b6fa67514598fcb0a152 Mon Sep 17 00:00:00 2001 From: Tony Anziano Date: Fri, 12 Oct 2018 10:50:54 -0700 Subject: [PATCH 31/35] Changing version --- packages/app/main/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/app/main/package.json b/packages/app/main/package.json index 1103f7bc4..b35533a30 100644 --- a/packages/app/main/package.json +++ b/packages/app/main/package.json @@ -1,7 +1,7 @@ { "name": "@bfemulator/main", "packagename": "BotFramework-Emulator", - "version": "4.0.0-preview-one-off-win", + "version": "4.0.0-preview-one-off", "private": true, "description": "Development tool for the Microsoft Bot Framework. Allows developers to test and debug bots on localhost.", "main": "./app/server/main.js", From 09baf030750c862531a4e35dea16e6e4a6e94702 Mon Sep 17 00:00:00 2001 From: Tony Anziano Date: Fri, 12 Oct 2018 12:41:24 -0700 Subject: [PATCH 32/35] Refactored utility function out of platform gulp files. --- packages/app/main/gulpfile.common.js | 13 +++++++++++++ packages/app/main/gulpfile.linux.js | 20 +++----------------- packages/app/main/gulpfile.mac.js | 17 ++--------------- packages/app/main/gulpfile.windows.js | 15 +-------------- 4 files changed, 19 insertions(+), 46 deletions(-) diff --git a/packages/app/main/gulpfile.common.js b/packages/app/main/gulpfile.common.js index 821000797..7ada729b7 100644 --- a/packages/app/main/gulpfile.common.js +++ b/packages/app/main/gulpfile.common.js @@ -134,11 +134,24 @@ function hashFileAsync(filename, algo = 'sha512', encoding = 'base64') { return builderUtil.hashFile(filename, algo, encoding); } +/** Sets the packaged artifact filenames */ +function getReleaseFilename() { + const releaseVersion = getEnvironmentVar('EMU_VERSION', packageJson.version); + const releasePlatform = getEnvironmentVar('EMU_PLATFORM'); + if (!releasePlatform) { + throw new Error('Environment variable EMU_PLATFORM missing. Please retry with valid value.'); + } + const releaseName = `${packageJson.packagename}-${releaseVersion}-${releasePlatform}`; + + return releaseName; +} + module.exports = { extend, getConfig, getEnvironmentVar, getElectronMirrorUrl, + getReleaseFilename, githubAccountName, githubRepoName, hashFileAsync diff --git a/packages/app/main/gulpfile.linux.js b/packages/app/main/gulpfile.linux.js index d5e50dcc7..615e6f810 100644 --- a/packages/app/main/gulpfile.linux.js +++ b/packages/app/main/gulpfile.linux.js @@ -1,17 +1,16 @@ const gulp = require('gulp'); const common = require('./gulpfile.common.js'); -const packageJson = require('./package.json'); /** Package the emulator using electron-builder * and output artifacts to /dist/ */ gulp.task('package', async () => { - const { getElectronMirrorUrl, getConfig } = common; + const { getElectronMirrorUrl, getConfig } = common;, const rename = require('gulp-rename'); const builder = require('electron-builder'); const config = getConfig('linux'); - console.log(`Electron mirror: ${getElectronMirrorUrl()}`); + console.log(`Electron mirror: ${getElectronMirrorUrl(getReleaseFilename)}`); // create build artifacts const filenames = await builder.build({ @@ -24,22 +23,9 @@ gulp.task('package', async () => { gulp .src(filenames, { allowEmpty: true }) .pipe(rename(path => { - path.basename = getReleaseFilename(path.basename); + path.basename = getReleaseFilename(); })) .pipe(gulp.dest('./dist')) .on('end', resolve); }); }); - -/** Sets the packaged artifact filenames */ -function getReleaseFilename() { - const { getEnvironmentVar } = common; - const releaseVersion = getEnvironmentVar('EMU_VERSION', packageJson.version); - const releasePlatform = getEnvironmentVar('EMU_PLATFORM'); - if (!releasePlatform) { - throw new Error('Environment variable EMU_PLATFORM missing. Please retry with valid value.'); - } - const releaseName = `${packageJson.packagename}-${releaseVersion}-${releasePlatform}`; - - return releaseName; -} diff --git a/packages/app/main/gulpfile.mac.js b/packages/app/main/gulpfile.mac.js index b2fbed3d1..fbc5fd21f 100644 --- a/packages/app/main/gulpfile.mac.js +++ b/packages/app/main/gulpfile.mac.js @@ -19,7 +19,7 @@ gulp.task('stage', async () => { /** Creates the emulator installers */ gulp.task('redist:binaries', async () => { - const { getElectronMirrorUrl, getConfig } = common; + const { getElectronMirrorUrl, getConfig, getReleaseFilename } = common; const rename = require('gulp-rename'); const builder = require('electron-builder'); const config = getConfig('mac'); @@ -47,7 +47,7 @@ gulp.task('redist:binaries', async () => { /** Creates the .yml and .json metadata files */ gulp.task('redist:metadata-only', async () => { - const { hashFileAsync } = common; + const { hashFileAsync, getReleaseFilename } = common; const releaseFilename = `${getReleaseFilename()}.zip`; const releaseHash = await hashFileAsync(`./dist/${releaseFilename}`); const releaseDate = new Date().toISOString(); @@ -56,19 +56,6 @@ gulp.task('redist:metadata-only', async () => { writeYamlMetadataFile(releaseFilename, 'latest-mac.yml', './dist', releaseHash, releaseDate); }); -/** Sets the packaged artifact filenames */ -function getReleaseFilename() { - const { getEnvironmentVar } = common; - const releaseVersion = getEnvironmentVar('EMU_VERSION', packageJson.version); - const releasePlatform = getEnvironmentVar('EMU_PLATFORM'); - if (!releasePlatform) { - throw new Error('Environment variable EMU_PLATFORM missing. Please retry with valid value.'); - } - const releaseName = `${packageJson.packagename}-${releaseVersion}-${releasePlatform}`; - - return releaseName; -} - /** Writes the .yml metadata file */ function writeYamlMetadataFile(releaseFilename, yamlFilename, path, fileHash, releaseDate, extra = {}) { const { extend } = common; diff --git a/packages/app/main/gulpfile.windows.js b/packages/app/main/gulpfile.windows.js index cdf07f34c..e52a8f63d 100644 --- a/packages/app/main/gulpfile.windows.js +++ b/packages/app/main/gulpfile.windows.js @@ -19,7 +19,7 @@ gulp.task('stage', async () => { /** Creates the emulator installers */ gulp.task('redist:binaries', async () => { - const { getConfig, getElectronMirrorUrl } = common; + const { getConfig, getElectronMirrorUrl, getReleaseFilename } = common; var rename = require('gulp-rename'); var builder = require('electron-builder'); const config = getConfig("windows", "nsis"); @@ -69,19 +69,6 @@ gulp.task('redist', gulp.series('redist:binaries', 'redist:metadata-only') ); -/** Sets the packaged artifact filename */ -function getReleaseFilename() { - const { getEnvironmentVar } = common; - const releaseVersion = getEnvironmentVar('EMU_VERSION', packageJson.version); - const releasePlatform = getEnvironmentVar('EMU_PLATFORM'); - if (!releasePlatform) { - throw new Error('Environment variable EMU_PLATFORM missing. Please retry with valid value.'); - } - const releaseName = `${packageJson.packagename}-${releaseVersion}-${releasePlatform}`; - - return releaseName; -} - /** Writes the .yml metadata file */ function writeYamlMetadataFile(releaseFilename, yamlFilename, path, fileHash, releaseDate, extra = {}) { const { extend } = common; From 5b50b2a480c31e2cf3ce416b6639d1510410d9b0 Mon Sep 17 00:00:00 2001 From: Tony Anziano Date: Fri, 12 Oct 2018 13:36:57 -0700 Subject: [PATCH 33/35] Fixed misplaced comma. --- packages/app/main/gulpfile.linux.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/app/main/gulpfile.linux.js b/packages/app/main/gulpfile.linux.js index 615e6f810..10b378141 100644 --- a/packages/app/main/gulpfile.linux.js +++ b/packages/app/main/gulpfile.linux.js @@ -5,7 +5,7 @@ const common = require('./gulpfile.common.js'); * and output artifacts to /dist/ */ gulp.task('package', async () => { - const { getElectronMirrorUrl, getConfig } = common;, + const { getElectronMirrorUrl, getConfig } = common; const rename = require('gulp-rename'); const builder = require('electron-builder'); const config = getConfig('linux'); From 4b2c1181d14adc7956e9715917148aade6eb6e48 Mon Sep 17 00:00:00 2001 From: Tony Anziano Date: Fri, 12 Oct 2018 14:20:28 -0700 Subject: [PATCH 34/35] Fixed missing import in linux gulpfile. --- packages/app/main/gulpfile.linux.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/app/main/gulpfile.linux.js b/packages/app/main/gulpfile.linux.js index 10b378141..f1e4af8b4 100644 --- a/packages/app/main/gulpfile.linux.js +++ b/packages/app/main/gulpfile.linux.js @@ -5,7 +5,7 @@ const common = require('./gulpfile.common.js'); * and output artifacts to /dist/ */ gulp.task('package', async () => { - const { getElectronMirrorUrl, getConfig } = common; + const { getElectronMirrorUrl, getConfig, getReleaseFilename } = common; const rename = require('gulp-rename'); const builder = require('electron-builder'); const config = getConfig('linux'); From f3e8c179cad5e0b16b63a055dc85f8801cde29c8 Mon Sep 17 00:00:00 2001 From: Tony Anziano Date: Mon, 15 Oct 2018 12:41:43 -0700 Subject: [PATCH 35/35] Reverted package version. --- packages/app/main/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/app/main/package.json b/packages/app/main/package.json index b35533a30..f5d5d16d8 100644 --- a/packages/app/main/package.json +++ b/packages/app/main/package.json @@ -1,7 +1,7 @@ { "name": "@bfemulator/main", "packagename": "BotFramework-Emulator", - "version": "4.0.0-preview-one-off", + "version": "4.0.0-preview", "private": true, "description": "Development tool for the Microsoft Bot Framework. Allows developers to test and debug bots on localhost.", "main": "./app/server/main.js",