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

Build relies on shrinkwrap, release requires it #4770

Merged
merged 3 commits into from
Aug 27, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ module.exports = function (grunt) {
grunt.log.ok(`downloading ${platform.name} - ${mb} mb`);
};

grunt.registerTask('_build:downloadNodes:start', function () {
grunt.registerTask('_build:downloadNodeBuilds:start', function () {
map(platforms, start).nodeify(this.async());
});

grunt.registerTask('_build:downloadNodes:finish', function () {
grunt.registerTask('_build:downloadNodeBuilds:finish', function () {
map(activeDownloads, async (platform) => {
await platform.downloadPromise;
grunt.log.ok(`${platform.name} download complete`);
Expand Down
7 changes: 5 additions & 2 deletions tasks/build/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,24 @@ module.exports = function (grunt) {
let { flatten } = require('lodash');

grunt.registerTask('build', flatten([
'_build:shrinkwrap:ensureExists:true',
'_build:getProps',
'clean:build',
'clean:target',
'_build:downloadNodes:start',
'_build:downloadNodeBuilds:start',
'copy:devSource',
'babel:build',
'_build:cliIndex',
'_build:installedPlugins',
'_build:packageJson',
'_build:readme',
'_build:shrinkwrap:copyToBuild',
'_build:shrinkwrap:cleanup',
'_build:installNpmDeps',
'clean:testsFromModules',
'run:optimizeBuild',
'stop:optimizeBuild',
'_build:downloadNodes:finish',
'_build:downloadNodeBuilds:finish',
'_build:versionedLinks',
'_build:archives',
!grunt.option('os-packages') ? [] : [
Expand Down
41 changes: 41 additions & 0 deletions tasks/build/shrinkwrap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
module.exports = function (grunt) {
let { config } = grunt;
let { statSync } = require('fs');
let { join } = require('path');
let exec = (...args) => require('../utils/exec')(...args, { cwd: config.get('root') });
let newFiles = [];
let shrinkwrapFile = join(config.get('root'), 'npm-shrinkwrap.json');

grunt.registerTask('_build:shrinkwrap:ensureExists', function (createIfMissing) {
try {
statSync(shrinkwrapFile);
} catch (e) {
if (e.code !== 'ENOENT') throw e;

if (createIfMissing) {
exec('npm', ['shrinkwrap', '--silent', '--dev']);
newFiles.push(shrinkwrapFile);
}
else grunt.fail.warn('Releases require an npm-shrinkwrap.json file to exist');
}
});

grunt.registerTask('_build:shrinkwrap:copyToBuild', function () {
// this.requires(['_build:shrinkwrap:ensureExists', 'copy:devSource']);

// backup shrinkwrap and copy to build
exec('cp', ['npm-shrinkwrap.json', 'npm-shrinkwrap.dev']);
exec('cp', ['npm-shrinkwrap.json', join(config.get('root'), 'build', 'kibana', 'npm-shrinkwrap.build.json')]);

// create shrinkwrap without dev dependencies and copy to build
exec('npm', ['shrinkwrap', '--silent']);
exec('cp', ['npm-shrinkwrap.json', join(config.get('root'), 'build', 'kibana', 'npm-shrinkwrap.json')]);

// restore the dev shrinkwrap
exec('mv', ['npm-shrinkwrap.dev', 'npm-shrinkwrap.json']);
});

grunt.registerTask('_build:shrinkwrap:cleanup', function () {
if (newFiles.length) exec('rm', newFiles.splice(0));
});
};
2 changes: 1 addition & 1 deletion tasks/release.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module.exports = function (grunt) {

var readline = require('readline');

// build, then zip and upload to s3
grunt.registerTask('release', [
'_build:shrinkwrap:ensureExists',
'_release:confirmUpload',
'_release:loadS3Config',
'build',
Expand Down