kibana/x-pack/tasks/helpers/pkg.ts
Spencer ef6727cc52
[7.x] Update gulp related packages (major) (#46665 and #47421) (#47409)
* Update gulp related packages (major) (#46665)

* Update gulp related packages

* ts-ify and gulp4-ify x-pack tasks, remove unused canvas tasks

* remove unnecessary gulp.TaskFunction usage

* fix old references

* update renovate config

* move constants into helpers directory

* typo

* compact tasks a bit, remove unnecessary paths

* fix build directories

* deprecate testonly task

* rather than justifying an unjustifiable ts-ignore, ts-ify the imported module

* update renovate config

* update browser download tests to mock axios

* add root index.d.ts to tsconfig

* export BrowserType

* remove unnecessary `@ts-ignore`

* use consistent casing

* correct import for createAutoJUnitReporter

* Update gulp related packages (#47421)

(cherry picked from commit 35751f9828)
2019-10-06 22:49:28 -07:00

33 lines
931 B
TypeScript

/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import Fs from 'fs';
import semver from 'semver';
interface PackageJson {
name: string;
version: string;
dependencies: Record<string, string>;
devDependencies: Record<string, string>;
[key: string]: unknown;
}
const PKG_PATH = require.resolve('../../package.json');
export const PKG: PackageJson = JSON.parse(Fs.readFileSync(PKG_PATH, 'utf8'));
export const PKG_VERSION = PKG.version;
export const PKG_NAME = PKG.name;
if (!PKG_VERSION) {
throw new Error('No "version" found in package.json');
}
if (!PKG_NAME) {
throw new Error('No "name" found in package.json');
}
if (!semver.valid(PKG_VERSION)) {
throw new Error(`Version is not valid semver: ${PKG_VERSION}`);
}