Skip to content

Commit

Permalink
feat!: rename enableDevServer (#15759)
Browse files Browse the repository at this point in the history
Rename enableDevServer to
frontendHotdeploy as devServer
can at the moment mean too many things.

Part of #15743
  • Loading branch information
caalador committed Jan 26, 2023
1 parent 5d0fb3f commit 23c57c8
Show file tree
Hide file tree
Showing 28 changed files with 72 additions and 80 deletions.
2 changes: 1 addition & 1 deletion flow-client/eclipse/GWT tests.launch
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.vaadin.client.GwtSuite"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="flow-client"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.m2e.launchconfig.sourcepathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dgwt.args=&quot;-war target/www-test -logLevel INFO -prod -ea -sourceLevel 1.8 -runStyle HtmlUnit:FF38 -style PRETTY&quot; -Dvaadin.enableDevServer=false"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dgwt.args=&quot;-war target/www-test -logLevel INFO -prod -ea -sourceLevel 1.8 -runStyle HtmlUnit:FF38 -style PRETTY&quot; -Dvaadin.frontend.hotdeploy=false"/>
</launchConfiguration>
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public void tokenFileShouldExist_noDevModeTokenVisible()
}

@Test
public void existingTokenFile_enableDevServerShouldBeRemoved()
public void existingTokenFile_frontendHotdeployShouldBeRemoved()
throws IOException, MojoExecutionException, MojoFailureException {

JsonObject initialBuildInfo = Json.createObject();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public interface AbstractConfiguration extends Serializable {
*
* @return true if dev server should be used
*/
default boolean enableDevServer() {
default boolean frontendHotdeploy() {
if (isProductionMode()) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public class DefaultDeploymentConfiguration
private boolean syncIdCheck;
private boolean sendUrlsAsParameters;
private boolean requestTiming;
private boolean enableDevServer;
private boolean frontendHotdeploy;

private static AtomicBoolean logging = new AtomicBoolean(true);
private List<String> warnings = new ArrayList<>();
Expand Down Expand Up @@ -247,8 +247,8 @@ public PushMode getPushMode() {
}

@Override
public boolean enableDevServer() {
return enableDevServer;
public boolean frontendHotdeploy() {
return frontendHotdeploy;
}

/**
Expand Down Expand Up @@ -383,8 +383,8 @@ private void checkSendUrlsAsParameters() {
}

private void checkFrontendHotdeploy() {
enableDevServer = getBooleanProperty(InitParameters.FRONTEND_HOTDEPLOY,
DEFAULT_FRONTEND_HOTDEPLOY);
frontendHotdeploy = getBooleanProperty(
InitParameters.FRONTEND_HOTDEPLOY, DEFAULT_FRONTEND_HOTDEPLOY);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,11 @@ public boolean isProductionMode() {
}

@Override
public boolean enableDevServer() {
public boolean frontendHotdeploy() {
if (isOwnProperty(FRONTEND_HOTDEPLOY)) {
return getBooleanProperty(FRONTEND_HOTDEPLOY, false);
}
return parentConfig.enableDevServer();
return parentConfig.frontendHotdeploy();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ public boolean serveStaticResource(HttpServletRequest request,
deploymentConfiguration.getProjectFolder(),
"webapp/" + filenameInsideBundle);
} else if (APP_THEME_PATTERN.matcher(filenameWithPath).find()) {
if (!deploymentConfiguration.enableDevServer()) {
if (!deploymentConfiguration.frontendHotdeploy()) {
resourceUrl = findAssetInFrontendThemesOrDevBundle(
vaadinService,
deploymentConfiguration.getProjectFolder(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import com.vaadin.flow.function.DeploymentConfiguration;
import com.vaadin.flow.internal.DevModeHandler;
import com.vaadin.flow.internal.DevModeHandlerManager;
import com.vaadin.flow.internal.UsageStatistics;
import com.vaadin.flow.server.communication.FaviconHandler;
import com.vaadin.flow.server.communication.IndexHtmlRequestHandler;
import com.vaadin.flow.server.communication.PushRequestHandler;
Expand Down Expand Up @@ -86,7 +85,7 @@ protected List<RequestHandler> createRequestHandlers()
List<RequestHandler> handlers = super.createRequestHandlers();
handlers.add(0, new FaviconHandler());

if (getDeploymentConfiguration().enableDevServer()) {
if (getDeploymentConfiguration().frontendHotdeploy()) {
Optional<DevModeHandler> handlerManager = DevModeHandlerManager
.getDevModeHandler(this);
if (handlerManager.isPresent()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public boolean synchronizedHandleRequest(VaadinSession session,

configureHiddenElementStyles(indexDocument);

if (!config.enableDevServer()) {
if (!config.frontendHotdeploy()) {
addStylesCssLink(config, indexDocument);
}

Expand Down Expand Up @@ -413,7 +413,7 @@ private static Document getIndexHtmlDocument(VaadinService service)
if (config.isProductionMode()) {
// The index.html is fetched from the bundle so it includes the
// entry point javascripts
} else if (!service.getDeploymentConfiguration().enableDevServer()) {
} else if (!service.getDeploymentConfiguration().frontendHotdeploy()) {
// When running without a frontend server, the index.html comes
// directly from the frontend folder and the JS entrypoint(s) need
// to be added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,8 @@ && frontendFileExists(localModulePath)) {
}

boolean devModeWithoutServer = !options.productionMode
&& !options.isEnableDevServer() && !options.isDevBundleBuild();
&& !options.isFrontendHotdeploy()
&& !options.isDevBundleBuild();
if (!npmNotFound.isEmpty() && getLogger().isInfoEnabled()
&& !devModeWithoutServer) {
getLogger().info(notFoundMessage(npmNotFound,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
import java.util.List;
import java.util.Set;

import org.slf4j.LoggerFactory;

import com.vaadin.experimental.FeatureFlags;
import com.vaadin.flow.di.Lookup;
import com.vaadin.flow.internal.UsageStatistics;
Expand Down Expand Up @@ -158,7 +156,7 @@ public NodeTasks(Options options) {
addGenerateServiceWorkerTask(options,
frontendDependencies.getPwaConfiguration());

if (options.productionMode || options.isEnableDevServer()
if (options.productionMode || options.isFrontendHotdeploy()
|| options.isDevBundleBuild()) {
addGenerateTsConfigTask(options);
}
Expand Down Expand Up @@ -207,7 +205,7 @@ public NodeTasks(Options options) {
pwa = new PwaConfiguration();
}
commands.add(new TaskUpdateSettingsFile(options, themeName, pwa));
if (options.productionMode || options.isEnableDevServer()
if (options.productionMode || options.isFrontendHotdeploy()
|| options.isDevBundleBuild()) {
commands.add(new TaskUpdateVite(options));
}
Expand All @@ -230,7 +228,7 @@ public NodeTasks(Options options) {

private void addBootstrapTasks(Options options) {
commands.add(new TaskGenerateIndexHtml(options));
if (options.productionMode || options.isEnableDevServer()
if (options.productionMode || options.isFrontendHotdeploy()
|| options.isDevBundleBuild()) {
commands.add(new TaskGenerateIndexTs(options));
if (!options.productionMode) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.vaadin.experimental.FeatureFlags;
import com.vaadin.flow.server.Constants;
import com.vaadin.flow.server.frontend.scanner.ClassFinder;
import com.vaadin.flow.server.frontend.scanner.FrontendDependencies;
Expand Down Expand Up @@ -487,7 +486,8 @@ String writePackageFile(JsonObject json, File packageFile)
throws IOException {
String content = stringify(json, 2) + "\n";
if (packageFile.exists() || options.productionMode
|| options.isEnableDevServer() || options.isDevBundleBuild()) {
|| options.isFrontendHotdeploy()
|| options.isDevBundleBuild()) {
log().debug("writing file {}.", packageFile.getAbsolutePath());
FileUtils.forceMkdirParent(packageFile);
FileUtils.writeStringToFile(packageFile, content, UTF_8.name());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public class Options implements Serializable {

private FeatureFlags featureFlags;

private boolean enableDevServer = false;
private boolean frontendHotdeploy = false;

/**
* Creates a new instance.
Expand Down Expand Up @@ -542,12 +542,12 @@ public Options withProductionMode(boolean productionMode) {
/**
* Whether to run with a dev server (when not in production mode).
*
* @param enableDevServer
* @param frontendHotdeploy
* true to run with a dev server, false to run in express mode
* @return this builder
*/
public Options withEnableDevServer(boolean enableDevServer) {
this.enableDevServer = enableDevServer;
public Options withFrontendHotdeploy(boolean frontendHotdeploy) {
this.frontendHotdeploy = frontendHotdeploy;
return this;
}

Expand All @@ -556,8 +556,8 @@ public Options withEnableDevServer(boolean enableDevServer) {
*
* @return true to run with a dev server, false to run in express mode
*/
public boolean isEnableDevServer() {
return enableDevServer;
public boolean isFrontendHotdeploy() {
return frontendHotdeploy;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ protected File getGeneratedFile() {

@Override
protected boolean shouldGenerate() {
return options.productionMode || options.isEnableDevServer()
return options.productionMode || options.isFrontendHotdeploy()
|| options.isDevBundleBuild();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,14 @@
*/
package com.vaadin.flow.server;

import java.nio.file.Paths;
import java.util.Collections;
import java.util.Properties;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.mockito.MockedStatic;
import org.mockito.Mockito;

import com.vaadin.experimental.FeatureFlags;
import com.vaadin.flow.di.Lookup;
import com.vaadin.flow.server.frontend.installer.Platform;
import com.vaadin.flow.server.startup.ApplicationConfiguration;

import static org.junit.Assert.assertEquals;
Expand Down Expand Up @@ -224,17 +219,17 @@ public void isXsrfProtectionEnabled_valueIsSetViaParentOnlyAndViaParent_valueIsT
}

@Test
public void enableDevServerParameter_expressBuildFeatureFlagIsON_resetsEnableDevServerToFalse() {
public void frontendHotdeployParameter_expressBuildFeatureFlagIsON_resetsFrontendHotdeployToFalse() {
DefaultDeploymentConfiguration config = createDeploymentConfig(
new Properties());
Assert.assertFalse("Expected dev server to be disabled by default",
config.enableDevServer());
config.frontendHotdeploy());

Properties init = new Properties();
init.put(InitParameters.FRONTEND_HOTDEPLOY, "true");
config = createDeploymentConfig(init);
Assert.assertTrue("Expected dev server to be enabled when set true",
config.enableDevServer());
config.frontendHotdeploy());
}

private DefaultDeploymentConfiguration createDeploymentConfig(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ public void externalStatsFileTrue_predefinedValuesAreNotOverridden_productionMod

assertTrue(config.isProductionMode());
assertFalse("Dev server should be default false due to stats",
config.enableDevServer());
config.frontendHotdeploy());
assertTrue(config.isStatsExternal());
assertEquals(Constants.DEFAULT_EXTERNAL_STATS_URL,
config.getExternalStatsUrl());
Expand Down Expand Up @@ -654,7 +654,7 @@ private ApplicationConfiguration mockApplicationConfiguration() {
VaadinContext context = new MockVaadinContext();
ApplicationConfiguration configuration = Mockito
.mock(ApplicationConfiguration.class);
Mockito.when(configuration.enableDevServer()).thenReturn(true);
Mockito.when(configuration.frontendHotdeploy()).thenReturn(true);
Mockito.when(configuration.isProductionMode()).thenReturn(true);
Mockito.when(configuration.getContext()).thenReturn(context);
Mockito.when(configuration.getStringProperty(Mockito.anyString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ public MockServletServiceSessionSetup(boolean sessionAvailable)
.when(servletContext).getClassLoader();
Mockito.when(servletConfig.getServletContext())
.thenReturn(servletContext);
deploymentConfiguration.setEnableDevServer(false);
deploymentConfiguration.setFrontendHotdeploy(false);

Mockito.when(servletContext.getAttribute(Lookup.class.getName()))
.thenReturn(lookup);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ public void isProductionMode_modeIsProvidedViaPropertiesAndParent_valueFromPrope
}

@Test
public void enableDevServer_valueIsProvidedViaParentOnly_valueFromParentIsReturned() {
public void frontendHotdeploy_valueIsProvidedViaParentOnly_valueFromParentIsReturned() {
ApplicationConfiguration appConfig = mockAppConfig();
Mockito.when(appConfig.enableDevServer()).thenReturn(true);
Mockito.when(appConfig.frontendHotdeploy()).thenReturn(true);
PropertyDeploymentConfiguration config = createConfiguration(appConfig,
new Properties());
Assert.assertTrue(config.enableDevServer());
Assert.assertTrue(config.frontendHotdeploy());
// there is no any property
Assert.assertTrue(config.getInitParameters().isEmpty());
}
Expand Down Expand Up @@ -89,16 +89,16 @@ public void reuseDevServer_valueIsProvidedViaParentOnly_valueFromParentIsReturne
}

@Test
public void enableDevServer_valueIsProvidedViaPropertiesAndParent_valueIsAlwaysTrueIfExpressBuildIsOFF() {
public void frontendHotdeploy_valueIsProvidedViaPropertiesAndParent_valueIsAlwaysTrueIfExpressBuildIsOFF() {
ApplicationConfiguration appConfig = mockAppConfig();
Mockito.when(appConfig.enableDevServer()).thenReturn(false);
Mockito.when(appConfig.frontendHotdeploy()).thenReturn(false);

Properties properties = new Properties();
properties.put(InitParameters.FRONTEND_HOTDEPLOY,
Boolean.TRUE.toString());
PropertyDeploymentConfiguration config = createConfiguration(appConfig,
properties);
Assert.assertTrue(config.enableDevServer());
Assert.assertTrue(config.frontendHotdeploy());
Assert.assertEquals(properties, config.getInitParameters());
}

Expand Down Expand Up @@ -213,11 +213,11 @@ public void isProductionMode_modeIsProvidedViaParentOnly_propertyIsSetToAnotherV
}

@Test
public void enableDevServer_valueIsProvidedViaParentOnly_propertyIsSetToAnotherValue_valueFromParentIsReturnedViaAPI() {
public void frontendHotdeploy_valueIsProvidedViaParentOnly_propertyIsSetToAnotherValue_valueFromParentIsReturnedViaAPI() {
ApplicationConfiguration appConfig = mockAppConfig();

// The property value is provided via API
Mockito.when(appConfig.enableDevServer()).thenReturn(true);
Mockito.when(appConfig.frontendHotdeploy()).thenReturn(true);

// The property whose value is overridden above via API is different
Mockito.when(appConfig.getPropertyNames())
Expand All @@ -235,7 +235,7 @@ public void enableDevServer_valueIsProvidedViaParentOnly_propertyIsSetToAnotherV
// though its "getInitParameters" method returns the property. Also
// "getApplicationProperty" method checks the parent properties which
// should not be taken into account here
Assert.assertTrue(config.enableDevServer());
Assert.assertTrue(config.frontendHotdeploy());
Assert.assertTrue(config.getInitParameters()
.containsKey(InitParameters.FRONTEND_HOTDEPLOY));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1175,7 +1175,7 @@ public void serveStaticResource_projectThemeResourceRequest_serveFromFrontend()
TestUtil.createStyleCssStubInFrontend(projectRootFolder, "my-theme",
styles);

Mockito.when(configuration.enableDevServer()).thenReturn(false);
Mockito.when(configuration.frontendHotdeploy()).thenReturn(false);
Mockito.when(configuration.getProjectFolder())
.thenReturn(projectRootFolder);

Expand All @@ -1192,7 +1192,7 @@ public void serveStaticResource_externalThemeResourceRequest_serveFromBundle()
TestUtil.createStylesCssStubInBundle(projectRootFolder, "my-theme",
styles);

Mockito.when(configuration.enableDevServer()).thenReturn(false);
Mockito.when(configuration.frontendHotdeploy()).thenReturn(false);
Mockito.when(configuration.getProjectFolder())
.thenReturn(projectRootFolder);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public void setUp() throws Exception {
responseOutput = new ByteArrayOutputStream();
Mockito.when(response.getOutputStream()).thenReturn(responseOutput);
deploymentConfiguration = mocks.getDeploymentConfiguration();
deploymentConfiguration.setEnableDevServer(false);
deploymentConfiguration.setFrontendHotdeploy(false);
deploymentConfiguration.setProductionMode(true);
indexHtmlRequestHandler = new IndexHtmlRequestHandler();
context = Mockito.mock(VaadinServletContext.class);
Expand Down

0 comments on commit 23c57c8

Please sign in to comment.