use of com.vaadin.experimental.FeatureFlags in project flow by vaadin.
the class BuildFrontendUtil method runFrontendBuild.
/**
* Execute the frontend build with the wanted build system.
*
* @param adapter
* - the PluginAdapterBase.
* @throws TimeoutException
* - while running build system
* @throws URISyntaxException
* - while parsing nodeDownloadRoot()) to URI
*/
public static void runFrontendBuild(PluginAdapterBase adapter) throws TimeoutException, URISyntaxException {
ClassFinder classFinder = adapter.getClassFinder();
Lookup lookup = adapter.createLookup(classFinder);
final FeatureFlags featureFlags = new FeatureFlags(lookup);
featureFlags.setPropertiesLocation(adapter.javaResourceFolder());
FrontendToolsSettings settings = getFrontendToolsSettings(adapter);
FrontendTools tools = new FrontendTools(settings);
if (featureFlags.isEnabled(FeatureFlags.VITE)) {
BuildFrontendUtil.runVite(adapter, tools);
} else {
BuildFrontendUtil.runWebpack(adapter, tools);
}
}
use of com.vaadin.experimental.FeatureFlags in project flow by vaadin.
the class AbstractNodeUpdatePackagesTest method setup.
@Before
public void setup() throws Exception {
baseDir = temporaryFolder.getRoot();
featureFlags = Mockito.mock(FeatureFlags.class);
generatedDir = new File(baseDir, Paths.get(TARGET, DEFAULT_GENERATED_DIR).toString());
resourcesDir = new File(baseDir, Paths.get(TARGET, DEFAULT_FLOW_RESOURCES_FOLDER).toString());
FrontendStubs.createStubNode(true, true, baseDir.getAbsolutePath());
packageCreator = new TaskGeneratePackageJson(baseDir, generatedDir, resourcesDir, TARGET, featureFlags);
classFinder = Mockito.spy(getClassFinder());
File versions = temporaryFolder.newFile();
FileUtils.write(versions, "{}", StandardCharsets.UTF_8);
Mockito.when(classFinder.getResource(Constants.VAADIN_VERSIONS_JSON)).thenReturn(versions.toURI().toURL());
packageUpdater = new TaskUpdatePackages(classFinder, getScanner(classFinder), baseDir, generatedDir, resourcesDir, false, false, TARGET, featureFlags);
packageJson = new File(baseDir, PACKAGE_JSON);
mainNodeModules = new File(baseDir, FrontendUtils.NODE_MODULES);
appNodeModules = new File(generatedDir, FrontendUtils.NODE_MODULES);
packageLock = new File(baseDir, "package-lock.json");
}
use of com.vaadin.experimental.FeatureFlags in project flow by vaadin.
the class BootstrapHandlerTest method enableViteFeature.
private void enableViteFeature(boolean productionMode) throws IOException {
VaadinContext vaadinContext = Mockito.mock(VaadinContext.class);
final Lookup lookup = Mockito.mock(Lookup.class);
ResourceProvider resourceProvider = Mockito.mock(ResourceProvider.class);
Mockito.when(lookup.lookup(ResourceProvider.class)).thenReturn(resourceProvider);
Mockito.when(resourceProvider.getClientResourceAsStream("META-INF/resources/" + ApplicationConstants.CLIENT_ENGINE_PATH + "/compile.properties")).thenReturn(getClass().getClassLoader().getResourceAsStream("META-INF/resources/" + ApplicationConstants.CLIENT_ENGINE_PATH + "/compile.properties"));
Mockito.when(vaadinContext.getAttribute(Lookup.class)).thenReturn(lookup);
service.setContext(vaadinContext);
ApplicationConfiguration configuration = Mockito.mock(ApplicationConfiguration.class);
Mockito.when(configuration.isProductionMode()).thenReturn(false);
Mockito.when(configuration.getJavaResourceFolder()).thenReturn(tmpDir.getRoot());
Mockito.when(lookup.lookup(ApplicationConfiguration.class)).thenReturn(configuration);
Mockito.when(vaadinContext.getAttribute(ApplicationConfiguration.class)).thenReturn(configuration);
Mockito.when(vaadinContext.getAttribute(Mockito.eq(ApplicationConfiguration.class), Mockito.any())).thenReturn(configuration);
final FeatureFlags featureFlags = FeatureFlags.get(testUI.getSession().getService().getContext());
Mockito.when(vaadinContext.getAttribute(FeatureFlags.class)).thenReturn(featureFlags);
featureFlags.setEnabled(FeatureFlags.VITE.getId(), true);
Mockito.when(configuration.isProductionMode()).thenReturn(productionMode);
}
use of com.vaadin.experimental.FeatureFlags in project flow by vaadin.
the class ComponentFlagsTest method before.
@Before
public void before() throws IOException {
tmpRoot = temporaryFolder.getRoot();
propertiesDir = temporaryFolder.newFolder();
featureFlags = new FeatureFlags(Mockito.mock(Lookup.class));
featureFlags.setPropertiesLocation(propertiesDir);
frontendDirectory = new File(tmpRoot, DEFAULT_FRONTEND_DIR);
nodeModulesPath = new File(tmpRoot, NODE_MODULES);
generatedPath = new File(tmpRoot, Paths.get(TARGET, DEFAULT_GENERATED_DIR).toString());
importsFile = new File(generatedPath, IMPORTS_NAME);
assertTrue(nodeModulesPath.mkdirs());
createExpectedImports(frontendDirectory, nodeModulesPath);
}
use of com.vaadin.experimental.FeatureFlags in project flow by vaadin.
the class NodeUpdatePackagesNpmVersionLockingTest method setup.
@Before
public void setup() throws Exception {
baseDir = temporaryFolder.getRoot();
featureFlags = Mockito.mock(FeatureFlags.class);
generatedDir = new File(baseDir, Paths.get(TARGET, DEFAULT_GENERATED_DIR).toString());
resourcesDir = new File(baseDir, Paths.get(TARGET, DEFAULT_FLOW_RESOURCES_FOLDER).toString());
FrontendStubs.createStubNode(true, true, baseDir.getAbsolutePath());
classFinder = Mockito.spy(getClassFinder());
File versions = temporaryFolder.newFile();
FileUtils.write(versions, String.format("{" + "\"vaadin-overlay\": {" + "\"npmName\": \"@vaadin/vaadin-overlay\"," + "\"jsVersion\": \"%s\"" + "}" + "}", PLATFORM_PINNED_DEPENDENCY_VERSION), StandardCharsets.UTF_8);
// @formatter:on
Mockito.when(classFinder.getResource(Constants.VAADIN_VERSIONS_JSON)).thenReturn(versions.toURI().toURL());
}
Aggregations