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

Feat: webpack template generator for webpack repos #4152

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@ test/**/**/binary/**
test/**/dist
test/**/**/dist
test/**/**/**/dist
test/**/stats.json
test/**/stats.json
16 changes: 15 additions & 1 deletion packages/generators/src/init-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,27 @@ export default class InitGenerator<
public constructor(args: string | string[], opts: Z) {
super(args, opts);

const [, , ...restArgs] = args;
this.#parseArgs(restArgs);

this.dependencies = ["webpack", "webpack-cli"];
this.supportedTemplates = Object.keys(handlers);
}

#parseArgs(args: string[]): void {
const templateIndex = args.findIndex((arg) => arg === "--template");
if (
templateIndex !== -1 &&
templateIndex + 1 < args.length &&
args[templateIndex + 1] == "webpack"
) {
this.template = args[templateIndex + 1];
// now if the template is webpack, then we follow the execution of webpack-defaults ?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to move all logic of webpack-defaults here

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i.e. the same files, configuration and etc

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it, working on it

}
}

public async prompting(): Promise<void> {
this.template = await getTemplate.call(this);

await handlers[this.template as keyof typeof handlers].questions(this, Question);

// Handle installation of prettier
Expand Down
Empty file modified packages/webpack-cli/bin/cli.js
100755 → 100644
Empty file.