Skip to content

Commit

Permalink
Inject deprecationEntries from jest-config to jest-validate. (#…
Browse files Browse the repository at this point in the history
…6067)

* Move `deprecationEntries` from `jest-config` to `jest-validate`.
Also fix a typo on `jest-runtime`

* Update CHANGELOG.md

* Update .gitignore

* deprecations are an option

* Fix changelog

* Update CHANGELOG.md

* Properly describe changes on changelog.md
  • Loading branch information
Sid Ferreira authored and cpojer committed Apr 28, 2018
1 parent c8be2dc commit 9850275
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
/packages/*/build-es5/
/packages/*/coverage/
/packages/*/node_modules/
/packages/*/package-lock.json

/website/build
/website/node_modules
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

### Features

* `[jest-validate]` Get rid of `jest-config` dependency
([#6067](https://github.com/facebook/jest/pull/6067))
* `[jest-validate]` Adds option to inject `deprecationEntries`
([#6067](https://github.com/facebook/jest/pull/6067))
* `[jest-snapshot]` [**BREAKING**] Concatenate name of test, optional snapshot
name and count ([#6015](https://github.com/facebook/jest/pull/6015))
* `[jest-runtime]` Allow for transform plugins to skip the definition process
Expand Down
7 changes: 5 additions & 2 deletions packages/jest-cli/src/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import type {GlobalConfig, Path, ProjectConfig} from 'types/Config';

import {Console, clearLine, createDirectory} from 'jest-util';
import {validateCLIOptions} from 'jest-validate';
import {readConfig} from 'jest-config';
import {readConfig, deprecationEntries} from 'jest-config';
import {version as VERSION} from '../../package.json';
import * as args from './args';
import chalk from 'chalk';
Expand Down Expand Up @@ -126,7 +126,10 @@ const buildArgv = (maybeArgv: ?Argv, project: ?Path) => {
.check(args.check)
.version(false).argv;

validateCLIOptions(argv, args.options);
validateCLIOptions(
argv,
Object.assign({}, args.options, {deprecationEntries}),
);

return argv;
};
Expand Down
1 change: 1 addition & 0 deletions packages/jest-repl/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"license": "MIT",
"main": "build/index.js",
"dependencies": {
"jest-config": "^22.4.2",
"jest-runtime": "^22.4.2",
"jest-validate": "^22.4.2",
"repl": "^0.1.3",
Expand Down
6 changes: 5 additions & 1 deletion packages/jest-repl/src/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import path from 'path';
import Runtime from 'jest-runtime';
import yargs from 'yargs';
import {validateCLIOptions} from 'jest-validate';
import {deprecationEntries} from 'jest-config';
import {version as VERSION} from '../../package.json';
import * as args from './args';

Expand All @@ -21,7 +22,10 @@ const REPL_SCRIPT = path.resolve(__dirname, './repl.js');
module.exports = function() {
const argv = yargs.usage(args.usage).options(args.options).argv;

validateCLIOptions(argv, args.options);
validateCLIOptions(
argv,
Object.assign({}, args.options, {deprecationEntries}),
);

argv._ = [REPL_SCRIPT];

Expand Down
7 changes: 5 additions & 2 deletions packages/jest-runtime/src/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import path from 'path';
import yargs from 'yargs';
import {Console, setGlobal} from 'jest-util';
import {validateCLIOptions} from 'jest-validate';
import {readConfig} from 'jest-config';
import {readConfig, deprecationEntries} from 'jest-config';
// eslint-disable-next-line import/default
import Runtime from '../';
import * as args from './args';
Expand All @@ -38,7 +38,10 @@ export function run(cliArgv?: Argv, cliInfo?: Array<string>) {
.version(false)
.options(args.options).argv;

validateCLIOptions(argv, args.options);
validateCLIOptions(
argv,
Object.assign({}, args.options, {deprecationEntries}),
);
}

if (argv.help) {
Expand Down
4 changes: 2 additions & 2 deletions packages/jest-runtime/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import fs from 'graceful-fs';
import stripBOM from 'strip-bom';
import ScriptTransformer from './script_transformer';
import shouldInstrument from './should_instrument';
import {run as cilRun} from './cli';
import {run as cliRun} from './cli';
import {options as cliOptions} from './cli/args';

type Module = {|
Expand Down Expand Up @@ -261,7 +261,7 @@ class Runtime {
}

static runCLI(args?: Argv, info?: Array<string>) {
return cilRun(args, info);
return cliRun(args, info);
}

static getCLIOptions() {
Expand Down
1 change: 0 additions & 1 deletion packages/jest-validate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"main": "build/index.js",
"dependencies": {
"chalk": "^2.0.1",
"jest-config": "^22.4.2",
"jest-get-type": "^22.1.0",
"leven": "^2.1.0",
"pretty-format": "^22.4.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-validate/src/validate_cli_options.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import type {Argv} from 'types/Argv';

import chalk from 'chalk';
import {deprecationEntries} from 'jest-config';
import {createDidYouMeanMessage, format, ValidationError} from './utils';
import {deprecationWarning} from './deprecated';
import defaultConfig from './default_config';
Expand Down Expand Up @@ -68,6 +67,7 @@ const logDeprecatedOptions = (

export default function validateCLIOptions(argv: Argv, options: Object) {
const yargsSpecialOptions = ['$0', '_', 'help', 'h'];
const deprecationEntries = options.deprecationEntries || {};
const allowedOptions = Object.keys(options).reduce(
(acc, option) => acc.add(option).add(options[option].alias || option),
new Set(yargsSpecialOptions),
Expand Down

0 comments on commit 9850275

Please sign in to comment.