-
Notifications
You must be signed in to change notification settings - Fork 528
fix: bump npm infrastructure dependencies and make sure changing serve.js content is applied #2542
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
nedtwigg
merged 7 commits into
diffplug:main
from
simschla:bugfix/bump-versioning-for-js-based-steps
Jul 7, 2025
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f6ebe92
chore: bump/replace server deps
simschla fea6e81
fix: use correct variable name in error case
simschla c93a158
chore: bump internal version number(s)
simschla 8815367
chore: make sure to calculate different hashes if serve-files change
simschla 5f6880f
chore: assert new expected behaviour in test
simschla 7572d5f
chore: implement PR feedback
simschla 3bfd0ae
docs: note changes in changelog
simschla File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
lib/src/test/java/com/diffplug/spotless/npm/NodeServerLayoutTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| /* | ||
| * Copyright 2025 DiffPlug | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package com.diffplug.spotless.npm; | ||
|
|
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| import java.io.File; | ||
| import java.io.IOException; | ||
| import java.util.Collections; | ||
| import java.util.Map; | ||
|
|
||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| import com.diffplug.spotless.ResourceHarness; | ||
|
|
||
| class NodeServerLayoutTest extends ResourceHarness { | ||
|
|
||
| @Test | ||
| void itCalculatesSameNodeModulesDirForSameContent() throws IOException { | ||
| File testDir = newFolder("build"); | ||
| String packageJsonContent = prettierPackageJson(Collections.emptyMap()); | ||
| String serveJsContent = "fun main() { console.log('Hello, world!'); }"; | ||
| NodeServerLayout layout1 = new NodeServerLayout(testDir, packageJsonContent, serveJsContent); | ||
| NodeServerLayout layout2 = new NodeServerLayout(testDir, packageJsonContent, serveJsContent); | ||
|
|
||
| assertThat(layout1.nodeModulesDir()).isEqualTo(layout2.nodeModulesDir()); | ||
| } | ||
|
|
||
| @Test | ||
| void itCalculatesDifferentNodeModulesDirForDifferentPackageJson() throws IOException { | ||
| File testDir = newFolder("build"); | ||
| String packageJsonContent1 = prettierPackageJson(Collections.singletonMap("prettier-plugin-xy", "^2.0.0")); | ||
| String packageJsonContent2 = prettierPackageJson(Collections.singletonMap("prettier-plugin-xy", "^2.1.0")); | ||
| String serveJsContent = "fun main() { console.log('Hello, world!'); }"; | ||
|
|
||
| NodeServerLayout layout1 = new NodeServerLayout(testDir, packageJsonContent1, serveJsContent); | ||
| NodeServerLayout layout2 = new NodeServerLayout(testDir, packageJsonContent2, serveJsContent); | ||
|
|
||
| assertThat(layout1.nodeModulesDir()).isNotEqualTo(layout2.nodeModulesDir()); | ||
| } | ||
|
|
||
| @Test | ||
| void itCalculatesDifferentNodeModulesDirForDifferentServeJs() throws IOException { | ||
| File testDir = newFolder("build"); | ||
| String packageJsonContent = prettierPackageJson(Collections.emptyMap()); | ||
| String serveJsContent1 = "fun main() { console.log('Hello, world!'); }"; | ||
| String serveJsContent2 = "fun main() { console.log('Goodbye, world!'); }"; | ||
|
|
||
| NodeServerLayout layout1 = new NodeServerLayout(testDir, packageJsonContent, serveJsContent1); | ||
| NodeServerLayout layout2 = new NodeServerLayout(testDir, packageJsonContent, serveJsContent2); | ||
|
|
||
| assertThat(layout1.nodeModulesDir()).isNotEqualTo(layout2.nodeModulesDir()); | ||
| } | ||
|
|
||
| static String prettierPackageJson(Map<String, String> dependencies) { | ||
| String templateContent = NpmResourceHelper.readUtf8StringFromClasspath(NodeServerLayoutTest.class, "/com/diffplug/spotless/npm/prettier-package.json"); | ||
| String dependenciesList = dependencies.entrySet().stream() | ||
| .map(entry -> String.format("\"%s\": \"%s\"", entry.getKey(), entry.getValue())) | ||
| .reduce((a, b) -> a + ",\n " + b) | ||
| .orElse(""); | ||
|
|
||
| return templateContent.replace("${devDependencies}", dependenciesList); | ||
| } | ||
| } |
38 changes: 38 additions & 0 deletions
38
lib/src/test/java/com/diffplug/spotless/npm/NpmResourceHelperTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| /* | ||
| * Copyright 2025 DiffPlug | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package com.diffplug.spotless.npm; | ||
|
|
||
| import static com.diffplug.selfie.Selfie.expectSelfie; | ||
|
|
||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| class NpmResourceHelperTest { | ||
|
|
||
| @Test | ||
| void itCalculatesMd5ForSingleString() { | ||
| String input = "Hello, World!"; | ||
|
|
||
| expectSelfie(NpmResourceHelper.md5(input)).toBe("65a8e27d8879283831b664bd8b7f0ad4"); | ||
| } | ||
|
|
||
| @Test | ||
| void itCalculatesMd5ForMultipleStrings() { | ||
| String input1 = "Hello, World!"; | ||
| String input2 = "Hello, Spencer!"; | ||
|
|
||
| expectSelfie(NpmResourceHelper.md5(input1, input2)).toBe("371ba0fbf3d73b33e71b4af8dc6afe00"); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.