Skip to content

Commit 0a72410

Browse files
refactor: create-webpack-app (#4352)
1 parent ce1e784 commit 0a72410

File tree

13 files changed

+59
-40
lines changed

13 files changed

+59
-40
lines changed

packages/create-webpack-app/package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@
3939
"lib",
4040
"!**/*__tests__"
4141
],
42-
"peerDependencies": {
43-
"webpack-cli": "^5.x.x"
44-
},
4542
"dependencies": {
4643
"@inquirer/prompts": "^7.2.0",
4744
"colorette": "^2.0.20",

packages/create-webpack-app/src/generators/init/default.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { Answers, ActionType, FileRecord } from "../../types";
1+
import { type Answers, type ActionType, type FileRecord } from "../../types";
2+
import { type NodePlopAPI, type DynamicActionsFunction } from "node-plop";
23
import { dirname, join, resolve } from "path";
3-
import { NodePlopAPI, DynamicActionsFunction } from "node-plop";
44
import { fileURLToPath } from "url";
55

6-
const __dirname = dirname(fileURLToPath(import.meta.url));
7-
86
export default async function (plop: NodePlopAPI) {
7+
const __dirname = dirname(fileURLToPath(import.meta.url));
8+
99
// dependencies to be installed
1010
const devDependencies: Array<string> = ["webpack", "webpack-cli"];
1111

packages/create-webpack-app/src/generators/init/react.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { Answers, ActionType, FileRecord } from "../../types";
1+
import { type Answers, type ActionType, type FileRecord } from "../../types";
2+
import { type NodePlopAPI, type DynamicActionsFunction } from "node-plop";
23
import { dirname, resolve, join } from "path";
3-
import { NodePlopAPI, DynamicActionsFunction } from "node-plop";
44
import { fileURLToPath } from "url";
55

6-
const __dirname = dirname(fileURLToPath(import.meta.url));
7-
86
export default async function (plop: NodePlopAPI) {
7+
const __dirname = dirname(fileURLToPath(import.meta.url));
8+
99
// dependencies to be installed
1010
const devDependencies: Array<string> = [
1111
"webpack",

packages/create-webpack-app/src/generators/init/svelte.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { Answers, ActionType, FileRecord } from "../../types";
1+
import { type Answers, type ActionType, type FileRecord } from "../../types";
2+
import { type NodePlopAPI, type DynamicActionsFunction } from "node-plop";
23
import { dirname, join, resolve } from "path";
3-
import { NodePlopAPI, DynamicActionsFunction } from "node-plop";
44
import { fileURLToPath } from "url";
55

6-
const __dirname = dirname(fileURLToPath(import.meta.url));
7-
86
export default async function (plop: NodePlopAPI) {
7+
const __dirname = dirname(fileURLToPath(import.meta.url));
8+
99
// dependencies to be installed
1010
const devDependencies: Array<string> = [
1111
"webpack",

packages/create-webpack-app/src/generators/init/vue.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import { Answers, ActionType, FileRecord } from "../../types";
1+
import { type Answers, type ActionType, type FileRecord } from "../../types";
2+
import { type NodePlopAPI, type DynamicActionsFunction } from "node-plop";
23
import { dirname, join, resolve } from "path";
3-
import { NodePlopAPI, DynamicActionsFunction } from "node-plop";
44
import { fileURLToPath } from "url";
55

6-
const __dirname = dirname(fileURLToPath(import.meta.url));
76
export default async function (plop: NodePlopAPI) {
7+
const __dirname = dirname(fileURLToPath(import.meta.url));
8+
89
// dependencies to be installed
910
const devDependencies: Array<string> = [
1011
"webpack",

packages/create-webpack-app/src/generators/loader/default.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { Answers, ActionType, FileRecord } from "../../types";
1+
import { type Answers, type ActionType, type FileRecord } from "../../types";
2+
import { type NodePlopAPI, type DynamicActionsFunction } from "node-plop";
23
import { dirname, join, resolve } from "path";
3-
import { NodePlopAPI, DynamicActionsFunction } from "node-plop";
44
import { fileURLToPath } from "url";
55
import { logger } from "../../utils/logger.js";
66

7-
const __dirname = dirname(fileURLToPath(import.meta.url));
8-
97
export default async function (plop: NodePlopAPI) {
8+
const __dirname = dirname(fileURLToPath(import.meta.url));
9+
1010
// dependencies to be installed
1111
const devDependencies: Array<string> = ["webpack-defaults"];
1212

packages/create-webpack-app/src/generators/plugin/default.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { Answers, ActionType, FileRecord } from "../../types";
1+
import { type Answers, type ActionType, type FileRecord } from "../../types";
2+
import { type NodePlopAPI, type DynamicActionsFunction } from "node-plop";
23
import { dirname, join, resolve } from "path";
3-
import { NodePlopAPI, DynamicActionsFunction } from "node-plop";
44
import { fileURLToPath } from "url";
55
import { logger } from "../../utils/logger.js";
66

7-
const __dirname = dirname(fileURLToPath(import.meta.url));
8-
97
export default async function (plop: NodePlopAPI) {
8+
const __dirname = dirname(fileURLToPath(import.meta.url));
9+
1010
// dependencies to be installed
1111
const devDependencies: Array<string> = ["webpack-defaults"];
1212

packages/create-webpack-app/src/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { Command } from "commander";
22
import { resolve, dirname } from "path";
33
import { select } from "@inquirer/prompts";
4-
import nodePlop, { PlopGenerator } from "node-plop";
4+
import nodePlop, { type PlopGenerator } from "node-plop";
55
import { fileURLToPath } from "url";
66

77
import { onSuccessHandler, onFailureHandler, logger } from "./utils/logger.js";
8-
import { Answers, InitOptions, LoaderOptions, PluginOptions } from "./types";
8+
import { type Answers, type InitOptions, type LoaderOptions, type PluginOptions } from "./types";
99

1010
const __dirname = dirname(fileURLToPath(import.meta.url));
1111

@@ -63,7 +63,6 @@ const pluginGenerators: Record<string, PlopGenerator> = {
6363
};
6464

6565
program
66-
.version("1.0.0", "-v, --version")
6766
.usage("[command] [options]")
6867
.helpOption("-h, --help", "Display help for command")
6968
.description("A CLI tool to generate a Webpack project");
@@ -127,6 +126,7 @@ program
127126
process.exit(2);
128127
}
129128
});
129+
130130
program
131131
.command("loader")
132132
.aliases(["l", "ld"])
@@ -167,6 +167,7 @@ program
167167
process.exit(2);
168168
}
169169
});
170+
170171
program
171172
.command("plugin")
172173
.aliases(["p", "pl"])

packages/create-webpack-app/src/plopfile.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { NodePlopAPI } from "node-plop";
1+
import { type NodePlopAPI } from "node-plop";
22

33
export default async function (plop: NodePlopAPI) {
44
//init generators

packages/create-webpack-app/src/types.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,15 @@ export type FileRecord = {
2424
filePath: string;
2525
fileType: string;
2626
};
27+
28+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
29+
type LogHandler = (value: any) => void;
30+
31+
export interface Logger {
32+
error: LogHandler;
33+
warn: LogHandler;
34+
info: LogHandler;
35+
success: LogHandler;
36+
log: LogHandler;
37+
raw: LogHandler;
38+
}

0 commit comments

Comments
 (0)