Skip to content

Commit

Permalink
Upgrade to NodeJS 10 (#25157)
Browse files Browse the repository at this point in the history
* feat(NA): upgrade node js version on file configs.

* chore(NA): migrate configs and 3rd party dependencies to work on node js 10.x

* fix(NA): add missing async function declaration.

* chore(NA): updated elastic/good package to work with node10

* chore(NA): update lockfiles.

* fix(NA): add missing dep.

* fix(NA): types for node 10.

* test(NA): fix error return type for node10.

* fix(NA): kbn-pm webpack config to unlazy a require using lazy-cache. fix(NA): build to work with node 10.

* test(NA): jest integration test for kbn-pluin-helpers.

* test(NA): fix jest tests for kbn-es.

* fix(NA): use ostmpdir instead of a tmp folder inside the fixtures.

* fix(NA): change afterEach on kbn es decompress test.

* fix(NA): change afterEach on kbn es decompress test.

* fix(NA): readd mock-fs for the tests that still use it on kbn-es and that works on node10.

* fix(NA): readd mock-fs for the tests that still use it on kbn-es and that works on node10.

* refact(NA): rewrite tests using mock-fs and completely remove this dependency.

* fix(NA): failing test implementation using jest mock in order to replace mock-fs.

* fix(NA): update jest snapshots to match new ones generated one node 10.

* fix(NA): cli/cluster mock to spyOn off method instead off spyOn removeListener as this was changed on Node 10.

* fix(NA): tests for cluster_manager to also spyOn off and on instead of addListener and removeListener

* test(NA): fix management advance settings image field test flow.

* fix(NA): apply missing types for src/core/server/plugins/discovery/plugins_discovery.ts.

* test(NA): updated 2 missing snapshots for KuiCodeEditor on kbn-ui-framework.

* refact(NA): fix eslint errors.

* refact(NA): fix ts code with tslint fix. chore(NA): update jest snapshots.

* chore(NA): migrate kbn config schema peer dependency to last used joi version to avoid warning on bootstrap.

* fix(NA): tslint errors.

* chore(NA): upgrade types node to the last version.

* fix(NA): missing utf8 input format encoding when reading a file.

* chore(NA): upgrade to node 10.14.1

* fix(NA): Buffer api usage to avoid deprecation warnings.
  • Loading branch information
mistic authored Dec 10, 2018
1 parent ef7cf4b commit 45a6770
Show file tree
Hide file tree
Showing 77 changed files with 40,427 additions and 14,912 deletions.
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8.14.0
10.14.1
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8.14.0
10.14.1
21 changes: 10 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"url": "https://github.com/elastic/kibana.git"
},
"resolutions": {
"**/@types/node": "8.10.38",
"**/@types/node": "10.12.12",
"@types/react": "16.3.14"
},
"workspaces": {
Expand All @@ -95,7 +95,7 @@
"@elastic/datemath": "5.0.1",
"@elastic/eui": "5.3.0",
"@elastic/filesaver": "1.1.2",
"@elastic/good": "8.1.1-kibana1",
"@elastic/good": "8.1.1-kibana2",
"@elastic/numeral": "2.3.2",
"@elastic/ui-ace": "0.2.3",
"@kbn/babel-code-parser": "1.0.0",
Expand Down Expand Up @@ -137,7 +137,7 @@
"elasticsearch": "^15.2.0",
"elasticsearch-browser": "^15.2.0",
"encode-uri-query": "1.0.0",
"execa": "^0.10.0",
"execa": "^1.0.0",
"expiry-js": "0.1.7",
"file-loader": "2.0.0",
"font-awesome": "4.4.0",
Expand Down Expand Up @@ -285,7 +285,7 @@
"@types/minimatch": "^2.0.29",
"@types/moment-timezone": "^0.5.8",
"@types/mustache": "^0.8.31",
"@types/node": "^8.10.38",
"@types/node": "^10.12.12",
"@types/opn": "^5.1.0",
"@types/podium": "^1.0.0",
"@types/prop-types": "^15.5.3",
Expand All @@ -308,7 +308,7 @@
"angular-mocks": "1.4.7",
"archiver": "^3.0.0",
"babel-eslint": "^9.0.0",
"babel-jest": "^23.4.2",
"babel-jest": "^23.6.0",
"backport": "4.4.1",
"chai": "3.5.0",
"chance": "1.0.10",
Expand All @@ -325,7 +325,7 @@
"eslint-config-prettier": "^3.1.0",
"eslint-plugin-babel": "^5.2.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-jest": "^21.22.1",
"eslint-plugin-jest": "^21.26.2",
"eslint-plugin-jsx-a11y": "^6.1.2",
"eslint-plugin-mocha": "^5.2.0",
"eslint-plugin-no-unsanitized": "^3.0.2",
Expand All @@ -345,13 +345,13 @@
"grunt-peg": "^2.0.1",
"grunt-run": "0.7.0",
"gulp-babel": "^7.0.1",
"gulp-sourcemaps": "1.7.3",
"gulp-sourcemaps": "2.6.4",
"has-ansi": "^3.0.0",
"image-diff": "1.6.0",
"intl-messageformat-parser": "^1.4.0",
"istanbul-instrumenter-loader": "3.0.1",
"jest": "^23.5.0",
"jest-cli": "^23.5.0",
"jest": "^23.6.0",
"jest-cli": "^23.6.0",
"jest-raw-loader": "^1.0.1",
"jimp": "0.2.28",
"json5": "^1.0.1",
Expand All @@ -369,7 +369,6 @@
"load-grunt-config": "0.19.2",
"makelogs": "^4.3.0",
"mocha": "3.3.0",
"mock-fs": "^4.4.2",
"murmurhash3js": "3.0.1",
"mutation-observer": "^1.0.3",
"nock": "8.0.0",
Expand Down Expand Up @@ -400,7 +399,7 @@
"zlib": "^1.0.5"
},
"engines": {
"node": "8.14.0",
"node": "10.14.1",
"yarn": "^1.10.1"
}
}
4 changes: 2 additions & 2 deletions packages/kbn-babel-code-parser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"url": "https://github.com/elastic/kibana/tree/master/packages/kbn-babel-code-parser"
},
"scripts": {
"build": "babel src --out-dir target --quiet",
"kbn:bootstrap": "yarn build",
"build": "babel src --out-dir target",
"kbn:bootstrap": "yarn build --quiet",
"kbn:watch": "yarn build --watch"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-config-schema/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"typescript": "^3.0.3"
},
"peerDependencies": {
"joi": "10.4.1",
"joi": "^13.5.2",
"moment": "^2.20.1",
"type-detect": "^4.0.8"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-dev-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
"dependencies": {
"chalk": "^2.4.1",
"execa": "^0.10.0",
"execa": "^1.0.0",
"moment": "^2.20.1",
"rxjs": "^6.2.1",
"tree-kill": "^1.2.0",
Expand Down
8 changes: 3 additions & 5 deletions packages/kbn-es/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,14 @@
"chalk": "^2.4.1",
"dedent": "^0.7.0",
"del": "^3.0.0",
"execa": "^0.10.0",
"execa": "^1.0.0",
"getopts": "^2.0.6",
"glob": "^7.1.2",
"mkdirp": "^0.5.1",
"mock-fs": "^4.5.0",
"node-fetch": "^2.0.0",
"simple-git": "^1.91.0",
"tar-fs": "^1.16.0",
"tar-fs": "^1.16.3",
"tree-kill": "^1.1.0",
"yauzl": "^2.10.0",
"zlib": "^1.0.5"
"yauzl": "^2.10.0"
}
}
36 changes: 23 additions & 13 deletions packages/kbn-es/src/utils/decompress.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,40 @@
*/

const { decompress } = require('./decompress');
const mockFs = require('mock-fs');
const fs = require('fs');
const path = require('path');
const mkdirp = require('mkdirp');
const del = require('del');
const os = require('os');

const fixturesFolder = path.resolve(__dirname, '__fixtures__');
const randomDir = Math.random().toString(36);
const tmpFolder = path.resolve(os.tmpdir(), randomDir);
const dataFolder = path.resolve(tmpFolder, 'data');
const esFolder = path.resolve(tmpFolder, '.es');

const zipSnapshot = path.resolve(dataFolder, 'snapshot.zip');
const tarGzSnapshot = path.resolve(dataFolder, 'snapshot.tar.gz');

beforeEach(() => {
mockFs({
'/data': {
'snapshot.zip': fs.readFileSync(path.resolve(__dirname, '__fixtures__/snapshot.zip')),
'snapshot.tar.gz': fs.readFileSync(path.resolve(__dirname, '__fixtures__/snapshot.tar.gz')),
},
'/.es': {},
});
mkdirp.sync(tmpFolder);
mkdirp.sync(dataFolder);
mkdirp.sync(esFolder);

fs.copyFileSync(path.resolve(fixturesFolder, 'snapshot.zip'), zipSnapshot);
fs.copyFileSync(path.resolve(fixturesFolder, 'snapshot.tar.gz'), tarGzSnapshot);
});

afterEach(() => {
mockFs.restore();
del.sync(tmpFolder, { force: true });
});

test('zip strips root directory', async () => {
await decompress('/data/snapshot.zip', '/.es/foo');
expect(fs.readdirSync('/.es/foo/bin')).toContain('elasticsearch.bat');
await decompress(zipSnapshot, path.resolve(esFolder, 'foo'));
expect(fs.readdirSync(path.resolve(esFolder, 'foo/bin'))).toContain('elasticsearch.bat');
});

test('tar strips root directory', async () => {
await decompress('/data/snapshot.tar.gz', '/.es/foo');
expect(fs.readdirSync('/.es/foo/bin')).toContain('elasticsearch');
await decompress(tarGzSnapshot, path.resolve(esFolder, 'foo'));
expect(fs.readdirSync(path.resolve(esFolder, 'foo/bin'))).toContain('elasticsearch');
});
24 changes: 12 additions & 12 deletions packages/kbn-es/src/utils/extract_config_files.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@
* under the License.
*/

jest.mock('fs', () => ({
readFileSync: jest.fn(),
existsSync: jest.fn().mockImplementation(() => true),
writeFileSync: jest.fn(),
}));

const { extractConfigFiles } = require('./extract_config_files');
const mockFs = require('mock-fs');
const fs = require('fs');

beforeEach(() => {
mockFs({
'/data': {
'foo.yml': '',
},
'/es': {},
});
afterEach(() => {
jest.clearAllMocks();
});

afterEach(() => {
mockFs.restore();
afterAll(() => {
jest.restoreAllMocks();
});

test('returns config with local paths', () => {
Expand All @@ -43,8 +43,8 @@ test('returns config with local paths', () => {
test('copies file', () => {
extractConfigFiles(['path=/data/foo.yml'], '/es');

expect(fs.existsSync('/es/config/foo.yml')).toBe(true);
expect(fs.existsSync('/data/foo.yml')).toBe(true);
expect(fs.readFileSync.mock.calls[0][0]).toEqual('/data/foo.yml');
expect(fs.writeFileSync.mock.calls[0][0]).toEqual('/es/config/foo.yml');
});

test('ignores non-paths', () => {
Expand Down
47 changes: 26 additions & 21 deletions packages/kbn-es/src/utils/find_most_recently_changed.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,38 @@
* under the License.
*/

const mockFs = require('mock-fs');
const { findMostRecentlyChanged } = require('./find_most_recently_changed');

beforeEach(() => {
mockFs({
'/data': {
'oldest.yml': mockFs.file({
content: 'foo',
jest.mock('fs', () => ({
statSync: jest.fn().mockImplementation(path => {
if (path.includes('oldest')) {
return {
ctime: new Date(2018, 2, 1),
}),
'newest.yml': mockFs.file({
content: 'bar',
};
}

if (path.includes('newest')) {
return {
ctime: new Date(2018, 2, 3),
}),
'middle.yml': mockFs.file({
content: 'baz',
};
}

if (path.includes('middle')) {
return {
ctime: new Date(2018, 2, 2),
}),
},
});
});
};
}
}),
readdirSync: jest.fn().mockImplementation(() => {
return ['oldest.yml', 'newest.yml', 'middle.yml'];
}),
}));

afterEach(() => {
mockFs.restore();
});
const { findMostRecentlyChanged } = require('./find_most_recently_changed');

test('returns newest file', () => {
const file = findMostRecentlyChanged('/data/*.yml');
expect(file).toEqual('/data/newest.yml');
});

afterAll(() => {
jest.restoreAllMocks();
});
2 changes: 1 addition & 1 deletion packages/kbn-i18n/src/__snapshots__/loader.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

exports[`I18n loader registerTranslationFile should throw error if path to translation file is not an absolute 1`] = `"Paths to translation files must be absolute. Got relative path: \\"./en.json\\""`;

exports[`I18n loader registerTranslationFile should throw error if path to translation file is not specified 1`] = `"Path must be a string. Received undefined"`;
exports[`I18n loader registerTranslationFile should throw error if path to translation file is not specified 1`] = `"The \\"path\\" argument must be of type string. Received type undefined"`;
2 changes: 1 addition & 1 deletion packages/kbn-plugin-generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"dependencies": {
"chalk": "^2.4.1",
"dedent": "^0.7.0",
"execa": "^0.9.0",
"execa": "^1.0.0",
"getopts": "^2.0.0",
"lodash.camelcase": "^4.3.0",
"lodash.kebabcase": "^4.1.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-plugin-helpers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"argv-split": "^2.0.1",
"commander": "^2.9.0",
"del": "^2.2.2",
"execa": "^0.10.0",
"execa": "^1.0.0",
"gulp-rename": "1.2.2",
"gulp-zip": "^4.1.0",
"inquirer": "^1.2.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

const { resolve } = require('path');
const { readdirSync, existsSync, unlink } = require('fs');
const { readdirSync, existsSync, unlinkSync } = require('fs');
const del = require('del');
const createBuild = require('../create_build');

Expand Down Expand Up @@ -96,7 +96,7 @@ describe('creating the build', () => {
afterEach(() => {
PLUGIN.skipInstallDependencies = false;
PLUGIN.styleSheetToCompile = undefined;
unlink(cssPath);
unlinkSync(cssPath);
});

it('produces CSS', async () => {
Expand Down
Loading

0 comments on commit 45a6770

Please sign in to comment.