Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleaned up and modified build infrastructure #988

Merged
merged 39 commits into from
Oct 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
c960217
WIP cleaning up gulp file.
tonyanziano Oct 8, 2018
d4fc9c8
Refactored linux gulp processes.
tonyanziano Oct 8, 2018
7af1c6c
Changing package name for testing.
tonyanziano Oct 8, 2018
6fccb44
Correcting some missing references.
tonyanziano Oct 8, 2018
50fdfb2
Fixed bad reference.
tonyanziano Oct 8, 2018
318380a
Added missing constants.
tonyanziano Oct 8, 2018
1f1a91b
Fixed bad variable name.
tonyanziano Oct 8, 2018
6dd40fe
Merge branch 'v4' of https://github.com/Microsoft/BotFramework-Emulat…
tonyanziano Oct 8, 2018
2e4a9a9
Fixed old variable reference.
tonyanziano Oct 8, 2018
d2ff35d
Fixed missing import in publish task.
tonyanziano Oct 8, 2018
ea7e199
Trying to diagnose environment variable issue.
tonyanziano Oct 9, 2018
067f2ae
More WIP for env.
tonyanziano Oct 9, 2018
12ef7fd
Finished initial refactoring of Linux build process.
tonyanziano Oct 9, 2018
54be615
WIP on Windows Build Refactoring.
tonyanziano Oct 9, 2018
9ab890a
Added missing gulp import.
tonyanziano Oct 9, 2018
60d2569
Fixed missing packageJson reference.
tonyanziano Oct 9, 2018
09a4b78
Fixed incorrect package.json reference.'
tonyanziano Oct 9, 2018
50853e9
Fixed bad variable in utility function.
tonyanziano Oct 9, 2018
cd2eeb5
Fixed extend import.
tonyanziano Oct 10, 2018
3abb4fd
WIP on refactoring mac build process.
tonyanziano Oct 10, 2018
857b9c7
Fixed incorrect variable.
tonyanziano Oct 10, 2018
a0c1c39
Fixed string that should have been quoted.
tonyanziano Oct 10, 2018
786b0ff
Got rid of old master gulp file.
tonyanziano Oct 10, 2018
a1b21f6
Merge branch 'v4' of https://github.com/Microsoft/BotFramework-Emulat…
tonyanziano Oct 10, 2018
0569ca1
Testing out artifact naming.
tonyanziano Oct 10, 2018
bb2125d
WIP artifact naming.
tonyanziano Oct 10, 2018
93a068a
Setting up nightly compatibility.
tonyanziano Oct 10, 2018
8bc8ecf
WIP nightly on linux.
tonyanziano Oct 11, 2018
fddefe1
Linux publish is done in VSTS now.
tonyanziano Oct 11, 2018
ce15cd0
WIP windows nightly.
tonyanziano Oct 11, 2018
290903c
Correcting setup.exe windows artifact name.'
tonyanziano Oct 11, 2018
9971e62
Changing package version to test one-off builds.
tonyanziano Oct 12, 2018
f43a8ab
Changing version
tonyanziano Oct 12, 2018
09baf03
Refactored utility function out of platform gulp files.
tonyanziano Oct 12, 2018
5b50b2a
Fixed misplaced comma.
tonyanziano Oct 12, 2018
4b2c118
Fixed missing import in linux gulpfile.
tonyanziano Oct 12, 2018
f3e8c17
Reverted package version.
tonyanziano Oct 15, 2018
76b6316
Merge branch 'v4' into toanzian/build-sync
tonyanziano Oct 15, 2018
b746ee4
Merge branch 'v4' into toanzian/build-sync
Oct 15, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
158 changes: 158 additions & 0 deletions packages/app/main/gulpfile.common.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
const packageJson = require('./package.json');
const gulp = require ('gulp');

const defaultElectronMirror = 'https://github.com/electron/electron/releases/download/v';
const defaultElectronVersion = packageJson.devDependencies["electron"];
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]
}

/** 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);
}

/** 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;
};

/** Hashes a file asynchronously */
function hashFileAsync(filename, algo = 'sha512', encoding = 'base64') {
var builderUtil = require('builder-util');
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
};
Loading