-
-
Notifications
You must be signed in to change notification settings - Fork 612
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cf8e3c9
commit 7481974
Showing
4 changed files
with
64 additions
and
89 deletions.
There are no files selected for viewing
This file contains 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 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 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,46 @@ | ||
import { AutoComplete, Confirm, Input, InputValidate } from "@webpack-cli/webpack-scaffold"; | ||
import { existsSync } from "fs"; | ||
import { resolve } from "path"; | ||
import { searchProps } from "./index"; | ||
import { Question } from "inquirer"; | ||
|
||
/** | ||
* Returns Inquirer question for given action | ||
* @param {string} action action for which question has to be prompted | ||
* @returns {Question} Question for given action | ||
*/ | ||
export const manualOrListInput = (action: string): Question => { | ||
const actionQuestion = `What do you want to add to ${action}?`; | ||
return Input("actionAnswer", actionQuestion); | ||
}; | ||
|
||
export const actionTypeQuestion = AutoComplete("actionType", "What property do you want to add to?", { | ||
pageSize: 7, | ||
source: searchProps, | ||
suggestOnly: false | ||
}); | ||
|
||
export const entryTypeQuestion: Question = Confirm("entryType", "Will your application have multiple bundles?", false); | ||
|
||
export const topScopeQuestion: Question = Input("topScope", "What do you want to add to topScope?"); | ||
|
||
const mergeFileQuestionsFunction = (): Question[] => { | ||
const mergePathQuestion = | ||
"What is the location of webpack configuration with which you want to merge current configuration?"; | ||
const mergePathValidator = (path: string): boolean | string => { | ||
const resolvedPath = resolve(process.cwd(), path); | ||
if (existsSync(resolvedPath)) { | ||
if (/\.js$/.test(path)) { | ||
return true; | ||
} | ||
return "Path doesn't corresponds to a javascript file"; | ||
} | ||
return "Invalid path provided"; | ||
}; | ||
const mergeConfigNameQuestion = "What is the name by which you want to denote above configuration?"; | ||
return [ | ||
InputValidate("mergeFile", mergePathQuestion, mergePathValidator), | ||
Input("mergeConfigName", mergeConfigNameQuestion) | ||
]; | ||
}; | ||
export const mergeFileQuestion: Question[] = mergeFileQuestionsFunction(); |
This file was deleted.
Oops, something went wrong.