Skip to content

Commit

Permalink
Move src/dev/run to @kbn/dev-utils (#43387) (#43490)
Browse files Browse the repository at this point in the history
* move src/dev/run into `@kbn/dev-utils`

* forgot to save a replacement

# Conflicts:
#	packages/kbn-dev-utils/src/index.ts
#	packages/kbn-test/src/functional_test_runner/cli.ts
#	src/dev/renovate/run_build_renovate_config_cli.ts
#	src/dev/run_i18n_check.ts
#	src/dev/run_i18n_extract.ts
#	src/dev/run_i18n_integrate.ts
  • Loading branch information
Spencer committed Aug 16, 2019
1 parent 2b4f2a2 commit 0f77462
Show file tree
Hide file tree
Showing 37 changed files with 42 additions and 34 deletions.
2 changes: 2 additions & 0 deletions packages/kbn-dev-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
},
"dependencies": {
"chalk": "^2.4.1",
"dedent": "^0.7.0",
"execa": "^1.0.0",
"exit-hook": "^2.2.0",
"getopts": "^2.2.5",
"moment": "^2.20.1",
"rxjs": "^6.2.1",
"tree-kill": "^1.2.0",
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-dev-utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@
export { withProcRunner } from './proc_runner';
export { ToolingLog, ToolingLogTextWriter, pickLevelFromFlags } from './tooling_log';
export { createAbsolutePathSerializer } from './serializers';
export { run, createFailError, createFlagError, combineErrors, isFailError } from './run';
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# dev/run
# @kbn/dev-utils > run()

Helper functions for writing little scripts for random build/ci/dev tasks.

Expand All @@ -8,7 +8,7 @@ Define the function that should validate the CLI arguments and call your task fn

```ts
// dev/my_task/run_my_task.ts
import { createFlagError, run } from '../run';
import { createFlagError, run } from '@kbn/dev-utils';

run(
async ({ flags, log }) => {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
// @ts-ignore @types are outdated and module is super simple
import exitHook from 'exit-hook';

import { pickLevelFromFlags, ToolingLog } from '@kbn/dev-utils';
import { pickLevelFromFlags, ToolingLog } from '../tooling_log';
import { createFlagError, isFailError } from './fail';
import { Flags, getFlags, getHelp } from './flags';

Expand Down
2 changes: 1 addition & 1 deletion src/dev/eslint/lint_files.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import { CLIEngine } from 'eslint';

import { createFailError } from '../run';
import { createFailError } from '@kbn/dev-utils';
import { REPO_ROOT } from '../constants';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/dev/i18n/extract_default_translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
} from './extractors';
import { globAsync, readFileAsync, normalizePath } from './utils';

import { createFailError, isFailError } from '../run';
import { createFailError, isFailError } from '@kbn/dev-utils';

function addMessageToMap(targetMap, key, value, reporter) {
const existingValue = targetMap.get(key);
Expand Down
2 changes: 1 addition & 1 deletion src/dev/i18n/extractors/code.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
import { extractI18nCallMessages } from './i18n_call';
import { createParserErrorMessage, isI18nTranslateFunction, traverseNodes } from '../utils';
import { extractIntlMessages, extractFormattedMessages } from './react';
import { createFailError, isFailError } from '../../run';
import { createFailError, isFailError } from '@kbn/dev-utils';

/**
* Detect Intl.formatMessage() function call (React).
Expand Down
2 changes: 1 addition & 1 deletion src/dev/i18n/extractors/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import {
extractDescriptionValueFromNode,
} from '../utils';
import { DEFAULT_MESSAGE_KEY, DESCRIPTION_KEY, VALUES_KEY } from '../constants';
import { createFailError, isFailError } from '../../run';
import { createFailError, isFailError } from '@kbn/dev-utils';

/**
* Find all substrings of "{{ any text }}" pattern allowing '{' and '}' chars in single quote strings
Expand Down
2 changes: 1 addition & 1 deletion src/dev/i18n/extractors/i18n_call.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
extractValuesKeysFromNode,
} from '../utils';
import { DEFAULT_MESSAGE_KEY, DESCRIPTION_KEY, VALUES_KEY } from '../constants';
import { createFailError } from '../../run';
import { createFailError } from '@kbn/dev-utils';

/**
* Extract messages from `funcName('id', { defaultMessage: 'Message text' })` call expression AST
Expand Down
2 changes: 1 addition & 1 deletion src/dev/i18n/extractors/pug.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { parse } from '@babel/parser';

import { extractI18nCallMessages } from './i18n_call';
import { isI18nTranslateFunction, traverseNodes, createParserErrorMessage } from '../utils';
import { createFailError, isFailError } from '../../run';
import { createFailError, isFailError } from '@kbn/dev-utils';

/**
* Matches `i18n(...)` in `#{i18n('id', { defaultMessage: 'Message text' })}`
Expand Down
2 changes: 1 addition & 1 deletion src/dev/i18n/extractors/react.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
checkValuesProperty,
} from '../utils';
import { DEFAULT_MESSAGE_KEY, VALUES_KEY, DESCRIPTION_KEY } from '../constants';
import { createFailError } from '../../run';
import { createFailError } from '@kbn/dev-utils';

/**
* Extract default messages from ReactJS intl.formatMessage(...) AST
Expand Down
2 changes: 1 addition & 1 deletion src/dev/i18n/integrate_locale_files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { ToolingLog } from '@kbn/dev-utils';
import { i18n } from '@kbn/i18n';
import path from 'path';

import { createFailError } from '@kbn/dev-utils';
import {
accessAsync,
checkValuesProperty,
Expand All @@ -33,7 +34,6 @@ import {
// @ts-ignore
} from './utils';

import { createFailError } from '../run';
import { I18nConfig } from './config';
import { serializeToJson } from './serializers';

Expand Down
2 changes: 1 addition & 1 deletion src/dev/i18n/tasks/extract_default_translations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import chalk from 'chalk';
import { createFailError } from '../../run';
import { createFailError } from '@kbn/dev-utils';
import { ErrorReporter, extractMessagesFromPathToMap, filterConfigPaths, I18nConfig } from '..';

export function extractDefaultMessages({
Expand Down
2 changes: 1 addition & 1 deletion src/dev/i18n/tasks/extract_untracked_translations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { createFailError } from '../../run';
import { createFailError } from '@kbn/dev-utils';
import {
I18nConfig,
matchEntriesWithExctractors,
Expand Down
2 changes: 1 addition & 1 deletion src/dev/i18n/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import path from 'path';
import chalk from 'chalk';
import parser from 'intl-messageformat-parser';

import { createFailError } from '../run';
import { createFailError } from '@kbn/dev-utils';

const ESCAPE_LINE_BREAK_REGEX = /(?<!\\)\\\n/g;
const HTML_LINE_BREAK_REGEX = /[\s]*\n[\s]*/g;
Expand Down
2 changes: 1 addition & 1 deletion src/dev/license_checker/run_check_licenses_cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
* under the License.
*/

import { run } from '@kbn/dev-utils';
import { getInstalledPackages } from '../npm';
import { run } from '../run';

import { LICENSE_WHITELIST, DEV_ONLY_LICENSE_WHITELIST, LICENSE_OVERRIDES } from './config';
import { assertLicensesValid } from './valid';
Expand Down
2 changes: 1 addition & 1 deletion src/dev/license_checker/valid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import dedent from 'dedent';
import { createFailError } from '../run';
import { createFailError } from '@kbn/dev-utils';

interface Options {
packages: Array<{
Expand Down
2 changes: 1 addition & 1 deletion src/dev/precommit_hook/check_file_casing.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { relative, basename } from 'path';

import { dim } from 'chalk';

import { createFailError } from '../run';
import { createFailError } from '@kbn/dev-utils';
import { matchesAnyGlob } from '../globs';

import {
Expand Down
2 changes: 1 addition & 1 deletion src/dev/prs/github_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import axios, { AxiosError, AxiosResponse } from 'axios';

import { createFailError } from '../run';
import { createFailError } from '@kbn/dev-utils';

interface ResponseError extends AxiosError {
request: any;
Expand Down
2 changes: 1 addition & 1 deletion src/dev/prs/pr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { createFlagError } from '../run';
import { createFlagError } from '@kbn/dev-utils';

const isNum = (input: string) => {
return /^\d+$/.test(input);
Expand Down
2 changes: 1 addition & 1 deletion src/dev/prs/run_update_prs_cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import chalk from 'chalk';
import { first, tap } from 'rxjs/operators';
import dedent from 'dedent';

import { run, createFlagError } from '@kbn/dev-utils';
import { getLine$ } from './helpers';
import { run, createFlagError } from '../run';
import { Pr } from './pr';
import { GithubApi } from './github_api';

Expand Down
2 changes: 1 addition & 1 deletion src/dev/run_check_file_casing.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import globby from 'globby';

import { run } from './run';
import { run } from '@kbn/dev-utils';
import { File } from './file';
import { REPO_ROOT } from './constants';
import { checkFileCasing } from './precommit_hook/check_file_casing';
Expand Down
2 changes: 1 addition & 1 deletion src/dev/run_i18n_check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
import chalk from 'chalk';
import Listr from 'listr';

import { createFailError, run } from '@kbn/dev-utils';
import { ErrorReporter, mergeConfigs } from './i18n';
import { extractDefaultMessages, extractUntrackedMessages, checkCompatibility } from './i18n/tasks';
import { createFailError, run } from './run';

run(
async ({
Expand Down
2 changes: 1 addition & 1 deletion src/dev/run_i18n_extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import chalk from 'chalk';
import Listr from 'listr';
import { resolve } from 'path';

import { createFailError, run } from '@kbn/dev-utils';
import {
ErrorReporter,
mergeConfigs,
Expand All @@ -29,7 +30,6 @@ import {
writeFileAsync,
} from './i18n';
import { extractDefaultMessages } from './i18n/tasks';
import { createFailError, run } from './run';

run(
async ({
Expand Down
2 changes: 1 addition & 1 deletion src/dev/run_i18n_integrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
import chalk from 'chalk';
import Listr from 'listr';

import { createFailError, run } from '@kbn/dev-utils';
import { ErrorReporter, integrateLocaleFiles, mergeConfigs } from './i18n';
import { extractDefaultMessages } from './i18n/tasks';
import { createFailError, run } from './run';

run(
async ({
Expand Down
2 changes: 1 addition & 1 deletion src/dev/run_precommit_hook.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { run, combineErrors } from './run';
import { run, combineErrors } from '@kbn/dev-utils';
import * as Eslint from './eslint';
import * as Sasslint from './sasslint';
import { getFilesForCommit, checkFileCasing } from './precommit_hook';
Expand Down
2 changes: 1 addition & 1 deletion src/dev/run_register_git_hook.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { run, createFailError } from './run';
import { run, createFailError } from '@kbn/dev-utils';
import { registerPrecommitGitHook } from './register_git_hook';

run(async ({ log }) => {
Expand Down
2 changes: 1 addition & 1 deletion src/dev/sass/build_sass.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { resolve } from 'path';

import { toArray } from 'rxjs/operators';

import { createFailError } from '../run';
import { createFailError } from '@kbn/dev-utils';
import { findPluginSpecs } from '../../legacy/plugin_discovery';
import { collectUiExports } from '../../legacy/ui';
import { buildAll } from '../../legacy/server/sass/build_all';
Expand Down
2 changes: 1 addition & 1 deletion src/dev/sass/run_build_sass_cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { run } from '../run';
import { run } from '@kbn/dev-utils';
import { REPO_ROOT } from '../constants';
import { buildSass } from './build_sass';

Expand Down
2 changes: 1 addition & 1 deletion src/dev/sasslint/lint_files.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import sassLint from 'sass-lint';
import path from 'path';
import { createFailError } from '../run';
import { createFailError } from '@kbn/dev-utils';

/**
* Lints a list of files with eslint. eslint reports are written to the log
Expand Down
2 changes: 1 addition & 1 deletion src/dev/typescript/run_check_ts_projects_cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { resolve } from 'path';

import execa from 'execa';

import { run } from '../run';
import { run } from '@kbn/dev-utils';

const REPO_ROOT = resolve(__dirname, '../../../');
import { File } from '../file';
Expand Down
2 changes: 1 addition & 1 deletion src/functional_test_runner/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import { resolve } from 'path';

import { run } from '../dev/run';
import { run } from '@kbn/dev-utils';
import { FunctionalTestRunner } from './functional_test_runner';

run(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

import { resolve } from 'path';

// eslint-disable-next-line import/no-extraneous-dependencies
/* eslint-disable-next-line import/no-extraneous-dependencies */
import madge from 'madge';

import { run, createFailError } from '../../../../../../src/dev/run';
/* eslint-disable-next-line import/no-extraneous-dependencies */
import { run, createFailError } from '@kbn/dev-utils';

run(
async ({ log }) => {
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13283,6 +13283,11 @@ getopts@^2.2.4:
resolved "https://registry.yarnpkg.com/getopts/-/getopts-2.2.4.tgz#3137fe8a5fddf304904059a851bdc1c22f0f54fb"
integrity sha512-Rz7DGyomZjrenu9Jx4qmzdlvJgvrEFHXHvjK0FcZtcTC1U5FmES7OdZHUwMuSnEE6QvBvwse1JODKj7TgbSEjQ==

getopts@^2.2.5:
version "2.2.5"
resolved "https://registry.yarnpkg.com/getopts/-/getopts-2.2.5.tgz#67a0fe471cacb9c687d817cab6450b96dde8313b"
integrity sha512-9jb7AW5p3in+IiJWhQiZmmwkpLaR/ccTWdWQCtZM66HJcHHLegowh4q4tSD7gouUyeNvFWRavfK9GXosQHDpFA==

getos@3.1.1:
version "3.1.1"
resolved "https://registry.yarnpkg.com/getos/-/getos-3.1.1.tgz#967a813cceafee0156b0483f7cffa5b3eff029c5"
Expand Down

0 comments on commit 0f77462

Please sign in to comment.