Skip to content

Commit 7c9ece2

Browse files
snitin315alexander-akait
authored andcommitted
chore: update yeoman-generator to v5 (#3421)
1 parent bbd41c9 commit 7c9ece2

File tree

5 files changed

+59
-1258
lines changed

5 files changed

+59
-1258
lines changed

packages/generators/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"dependencies": {
2828
"webpack-cli": "^4.10.0",
2929
"yeoman-environment": "^3.9.1",
30-
"yeoman-generator": "^4.12.0"
30+
"yeoman-generator": "^5.7.0"
3131
},
3232
"peerDependencies": {
3333
"webpack": "5.x.x",

packages/generators/src/addon-generator.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ import { CustomGenerator } from "./types";
66
import type { CustomGeneratorOptions, BaseCustomGeneratorOptions } from "./types";
77
import { getInstaller, getTemplate } from "./utils/helpers";
88

9+
// eslint-disable-next-line @typescript-eslint/no-var-requires
10+
Object.assign(Generator.prototype, require("yeoman-generator/lib/actions/install"));
11+
912
// Helper to get the template-directory content
1013
const getFiles = (dir: string): string[] => {
1114
return fs.readdirSync(dir).reduce((list, file) => {

packages/generators/src/init-generator.ts

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
1+
import { readFileSync, writeFileSync } from "fs";
22

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

2121
public async prompting(): Promise<void> {
22-
if (!existsSync(this.generationPath)) {
23-
this.cli.logger.log(
24-
`${this.cli.colors.blue(
25-
"ℹ INFO ",
26-
)} supplied generation path doesn't exist, required folders will be created.`,
27-
);
28-
try {
29-
mkdirSync(this.generationPath, { recursive: true });
30-
} catch (error) {
31-
this.cli.logger.error(`Failed to create directory.\n ${error}`);
32-
process.exit(2);
33-
}
34-
}
35-
3622
this.template = await getTemplate.call(this);
3723

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

test/init/init.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ describe("init command", () => {
8181
const assetsPath = path.resolve(os.tmpdir(), Date.now().toString());
8282
const { stdout, stderr } = await run(__dirname, ["init", assetsPath, "--force"]);
8383

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

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

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

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

514514
expect(exitCode).toBe(2);
515-
expect(stderr).toContain("Failed to create directory");
515+
expect(stderr).toContain("Failed to initialize the project.");
516516
});
517517

518518
it("should work with 'new' alias", async () => {

0 commit comments

Comments
 (0)