-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add package-lock.json for hybrid apps to dev-bundle
A 'hybrid-package-lock.json', containing also Hilla dependencies, is added to the vaadin-dev-bundle artifact, so that Flow can chose the appropriate lock file based on the project configuration. Part of vaadin/flow#19298
- Loading branch information
1 parent
3d8a138
commit 22a5a06
Showing
15 changed files
with
331 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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 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 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 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 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
171 changes: 171 additions & 0 deletions
171
scripts/generator/templates/template-hybrid-dev-bundle-pom.xml
This file contains 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,171 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>com.vaadin</groupId> | ||
<artifactId>vaadin-platform-parent</artifactId> | ||
<version>{{platform}}</version> | ||
</parent> | ||
<artifactId>vaadin-hybrid-dev-bundle</artifactId> | ||
<packaging>jar</packaging> | ||
<name>Vaadin Hybrid Dev Bundle</name> | ||
<description>Vaadin Hybrid Dev Bundle</description> | ||
<url>https://vaadin.com</url> | ||
|
||
<distributionManagement> | ||
<repository> | ||
<id>vaadin-prereleases</id> | ||
<url>https://maven.vaadin.com/vaadin-prereleases/</url> | ||
</repository> | ||
</distributionManagement> | ||
|
||
<properties> | ||
{{javadeps}} | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.vaadin</groupId> | ||
<artifactId>vaadin-internal</artifactId> | ||
<version>${project.version}</version> | ||
<optional>true</optional> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.vaadin</groupId> | ||
<artifactId>hilla-dev</artifactId> | ||
<version>${hilla.version}</version> | ||
<optional>true</optional> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.vaadin</groupId> | ||
<artifactId>hilla</artifactId> | ||
<version>${hilla.version}</version> | ||
<optional>true</optional> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.vaadin</groupId> | ||
<artifactId>vaadin-spreadsheet-flow</artifactId> | ||
<version>${vaadin.spreadsheet.version}</version> | ||
<optional>true</optional> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.vaadin</groupId> | ||
<artifactId>vaadin-dev-server</artifactId> | ||
<version>${flow.version}</version> | ||
<optional>true</optional> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.vaadin</groupId> | ||
<artifactId>copilot</artifactId> | ||
<version>${copilot.version}</version> | ||
<optional>true</optional> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-simple</artifactId> | ||
<version>2.0.0</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-api</artifactId> | ||
<version>2.0.0</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-api</artifactId> | ||
<version>${junit.jupiter.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter</artifactId> | ||
<version>${junit.jupiter.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<version>3.3.0</version> | ||
<configuration> | ||
<excludes> | ||
<exclude>**/*Fake*</exclude> | ||
</excludes> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>com.vaadin</groupId> | ||
<artifactId>flow-dev-bundle-plugin</artifactId> | ||
<version>${flow.version}</version> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>build-dev-bundle</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-resources-plugin</artifactId> | ||
<version>3.0.2</version> | ||
<executions> | ||
<execution> | ||
<id>copy-dev-bundle-to-target</id> | ||
<phase>prepare-package</phase> | ||
<goals> | ||
<goal>copy-resources</goal> | ||
</goals> | ||
<configuration> | ||
<outputDirectory>${project.build.outputDirectory}/vaadin-dev-bundle</outputDirectory> | ||
<resources> | ||
<resource> | ||
<directory>${project.build.directory}/dev-bundle</directory> | ||
<excludes> | ||
<exclude>file-routes.json</exclude> | ||
</excludes> | ||
</resource> | ||
</resources> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-clean-plugin</artifactId> | ||
<version>3.2.0</version> | ||
<configuration> | ||
<filesets> | ||
<fileset> | ||
<directory>${project.basedir}/src/main/bundles</directory> | ||
</fileset> | ||
</filesets> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-antrun-plugin</artifactId> | ||
<version>3.0.0</version> | ||
<executions> | ||
<execution> | ||
<phase>prepare-package</phase> | ||
<goals> | ||
<goal>run</goal> | ||
</goals> | ||
<configuration> | ||
<target> | ||
<!-- Remove application class file, so as IT modules do not read @Theme annotations when | ||
maven configures the classpath for multimodule projects --> | ||
<delete dir="target/classes/com/vaadin/devbundle" includeemptydirs="true"></delete> | ||
</target> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
This file contains 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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
src/main/dev-bundle | ||
frontend/index.html | ||
src/main/bundles | ||
vite.*.ts |
This file contains 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,3 @@ | ||
frontend/index.html | ||
src/main/bundles | ||
vite.*.ts |
Empty file.
3 changes: 3 additions & 0 deletions
3
vaadin-hybrid-dev-bundle/frontend/themes/vaadin-dev-bundle/theme.json
This file contains 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,3 @@ | ||
{ | ||
"lumoImports": ["typography", "color", "spacing", "badge", "utility"] | ||
} |
This file contains 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 @@ | ||
const __dummy__ = "Fake view only used to trigger Hilla usage in frontend build"; |
11 changes: 11 additions & 0 deletions
11
vaadin-hybrid-dev-bundle/src/main/java/com/vaadin/devbundle/FakeAppConf.java
This file contains 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,11 @@ | ||
package com.vaadin.devbundle; | ||
|
||
import com.vaadin.flow.component.page.AppShellConfigurator; | ||
import com.vaadin.flow.server.PWA; | ||
import com.vaadin.flow.theme.Theme; | ||
|
||
@Theme("vaadin-dev-bundle") | ||
@PWA(name = "vaadin-dev-bundle", shortName = "vaadin-dev-bundle") | ||
public class FakeAppConf implements AppShellConfigurator{ | ||
|
||
} |
Empty file.
90 changes: 90 additions & 0 deletions
90
vaadin-hybrid-dev-bundle/src/test/java/com/vaadin/devbundle/BundleTest.java
This file contains 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,90 @@ | ||
package com.vaadin.devbundle; | ||
|
||
import java.io.IOException; | ||
import java.nio.charset.StandardCharsets; | ||
import java.nio.file.FileVisitResult; | ||
import java.nio.file.FileVisitor; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.nio.file.attribute.BasicFileAttributes; | ||
import java.util.concurrent.atomic.AtomicInteger; | ||
|
||
import org.apache.commons.io.FileUtils; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class BundleTest { | ||
|
||
@Test | ||
public void usageStatsIncluded() throws IOException { | ||
String needle = "StatisticsGatherer"; | ||
Path bundlerBuildFolder = Paths.get("target", "dev-bundle", "webapp", | ||
"VAADIN", "build"); | ||
|
||
int foundInFiles = findInFiles(bundlerBuildFolder, needle); | ||
Assertions.assertEquals(1, foundInFiles, | ||
"The key '" + needle + "' should be found in one file"); | ||
} | ||
@Test | ||
public void copilotIncluded() throws IOException { | ||
String needle = "copilot-main"; | ||
Path bundlerBuildFolder = Paths.get("target", "dev-bundle", "webapp", | ||
"VAADIN", "build"); | ||
|
||
int foundInFiles = findInFiles(bundlerBuildFolder, needle); | ||
Assertions.assertEquals(1, foundInFiles, | ||
"The key '" + needle + "' should be found in one file"); | ||
} | ||
@Test | ||
public void hillaIncluded() throws IOException { | ||
String needle = "@vaadin/hilla-frontend"; | ||
int foundInFiles = findInBundleBuildFolder(needle); | ||
Assertions.assertEquals(1, foundInFiles, | ||
"The key '" + needle + "' should be found in one file"); | ||
} | ||
|
||
private int findInBundleBuildFolder(String needle) throws IOException { | ||
Path bundlerBuildFolder = Paths.get("target", "dev-bundle", "webapp", | ||
"VAADIN", "build"); | ||
return findInFiles(bundlerBuildFolder, needle); | ||
} | ||
|
||
private int findInFiles(Path path, String needle) throws IOException { | ||
AtomicInteger foundInFiles = new AtomicInteger(); | ||
Files.walkFileTree(path, new FileVisitor<Path>() { | ||
|
||
@Override | ||
public FileVisitResult preVisitDirectory(Path dir, | ||
BasicFileAttributes attrs) throws IOException { | ||
return FileVisitResult.CONTINUE; | ||
} | ||
|
||
@Override | ||
public FileVisitResult visitFile(Path file, | ||
BasicFileAttributes attrs) throws IOException { | ||
String content = FileUtils.readFileToString(file.toFile(), | ||
StandardCharsets.UTF_8); | ||
if (content.contains(needle)) { | ||
foundInFiles.incrementAndGet(); | ||
} | ||
return FileVisitResult.CONTINUE; | ||
} | ||
|
||
@Override | ||
public FileVisitResult visitFileFailed(Path file, IOException exc) | ||
throws IOException { | ||
return FileVisitResult.CONTINUE; | ||
} | ||
|
||
@Override | ||
public FileVisitResult postVisitDirectory(Path dir, IOException exc) | ||
throws IOException { | ||
return FileVisitResult.CONTINUE; | ||
} | ||
|
||
}); | ||
return foundInFiles.get(); | ||
|
||
} | ||
} |
This file contains 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,3 @@ | ||
frontend/index.html | ||
src/main/bundles | ||
vite.*.ts |