Class FrontendStubs


  • public class FrontendStubs
    extends Object
    Utility class for stubbing Node.JS and Webpack scripts.
    • Method Detail

      • createStubNode

        public static void createStubNode​(FrontendStubs.ToolStubInfo stubNode,
                                          FrontendStubs.ToolStubInfo stubNpm,
                                          String baseDir)
                                   throws IOException
        Creates stub versions of `node` and `npm` in the ./node folder as frontend-maven-plugin does.
        Parameters:
        stubNode - node stub information, including whether `node/node` (`node/node.exe`) stub should be created, and what version should it output if '-v' || '--version' flag are set.
        stubNpm - npm stub information, including whether `node/node_modules/npm/bin/npm-cli` and `npx-cli` should be created, and what version should it output if '-v' || '--version' flag are set.
        baseDir - parent to create `node` dir in
        Throws:
        IOException - when a file operation fails
      • createStubNode

        public static void createStubNode​(boolean stubNode,
                                          boolean stubNpm,
                                          String baseDir)
                                   throws IOException
        Creates stub versions of `node` and `npm` in the ./node folder as frontend-maven-plugin does. This method creates a default stubs for tool's versions.
        Parameters:
        stubNode - whether `node/node` (`node/node.exe`) stub should be created
        stubNpm - whether `node/node_modules/npm/bin/npm-cli` and `npx-cli` should be created
        baseDir - parent to create `node` dir in
        Throws:
        IOException - when a file operation fails
      • createStubWebpackServer

        public static void createStubWebpackServer​(String readyString,
                                                   int milliSecondsToRun,
                                                   String baseDir,
                                                   boolean enableListening)
                                            throws IOException
        Creates a stub webpack-dev-server able to output a ready string, sleep for a while and output arguments passed to a file, so as tests can check it.
        Parameters:
        readyString - string to output
        milliSecondsToRun - time to keep the server running
        baseDir - parent directory
        enableListening - enable listening to port passed via `--port`
        Throws:
        IOException - when a file operation fails
      • createStubWebpackServer

        public static void createStubWebpackServer​(String readyString,
                                                   int milliSecondsToRun,
                                                   String baseDir)
                                            throws IOException
        Creates a stub webpack-dev-server able to output a ready string, sleep for a while and output arguments passed to a file, so as tests can check it.
        Parameters:
        readyString - string to output
        milliSecondsToRun - time to keep the server running
        baseDir - parent directory
        Throws:
        IOException - when a file operation fails
      • createStubViteServer

        public static void createStubViteServer​(String readyString,
                                                int milliSecondsToRun,
                                                String baseDir,
                                                boolean enableListening)
                                         throws IOException
        Creates a stub vite-dev-server able to output a ready string, sleep for a while and output arguments passed to a file, so as tests can check it.
        Parameters:
        readyString - string to output
        milliSecondsToRun - time to keep the server running
        baseDir - parent directory
        enableListening - enable listening to port passed via `--port`
        Throws:
        IOException - when a file operation fails
      • createStubViteServer

        public static void createStubViteServer​(String readyString,
                                                int milliSecondsToRun,
                                                String baseDir)
                                         throws IOException
        Creates a stub vite-dev-server able to output a ready string, sleep for a while and output arguments passed to a file, so as tests can check it.
        Parameters:
        readyString - string to output
        milliSecondsToRun - time to keep the server running
        baseDir - parent directory
        Throws:
        IOException - when a file operation fails