[npm] prepare @kbn/datemath for publishing (#26559)

We need to share `@kbn/datemath` with `@elastic/eui`, and rather than making them rely on Kibana for their dependencies we've decided to republish `@kbn/datemath` as `@elastic/datemath`. This isn't something we want to do often, so please check with the platform team if you'd like to do this for another module.
This commit is contained in:
Spencer 2018-12-03 16:01:16 -08:00 committed by GitHub
parent 168cb07cd2
commit 0b4ae5020b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
37 changed files with 43 additions and 49 deletions

View file

@ -63,7 +63,7 @@ module.exports = {
'packages/kbn-config-schema/**/*',
'packages/kbn-pm/**/*',
'packages/kbn-es/**/*',
'packages/kbn-datemath/**/*',
'packages/elastic-datemath/**/*',
'packages/kbn-i18n/**/*',
'packages/kbn-dev-utils/**/*',
'packages/kbn-plugin-helpers/**/*',

View file

@ -96,7 +96,7 @@
"@elastic/ui-ace": "0.2.3",
"@kbn/babel-preset": "1.0.0",
"@kbn/config-schema": "1.0.0",
"@kbn/datemath": "5.0.0",
"@elastic/datemath": "5.0.0",
"@kbn/es-query": "1.0.0",
"@kbn/i18n": "1.0.0",
"@kbn/interpreter": "1.0.0",

View file

@ -12,21 +12,22 @@ tl;dr:
## Using these packages
We no longer publish these packages to the npm registry. Now, instead of
specifying a version when including these packages, we rely on `link:`
dependencies in Yarn, which sets up a symlink to the package.
specifying a version when including these packages, we rely on yarn workspaces,
which sets up a symlink to the package.
For example if you want to use the `@kbn/datemath` package in Kibana itself, you
For example if you want to use the `@kbn/i18n` package in Kibana itself, you
can specify the dependency like this:
```
"@kbn/datemath": "link:packages/kbn-datemath"
"@kbn/i18n": "1.0.0"
```
However, if you want to use this from a Kibana plugin, you need to account for
the relative location of the Kibana repo, so it would instead be:
However, if you want to use this from a Kibana plugin, you need to use a `link:`
dependency and account for the relative location of the Kibana repo, so it would
instead be:
```
"@kbn/datemath": "link:../../kibana/packages/kbn-datemath"
"@kbn/i18n": "link:../../kibana/packages/kbn-i18n"
```
How all of this works is described in more detail in the
@ -35,8 +36,8 @@ How all of this works is described in more detail in the
## Creating a new package
Create a new sub-folder. The name of the folder should mirror the `name` in the
package's `package.json`. E.g. if the name is `@kbn/datemath` the folder name
should be `kbn-datemath`.
package's `package.json`. E.g. if the name is `@kbn/i18n` the folder name
should be `kbn-i18n`.
All new packages should use the `@kbn` namespace, and should be marked with
`"private": true`.

View file

@ -1,5 +1,5 @@
{
"name": "@kbn/datemath",
"name": "@elastic/datemath",
"version": "5.0.0",
"description": "elasticsearch datemath parser, used in kibana",
"license": "Apache-2.0",

View file

@ -55,7 +55,7 @@ scripts, while still having a nice developer experience.
### Internal usage
For packages that are referenced within the Kibana repo itself (for example,
using the `@kbn/datemath` package from an `x-pack` plugin), we are leveraging
using the `@kbn/i18n` package from an `x-pack` plugin), we are leveraging
Yarn's workspaces feature. This allows yarn to optimize node_modules within
the entire repo to avoid duplicate modules by hoisting common packages as high
in the dependency tree as possible.
@ -63,7 +63,7 @@ in the dependency tree as possible.
To reference a package from within the Kibana repo, simply use the current
version number from that package's package.json file. Then, running `yarn kbn
bootstrap` will symlink that package into your dependency tree. That means
you can make changes to `@kbn/datematch` and immediately have them available
you can make changes to `@kbn/i18n` and immediately have them available
in Kibana itself. No `npm publish` needed anymore — Kibana will always rely
directly on the code that's in the local packages.
@ -75,7 +75,7 @@ relative location to a package instead of a version when adding it to
`package.json`. For example:
```
"@kbn/datemath": "link:packages/kbn-datemath"
"@kbn/i18n": "link:packages/kbn-i18n"
```
Now when you run `yarn` it will set up a symlink to this folder instead of
@ -84,7 +84,7 @@ use the versions of the package that is bundled with the Kibana version they
are running inside of.
```
"@kbn/datemath": "link:../../kibana/packages/kbn-date-math"
"@kbn/i18n": "link:../../kibana/packages/kbn-date-math"
```
This works because we moved to a strict location of Kibana plugins,
@ -129,7 +129,7 @@ yarn kbn bootstrap --skip-kibana-extra
Or just skip few selected packages:
```
yarn kbn bootstrap --exclude @kbn/pm --exclude @kbn/datemath
yarn kbn bootstrap --exclude @kbn/pm --exclude @kbn/i18n
```
For more details, run:

View file

@ -69,7 +69,7 @@ export function runMochaCli() {
if (!opts._.length) {
globby.sync([
'src/**/__tests__/**/*.js',
'packages/kbn-datemath/test/**/*.js',
'packages/elastic-datemath/test/**/*.js',
'packages/kbn-dev-utils/src/**/__tests__/**/*.js',
'tasks/**/__tests__/**/*.js',
], {

View file

@ -24,7 +24,7 @@ import chrome from 'ui/chrome';
import { getSort } from 'ui/doc_table/lib/get_sort';
import * as columnActions from 'ui/doc_table/actions/columns';
import * as filterActions from 'ui/doc_table/actions/filter';
import dateMath from '@kbn/datemath';
import dateMath from '@elastic/datemath';
import 'ui/doc_table';
import 'ui/visualize';
import 'ui/fixed_scroll';

View file

@ -17,7 +17,7 @@
* under the License.
*/
import dateMath from '@kbn/datemath';
import dateMath from '@elastic/datemath';
export const GTE_INTERVAL_RE = new RegExp(`^>=([\\d\\.]*\\s*(${dateMath.units.join('|')}))$`);
export const INTERVAL_STRING_RE = new RegExp('^([0-9\\.]*)\\s*(' + dateMath.units.join('|') + ')$');

View file

@ -19,7 +19,7 @@
import _ from 'lodash';
import moment from 'moment';
import dateMath from '@kbn/datemath';
import dateMath from '@elastic/datemath';
// Assume interval is in the form (value)(unit), such as "1h"
const INTERVAL_STRING_RE = new RegExp(

View file

@ -19,7 +19,7 @@
import $ from 'jquery';
import moment from 'moment';
import dateMath from '@kbn/datemath';
import dateMath from '@elastic/datemath';
import * as vega from 'vega-lib';
import * as vegaLite from 'vega-lite';
import { Utils } from '../data_model/utils';

View file

@ -17,7 +17,7 @@
* under the License.
*/
import dateMath from '@kbn/datemath';
import dateMath from '@elastic/datemath';
import { uiModules } from '../modules';
uiModules.get('kibana').directive('validateDateMath', function () {

View file

@ -17,7 +17,7 @@
* under the License.
*/
import dateMath from '@kbn/datemath';
import dateMath from '@elastic/datemath';
import { parseEsInterval } from 'ui/utils/parse_es_interval';
const unitsDesc = dateMath.unitsDesc;

View file

@ -18,7 +18,7 @@
*/
import _ from 'lodash';
import dateMath from '@kbn/datemath';
import dateMath from '@elastic/datemath';
export function calculateBounds(timeRange, options = {}) {
return {

View file

@ -17,7 +17,7 @@
* under the License.
*/
import dateMath from '@kbn/datemath';
import dateMath from '@elastic/datemath';
import moment from 'moment';
import _ from 'lodash';
import { relativeOptions } from './relative_options';

View file

@ -17,7 +17,7 @@
* under the License.
*/
import dateMath from '@kbn/datemath';
import dateMath from '@elastic/datemath';
import moment from 'moment';
import { timeUnits } from './time_units';

View file

@ -25,7 +25,7 @@ import './absolute_panel';
import _ from 'lodash';
import { relativeOptions } from './relative_options';
import { parseRelativeParts } from './parse_relative_parts';
import dateMath from '@kbn/datemath';
import dateMath from '@elastic/datemath';
import moment from 'moment';
import './timepicker.less';
import '../directives/input_datetime';

View file

@ -17,7 +17,7 @@
* under the License.
*/
import { Unit } from '@kbn/datemath';
import { Unit } from '@elastic/datemath';
import { i18n } from '@kbn/i18n';
export class InvalidEsCalendarIntervalError extends Error {

View file

@ -17,7 +17,7 @@
* under the License.
*/
import dateMath, { Unit } from '@kbn/datemath';
import dateMath, { Unit } from '@elastic/datemath';
import { InvalidEsCalendarIntervalError } from './invalid_es_calendar_interval_error';
import { InvalidEsIntervalFormatError } from './invalid_es_interval_format_error';

View file

@ -19,7 +19,7 @@
import _ from 'lodash';
import moment from 'moment';
import dateMath from '@kbn/datemath';
import dateMath from '@elastic/datemath';
// Assume interval is in the form (value)(unit), such as "1h"
const INTERVAL_STRING_RE = new RegExp('^([0-9\\.]*)\\s*(' + dateMath.units.join('|') + ')$');

View file

@ -17,7 +17,7 @@
* under the License.
*/
import dateMath from '@kbn/datemath';
import dateMath from '@elastic/datemath';
import { leastCommonMultiple } from '../../utils/math';
import { parseEsInterval } from '../../utils/parse_es_interval';

View file

@ -18,7 +18,7 @@
*/
import d3 from 'd3';
import dateMath from '@kbn/datemath';
import dateMath from '@elastic/datemath';
export function VislibVisualizationsTimeMarkerProvider() {

View file

@ -122,7 +122,7 @@
"@elastic/node-phantom-simple": "2.2.4",
"@elastic/numeral": "2.3.2",
"@kbn/babel-preset": "1.0.0",
"@kbn/datemath": "5.0.0",
"@elastic/datemath": "5.0.0",
"@kbn/es-query": "1.0.0",
"@kbn/i18n": "1.0.0",
"@kbn/ui-framework": "1.0.0",

View file

@ -7,7 +7,7 @@
import moment from 'moment';
import dateMath from '@kbn/datemath';
import dateMath from '@elastic/datemath';
// Assume interval is in the form (value)(unit), such as "1h"
const INTERVAL_STRING_RE = new RegExp('^([0-9]*)\\s*(' + dateMath.units.join('|') + ')$');

View file

@ -12,7 +12,7 @@ import { aggTypes } from 'ui/agg_types';
import { addJobValidationMethods } from 'plugins/ml/../common/util/validation_utils';
import { parseInterval } from 'plugins/ml/../common/util/parse_interval';
import dateMath from '@kbn/datemath';
import dateMath from '@elastic/datemath';
import angular from 'angular';
import uiRoutes from 'ui/routes';

View file

@ -12,7 +12,7 @@ import { aggTypes } from 'ui/agg_types/index';
import { addJobValidationMethods } from 'plugins/ml/../common/util/validation_utils';
import { parseInterval } from 'plugins/ml/../common/util/parse_interval';
import dateMath from '@kbn/datemath';
import dateMath from '@elastic/datemath';
import angular from 'angular';
import uiRoutes from 'ui/routes';

View file

@ -8,7 +8,7 @@
import _ from 'lodash';
import angular from 'angular';
import dateMath from '@kbn/datemath';
import dateMath from '@elastic/datemath';
import { isJobIdValid, prefixDatafeedId } from 'plugins/ml/../common/util/job_utils';
import { SearchItemsProvider, addNewJobToRecentlyAccessed } from 'plugins/ml/jobs/new_job/utils/new_job_utils';

View file

@ -12,7 +12,7 @@ import { aggTypes } from 'ui/agg_types';
import { addJobValidationMethods } from 'plugins/ml/../common/util/validation_utils';
import { parseInterval } from 'plugins/ml/../common/util/parse_interval';
import dateMath from '@kbn/datemath';
import dateMath from '@elastic/datemath';
import angular from 'angular';
import uiRoutes from 'ui/routes';

View file

@ -13,7 +13,7 @@
import _ from 'lodash';
import moment from 'moment';
import dateMath from '@kbn/datemath';
import dateMath from '@elastic/datemath';
import { TimeBucketsCalcAutoIntervalProvider } from 'plugins/ml/util/ml_calc_auto_interval';
import { inherits } from 'plugins/ml/util/inherits';

View file

@ -5,7 +5,7 @@
*/
import { get } from 'lodash';
import datemath from '@kbn/datemath';
import datemath from '@elastic/datemath';
export function getAbsoluteTime(time) {
const mode = get(time, 'mode');

View file

@ -22,7 +22,7 @@ import 'plugins/watcher/services/watch';
import 'plugins/watcher/services/interval';
import 'plugins/watcher/services/action_defaults';
import dateMath from '@kbn/datemath';
import dateMath from '@elastic/datemath';
import { toastNotifications } from 'ui/notify';
import { VisualizeOptions } from 'plugins/watcher/models/visualize_options';
import { REFRESH_INTERVALS } from 'plugins/watcher/../common/constants';

View file

@ -717,13 +717,6 @@
lodash "^4.17.10"
to-fast-properties "^2.0.0"
"@elastic/datemath@^4.0.2":
version "4.0.2"
resolved "https://registry.yarnpkg.com/@elastic/datemath/-/datemath-4.0.2.tgz#91417763fa4ec93ad1426cb69aaf2de2e9914a68"
integrity sha1-kUF3Y/pOyTrRQmy2mq8t4umRSmg=
dependencies:
moment "^2.13.0"
"@elastic/eui@0.0.23":
version "0.0.23"
resolved "https://registry.yarnpkg.com/@elastic/eui/-/eui-0.0.23.tgz#01a3d88aeaff175da5d42b70d407d08a32783f3d"