Skip to content
Merged
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 packages/generators/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"dependencies": {
"webpack-cli": "^4.10.0",
"yeoman-environment": "^3.9.1",
"yeoman-generator": "^4.12.0"
"yeoman-generator": "^5.7.0"
},
"peerDependencies": {
"webpack": "5.x.x",
Expand Down
3 changes: 3 additions & 0 deletions packages/generators/src/addon-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import { CustomGenerator } from "./types";
import type { CustomGeneratorOptions, BaseCustomGeneratorOptions } from "./types";
import { getInstaller, getTemplate } from "./utils/helpers";

// eslint-disable-next-line @typescript-eslint/no-var-requires
Object.assign(Generator.prototype, require("yeoman-generator/lib/actions/install"));
Comment on lines +9 to +10
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Install action is deprecated and is not included by default

Breaking change


// Helper to get the template-directory content
const getFiles = (dir: string): string[] => {
return fs.readdirSync(dir).reduce((list, file) => {
Expand Down
16 changes: 1 addition & 15 deletions packages/generators/src/init-generator.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
import { readFileSync, writeFileSync } from "fs";

import { CustomGenerator, InitGeneratorOptions, CustomGeneratorOptions } from "./types";
import { getInstaller, getTemplate } from "./utils/helpers";
Expand All @@ -19,20 +19,6 @@ export default class InitGenerator<
}

public async prompting(): Promise<void> {
if (!existsSync(this.generationPath)) {
this.cli.logger.log(
`${this.cli.colors.blue(
"ℹ INFO ",
)} supplied generation path doesn't exist, required folders will be created.`,
);
try {
mkdirSync(this.generationPath, { recursive: true });
} catch (error) {
this.cli.logger.error(`Failed to create directory.\n ${error}`);
process.exit(2);
}
}
Comment on lines -22 to -34
Copy link
Copy Markdown
Member Author

@snitin315 snitin315 Sep 24, 2022

Choose a reason for hiding this comment

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

This is now handled by the yeoman-generator itself. I've updated the test cases accordingly.


this.template = await getTemplate.call(this);

await handlers[this.template as keyof typeof handlers].questions(this, Question);
Expand Down
6 changes: 3 additions & 3 deletions test/init/init.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ describe("init command", () => {
const assetsPath = path.resolve(os.tmpdir(), Date.now().toString());
const { stdout, stderr } = await run(__dirname, ["init", assetsPath, "--force"]);

expect(stdout).toContain("generation path doesn't exist, required folders will be created.");
expect(stdout).toContain("Project has been initialised with webpack!");
expect(stderr).toContain(`create ${path.relative(__dirname, assetsPath)}`);
expect(stderr).toContain("webpack.config.js");

// Test files
Expand All @@ -98,8 +98,8 @@ describe("init command", () => {
const assetsPath = path.resolve(os.tmpdir(), Date.now().toString());
const { stdout, stderr } = await run(__dirname, ["init", assetsPath, "--force"]);

expect(stdout).toContain("generation path doesn't exist, required folders will be created.");
expect(stdout).toContain("Project has been initialised with webpack!");
expect(stderr).toContain(`create ${path.relative(__dirname, assetsPath)}`);
expect(stderr).toContain("webpack.config.js");

// Test files
Expand Down Expand Up @@ -512,7 +512,7 @@ describe("init command", () => {
const { exitCode, stderr } = await run(projectPath, ["init", "my-app"], { reject: false });

expect(exitCode).toBe(2);
expect(stderr).toContain("Failed to create directory");
expect(stderr).toContain("Failed to initialize the project.");
});

it("should work with 'new' alias", async () => {
Expand Down
Loading