Skip to content

Commit

Permalink
Merge pull request jhipster#11036 from Gnuk/add-prettier-pug-plugin
Browse files Browse the repository at this point in the history
Add prettier pug plugin on Tikui
  • Loading branch information
murdos authored Oct 3, 2024
2 parents ebe5ee2 + 37edfbe commit 1aaa398
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public JHipsterModule buildModule(JHipsterModuleProperties properties) {
return moduleBuilder(properties)
.packageJson()
.addDependency(packageName("@tikui/core"), COMMON)
.addDevDependency(packageName("@prettier/plugin-pug"), COMMON)
.addDevDependency(packageName("stylelint"), COMMON)
.addDevDependency(packageName("stylelint-config-concentric-order"), COMMON)
.addDevDependency(packageName("stylelint-config-standard-scss"), COMMON)
Expand Down Expand Up @@ -126,6 +127,9 @@ public JHipsterModule buildModule(JHipsterModuleProperties properties) {
.in(path("src/main/webapp/index.html"))
.add(lineBeforeText("</head>"), tikuiLink(properties))
.and()
.in(path(".prettierrc"))
.add(lineAfterText("plugins:"), pugPlugin(properties))
.and()
.and()
.gitIgnore()
.pattern(".tikui-cache")
Expand All @@ -149,6 +153,10 @@ private String tikuiLink(JHipsterModuleProperties properties) {
return properties.indentation().times(2) + "<link rel=\"stylesheet\" href=\"/style/tikui.css\" />";
}

private String pugPlugin(JHipsterModuleProperties properties) {
return properties.indentation().times(1) + "- '@prettier/plugin-pug'";
}

private static String newProxyForStyle(JHipsterModuleProperties properties) {
return new StringBuilder()
.append(properties.indentation().times(2))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"devDependencies": {
"@babel/cli": "7.25.6",
"@playwright/test": "1.47.2",
"@prettier/plugin-pug": "3.1.0",
"@prettier/plugin-xml": "3.4.1",
"@tikui/core": "6.2.0",
"@tsconfig/recommended": "1.0.7",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,34 @@ class TikuiModuleFactoryTest {

private static final TikuiModuleFactory factory = new TikuiModuleFactory();

@Nested
class PrettierTest {

@Test
void shouldBuildModuleWithPugFormat() {
JHipsterModuleProperties properties = propertiesBuilder(TestFileUtils.tmpDirForTest()).build();

JHipsterModule module = factory.buildModule(properties);

assertThatModuleWithFiles(module, packageJsonFile(), prettierConfigFile())
.hasFile("package.json")
.containing(nodeDependency("@prettier/plugin-pug"))
.and()
.hasFile(".prettierrc")
.containing(prettierConfig());
}

private static ModuleFile prettierConfigFile() {
return file("src/main/resources/generator/prettier/.prettierrc.mustache", ".prettierrc");
}

private static String prettierConfig() {
return """
- '@prettier/plugin-pug'
""";
}
}

@Nested
class VueTest {

Expand Down

0 comments on commit 1aaa398

Please sign in to comment.