mirror of
https://github.com/elastic/kibana.git
synced 2025-04-22 08:49:27 -04:00
* [npm] upgrade to RxJS 6 (#18885) This PR upgrades RxJS to version 6 and switches to a fork of `stream-to-observable` which includes an updated version of `any-observable` that supports RxJS 6 until https://github.com/jamestalmage/stream-to-observable/pull/10 is merged. The primary change in this version of RxJS is the movement of stream operators from `Obersable.prototype` to the `rxjs/operators` module. Some of the operators, like `catch` and `do`, have been renamed (`catchError`, and `tap`). The Obsevable factories have also been moved from static methods on the `Observable` class to named exports of the root `rxjs` module. Some of those factories have also changed slightly, like `fromEvent` which now emits arrays if the event handler is called with multiple arguments. ```js // import the Rx namespace to get the Observable factories import * as Rx from 'rxjs'; // import the operators as named imports import { map, tap, switchMap } from 'rxjs/operators'; ``` * [rxjs/dev-utils] fix old operator usage * [rxjs/dev-utils] remove one more old operator
87 lines
2.6 KiB
JavaScript
87 lines
2.6 KiB
JavaScript
/*
|
|
* Licensed to Elasticsearch B.V. under one or more contributor
|
|
* license agreements. See the NOTICE file distributed with
|
|
* this work for additional information regarding copyright
|
|
* ownership. Elasticsearch B.V. licenses this file to you under
|
|
* the Apache License, Version 2.0 (the "License"); you may
|
|
* not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing,
|
|
* software distributed under the License is distributed on an
|
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
* KIND, either express or implied. See the License for the
|
|
* specific language governing permissions and limitations
|
|
* under the License.
|
|
*/
|
|
|
|
import { toArray } from 'rxjs/operators';
|
|
import { fromRoot, formatListAsProse } from '../src/utils';
|
|
import { findPluginSpecs } from '../src/plugin_discovery';
|
|
import { collectUiExports } from '../src/ui';
|
|
import { I18n } from '../src/ui/ui_i18n/i18n';
|
|
|
|
import * as i18nVerify from './utils/i18n_verify_keys';
|
|
|
|
export default function (grunt) {
|
|
grunt.registerTask('verifyTranslations', async function () {
|
|
const done = this.async();
|
|
|
|
try {
|
|
const { spec$ } = findPluginSpecs({
|
|
env: 'production',
|
|
plugins: {
|
|
scanDirs: [fromRoot('src/core_plugins')]
|
|
}
|
|
});
|
|
|
|
const specs = await spec$.pipe(toArray()).toPromise();
|
|
const uiExports = collectUiExports(specs);
|
|
await verifyTranslations(uiExports);
|
|
|
|
done();
|
|
} catch (error) {
|
|
done(error);
|
|
}
|
|
});
|
|
|
|
}
|
|
|
|
async function verifyTranslations(uiExports) {
|
|
const keysUsedInViews = [];
|
|
|
|
// Search files for used translation keys
|
|
const translationPatterns = [
|
|
{ regexp: 'i18n\\(\'(.*)\'\\)',
|
|
parsePaths: [fromRoot('src/ui/ui_render/views/*.jade')] }
|
|
];
|
|
for (const { regexp, parsePaths } of translationPatterns) {
|
|
const keys = await i18nVerify.getTranslationKeys(regexp, parsePaths);
|
|
for (const key of keys) {
|
|
keysUsedInViews.push(key);
|
|
}
|
|
}
|
|
|
|
// get all of the translations from uiExports
|
|
const translations = await I18n.getAllTranslationsFromPaths(uiExports.translationPaths);
|
|
const keysWithoutTranslations = Object.entries(
|
|
i18nVerify.getNonTranslatedKeys(keysUsedInViews, translations)
|
|
);
|
|
|
|
if (!keysWithoutTranslations.length) {
|
|
return;
|
|
}
|
|
|
|
throw new Error(
|
|
'\n' +
|
|
'\n' +
|
|
'The following keys are used in angular/jade views but are not translated:\n' +
|
|
keysWithoutTranslations.map(([locale, keys]) => (
|
|
` - ${locale}: ${formatListAsProse(keys)}`
|
|
)).join('\n') +
|
|
'\n' +
|
|
'\n'
|
|
);
|
|
}
|