Skip to content
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

fix: copy source maps for frontend resources #12701

Merged
merged 1 commit into from
Jan 13, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
*/
public class TaskCopyFrontendFiles implements FallibleCommand {
private static final String[] WILDCARD_INCLUSIONS = new String[] {
"**/*.js", "**/*.css", "**/*.ts" };
"**/*.js", "**/*.js.map", "**/*.css", "**/*.css.map", "**/*.ts",
"**/*.ts.map" };
private static final String WILDCARD_INCLUSION_APP_THEME_JAR = "**/themes/**/*";
private File targetDirectory;
private Set<File> resourceLocations = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ public void setup() throws IOException, ExecutionFailedException {
public void frontendResources_should_beCopiedFromJars_when_TaskUpdatePackagesRemovesThem()
throws IOException, ExecutionFailedException {
copyResources();
assertCopiedFrontendFileAmount(3);
assertCopiedFrontendFileAmount(6/* jar files */ + 1/* package.json */);

performPackageClean();
// Should keep the `package.json` file
assertCopiedFrontendFileAmount(1);

copyResources();
assertCopiedFrontendFileAmount(3);
assertCopiedFrontendFileAmount(6/* jar files */ + 1/* package.json */);
}

private void assertCopiedFrontendFileAmount(int fileCount)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,15 @@ private void should_collectJsAndCssFilesFromJars(String jarFile,

// contains:
// - ExampleConnector.js
// - ExampleConnector.js.map
// - inline.css
// - inline.css.map
// - example.ts
// - example.ts.map
File jar = TestUtils.getTestJar(jarFile);
// Contains:
// - resourceInFolder.js
// - resourceInFolder.js.map
File dir = TestUtils.getTestFolder(fsDir);

TaskCopyFrontendFiles task = new TaskCopyFrontendFiles(
Expand All @@ -100,17 +105,36 @@ private void should_collectJsAndCssFilesFromJars(String jarFile,
task.execute();

List<String> files = TestUtils.listFilesRecursively(frontendDepsFolder);
Assert.assertEquals(3, files.size());
Assert.assertEquals(8, files.size());

Assert.assertTrue("Js resource should have been copied from jar file",
Assert.assertTrue("TS resource should have been copied from jar file",
files.contains("example.ts"));

Assert.assertTrue(
"TS resource source map should have been copied from jar file",
files.contains("example.ts.map"));

Assert.assertTrue("JS resource should have been copied from jar file",
files.contains("ExampleConnector.js"));

Assert.assertTrue("Css resource should have been copied from jar file",
Assert.assertTrue(
"JS resource source map should have been copied from jar file",
files.contains("ExampleConnector.js.map"));

Assert.assertTrue("CSS resource should have been copied from jar file",
files.contains("inline.css"));

Assert.assertTrue(
"Js resource should have been copied from resource folder",
"CSS resource source map should have been copied from jar file",
files.contains("inline.css.map"));

Assert.assertTrue(
"JS resource should have been copied from resource folder",
files.contains("resourceInFolder.js"));

Assert.assertTrue(
"JS resource source map should have been copied from resource folder",
files.contains("resourceInFolder.js.map"));
}

private static Set<File> jars(File... files) {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified flow-server/src/test/resources/jar-with-frontend-resources.jar
Binary file not shown.
Binary file modified flow-server/src/test/resources/jar-with-modern-frontend.jar
Binary file not shown.