Skip to content

Commit

Permalink
Create shrinkwrap from build
Browse files Browse the repository at this point in the history
The npm shrinkwrap that we generate during build in order to package
with distributions is now properly created based on the built
dependencies rather than the local dev install.
  • Loading branch information
epixa committed Sep 17, 2015
1 parent 62a136c commit 690d204
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 24 deletions.
4 changes: 1 addition & 3 deletions tasks/build/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ module.exports = function (grunt) {
let { flatten } = require('lodash');

grunt.registerTask('build', flatten([
'_build:shrinkwrap:ensureExists:true',
'_build:getProps',
'clean:build',
'clean:target',
Expand All @@ -13,9 +12,8 @@ module.exports = function (grunt) {
'_build:installedPlugins',
'_build:packageJson',
'_build:readme',
'_build:shrinkwrap:copyToBuild',
'_build:shrinkwrap:cleanup',
'_build:installNpmDeps',
'_build:shrinkwrap:ensureExists:true',
'clean:testsFromModules',
'clean:deepModuleBins',
'clean:deepModules',
Expand Down
24 changes: 3 additions & 21 deletions tasks/build/shrinkwrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ 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 buildDir = join(config.get('root'), 'build', 'kibana');
let exec = (...args) => require('../utils/exec')(...args, { cwd: buildDir });
let newFiles = [];
let shrinkwrapFile = join(config.get('root'), 'npm-shrinkwrap.json');
let shrinkwrapFile = join(buildDir, 'npm-shrinkwrap.json');

grunt.registerTask('_build:shrinkwrap:ensureExists', function (createIfMissing) {
try {
Expand All @@ -19,23 +20,4 @@ module.exports = function (grunt) {
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', '--loglevel', 'error']);
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));
});
};

0 comments on commit 690d204

Please sign in to comment.