Skip to content

Commit

Permalink
refactor: code
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-akait committed Dec 20, 2024
1 parent fca8c00 commit 2db1195
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 28 deletions.
8 changes: 4 additions & 4 deletions packages/create-webpack-app/src/generators/init/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ export default async function (plop: NodePlopAPI) {
// dependencies to be installed
const devDependencies: Array<string> = ["webpack", "webpack-cli"];

await plop.load("../../utils/pkgInstallAction.js", {}, true);
await plop.load("../../utils/fileGenerator.js", {}, true);
await plop.load("../../utils/install-dependencies.js", {}, true);
await plop.load("../../utils/generate-files.js", {}, true);

plop.setDefaultInclude({ generators: true, actionTypes: true });
plop.setPlopfilePath(resolve(__dirname, "../../plopfile.js"));
Expand Down Expand Up @@ -181,7 +181,7 @@ export default async function (plop: NodePlopAPI) {

for (const file of files) {
actions.push({
type: "fileGenerator",
type: "generate-files",
path: join(answers.projectPath, file.filePath),
templateFile: join(
plop.getPlopfilePath(),
Expand All @@ -194,7 +194,7 @@ export default async function (plop: NodePlopAPI) {
}

actions.push({
type: "pkgInstall",
type: "install-dependencies",
path: answers.projectPath,
packages: devDependencies,
});
Expand Down
8 changes: 4 additions & 4 deletions packages/create-webpack-app/src/generators/init/react.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export default async function (plop: NodePlopAPI) {
"@types/react-router-dom",
];

await plop.load("../../utils/pkgInstallAction.js", {}, true);
await plop.load("../../utils/fileGenerator.js", {}, true);
await plop.load("../../utils/install-dependencies.js", {}, true);
await plop.load("../../utils/generate-files.js", {}, true);

plop.setDefaultInclude({ generators: true, actionTypes: true });
plop.setPlopfilePath(resolve(__dirname, "../../plopfile.js"));
Expand Down Expand Up @@ -201,7 +201,7 @@ export default async function (plop: NodePlopAPI) {

for (const file of files) {
actions.push({
type: "fileGenerator",
type: "generate-files",
path: join(answers.projectPath, file.filePath),
templateFile: join(
plop.getPlopfilePath(),
Expand All @@ -214,7 +214,7 @@ export default async function (plop: NodePlopAPI) {
}

actions.push({
type: "pkgInstall",
type: "install-dependencies",
path: answers.projectPath,
packages: devDependencies,
});
Expand Down
8 changes: 4 additions & 4 deletions packages/create-webpack-app/src/generators/init/svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export default async function (plop: NodePlopAPI) {
"html-webpack-plugin",
];

await plop.load("../../utils/pkgInstallAction.js", {}, true);
await plop.load("../../utils/fileGenerator.js", {}, true);
await plop.load("../../utils/install-dependencies.js", {}, true);
await plop.load("../../utils/generate-files.js", {}, true);

plop.setDefaultInclude({ generators: true, actionTypes: true });
plop.setPlopfilePath(resolve(__dirname, "../../plopfile.js"));
Expand Down Expand Up @@ -188,7 +188,7 @@ export default async function (plop: NodePlopAPI) {

for (const file of files) {
actions.push({
type: "fileGenerator",
type: "generate-files",
path: join(answers.projectPath, file.filePath),
templateFile: join(
plop.getPlopfilePath(),
Expand All @@ -201,7 +201,7 @@ export default async function (plop: NodePlopAPI) {
}

actions.push({
type: "pkgInstall",
type: "install-dependencies",
path: answers.projectPath,
packages: devDependencies,
});
Expand Down
8 changes: 4 additions & 4 deletions packages/create-webpack-app/src/generators/init/vue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export default async function (plop: NodePlopAPI) {
"vue-router@4",
];

await plop.load("../../utils/pkgInstallAction.js", {}, true);
await plop.load("../../utils/fileGenerator.js", {}, true);
await plop.load("../../utils/install-dependencies.js", {}, true);
await plop.load("../../utils/generate-files.js", {}, true);

plop.setDefaultInclude({ generators: true, actionTypes: true });
plop.setPlopfilePath(resolve(__dirname, "../../plopfile.js"));
Expand Down Expand Up @@ -210,7 +210,7 @@ export default async function (plop: NodePlopAPI) {

for (const file of files) {
actions.push({
type: "fileGenerator",
type: "generate-files",
path: join(answers.projectPath, file.filePath),
templateFile: join(
plop.getPlopfilePath(),
Expand All @@ -223,7 +223,7 @@ export default async function (plop: NodePlopAPI) {
}

actions.push({
type: "pkgInstall",
type: "install-dependencies",
path: answers.projectPath,
packages: devDependencies,
});
Expand Down
8 changes: 4 additions & 4 deletions packages/create-webpack-app/src/generators/loader/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ export default async function (plop: NodePlopAPI) {
// dependencies to be installed
const devDependencies: Array<string> = ["webpack-defaults"];

await plop.load("../../utils/pkgInstallAction.js", {}, true);
await plop.load("../../utils/fileGenerator.js", {}, true);
await plop.load("../../utils/install-dependencies.js", {}, true);
await plop.load("../../utils/generate-files.js", {}, true);

// custom helper function
plop.setHelper("makeLoaderName", (name: string) => {
Expand Down Expand Up @@ -76,7 +76,7 @@ export default async function (plop: NodePlopAPI) {

for (const file of files) {
actions.push({
type: "fileGenerator",
type: "generate-files",
path: join(answers.projectPath, file.filePath),
templateFile: join(
plop.getPlopfilePath(),
Expand All @@ -89,7 +89,7 @@ export default async function (plop: NodePlopAPI) {
}

actions.push({
type: "pkgInstall",
type: "install-dependencies",
path: answers.projectPath,
packages: devDependencies,
});
Expand Down
8 changes: 4 additions & 4 deletions packages/create-webpack-app/src/generators/plugin/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ export default async function (plop: NodePlopAPI) {
// dependencies to be installed
const devDependencies: Array<string> = ["webpack-defaults"];

await plop.load("../../utils/pkgInstallAction.js", {}, true);
await plop.load("../../utils/fileGenerator.js", {}, true);
await plop.load("../../utils/install-dependencies.js", {}, true);
await plop.load("../../utils/generate-files.js", {}, true);

plop.setDefaultInclude({ generators: true, actionTypes: true });
plop.setPlopfilePath(resolve(__dirname, "../../plopfile.js"));
Expand Down Expand Up @@ -68,7 +68,7 @@ export default async function (plop: NodePlopAPI) {

for (const file of files) {
actions.push({
type: "fileGenerator",
type: "generate-files",
path: join(answers.projectPath, file.filePath),
templateFile: join(
plop.getPlopfilePath(),
Expand All @@ -81,7 +81,7 @@ export default async function (plop: NodePlopAPI) {
}

actions.push({
type: "pkgInstall",
type: "install-dependencies",
path: answers.projectPath,
packages: devDependencies,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ export default async function (plop: NodePlopAPI) {
plop.setPlopfilePath(path.resolve(__dirname, "../plopfile.js"));
plop.setDefaultInclude({ actions: true });

plop.setActionType("fileGenerator", async (answers, config) => {
plop.setActionType("generate-files", async (answers, config) => {
const isTemplate = config.fileType === "text";
const result = await checkAndPrepareContent(
{ ...config, data: answers } as AddConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default async function (plop: NodePlopAPI) {

plop.setPlopfilePath(resolve(__dirname, "../plopfile.js"));
plop.setDefaultInclude({ actions: true });
plop.setActionType("pkgInstall", (answers, config) => {
plop.setActionType("install-dependencies", (answers, config) => {
const options: SpawnOptionsWithStdioTuple<
StdioNull,
StdioNull | StdioPipe,
Expand Down
4 changes: 2 additions & 2 deletions packages/create-webpack-app/src/utils/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const typeDisplay: Record<string, Color | string> = {

function onSuccessHandler(change: PlopActionHooksChanges): void {
switch (change.type) {
case "fileGenerator": {
case "generate-files": {
change.path.split("\n").forEach((line) => {
const [operationType = "", renderPath = ""] = line.split("|");
console.log(
Expand All @@ -38,7 +38,7 @@ function onSuccessHandler(change: PlopActionHooksChanges): void {
});
break;
}
case "pkgInstall": {
case "install-dependencies": {
logger.success(change.path);
break;
}
Expand Down

0 comments on commit 2db1195

Please sign in to comment.