Switch to Yarn (#11637)

(cherry picked from commit 71a9b8b6bc)
This commit is contained in:
Spencer 2017-05-26 19:32:03 -07:00 committed by spalger
parent df346b0e0c
commit ce5c4e756b
10 changed files with 8122 additions and 73 deletions

1
.gitignore vendored
View file

@ -34,4 +34,3 @@ selenium
*.swo
*.out
ui_framework/doc_site/build/*.js*
yarn.lock

View file

@ -103,10 +103,17 @@ Install the version of node.js listed in the `.node-version` file _(this can be
nvm install "$(cat .node-version)"
```
Install `npm` dependencies
Install the latest version of [yarn](https://yarnpkg.com/en/docs/install)
```bash
npm install
# See https://yarnpkg.com/en/docs/install for non-MacOS install
brew install yarn
```
Install dependencies
```bash
yarn
```
Start elasticsearch.
@ -365,4 +372,4 @@ Remember, someone is blocked by a pull awaiting review, make it count. Be thorou
1. **Hand it off** If you're the first reviewer and everything looks good but the changes are more than a few lines, hand the pull to someone else to take a second look. Again, try to find the right person to assign it to.
1. **Merge the code** When everything looks good, put in a `LGTM` (looks good to me) comment. Merge into the target branch. Check the labels on the pull to see if backporting is required, and perform the backport if so.
Thank you so much for reading our guidelines! :tada:
Thank you so much for reading our guidelines! :tada:

View file

@ -10,14 +10,14 @@ Before you can use an external library with Kibana you have to install it. You
do that using...
[float]
==== npm (preferred method)
==== yarn (preferred method)
Once you've http://npmsearch.com[found] a dependency you want to add, you can
install it like so:
["source","shell"]
-----------
npm install --save some-neat-library
yarn add some-neat-library
-----------
At the top of a javascript file, just import the library using it's name:
@ -28,13 +28,13 @@ import someNeatLibrary from 'some-neat-library';
-----------
Just like working in node.js, front-end code can require node modules installed
by npm without any additional configuration.
by yarn without any additional configuration.
[float]
==== webpackShims
When a library you want to use does use es6 or common.js modules but is not
available on npm, you can copy the source of the library into a webpackShim.
available with yarn, you can copy the source of the library into a webpackShim.
["source","shell"]
-----------
@ -97,7 +97,7 @@ module.exports = window.angular;
What this shim does is fairly simple if you go line by line:
. makes sure that jQuery is loaded before angular (which actually runs the shim above)
. load the angular.js file from the npm installation
. load the angular.js file from the node_modules directory
. load the angular-elastic plugin, a plugin we want to always be included whenever we import angular
. use the `ui/modules` module to add the module exported by angular-elastic as a dependency to the `kibana` angular module
. finally, export the window.angular variable. This means that writing `import angular from 'angular';` will properly set the angular variable to the angular library, rather than undefined which is the default behavior.
. finally, export the window.angular variable. This means that writing `import angular from 'angular';` will properly set the angular variable to the angular library, rather than undefined which is the default behavior.

View file

@ -102,7 +102,7 @@
"bunyan": "1.7.1",
"check-hash": "1.0.1",
"commander": "2.8.1",
"css-loader": "0.17.0",
"css-loader": "^0.28.1",
"d3": "3.5.6",
"d3-cloud": "1.2.1",
"dragula": "3.7.0",

View file

@ -15,7 +15,7 @@ module.exports = function (grunt) {
'_build:packageJson',
'_build:readme',
'_build:babelCache',
'_build:installNpmDeps',
'_build:installDependencies',
'_build:notice',
'_build:removePkgJsonDeps',
'clean:testsFromModules',

View file

@ -0,0 +1,10 @@
import { exec } from 'child_process';
module.exports = function (grunt) {
grunt.registerTask('_build:installDependencies', function () {
grunt.file.mkdir('<%= root %>/build/kibana/node_modules');
exec('yarn --production --ignore-optional', {
cwd: grunt.config.process('<%= root %>/build/kibana')
}, this.async());
});
};

View file

@ -1,14 +0,0 @@
module.exports = function (grunt) {
const { exec } = require('child_process');
const { resolve } = require('path');
grunt.registerTask('_build:installNpmDeps', function () {
grunt.file.mkdir('build/kibana/node_modules');
exec('npm install --production --no-optional', {
cwd: grunt.config.process('<%= root %>/build/kibana')
}, this.async());
});
};

View file

@ -1,39 +0,0 @@
const Promise = require('bluebird');
const spawn = require('./spawn');
const grunt = require('grunt');
module.exports = function (repo, dir) {
// store the previous and new hash from the repo
// to know if there was an update from fetch
let prevHash;
let newHash;
return Promise.resolve()
.then(function () {
if (!grunt.file.isDir(dir + '/.git')) {
if (grunt.file.isDir(dir)) {
throw new Error(dir + ' needs to be removed so that we can replace it with a git-repo');
}
return spawn('git', ['clone', repo, dir])();
} else {
return spawn.silent('git', ['log', '-1', '--pretty=%H'], dir)()
.then(function (out) {
prevHash = out.trim();
})
.then(spawn('git', ['fetch', 'origin', 'master'], dir))
.then(spawn('git', ['reset', '--hard', 'origin/master'], dir))
.then(spawn.silent('git', ['log', '-1', '--pretty=%H'], dir));
}
})
.then(function (out) {
if (prevHash) newHash = out.trim();
if (!prevHash || newHash !== prevHash) {
return spawn('npm', ['update'], dir)()
.then(spawn('bower', ['install'], dir))
.then(function () {
return true;
});
}
});
};

View file

@ -28,12 +28,10 @@ fi
nvm install "$(cat .node-version)"
###*****###
### NPM ###
### yarn ###
###*****###
npm install
if [ -z "$(npm bin)" ]; then
echo "npm does not know where it stores executables..... huh??"
exit 1
fi
mkdir .bin
curl -L https://github.com/yarnpkg/yarn/releases/download/v0.24.2/yarn-0.24.2.js > .bin/yarn
chmod +x .bin/yarn
PATH="$(pwd)/.bin:$PATH"
yarn

8088
yarn.lock Normal file

File diff suppressed because it is too large Load diff