From 2ca57a2d1f1b98eb8db53ddfba00dca11bde148a Mon Sep 17 00:00:00 2001 From: anikethsaha Date: Sun, 12 May 2019 16:55:09 +0530 Subject: [PATCH 1/6] fix(generator): using configFile in configPath Passing {configFile:configFile} to the env.run(generator) as second argument in packages/utils/modify-config.ts and using this property in generator class to get the configPath in generator class constructor in remove-generator.ts --- packages/generators/remove-generator.ts | 6 ++++-- packages/utils/modify-config-helper.ts | 8 +++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/generators/remove-generator.ts b/packages/generators/remove-generator.ts index 9169a42ffad..d3e35f0c652 100644 --- a/packages/generators/remove-generator.ts +++ b/packages/generators/remove-generator.ts @@ -32,13 +32,15 @@ export default class RemoveGenerator extends Generator { webpackOptions: {} } }; - - let configPath = path.resolve(process.cwd(), "webpack.config.js"); + const {configFile} = opts + let configPath = path.resolve(process.cwd(), configFile); const webpackConfigExists = fs.existsSync(configPath); + if (!webpackConfigExists) { configPath = null; // end the generator stating webpack config not found or to specify the config } + this.webpackOptions = require(configPath); } diff --git a/packages/utils/modify-config-helper.ts b/packages/utils/modify-config-helper.ts index e836f283991..50cada86130 100644 --- a/packages/utils/modify-config-helper.ts +++ b/packages/utils/modify-config-helper.ts @@ -58,13 +58,14 @@ export default function modifyHelperUtil( chalk.cyan(configFile + "\n") + "\n" ); + } else { process.stdout.write( "\n" + logSymbols.error + chalk.red(" ERROR ") + chalk.cyan(configFile) + - " not found. Please specify a valid path to your webpack config like " + + " not found. Please specify a valid path to your webpack config like \n " + chalk.white("$ ") + chalk.cyan(`webpack-cli ${action} webpack.dev.js`) + "\n" @@ -89,8 +90,9 @@ export default function modifyHelperUtil( } env.registerStub(generator, generatorName); - env.run(generatorName) - .then( + env.run(generatorName,{ + configFile + }).then( (): void => { let configModule: object; try { From 0b65ba8d6a3e210ef0e025624ad42d13d54d66b6 Mon Sep 17 00:00:00 2001 From: Anix Date: Mon, 13 May 2019 01:34:59 +0530 Subject: [PATCH 2/6] fix(lint): added semicolon added semicolon in line 35 --- packages/generators/remove-generator.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/generators/remove-generator.ts b/packages/generators/remove-generator.ts index d3e35f0c652..c00928bc399 100644 --- a/packages/generators/remove-generator.ts +++ b/packages/generators/remove-generator.ts @@ -32,7 +32,7 @@ export default class RemoveGenerator extends Generator { webpackOptions: {} } }; - const {configFile} = opts + const {configFile} = opts; let configPath = path.resolve(process.cwd(), configFile); const webpackConfigExists = fs.existsSync(configPath); From e007c45361366a954980c1c1ac97c15abb10917b Mon Sep 17 00:00:00 2001 From: Anix Date: Mon, 13 May 2019 01:40:34 +0530 Subject: [PATCH 3/6] fix(lint): remove blank line and added space removed the blank line and added space in env.run method 's second argument. --- packages/utils/modify-config-helper.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/utils/modify-config-helper.ts b/packages/utils/modify-config-helper.ts index 50cada86130..5d25385c8c0 100644 --- a/packages/utils/modify-config-helper.ts +++ b/packages/utils/modify-config-helper.ts @@ -58,7 +58,6 @@ export default function modifyHelperUtil( chalk.cyan(configFile + "\n") + "\n" ); - } else { process.stdout.write( "\n" + @@ -88,9 +87,9 @@ export default function modifyHelperUtil( } }; } + env.registerStub(generator, generatorName); - - env.run(generatorName,{ + env.run(generatorName, { configFile }).then( (): void => { From c395c165b54a84113e634203337c55f87a41710f Mon Sep 17 00:00:00 2001 From: Anix Date: Mon, 13 May 2019 14:10:43 +0530 Subject: [PATCH 4/6] chore: removed the if-statement removed the if-statement and added space --- packages/generators/remove-generator.ts | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/packages/generators/remove-generator.ts b/packages/generators/remove-generator.ts index c00928bc399..9af3b862592 100644 --- a/packages/generators/remove-generator.ts +++ b/packages/generators/remove-generator.ts @@ -32,15 +32,9 @@ export default class RemoveGenerator extends Generator { webpackOptions: {} } }; - const {configFile} = opts; + const { configFile } = opts; let configPath = path.resolve(process.cwd(), configFile); const webpackConfigExists = fs.existsSync(configPath); - - if (!webpackConfigExists) { - configPath = null; - // end the generator stating webpack config not found or to specify the config - } - this.webpackOptions = require(configPath); } From 118ac1dcdd6627a7de47cebf09ce2509a6ec95b4 Mon Sep 17 00:00:00 2001 From: anikethsaha Date: Tue, 21 May 2019 16:37:19 +0530 Subject: [PATCH 5/6] fix(init): refractor the init-generator to fix entry issue Changed the init-generator code to fix the entry point issue when the entry point was answered --- packages/generators/init-generator.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/generators/init-generator.ts b/packages/generators/init-generator.ts index c33e038a087..58b8cc9321c 100644 --- a/packages/generators/init-generator.ts +++ b/packages/generators/init-generator.ts @@ -91,13 +91,11 @@ export default class InitGenerator extends Generator { .then( (entryOptions: object | string): Promise<{}> => { if (typeof entryOptions === "string" && entryOptions.length > 0) { - return this.prompt([ - Input("outputType", "In which folder do you want to store your generated bundles? (dist):") - ]); - } - if (entryOptions !== '""') { - this.configuration.config.webpackOptions.entry = entryOptions; + if (entryOptions !== "\"\"" && entryOptions !== "\'\'") { + this.configuration.config.webpackOptions.entry = entryOptions; + } } + return this.prompt([ Input("outputType", "In which folder do you want to store your generated bundles? (dist):") ]); From 04e7b1779595dc54b1a6dc92fd302649fd651afb Mon Sep 17 00:00:00 2001 From: anikethsaha Date: Tue, 21 May 2019 16:37:19 +0530 Subject: [PATCH 6/6] fix(init): refractor the init-generator to fix entry issue Changed the init-generator code to fix the entry point issue when the entry point was answered --- packages/generators/init-generator.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/generators/init-generator.ts b/packages/generators/init-generator.ts index a50f04813d3..715b44e8797 100644 --- a/packages/generators/init-generator.ts +++ b/packages/generators/init-generator.ts @@ -92,13 +92,11 @@ export default class InitGenerator extends Generator { .then( (entryOptions: object | string): Promise<{}> => { if (typeof entryOptions === "string" && entryOptions.length > 0) { - return this.prompt([ - Input("outputType", "In which folder do you want to store your generated bundles? (dist):") - ]); - } - if (entryOptions !== '""') { - this.configuration.config.webpackOptions.entry = entryOptions; + if (entryOptions !== "\"\"" && entryOptions !== "\'\'") { + this.configuration.config.webpackOptions.entry = entryOptions; + } } + return this.prompt([ Input("outputType", "In which folder do you want to store your generated bundles? (dist):") ]);