Skip to content
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

enh(webpack-scaffold): improve prompt and doc #794

Merged
merged 7 commits into from
Mar 19, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
misc(webpack-scaffold): add Confirm prompt default option
  • Loading branch information
misterdev committed Mar 17, 2019
commit 7fe33d70c54806e265dd6d400d8c52508a6d391e
2 changes: 1 addition & 1 deletion packages/generators/add-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export default class AddGenerator extends Generator {
.then((_: void) => {
if (action === "entry") {
return this.prompt([
Confirm("entryType", "Will your application have multiple bundles?"),
Confirm("entryType", "Will your application have multiple bundles?", false),
])
.then((entryTypeAnswer: {
entryType: boolean,
Expand Down
10 changes: 5 additions & 5 deletions packages/generators/init-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export default class InitGenerator extends Generator {
);

return this.prompt([
Confirm("entryType", "Will your application have multiple bundles?"),
Confirm("entryType", "Will your application have multiple bundles?", false),
])
.then((entryTypeAnswer: {
entryType: boolean;
Expand All @@ -100,7 +100,7 @@ export default class InitGenerator extends Generator {
return this.prompt([
Input(
"outputType",
"Which folder will your generated bundles be in? [default: dist]:",
"In which folder do you want to store your generated bundles? (dist/):",
),
]);
}
Expand All @@ -110,7 +110,7 @@ export default class InitGenerator extends Generator {
return this.prompt([
Input(
"outputType",
"Which folder will your generated bundles be in? [default: dist]:",
"In which folder do you want to store your generated bundles? (dist/):",
),
]);
})
Expand Down Expand Up @@ -165,11 +165,11 @@ export default class InitGenerator extends Generator {
.then((_: void) => {
return this.prompt([
List("stylingType", "Will you use one of the below CSS solutions?", [
"No",
"CSS",
"SASS",
"LESS",
"CSS",
"PostCSS",
"No",
]),
]);
})
Expand Down
3 changes: 2 additions & 1 deletion packages/generators/types/yeoman-generator.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ declare module "yeoman-generator" {
name: string;
message: string | ((answers: Object) => string);
choices?: string[] | ((answers: Object) => string);
default?: string | number | string[] | number[] | ((answers: Object) => (string | number | string[] | number[]));
default?: string | number | boolean | string[] | number[]
| ((answers: Object) => (string | number | boolean | string[] | number[]));
validate?: ((input: string) => boolean | string);
when?: ((answers: Object) => boolean) | boolean;
store?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion packages/generators/utils/entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export default function entry(self: IEntry, answer: {
.prompt([
InputValidate(
"singularEntry",
"Which module will be the first to enter the application? [default: ./src/index]",
"Which will be your application entry point? (./src/index)",
),
])
.then((singularEntryAnswer: {
Expand Down
6 changes: 4 additions & 2 deletions packages/webpack-scaffold/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ export interface IInquirerScaffoldObject {
name: string;
message: string;
choices?: ((answers: Object) => string) | string[];
default?: string | number | string[] | number[] | ((answers: Object) => (string | number | string[] | number[]));
default?: string | number | boolean | string[] | number[]
| ((answers: Object) => (string | number | boolean | string[] | number[]));
validate?: ((input: string) => boolean | string);
when?: ((answers: Object) => boolean) | boolean;
store?: boolean;
Expand Down Expand Up @@ -110,8 +111,9 @@ export function InputValidate(name: string, message: string, cb?: (input: string
};
}

export function Confirm(name: string, message: string): IInquirerScaffoldObject {
export function Confirm(name: string, message: string, defaultChoice: boolean = true): IInquirerScaffoldObject {
return {
default: defaultChoice,
message,
name,
type: "confirm",
Expand Down