Skip to content

Commit

Permalink
Merge pull request #9899 from murdos/npmrc-save-exact
Browse files Browse the repository at this point in the history
feat: generate clients with a .npmrc config for forcing saving exact versions of npm dependencies
  • Loading branch information
pascalgrimaud authored May 25, 2024
2 parents e72fc32 + e48c60c commit 55e366c
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package tech.jhipster.lite.generator.client.angular.core.domain;

import static tech.jhipster.lite.module.domain.JHipsterModule.*;
import static tech.jhipster.lite.module.domain.packagejson.VersionSource.*;
import static tech.jhipster.lite.module.domain.packagejson.VersionSource.ANGULAR;

import tech.jhipster.lite.generator.client.common.domain.ClientsModulesFactory;
import tech.jhipster.lite.module.domain.Indentation;
Expand All @@ -14,7 +14,7 @@ public class AngularModuleFactory {

private static final JHipsterSource SOURCE = from("client/angular/core");

private static final JHipsterSource COMMON_ESLINT = from("client/common/eslint");
private static final JHipsterSource COMMON = from("client/common");

private static final String ENGINES_NEEDLE = " \"engines\":";
private static final PackageName ANGULAR_CORE_PACKAGE = packageName("@angular/core");
Expand Down Expand Up @@ -75,7 +75,10 @@ public JHipsterModule buildModule(JHipsterModuleProperties properties) {
.add(SOURCE.file("tsconfig.json"), to("tsconfig.json"))
.add(SOURCE.file("tsconfig.app.json"), to("tsconfig.app.json"))
.add(SOURCE.file(".eslintrc.json"), to(".eslintrc.json"))
.add(COMMON_ESLINT.file(".eslintignore"), to(".eslintignore"))
.batch(COMMON, to("."))
.addFile(".eslintignore")
.addFile(".npmrc")
.and()
.batch(SOURCE, to("."))
.addTemplate("proxy.conf.json")
.addTemplate("jest.conf.js")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class ReactCoreModulesFactory {
private static final JHipsterSource SOURCE = from("client/react");

private static final JHipsterSource WEBAPP_SOURCE = SOURCE.append("src/main/webapp");
private static final JHipsterSource COMMON_ESLINT = from("client/common/eslint");
private static final JHipsterSource COMMON = from("client/common");
private static final JHipsterDestination WEBAPP_DESTINATION = to("src/main/webapp");

private static final JHipsterSource APP_SOURCE = WEBAPP_SOURCE.append("app");
Expand Down Expand Up @@ -67,8 +67,9 @@ public JHipsterModule buildModule(JHipsterModuleProperties properties) {
.addTemplate("vitest.config.ts")
.addFile(".eslintrc.cjs")
.and()
.batch(COMMON_ESLINT, to("."))
.batch(COMMON, to("."))
.addFile(".eslintignore")
.addFile(".npmrc")
.and()
.batch(APP_SOURCE, APP_DESTINATION)
.addTemplate("index.css")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package tech.jhipster.lite.generator.client.svelte.core.domain;

import static tech.jhipster.lite.generator.client.common.domain.ClientsModulesFactory.*;
import static tech.jhipster.lite.generator.client.common.domain.ClientsModulesFactory.clientModuleBuilder;
import static tech.jhipster.lite.module.domain.JHipsterModule.*;
import static tech.jhipster.lite.module.domain.packagejson.VersionSource.*;
import static tech.jhipster.lite.module.domain.packagejson.VersionSource.SVELTE;

import tech.jhipster.lite.module.domain.Indentation;
import tech.jhipster.lite.module.domain.JHipsterModule;
Expand All @@ -19,7 +19,7 @@ public class SvelteModuleFactory {

private static final JHipsterSource PRIMARY_MAIN_SOURCE = SOURCE.append("src/main/webapp/app/common/primary/app");
private static final JHipsterDestination PRIMARY_MAIN_DESTINATION = to("src/main/webapp/app/common/primary/app");
private static final JHipsterSource COMMON_ESLINT = from("client/common/eslint");
private static final JHipsterSource COMMON = from("client/common");

private static final JHipsterSource PRIMARY_TEST_SOURCE = SOURCE.append("src/test/spec/common/primary/app");
private static final JHipsterDestination PRIMARY_TEST_DESTINATION = to("src/test/javascript/spec/common/primary/app");
Expand Down Expand Up @@ -85,7 +85,10 @@ public JHipsterModule buildSvelteModule(JHipsterModuleProperties properties) {
.add(SOURCE.append("src/main/webapp/routes").template("+page.svelte"), to("src/main/webapp/routes/+page.svelte"))
.add(PRIMARY_MAIN_SOURCE.template("App.svelte"), PRIMARY_MAIN_DESTINATION.append("App.svelte"))
.add(PRIMARY_TEST_SOURCE.template("App.spec.ts"), PRIMARY_TEST_DESTINATION.append("App.spec.ts"))
.add(COMMON_ESLINT.file(".eslintignore"), to(".eslintignore"))
.batch(COMMON, to("."))
.addFile(".eslintignore")
.addFile(".npmrc")
.and()
.move(path(".lintstagedrc.js"), to(".lintstagedrc.cjs"))
.batch(SOURCE, to("."))
.addTemplate("svelte.config.js")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class VueModulesFactory {
private static final JHipsterSource IMAGE_SOURCE = SOURCE.append("webapp/content/images");
private static final JHipsterSource COMMON_PRIMARY_SOURCE = SOURCE.append("webapp/app/common/primary");
private static final JHipsterSource COMMON_PRIMARY_TEST_SOURCE = SOURCE.append("test/spec/common/primary");
private static final JHipsterSource COMMON_ESLINT = from("client/common/eslint");
private static final JHipsterSource COMMON = from("client/common");

private static final JHipsterDestination MAIN_DESTINATION = to("src/main/webapp/app");
private static final JHipsterDestination TEST_DESTINATION = to("src/test/javascript/spec");
Expand Down Expand Up @@ -81,7 +81,10 @@ public JHipsterModule buildVueModule(JHipsterModuleProperties properties) {
.addTemplate("vite.config.mts")
.addTemplate("vitest.config.mts")
.and()
.add(COMMON_ESLINT.file(".eslintignore"), to(".eslintignore"))
.batch(COMMON, to("."))
.addFile(".eslintignore")
.addFile(".npmrc")
.and()
.batch(SOURCE.file("test/spec/http"), to("src/test/javascript/spec/http"))
.addTemplate("AxiosHttp.spec.ts")
.addTemplate("AxiosHttpStub.ts")
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/generator/client/common/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
save-exact=true
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ void shouldCreateAngularModule() {
"tsconfig.app.json",
"tsconfig.spec.json",
"proxy.conf.json",
".npmrc",
".eslintignore",
".eslintrc.json"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void shouldBuildModuleWithStyle() {
"""
)
.and()
.hasFiles("tsconfig.json", "vite.config.ts", "vitest.config.ts", ".eslintignore", ".eslintrc.cjs")
.hasFiles("tsconfig.json", "vite.config.ts", "vitest.config.ts", ".npmrc", ".eslintignore", ".eslintrc.cjs")
.hasFiles("src/main/webapp/index.html")
.hasPrefixedFiles("src/main/webapp/app", "index.css", "index.tsx", "vite-env.d.ts")
.hasFiles("src/test/javascript/spec/common/primary/app/App.spec.tsx")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void shouldCreateSvelteModule() {
.containing(nodeScript("test:watch", "vitest --"))
.containing("\"type\": \"module\"")
.and()
.hasFiles(".eslintignore", ".eslintrc.cjs", "tsconfig.json", "svelte.config.js", "vite.config.js", "vitest.config.ts")
.hasFiles(".eslintignore", ".eslintrc.cjs", ".npmrc", "tsconfig.json", "svelte.config.js", "vite.config.js", "vitest.config.ts")
.hasPrefixedFiles("src/main/webapp", "app.html", "app.d.ts")
.hasPrefixedFiles("src/main/webapp/routes", "+page.svelte")
.hasPrefixedFiles("src/test/javascript/spec/common/primary/app", "App.spec.ts")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void shouldCreateVueModule() {
"""
)
.and()
.hasPrefixedFiles("", ".eslintignore", ".eslintrc.js", "tsconfig.json", "tsconfig.build.json", "vite.config.mts", "vitest.config.mts")
.hasPrefixedFiles("", ".eslintignore", ".npmrc", ".eslintrc.js", "tsconfig.json", "tsconfig.build.json", "vite.config.mts", "vitest.config.mts")
.hasFiles("src/main/webapp/app/http/AxiosHttp.ts")
.hasPrefixedFiles("src/test/javascript/spec/http", "AxiosHttp.spec.ts", "AxiosHttpStub.ts", "AxiosStub.ts")
.hasFiles("src/main/webapp/index.html")
Expand Down

0 comments on commit 55e366c

Please sign in to comment.