diff --git a/docs/AddGenerator.html b/docs/AddGenerator.html index c6103a80331..c58570f84f7 100644 --- a/docs/AddGenerator.html +++ b/docs/AddGenerator.html @@ -186,13 +186,13 @@

Extends


diff --git a/docs/InitGenerator.html b/docs/InitGenerator.html index 74314ee2746..a8ee7127249 100644 --- a/docs/InitGenerator.html +++ b/docs/InitGenerator.html @@ -186,13 +186,13 @@

Extends


diff --git a/docs/LoaderGenerator.html b/docs/LoaderGenerator.html index 4c74fb9ab0a..4a075e52b67 100644 --- a/docs/LoaderGenerator.html +++ b/docs/LoaderGenerator.html @@ -166,13 +166,13 @@

Extends


diff --git a/docs/PluginGenerator.html b/docs/PluginGenerator.html index 1678e1dec30..1ecf1ba6206 100644 --- a/docs/PluginGenerator.html +++ b/docs/PluginGenerator.html @@ -166,13 +166,13 @@

Extends


diff --git a/docs/commands_add.js.html b/docs/commands_add.js.html index 3aed027acc3..17204927106 100644 --- a/docs/commands_add.js.html +++ b/docs/commands_add.js.html @@ -52,13 +52,13 @@

Source: commands/add.js


diff --git a/docs/commands_init.js.html b/docs/commands_init.js.html index 3b9e17da253..01c45585644 100644 --- a/docs/commands_init.js.html +++ b/docs/commands_init.js.html @@ -58,13 +58,13 @@

Source: commands/init.js


diff --git a/docs/commands_make.js.html b/docs/commands_make.js.html index 95907e4deef..d7d26082b55 100644 --- a/docs/commands_make.js.html +++ b/docs/commands_make.js.html @@ -48,13 +48,13 @@

Source: commands/make.js


diff --git a/docs/commands_migrate.js.html b/docs/commands_migrate.js.html index 375cde12482..1744aa068a4 100644 --- a/docs/commands_migrate.js.html +++ b/docs/commands_migrate.js.html @@ -188,13 +188,13 @@

Source: commands/migrate.js


diff --git a/docs/commands_remove.js.html b/docs/commands_remove.js.html index c50f814d258..bf4d453c90e 100644 --- a/docs/commands_remove.js.html +++ b/docs/commands_remove.js.html @@ -52,13 +52,13 @@

Source: commands/remove.js


diff --git a/docs/commands_serve.js.html b/docs/commands_serve.js.html index 8f5a3ae24a1..b7046395c17 100644 --- a/docs/commands_serve.js.html +++ b/docs/commands_serve.js.html @@ -99,7 +99,9 @@

Source: commands/serve.js

: []; if (hasDevServerDep.length) { - let WDSPath = getRootPathModule("node_modules/webpack-dev-server/bin/webpack-dev-server.js"); + let WDSPath = getRootPathModule( + "node_modules/webpack-dev-server/bin/webpack-dev-server.js" + ); if (!WDSPath) { console.log( "\n", @@ -207,13 +209,13 @@

Source: commands/serve.js


diff --git a/docs/commands_update.js.html b/docs/commands_update.js.html index 04250c1253a..b9feea298c6 100644 --- a/docs/commands_update.js.html +++ b/docs/commands_update.js.html @@ -52,13 +52,13 @@

Source: commands/update.js


diff --git a/docs/generate-loader_index.js.html b/docs/generate-loader_index.js.html index 7d03aa0c650..36260277e31 100644 --- a/docs/generate-loader_index.js.html +++ b/docs/generate-loader_index.js.html @@ -26,16 +26,16 @@

Source: generate-loader/index.js

-
var yeoman = require("yeoman-environment");
-var LoaderGenerator = require("../generators/loader-generator").LoaderGenerator;
+            
const yeoman = require("yeoman-environment");
+const { LoaderGenerator } = require("../generators/loader-generator");
 
 /**
  * Runs a yeoman generator to create a new webpack loader project
  * @returns {void}
  */
 function loaderCreator() {
-	var env = yeoman.createEnv();
-	var generatorName = "webpack-loader-generator";
+	const env = yeoman.createEnv();
+	const generatorName = "webpack-loader-generator";
 
 	env.registerStub(LoaderGenerator, generatorName);
 
@@ -53,13 +53,13 @@ 

Source: generate-loader/index.js


- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:39 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)
diff --git a/docs/generate-plugin_index.js.html b/docs/generate-plugin_index.js.html index f44c28d1034..f0931498929 100644 --- a/docs/generate-plugin_index.js.html +++ b/docs/generate-plugin_index.js.html @@ -26,16 +26,16 @@

Source: generate-plugin/index.js

-
var yeoman = require("yeoman-environment");
-var PluginGenerator = require("../generators/plugin-generator").PluginGenerator;
+            
const yeoman = require("yeoman-environment");
+const PluginGenerator = require("../generators/plugin-generator").PluginGenerator;
 
 /**
  * Runs a yeoman generator to create a new webpack plugin project
  * @returns {void}
  */
 function pluginCreator() {
-	var env = yeoman.createEnv();
-	var generatorName = "webpack-plugin-generator";
+	const env = yeoman.createEnv();
+	const generatorName = "webpack-plugin-generator";
 
 	env.registerStub(PluginGenerator, generatorName);
 
@@ -53,13 +53,13 @@ 

Source: generate-plugin/index.js


- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:40 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)
diff --git a/docs/generators_add-generator.js.html b/docs/generators_add-generator.js.html index 3c3a631ddce..8dff982bd73 100644 --- a/docs/generators_add-generator.js.html +++ b/docs/generators_add-generator.js.html @@ -26,7 +26,7 @@

Source: generators/add-generator.js

-
const Generator = require("webpack-fork-yeoman-generator");
+            
const Generator = require("yeoman-generator");
 const glob = require("glob-all");
 const path = require("path");
 const Confirm = require("webpack-addons").Confirm;
@@ -152,7 +152,7 @@ 

Source: generators/add-generator.js

: webpackSchema.properties[action].anyOf ? webpackSchema.properties[action].anyOf.filter( p => p.properties || p.enum - ) + ) // eslint-disable-line : null; if (Array.isArray(defOrPropDescription)) { // Todo: Generalize these to go through the array, then merge enum with props if needed @@ -433,7 +433,7 @@

Source: generators/add-generator.js

let othersDeepPropKey = deepPropAns.deepProp ? `what do you want the value of ${ deepPropAns.deepProp - } to be?` + } to be?` // eslint-disable-line : `what do you want to be the value of ${action} to be?`; // Push the answer to the array we have created, so we can use it later isDeepProp.push(deepPropAns.deepProp); @@ -486,13 +486,13 @@

Source: generators/add-generator.js


- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:39 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)
diff --git a/docs/generators_init-generator.js.html b/docs/generators_init-generator.js.html index d64d53ea408..e8130fae45c 100644 --- a/docs/generators_init-generator.js.html +++ b/docs/generators_init-generator.js.html @@ -28,7 +28,7 @@

Source: generators/init-generator.js

"use strict";
 
-const Generator = require("webpack-fork-yeoman-generator");
+const Generator = require("yeoman-generator");
 const chalk = require("chalk");
 const logSymbols = require("log-symbols");
 
@@ -368,7 +368,8 @@ 

Source: generators/init-generator.js

if (regExpForStyles) { if (this.isProd) { this.configuration.config.topScope.push(tooltip.cssPlugin()); - this.dependencies.push("extract-text-webpack-plugin"); + // TODO: Replace with regular version once v.4 is out + this.dependencies.push("extract-text-webpack-plugin@next"); if (cssBundleName.length !== 0) { this.configuration.config.webpackOptions.plugins.push( @@ -438,6 +439,9 @@

Source: generators/init-generator.js

}); }); } + writing() { + this.config.set("configuration", this.configuration); + } };
@@ -449,13 +453,13 @@

Source: generators/init-generator.js


- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:39 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)
diff --git a/docs/generators_loader-generator.js.html b/docs/generators_loader-generator.js.html index 4e03d51b74b..099e5edc2a0 100644 --- a/docs/generators_loader-generator.js.html +++ b/docs/generators_loader-generator.js.html @@ -26,9 +26,9 @@

Source: generators/loader-generator.js

-
var path = require("path");
-var _ = require("lodash");
-var webpackGenerator = require("./webpack-generator");
+            
const path = require("path");
+const _ = require("lodash");
+const webpackGenerator = require("./webpack-generator");
 
 /**
  * Formats a string into webpack loader format
@@ -53,7 +53,7 @@ 

Source: generators/loader-generator.js

* @class LoaderGenerator * @extends {Generator} */ -var LoaderGenerator = webpackGenerator( +const LoaderGenerator = webpackGenerator( [ { type: "input", @@ -94,13 +94,13 @@

Source: generators/loader-generator.js


- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:39 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)
diff --git a/docs/generators_plugin-generator.js.html b/docs/generators_plugin-generator.js.html index a65841732da..bd1a1850e55 100644 --- a/docs/generators_plugin-generator.js.html +++ b/docs/generators_plugin-generator.js.html @@ -26,9 +26,9 @@

Source: generators/plugin-generator.js

-
var path = require("path");
-var _ = require("lodash");
-var webpackGenerator = require("./webpack-generator");
+            
const path = require("path");
+const _ = require("lodash");
+const webpackGenerator = require("./webpack-generator");
 
 /**
  * A yeoman generator class for creating a webpack
@@ -38,7 +38,7 @@ 

Source: generators/plugin-generator.js

* @class PluginGenerator * @extends {Generator} */ -var PluginGenerator = webpackGenerator( +const PluginGenerator = webpackGenerator( [ { type: "input", @@ -75,13 +75,13 @@

Source: generators/plugin-generator.js


- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:40 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)
diff --git a/docs/generators_utils_entry.js.html b/docs/generators_utils_entry.js.html index db6c7680cde..458948ba468 100644 --- a/docs/generators_utils_entry.js.html +++ b/docs/generators_utils_entry.js.html @@ -126,13 +126,13 @@

Source: generators/utils/entry.js


- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:40 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)
diff --git a/docs/generators_utils_module.js.html b/docs/generators_utils_module.js.html index 26858d897af..54989ff74ae 100644 --- a/docs/generators_utils_module.js.html +++ b/docs/generators_utils_module.js.html @@ -55,13 +55,13 @@

Source: generators/utils/module.js


- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:40 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)
diff --git a/docs/generators_utils_plugins.js.html b/docs/generators_utils_plugins.js.html index 9e063a006c8..efb1a20f5e0 100644 --- a/docs/generators_utils_plugins.js.html +++ b/docs/generators_utils_plugins.js.html @@ -50,13 +50,13 @@

Source: generators/utils/plugins.js


- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:40 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)
diff --git a/docs/generators_utils_tooltip.js.html b/docs/generators_utils_tooltip.js.html index a4f9b0ea5bb..a4266c0a751 100644 --- a/docs/generators_utils_tooltip.js.html +++ b/docs/generators_utils_tooltip.js.html @@ -92,13 +92,13 @@

Source: generators/utils/tooltip.js


- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:40 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)
diff --git a/docs/generators_utils_validate.js.html b/docs/generators_utils_validate.js.html index 9b3923b9bcc..8efa14b8e10 100644 --- a/docs/generators_utils_validate.js.html +++ b/docs/generators_utils_validate.js.html @@ -53,13 +53,13 @@

Source: generators/utils/validate.js


- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:40 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)
diff --git a/docs/generators_webpack-generator.js.html b/docs/generators_webpack-generator.js.html index 9e0e08d663b..ce675c64161 100644 --- a/docs/generators_webpack-generator.js.html +++ b/docs/generators_webpack-generator.js.html @@ -26,10 +26,10 @@

Source: generators/webpack-generator.js

-
var path = require("path");
-var mkdirp = require("mkdirp");
-var Generator = require("webpack-fork-yeoman-generator");
-var copyUtils = require("../utils/copy-utils");
+            
const path = require("path");
+const mkdirp = require("mkdirp");
+const Generator = require("yeoman-generator");
+const copyUtils = require("../utils/copy-utils");
 
 /**
  * Creates a Yeoman Generator that generates a project conforming
@@ -68,14 +68,14 @@ 

Source: generators/webpack-generator.js

} default() { - var currentDirName = path.basename(this.destinationPath()); + const currentDirName = path.basename(this.destinationPath()); if (currentDirName !== this.props.name) { this.log(` Your project must be inside a folder named ${this.props.name} I will create this folder for you. `); mkdirp(this.props.name); - var pathToProjectDir = this.destinationPath(this.props.name); + const pathToProjectDir = this.destinationPath(this.props.name); this.destinationRoot(pathToProjectDir); } } @@ -113,13 +113,13 @@

Source: generators/webpack-generator.js


- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:40 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)
diff --git a/docs/global.html b/docs/global.html index f7a7e8a3d8c..3ad1f702791 100644 --- a/docs/global.html +++ b/docs/global.html @@ -94,72 +94,6 @@

-

Members

- - - -

(constant) transformsObject

- - - - -
- Runs the transformations from an object we get from yeoman -
- - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - -

Methods

@@ -2180,165 +2114,6 @@
Returns:
-

creator(options) → {function}

- - - - - - -
- Runs yeoman and runs the transformations based on the object -built up from an author/user -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
options - - -String - - - - An path to the given generator
- - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - -
- runTransform - Run transformations based on the finished -yeoman instance -
- - - -
-
- Type -
-
- -function - - -
-
- - - - - - - - - - - - -

defineTest(dirName, transformName, testFilePrefixopt, transformObject, action) → {Void}

@@ -3424,7 +3199,7 @@
Returns:
- variable name - ex. 'var s = require(s) gives "s"` + variable name - ex. 'const s = require(s) gives "s"`
@@ -3893,7 +3668,7 @@

getP
Source:
@@ -3949,6 +3724,116 @@

Returns:
+

getPathToGlobalPackages() → {String}

+ + + + + + +
+ Returns the path to globally installed +npm packages, depending on the available +package manager determined by `getPackageManager` +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ path - Path to global node_modules folder +
+ + + +
+
+ Type +
+
+ +String + + +
+
+ + + + + + + + + + + + +

getRequire(j, constName, packagePath) → {Node}

@@ -5206,6 +5091,187 @@
Returns:
+

mapOptionsToTransform(transformObject, config) → {Object}

+ + + + + + +
+ Maps back transforms that needs to be run using the configuration +provided. +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
transformObject + + +Object + + + + An Object with all transformations
config + + +Object + + + + Configuration to transform
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ - An Object with the transformations to be run +
+ + + +
+
+ Type +
+
+ +Object + + +
+
+ + + + + + + + + + + + +

pluginCreator() → {void}

@@ -5411,7 +5477,7 @@
Parameters:
Source:
@@ -6224,7 +6290,7 @@
Parameters:
Source:
@@ -8260,13 +8326,13 @@
Returns:

- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:40 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)
diff --git a/docs/index.html b/docs/index.html index 64d5e2b5a26..d75ab160b3d 100644 --- a/docs/index.html +++ b/docs/index.html @@ -50,13 +50,13 @@


- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:40 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)
diff --git a/docs/index.js.html b/docs/index.js.html index a0556dbf5c5..9cf7405a255 100644 --- a/docs/index.js.html +++ b/docs/index.js.html @@ -96,13 +96,13 @@

Source: index.js


- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:40 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)
diff --git a/docs/init_index.js.html b/docs/init_index.js.html index 90111bf8301..2243108555a 100644 --- a/docs/init_index.js.html +++ b/docs/init_index.js.html @@ -28,68 +28,176 @@

Source: init/index.js

"use strict";
 
-const yeoman = require("yeoman-environment");
-const Generator = require("webpack-fork-yeoman-generator");
 const path = require("path");
-const defaultGenerator = require("../generators/init-generator");
-const runTransform = require("./transformations/index");
+const j = require("jscodeshift");
+const chalk = require("chalk");
+const pEachSeries = require("p-each-series");
+
+const runPrettier = require("../utils/run-prettier");
+
+const entryTransform = require("./transformations/entry/entry");
+const outputTransform = require("./transformations/output/output");
+const contextTransform = require("./transformations/context/context");
+const resolveTransform = require("./transformations/resolve/resolve");
+const devtoolTransform = require("./transformations/devtool/devtool");
+const targetTransform = require("./transformations/target/target");
+const watchTransform = require("./transformations/watch/watch");
+const watchOptionsTransform = require("./transformations/watch/watchOptions");
+const externalsTransform = require("./transformations/externals/externals");
+const nodeTransform = require("./transformations/node/node");
+const performanceTransform = require("./transformations/performance/performance");
+const statsTransform = require("./transformations/stats/stats");
+const amdTransform = require("./transformations/other/amd");
+const bailTransform = require("./transformations/other/bail");
+const cacheTransform = require("./transformations/other/cache");
+const profileTransform = require("./transformations/other/profile");
+const mergeTransform = require("./transformations/other/merge");
+const parallelismTransform = require("./transformations/other/parallelism");
+const recordsInputPathTransform = require("./transformations/other/recordsInputPath");
+const recordsOutputPathTransform = require("./transformations/other/recordsOutputPath");
+const recordsPathTransform = require("./transformations/other/recordsPath");
+const moduleTransform = require("./transformations/module/module");
+const pluginsTransform = require("./transformations/plugins/plugins");
+const topScopeTransform = require("./transformations/top-scope/top-scope");
+const devServerTransform = require("./transformations/devServer/devServer");
+const modeTransform = require("./transformations/mode/mode");
+const resolveLoaderTransform = require("./transformations/resolveLoader/resolveLoader");
+
+const transformsObject = {
+	entryTransform,
+	outputTransform,
+	contextTransform,
+	resolveTransform,
+	devtoolTransform,
+	targetTransform,
+	watchTransform,
+	watchOptionsTransform,
+	externalsTransform,
+	nodeTransform,
+	performanceTransform,
+	statsTransform,
+	amdTransform,
+	bailTransform,
+	cacheTransform,
+	profileTransform,
+	moduleTransform,
+	pluginsTransform,
+	topScopeTransform,
+	mergeTransform,
+	devServerTransform,
+	modeTransform,
+	parallelismTransform,
+	recordsInputPathTransform,
+	recordsOutputPathTransform,
+	recordsPathTransform,
+	resolveLoaderTransform
+};
 
 /**
  *
- * Runs yeoman and runs the transformations based on the object
- * built up from an author/user
+ * Maps back transforms that needs to be run using the configuration
+ * provided.
  *
- * @param {String} options - An path to the given generator
- * @returns {Function} runTransform - Run transformations based on the finished
- * yeoman instance
+ * @param {Object} transformObject - An Object with all transformations
+ * @param {Object} config - Configuration to transform
+ * @returns {Object} - An Object with the transformations to be run
  */
 
-function creator(options) {
-	let env = yeoman.createEnv("webpack", null);
-	const generatorName = options
-		? replaceGeneratorName(path.basename(options[0]))
-		: "webpack-default-generator";
-	if (options) {
-		const WebpackGenerator = class extends Generator {
-			initializing() {
-				options.forEach(path => {
-					return this.composeWith(require.resolve(path));
-				});
+function mapOptionsToTransform(transformObject, config) {
+	return Object.keys(transformObject)
+		.map(transformKey => {
+			const stringVal = transformKey.substr(
+				0,
+				transformKey.indexOf("Transform")
+			);
+			if (Object.keys(config.webpackOptions).length) {
+				if (config.webpackOptions[stringVal]) {
+					return [
+						transformObject[transformKey],
+						config.webpackOptions[stringVal]
+					];
+				} else {
+					return [transformObject[transformKey], config[stringVal]];
+				}
+			} else {
+				return [transformObject[transformKey]];
 			}
-		};
-		env.registerStub(WebpackGenerator, generatorName);
-	} else {
-		env.registerStub(defaultGenerator, "webpack-default-generator");
-	}
-
-	env.run(generatorName).on("end", _ => {
-		if (generatorName !== "webpack-default-generator") {
-			//HACK / FIXME
-			env = env.options.env;
-			return runTransform(env.configuration);
-		} else {
-			return runTransform(env.getArgument("configuration"));
-		}
-	});
+		})
+		.filter(e => e[1]);
 }
 
-/*
-* @function replaceGeneratorName
-*
-* Replaces the webpack-addons pattern with the end of the addons name merged
-* with 'generator'
-*
-* @param { String } name - name of the generator
-* @returns { String } name - replaced pattern of the name
-*/
-
-function replaceGeneratorName(name) {
-	return name.replace(/(webpack-addons)?([^:]+)(:.*)?/g, "generator$2");
-}
+/**
+ *
+ * Runs the transformations from an object we get from yeoman
+ *
+ * @param {Object} webpackProperties - Configuration to transform
+ * @param {String} action - Action to be done on the given ast
+ * @returns {Promise} - A promise that writes each transform, runs prettier
+ * and writes the file
+ */
 
-module.exports = {
-	creator,
-	replaceGeneratorName
+module.exports = function runTransform(webpackProperties, action) {
+	// webpackOptions.name sent to nameTransform if match
+	const webpackConfig = Object.keys(webpackProperties).filter(p => {
+		return p !== "configFile" && p !== "configPath";
+	});
+	const initActionNotDefined = action && action !== "init" ? true : false;
+
+	webpackConfig.forEach(scaffoldPiece => {
+		const config = webpackProperties[scaffoldPiece];
+		const transformations = mapOptionsToTransform(transformsObject, config);
+		const ast = j(
+			initActionNotDefined
+				? webpackProperties.configFile
+				: "module.exports = {}"
+		);
+		const transformAction = action || null;
+
+		return pEachSeries(transformations, f => {
+			if (!f[1]) {
+				return f[0](j, ast, transformAction);
+			} else {
+				return f[0](j, ast, f[1], transformAction);
+			}
+		})
+			.then(_ => {
+				let configurationName;
+				if (!config.configName) {
+					configurationName = "webpack.config.js";
+				} else {
+					configurationName = "webpack." + config.configName + ".js";
+				}
+
+				const outputPath = initActionNotDefined
+					? webpackProperties.configPath
+					: path.join(process.cwd(), configurationName);
+				const source = ast.toSource({
+					quote: "single"
+				});
+
+				runPrettier(outputPath, source);
+			})
+			.catch(err => {
+				console.error(err.message ? err.message : err);
+			});
+	});
+	if (initActionNotDefined && webpackProperties.config.item) {
+		process.stdout.write(
+			"\n" +
+				chalk.green(
+					`Congratulations! ${
+						webpackProperties.config.item
+					} has been ${action}ed!\n`
+				)
+		);
+	} else {
+		process.stdout.write(
+			"\n" +
+				chalk.green(
+					"Congratulations! Your new webpack configuration file has been created!\n"
+				)
+		);
+	}
 };
 
@@ -101,13 +209,13 @@

Source: init/index.js


- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:39 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)
diff --git a/docs/init_transformations_context_context.js.html b/docs/init_transformations_context_context.js.html index 9bd76af1df0..99ad4711a39 100644 --- a/docs/init_transformations_context_context.js.html +++ b/docs/init_transformations_context_context.js.html @@ -91,13 +91,13 @@

Source: init/transformations/context/context.js


- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:40 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)
diff --git a/docs/init_transformations_devServer_devServer.js.html b/docs/init_transformations_devServer_devServer.js.html index 5db1f9cf070..b1cc40cd6c2 100644 --- a/docs/init_transformations_devServer_devServer.js.html +++ b/docs/init_transformations_devServer_devServer.js.html @@ -125,13 +125,13 @@

Source: init/transformations/devServer/devServer.js


- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:40 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)
diff --git a/docs/init_transformations_devtool_devtool.js.html b/docs/init_transformations_devtool_devtool.js.html index 3383ac76faa..96d5066bad2 100644 --- a/docs/init_transformations_devtool_devtool.js.html +++ b/docs/init_transformations_devtool_devtool.js.html @@ -90,13 +90,13 @@

Source: init/transformations/devtool/devtool.js


- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:40 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)
diff --git a/docs/init_transformations_entry_entry.js.html b/docs/init_transformations_entry_entry.js.html index 4065fcde5f6..0bd9df9631e 100644 --- a/docs/init_transformations_entry_entry.js.html +++ b/docs/init_transformations_entry_entry.js.html @@ -121,13 +121,13 @@

Source: init/transformations/entry/entry.js


- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:39 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)
diff --git a/docs/init_transformations_externals_externals.js.html b/docs/init_transformations_externals_externals.js.html index 528e2d63e2c..b2354ff9f9b 100644 --- a/docs/init_transformations_externals_externals.js.html +++ b/docs/init_transformations_externals_externals.js.html @@ -145,13 +145,13 @@

Source: init/transformations/externals/externals.js


- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:39 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)
diff --git a/docs/init_transformations_mode_mode.js.html b/docs/init_transformations_mode_mode.js.html index f76f27d16a1..bd479212bb3 100644 --- a/docs/init_transformations_mode_mode.js.html +++ b/docs/init_transformations_mode_mode.js.html @@ -91,13 +91,13 @@

Source: init/transformations/mode/mode.js


- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:39 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)
diff --git a/docs/init_transformations_module_module.js.html b/docs/init_transformations_module_module.js.html index 9a21d984caa..ae68114b3df 100644 --- a/docs/init_transformations_module_module.js.html +++ b/docs/init_transformations_module_module.js.html @@ -109,13 +109,13 @@

Source: init/transformations/module/module.js


- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:39 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)
diff --git a/docs/init_transformations_node_node.js.html b/docs/init_transformations_node_node.js.html index 038ae0734f9..99d0f0f745c 100644 --- a/docs/init_transformations_node_node.js.html +++ b/docs/init_transformations_node_node.js.html @@ -80,13 +80,13 @@

Source: init/transformations/node/node.js


- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:39 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)
diff --git a/docs/init_transformations_other_amd.js.html b/docs/init_transformations_other_amd.js.html index b3fe4e1b507..ad838fde118 100644 --- a/docs/init_transformations_other_amd.js.html +++ b/docs/init_transformations_other_amd.js.html @@ -120,13 +120,13 @@

Source: init/transformations/other/amd.js


- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:39 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)
diff --git a/docs/init_transformations_other_bail.js.html b/docs/init_transformations_other_bail.js.html index 42d174dd28b..afc4a95078b 100644 --- a/docs/init_transformations_other_bail.js.html +++ b/docs/init_transformations_other_bail.js.html @@ -91,13 +91,13 @@

Source: init/transformations/other/bail.js


- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:39 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)
diff --git a/docs/init_transformations_other_cache.js.html b/docs/init_transformations_other_cache.js.html index 2b04bf8605c..15a782aa572 100644 --- a/docs/init_transformations_other_cache.js.html +++ b/docs/init_transformations_other_cache.js.html @@ -124,13 +124,13 @@

Source: init/transformations/other/cache.js


- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:39 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)
diff --git a/docs/init_transformations_other_merge.js.html b/docs/init_transformations_other_merge.js.html index ef44f415e3e..d5a2409c3b4 100644 --- a/docs/init_transformations_other_merge.js.html +++ b/docs/init_transformations_other_merge.js.html @@ -83,13 +83,13 @@

Source: init/transformations/other/merge.js


- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:39 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)
diff --git a/docs/init_transformations_other_parallelism.js.html b/docs/init_transformations_other_parallelism.js.html index f2539d5885b..c9d53448c26 100644 --- a/docs/init_transformations_other_parallelism.js.html +++ b/docs/init_transformations_other_parallelism.js.html @@ -96,13 +96,13 @@

Source: init/transformations/other/parallelism.js


- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:39 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)
diff --git a/docs/init_transformations_other_profile.js.html b/docs/init_transformations_other_profile.js.html index 291e9db503e..b1fb30fdb65 100644 --- a/docs/init_transformations_other_profile.js.html +++ b/docs/init_transformations_other_profile.js.html @@ -124,13 +124,13 @@

Source: init/transformations/other/profile.js


- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:39 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)
diff --git a/docs/init_transformations_other_recordsInputPath.js.html b/docs/init_transformations_other_recordsInputPath.js.html index ba40d06a684..d11fada1125 100644 --- a/docs/init_transformations_other_recordsInputPath.js.html +++ b/docs/init_transformations_other_recordsInputPath.js.html @@ -136,13 +136,13 @@

Source: init/transformations/other/recordsInputPath.js
- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:39 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)
diff --git a/docs/init_transformations_other_recordsOutputPath.js.html b/docs/init_transformations_other_recordsOutputPath.js.html index b559c99c627..9f0a69c0d78 100644 --- a/docs/init_transformations_other_recordsOutputPath.js.html +++ b/docs/init_transformations_other_recordsOutputPath.js.html @@ -136,13 +136,13 @@

Source: init/transformations/other/recordsOutputPath.js
- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:39 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)
diff --git a/docs/init_transformations_other_recordsPath.js.html b/docs/init_transformations_other_recordsPath.js.html index 5a03ef09f03..d2d0d9fb980 100644 --- a/docs/init_transformations_other_recordsPath.js.html +++ b/docs/init_transformations_other_recordsPath.js.html @@ -125,13 +125,13 @@

Source: init/transformations/other/recordsPath.js


- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:39 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)
diff --git a/docs/init_transformations_output_output.js.html b/docs/init_transformations_output_output.js.html index 77b273c9864..b0979b48db3 100644 --- a/docs/init_transformations_output_output.js.html +++ b/docs/init_transformations_output_output.js.html @@ -120,13 +120,13 @@

Source: init/transformations/output/output.js


- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:39 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)
diff --git a/docs/init_transformations_performance_performance.js.html b/docs/init_transformations_performance_performance.js.html index 1c4be8478ae..b6a8e2ceb57 100644 --- a/docs/init_transformations_performance_performance.js.html +++ b/docs/init_transformations_performance_performance.js.html @@ -128,13 +128,13 @@

Source: init/transformations/performance/performance.js
- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:39 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)
diff --git a/docs/init_transformations_plugins_plugins.js.html b/docs/init_transformations_plugins_plugins.js.html index f7e603f7359..97dd8dd1b80 100644 --- a/docs/init_transformations_plugins_plugins.js.html +++ b/docs/init_transformations_plugins_plugins.js.html @@ -92,13 +92,13 @@

Source: init/transformations/plugins/plugins.js


- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:39 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)
diff --git a/docs/init_transformations_resolveLoader_resolveLoader.js.html b/docs/init_transformations_resolveLoader_resolveLoader.js.html index ebc3a4e6973..e4e38f0a9ef 100644 --- a/docs/init_transformations_resolveLoader_resolveLoader.js.html +++ b/docs/init_transformations_resolveLoader_resolveLoader.js.html @@ -121,13 +121,13 @@

Source: init/transformations/resolveLoader/resolveLoader.
- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:40 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)
diff --git a/docs/init_transformations_resolve_resolve.js.html b/docs/init_transformations_resolve_resolve.js.html index 8a23b566b4e..8fd498c974b 100644 --- a/docs/init_transformations_resolve_resolve.js.html +++ b/docs/init_transformations_resolve_resolve.js.html @@ -109,13 +109,13 @@

Source: init/transformations/resolve/resolve.js


- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:39 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)
diff --git a/docs/init_transformations_stats_stats.js.html b/docs/init_transformations_stats_stats.js.html index f97b0f26332..4d1e76a9f8f 100644 --- a/docs/init_transformations_stats_stats.js.html +++ b/docs/init_transformations_stats_stats.js.html @@ -120,13 +120,13 @@

Source: init/transformations/stats/stats.js


- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:40 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)
diff --git a/docs/init_transformations_target_target.js.html b/docs/init_transformations_target_target.js.html index c2bb0c3fc13..e39aaaf305f 100644 --- a/docs/init_transformations_target_target.js.html +++ b/docs/init_transformations_target_target.js.html @@ -91,13 +91,13 @@

Source: init/transformations/target/target.js


- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:40 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)
diff --git a/docs/init_transformations_top-scope_top-scope.js.html b/docs/init_transformations_top-scope_top-scope.js.html index 605cb856a26..2b02ac1b65d 100644 --- a/docs/init_transformations_top-scope_top-scope.js.html +++ b/docs/init_transformations_top-scope_top-scope.js.html @@ -65,13 +65,13 @@

Source: init/transformations/top-scope/top-scope.js


- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:40 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)
diff --git a/docs/init_transformations_watch_watch.js.html b/docs/init_transformations_watch_watch.js.html index af6a67792e5..8fbc19e4543 100644 --- a/docs/init_transformations_watch_watch.js.html +++ b/docs/init_transformations_watch_watch.js.html @@ -121,13 +121,13 @@

Source: init/transformations/watch/watch.js


- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:40 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)
diff --git a/docs/init_transformations_watch_watchOptions.js.html b/docs/init_transformations_watch_watchOptions.js.html index 57195403885..1582b12a4b4 100644 --- a/docs/init_transformations_watch_watchOptions.js.html +++ b/docs/init_transformations_watch_watchOptions.js.html @@ -136,13 +136,13 @@

Source: init/transformations/watch/watchOptions.js


- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:40 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)
diff --git a/docs/migrate_bannerPlugin_bannerPlugin.js.html b/docs/migrate_bannerPlugin_bannerPlugin.js.html index b4ce6f2193c..a4acdc80f84 100644 --- a/docs/migrate_bannerPlugin_bannerPlugin.js.html +++ b/docs/migrate_bannerPlugin_bannerPlugin.js.html @@ -69,13 +69,13 @@

Source: migrate/bannerPlugin/bannerPlugin.js


- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:40 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)
diff --git a/docs/migrate_extractTextPlugin_extractTextPlugin.js.html b/docs/migrate_extractTextPlugin_extractTextPlugin.js.html index 3310f30ed26..5607cee1926 100644 --- a/docs/migrate_extractTextPlugin_extractTextPlugin.js.html +++ b/docs/migrate_extractTextPlugin_extractTextPlugin.js.html @@ -94,13 +94,13 @@

Source: migrate/extractTextPlugin/extractTextPlugin.js
- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:39 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)
diff --git a/docs/migrate_index.js.html b/docs/migrate_index.js.html index ed07cbb57a3..2ad277af537 100644 --- a/docs/migrate_index.js.html +++ b/docs/migrate_index.js.html @@ -115,13 +115,13 @@

Source: migrate/index.js


- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:40 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)
diff --git a/docs/migrate_loaderOptionsPlugin_loaderOptionsPlugin.js.html b/docs/migrate_loaderOptionsPlugin_loaderOptionsPlugin.js.html index 6368f2478b2..4cb36ce285d 100644 --- a/docs/migrate_loaderOptionsPlugin_loaderOptionsPlugin.js.html +++ b/docs/migrate_loaderOptionsPlugin_loaderOptionsPlugin.js.html @@ -83,13 +83,13 @@

Source: migrate/loaderOptionsPlugin/loaderOptionsPlugin.j
- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:40 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)
diff --git a/docs/migrate_loaders_loaders.js.html b/docs/migrate_loaders_loaders.js.html index 4d8dbd1d04b..f4767f047a9 100644 --- a/docs/migrate_loaders_loaders.js.html +++ b/docs/migrate_loaders_loaders.js.html @@ -347,13 +347,59 @@

Source: migrate/loaders/loaders.js

}); }); + /** + * + * Puts options object outside use object into use object + * + * @param {Node} p - object expression ast that has a key for either 'options' or 'use' + * @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; + if (keyName === "options") { + options = prop; + } + }); + + if (options) { + p.value.properties = p.value.properties.filter( + prop => prop.key.name !== "options" + ); + + p.value.properties.forEach(prop => { + const keyName = prop.key.name; + if (keyName === "use") { + prop.value.elements[0].properties.push(options); + } + }); + } + + return p; + }; + + /** + * Move `options` inside the Array of {Rule.Use} + * + * @returns {Node} ast - jscodeshift ast + */ + + const moveOptionsToUse = () => + ast + .find(j.ObjectExpression) + .filter(p => utils.findObjWithOneOfKeys(p, ["use"])) + .forEach(fitOptionsToUse); + const transforms = [ prepostLoaders, loadersToRules, loadersToArrayExpression, loaderWithQueryParam, loaderWithQueryProp, - addLoaderSuffix + addLoaderSuffix, + moveOptionsToUse ]; transforms.forEach(t => t()); @@ -369,13 +415,13 @@

Source: migrate/loaders/loaders.js


- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:40 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)
diff --git a/docs/migrate_outputPath_outputPath.js.html b/docs/migrate_outputPath_outputPath.js.html index b6d6f3c3565..bc2a0c3633b 100644 --- a/docs/migrate_outputPath_outputPath.js.html +++ b/docs/migrate_outputPath_outputPath.js.html @@ -110,13 +110,13 @@

Source: migrate/outputPath/outputPath.js


- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:40 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)
diff --git a/docs/migrate_removeDeprecatedPlugins_removeDeprecatedPlugins.js.html b/docs/migrate_removeDeprecatedPlugins_removeDeprecatedPlugins.js.html index 02d0c28c54c..17bcf8f51e6 100644 --- a/docs/migrate_removeDeprecatedPlugins_removeDeprecatedPlugins.js.html +++ b/docs/migrate_removeDeprecatedPlugins_removeDeprecatedPlugins.js.html @@ -80,13 +80,13 @@

Source: migrate/removeDeprecatedPlugins/removeDeprecatedP
- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:40 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)
diff --git a/docs/migrate_removeJsonLoader_removeJsonLoader.js.html b/docs/migrate_removeJsonLoader_removeJsonLoader.js.html index c5f145507f4..c04772a41d0 100644 --- a/docs/migrate_removeJsonLoader_removeJsonLoader.js.html +++ b/docs/migrate_removeJsonLoader_removeJsonLoader.js.html @@ -105,13 +105,13 @@

Source: migrate/removeJsonLoader/removeJsonLoader.js


- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:40 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)
diff --git a/docs/migrate_resolve_resolve.js.html b/docs/migrate_resolve_resolve.js.html index fe7dc8f5da6..0da1af0a136 100644 --- a/docs/migrate_resolve_resolve.js.html +++ b/docs/migrate_resolve_resolve.js.html @@ -108,13 +108,13 @@

Source: migrate/resolve/resolve.js


- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:40 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)
diff --git a/docs/migrate_uglifyJsPlugin_uglifyJsPlugin.js.html b/docs/migrate_uglifyJsPlugin_uglifyJsPlugin.js.html index 8c06b8d0f92..867aacd93a1 100644 --- a/docs/migrate_uglifyJsPlugin_uglifyJsPlugin.js.html +++ b/docs/migrate_uglifyJsPlugin_uglifyJsPlugin.js.html @@ -69,13 +69,13 @@

Source: migrate/uglifyJsPlugin/uglifyJsPlugin.js


- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:40 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)
diff --git a/docs/utils_ast-utils.js.html b/docs/utils_ast-utils.js.html index 21da0eb7e1e..241e6e998f4 100644 --- a/docs/utils_ast-utils.js.html +++ b/docs/utils_ast-utils.js.html @@ -262,7 +262,7 @@

Source: utils/ast-utils.js

* @param {any} j — jscodeshift API * @param {Node} rootNode - `plugins: []` Root Node. See https://github.com/facebook/jscodeshift/wiki/jscodeshift-Documentation#nodepaths * @param {String} pluginPackageName - ex. `extract-text-plugin` - * @returns {String} variable name - ex. 'var s = require(s) gives "s"` + * @returns {String} variable name - ex. 'const s = require(s) gives "s"` */ function findVariableToPlugin(j, rootNode, pluginPackageName) { @@ -712,13 +712,13 @@

Source: utils/ast-utils.js


- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:39 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)
diff --git a/docs/utils_copy-utils.js.html b/docs/utils_copy-utils.js.html index 1d7a9b59b19..4aae302ca3b 100644 --- a/docs/utils_copy-utils.js.html +++ b/docs/utils_copy-utils.js.html @@ -26,7 +26,7 @@

Source: utils/copy-utils.js

-
var path = require("path");
+            
const path = require("path");
 
 /**
  * Takes in a file path in the `./templates` directory. Copies that
@@ -36,13 +36,13 @@ 

Source: utils/copy-utils.js

* @param {string} templateDir Absolute path to template directory * @returns {Function} A curried function that takes a file path and copies it */ -var generatorCopy = ( +const generatorCopy = ( generator, templateDir ) => /** @param {string} filePath */ filePath => { - var sourceParts = templateDir.split(path.delimiter); + const sourceParts = templateDir.split(path.delimiter); sourceParts.push.apply(sourceParts, filePath.split("/")); - var targetParts = path.dirname(filePath).split("/"); + const targetParts = path.dirname(filePath).split("/"); targetParts.push(path.basename(filePath, ".tpl")); generator.fs.copy( @@ -62,14 +62,14 @@

Source: utils/copy-utils.js

* the template files. * @returns {Function} A curried function that takes a file path and copies it */ -var generatorCopyTpl = ( +const generatorCopyTpl = ( generator, templateDir, templateData ) => /** @param {string} filePath */ filePath => { - var sourceParts = templateDir.split(path.delimiter); + const sourceParts = templateDir.split(path.delimiter); sourceParts.push.apply(sourceParts, filePath.split("/")); - var targetParts = path.dirname(filePath).split("/"); + const targetParts = path.dirname(filePath).split("/"); targetParts.push(path.basename(filePath, ".tpl").slice(1)); generator.fs.copyTpl( @@ -93,13 +93,13 @@

Source: utils/copy-utils.js


- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:39 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)
diff --git a/docs/utils_defineTest.js.html b/docs/utils_defineTest.js.html index 5c300175f05..19b3120a4b3 100644 --- a/docs/utils_defineTest.js.html +++ b/docs/utils_defineTest.js.html @@ -141,13 +141,13 @@

Source: utils/defineTest.js


- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:39 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)
diff --git a/docs/utils_hashtable.js.html b/docs/utils_hashtable.js.html index 5ec89290485..160250596f8 100644 --- a/docs/utils_hashtable.js.html +++ b/docs/utils_hashtable.js.html @@ -34,11 +34,11 @@

Source: utils/hashtable.js

* @returns {Array} A sorted array with removed dupe elements */ module.exports = function hashtable(a) { - var prims = { boolean: {}, number: {}, string: {} }, + const prims = { boolean: {}, number: {}, string: {} }, objs = []; return a.filter(function(item) { - var type = typeof item; + const type = typeof item; if (type in prims) return prims[type].hasOwnProperty(item) ? false @@ -56,13 +56,13 @@

Source: utils/hashtable.js


- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:40 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)
diff --git a/docs/utils_is-local-path.js.html b/docs/utils_is-local-path.js.html new file mode 100644 index 00000000000..a33ef6659a4 --- /dev/null +++ b/docs/utils_is-local-path.js.html @@ -0,0 +1,70 @@ + + + + + JSDoc: Source: utils/is-local-path.js + + + + + + + + + + +
+ +

Source: utils/is-local-path.js

+ + + + + + +
+
+
"use strict";
+
+const fs = require("fs");
+const path = require("path");
+
+/**
+ * Attempts to detect whether the string is a local path regardless of its
+ * existence by checking its format. The point is to distinguish between
+ * paths and modules on the npm registry. This will fail for non-existent
+ * local Windows paths that begin with a drive letter, e.g. C:..\generator.js,
+ * but will succeed for any existing files and any absolute paths.
+ *
+ * @param {String} str - string to check
+ * @returns {Boolean} whether the string could be a path to a local file or directory
+ */
+
+module.exports = function(str) {
+	return path.isAbsolute(str) || /^\./.test(str) || fs.existsSync(str);
+};
+
+
+
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET) +
+ + + + + diff --git a/docs/utils_modify-config-helper.js.html b/docs/utils_modify-config-helper.js.html index bb10b103031..21fa08ce483 100644 --- a/docs/utils_modify-config-helper.js.html +++ b/docs/utils_modify-config-helper.js.html @@ -30,8 +30,10 @@

Source: utils/modify-config-helper.js

const fs = require("fs"); const path = require("path"); +const chalk = require("chalk"); const yeoman = require("yeoman-environment"); -const runTransform = require("../init/transformations/index"); +const runTransform = require("../init/index"); +const Generator = require("yeoman-generator"); /** * @@ -43,7 +45,7 @@

Source: utils/modify-config-helper.js

* @returns {Function} runTransform - Returns a transformation instance */ -module.exports = function modifyHelperUtil(action, generator) { +module.exports = function modifyHelperUtil(action, generator, packages) { let configPath = path.resolve(process.cwd(), "webpack.config.js"); const webpackConfigExists = fs.existsSync(configPath); if (!webpackConfigExists) { @@ -51,15 +53,50 @@

Source: utils/modify-config-helper.js

} const env = yeoman.createEnv("webpack", null); const generatorName = `webpack-${action}-generator`; + + if (!generator) { + generator = class extends Generator { + initializing() { + packages.forEach(pkgPath => { + return this.composeWith(require.resolve(pkgPath)); + }); + } + }; + } env.registerStub(generator, generatorName); env.run(generatorName).on("end", () => { + let configModule; + try { + const configPath = path.resolve(process.cwd(), ".yo-rc.json"); + configModule = require(configPath); + // Change structure of the config to be transformed + let tmpConfig = {}; + Object.keys(configModule).forEach(prop => { + const configs = Object.keys(configModule[prop].configuration); + configs.forEach(config => { + tmpConfig[config] = configModule[prop].configuration[config]; + }); + }); + configModule = tmpConfig; + } catch (err) { + console.error( + chalk.red("\nCould not find a yeoman configuration file.\n") + ); + console.error( + chalk.red( + "\nPlease make sure to use 'this.config.set('configuration', this.configuration);' at the end of the generator.\n" + ) + ); + Error.stackTraceLimit = 0; + process.exitCode = -1; + } const config = Object.assign( { configFile: !configPath ? null : fs.readFileSync(configPath, "utf8"), configPath: configPath }, - env.getArgument("configuration") + configModule ); return runTransform(config, action); }); @@ -74,13 +111,13 @@

Source: utils/modify-config-helper.js


- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:40 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)
diff --git a/docs/utils_npm-exists.js.html b/docs/utils_npm-exists.js.html index 7d4c0a9f885..c93f7a77d2d 100644 --- a/docs/utils_npm-exists.js.html +++ b/docs/utils_npm-exists.js.html @@ -59,13 +59,13 @@

Source: utils/npm-exists.js


- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:40 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)
diff --git a/docs/utils_npm-packages-exists.js.html b/docs/utils_npm-packages-exists.js.html index 6db674942e0..8ac97216255 100644 --- a/docs/utils_npm-packages-exists.js.html +++ b/docs/utils_npm-packages-exists.js.html @@ -28,9 +28,12 @@

Source: utils/npm-packages-exists.js

"use strict";
 const chalk = require("chalk");
+const isLocalPath = require("./is-local-path");
 const npmExists = require("./npm-exists");
 const resolvePackages = require("./resolve-packages").resolvePackages;
 
+const WEBPACK_ADDON_PREFIX = "webpack-addons";
+
 /**
  *
  * Loops through an array and checks if a package is registered
@@ -42,21 +45,38 @@ 

Source: utils/npm-packages-exists.js

module.exports = function npmPackagesExists(pkg) { let acceptedPackages = []; + + function resolvePackagesIfReady() { + if (acceptedPackages.length === pkg.length) + return resolvePackages(acceptedPackages); + } + pkg.forEach(addon => { - //eslint-disable-next-line - if (addon.length <= 14 || addon.slice(0, 14) !== "webpack-addons") { + if (isLocalPath(addon)) { + // If the addon is a path to a local folder, no name validation is necessary. + acceptedPackages.push(addon); + resolvePackagesIfReady(); + return; + } + + // The addon is on npm; validate name and existence + if ( + addon.length <= WEBPACK_ADDON_PREFIX.length || + addon.slice(0, WEBPACK_ADDON_PREFIX.length) !== WEBPACK_ADDON_PREFIX + ) { throw new TypeError( chalk.bold(`${addon} isn't a valid name.\n`) + chalk.red( - "\nIt should be prefixed with 'webpack-addons', but have different suffix.\n" + `\nIt should be prefixed with '${WEBPACK_ADDON_PREFIX}', but have different suffix.\n` ) ); } + npmExists(addon) .then(moduleExists => { if (!moduleExists) { Error.stackTraceLimit = 0; - throw new TypeError("Package isn't registered on npm."); + throw new TypeError(`Cannot resolve location of package ${addon}.`); } if (moduleExists) { acceptedPackages.push(addon); @@ -66,10 +86,7 @@

Source: utils/npm-packages-exists.js

console.error(err.stack || err); process.exit(0); }) - .then(_ => { - if (acceptedPackages.length === pkg.length) - return resolvePackages(acceptedPackages); - }); + .then(resolvePackagesIfReady); }); };
@@ -82,13 +99,13 @@

Source: utils/npm-packages-exists.js


- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:40 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)
diff --git a/docs/utils_package-manager.js.html b/docs/utils_package-manager.js.html index 302474f6483..4f92cb5a8ff 100644 --- a/docs/utils_package-manager.js.html +++ b/docs/utils_package-manager.js.html @@ -76,7 +76,8 @@

Source: utils/package-manager.js

*/ function spawnChild(pkg) { - const pkgPath = path.resolve(globalPath, pkg); + const rootPath = getPathToGlobalPackages(); + const pkgPath = path.resolve(rootPath, pkg); const packageManager = getPackageManager(); const isNew = !fs.existsSync(pkgPath); @@ -99,8 +100,35 @@

Source: utils/package-manager.js

return "yarn"; } +/** + * + * Returns the path to globally installed + * npm packages, depending on the available + * package manager determined by `getPackageManager` + * + * @returns {String} path - Path to global node_modules folder + */ +function getPathToGlobalPackages() { + const manager = getPackageManager(); + + if (manager === "yarn") { + try { + const yarnDir = spawn + .sync("yarn", ["global", "dir"]) + .stdout.toString() + .trim(); + return path.join(yarnDir, "node_modules"); + } catch (e) { + // Default to the global npm path below + } + } + + return globalPath; +} + module.exports = { getPackageManager, + getPathToGlobalPackages, spawnChild };
@@ -113,13 +141,13 @@

Source: utils/package-manager.js


- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:39 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)
diff --git a/docs/utils_prop-types.js.html b/docs/utils_prop-types.js.html index f5ef30e6868..1df6d2af6ae 100644 --- a/docs/utils_prop-types.js.html +++ b/docs/utils_prop-types.js.html @@ -71,13 +71,13 @@

Source: utils/prop-types.js


- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:40 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)
diff --git a/docs/utils_resolve-packages.js.html b/docs/utils_resolve-packages.js.html index c9f3fc62705..52768bf6878 100644 --- a/docs/utils_resolve-packages.js.html +++ b/docs/utils_resolve-packages.js.html @@ -30,10 +30,12 @@

Source: utils/resolve-packages.js

const path = require("path"); const chalk = require("chalk"); -const globalPath = require("global-modules"); -const creator = require("../init/index").creator; +const modifyConfigHelper = require("./modify-config-helper"); +const getPathToGlobalPackages = require("./package-manager") + .getPathToGlobalPackages; +const isLocalPath = require("./is-local-path"); const spawnChild = require("./package-manager").spawnChild; /** @@ -69,10 +71,36 @@

Source: utils/resolve-packages.js

let packageLocations = []; + function invokeGeneratorIfReady() { + if (packageLocations.length === pkg.length) + return modifyConfigHelper("init", null, packageLocations); + } + pkg.forEach(addon => { + // Resolve paths to modules on local filesystem + if (isLocalPath(addon)) { + let absolutePath = addon; + + try { + absolutePath = path.resolve(process.cwd(), addon); + require.resolve(absolutePath); + packageLocations.push(absolutePath); + } catch (err) { + console.log(`Cannot find a generator at ${absolutePath}.`); + console.log("\nReason:\n"); + console.error(chalk.bold.red(err)); + process.exitCode = 1; + } + + invokeGeneratorIfReady(); + return; + } + + // Resolve modules on npm registry processPromise(spawnChild(addon)) .then(_ => { try { + const globalPath = getPathToGlobalPackages(); packageLocations.push(path.resolve(globalPath, addon)); } catch (err) { console.log("Package wasn't validated correctly.."); @@ -83,15 +111,12 @@

Source: utils/resolve-packages.js

} }) .catch(err => { - console.log("Package Couldn't be installed, aborting.."); + console.log("Package couldn't be installed, aborting.."); console.log("\nReason: \n"); console.error(chalk.bold.red(err)); process.exitCode = 1; }) - .then(_ => { - if (packageLocations.length === pkg.length) - return creator(packageLocations); - }); + .then(invokeGeneratorIfReady); }); } @@ -109,13 +134,13 @@

Source: utils/resolve-packages.js


- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:40 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)
diff --git a/docs/utils_run-prettier.js.html b/docs/utils_run-prettier.js.html index f33289246dc..49ec136bed9 100644 --- a/docs/utils_run-prettier.js.html +++ b/docs/utils_run-prettier.js.html @@ -80,13 +80,13 @@

Source: utils/run-prettier.js


- Documentation generated by JSDoc 3.5.5 on Sun Feb 25 2018 15:08:40 GMT+0100 (CET) + Documentation generated by JSDoc 3.5.5 on Sat Mar 10 2018 01:28:11 GMT+0100 (CET)