Fix: Package use build target (elastic/kibana-plugin-helpers#52)
* fix: pass build target into package task use the build target for the zip output * chore: change up the npm scripts * chore: add create package tests * chore: update eslint deps * chore: fix linting issues, add engines Original commit: elastic/kibana-plugin-helpers@51058fb7fc
This commit is contained in:
parent
7f15f82600
commit
8e9443f253
|
@ -1,2 +1,5 @@
|
|||
---
|
||||
extends: "@elastic/kibana"
|
||||
|
||||
rules:
|
||||
prefer-object-spread/prefer-object-spread: 0
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
var program = require('commander');
|
||||
const program = require('commander');
|
||||
|
||||
var pkg = require('./package.json');
|
||||
var run = require('./lib/run');
|
||||
var docs = require('./lib/docs');
|
||||
var enableCollectingUnknownOptions = require('./lib/enable_collecting_unknown_options');
|
||||
const pkg = require('./package.json');
|
||||
const run = require('./lib/run');
|
||||
const docs = require('./lib/docs');
|
||||
const enableCollectingUnknownOptions = require('./lib/enable_collecting_unknown_options');
|
||||
|
||||
function taskRunner(fn) {
|
||||
return function actionWrapper() {
|
||||
var args = [].slice.apply(arguments);
|
||||
var command = args.pop();
|
||||
const args = [].slice.apply(arguments);
|
||||
const command = args.pop();
|
||||
fn.apply(null, [command].concat(args));
|
||||
};
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ program
|
|||
.command('test')
|
||||
.description('Run the server and browser tests')
|
||||
.on('--help', docs('test/all'))
|
||||
.action(taskRunner(function (command, files) {
|
||||
.action(taskRunner(function (command) {
|
||||
run('testAll');
|
||||
}));
|
||||
|
||||
|
|
|
@ -13,9 +13,9 @@
|
|||
"author": "Spencer Alger <email@spalger.com>",
|
||||
"license": "Apache-2.0",
|
||||
"scripts": {
|
||||
"test": "npm run lint && npm run jest",
|
||||
"test:only": "npm run jest",
|
||||
"jest": "jest",
|
||||
"test": "npm run lint && jest",
|
||||
"test:only": "jest",
|
||||
"test:dev": "jest --watch",
|
||||
"lint": "eslint bin/ help/ tasks/"
|
||||
},
|
||||
"dependencies": {
|
||||
|
@ -27,18 +27,24 @@
|
|||
"through2-map": "^3.0.0",
|
||||
"vinyl-fs": "2.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@elastic/eslint-config-kibana": "^0.13.0",
|
||||
"babel-eslint": "^7.2.3",
|
||||
"eslint": "^4.1.0",
|
||||
"eslint-plugin-babel": "^4.1.1",
|
||||
"eslint-plugin-import": "^2.6.0",
|
||||
"eslint-plugin-jest": "^21.0.0",
|
||||
"eslint-plugin-mocha": "^4.9.0",
|
||||
"eslint-plugin-prefer-object-spread": "^1.2.1",
|
||||
"eslint-plugin-react": "^7.1.0",
|
||||
"jest": "^17.0.3"
|
||||
},
|
||||
"engines" : {
|
||||
"node" : "^6.11.5 || ^8.8.0"
|
||||
},
|
||||
"directories": {
|
||||
"doc": "docs"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@elastic/eslint-config-kibana": "0.5.0",
|
||||
"babel-eslint": "6.1.2",
|
||||
"eslint": "3.11.1",
|
||||
"eslint-plugin-babel": "4.0.0",
|
||||
"eslint-plugin-mocha": "4.7.0",
|
||||
"eslint-plugin-react": "6.10.3",
|
||||
"jest": "^17.0.3"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/elastic/kibana-plugin-helpers.git"
|
||||
|
|
|
@ -34,7 +34,7 @@ module.exports = function (plugin, run, options) {
|
|||
return buildStep
|
||||
.then(function () {
|
||||
if (options.skipArchive) return;
|
||||
return createPackage(plugin, buildVersion);
|
||||
return createPackage(plugin, buildTarget, buildVersion);
|
||||
})
|
||||
.catch(function (err) {
|
||||
console.log('BUILD ACTION FAILED:', err);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/*eslint-env jest*/
|
||||
const { resolve } = require('path');
|
||||
const del = require('del');
|
||||
const createBuild = require('./create_build');
|
||||
|
||||
const PLUGIN_FIXTURE = resolve(__dirname, '__fixtures__/test_plugin');
|
||||
const PLUGIN = require('../../lib/plugin_config')(PLUGIN_FIXTURE);
|
||||
|
@ -12,7 +13,6 @@ describe('create_build', () => {
|
|||
afterEach(() => del(PLUGIN_BUILD_DIR));
|
||||
|
||||
describe('creating the build', function () {
|
||||
const createBuild = require('./create_build');
|
||||
const buildTarget = resolve(PLUGIN.root, 'build');
|
||||
const buildVersion = PLUGIN.version;
|
||||
const kibanaVersion = PLUGIN.version;
|
||||
|
@ -23,23 +23,23 @@ describe('create_build', () => {
|
|||
expect(PLUGIN.pkg.devDependencies).not.toBeUndefined();
|
||||
|
||||
return createBuild(PLUGIN, buildTarget, buildVersion, kibanaVersion, buildFiles)
|
||||
.then(() => {
|
||||
const pkg = require(resolve(PLUGIN_BUILD_TARGET, 'package.json'));
|
||||
expect(pkg.scripts).toBeUndefined();
|
||||
expect(pkg.devDependencies).toBeUndefined();
|
||||
});
|
||||
.then(() => {
|
||||
const pkg = require(resolve(PLUGIN_BUILD_TARGET, 'package.json'));
|
||||
expect(pkg.scripts).toBeUndefined();
|
||||
expect(pkg.devDependencies).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
it('adds build metadata to package.json', function () {
|
||||
expect(PLUGIN.pkg.build).toBeUndefined();
|
||||
|
||||
return createBuild(PLUGIN, buildTarget, buildVersion, kibanaVersion, buildFiles)
|
||||
.then(() => {
|
||||
const pkg = require(resolve(PLUGIN_BUILD_TARGET, 'package.json'));
|
||||
expect(pkg.build).not.toBeUndefined();
|
||||
expect(pkg.build.git).not.toBeUndefined();
|
||||
expect(pkg.build.date).not.toBeUndefined();
|
||||
});
|
||||
.then(() => {
|
||||
const pkg = require(resolve(PLUGIN_BUILD_TARGET, 'package.json'));
|
||||
expect(pkg.build).not.toBeUndefined();
|
||||
expect(pkg.build.git).not.toBeUndefined();
|
||||
expect(pkg.build.date).not.toBeUndefined();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -4,9 +4,8 @@ const del = require('del');
|
|||
const vfs = require('vinyl-fs');
|
||||
const zip = require('gulp-zip');
|
||||
|
||||
module.exports = function createPackage(plugin, buildVersion) {
|
||||
module.exports = function createPackage(plugin, buildTarget, buildVersion) {
|
||||
const buildId = `${plugin.id}-${buildVersion}`;
|
||||
const buildTarget = join(plugin.root, 'build');
|
||||
const buildRoot = join(buildTarget, 'kibana', plugin.id);
|
||||
|
||||
// zip up the package
|
||||
|
@ -19,8 +18,8 @@ module.exports = function createPackage(plugin, buildVersion) {
|
|||
.on('end', resolve)
|
||||
.on('error', reject);
|
||||
})
|
||||
.then(function () {
|
||||
// clean up the build path
|
||||
return del(join(buildTarget, 'kibana'));
|
||||
});
|
||||
.then(function () {
|
||||
// clean up the build path
|
||||
return del(join(buildTarget, 'kibana'));
|
||||
});
|
||||
};
|
|
@ -0,0 +1,32 @@
|
|||
/*eslint-env jest*/
|
||||
const { resolve } = require('path');
|
||||
const { statSync } = require('fs');
|
||||
const del = require('del');
|
||||
const createBuild = require('./create_build');
|
||||
const createPackage = require('./create_package');
|
||||
|
||||
const PLUGIN_FIXTURE = resolve(__dirname, '__fixtures__/test_plugin');
|
||||
const PLUGIN = require('../../lib/plugin_config')(PLUGIN_FIXTURE);
|
||||
const PLUGIN_BUILD_DIR = resolve(PLUGIN_FIXTURE, 'build-custom');
|
||||
|
||||
describe('create_build', () => {
|
||||
const buildVersion = PLUGIN.version;
|
||||
const kibanaVersion = PLUGIN.version;
|
||||
const buildFiles = PLUGIN.buildSourcePatterns;
|
||||
const packageFile = `${PLUGIN.id}-${buildVersion}.zip`;
|
||||
const doBuild = () => createBuild(PLUGIN, PLUGIN_BUILD_DIR, buildVersion, kibanaVersion, buildFiles);
|
||||
|
||||
beforeAll(() => del(PLUGIN_BUILD_DIR).then(doBuild));
|
||||
afterAll(() => del(PLUGIN_BUILD_DIR));
|
||||
|
||||
describe('creating the package', function () {
|
||||
it('creates zip file in build target path', function () {
|
||||
return createPackage(PLUGIN, PLUGIN_BUILD_DIR, buildVersion)
|
||||
.then(() => {
|
||||
const zipFile = resolve(PLUGIN_BUILD_DIR, packageFile);
|
||||
const stats = statSync(zipFile);
|
||||
expect(stats.isFile()).toBeTruthy();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue