mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
* [plugin-helpers] npm -> yarn * Allow globs to not match when singular, e.g. for 'yarn.lock' * --frozen-lockfile
This commit is contained in:
parent
b665999344
commit
38319f1b72
4 changed files with 8 additions and 33 deletions
|
@ -1,5 +1,4 @@
|
|||
const resolve = require('path').resolve;
|
||||
const statSync = require('fs').statSync;
|
||||
const readFileSync = require('fs').readFileSync;
|
||||
const configFile = require('./config_file');
|
||||
|
||||
|
@ -10,19 +9,12 @@ module.exports = function (root) {
|
|||
const config = configFile(root);
|
||||
|
||||
const buildSourcePatterns = [
|
||||
'yarn.lock',
|
||||
'package.json',
|
||||
'index.js',
|
||||
'{lib,public,server,webpackShims,translations}/**/*',
|
||||
];
|
||||
|
||||
// add shrinkwrap and lock files, if they exist
|
||||
['npm-shrinkwrap.json', 'yarn.lock']
|
||||
.forEach(function (file) {
|
||||
if (fileExists(resolve(root, file))) {
|
||||
buildSourcePatterns.push(file);
|
||||
}
|
||||
});
|
||||
|
||||
return Object.assign({
|
||||
root: root,
|
||||
kibanaRoot: resolve(root, '../kibana'),
|
||||
|
@ -33,12 +25,3 @@ module.exports = function (root) {
|
|||
version: pkg.version,
|
||||
}, config);
|
||||
};
|
||||
|
||||
function fileExists(path) {
|
||||
try {
|
||||
const stat = statSync(path);
|
||||
return stat.isFile();
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
const join = require('path').join;
|
||||
const relative = require('path').relative;
|
||||
const statSync = require('fs').statSync;
|
||||
const execFileSync = require('child_process').execFileSync;
|
||||
const del = require('del');
|
||||
const vfs = require('vinyl-fs');
|
||||
|
@ -17,7 +16,7 @@ module.exports = function createBuild(plugin, buildTarget, buildVersion, kibanaV
|
|||
.then(function () {
|
||||
return new Promise(function (resolve, reject) {
|
||||
vfs
|
||||
.src(files, { cwd: buildSource, base: buildSource })
|
||||
.src(files, { cwd: buildSource, base: buildSource, allowEmpty: true })
|
||||
// modify the package.json file
|
||||
.pipe(rewritePackageJson(buildSource, buildVersion, kibanaVersion))
|
||||
|
||||
|
@ -39,13 +38,6 @@ module.exports = function createBuild(plugin, buildTarget, buildVersion, kibanaV
|
|||
stdio: ['ignore', 'ignore', 'pipe'],
|
||||
};
|
||||
|
||||
try {
|
||||
// use yarn if yarn lockfile is found in the build
|
||||
statSync(join(buildRoot, 'yarn.lock'));
|
||||
execFileSync(winCmd('yarn'), ['install', '--production'], options);
|
||||
} catch (e) {
|
||||
// use npm if there is no yarn lockfile in the build
|
||||
execFileSync(winCmd('npm'), ['install', '--production', '--no-bin-links'], options);
|
||||
}
|
||||
execFileSync(winCmd('yarn'), ['install', '--production', '--frozen-lockfile'], options);
|
||||
});
|
||||
};
|
||||
|
|
|
@ -15,8 +15,8 @@ module.exports = function testBrowserAction(plugin, run, options) {
|
|||
}
|
||||
|
||||
const task = (options.dev) ? 'test:dev' : 'test:browser';
|
||||
const args = ['run', task, '--'].concat(kbnServerArgs);
|
||||
execFileSync(winCmd('npm'), args, {
|
||||
const args = [task].concat(kbnServerArgs);
|
||||
execFileSync(winCmd('yarn'), args, {
|
||||
cwd: plugin.kibanaRoot,
|
||||
stdio: ['ignore', 1, 2]
|
||||
});
|
||||
|
|
|
@ -20,14 +20,14 @@ Server tests are written just like browser tests, they are just executed differe
|
|||
running the tests
|
||||
=================
|
||||
|
||||
Running the server tests is simple, just execute `npm run test:server` in your terminal
|
||||
Running the server tests is simple, just execute `yarn test:server` in your terminal
|
||||
and all of the tests in your server will be run.
|
||||
|
||||
By default, the runner will look for tests in `server/**/__tests__/**/*.js`. If you'd prefer to
|
||||
use a different collection of globs and files, you can specify them after the `npm run test:server`
|
||||
use a different collection of globs and files, you can specify them after the `yarn test:server`
|
||||
task, like so:
|
||||
|
||||
`npm run test:server 'plugins/myplugins/server/__tests__/**/*.js'`
|
||||
`yarn test:server 'plugins/myplugins/server/__tests__/**/*.js'`
|
||||
|
||||
NOTE: quoting the glob pattern is not required, but helps to avoid issues with globbing expansion
|
||||
in your shell.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue