-
-
Notifications
You must be signed in to change notification settings - Fork 679
[WIP] UI: endpoint for init #756
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
a103ec0
ui(init): start writing endpoint
rishabh3112 4e411e4
ui(init): minor correction
rishabh3112 6253316
ui(init): incorporate inquirer questions
rishabh3112 fd87903
ui(init): complete port of init generator
rishabh3112 a2b58fe
ui: add static fallback
rishabh3112 6fc3a2d
chore: fix existsSync function
rishabh3112 7e340b1
ui(docs): update ui-gui guide
rishabh3112 8e5cceb
ui(init): identify user directory
rishabh3112 7a601a5
ui(init): added some comments
rishabh3112 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| /utils/**.js |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| /* eslint-disable node/no-unpublished-require */ | ||
| const InputValidate = require("../../../webpack-scaffold").InputValidate; | ||
| const webpackEntryPoint = {}; | ||
| function forEachPromise(entries, fn) { | ||
| return entries.reduce((promise, prop) => { | ||
| const trimmedProp = prop.trim(); | ||
|
|
||
| return promise.then((n) => { | ||
| if (n) { | ||
| Object.keys(n).forEach((val) => { | ||
| if ( | ||
| n[val].charAt(0) !== "(" && | ||
| n[val].charAt(0) !== "[" && | ||
| !n[val].includes("function") && | ||
| !n[val].includes("path") && | ||
| !n[val].includes("process") | ||
| ) { | ||
| n[val] = `\'${n[val].replace(/"|'/g, "").concat(".js")}\'`; | ||
| } | ||
| webpackEntryPoint[val] = n[val]; | ||
| }); | ||
| } else { | ||
| n = {}; | ||
| } | ||
| return fn(trimmedProp); | ||
| }); | ||
| }, Promise.resolve()); | ||
| } | ||
| /** | ||
| * Asks for entry points, either if it has multiple or one entry | ||
| * @param {Object} questioner Instance of TCP questioner used by init endpoint | ||
| * @param {Object} answer Boolean answer to whether mutiple entries are used or not | ||
| * @returns {Object} An Object to entry for webpack config | ||
| */ | ||
| module.exports = function(questioner, answer) { | ||
| if (answer.entryType === true) { | ||
| return questioner.question({ | ||
| action: "question", | ||
| question: InputValidate( | ||
| "multipleEntries", | ||
| "Type the names you want for your modules (entry files), separated by comma [example: app,vendor]" | ||
| ), | ||
| }).then((entries) => { | ||
| return forEachPromise(entries, (entryProp) => { | ||
| return questioner.question({ | ||
| action: "question", | ||
| question: InputValidate( | ||
| `${entryProp}`, | ||
| `What is the location of "${entryProp}"? [example: ./src/${entryProp}]` | ||
| ), | ||
| }); | ||
| }).then((entryPropAnswer) => { | ||
| Object.keys(entryPropAnswer).forEach(val => { | ||
| if ( | ||
| entryPropAnswer[val].charAt(0) !== "(" && | ||
| entryPropAnswer[val].charAt(0) !== "[" && | ||
| !entryPropAnswer[val].includes("function") && | ||
| !entryPropAnswer[val].includes("path") && | ||
| !entryPropAnswer[val].includes("process") | ||
| ) { | ||
|
rishabh3112 marked this conversation as resolved.
|
||
| entryPropAnswer[val] = `\'${entryPropAnswer[val] | ||
| .replace(/"|'/g, "") | ||
| .concat(".js")}\'`; | ||
| } | ||
| webpackEntryPoint[val] = entryPropAnswer[val]; | ||
| }); | ||
| return webpackEntryPoint; | ||
| }); | ||
| }); | ||
| } else { | ||
| return questioner.question({ | ||
| action: "question", | ||
| question: InputValidate( | ||
| "singularEntry", | ||
| "Which module will be the first to enter the application? [default: ./src/index]" | ||
| ) | ||
| }).then((singularEntryAnswer) => { | ||
| let singularEntry = singularEntryAnswer.singularEntry; | ||
| if (singularEntry.indexOf("\"") >= 0) { | ||
| singularEntry = singularEntry.replace(/"/g, "'"); | ||
| } | ||
| return singularEntry; | ||
|
rishabh3112 marked this conversation as resolved.
|
||
| }); | ||
| } | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| /** | ||
| * | ||
| * Returns an module.rule object that has the babel loader if invoked | ||
| * | ||
| * @returns {Function} A callable function that adds the babel-loader with env preset | ||
| */ | ||
| module.exports = function() { | ||
| return { | ||
| include: ["path.resolve(__dirname, 'src')"], | ||
| loader: "'babel-loader'", | ||
| options: { | ||
| plugins: [ | ||
| "'syntax-dynamic-import'", | ||
| ], | ||
| presets: [ | ||
| [ | ||
| "'env'", | ||
| { | ||
| "'modules'": false, | ||
| }, | ||
| ], | ||
| ], | ||
| }, | ||
| test: `${new RegExp(/\.js$/)}`, | ||
| }; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| /** | ||
| * Callable function with the initial plugins | ||
| * | ||
| * @returns {Function} An function that returns an array | ||
| * that consists of the uglify plugin | ||
| */ | ||
| module.exports = () => ["new UglifyJSPlugin()"]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| /** | ||
| * | ||
| * Tooltip object that consists of tooltips for various of | ||
| * features | ||
| * | ||
| * @returns {Object} An Object that consists of tooltip methods to be invoked | ||
| */ | ||
| module.exports = { | ||
| cssPlugin: () => `/* | ||
| * We've enabled MiniCssExtractPlugin for you. This allows your app to | ||
| * use css modules that will be moved into a separate CSS file instead of inside | ||
| * one of your module entries! | ||
| * | ||
| * https://github.com/webpack-contrib/mini-css-extract-plugin | ||
| * | ||
| */`, | ||
| splitChunks: () => `/* | ||
| * SplitChunksPlugin is enabled by default and replaced | ||
| * deprecated CommonsChunkPlugin. It automatically identifies modules which | ||
| * should be splitted of chunk by heuristics using module duplication count and | ||
| * module category (i. e. node_modules). And splits the chunks… | ||
| * | ||
| * It is safe to remove "splitChunks" from the generated configuration | ||
| * and was added as an educational example. | ||
| * | ||
| * https://webpack.js.org/plugins/split-chunks-plugin/ | ||
| * | ||
| */`, | ||
| postcss: () => `/* | ||
| * We've enabled Postcss, autoprefixer and precss for you. This allows your app | ||
| * to lint CSS, support variables and mixins, transpile future CSS syntax, | ||
| * inline images, and more! | ||
| * | ||
| * To enable SASS or LESS, add the respective loaders to module.rules | ||
| * | ||
| * https://github.com/postcss/postcss | ||
| * | ||
| * https://github.com/postcss/autoprefixer | ||
| * | ||
| * https://github.com/jonathantneal/precss | ||
| * | ||
| */`, | ||
| uglify: () => `/* | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We're using terser
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, will do it here when terser PR get merged in master 👍 |
||
| * We've enabled UglifyJSPlugin for you! This minifies your app | ||
| * in order to load faster and run less javascript. | ||
| * | ||
| * https://github.com/webpack-contrib/uglifyjs-webpack-plugin | ||
| * | ||
| */` | ||
| }; | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.