From 82a7dec3ddf32218e1cad60ae8168a2dcef3b236 Mon Sep 17 00:00:00 2001 From: dhruvdutt Date: Tue, 10 Jul 2018 22:53:26 +0530 Subject: [PATCH] chore(migrate): add typescript support --- package-lock.json | 1063 ++++++++--------- packages/add/package-lock.json | 6 +- packages/generators/package-lock.json | 26 +- packages/info/package-lock.json | 6 +- packages/init/package-lock.json | 26 +- packages/migrate/.gitignore | 6 + .../{bannerPlugin.js => bannerPlugin.ts} | 16 +- .../extractTextPlugin/extractTextPlugin.js | 58 - .../extractTextPlugin.test.js | 2 +- .../extractTextPlugin/extractTextPlugin.ts | 60 + packages/migrate/{index.js => index.ts} | 184 +-- ...ptionsPlugin.js => loaderOptionsPlugin.ts} | 46 +- .../loaders/{loaders.js => loaders.ts} | 138 +-- packages/migrate/migrate.js | 81 -- packages/migrate/migrate.ts | 116 ++ ...Plugin.js => moduleConcatenationPlugin.ts} | 21 +- ...ModulesPlugin.js => namedModulesPlugin.ts} | 19 +- ...rrorsPlugin.js => noEmitOnErrorsPlugin.ts} | 20 +- .../{outputPath.js => outputPath.ts} | 49 +- packages/migrate/package-lock.json | 216 +++- packages/migrate/package.json | 19 +- ...dPlugins.js => removeDeprecatedPlugins.ts} | 25 +- ...emoveJsonLoader.js => removeJsonLoader.ts} | 34 +- .../resolve/{resolve.js => resolve.ts} | 47 +- packages/migrate/tsconfig.json | 3 + packages/migrate/types/NodePath.ts | 89 ++ packages/migrate/types/index.ts | 0 .../migrate/uglifyJsPlugin/uglifyJsPlugin.js | 123 -- .../migrate/uglifyJsPlugin/uglifyJsPlugin.ts | 128 ++ packages/utils/package-lock.json | 40 +- packages/webpack-scaffold/package-lock.json | 20 +- 31 files changed, 1499 insertions(+), 1188 deletions(-) create mode 100644 packages/migrate/.gitignore rename packages/migrate/bannerPlugin/{bannerPlugin.js => bannerPlugin.ts} (71%) delete mode 100644 packages/migrate/extractTextPlugin/extractTextPlugin.js create mode 100644 packages/migrate/extractTextPlugin/extractTextPlugin.ts rename packages/migrate/{index.js => index.ts} (52%) rename packages/migrate/loaderOptionsPlugin/{loaderOptionsPlugin.js => loaderOptionsPlugin.ts} (55%) rename packages/migrate/loaders/{loaders.js => loaders.ts} (66%) delete mode 100644 packages/migrate/migrate.js create mode 100644 packages/migrate/migrate.ts rename packages/migrate/moduleConcatenationPlugin/{moduleConcatenationPlugin.js => moduleConcatenationPlugin.ts} (58%) rename packages/migrate/namedModulesPlugin/{namedModulesPlugin.js => namedModulesPlugin.ts} (58%) rename packages/migrate/noEmitOnErrorsPlugin/{noEmitOnErrorsPlugin.js => noEmitOnErrorsPlugin.ts} (59%) rename packages/migrate/outputPath/{outputPath.js => outputPath.ts} (56%) rename packages/migrate/removeDeprecatedPlugins/{removeDeprecatedPlugins.js => removeDeprecatedPlugins.ts} (67%) rename packages/migrate/removeJsonLoader/{removeJsonLoader.js => removeJsonLoader.ts} (61%) rename packages/migrate/resolve/{resolve.js => resolve.ts} (53%) create mode 100644 packages/migrate/tsconfig.json create mode 100644 packages/migrate/types/NodePath.ts create mode 100644 packages/migrate/types/index.ts delete mode 100644 packages/migrate/uglifyJsPlugin/uglifyJsPlugin.js create mode 100644 packages/migrate/uglifyJsPlugin/uglifyJsPlugin.ts diff --git a/package-lock.json b/package-lock.json index ec22078cdcf..e811c2885b6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,12 +5,12 @@ "requires": true, "dependencies": { "@babel/code-frame": { - "version": "7.0.0-beta.51", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0-beta.51.tgz", - "integrity": "sha1-vXHZsZKvl435FYKdOdQJRFZDmgw=", + "version": "7.0.0-beta.52", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0-beta.52.tgz", + "integrity": "sha1-GSSDv6DR5GfBAVccIQKcy3SvKAE=", "dev": true, "requires": { - "@babel/highlight": "7.0.0-beta.51" + "@babel/highlight": "7.0.0-beta.52" } }, "@babel/generator": { @@ -70,9 +70,9 @@ } }, "@babel/highlight": { - "version": "7.0.0-beta.51", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.0.0-beta.51.tgz", - "integrity": "sha1-6IRK4loVlcz9QriWI7Q3bKBtIl0=", + "version": "7.0.0-beta.52", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.0.0-beta.52.tgz", + "integrity": "sha1-7ySTFDLwYVXnvDnNuKaze0oos9A=", "dev": true, "requires": { "chalk": "^2.0.0", @@ -96,6 +96,28 @@ "@babel/parser": "7.0.0-beta.51", "@babel/types": "7.0.0-beta.51", "lodash": "^4.17.5" + }, + "dependencies": { + "@babel/code-frame": { + "version": "7.0.0-beta.51", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0-beta.51.tgz", + "integrity": "sha1-vXHZsZKvl435FYKdOdQJRFZDmgw=", + "dev": true, + "requires": { + "@babel/highlight": "7.0.0-beta.51" + } + }, + "@babel/highlight": { + "version": "7.0.0-beta.51", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.0.0-beta.51.tgz", + "integrity": "sha1-6IRK4loVlcz9QriWI7Q3bKBtIl0=", + "dev": true, + "requires": { + "chalk": "^2.0.0", + "esutils": "^2.0.2", + "js-tokens": "^3.0.0" + } + } } }, "@babel/traverse": { @@ -114,6 +136,28 @@ "globals": "^11.1.0", "invariant": "^2.2.0", "lodash": "^4.17.5" + }, + "dependencies": { + "@babel/code-frame": { + "version": "7.0.0-beta.51", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0-beta.51.tgz", + "integrity": "sha1-vXHZsZKvl435FYKdOdQJRFZDmgw=", + "dev": true, + "requires": { + "@babel/highlight": "7.0.0-beta.51" + } + }, + "@babel/highlight": { + "version": "7.0.0-beta.51", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.0.0-beta.51.tgz", + "integrity": "sha1-6IRK4loVlcz9QriWI7Q3bKBtIl0=", + "dev": true, + "requires": { + "chalk": "^2.0.0", + "esutils": "^2.0.2", + "js-tokens": "^3.0.0" + } + } } }, "@babel/types": { @@ -932,9 +976,9 @@ } }, "@types/node": { - "version": "10.5.1", - "resolved": "https://registry.npmjs.org/@types/node/-/node-10.5.1.tgz", - "integrity": "sha512-AFLl1IALIuyt6oK4AYZsgWVJ/5rnyzQWud7IebaZWWV3YmgtPZkQmYio9R5Ze/2pdd7XfqF5bP+hWS11mAKoOQ==", + "version": "10.5.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.5.2.tgz", + "integrity": "sha512-m9zXmifkZsMHZBOyxZWilMwmTlpC8x5Ty360JKTiXvlXZfBWYpsg9ZZvP/Ye+iZUh+Q+MxDLjItVTWIsfwz+8Q==", "dev": true }, "@webassemblyjs/ast": { @@ -2412,14 +2456,15 @@ } }, "browserify-des": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/browserify-des/-/browserify-des-1.0.1.tgz", - "integrity": "sha512-zy0Cobe3hhgpiOM32Tj7KQ3Vl91m0njwsjzZQK1L+JDf11dzP9qIvjreVinsvXrgfjhStXwUWAEpB9D7Gwmayw==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/browserify-des/-/browserify-des-1.0.2.tgz", + "integrity": "sha512-BioO1xf3hFwz4kc6iBhI3ieDFompMhrMlnDFC4/0/vd5MokpuAc3R+LYbwTA9A5Yc9pq9UYPqffKpW2ObuwX5A==", "dev": true, "requires": { "cipher-base": "^1.0.1", "des.js": "^1.0.0", - "inherits": "^2.0.1" + "inherits": "^2.0.1", + "safe-buffer": "^5.1.2" } }, "browserify-rsa": { @@ -2980,14 +3025,125 @@ "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=" }, "codecov": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/codecov/-/codecov-3.0.2.tgz", - "integrity": "sha512-9ljtIROIjPIUmMRqO+XuDITDoV8xRrZmA0jcEq6p2hg2+wY9wGmLfreAZGIL72IzUfdEDZaU8+Vjidg1fBQ8GQ==", + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/codecov/-/codecov-3.0.4.tgz", + "integrity": "sha512-KJyzHdg9B8U9LxXa7hS6jnEW5b1cNckLYc2YpnJ1nEFiOW+/iSzDHp+5MYEIQd9fN3/tC6WmGZmYiwxzkuGp/A==", "dev": true, "requires": { - "argv": "0.0.2", - "request": "^2.81.0", - "urlgrey": "0.4.4" + "argv": "^0.0.2", + "ignore-walk": "^3.0.1", + "request": "^2.87.0", + "urlgrey": "^0.4.4" + }, + "dependencies": { + "ajv": { + "version": "5.5.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz", + "integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=", + "dev": true, + "requires": { + "co": "^4.6.0", + "fast-deep-equal": "^1.0.0", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.3.0" + } + }, + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", + "dev": true + }, + "aws-sign2": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", + "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=", + "dev": true + }, + "form-data": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.2.tgz", + "integrity": "sha1-SXBJi+YEwgwAXU9cI67NIda0kJk=", + "dev": true, + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "1.0.6", + "mime-types": "^2.1.12" + } + }, + "har-schema": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", + "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=", + "dev": true + }, + "har-validator": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.0.3.tgz", + "integrity": "sha1-ukAsJmGU8VlW7xXg/PJCmT9qff0=", + "dev": true, + "requires": { + "ajv": "^5.1.0", + "har-schema": "^2.0.0" + } + }, + "http-signature": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", + "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", + "dev": true, + "requires": { + "assert-plus": "^1.0.0", + "jsprim": "^1.2.2", + "sshpk": "^1.7.0" + } + }, + "performance-now": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", + "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=", + "dev": true + }, + "qs": { + "version": "6.5.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", + "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==", + "dev": true + }, + "request": { + "version": "2.87.0", + "resolved": "https://registry.npmjs.org/request/-/request-2.87.0.tgz", + "integrity": "sha512-fcogkm7Az5bsS6Sl0sibkbhcKsnyon/jV1kF3ajGmF0c8HrttdKTPRT9hieOaQHA5HEq6r8OyWOo/o781C1tNw==", + "dev": true, + "requires": { + "aws-sign2": "~0.7.0", + "aws4": "^1.6.0", + "caseless": "~0.12.0", + "combined-stream": "~1.0.5", + "extend": "~3.0.1", + "forever-agent": "~0.6.1", + "form-data": "~2.3.1", + "har-validator": "~5.0.3", + "http-signature": "~1.2.0", + "is-typedarray": "~1.0.0", + "isstream": "~0.1.2", + "json-stringify-safe": "~5.0.1", + "mime-types": "~2.1.17", + "oauth-sign": "~0.8.2", + "performance-now": "^2.1.0", + "qs": "~6.5.1", + "safe-buffer": "^5.1.1", + "tough-cookie": "~2.3.3", + "tunnel-agent": "^0.6.0", + "uuid": "^3.1.0" + } + }, + "uuid": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", + "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==", + "dev": true + } } }, "collection-visit": { @@ -5263,9 +5419,9 @@ } }, "eslint": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-5.0.1.tgz", - "integrity": "sha512-D5nG2rErquLUstgUaxJlWB5+gu+U/3VDY0fk/Iuq8y9CUFy/7Y6oF4N2cR1tV8knzQvciIbfqfohd359xTLIKQ==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-5.1.0.tgz", + "integrity": "sha512-DyH6JsoA1KzA5+OSWFjg56DFJT+sDLO0yokaPZ9qY0UEmYrPA1gEX/G1MnVkmRDsksG4H1foIVz2ZXXM3hHYvw==", "dev": true, "requires": { "ajv": "^6.5.0", @@ -5275,6 +5431,7 @@ "debug": "^3.1.0", "doctrine": "^2.1.0", "eslint-scope": "^4.0.0", + "eslint-utils": "^1.3.1", "eslint-visitor-keys": "^1.0.0", "espree": "^4.0.0", "esquery": "^1.0.1", @@ -5282,7 +5439,7 @@ "file-entry-cache": "^2.0.0", "functional-red-black-tree": "^1.0.1", "glob": "^7.1.2", - "globals": "^11.5.0", + "globals": "^11.7.0", "ignore": "^3.3.3", "imurmurhash": "^0.1.4", "inquirer": "^5.2.0", @@ -5337,6 +5494,12 @@ "tmp": "^0.0.33" } }, + "fast-deep-equal": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", + "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=", + "dev": true + }, "inquirer": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-5.2.0.tgz", @@ -5358,6 +5521,12 @@ "through": "^2.3.6" } }, + "json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true + }, "rxjs": { "version": "5.5.11", "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-5.5.11.tgz", @@ -5391,6 +5560,12 @@ "estraverse": "^4.1.1" } }, + "eslint-utils": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-1.3.1.tgz", + "integrity": "sha512-Z7YjnIldX+2XMcjr7ZkgEsOj/bREONV60qYeB/bjMAqqqZ4zxKyWX+BOUkdmRmA9riiIPVvo5x86m5elviOk0Q==", + "dev": true + }, "eslint-visitor-keys": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz", @@ -5708,9 +5883,9 @@ "dev": true }, "fast-deep-equal": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", - "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz", + "integrity": "sha1-wFNHeBfIa1HaqFPIHgWbcz0CNhQ=", "dev": true }, "fast-json-stable-stringify": { @@ -5918,9 +6093,9 @@ } }, "follow-redirects": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.0.tgz", - "integrity": "sha512-fdrt472/9qQ6Kgjvb935ig6vJCuofpBUD14f9Vb+SLlm7xIe4Qva5gey8EKtv8lp7ahE1wilg3xL1znpVGtZIA==", + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.1.tgz", + "integrity": "sha512-v9GI1hpaqq1ZZR6pBD1+kI7O24PhDvNGNodjS3MdcEqyrahCp8zbtpv+2B/krUnSmUH80lbAS7MrdeK5IylgKg==", "dev": true, "requires": { "debug": "^3.1.0" @@ -7325,13 +7500,13 @@ } }, "hash.js": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.4.tgz", - "integrity": "sha512-A6RlQvvZEtFS5fLU43IDu0QUmBy+fDO9VMdTXvufKwIkt/rFfvICAViCax5fbDO4zdNzaC3/27ZhKUok5bAJyw==", + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.5.tgz", + "integrity": "sha512-eWI5HG9Np+eHV1KQhisXWwM+4EPPYe5dFX1UZZH7k/E3JzDEazVH+VGlZi6R94ZqImq+A3D1mCEtrFIfg/E7sA==", "dev": true, "requires": { "inherits": "^2.0.3", - "minimalistic-assert": "^1.0.0" + "minimalistic-assert": "^1.0.1" } }, "hawk": { @@ -7383,9 +7558,9 @@ } }, "hosted-git-info": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.6.1.tgz", - "integrity": "sha512-Ba4+0M4YvIDUUsprMjhVTU1yN9F2/LJSAl69ZpzaLT4l4j5mwTS6jqqW9Ojvj6lKz/veqPzpJBqGbXspOb533A==", + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.7.1.tgz", + "integrity": "sha512-7T/BxH19zbcCTa8XkMlbK5lTo1WtgkFi3GvdWEyNuc4Vex7/9Dqbnpsf4JMydcfj9HCg4zUWFTL3Za6lapg5/w==", "dev": true }, "hpack.js": { @@ -7818,6 +7993,15 @@ "integrity": "sha512-Pgs951kaMm5GXP7MOvxERINe3gsaVjUWFm+UZPSq9xYriQAksyhg0csnS0KXSNRD5NmNdapXEpjxG49+AKh/ug==", "dev": true }, + "ignore-walk": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/ignore-walk/-/ignore-walk-3.0.1.tgz", + "integrity": "sha512-DTVlMx3IYPe0/JJcYP7Gxg7ttZZu3IInhuEhbchuqneY9wWe5Ojy2mXLBaQFUQmo0AW2r3qG7m1mg86js+gnlQ==", + "dev": true, + "requires": { + "minimatch": "^3.0.4" + } + }, "iltorb": { "version": "1.3.10", "resolved": "https://registry.npmjs.org/iltorb/-/iltorb-1.3.10.tgz", @@ -8682,402 +8866,146 @@ }, "y18n": { "version": "3.2.1", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-3.2.1.tgz", - "integrity": "sha1-bRX7qITAhnnA136I53WegR4H+kE=", - "dev": true - }, - "yargs": { - "version": "10.1.2", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-10.1.2.tgz", - "integrity": "sha512-ivSoxqBGYOqQVruxD35+EyCFDYNEFL/Uo6FcOnz+9xZdZzK0Zzw4r4KhbrME1Oo2gOggwJod2MnsdamSG7H9ig==", - "dev": true, - "requires": { - "cliui": "^4.0.0", - "decamelize": "^1.1.1", - "find-up": "^2.1.0", - "get-caller-file": "^1.0.1", - "os-locale": "^2.0.0", - "require-directory": "^2.1.1", - "require-main-filename": "^1.0.1", - "set-blocking": "^2.0.0", - "string-width": "^2.0.0", - "which-module": "^2.0.0", - "y18n": "^3.2.1", - "yargs-parser": "^8.1.0" - } - }, - "yargs-parser": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-8.1.0.tgz", - "integrity": "sha512-yP+6QqN8BmrgW2ggLtTbdrOyBNSI7zBa4IykmiV5R1wl1JWNxQvWhMfMdmzIYtKU7oP3OOInY/tl2ov3BDjnJQ==", - "dev": true, - "requires": { - "camelcase": "^4.1.0" - } - } - } - }, - "jest-changed-files": { - "version": "22.4.3", - "resolved": "https://registry.npmjs.org/jest-changed-files/-/jest-changed-files-22.4.3.tgz", - "integrity": "sha512-83Dh0w1aSkUNFhy5d2dvqWxi/y6weDwVVLU6vmK0cV9VpRxPzhTeGimbsbRDSnEoszhF937M4sDLLeS7Cu/Tmw==", - "dev": true, - "requires": { - "throat": "^4.0.0" - } - }, - "jest-cli": { - "version": "23.3.0", - "resolved": "https://registry.npmjs.org/jest-cli/-/jest-cli-23.3.0.tgz", - "integrity": "sha1-MH6b53M0Q7eJqCedaUBU0FGp5eI=", - "dev": true, - "requires": { - "ansi-escapes": "^3.0.0", - "chalk": "^2.0.1", - "exit": "^0.1.2", - "glob": "^7.1.2", - "graceful-fs": "^4.1.11", - "import-local": "^1.0.0", - "is-ci": "^1.0.10", - "istanbul-api": "^1.3.1", - "istanbul-lib-coverage": "^1.2.0", - "istanbul-lib-instrument": "^1.10.1", - "istanbul-lib-source-maps": "^1.2.4", - "jest-changed-files": "^23.2.0", - "jest-config": "^23.3.0", - "jest-environment-jsdom": "^23.3.0", - "jest-get-type": "^22.1.0", - "jest-haste-map": "^23.2.0", - "jest-message-util": "^23.3.0", - "jest-regex-util": "^23.3.0", - "jest-resolve-dependencies": "^23.3.0", - "jest-runner": "^23.3.0", - "jest-runtime": "^23.3.0", - "jest-snapshot": "^23.3.0", - "jest-util": "^23.3.0", - "jest-validate": "^23.3.0", - "jest-watcher": "^23.2.0", - "jest-worker": "^23.2.0", - "micromatch": "^3.1.10", - "node-notifier": "^5.2.1", - "prompts": "^0.1.9", - "realpath-native": "^1.0.0", - "rimraf": "^2.5.4", - "slash": "^1.0.0", - "string-length": "^2.0.0", - "strip-ansi": "^4.0.0", - "which": "^1.2.12", - "yargs": "^11.0.0" - }, - "dependencies": { - "arr-diff": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", - "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=", - "dev": true - }, - "array-unique": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", - "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=", - "dev": true - }, - "babel-jest": { - "version": "23.2.0", - "resolved": "https://registry.npmjs.org/babel-jest/-/babel-jest-23.2.0.tgz", - "integrity": "sha1-FKnWo/QSLf6mBp03CFrfJqU6Tbo=", - "dev": true, - "requires": { - "babel-plugin-istanbul": "^4.1.6", - "babel-preset-jest": "^23.2.0" - } - }, - "babel-plugin-jest-hoist": { - "version": "23.2.0", - "resolved": "https://registry.npmjs.org/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-23.2.0.tgz", - "integrity": "sha1-5h+uBaHKiAGq3uV6bWa4zvr0QWc=", - "dev": true - }, - "babel-preset-jest": { - "version": "23.2.0", - "resolved": "https://registry.npmjs.org/babel-preset-jest/-/babel-preset-jest-23.2.0.tgz", - "integrity": "sha1-jsegOhOPABoaj7HoETZSvxpV2kY=", - "dev": true, - "requires": { - "babel-plugin-jest-hoist": "^23.2.0", - "babel-plugin-syntax-object-rest-spread": "^6.13.0" - } - }, - "braces": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz", - "integrity": "sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==", - "dev": true, - "requires": { - "arr-flatten": "^1.1.0", - "array-unique": "^0.3.2", - "extend-shallow": "^2.0.1", - "fill-range": "^4.0.0", - "isobject": "^3.0.1", - "repeat-element": "^1.1.2", - "snapdragon": "^0.8.1", - "snapdragon-node": "^2.0.1", - "split-string": "^3.0.2", - "to-regex": "^3.0.1" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "^0.1.0" - } - } - } - }, - "callsites": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/callsites/-/callsites-2.0.0.tgz", - "integrity": "sha1-BuuE8A7qQT2oav/vrL/7Ngk7PFA=", - "dev": true - }, - "decamelize": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", - "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", - "dev": true - }, - "expand-brackets": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", - "integrity": "sha1-t3c14xXOMPa27/D4OwQVGiJEliI=", - "dev": true, - "requires": { - "debug": "^2.3.3", - "define-property": "^0.2.5", - "extend-shallow": "^2.0.1", - "posix-character-classes": "^0.1.0", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.1" - }, - "dependencies": { - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - }, - "define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "dev": true, - "requires": { - "is-descriptor": "^0.1.0" - } - }, - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "^0.1.0" - } - }, - "is-accessor-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", - "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", - "dev": true, - "requires": { - "kind-of": "^3.0.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "is-data-descriptor": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", - "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", - "dev": true, - "requires": { - "kind-of": "^3.0.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "is-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", - "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", - "dev": true, - "requires": { - "is-accessor-descriptor": "^0.1.6", - "is-data-descriptor": "^0.1.4", - "kind-of": "^5.0.0" - } - }, - "kind-of": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", - "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", - "dev": true - } - } - }, - "expect": { - "version": "23.3.0", - "resolved": "https://registry.npmjs.org/expect/-/expect-23.3.0.tgz", - "integrity": "sha1-7LBRrcvcQKxNtXbBYGfxL9sTzGE=", - "dev": true, - "requires": { - "ansi-styles": "^3.2.0", - "jest-diff": "^23.2.0", - "jest-get-type": "^22.1.0", - "jest-matcher-utils": "^23.2.0", - "jest-message-util": "^23.3.0", - "jest-regex-util": "^23.3.0" - } - }, - "extglob": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/extglob/-/extglob-2.0.4.tgz", - "integrity": "sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw==", - "dev": true, - "requires": { - "array-unique": "^0.3.2", - "define-property": "^1.0.0", - "expand-brackets": "^2.1.4", - "extend-shallow": "^2.0.1", - "fragment-cache": "^0.2.1", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.1" - }, - "dependencies": { - "define-property": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", - "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", - "dev": true, - "requires": { - "is-descriptor": "^1.0.0" - } - }, - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "^0.1.0" - } - } - } + "resolved": "https://registry.npmjs.org/y18n/-/y18n-3.2.1.tgz", + "integrity": "sha1-bRX7qITAhnnA136I53WegR4H+kE=", + "dev": true }, - "fill-range": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", - "integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=", + "yargs": { + "version": "10.1.2", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-10.1.2.tgz", + "integrity": "sha512-ivSoxqBGYOqQVruxD35+EyCFDYNEFL/Uo6FcOnz+9xZdZzK0Zzw4r4KhbrME1Oo2gOggwJod2MnsdamSG7H9ig==", "dev": true, "requires": { - "extend-shallow": "^2.0.1", - "is-number": "^3.0.0", - "repeat-string": "^1.6.1", - "to-regex-range": "^2.1.0" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "^0.1.0" - } - } + "cliui": "^4.0.0", + "decamelize": "^1.1.1", + "find-up": "^2.1.0", + "get-caller-file": "^1.0.1", + "os-locale": "^2.0.0", + "require-directory": "^2.1.1", + "require-main-filename": "^1.0.1", + "set-blocking": "^2.0.0", + "string-width": "^2.0.0", + "which-module": "^2.0.0", + "y18n": "^3.2.1", + "yargs-parser": "^8.1.0" } }, - "is-accessor-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", - "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", + "yargs-parser": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-8.1.0.tgz", + "integrity": "sha512-yP+6QqN8BmrgW2ggLtTbdrOyBNSI7zBa4IykmiV5R1wl1JWNxQvWhMfMdmzIYtKU7oP3OOInY/tl2ov3BDjnJQ==", "dev": true, "requires": { - "kind-of": "^6.0.0" + "camelcase": "^4.1.0" } - }, - "is-data-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", - "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", + } + } + }, + "jest-changed-files": { + "version": "22.4.3", + "resolved": "https://registry.npmjs.org/jest-changed-files/-/jest-changed-files-22.4.3.tgz", + "integrity": "sha512-83Dh0w1aSkUNFhy5d2dvqWxi/y6weDwVVLU6vmK0cV9VpRxPzhTeGimbsbRDSnEoszhF937M4sDLLeS7Cu/Tmw==", + "dev": true, + "requires": { + "throat": "^4.0.0" + } + }, + "jest-cli": { + "version": "23.4.0", + "resolved": "https://registry.npmjs.org/jest-cli/-/jest-cli-23.4.0.tgz", + "integrity": "sha1-0f3R28Qdaa6L1D0AcM4jmI6s2G8=", + "dev": true, + "requires": { + "ansi-escapes": "^3.0.0", + "chalk": "^2.0.1", + "exit": "^0.1.2", + "glob": "^7.1.2", + "graceful-fs": "^4.1.11", + "import-local": "^1.0.0", + "is-ci": "^1.0.10", + "istanbul-api": "^1.3.1", + "istanbul-lib-coverage": "^1.2.0", + "istanbul-lib-instrument": "^1.10.1", + "istanbul-lib-source-maps": "^1.2.4", + "jest-changed-files": "^23.4.0", + "jest-config": "^23.4.0", + "jest-environment-jsdom": "^23.4.0", + "jest-get-type": "^22.1.0", + "jest-haste-map": "^23.4.0", + "jest-message-util": "^23.4.0", + "jest-regex-util": "^23.3.0", + "jest-resolve-dependencies": "^23.4.0", + "jest-runner": "^23.4.0", + "jest-runtime": "^23.4.0", + "jest-snapshot": "^23.4.0", + "jest-util": "^23.4.0", + "jest-validate": "^23.4.0", + "jest-watcher": "^23.4.0", + "jest-worker": "^23.2.0", + "micromatch": "^2.3.11", + "node-notifier": "^5.2.1", + "prompts": "^0.1.9", + "realpath-native": "^1.0.0", + "rimraf": "^2.5.4", + "slash": "^1.0.0", + "string-length": "^2.0.0", + "strip-ansi": "^4.0.0", + "which": "^1.2.12", + "yargs": "^11.0.0" + }, + "dependencies": { + "babel-jest": { + "version": "23.4.0", + "resolved": "https://registry.npmjs.org/babel-jest/-/babel-jest-23.4.0.tgz", + "integrity": "sha1-IsNMOS4hdvakw2eZKn/P9p0uhVc=", "dev": true, "requires": { - "kind-of": "^6.0.0" + "babel-plugin-istanbul": "^4.1.6", + "babel-preset-jest": "^23.2.0" } }, - "is-descriptor": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", - "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", + "babel-plugin-jest-hoist": { + "version": "23.2.0", + "resolved": "https://registry.npmjs.org/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-23.2.0.tgz", + "integrity": "sha1-5h+uBaHKiAGq3uV6bWa4zvr0QWc=", + "dev": true + }, + "babel-preset-jest": { + "version": "23.2.0", + "resolved": "https://registry.npmjs.org/babel-preset-jest/-/babel-preset-jest-23.2.0.tgz", + "integrity": "sha1-jsegOhOPABoaj7HoETZSvxpV2kY=", "dev": true, "requires": { - "is-accessor-descriptor": "^1.0.0", - "is-data-descriptor": "^1.0.0", - "kind-of": "^6.0.2" + "babel-plugin-jest-hoist": "^23.2.0", + "babel-plugin-syntax-object-rest-spread": "^6.13.0" } }, - "is-number": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", - "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", + "callsites": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-2.0.0.tgz", + "integrity": "sha1-BuuE8A7qQT2oav/vrL/7Ngk7PFA=", + "dev": true + }, + "decamelize": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", + "dev": true + }, + "expect": { + "version": "23.4.0", + "resolved": "https://registry.npmjs.org/expect/-/expect-23.4.0.tgz", + "integrity": "sha1-baTsyZwUcSU+cogziYOtHrrbYMM=", "dev": true, "requires": { - "kind-of": "^3.0.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } + "ansi-styles": "^3.2.0", + "jest-diff": "^23.2.0", + "jest-get-type": "^22.1.0", + "jest-matcher-utils": "^23.2.0", + "jest-message-util": "^23.4.0", + "jest-regex-util": "^23.3.0" } }, - "isobject": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true - }, "istanbul-lib-source-maps": { "version": "1.2.5", "resolved": "https://registry.npmjs.org/istanbul-lib-source-maps/-/istanbul-lib-source-maps-1.2.5.tgz", @@ -9092,32 +9020,32 @@ } }, "jest-changed-files": { - "version": "23.2.0", - "resolved": "https://registry.npmjs.org/jest-changed-files/-/jest-changed-files-23.2.0.tgz", - "integrity": "sha1-oUWm5LZtASn8fJnO4TTck3pkPZw=", + "version": "23.4.0", + "resolved": "https://registry.npmjs.org/jest-changed-files/-/jest-changed-files-23.4.0.tgz", + "integrity": "sha1-8bME+YwjWvXZox7FJCYsXk3jxv8=", "dev": true, "requires": { "throat": "^4.0.0" } }, "jest-config": { - "version": "23.3.0", - "resolved": "https://registry.npmjs.org/jest-config/-/jest-config-23.3.0.tgz", - "integrity": "sha1-u01Ttw+VAPr933GNImq7U7E7gyM=", + "version": "23.4.0", + "resolved": "https://registry.npmjs.org/jest-config/-/jest-config-23.4.0.tgz", + "integrity": "sha1-ecz41oqg5I+eO+uBuDqlh1xj+j8=", "dev": true, "requires": { "babel-core": "^6.0.0", - "babel-jest": "^23.2.0", + "babel-jest": "^23.4.0", "chalk": "^2.0.1", "glob": "^7.1.1", - "jest-environment-jsdom": "^23.3.0", - "jest-environment-node": "^23.3.0", + "jest-environment-jsdom": "^23.4.0", + "jest-environment-node": "^23.4.0", "jest-get-type": "^22.1.0", - "jest-jasmine2": "^23.3.0", + "jest-jasmine2": "^23.4.0", "jest-regex-util": "^23.3.0", - "jest-resolve": "^23.2.0", - "jest-util": "^23.3.0", - "jest-validate": "^23.3.0", + "jest-resolve": "^23.4.0", + "jest-util": "^23.4.0", + "jest-validate": "^23.4.0", "pretty-format": "^23.2.0" } }, @@ -9143,30 +9071,30 @@ } }, "jest-environment-jsdom": { - "version": "23.3.0", - "resolved": "https://registry.npmjs.org/jest-environment-jsdom/-/jest-environment-jsdom-23.3.0.tgz", - "integrity": "sha1-GQRX+RyeYVRUxBhgVgZdtu16Tio=", + "version": "23.4.0", + "resolved": "https://registry.npmjs.org/jest-environment-jsdom/-/jest-environment-jsdom-23.4.0.tgz", + "integrity": "sha1-BWp5UrP+pROsYqFAosNox52eYCM=", "dev": true, "requires": { "jest-mock": "^23.2.0", - "jest-util": "^23.3.0", + "jest-util": "^23.4.0", "jsdom": "^11.5.1" } }, "jest-environment-node": { - "version": "23.3.0", - "resolved": "https://registry.npmjs.org/jest-environment-node/-/jest-environment-node-23.3.0.tgz", - "integrity": "sha1-Ho3yHIR6pdA7dlc/DcFvzeUDTDI=", + "version": "23.4.0", + "resolved": "https://registry.npmjs.org/jest-environment-node/-/jest-environment-node-23.4.0.tgz", + "integrity": "sha1-V+gO0IQd6jAxZ8zozXlSHeuv3hA=", "dev": true, "requires": { "jest-mock": "^23.2.0", - "jest-util": "^23.3.0" + "jest-util": "^23.4.0" } }, "jest-haste-map": { - "version": "23.2.0", - "resolved": "https://registry.npmjs.org/jest-haste-map/-/jest-haste-map-23.2.0.tgz", - "integrity": "sha1-0Qy6wAfGlZSMjvGCGisu0tTy1Ng=", + "version": "23.4.0", + "resolved": "https://registry.npmjs.org/jest-haste-map/-/jest-haste-map-23.4.0.tgz", + "integrity": "sha1-8qDqpBr3Zs1RAebCkf3GQ1yT7hw=", "dev": true, "requires": { "fb-watchman": "^2.0.0", @@ -9174,26 +9102,26 @@ "jest-docblock": "^23.2.0", "jest-serializer": "^23.0.1", "jest-worker": "^23.2.0", - "micromatch": "^3.1.10", + "micromatch": "^2.3.11", "sane": "^2.0.0" } }, "jest-jasmine2": { - "version": "23.3.0", - "resolved": "https://registry.npmjs.org/jest-jasmine2/-/jest-jasmine2-23.3.0.tgz", - "integrity": "sha1-qHBrqsI8ihMNWqjvVGSp1JCW0bU=", + "version": "23.4.0", + "resolved": "https://registry.npmjs.org/jest-jasmine2/-/jest-jasmine2-23.4.0.tgz", + "integrity": "sha1-F85Tn+YI74mNaYZRgUSs8nC+yo8=", "dev": true, "requires": { "chalk": "^2.0.1", "co": "^4.6.0", - "expect": "^23.3.0", + "expect": "^23.4.0", "is-generator-fn": "^1.0.0", "jest-diff": "^23.2.0", - "jest-each": "^23.2.0", + "jest-each": "^23.4.0", "jest-matcher-utils": "^23.2.0", - "jest-message-util": "^23.3.0", - "jest-snapshot": "^23.3.0", - "jest-util": "^23.3.0", + "jest-message-util": "^23.4.0", + "jest-snapshot": "^23.4.0", + "jest-util": "^23.4.0", "pretty-format": "^23.2.0" } }, @@ -9218,14 +9146,14 @@ } }, "jest-message-util": { - "version": "23.3.0", - "resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-23.3.0.tgz", - "integrity": "sha1-vAexHOxpcftd2d4t+2DrwiFQwWA=", + "version": "23.4.0", + "resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-23.4.0.tgz", + "integrity": "sha1-F2EMUJQjSVCNAaPR4L2iwHkIap8=", "dev": true, "requires": { "@babel/code-frame": "^7.0.0-beta.35", "chalk": "^2.0.1", - "micromatch": "^3.1.10", + "micromatch": "^2.3.11", "slash": "^1.0.0", "stack-utils": "^1.0.1" } @@ -9243,9 +9171,9 @@ "dev": true }, "jest-resolve": { - "version": "23.2.0", - "resolved": "https://registry.npmjs.org/jest-resolve/-/jest-resolve-23.2.0.tgz", - "integrity": "sha1-oHkK1aO5kAKrTb/L+Nni1qabPZk=", + "version": "23.4.0", + "resolved": "https://registry.npmjs.org/jest-resolve/-/jest-resolve-23.4.0.tgz", + "integrity": "sha1-tAYdvNY5G15EXV/YTJ2tX/H/VmI=", "dev": true, "requires": { "browser-resolve": "^1.11.3", @@ -9254,40 +9182,40 @@ } }, "jest-resolve-dependencies": { - "version": "23.3.0", - "resolved": "https://registry.npmjs.org/jest-resolve-dependencies/-/jest-resolve-dependencies-23.3.0.tgz", - "integrity": "sha1-hETTsLEoi4CGTYgB/1C0Sk1pXR0=", + "version": "23.4.0", + "resolved": "https://registry.npmjs.org/jest-resolve-dependencies/-/jest-resolve-dependencies-23.4.0.tgz", + "integrity": "sha1-5z785wJipuK/UmPQsjAJoJhnhiA=", "dev": true, "requires": { "jest-regex-util": "^23.3.0", - "jest-snapshot": "^23.3.0" + "jest-snapshot": "^23.4.0" } }, "jest-runner": { - "version": "23.3.0", - "resolved": "https://registry.npmjs.org/jest-runner/-/jest-runner-23.3.0.tgz", - "integrity": "sha1-BMfkWKYXUBpIddsNf/vg48vUO/s=", + "version": "23.4.0", + "resolved": "https://registry.npmjs.org/jest-runner/-/jest-runner-23.4.0.tgz", + "integrity": "sha1-GFmyEaJk6lpDt6MCLhGZBnxN/lc=", "dev": true, "requires": { "exit": "^0.1.2", "graceful-fs": "^4.1.11", - "jest-config": "^23.3.0", + "jest-config": "^23.4.0", "jest-docblock": "^23.2.0", - "jest-haste-map": "^23.2.0", - "jest-jasmine2": "^23.3.0", + "jest-haste-map": "^23.4.0", + "jest-jasmine2": "^23.4.0", "jest-leak-detector": "^23.2.0", - "jest-message-util": "^23.3.0", - "jest-runtime": "^23.3.0", - "jest-util": "^23.3.0", + "jest-message-util": "^23.4.0", + "jest-runtime": "^23.4.0", + "jest-util": "^23.4.0", "jest-worker": "^23.2.0", "source-map-support": "^0.5.6", "throat": "^4.0.0" } }, "jest-runtime": { - "version": "23.3.0", - "resolved": "https://registry.npmjs.org/jest-runtime/-/jest-runtime-23.3.0.tgz", - "integrity": "sha1-SGWqtM7/gvnOxjNf164UIswd598=", + "version": "23.4.0", + "resolved": "https://registry.npmjs.org/jest-runtime/-/jest-runtime-23.4.0.tgz", + "integrity": "sha1-ww72Gd71h7k7rUpJONqazLmTa00=", "dev": true, "requires": { "babel-core": "^6.0.0", @@ -9297,15 +9225,15 @@ "exit": "^0.1.2", "fast-json-stable-stringify": "^2.0.0", "graceful-fs": "^4.1.11", - "jest-config": "^23.3.0", - "jest-haste-map": "^23.2.0", - "jest-message-util": "^23.3.0", + "jest-config": "^23.4.0", + "jest-haste-map": "^23.4.0", + "jest-message-util": "^23.4.0", "jest-regex-util": "^23.3.0", - "jest-resolve": "^23.2.0", - "jest-snapshot": "^23.3.0", - "jest-util": "^23.3.0", - "jest-validate": "^23.3.0", - "micromatch": "^3.1.10", + "jest-resolve": "^23.4.0", + "jest-snapshot": "^23.4.0", + "jest-util": "^23.4.0", + "jest-validate": "^23.4.0", + "micromatch": "^2.3.11", "realpath-native": "^1.0.0", "slash": "^1.0.0", "strip-bom": "3.0.0", @@ -9320,9 +9248,9 @@ "dev": true }, "jest-snapshot": { - "version": "23.3.0", - "resolved": "https://registry.npmjs.org/jest-snapshot/-/jest-snapshot-23.3.0.tgz", - "integrity": "sha1-/E6fgeRUMtEFB+J/ULzmD0TYFCQ=", + "version": "23.4.0", + "resolved": "https://registry.npmjs.org/jest-snapshot/-/jest-snapshot-23.4.0.tgz", + "integrity": "sha1-dGPQNXyr3+HGOZTV4y9wfRAz1hY=", "dev": true, "requires": { "babel-traverse": "^6.0.0", @@ -9330,8 +9258,8 @@ "chalk": "^2.0.1", "jest-diff": "^23.2.0", "jest-matcher-utils": "^23.2.0", - "jest-message-util": "^23.3.0", - "jest-resolve": "^23.2.0", + "jest-message-util": "^23.4.0", + "jest-resolve": "^23.4.0", "mkdirp": "^0.5.1", "natural-compare": "^1.4.0", "pretty-format": "^23.2.0", @@ -9339,16 +9267,16 @@ } }, "jest-util": { - "version": "23.3.0", - "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-23.3.0.tgz", - "integrity": "sha1-efNbsMMBAO9hHZY+5riPjthzqB0=", + "version": "23.4.0", + "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-23.4.0.tgz", + "integrity": "sha1-TQY8uSe68KI4Mf9hvsLLv0l5NWE=", "dev": true, "requires": { "callsites": "^2.0.0", "chalk": "^2.0.1", "graceful-fs": "^4.1.11", "is-ci": "^1.0.10", - "jest-message-util": "^23.3.0", + "jest-message-util": "^23.4.0", "mkdirp": "^0.5.1", "slash": "^1.0.0", "source-map": "^0.6.0" @@ -9363,9 +9291,9 @@ } }, "jest-validate": { - "version": "23.3.0", - "resolved": "https://registry.npmjs.org/jest-validate/-/jest-validate-23.3.0.tgz", - "integrity": "sha1-1Jvqaq2YwwrNLLtUJDR5igzBP3Y=", + "version": "23.4.0", + "resolved": "https://registry.npmjs.org/jest-validate/-/jest-validate-23.4.0.tgz", + "integrity": "sha1-2W7t4B7wOskJwAnpyORVGX1IwgE=", "dev": true, "requires": { "chalk": "^2.0.1", @@ -9383,33 +9311,6 @@ "merge-stream": "^1.0.1" } }, - "kind-of": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", - "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", - "dev": true - }, - "micromatch": { - "version": "3.1.10", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", - "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", - "dev": true, - "requires": { - "arr-diff": "^4.0.0", - "array-unique": "^0.3.2", - "braces": "^2.3.1", - "define-property": "^2.0.2", - "extend-shallow": "^3.0.2", - "extglob": "^2.0.4", - "fragment-cache": "^0.2.1", - "kind-of": "^6.0.2", - "nanomatch": "^1.2.9", - "object.pick": "^1.3.0", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.2" - } - }, "pretty-format": { "version": "23.2.0", "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-23.2.0.tgz", @@ -9504,9 +9405,9 @@ } }, "jest-each": { - "version": "23.2.0", - "resolved": "https://registry.npmjs.org/jest-each/-/jest-each-23.2.0.tgz", - "integrity": "sha1-pAD4HIVwg/UMT1M5mxCfEgI/sZ0=", + "version": "23.4.0", + "resolved": "https://registry.npmjs.org/jest-each/-/jest-each-23.4.0.tgz", + "integrity": "sha1-L6nt2J2qGk7cn/m/YGKja3E0UUM=", "dev": true, "requires": { "chalk": "^2.0.1", @@ -9803,9 +9704,9 @@ } }, "jest-watcher": { - "version": "23.2.0", - "resolved": "https://registry.npmjs.org/jest-watcher/-/jest-watcher-23.2.0.tgz", - "integrity": "sha1-Z46FKJbpGenZoOtLi68a4nliDqk=", + "version": "23.4.0", + "resolved": "https://registry.npmjs.org/jest-watcher/-/jest-watcher-23.4.0.tgz", + "integrity": "sha1-0uKM50+NrWxq/JIrksq+9u0FyRw=", "dev": true, "requires": { "ansi-escapes": "^3.0.0", @@ -9949,12 +9850,6 @@ "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=", "dev": true }, - "fast-deep-equal": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz", - "integrity": "sha1-wFNHeBfIa1HaqFPIHgWbcz0CNhQ=", - "dev": true - }, "form-data": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.2.tgz", @@ -9993,12 +9888,6 @@ "sshpk": "^1.7.0" } }, - "json-schema-traverse": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz", - "integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A=", - "dev": true - }, "performance-now": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", @@ -10066,9 +9955,9 @@ "dev": true }, "json-schema-traverse": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", - "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz", + "integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A=", "dev": true }, "json-stable-stringify": { @@ -10838,9 +10727,9 @@ "dev": true }, "jest-validate": { - "version": "23.3.0", - "resolved": "https://registry.npmjs.org/jest-validate/-/jest-validate-23.3.0.tgz", - "integrity": "sha1-1Jvqaq2YwwrNLLtUJDR5igzBP3Y=", + "version": "23.4.0", + "resolved": "https://registry.npmjs.org/jest-validate/-/jest-validate-23.4.0.tgz", + "integrity": "sha1-2W7t4B7wOskJwAnpyORVGX1IwgE=", "dev": true, "requires": { "chalk": "^2.0.1", @@ -11444,12 +11333,12 @@ "dev": true }, "loose-envify": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.3.1.tgz", - "integrity": "sha1-0aitM/qc4OcT1l/dCsi3SNR4yEg=", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", + "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", "dev": true, "requires": { - "js-tokens": "^3.0.0" + "js-tokens": "^3.0.0 || ^4.0.0" } }, "loud-rejection": { @@ -13039,9 +12928,9 @@ } }, "istanbul-lib-instrument": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-2.3.0.tgz", - "integrity": "sha512-Ie1LGWJVCFDDJKKH4g1ffpFcZTEXEd6ay5l9fE8539y4qPErJnzo4psnGzDH92tcKvdUDdbxrKySYIbt6zB9hw==", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-2.3.1.tgz", + "integrity": "sha512-h9Vg3nfbxrF0PK0kZiNiMAyL8zXaLiBP/BXniaKSwVvAi1TaumYV2b0wPdmy1CRX3irYbYD1p4Wjbv4uyECiiQ==", "dev": true, "requires": { "@babel/generator": "7.0.0-beta.51", @@ -13049,14 +12938,14 @@ "@babel/template": "7.0.0-beta.51", "@babel/traverse": "7.0.0-beta.51", "@babel/types": "7.0.0-beta.51", - "istanbul-lib-coverage": "^2.0.0", + "istanbul-lib-coverage": "^2.0.1", "semver": "^5.5.0" }, "dependencies": { "istanbul-lib-coverage": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.0.tgz", - "integrity": "sha512-yMSw5xLIbdaxiVXHk3amfNM2WeBxLrwH/BCyZ9HvA/fylwziAIJOG2rKqWyLqEJqwKT725vxxqidv+SyynnGAA==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.1.tgz", + "integrity": "sha512-nPvSZsVlbG9aLhZYaC3Oi1gT/tpyo3Yt5fNyf6NmcKIayz4VV/txxJFFKAK/gU4dcNn8ehsanBbVHVl0+amOLA==", "dev": true } } @@ -15189,12 +15078,6 @@ "tmp": "^0.0.33" } }, - "fast-deep-equal": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz", - "integrity": "sha1-wFNHeBfIa1HaqFPIHgWbcz0CNhQ=", - "dev": true - }, "inquirer": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-3.3.0.tgz", @@ -15217,12 +15100,6 @@ "through": "^2.3.6" } }, - "json-schema-traverse": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz", - "integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A=", - "dev": true - }, "pretty-format": { "version": "23.2.0", "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-23.2.0.tgz", @@ -15460,12 +15337,6 @@ "tmp": "^0.0.33" } }, - "fast-deep-equal": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz", - "integrity": "sha1-wFNHeBfIa1HaqFPIHgWbcz0CNhQ=", - "dev": true - }, "has-flag": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", @@ -15503,12 +15374,6 @@ "number-is-nan": "^1.0.0" } }, - "json-schema-traverse": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz", - "integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A=", - "dev": true - }, "rxjs": { "version": "5.5.11", "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-5.5.11.tgz", @@ -15655,9 +15520,9 @@ "dev": true }, "prompts": { - "version": "0.1.10", - "resolved": "https://registry.npmjs.org/prompts/-/prompts-0.1.10.tgz", - "integrity": "sha512-/MPwms6+g/m6fvXZlQyOL4m4ziDim2+Wc6CdWVjp+nVCkzEkK2N4rR74m/bbGf+dkta+/SBpo1FfES8Wgrk/Fw==", + "version": "0.1.11", + "resolved": "https://registry.npmjs.org/prompts/-/prompts-0.1.11.tgz", + "integrity": "sha512-6ZFzPasWMEgZ/cDpQQshV/l/fWISILGjq4VctCipG6RVfaO4FAafGR8iKXSFxoHIYgPcPYuDupyLtVNc/aDG8Q==", "dev": true, "requires": { "clorox": "^1.0.3", @@ -16688,6 +16553,18 @@ "json-schema-traverse": "^0.4.1", "uri-js": "^4.2.1" } + }, + "fast-deep-equal": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", + "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=", + "dev": true + }, + "json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true } } }, @@ -17577,6 +17454,18 @@ "json-schema-traverse": "^0.4.1", "uri-js": "^4.2.1" } + }, + "fast-deep-equal": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", + "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=", + "dev": true + }, + "json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true } } }, @@ -19059,9 +18948,9 @@ "dev": true }, "webpack": { - "version": "4.15.0", - "resolved": "https://registry.npmjs.org/webpack/-/webpack-4.15.0.tgz", - "integrity": "sha512-S2fpUI4WLg9gsg1CZ9SE790C1fI2zbxiBCdl9xAnttdLjXhzfCYSYu+TeSEz6ZrLcmQ8RpJoieOAAS0p27nTog==", + "version": "4.15.1", + "resolved": "https://registry.npmjs.org/webpack/-/webpack-4.15.1.tgz", + "integrity": "sha512-UwfFQ2plA5EMhhzwi/hl5xpLk7mNK7p0853Ml04z1Bqw553pY+oS8Xke3funcVy7eG/yMpZPvnlFTUyGKyKoyw==", "dev": true, "requires": { "@webassemblyjs/ast": "1.5.13", @@ -19291,6 +19180,12 @@ } } }, + "fast-deep-equal": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", + "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=", + "dev": true + }, "fill-range": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", @@ -19369,6 +19264,12 @@ "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", "dev": true }, + "json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true + }, "kind-of": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", diff --git a/packages/add/package-lock.json b/packages/add/package-lock.json index b15a5640ed8..e7caa9186a2 100644 --- a/packages/add/package-lock.json +++ b/packages/add/package-lock.json @@ -3,9 +3,9 @@ "lockfileVersion": 1, "dependencies": { "@types/node": { - "version": "10.5.1", - "resolved": "https://registry.npmjs.org/@types/node/-/node-10.5.1.tgz", - "integrity": "sha512-AFLl1IALIuyt6oK4AYZsgWVJ/5rnyzQWud7IebaZWWV3YmgtPZkQmYio9R5Ze/2pdd7XfqF5bP+hWS11mAKoOQ==" + "version": "10.5.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.5.2.tgz", + "integrity": "sha512-m9zXmifkZsMHZBOyxZWilMwmTlpC8x5Ty360JKTiXvlXZfBWYpsg9ZZvP/Ye+iZUh+Q+MxDLjItVTWIsfwz+8Q==" }, "typescript": { "version": "2.9.2", diff --git a/packages/generators/package-lock.json b/packages/generators/package-lock.json index 4a86764728d..a548dd1cd65 100644 --- a/packages/generators/package-lock.json +++ b/packages/generators/package-lock.json @@ -2758,14 +2758,14 @@ } }, "flow-parser": { - "version": "0.75.0", - "resolved": "https://registry.npmjs.org/flow-parser/-/flow-parser-0.75.0.tgz", - "integrity": "sha512-QEyV/t9TERBOSI/zSx0zhKH6924135WPI7pMmug2n/n/4puFm4mdAq1QaKPA3IPhXDRtManbySkKhRqws5UUGA==" + "version": "0.76.0", + "resolved": "https://registry.npmjs.org/flow-parser/-/flow-parser-0.76.0.tgz", + "integrity": "sha512-p+K8OKiMlq8AIZH8KTydHEGUUd71AqfCL+zTJNsdHtQmX3i3eaeIysF83Ad6Oo7OQcHCj3vocb/EHYiEyq+ZBg==" }, "follow-redirects": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.0.tgz", - "integrity": "sha512-fdrt472/9qQ6Kgjvb935ig6vJCuofpBUD14f9Vb+SLlm7xIe4Qva5gey8EKtv8lp7ahE1wilg3xL1znpVGtZIA==", + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.1.tgz", + "integrity": "sha512-v9GI1hpaqq1ZZR6pBD1+kI7O24PhDvNGNodjS3MdcEqyrahCp8zbtpv+2B/krUnSmUH80lbAS7MrdeK5IylgKg==", "requires": { "debug": "^3.1.0" }, @@ -3552,9 +3552,9 @@ } }, "hosted-git-info": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.6.1.tgz", - "integrity": "sha512-Ba4+0M4YvIDUUsprMjhVTU1yN9F2/LJSAl69ZpzaLT4l4j5mwTS6jqqW9Ojvj6lKz/veqPzpJBqGbXspOb533A==" + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.7.1.tgz", + "integrity": "sha512-7T/BxH19zbcCTa8XkMlbK5lTo1WtgkFi3GvdWEyNuc4Vex7/9Dqbnpsf4JMydcfj9HCg4zUWFTL3Za6lapg5/w==" }, "hpack.js": { "version": "2.1.6", @@ -4428,11 +4428,11 @@ } }, "loose-envify": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.3.1.tgz", - "integrity": "sha1-0aitM/qc4OcT1l/dCsi3SNR4yEg=", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", + "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", "requires": { - "js-tokens": "^3.0.0" + "js-tokens": "^3.0.0 || ^4.0.0" } }, "loud-rejection": { diff --git a/packages/info/package-lock.json b/packages/info/package-lock.json index a45654a4ee0..d1d60f92269 100644 --- a/packages/info/package-lock.json +++ b/packages/info/package-lock.json @@ -3,9 +3,9 @@ "lockfileVersion": 1, "dependencies": { "@types/node": { - "version": "10.5.1", - "resolved": "https://registry.npmjs.org/@types/node/-/node-10.5.1.tgz", - "integrity": "sha512-AFLl1IALIuyt6oK4AYZsgWVJ/5rnyzQWud7IebaZWWV3YmgtPZkQmYio9R5Ze/2pdd7XfqF5bP+hWS11mAKoOQ==" + "version": "10.5.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.5.2.tgz", + "integrity": "sha512-m9zXmifkZsMHZBOyxZWilMwmTlpC8x5Ty360JKTiXvlXZfBWYpsg9ZZvP/Ye+iZUh+Q+MxDLjItVTWIsfwz+8Q==" }, "envinfo": { "version": "5.10.0", diff --git a/packages/init/package-lock.json b/packages/init/package-lock.json index 98ea4e9ed36..f565563e384 100644 --- a/packages/init/package-lock.json +++ b/packages/init/package-lock.json @@ -3,9 +3,9 @@ "lockfileVersion": 1, "dependencies": { "@types/node": { - "version": "10.5.1", - "resolved": "https://registry.npmjs.org/@types/node/-/node-10.5.1.tgz", - "integrity": "sha512-AFLl1IALIuyt6oK4AYZsgWVJ/5rnyzQWud7IebaZWWV3YmgtPZkQmYio9R5Ze/2pdd7XfqF5bP+hWS11mAKoOQ==" + "version": "10.5.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.5.2.tgz", + "integrity": "sha512-m9zXmifkZsMHZBOyxZWilMwmTlpC8x5Ty360JKTiXvlXZfBWYpsg9ZZvP/Ye+iZUh+Q+MxDLjItVTWIsfwz+8Q==" }, "@types/p-each-series": { "version": "1.0.0", @@ -958,9 +958,9 @@ } }, "flow-parser": { - "version": "0.75.0", - "resolved": "https://registry.npmjs.org/flow-parser/-/flow-parser-0.75.0.tgz", - "integrity": "sha512-QEyV/t9TERBOSI/zSx0zhKH6924135WPI7pMmug2n/n/4puFm4mdAq1QaKPA3IPhXDRtManbySkKhRqws5UUGA==" + "version": "0.76.0", + "resolved": "https://registry.npmjs.org/flow-parser/-/flow-parser-0.76.0.tgz", + "integrity": "sha512-p+K8OKiMlq8AIZH8KTydHEGUUd71AqfCL+zTJNsdHtQmX3i3eaeIysF83Ad6Oo7OQcHCj3vocb/EHYiEyq+ZBg==" }, "for-in": { "version": "1.0.2", @@ -1168,11 +1168,11 @@ "integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg==" }, "loose-envify": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.3.1.tgz", - "integrity": "sha1-0aitM/qc4OcT1l/dCsi3SNR4yEg=", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", + "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", "requires": { - "js-tokens": "^3.0.0" + "js-tokens": "^3.0.0 || ^4.0.0" } }, "math-random": { @@ -1361,9 +1361,9 @@ } }, "recast": { - "version": "0.15.1", - "resolved": "https://registry.npmjs.org/recast/-/recast-0.15.1.tgz", - "integrity": "sha512-Q2TQyDveVn1ZGyFJlb6nPyu/ojkX+xtFSMSucO2L+yWVulqXhRtA6KyvJy860APaWBsKrTz2BMnGtYu6++35ow==", + "version": "0.15.2", + "resolved": "https://registry.npmjs.org/recast/-/recast-0.15.2.tgz", + "integrity": "sha512-L4f/GqxjlEJ5IZ+tdll/l+6dVi2ylysWbkgFJbMuldD6Jklgfv6zJnCpuAZDfjwHhfcd/De0dDKelsTEPQ29qA==", "requires": { "ast-types": "0.11.5", "esprima": "~4.0.0", diff --git a/packages/migrate/.gitignore b/packages/migrate/.gitignore new file mode 100644 index 00000000000..04d5044e769 --- /dev/null +++ b/packages/migrate/.gitignore @@ -0,0 +1,6 @@ +/*.js +/**/*.js +!*.test.js +!/**/*.test.js +!/**/__testfixtures__/*.js +!/**/__snapshots__/*.js diff --git a/packages/migrate/bannerPlugin/bannerPlugin.js b/packages/migrate/bannerPlugin/bannerPlugin.ts similarity index 71% rename from packages/migrate/bannerPlugin/bannerPlugin.js rename to packages/migrate/bannerPlugin/bannerPlugin.ts index 4c45a1091e0..5d369f57ec9 100644 --- a/packages/migrate/bannerPlugin/bannerPlugin.js +++ b/packages/migrate/bannerPlugin/bannerPlugin.ts @@ -1,4 +1,6 @@ -const utils = require("@webpack-cli/utils/ast-utils"); +import * as utils from "@webpack-cli/utils/ast-utils"; + +import { IJSCodeshift, INode } from "../types/NodePath"; /** * @@ -10,11 +12,11 @@ const utils = require("@webpack-cli/utils/ast-utils"); * @returns {Node} ast - jscodeshift ast */ -module.exports = function(j, ast) { +export default function(j: IJSCodeshift, ast: INode): INode { return utils .findPluginsByName(j, ast, ["webpack.BannerPlugin"]) - .forEach(path => { - const args = path.value.arguments; // any node + .forEach((path: INode): void => { + const args: INode[] = path.value.arguments; // any node // If the first argument is a literal replace it with object notation // See https://webpack.js.org/guides/migrating/#bannerplugin-breaking-change if (args && args.length > 1 && args[0].type === j.Literal.name) { @@ -25,9 +27,9 @@ module.exports = function(j, ast) { path.parent, "webpack.BannerPlugin", { - banner: args[0].value - } + banner: args[0].value, + }, ); } }); -}; +} diff --git a/packages/migrate/extractTextPlugin/extractTextPlugin.js b/packages/migrate/extractTextPlugin/extractTextPlugin.js deleted file mode 100644 index 8512a7279ad..00000000000 --- a/packages/migrate/extractTextPlugin/extractTextPlugin.js +++ /dev/null @@ -1,58 +0,0 @@ -const utils = require("@webpack-cli/utils/ast-utils"); - -/** - * - * Check whether `node` is the invocation of the plugin denoted by `pluginName` - * - * @param {Object} j - jscodeshift top-level import - * @param {Node} node - ast node to check - * @param {String} pluginName - name of the plugin - * @returns {Boolean} isPluginInvocation - whether `node` is the invocation of the plugin denoted by `pluginName` - */ - -function findInvocation(j, node, pluginName) { - let found = false; - found = - j(node) - .find(j.MemberExpression) - .filter(p => p.get("object").value.name === pluginName) - .size() > 0; - return found; -} - -/** - * - * Transform for ExtractTextPlugin arguments. Consolidates arguments into single options object. - * - * @param {Object} j - jscodeshift top-level import - * @param {Node} ast - jscodeshift ast to transform - * @returns {Node} ast - jscodeshift ast - */ - -module.exports = function(j, ast) { - const changeArguments = function(p) { - const args = p.value.arguments; - - const literalArgs = args.filter(p => utils.isType(p, "Literal")); - if (literalArgs && literalArgs.length > 1) { - const newArgs = j.objectExpression( - literalArgs.map((p, index) => - utils.createProperty(j, index === 0 ? "fallback" : "use", p.value) - ) - ); - p.value.arguments = [newArgs]; - } - return p; - }; - const name = utils.findVariableToPlugin( - j, - ast, - "extract-text-webpack-plugin" - ); - if (!name) return ast; - - return ast - .find(j.CallExpression) - .filter(p => findInvocation(j, p, name)) - .forEach(changeArguments); -}; diff --git a/packages/migrate/extractTextPlugin/extractTextPlugin.test.js b/packages/migrate/extractTextPlugin/extractTextPlugin.test.js index 790ded2311a..14239d5749b 100644 --- a/packages/migrate/extractTextPlugin/extractTextPlugin.test.js +++ b/packages/migrate/extractTextPlugin/extractTextPlugin.test.js @@ -1,5 +1,5 @@ "use strict"; -const defineTest = require("@webpack-cli/utils//defineTest"); +const defineTest = require("@webpack-cli/utils/defineTest"); defineTest(__dirname, "extractTextPlugin"); diff --git a/packages/migrate/extractTextPlugin/extractTextPlugin.ts b/packages/migrate/extractTextPlugin/extractTextPlugin.ts new file mode 100644 index 00000000000..bf0cf39d937 --- /dev/null +++ b/packages/migrate/extractTextPlugin/extractTextPlugin.ts @@ -0,0 +1,60 @@ +import * as utils from "@webpack-cli/utils/ast-utils"; + +import { IJSCodeshift, INode } from "../types/NodePath"; + +/** + * + * Check whether `node` is the invocation of the plugin denoted by `pluginName` + * + * @param {Object} j - jscodeshift top-level import + * @param {Path} node - ast node to check + * @param {String} pluginName - name of the plugin + * @returns {Boolean} isPluginInvocation - whether `node` is the invocation of the plugin denoted by `pluginName` + */ + +function findInvocation(j: IJSCodeshift, path: INode, pluginName: string): boolean { + let found: boolean = false; + found = + j(path) + .find(j.MemberExpression) + .filter((p: INode): boolean => p.get("object").value.name === pluginName) + .size() > 0; + return found; +} + +/** + * + * Transform for ExtractTextPlugin arguments. Consolidates arguments into single options object. + * + * @param {Object} j - jscodeshift top-level import + * @param {Node} ast - jscodeshift ast to transform + * @returns {Node} ast - jscodeshift ast + */ + +export default function(j: IJSCodeshift, ast: INode): void | INode { + const changeArguments = (path: INode): INode => { + const args: INode[] = path.value.arguments; + + const literalArgs: INode[] = args.filter((p: INode): boolean => utils.isType(p, "Literal")); + if (literalArgs && literalArgs.length > 1) { + const newArgs: object = j.objectExpression( + literalArgs.map((p: INode, index: number): INode => + utils.createProperty(j, index === 0 ? "fallback" : "use", p.value), + ), + ); + path.value.arguments = [newArgs]; + } + return path; + }; + const name: string = utils.findVariableToPlugin( + j, + ast, + "extract-text-webpack-plugin", + ); + if (!name) { return ast; } + + return ast + .find(j.CallExpression) + .filter((p: INode): boolean => findInvocation(j, p, name)) + .forEach(changeArguments); +} diff --git a/packages/migrate/index.js b/packages/migrate/index.ts similarity index 52% rename from packages/migrate/index.js rename to packages/migrate/index.ts index 3fc5ac3892f..36ef807c6cb 100644 --- a/packages/migrate/index.js +++ b/packages/migrate/index.ts @@ -1,17 +1,32 @@ -"use strict"; +import chalk from "chalk"; +import * as diff from "diff"; +import * as fs from "fs"; +import * as inquirer from "inquirer"; +import * as Listr from "listr"; +import pLazy = require("p-lazy"); +import * as path from "path"; +import { validate, WebpackOptionsValidationError } from "webpack"; -const fs = require("fs"); -const path = require("path"); -const chalk = require("chalk"); -const diff = require("diff"); -const inquirer = require("inquirer"); -const PLazy = require("p-lazy"); -const Listr = require("listr"); +import * as runPrettier from "@webpack-cli/utils/run-prettier"; -const { validate } = process.webpackModule; -const { WebpackOptionsValidationError } = process.webpackModule; +import { transformations } from "./migrate"; +import { IJSCodeshift, INode } from "./types/NodePath"; -const runPrettier = require("@webpack-cli/utils/run-prettier"); +declare var process: { + cwd: Function; + webpackModule: { + validate: Function; + WebpackOptionsValidationError: { + new(errors: string[]): { + message: string; + }; + }; + }; + stdout: { + write: Function; + }; + exitCode: number; +}; /** * @@ -24,43 +39,47 @@ const runPrettier = require("@webpack-cli/utils/run-prettier"); * function. */ -module.exports = function migrate(...args) { - const filePaths = args.slice(3); +export default function migrate(...args: string[]): void | Promise { + const filePaths: string[] = args.slice(3); if (!filePaths.length) { - const errMsg = "\n ✖ Please specify a path to your webpack config \n "; + const errMsg: string = "\n ✖ Please specify a path to your webpack config \n "; console.error(chalk.red(errMsg)); return; } - const currentConfigPath = path.resolve(process.cwd(), filePaths[0]); - let outputConfigPath; + + const currentConfigPath: string = path.resolve(process.cwd(), filePaths[0]); + let outputConfigPath: string; + if (!filePaths[1]) { return inquirer .prompt([ { - type: "confirm", - name: "confirmPath", + default: "Y", message: "Migration output path not specified. " + "Do you want to use your existing webpack " + "configuration?", - default: "Y" - } + name: "confirmPath", + type: "confirm", + }, ]) - .then(ans => { - if (!ans["confirmPath"]) { + .then((ans: { + confirmPath: boolean; + }): void | Promise => { + if (!ans.confirmPath) { console.error(chalk.red("✖ ︎Migration aborted due no output path")); return; } outputConfigPath = path.resolve(process.cwd(), filePaths[0]); return runMigration(currentConfigPath, outputConfigPath); }) - .catch(err => { + .catch((err: object): void => { console.error(err); }); } outputConfigPath = path.resolve(process.cwd(), filePaths[1]); return runMigration(currentConfigPath, outputConfigPath); -}; +} /** * @@ -74,21 +93,24 @@ module.exports = function migrate(...args) { * user decides to abort the migration */ -function runMigration(currentConfigPath, outputConfigPath) { - const recastOptions = { - quote: "single" +function runMigration(currentConfigPath: string, outputConfigPath: string): Promise | void { + const recastOptions: object = { + quote: "single", }; - const tasks = new Listr([ + + const tasks: Listr = new Listr([ { - title: "Reading webpack config", - task: ctx => - new PLazy((resolve, reject) => { - fs.readFile(currentConfigPath, "utf8", (err, content) => { + task: (ctx: INode): string | void | Listr | Promise<{}> => + new pLazy(( + resolve: (value?: object) => void, + reject: (reason?: string | object, err?: object) => void, + ) => { + fs.readFile(currentConfigPath, "utf8", (err: object, content: string) => { if (err) { reject(err); } try { - const jscodeshift = require("jscodeshift"); + const jscodeshift: IJSCodeshift = require("jscodeshift"); ctx.source = content; ctx.ast = jscodeshift(content); resolve(); @@ -96,107 +118,119 @@ function runMigration(currentConfigPath, outputConfigPath) { reject("Error generating AST", err); } }); - }) + }), + title: "Reading webpack config", }, { - title: "Migrating config to newest version", - task: ctx => { - const transformations = require("./migrate").transformations; + task: (ctx: INode): string | void | Listr | Promise => { return new Listr( - Object.keys(transformations).map(key => { - const transform = transformations[key]; + Object.keys(transformations).map((key: string): { + task: (_?: void) => string; + title: string; + } => { + const transform: Function = transformations[key]; return { + task: (_?: void) => transform(ctx.ast, ctx.source), title: key, - task: _ => transform(ctx.ast, ctx.source) }; - }) + }), ); - } - } + }, + title: "Migrating config to newest version", + }, ]); tasks .run() - .then(ctx => { - const result = ctx.ast.toSource(recastOptions); - const diffOutput = diff.diffLines(ctx.source, result); - diffOutput.forEach(diffLine => { + .then((ctx: INode): void | Promise => { + const result: string = ctx.ast.toSource(recastOptions); + const diffOutput: diff.IDiffResult[] = diff.diffLines(ctx.source, result); + + diffOutput.forEach((diffLine: diff.IDiffResult): void => { if (diffLine.added) { process.stdout.write(chalk.green(`+ ${diffLine.value}`)); } else if (diffLine.removed) { process.stdout.write(chalk.red(`- ${diffLine.value}`)); } }); + return inquirer .prompt([ { - type: "confirm", - name: "confirmMigration", + default: "Y", message: "Are you sure these changes are fine?", - default: "Y" - } + name: "confirmMigration", + type: "confirm", + }, ]) - .then(answers => { - if (answers["confirmMigration"]) { + .then((answers: { + confirmMigration: boolean; + }): Promise<{}> => { + if (answers.confirmMigration) { return inquirer.prompt([ { - type: "confirm", - name: "confirmValidation", + default: "Y", message: "Do you want to validate your configuration? " + "(If you're using webpack merge, validation isn't useful)", - default: "Y" - } + name: "confirmValidation", + type: "confirm", + }, ]); } else { console.log(chalk.red("✖ Migration aborted")); } }) - .then(answer => { - if (!answer) return; + .then((answer: { + confirmValidation: boolean; + }): void => { + if (!answer) { return; } - runPrettier(outputConfigPath, result, err => { + runPrettier(outputConfigPath, result, (err: object): void => { if (err) { throw err; } }); - if (answer["confirmValidation"]) { - const webpackOptionsValidationErrors = validate( - require(outputConfigPath) + if (answer.confirmValidation) { + const webpackOptionsValidationErrors: string[] = validate( + require(outputConfigPath), ); + if (webpackOptionsValidationErrors.length) { console.log( chalk.red( - "\n✖ Your configuration validation wasn't successful \n" - ) + "\n✖ Your configuration validation wasn't successful \n", + ), ); console.error( new WebpackOptionsValidationError( - webpackOptionsValidationErrors - ).message + webpackOptionsValidationErrors, + ).message, ); } } + console.log( chalk.green( - `\n✔︎ New webpack config file is at ${outputConfigPath}.` - ) + `\n✔︎ New webpack config file is at ${outputConfigPath}.`, + ), ); console.log( chalk.green( - "✔︎ Heads up! Updating to the latest version could contain breaking changes." - ) + "✔︎ Heads up! Updating to the latest version could contain breaking changes.", + ), ); + console.log( chalk.green( - "✔︎ Plugin and loader dependencies may need to be updated." - ) + "✔︎ Plugin and loader dependencies may need to be updated.", + ), ); }); }) - .catch(err => { - const errMsg = "\n ✖ ︎Migration aborted due to some errors: \n"; + .catch((err: object): void => { + const errMsg: string = "\n ✖ ︎Migration aborted due to some errors: \n"; console.error(chalk.red(errMsg)); console.error(err); process.exitCode = 1; diff --git a/packages/migrate/loaderOptionsPlugin/loaderOptionsPlugin.js b/packages/migrate/loaderOptionsPlugin/loaderOptionsPlugin.ts similarity index 55% rename from packages/migrate/loaderOptionsPlugin/loaderOptionsPlugin.js rename to packages/migrate/loaderOptionsPlugin/loaderOptionsPlugin.ts index 566f7388483..2e4d6d4d1c8 100644 --- a/packages/migrate/loaderOptionsPlugin/loaderOptionsPlugin.js +++ b/packages/migrate/loaderOptionsPlugin/loaderOptionsPlugin.ts @@ -1,9 +1,17 @@ -const isEmpty = require("lodash/isEmpty"); -const findPluginsByName = require("@webpack-cli/utils/ast-utils") - .findPluginsByName; -const createOrUpdatePluginByName = require("@webpack-cli/utils/ast-utils") - .createOrUpdatePluginByName; -const safeTraverse = require("@webpack-cli/utils/ast-utils").safeTraverse; +import isEmpty = require("lodash/isEmpty"); + +import { + createOrUpdatePluginByName, + findPluginsByName, + safeTraverse, +} from "@webpack-cli/utils/ast-utils"; + +import { IJSCodeshift, INode } from "../types/NodePath"; + +interface ILoaderOptions { + debug?: boolean; + minimize?: boolean; +} /** * @@ -15,15 +23,18 @@ const safeTraverse = require("@webpack-cli/utils/ast-utils").safeTraverse; * */ -module.exports = function(j, ast) { - const loaderOptions = {}; +export default function(j: IJSCodeshift, ast: INode): void { + const loaderOptions: ILoaderOptions = {}; // If there is debug: true, set debug: true in the plugin if (ast.find(j.Identifier, { name: "debug" }).size()) { loaderOptions.debug = true; - ast.find(j.Identifier, { name: "debug" }).forEach(p => { - p.parent.prune(); - }); + + ast + .find(j.Identifier, { name: "debug" }) + .forEach((p: INode): void => { + p.parent.prune(); + }); } // If there is UglifyJsPlugin, set minimize: true @@ -34,16 +45,17 @@ module.exports = function(j, ast) { return ast .find(j.ArrayExpression) .filter( - path => - safeTraverse(path, ["parent", "value", "key", "name"]) === "plugins" + (path: INode): boolean => + safeTraverse(path, ["parent", "value", "key", "name"]) === "plugins", ) - .forEach(path => { - !isEmpty(loaderOptions) && + .forEach((path: INode): void => { + if (!isEmpty(loaderOptions)) { createOrUpdatePluginByName( j, path, "webpack.LoaderOptionsPlugin", - loaderOptions + loaderOptions, ); + } }); -}; +} diff --git a/packages/migrate/loaders/loaders.js b/packages/migrate/loaders/loaders.ts similarity index 66% rename from packages/migrate/loaders/loaders.js rename to packages/migrate/loaders/loaders.ts index 02e4d48f098..187b7e8a08e 100644 --- a/packages/migrate/loaders/loaders.js +++ b/packages/migrate/loaders/loaders.ts @@ -1,4 +1,6 @@ -const utils = require("@webpack-cli/utils/ast-utils"); +import * as utils from "@webpack-cli/utils/ast-utils"; + +import { IJSCodeshift, INode } from "../types/NodePath"; /** * @@ -11,7 +13,7 @@ const utils = require("@webpack-cli/utils/ast-utils"); * @returns {Node} ast - jscodeshift ast */ -module.exports = function(j, ast) { +export default function(j: IJSCodeshift, ast: INode): INode { /** * Creates an Array expression out of loaders string * @@ -52,43 +54,43 @@ module.exports = function(j, ast) { * @returns {Node} path - object expression ast with array expression instead of loaders string */ - const createArrayExpressionFromArray = function(path) { - const value = path.value; + const createArrayExpressionFromArray = (path: INode): INode => { + const value: INode = path.value; // Find paths with `loaders` keys in the given Object - const paths = value.properties.filter(prop => - prop.key.name.startsWith("loader") + const paths: INode[] = value.properties.filter((prop: INode): boolean => + prop.key.name.startsWith("loader"), ); // For each pair of key and value - paths.forEach(pair => { + paths.forEach((pair: INode): void => { // Replace 'loaders' Identifier with 'use' pair.key.name = "use"; // If the value is an Array if (pair.value.type === j.ArrayExpression.name) { // replace its elements - const pairValue = pair.value; + const pairValue: INode = pair.value; pair.value = j.arrayExpression( - pairValue.elements.map(arrElement => { + pairValue.elements.map((arrElement: INode): INode => { // If items of the array are Strings if (arrElement.type === j.Literal.name) { // Replace with `{ loader: LOADER }` Object return j.objectExpression([ - utils.createProperty(j, "loader", arrElement.value) + utils.createProperty(j, "loader", arrElement.value), ]); } // otherwise keep the existing element return arrElement; - }) + }), ); - // If the value is String of loaders like 'style!css' + // If the value is String of loaders like 'style!css' } else if (pair.value.type === j.Literal.name) { // Replace it with Array expression of loaders - const literalValue = pair.value; + const literalValue: INode = pair.value; pair.value = j.arrayExpression( - literalValue.value.split("!").map(loader => { + literalValue.value.split("!").map((loader: string): INode => { return j.objectExpression([ - utils.createProperty(j, "loader", loader) + utils.createProperty(j, "loader", loader), ]); - }) + }), ); } }); @@ -103,25 +105,25 @@ module.exports = function(j, ast) { * @returns {Node} objectExpression - an new object expression ast containing the query parameters */ - const createLoaderWithQuery = p => { - let properties = p.value.properties; - let loaderValue = properties.reduce( - (val, prop) => (prop.key.name === "loader" ? prop.value.value : val), - "" + const createLoaderWithQuery = (p: INode): INode => { + const properties: INode[] = p.value.properties; + const loaderValue: string = properties.reduce( + (val: string, prop: INode): string => (prop.key.name === "loader" ? prop.value.value : val), + "", ); - let loader = loaderValue.split("?")[0]; - let query = loaderValue.split("?")[1]; - let options = query.split("&").map(option => { - const param = option.split("="); - const key = param[0]; - const val = param[1] || true; // No value in query string means it is truthy value + const loader: string = loaderValue.split("?")[0]; + const query: string = loaderValue.split("?")[1]; + const options: INode[] = query.split("&").map((option: string): INode => { + const param: string[] = option.split("="); + const key: string = param[0]; + const val: string | boolean = param[1] || true; // No value in query string means it is truthy value return j.objectProperty(j.identifier(key), utils.createLiteral(j, val)); }); - let loaderProp = utils.createProperty(j, "loader", loader); - let queryProp = j.property( + const loaderProp: INode = utils.createProperty(j, "loader", loader); + const queryProp: INode = j.property( "init", j.identifier("options"), - j.objectExpression(options) + j.objectExpression(options), ); return j.objectExpression([loaderProp, queryProp]); }; @@ -134,8 +136,8 @@ module.exports = function(j, ast) { * @returns {Boolean} hasLoaderQueryString - whether the loader object contains a query string */ - const findLoaderWithQueryString = p => { - return p.value.properties.reduce((predicate, prop) => { + const findLoaderWithQueryString = (p: INode): boolean => { + return p.value.properties.reduce((predicate: boolean, prop: INode): boolean => { return ( (utils.safeTraverse(prop, ["value", "value", "indexOf"]) && prop.value.value.indexOf("?") > -1) || @@ -153,7 +155,7 @@ module.exports = function(j, ast) { * @returns {Boolean} isLoadersProp - whether the identifier is the `loaders` prop in the `module` object */ - const checkForLoader = path => + const checkForLoader = (path: INode): boolean => path.value.name === "loaders" && utils.safeTraverse(path, [ "parent", @@ -161,7 +163,7 @@ module.exports = function(j, ast) { "parent", "node", "key", - "name" + "name", ]) === "module"; /** @@ -171,19 +173,19 @@ module.exports = function(j, ast) { * @returns {Node} p - object expression with a `loaders` object and appropriate `enforce` properties */ - const fitIntoLoaders = p => { - let loaders; - p.value.properties.map(prop => { + const fitIntoLoaders = (p: INode): INode => { + let loaders: INode = null; + p.value.properties.map((prop: INode): void => { const keyName = prop.key.name; if (keyName === "loaders") { loaders = prop.value; } }); - p.value.properties.map(prop => { + p.value.properties.map((prop: INode): void => { const keyName = prop.key.name; if (keyName !== "loaders") { - const enforceVal = keyName === "preLoaders" ? "pre" : "post"; - prop.value.elements.map(elem => { + const enforceVal: string = keyName === "preLoaders" ? "pre" : "post"; + prop.value.elements.map((elem: INode): void => { elem.properties.push(utils.createProperty(j, "enforce", enforceVal)); if (loaders && loaders.type === "ArrayExpression") { loaders.elements.push(elem); @@ -195,7 +197,7 @@ module.exports = function(j, ast) { }); if (loaders) { p.value.properties = p.value.properties.filter( - prop => prop.key.name === "loaders" + (prop: INode): boolean => prop.key.name === "loaders", ); } return p; @@ -207,10 +209,10 @@ module.exports = function(j, ast) { * @returns {Node} ast - jscodeshift ast */ - const prepostLoaders = () => + const prepostLoaders = (_?: void): void => ast .find(j.ObjectExpression) - .filter(p => utils.findObjWithOneOfKeys(p, ["preLoaders", "postLoaders"])) + .filter((p: INode): boolean => utils.findObjWithOneOfKeys(p, ["preLoaders", "postLoaders"])) .forEach(fitIntoLoaders); /** @@ -219,11 +221,11 @@ module.exports = function(j, ast) { * @returns {Node} ast - jscodeshift ast */ - const loadersToRules = () => + const loadersToRules = (_?: void): void => ast .find(j.Identifier) .filter(checkForLoader) - .forEach(p => (p.value.name = "rules")); + .forEach((p: INode): string => (p.value.name = "rules")); /** * Convert `loader` and `loaders` to Array of {Rule.Use} @@ -231,19 +233,19 @@ module.exports = function(j, ast) { * @returns {Node} ast - jscodeshift ast */ - const loadersToArrayExpression = () => + const loadersToArrayExpression = (_?: void): INode | void => ast .find(j.ObjectExpression) - .filter(path => utils.findObjWithOneOfKeys(path, ["loader", "loaders"])) + .filter((path: INode): boolean => utils.findObjWithOneOfKeys(path, ["loader", "loaders"])) .filter( - path => + (path: INode): boolean => utils.safeTraverse(path, [ "parent", "parent", "node", "key", - "name" - ]) === "rules" + "name", + ]) === "rules", ) .forEach(createArrayExpressionFromArray); @@ -269,10 +271,10 @@ module.exports = function(j, ast) { * @returns {Node} ast - jscodeshift ast */ - const loaderWithQueryParam = () => + const loaderWithQueryParam = (_?: void): INode => ast .find(j.ObjectExpression) - .filter(p => utils.findObjWithOneOfKeys(p, ["loader"])) + .filter((p: INode): boolean => utils.findObjWithOneOfKeys(p, ["loader"])) .filter(findLoaderWithQueryString) .replaceWith(createLoaderWithQuery); @@ -293,10 +295,10 @@ module.exports = function(j, ast) { * @returns {Node} ast - jscodeshift ast */ - const loaderWithQueryProp = () => + const loaderWithQueryProp = (_?: void): INode => ast .find(j.Identifier) - .filter(p => p.value.name === "query") + .filter((p: INode): boolean => p.value.name === "query") .replaceWith(j.identifier("options")); /** @@ -306,9 +308,9 @@ module.exports = function(j, ast) { * @returns {Node} ast - jscodeshift ast */ - const addLoaderSuffix = () => - ast.find(j.ObjectExpression).forEach(path => { - path.value.properties.forEach(prop => { + const addLoaderSuffix = (_?: void): void => + ast.find(j.ObjectExpression).forEach((path: INode): void => { + path.value.properties.forEach((prop: INode): void => { if ( prop.key.name === "loader" && utils.safeTraverse(prop, ["value", "value"]) && @@ -327,10 +329,10 @@ module.exports = function(j, ast) { * @returns {Node} objectExpression - an use object expression ast containing the options and loader */ - const fitOptionsToUse = p => { - let options; - p.value.properties.forEach(prop => { - const keyName = prop.key.name; + const fitOptionsToUse = (p: INode): INode => { + let options: INode = null; + p.value.properties.forEach((prop: INode): void => { + const keyName: string = prop.key.name; if (keyName === "options") { options = prop; } @@ -338,10 +340,10 @@ module.exports = function(j, ast) { if (options) { p.value.properties = p.value.properties.filter( - prop => prop.key.name !== "options" + (prop: INode): boolean => prop.key.name !== "options", ); - p.value.properties.forEach(prop => { + p.value.properties.forEach((prop: INode): void => { const keyName = prop.key.name; if (keyName === "use") { prop.value.elements[0].properties.push(options); @@ -358,10 +360,10 @@ module.exports = function(j, ast) { * @returns {Node} ast - jscodeshift ast */ - const moveOptionsToUse = () => + const moveOptionsToUse = (_?: void): void => ast .find(j.ObjectExpression) - .filter(p => utils.findObjWithOneOfKeys(p, ["use"])) + .filter((p: INode): boolean => utils.findObjWithOneOfKeys(p, ["use"])) .forEach(fitOptionsToUse); const transforms = [ @@ -371,9 +373,9 @@ module.exports = function(j, ast) { loaderWithQueryParam, loaderWithQueryProp, addLoaderSuffix, - moveOptionsToUse + moveOptionsToUse, ]; - transforms.forEach(t => t()); + transforms.forEach((t: Function): void => t()); return ast; -}; +} diff --git a/packages/migrate/migrate.js b/packages/migrate/migrate.js deleted file mode 100644 index c3a6eaf4019..00000000000 --- a/packages/migrate/migrate.js +++ /dev/null @@ -1,81 +0,0 @@ -const jscodeshift = require("jscodeshift"); -const pEachSeries = require("p-each-series"); -const PLazy = require("p-lazy"); - -const loadersTransform = require("./loaders/loaders"); -const resolveTransform = require("./resolve/resolve"); -const removeJsonLoaderTransform = require("./removeJsonLoader/removeJsonLoader"); -const uglifyJsPluginTransform = require("./uglifyJsPlugin/uglifyJsPlugin"); -const loaderOptionsPluginTransform = require("./loaderOptionsPlugin/loaderOptionsPlugin"); -const bannerPluginTransform = require("./bannerPlugin/bannerPlugin"); -const extractTextPluginTransform = require("./extractTextPlugin/extractTextPlugin"); -const noEmitOnErrorsPluginTransform = require("./noEmitOnErrorsPlugin/noEmitOnErrorsPlugin"); -const removeDeprecatedPluginsTransform = require("./removeDeprecatedPlugins/removeDeprecatedPlugins"); - -const transformsObject = { - loadersTransform, - resolveTransform, - removeJsonLoaderTransform, - uglifyJsPluginTransform, - loaderOptionsPluginTransform, - bannerPluginTransform, - extractTextPluginTransform, - noEmitOnErrorsPluginTransform, - removeDeprecatedPluginsTransform -}; - -const transformations = Object.keys(transformsObject).reduce((res, key) => { - res[key] = (ast, source) => - transformSingleAST(ast, source, transformsObject[key]); - return res; -}, {}); - -function transformSingleAST(ast, source, transformFunction) { - return new PLazy((resolve, reject) => { - setTimeout(_ => { - try { - resolve(transformFunction(jscodeshift, ast, source)); - } catch (err) { - reject(err); - } - }, 0); - }); -} - -/** - * - * Transforms a given piece of source code by applying selected transformations to the AST. - * By default, transforms a webpack version 1 configuration file into a webpack version 2 - * configuration file. - * - * @param {String} source - source file contents - * @param {Function[]} [transforms] - List of transformation functions, defined in the - * order to apply them in. By default, all defined transformations. - * @param {Object} [options] - recast formatting options - * @returns {String} source — transformed source code - */ - -function transform(source, transforms, options) { - const ast = jscodeshift(source); - const recastOptions = Object.assign( - { - quote: "single" - }, - options - ); - transforms = - transforms || Object.keys(transformations).map(k => transformations[k]); - return pEachSeries(transforms, f => f(ast, source)) - .then(_ => { - return ast.toSource(recastOptions); - }) - .catch(err => { - console.error(err); - }); -} - -module.exports = { - transform, - transformSingleAST, - transformations -}; diff --git a/packages/migrate/migrate.ts b/packages/migrate/migrate.ts new file mode 100644 index 00000000000..1ce904e0af9 --- /dev/null +++ b/packages/migrate/migrate.ts @@ -0,0 +1,116 @@ +import * as jscodeshift from "jscodeshift"; +import pEachSeries = require("p-each-series"); +import pLazy = require("p-lazy"); + +import bannerPluginTransform from "./bannerPlugin/bannerPlugin"; +import extractTextPluginTransform from "./extractTextPlugin/extractTextPlugin"; +import loaderOptionsPluginTransform from "./loaderOptionsPlugin/loaderOptionsPlugin"; +import loadersTransform from "./loaders/loaders"; +import noEmitOnErrorsPluginTransform from "./noEmitOnErrorsPlugin/noEmitOnErrorsPlugin"; +import removeDeprecatedPluginsTransform from "./removeDeprecatedPlugins/removeDeprecatedPlugins"; +import removeJsonLoaderTransform from "./removeJsonLoader/removeJsonLoader"; +import resolveTransform from "./resolve/resolve"; +import { INode } from "./types/NodePath"; +import uglifyJsPluginTransform from "./uglifyJsPlugin/uglifyJsPlugin"; + +interface ITransformsObject { + bannerPluginTransform: object; + extractTextPluginTransform: object; + loaderOptionsPluginTransform: object; + loadersTransform: object; + noEmitOnErrorsPluginTransform: object; + removeDeprecatedPluginsTransform: object; + removeJsonLoaderTransform: object; + resolveTransform: object; + uglifyJsPluginTransform: object; +} + +const transformsObject: ITransformsObject = { + bannerPluginTransform, + extractTextPluginTransform, + loaderOptionsPluginTransform, + loadersTransform, + noEmitOnErrorsPluginTransform, + removeDeprecatedPluginsTransform, + removeJsonLoaderTransform, + resolveTransform, + uglifyJsPluginTransform, +}; + +export const transformations = + Object + .keys(transformsObject) + .reduce((res: object, key: string): object => { + res[key] = (ast: object, source: string) => + transformSingleAST(ast, source, transformsObject[key]); + return res; + }, {}); + +/** + * + * Transforms single AST based on given transform function + * and returns back a promise with resolved transformation + * + * @param {Object} ast - AST object + * @param {String} source - source string + * @param {Function} transformFunction - Transformation function with source object + * @returns {Object} pLazy promise with resolved transform function + */ + +export const transformSingleAST = ( + ast: object, + source: string, + transformFunction: (jscodeshift: object, ast: object, source: string) => object) + : pLazy<{}> => { + + return new pLazy(( + resolve: (value?: {} | PromiseLike<{}>) => void, + reject: (reason?: object) => void, + ): void => { + setTimeout((_?: void): void => { + try { + resolve(transformFunction(jscodeshift, ast, source)); + } catch (err) { + reject(err); + } + }, 0); + }); +}; + +/** + * + * Transforms a given piece of source code by applying selected transformations to the AST. + * By default, transforms a webpack version 1 configuration file into a webpack version 2 + * configuration file. + * + * @param {String} source - source file contents + * @param {Function[]} [transforms] - List of transformation functions, defined in the + * order to apply them in. By default, all defined transformations. + * @param {Object} [options] - recast formatting options + * @returns {Promise} promise functions for series + */ + +export const transform = ( + source: string, + transforms?: Iterable>, + options?: object) + : Promise => { + + const ast: INode = jscodeshift(source); + const recastOptions: object = Object.assign( + { + quote: "single", + }, + options, + ); + transforms = + transforms || Object.keys(transformations).map((k: string): Function => transformations[k]); + + return pEachSeries(transforms, (f: Function) => f(ast, source)) + .then((value: Function[]): string | PromiseLike => { + return ast.toSource(recastOptions); + }) + .catch((err: object) => { + console.error(err); + }); +}; diff --git a/packages/migrate/moduleConcatenationPlugin/moduleConcatenationPlugin.js b/packages/migrate/moduleConcatenationPlugin/moduleConcatenationPlugin.ts similarity index 58% rename from packages/migrate/moduleConcatenationPlugin/moduleConcatenationPlugin.js rename to packages/migrate/moduleConcatenationPlugin/moduleConcatenationPlugin.ts index e7275dd0857..21750bc8663 100644 --- a/packages/migrate/moduleConcatenationPlugin/moduleConcatenationPlugin.js +++ b/packages/migrate/moduleConcatenationPlugin/moduleConcatenationPlugin.ts @@ -1,7 +1,9 @@ -const { +import { addOrUpdateConfigObject, - findAndRemovePluginByName -} = require("@webpack-cli/utils/ast-utils"); + findAndRemovePluginByName, +} from "@webpack-cli/utils/ast-utils"; + +import { IJSCodeshift, INode } from "../types/NodePath"; /** * @@ -12,23 +14,24 @@ const { * @param {Node} ast - jscodeshift ast to transform * @returns {Node} ast - jscodeshift ast */ -module.exports = function(j, ast) { +export default function(j: IJSCodeshift, ast: INode): INode { // Remove old plugin - const root = findAndRemovePluginByName( + const root: INode = findAndRemovePluginByName( j, ast, - "webpack.optimize.ModuleConcatenationPlugin" + "webpack.optimize.ModuleConcatenationPlugin", ); // Add new optimizations option - root && + if (root) { addOrUpdateConfigObject( j, root, "optimizations", "concatenateModules", - j.booleanLiteral(true) + j.booleanLiteral(true), ); + } return ast; -}; +} diff --git a/packages/migrate/namedModulesPlugin/namedModulesPlugin.js b/packages/migrate/namedModulesPlugin/namedModulesPlugin.ts similarity index 58% rename from packages/migrate/namedModulesPlugin/namedModulesPlugin.js rename to packages/migrate/namedModulesPlugin/namedModulesPlugin.ts index 99b6fed918f..98c7e2ceb9c 100644 --- a/packages/migrate/namedModulesPlugin/namedModulesPlugin.js +++ b/packages/migrate/namedModulesPlugin/namedModulesPlugin.ts @@ -1,7 +1,9 @@ -const { +import { addOrUpdateConfigObject, - findAndRemovePluginByName -} = require("@webpack-cli/utils/ast-utils"); + findAndRemovePluginByName, +} from "@webpack-cli/utils/ast-utils"; + +import { IJSCodeshift, INode } from "../types/NodePath"; /** * @@ -12,19 +14,20 @@ const { * @param {Node} ast - jscodeshift ast to transform * @returns {Node} ast - jscodeshift ast */ -module.exports = function(j, ast) { +export default function(j: IJSCodeshift, ast: INode): INode { // Remove old plugin - const root = findAndRemovePluginByName(j, ast, "webpack.NamedModulesPlugin"); + const root: INode = findAndRemovePluginByName(j, ast, "webpack.NamedModulesPlugin"); // Add new optimizations option - root && + if (root) { addOrUpdateConfigObject( j, root, "optimizations", "namedModules", - j.booleanLiteral(true) + j.booleanLiteral(true), ); + } return ast; -}; +} diff --git a/packages/migrate/noEmitOnErrorsPlugin/noEmitOnErrorsPlugin.js b/packages/migrate/noEmitOnErrorsPlugin/noEmitOnErrorsPlugin.ts similarity index 59% rename from packages/migrate/noEmitOnErrorsPlugin/noEmitOnErrorsPlugin.js rename to packages/migrate/noEmitOnErrorsPlugin/noEmitOnErrorsPlugin.ts index cb285245317..c45ce923185 100644 --- a/packages/migrate/noEmitOnErrorsPlugin/noEmitOnErrorsPlugin.js +++ b/packages/migrate/noEmitOnErrorsPlugin/noEmitOnErrorsPlugin.ts @@ -1,7 +1,8 @@ -const { +import { addOrUpdateConfigObject, - findAndRemovePluginByName -} = require("@webpack-cli/utils/ast-utils"); + findAndRemovePluginByName, +} from "@webpack-cli/utils/ast-utils"; +import { IJSCodeshift, INode } from "../types/NodePath"; /** * @@ -12,23 +13,24 @@ const { * @param {Node} ast - jscodeshift ast to transform * @returns {Node} ast - jscodeshift ast */ -module.exports = function(j, ast) { +export default function(j: IJSCodeshift, ast: INode): INode { // Remove old plugin - const root = findAndRemovePluginByName( + const root: INode = findAndRemovePluginByName( j, ast, - "webpack.NoEmitOnErrorsPlugin" + "webpack.NoEmitOnErrorsPlugin", ); // Add new optimizations option - root && + if (root) { addOrUpdateConfigObject( j, root, "optimizations", "noEmitOnErrors", - j.booleanLiteral(true) + j.booleanLiteral(true), ); + } return ast; -}; +} diff --git a/packages/migrate/outputPath/outputPath.js b/packages/migrate/outputPath/outputPath.ts similarity index 56% rename from packages/migrate/outputPath/outputPath.js rename to packages/migrate/outputPath/outputPath.ts index 0a0334c4ebd..1d3e54853a6 100644 --- a/packages/migrate/outputPath/outputPath.js +++ b/packages/migrate/outputPath/outputPath.ts @@ -1,4 +1,6 @@ -const utils = require("@webpack-cli/utils/ast-utils"); +import * as utils from "@webpack-cli/utils/ast-utils"; + +import { IJSCodeshift, INode } from "../types/NodePath"; /** * @@ -9,66 +11,69 @@ const utils = require("@webpack-cli/utils/ast-utils"); * @returns {Node} ast - jscodeshift ast */ -module.exports = function(j, ast) { - const literalOutputPath = ast +export default function(j: IJSCodeshift, ast: INode): INode | void { + + const literalOutputPath: INode = ast .find(j.ObjectExpression) .filter( - p => + (p: INode): boolean => utils.safeTraverse(p, ["parentPath", "value", "key", "name"]) === - "output" + "output", ) .find(j.Property) .filter( - p => + (p: INode): boolean => utils.safeTraverse(p, ["value", "key", "name"]) === "path" && - utils.safeTraverse(p, ["value", "value", "type"]) === "Literal" + utils.safeTraverse(p, ["value", "value", "type"]) === "Literal", ); if (literalOutputPath) { let pathVarName = "path"; let isPathPresent = false; - const pathDeclaration = ast + const pathDeclaration: INode = ast .find(j.VariableDeclarator) .filter( - p => + (p: INode): boolean => utils.safeTraverse(p, ["value", "init", "callee", "name"]) === - "require" + "require", ) .filter( - p => + (p: INode): boolean => utils.safeTraverse(p, ["value", "init", "arguments"]) && - p.value.init.arguments.reduce((isPresent, a) => { + p.value.init.arguments.reduce((isPresent: boolean, a: INode): boolean => { return (a.type === "Literal" && a.value === "path") || isPresent; - }, false) + }, false), ); if (pathDeclaration) { isPathPresent = true; - pathDeclaration.forEach(p => { + pathDeclaration.forEach((p: INode): void => { pathVarName = utils.safeTraverse(p, ["value", "id", "name"]); }); } const finalPathName = pathVarName; literalOutputPath .find(j.Literal) - .replaceWith(p => replaceWithPath(j, p, finalPathName)); + .replaceWith((p: INode): INode => replaceWithPath(j, p, finalPathName)); if (!isPathPresent) { - const pathRequire = utils.getRequire(j, "path", "path"); + const pathRequire: INode[] = utils.getRequire(j, "path", "path"); return ast .find(j.Program) - .replaceWith(p => - j.program([].concat(pathRequire).concat(p.value.body)) + .replaceWith((p: INode): INode => + j.program([].concat(pathRequire).concat(p.value.body)), ); } } + return ast; -}; +} -function replaceWithPath(j, p, pathVarName) { - const convertedPath = j.callExpression( +function replaceWithPath(j: IJSCodeshift, p: INode, pathVarName: string): INode { + const convertedPath: INode = j.callExpression( j.memberExpression(j.identifier(pathVarName), j.identifier("join"), false), - [j.identifier("__dirname"), p.value] + [j.identifier("__dirname"), p.value], ); + return convertedPath; } diff --git a/packages/migrate/package-lock.json b/packages/migrate/package-lock.json index fa45bec4741..25e41d11583 100644 --- a/packages/migrate/package-lock.json +++ b/packages/migrate/package-lock.json @@ -3,17 +3,17 @@ "lockfileVersion": 1, "dependencies": { "@babel/code-frame": { - "version": "7.0.0-beta.51", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0-beta.51.tgz", - "integrity": "sha1-vXHZsZKvl435FYKdOdQJRFZDmgw=", + "version": "7.0.0-beta.52", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0-beta.52.tgz", + "integrity": "sha1-GSSDv6DR5GfBAVccIQKcy3SvKAE=", "requires": { - "@babel/highlight": "7.0.0-beta.51" + "@babel/highlight": "7.0.0-beta.52" } }, "@babel/highlight": { - "version": "7.0.0-beta.51", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.0.0-beta.51.tgz", - "integrity": "sha1-6IRK4loVlcz9QriWI7Q3bKBtIl0=", + "version": "7.0.0-beta.52", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.0.0-beta.52.tgz", + "integrity": "sha1-7ySTFDLwYVXnvDnNuKaze0oos9A=", "requires": { "chalk": "^2.0.0", "esutils": "^2.0.2", @@ -28,6 +28,177 @@ "any-observable": "^0.3.0" } }, + "@types/chalk": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@types/chalk/-/chalk-2.2.0.tgz", + "integrity": "sha512-1zzPV9FDe1I/WHhRkf9SNgqtRJWZqrBWgu7JGveuHmmyR9CnAPCie2N/x+iHrgnpYBIcCJWHBoMRv2TRWktsvw==", + "requires": { + "chalk": "*" + } + }, + "@types/diff": { + "version": "3.5.1", + "resolved": "https://registry.npmjs.org/@types/diff/-/diff-3.5.1.tgz", + "integrity": "sha512-nkT7bd/YM6QRDQjww8PYf0kOj1MvwxQ/WaCinj2Hm1HlL+JqGTm4cDoQeROfiWX/B3SNI1nyLLhLAQpp5sE3hw==" + }, + "@types/inquirer": { + "version": "0.0.41", + "resolved": "https://registry.npmjs.org/@types/inquirer/-/inquirer-0.0.41.tgz", + "integrity": "sha512-kIWkK3FECGKt9OrURxRvi59gwMNiWTePXWOvaJn+xhplbEvu91hIDMfLe5PUu+cEEMmD6EFU4VFJJKKp5kzCtw==", + "requires": { + "@types/rx": "*", + "@types/through": "*" + } + }, + "@types/listr": { + "version": "0.13.0", + "resolved": "https://registry.npmjs.org/@types/listr/-/listr-0.13.0.tgz", + "integrity": "sha512-8DOy0JCGwwAf76xmU0sRzSZCWKSPPA9djRcTYTsyqBPnMdGOjZ5tjmNswC4J9mgKZudte2tuTo1l14R1/t5l/g==", + "requires": { + "@types/node": "*" + } + }, + "@types/lodash": { + "version": "4.14.111", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.111.tgz", + "integrity": "sha512-t2FwnkdqdZNYPJHTEF+Zf//j5d2I7UbM2Ng+vqqmUCE2RuiVVINJi9RlVdpKvqPqVItsJa0X+ra/tvmwLzlcgg==" + }, + "@types/node": { + "version": "10.5.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.5.2.tgz", + "integrity": "sha512-m9zXmifkZsMHZBOyxZWilMwmTlpC8x5Ty360JKTiXvlXZfBWYpsg9ZZvP/Ye+iZUh+Q+MxDLjItVTWIsfwz+8Q==" + }, + "@types/p-each-series": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@types/p-each-series/-/p-each-series-1.0.0.tgz", + "integrity": "sha512-bqQAn+tAs1QwGQYNIbv8a0XT8Pzl6Z+6SVpca+vJngcvwRwws7eJj9P2rTJDpjwOSyX1iRNSlIokUlusV0mP0A==" + }, + "@types/p-lazy": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@types/p-lazy/-/p-lazy-1.0.0.tgz", + "integrity": "sha512-pqfl27Dolh25QxkKKbRfOY58gX/raqhaUFBIrNZudWcHQkMcQHMfJ7aqgCNFT8Vjm5DkVsEPl2Wl+8QpeCDG6A==" + }, + "@types/rx": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/@types/rx/-/rx-4.1.1.tgz", + "integrity": "sha1-WY/JSla67ZdfGUV04PVy/Y5iekg=", + "requires": { + "@types/rx-core": "*", + "@types/rx-core-binding": "*", + "@types/rx-lite": "*", + "@types/rx-lite-aggregates": "*", + "@types/rx-lite-async": "*", + "@types/rx-lite-backpressure": "*", + "@types/rx-lite-coincidence": "*", + "@types/rx-lite-experimental": "*", + "@types/rx-lite-joinpatterns": "*", + "@types/rx-lite-testing": "*", + "@types/rx-lite-time": "*", + "@types/rx-lite-virtualtime": "*" + } + }, + "@types/rx-core": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/@types/rx-core/-/rx-core-4.0.3.tgz", + "integrity": "sha1-CzNUsSOM7b4rdPYybxOdvHpZHWA=" + }, + "@types/rx-core-binding": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/@types/rx-core-binding/-/rx-core-binding-4.0.4.tgz", + "integrity": "sha512-5pkfxnC4w810LqBPUwP5bg7SFR/USwhMSaAeZQQbEHeBp57pjKXRlXmqpMrLJB4y1oglR/c2502853uN0I+DAQ==", + "requires": { + "@types/rx-core": "*" + } + }, + "@types/rx-lite": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/@types/rx-lite/-/rx-lite-4.0.5.tgz", + "integrity": "sha512-KZk5XTR1dm/kNgBx8iVpjno6fRYtAUQWBOmj+O8j724+nk097sz4fOoHJNpCkOJUtHUurZlJC7QvSFCZHbkC+w==", + "requires": { + "@types/rx-core": "*", + "@types/rx-core-binding": "*" + } + }, + "@types/rx-lite-aggregates": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/@types/rx-lite-aggregates/-/rx-lite-aggregates-4.0.3.tgz", + "integrity": "sha512-MAGDAHy8cRatm94FDduhJF+iNS5//jrZ/PIfm+QYw9OCeDgbymFHChM8YVIvN2zArwsRftKgE33QfRWvQk4DPg==", + "requires": { + "@types/rx-lite": "*" + } + }, + "@types/rx-lite-async": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@types/rx-lite-async/-/rx-lite-async-4.0.2.tgz", + "integrity": "sha512-vTEv5o8l6702ZwfAM5aOeVDfUwBSDOs+ARoGmWAKQ6LOInQ8J4/zjM7ov12fuTpktUKdMQjkeCp07Vd73mPkxw==", + "requires": { + "@types/rx-lite": "*" + } + }, + "@types/rx-lite-backpressure": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/@types/rx-lite-backpressure/-/rx-lite-backpressure-4.0.3.tgz", + "integrity": "sha512-Y6aIeQCtNban5XSAF4B8dffhIKu6aAy/TXFlScHzSxh6ivfQBQw6UjxyEJxIOt3IT49YkS+siuayM2H/Q0cmgA==", + "requires": { + "@types/rx-lite": "*" + } + }, + "@types/rx-lite-coincidence": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/@types/rx-lite-coincidence/-/rx-lite-coincidence-4.0.3.tgz", + "integrity": "sha512-1VNJqzE9gALUyMGypDXZZXzR0Tt7LC9DdAZQ3Ou/Q0MubNU35agVUNXKGHKpNTba+fr8GdIdkC26bRDqtCQBeQ==", + "requires": { + "@types/rx-lite": "*" + } + }, + "@types/rx-lite-experimental": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@types/rx-lite-experimental/-/rx-lite-experimental-4.0.1.tgz", + "integrity": "sha1-xTL1y98/LBXaFt7Ykw0bKYQCPL0=", + "requires": { + "@types/rx-lite": "*" + } + }, + "@types/rx-lite-joinpatterns": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@types/rx-lite-joinpatterns/-/rx-lite-joinpatterns-4.0.1.tgz", + "integrity": "sha1-9w/jcFGKhDLykVjMkv+1a05K/D4=", + "requires": { + "@types/rx-lite": "*" + } + }, + "@types/rx-lite-testing": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@types/rx-lite-testing/-/rx-lite-testing-4.0.1.tgz", + "integrity": "sha1-IbGdEfTf1v/vWp0WSOnIh5v+Iek=", + "requires": { + "@types/rx-lite-virtualtime": "*" + } + }, + "@types/rx-lite-time": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/@types/rx-lite-time/-/rx-lite-time-4.0.3.tgz", + "integrity": "sha512-ukO5sPKDRwCGWRZRqPlaAU0SKVxmWwSjiOrLhoQDoWxZWg6vyB9XLEZViKOzIO6LnTIQBlk4UylYV0rnhJLxQw==", + "requires": { + "@types/rx-lite": "*" + } + }, + "@types/rx-lite-virtualtime": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/@types/rx-lite-virtualtime/-/rx-lite-virtualtime-4.0.3.tgz", + "integrity": "sha512-3uC6sGmjpOKatZSVHI2xB1+dedgml669ZRvqxy+WqmGJDVusOdyxcKfyzjW0P3/GrCiN4nmRkLVMhPwHCc5QLg==", + "requires": { + "@types/rx-lite": "*" + } + }, + "@types/through": { + "version": "0.0.29", + "resolved": "https://registry.npmjs.org/@types/through/-/through-0.0.29.tgz", + "integrity": "sha512-9a7C5VHh+1BKblaYiq+7Tfc+EOmjMdZaD1MYtkQjSoxgB69tBjW98ry6SKsi4zEIWztLOMRuL87A3bdT/Fc/4w==", + "requires": { + "@types/node": "*" + } + }, "abab": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/abab/-/abab-1.0.4.tgz", @@ -2073,9 +2244,9 @@ } }, "flow-parser": { - "version": "0.75.0", - "resolved": "https://registry.npmjs.org/flow-parser/-/flow-parser-0.75.0.tgz", - "integrity": "sha512-QEyV/t9TERBOSI/zSx0zhKH6924135WPI7pMmug2n/n/4puFm4mdAq1QaKPA3IPhXDRtManbySkKhRqws5UUGA==" + "version": "0.76.0", + "resolved": "https://registry.npmjs.org/flow-parser/-/flow-parser-0.76.0.tgz", + "integrity": "sha512-p+K8OKiMlq8AIZH8KTydHEGUUd71AqfCL+zTJNsdHtQmX3i3eaeIysF83Ad6Oo7OQcHCj3vocb/EHYiEyq+ZBg==" }, "for-in": { "version": "1.0.2", @@ -2795,9 +2966,9 @@ } }, "hosted-git-info": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.6.1.tgz", - "integrity": "sha512-Ba4+0M4YvIDUUsprMjhVTU1yN9F2/LJSAl69ZpzaLT4l4j5mwTS6jqqW9Ojvj6lKz/veqPzpJBqGbXspOb533A==" + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.7.1.tgz", + "integrity": "sha512-7T/BxH19zbcCTa8XkMlbK5lTo1WtgkFi3GvdWEyNuc4Vex7/9Dqbnpsf4JMydcfj9HCg4zUWFTL3Za6lapg5/w==" }, "html-encoding-sniffer": { "version": "1.0.2", @@ -4076,11 +4247,11 @@ "integrity": "sha1-MKCy2jj3N3DoKUoNIuZiXtd9AJc=" }, "loose-envify": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.3.1.tgz", - "integrity": "sha1-0aitM/qc4OcT1l/dCsi3SNR4yEg=", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", + "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", "requires": { - "js-tokens": "^3.0.0" + "js-tokens": "^3.0.0 || ^4.0.0" } }, "lru-cache": { @@ -4866,9 +5037,9 @@ } }, "recast": { - "version": "0.15.1", - "resolved": "https://registry.npmjs.org/recast/-/recast-0.15.1.tgz", - "integrity": "sha512-Q2TQyDveVn1ZGyFJlb6nPyu/ojkX+xtFSMSucO2L+yWVulqXhRtA6KyvJy860APaWBsKrTz2BMnGtYu6++35ow==", + "version": "0.15.2", + "resolved": "https://registry.npmjs.org/recast/-/recast-0.15.2.tgz", + "integrity": "sha512-L4f/GqxjlEJ5IZ+tdll/l+6dVi2ylysWbkgFJbMuldD6Jklgfv6zJnCpuAZDfjwHhfcd/De0dDKelsTEPQ29qA==", "requires": { "ast-types": "0.11.5", "esprima": "~4.0.0", @@ -6164,6 +6335,11 @@ "prelude-ls": "~1.1.2" } }, + "typescript": { + "version": "2.9.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.9.2.tgz", + "integrity": "sha512-Gr4p6nFNaoufRIY4NMdpQRNmgxVIGMs4Fcu/ujdYk3nAZqk7supzBE9idmvfZIlH/Cuj//dvi+019qEue9lV0w==" + }, "uglify-js": { "version": "2.8.29", "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.8.29.tgz", diff --git a/packages/migrate/package.json b/packages/migrate/package.json index 78f596f1262..eb1aefe2e5d 100644 --- a/packages/migrate/package.json +++ b/packages/migrate/package.json @@ -3,16 +3,22 @@ "version": "0.0.8", "description": "Migrate command for webpack-cli", "main": "index.js", - "scripts": { - "test": "jest" - }, "author": "", "license": "MIT", "publishConfig": { "access": "public" }, "devDependencies": { - "jest": "^22.4.3" + "@types/chalk": "^2.2.0", + "@types/diff": "^3.5.1", + "@types/inquirer": "0.0.41", + "@types/listr": "^0.13.0", + "@types/lodash": "^4.14.109", + "@types/node": "^10.3.3", + "@types/p-each-series": "^1.0.0", + "@types/p-lazy": "^1.0.0", + "jest": "^22.4.3", + "typescript": "^2.9.2" }, "peerDependencies": { "webpack": "^4.x.x" @@ -27,5 +33,10 @@ "lodash": "^4.17.10", "p-each-series": "^1.0.0", "p-lazy": "^1.0.0" + }, + "scripts": { + "test": "jest", + "build": "tsc", + "watch": "tsc -w" } } diff --git a/packages/migrate/removeDeprecatedPlugins/removeDeprecatedPlugins.js b/packages/migrate/removeDeprecatedPlugins/removeDeprecatedPlugins.ts similarity index 67% rename from packages/migrate/removeDeprecatedPlugins/removeDeprecatedPlugins.js rename to packages/migrate/removeDeprecatedPlugins/removeDeprecatedPlugins.ts index 4945b1841d5..aecc0640353 100644 --- a/packages/migrate/removeDeprecatedPlugins/removeDeprecatedPlugins.js +++ b/packages/migrate/removeDeprecatedPlugins/removeDeprecatedPlugins.ts @@ -1,5 +1,8 @@ -const chalk = require("chalk"); -const utils = require("@webpack-cli/utils/ast-utils"); +import chalk from "chalk"; + +import * as utils from "@webpack-cli/utils/ast-utils"; + +import { IJSCodeshift, INode } from "../types/NodePath"; /** * @@ -11,23 +14,25 @@ const utils = require("@webpack-cli/utils/ast-utils"); * @returns {Node} ast - jscodeshift ast */ -module.exports = function(j, ast, source) { +export default function(j: IJSCodeshift, ast: INode) { + // List of deprecated plugins to remove // each item refers to webpack.optimize.[NAME] construct - const deprecatedPlugingsList = [ + const deprecatedPlugingsList: string[] = [ "webpack.optimize.OccurrenceOrderPlugin", - "webpack.optimize.DedupePlugin" + "webpack.optimize.DedupePlugin", ]; return utils .findPluginsByName(j, ast, deprecatedPlugingsList) - .forEach(path => { + .forEach((path: INode): void => { // For now we only support the case where plugins are defined in an Array - const arrayPath = utils.safeTraverse(path, ["parent", "value"]); + const arrayPath: INode = utils.safeTraverse(path, ["parent", "value"]); + if (arrayPath && utils.isType(arrayPath, "ArrayExpression")) { // Check how many plugins are defined and // if there is only last plugin left remove `plugins: []` node - const arrayElementsPath = utils.safeTraverse(arrayPath, ["elements"]); + const arrayElementsPath: INode[] = utils.safeTraverse(arrayPath, ["elements"]); if (arrayElementsPath && arrayElementsPath.length === 1) { j(path.parent.parent).remove(); } else { @@ -37,8 +42,8 @@ module.exports = function(j, ast, source) { console.log(` ${chalk.red("Please remove deprecated plugins manually. ")} See ${chalk.underline( - "https://webpack.js.org/guides/migrating/" + "https://webpack.js.org/guides/migrating/", )} for more information.`); } }); -}; +} diff --git a/packages/migrate/removeJsonLoader/removeJsonLoader.js b/packages/migrate/removeJsonLoader/removeJsonLoader.ts similarity index 61% rename from packages/migrate/removeJsonLoader/removeJsonLoader.js rename to packages/migrate/removeJsonLoader/removeJsonLoader.ts index 42bdb805db4..88d7a4fae5f 100644 --- a/packages/migrate/removeJsonLoader/removeJsonLoader.js +++ b/packages/migrate/removeJsonLoader/removeJsonLoader.ts @@ -1,4 +1,6 @@ -const utils = require("@webpack-cli/utils/ast-utils"); +import * as utils from "@webpack-cli/utils/ast-utils"; + +import { IJSCodeshift, INode } from "../types/NodePath"; /** * @@ -9,24 +11,26 @@ const utils = require("@webpack-cli/utils/ast-utils"); * @returns {Node} ast - jscodeshift ast */ -module.exports = function(j, ast) { +export default function(j: IJSCodeshift, ast: INode): INode { /** * * Remove the loader with name `name` from the given NodePath * * @param {Node} path - ast to remove the loader from * @param {String} name - the name of the loader to remove - * + * @returns {void} */ - function removeLoaderByName(path, name) { - const loadersNode = path.value.value; + function removeLoaderByName(path: INode, name: string): void { + const loadersNode: INode = path.value.value; + switch (loadersNode.type) { case j.ArrayExpression.name: { - let loaders = loadersNode.elements.map(p => { + const loaders: string[] = loadersNode.elements.map((p: INode): string => { return utils.safeTraverse(p, ["properties", "0", "value", "value"]); }); - const loaderIndex = loaders.indexOf(name); + + const loaderIndex: number = loaders.indexOf(name); if (loaders.length && loaderIndex > -1) { // Remove loader from the array loaders.splice(loaderIndex, 1); @@ -51,19 +55,19 @@ module.exports = function(j, ast) { } } - function removeLoaders(ast) { - ast + function removeLoaders(astNode: INode) { + astNode .find(j.Property, { key: { name: "use" } }) - .forEach(path => removeLoaderByName(path, "json-loader")); + .forEach((path: INode): void => removeLoaderByName(path, "json-loader")); - ast + astNode .find(j.Property, { key: { name: "loader" } }) - .forEach(path => removeLoaderByName(path, "json-loader")); + .forEach((path: INode): void => removeLoaderByName(path, "json-loader")); } - const transforms = [removeLoaders]; + const transforms: Array<(astNode: INode) => void> = [removeLoaders]; - transforms.forEach(t => t(ast)); + transforms.forEach((t: (astNode: INode) => void): void => t(ast)); return ast; -}; +} diff --git a/packages/migrate/resolve/resolve.js b/packages/migrate/resolve/resolve.ts similarity index 53% rename from packages/migrate/resolve/resolve.js rename to packages/migrate/resolve/resolve.ts index f0cb3b4b9df..9d0f8328364 100644 --- a/packages/migrate/resolve/resolve.js +++ b/packages/migrate/resolve/resolve.ts @@ -1,3 +1,5 @@ +import { IJSCodeshift, INode } from "../types/NodePath"; + /** * * Transform which consolidates the `resolve.root` configuration option into the `resolve.modules` array @@ -7,21 +9,23 @@ * @returns {Node} ast - jscodeshift ast */ -module.exports = function transformer(j, ast) { - const getRootVal = p => { - return p.node.value.properties.filter(prop => prop.key.name === "root")[0]; +export default function transformer(j: IJSCodeshift, ast: INode): INode[] | void { + + const getRootVal = (p: INode): INode => { + return p.node.value.properties.filter((prop: INode): boolean => prop.key.name === "root")[0]; }; - const getRootIndex = p => { - return p.node.value.properties.reduce((rootIndex, prop, index) => { + const getRootIndex = (p: INode): number => { + return p.node.value.properties.reduce((rootIndex: number, prop: INode, index: number): number => { return prop.key.name === "root" ? index : rootIndex; }, -1); }; - const isModulePresent = p => { - const modules = p.node.value.properties.filter( - prop => prop.key.name === "modules" + const isModulePresent = (p: INode): INode | false => { + const modules: INode[] = p.node.value.properties.filter( + (prop: INode): boolean => prop.key.name === "modules", ); + return modules.length > 0 && modules[0]; }; @@ -31,42 +35,49 @@ module.exports = function transformer(j, ast) { * based on what is already in `resolve.root` * * @param {Node} p - ast node that represents the `resolve` property - * @returns {Node} p - ast node that represents the updated `resolve` property + * @returns {Node} ast - ast node */ - const createModuleArray = p => { - const rootVal = getRootVal(p); - let modulesVal = null; + const createModuleArray = (p: INode): INode => { + + const rootVal: INode = getRootVal(p); + + let modulesVal: INode[] = null; + if (rootVal.value.type === "ArrayExpression") { modulesVal = rootVal.value.elements; } else { modulesVal = [rootVal.value]; } - let module = isModulePresent(p); + + let module: INode | false = isModulePresent(p); if (!module) { module = j.property( "init", j.identifier("modules"), - j.arrayExpression(modulesVal) + j.arrayExpression(modulesVal), ); p.node.value.properties = p.node.value.properties.concat([module]); } else { module.value.elements = module.value.elements.concat(modulesVal); } - const rootIndex = getRootIndex(p); + + const rootIndex: number = getRootIndex(p); + p.node.value.properties.splice(rootIndex, 1); + return p; }; return ast .find(j.Property) - .filter(p => { + .filter((p: INode): boolean => { return ( p.node.key.name === "resolve" && - p.node.value.properties.filter(prop => prop.key.name === "root") + p.node.value.properties.filter((prop: INode): boolean => prop.key.name === "root") .length === 1 ); }) .forEach(createModuleArray); -}; +} diff --git a/packages/migrate/tsconfig.json b/packages/migrate/tsconfig.json new file mode 100644 index 00000000000..4082f16a5d9 --- /dev/null +++ b/packages/migrate/tsconfig.json @@ -0,0 +1,3 @@ +{ + "extends": "../../tsconfig.json" +} diff --git a/packages/migrate/types/NodePath.ts b/packages/migrate/types/NodePath.ts new file mode 100644 index 00000000000..d63f5cad350 --- /dev/null +++ b/packages/migrate/types/NodePath.ts @@ -0,0 +1,89 @@ +export interface INode extends Object { + id?: { + name: string; + }; + arguments?: INode[]; + body?: INode[]; + elements?: INode[]; + expression?: { + left: { + computed: boolean, + object: INode, + property: INode, + type: string, + }, + operator: string, + right: INode, + type: string, + }; + filter?: (p: (p: INode) => boolean) => INode; + find?: (objectExpression: object, filterExpression?: object) => INode; + forEach?: (p: (p: INode) => void) => void; + get?: (property: string) => INode; + remove?: (_?: void) => void; + nodes?: (_?: void) => INode[]; + pop?: (_?: void) => INode; + key?: { + name: string; + value: INode | string; + }; + node?: INode; + name?: string; + object?: object; + parent?: INode; + properties?: INode[]; + property?: INode; + prune?: Function; + replaceWith?: (objectExpression: object) => INode; + size?: (_?: void) => number; + type?: string; + value?: INode | string | any; + toSource?: (object: { + quote?: string, + }) => string; + source: string; + ast: INode; + rules?: INode[]; + __paths?: INode[]; +} + +interface IExpressionObject { + name: string; +} + +export interface IJSCodeshift extends Object { + (source?: INode | string): INode; + withParser: (parser: string) => IJSCodeshift; + identifier: (key: string) => INode; + literal: (key: valueType) => INode; + memberExpression: (node1: INode, node2: INode, bool?: boolean) => INode; + objectProperty: (key: INode, property: valueType) => INode; + objectExpression: (properties: INode[]) => INode; + newExpression: (expression: INode, args: INode[]) => INode; + callExpression: (expression: INode, args: INode[]) => INode; + variableDeclarator: (key: INode, args: INode) => INode; + variableDeclaration: (key: string, args: INode[]) => INode; + arrayExpression: (args?: INode[]) => INode; + property: (type: string, key: INode, value: INode) => INode; + program: (nodes: INode[]) => INode; + booleanLiteral: (bool: boolean) => INode; + Property: IExpressionObject; + NewExpression: IExpressionObject; + CallExpression: IExpressionObject; + VariableDeclarator: IExpressionObject; + Identifier: IExpressionObject; + Literal: IExpressionObject; + ArrayExpression: IExpressionObject; + MemberExpression: IExpressionObject; + FunctionExpression: IExpressionObject; + ObjectExpression: IExpressionObject; + BlockStatement: IExpressionObject; + Program: IExpressionObject; + filters: { + VariableDeclarator: { + requiresModule: Function, + }, + }; +} + +export type valueType = string | number | boolean | INode[] | INode | null; diff --git a/packages/migrate/types/index.ts b/packages/migrate/types/index.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/packages/migrate/uglifyJsPlugin/uglifyJsPlugin.js b/packages/migrate/uglifyJsPlugin/uglifyJsPlugin.js deleted file mode 100644 index e1ef9e21874..00000000000 --- a/packages/migrate/uglifyJsPlugin/uglifyJsPlugin.js +++ /dev/null @@ -1,123 +0,0 @@ -const { - findPluginsByName, - safeTraverse, - createProperty, - getRequire, - findPluginsArrayAndRemoveIfEmpty -} = require("@webpack-cli/utils/ast-utils"); - -/** - * - * Transform which: - * - Removes UglifyWebpackPlugin from plugins array, if no options is passed to the plugin. - * and adds `optimization.minimize: true` to config - * - * - If any configuration is passed to UglifyWebpackPlugin - * plugin instantiation is moved to `optimization.minimizer`. - * - * @param {Object} j - jscodeshift top-level import - * @param {Node} ast - jscodeshift ast to transform - * @returns {Node} ast - jscodeshift ast - */ - -module.exports = function(j, ast) { - let pluginVariableAssignment; - - const searchForRequirePlugin = ast - .find(j.VariableDeclarator) - .filter( - j.filters.VariableDeclarator.requiresModule("uglifyjs-webpack-plugin") - ); - - /** - * Look for a variable declaration which requires uglifyjs-webpack-plugin - * saves the name of this variable. - */ - searchForRequirePlugin.forEach(node => { - pluginVariableAssignment = node.value.id.name; - }); - - pluginVariableAssignment = !pluginVariableAssignment - ? "webpack.optimize.UglifyJsPlugin" - : pluginVariableAssignment; - - findPluginsByName(j, ast, [pluginVariableAssignment]).forEach(node => { - let expressionContent; - const configBody = safeTraverse(node, ["parent", "parent", "parent"]); - - // options passed to plugin - const pluginOptions = node.value.arguments; - - /** - * check if there are any options passed to UglifyWebpackPlugin - * If so, they are moved to optimization.minimizer. - * Otherwise, rely on default options - */ - if (pluginOptions.length) { - /* - * If user is using UglifyJsPlugin directly from webpack - * transformation must: - * - remove it - * - add require for uglify-webpack-plugin - * - add to minimizer - */ - if (pluginVariableAssignment.includes("webpack")) { - // create require for uglify-webpack-plugin - const pathRequire = getRequire( - j, - "UglifyJsPlugin", - "uglifyjs-webpack-plugin" - ); - // append to source code. - ast - .find(j.Program) - .replaceWith(p => - j.program([].concat(pathRequire).concat(p.value.body)) - ); - - expressionContent = j.property( - "init", - j.identifier("minimizer"), - j.arrayExpression([ - j.newExpression(j.identifier("UglifyJsPlugin"), [pluginOptions[0]]) - ]) - ); - } else { - expressionContent = j.property( - "init", - j.identifier("minimizer"), - j.arrayExpression([node.value]) - ); - } - } else { - searchForRequirePlugin.forEach(node => j(node).remove()); - } - - const minimizeProperty = createProperty(j, "minimize", "true"); - // creates optimization property at the body of the config. - if (expressionContent) { - configBody.value.properties.push( - j.property( - "init", - j.identifier("optimization"), - j.objectExpression([minimizeProperty, expressionContent]) - ) - ); - } else { - configBody.value.properties.push( - j.property( - "init", - j.identifier("optimization"), - j.objectExpression([minimizeProperty]) - ) - ); - } - - // remove the old Uglify plugin from Plugins array. - j(node).remove(); - }); - - findPluginsArrayAndRemoveIfEmpty(j, ast); - - return ast; -}; diff --git a/packages/migrate/uglifyJsPlugin/uglifyJsPlugin.ts b/packages/migrate/uglifyJsPlugin/uglifyJsPlugin.ts new file mode 100644 index 00000000000..dbf5f8152fa --- /dev/null +++ b/packages/migrate/uglifyJsPlugin/uglifyJsPlugin.ts @@ -0,0 +1,128 @@ +import { + createProperty, + findPluginsArrayAndRemoveIfEmpty, + findPluginsByName, + getRequire, + safeTraverse, +} from "@webpack-cli/utils/ast-utils"; + +import { IJSCodeshift, INode } from "../types/NodePath"; + +/** + * + * Transform which: + * Removes UglifyWebpackPlugin from plugins array, if no options is passed to the plugin. + * and adds `optimization.minimize: true` to config + * + * If any configuration is passed to UglifyWebpackPlugin + * plugin instantiation is moved to `optimization.minimizer`. + * + * @param {Object} j - jscodeshift top-level import + * @param {Node} ast - jscodeshift ast to transform + * @returns {Node} ast - jscodeshift ast + */ + +export default function(j: IJSCodeshift, ast: INode): INode { + + let pluginVariableAssignment: string = null; + + const searchForRequirePlugin: INode = ast + .find(j.VariableDeclarator) + .filter( + j.filters.VariableDeclarator.requiresModule("uglifyjs-webpack-plugin"), + ); + + /** + * Look for a variable declaration which requires uglifyjs-webpack-plugin + * saves the name of this variable. + */ + searchForRequirePlugin.forEach((node: INode): void => { + pluginVariableAssignment = node.value.id.name; + }); + + pluginVariableAssignment = !pluginVariableAssignment + ? "webpack.optimize.UglifyJsPlugin" + : pluginVariableAssignment; + + findPluginsByName(j, ast, [pluginVariableAssignment]) + .forEach((node: INode): void => { + let expressionContent: object = null; + + const configBody: INode = safeTraverse(node, ["parent", "parent", "parent"]); + + // options passed to plugin + const pluginOptions: INode[] = node.value.arguments; + + /** + * check if there are any options passed to UglifyWebpackPlugin + * If so, they are moved to optimization.minimizer. + * Otherwise, rely on default options + */ + if (pluginOptions.length) { + /* + * If user is using UglifyJsPlugin directly from webpack + * transformation must: + * - remove it + * - add require for uglify-webpack-plugin + * - add to minimizer + */ + if (pluginVariableAssignment && pluginVariableAssignment.includes("webpack")) { + // create require for uglify-webpack-plugin + const pathRequire: INode = getRequire( + j, + "UglifyJsPlugin", + "uglifyjs-webpack-plugin", + ); + // append to source code. + ast + .find(j.Program) + .replaceWith((p: INode): INode => + j.program([].concat(pathRequire).concat(p.value.body)), + ); + + expressionContent = j.property( + "init", + j.identifier("minimizer"), + j.arrayExpression([ + j.newExpression(j.identifier("UglifyJsPlugin"), [pluginOptions[0]]), + ]), + ); + } else { + expressionContent = j.property( + "init", + j.identifier("minimizer"), + j.arrayExpression([node.value]), + ); + } + } else { + searchForRequirePlugin.forEach((n: INode): void => j(n).remove()); + } + + const minimizeProperty = createProperty(j, "minimize", "true"); + // creates optimization property at the body of the config. + if (expressionContent) { + configBody.value.properties.push( + j.property( + "init", + j.identifier("optimization"), + j.objectExpression([minimizeProperty, expressionContent]), + ), + ); + } else { + configBody.value.properties.push( + j.property( + "init", + j.identifier("optimization"), + j.objectExpression([minimizeProperty]), + ), + ); + } + + // remove the old Uglify plugin from Plugins array. + j(node).remove(); + }); + + findPluginsArrayAndRemoveIfEmpty(j, ast); + + return ast; +} diff --git a/packages/utils/package-lock.json b/packages/utils/package-lock.json index b663baa780d..e41023ca20f 100644 --- a/packages/utils/package-lock.json +++ b/packages/utils/package-lock.json @@ -3,17 +3,17 @@ "lockfileVersion": 1, "dependencies": { "@babel/code-frame": { - "version": "7.0.0-beta.51", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0-beta.51.tgz", - "integrity": "sha1-vXHZsZKvl435FYKdOdQJRFZDmgw=", + "version": "7.0.0-beta.52", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0-beta.52.tgz", + "integrity": "sha1-GSSDv6DR5GfBAVccIQKcy3SvKAE=", "requires": { - "@babel/highlight": "7.0.0-beta.51" + "@babel/highlight": "7.0.0-beta.52" } }, "@babel/highlight": { - "version": "7.0.0-beta.51", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.0.0-beta.51.tgz", - "integrity": "sha1-6IRK4loVlcz9QriWI7Q3bKBtIl0=", + "version": "7.0.0-beta.52", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.0.0-beta.52.tgz", + "integrity": "sha1-7ySTFDLwYVXnvDnNuKaze0oos9A=", "requires": { "chalk": "^2.0.0", "esutils": "^2.0.2", @@ -2510,9 +2510,9 @@ } }, "flow-parser": { - "version": "0.75.0", - "resolved": "https://registry.npmjs.org/flow-parser/-/flow-parser-0.75.0.tgz", - "integrity": "sha512-QEyV/t9TERBOSI/zSx0zhKH6924135WPI7pMmug2n/n/4puFm4mdAq1QaKPA3IPhXDRtManbySkKhRqws5UUGA==" + "version": "0.76.0", + "resolved": "https://registry.npmjs.org/flow-parser/-/flow-parser-0.76.0.tgz", + "integrity": "sha512-p+K8OKiMlq8AIZH8KTydHEGUUd71AqfCL+zTJNsdHtQmX3i3eaeIysF83Ad6Oo7OQcHCj3vocb/EHYiEyq+ZBg==" }, "for-in": { "version": "1.0.2", @@ -3394,9 +3394,9 @@ } }, "hosted-git-info": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.6.1.tgz", - "integrity": "sha512-Ba4+0M4YvIDUUsprMjhVTU1yN9F2/LJSAl69ZpzaLT4l4j5mwTS6jqqW9Ojvj6lKz/veqPzpJBqGbXspOb533A==" + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.7.1.tgz", + "integrity": "sha512-7T/BxH19zbcCTa8XkMlbK5lTo1WtgkFi3GvdWEyNuc4Vex7/9Dqbnpsf4JMydcfj9HCg4zUWFTL3Za6lapg5/w==" }, "html-encoding-sniffer": { "version": "1.0.2", @@ -4468,11 +4468,11 @@ "integrity": "sha1-MKCy2jj3N3DoKUoNIuZiXtd9AJc=" }, "loose-envify": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.3.1.tgz", - "integrity": "sha1-0aitM/qc4OcT1l/dCsi3SNR4yEg=", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", + "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", "requires": { - "js-tokens": "^3.0.0" + "js-tokens": "^3.0.0 || ^4.0.0" } }, "lowercase-keys": { @@ -5374,9 +5374,9 @@ } }, "recast": { - "version": "0.15.1", - "resolved": "https://registry.npmjs.org/recast/-/recast-0.15.1.tgz", - "integrity": "sha512-Q2TQyDveVn1ZGyFJlb6nPyu/ojkX+xtFSMSucO2L+yWVulqXhRtA6KyvJy860APaWBsKrTz2BMnGtYu6++35ow==", + "version": "0.15.2", + "resolved": "https://registry.npmjs.org/recast/-/recast-0.15.2.tgz", + "integrity": "sha512-L4f/GqxjlEJ5IZ+tdll/l+6dVi2ylysWbkgFJbMuldD6Jklgfv6zJnCpuAZDfjwHhfcd/De0dDKelsTEPQ29qA==", "requires": { "ast-types": "0.11.5", "esprima": "~4.0.0", diff --git a/packages/webpack-scaffold/package-lock.json b/packages/webpack-scaffold/package-lock.json index fcae76121c8..11a42d683c6 100644 --- a/packages/webpack-scaffold/package-lock.json +++ b/packages/webpack-scaffold/package-lock.json @@ -910,9 +910,9 @@ } }, "flow-parser": { - "version": "0.75.0", - "resolved": "https://registry.npmjs.org/flow-parser/-/flow-parser-0.75.0.tgz", - "integrity": "sha512-QEyV/t9TERBOSI/zSx0zhKH6924135WPI7pMmug2n/n/4puFm4mdAq1QaKPA3IPhXDRtManbySkKhRqws5UUGA==" + "version": "0.76.0", + "resolved": "https://registry.npmjs.org/flow-parser/-/flow-parser-0.76.0.tgz", + "integrity": "sha512-p+K8OKiMlq8AIZH8KTydHEGUUd71AqfCL+zTJNsdHtQmX3i3eaeIysF83Ad6Oo7OQcHCj3vocb/EHYiEyq+ZBg==" }, "for-in": { "version": "1.0.2", @@ -1115,11 +1115,11 @@ "integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg==" }, "loose-envify": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.3.1.tgz", - "integrity": "sha1-0aitM/qc4OcT1l/dCsi3SNR4yEg=", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", + "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", "requires": { - "js-tokens": "^3.0.0" + "js-tokens": "^3.0.0 || ^4.0.0" } }, "math-random": { @@ -1295,9 +1295,9 @@ } }, "recast": { - "version": "0.15.1", - "resolved": "https://registry.npmjs.org/recast/-/recast-0.15.1.tgz", - "integrity": "sha512-Q2TQyDveVn1ZGyFJlb6nPyu/ojkX+xtFSMSucO2L+yWVulqXhRtA6KyvJy860APaWBsKrTz2BMnGtYu6++35ow==", + "version": "0.15.2", + "resolved": "https://registry.npmjs.org/recast/-/recast-0.15.2.tgz", + "integrity": "sha512-L4f/GqxjlEJ5IZ+tdll/l+6dVi2ylysWbkgFJbMuldD6Jklgfv6zJnCpuAZDfjwHhfcd/De0dDKelsTEPQ29qA==", "requires": { "ast-types": "0.11.5", "esprima": "~4.0.0",