Skip to main content

Engineer

warning

Engineer and engine-scripts are being deprecated in favor of Engineer CLI

The engineer is the CLI tool of the engine, It's responsible to start (in dev mode), build and run engine applications.

The flow of the major 3 commands (start, build, run) can be summarized as follows:

start

1. analyze features

  1. We will locate all the features in the current baseDir (by default process.cwd()). Features located by file name conventions and directories. It will take the current baseDir and (if provided, either from [[engine config|utils.engineer.config]] or through a cli argument) the featureDiscoveryRoot, and will look for files with the *.feature.(t|j)s files in 3 places inside there: a. current root b. feature folder (currently only 1 level deep) c. fixtures folder (currently only 2 levels deep)

  2. After locating all feature files, we will analyze them. we will locate all dependent features, exported environments, resolved contexts for every feature and contextual environment declared and location of setup and context files for every feature and environment

2. running node environments

If a feature flag is provided to the cli, it will run all the environments which needs to be executed in a node process for that feature. We have 3 methods of running them - same-server, new-server, forked, and these methods apply to all node environments launchings, and are set either from [[engine config|utils.engineer.config]] or through a cli argument name nodeEnvironmentsMode.

Every node environment launched as a socket server environment, and it's address is used as an entrypoint for every other environment trying to communicate with it.

3. compiling all browser environments

Will create a webpack compiler, and for every browser environment found (window|iframe|webworker|electron-renderer) will generate an entry, which when evaluated will run a method which will parse from the URL params the feature name (feature param) and the config name (config param) and will start the engine application with the provided feature, on that environment.

  • engineer will use the webpack.config located in the baseDir to bundle the entry it generates for each environments.

  • the values provided to the --feature or the --config flags will be used as the default features, so that if no URL params were passed, these are the feature and the configuration the engine application of that environment will start with.

  • if the feature and --singleFeature flags are provided, only this feature and it's dependencies will be included in the bundle for every environment that is used for this feature.

Generated by engineer entrypoint

Each entrypoint generated by engineer for every environment, is a js file, with the name of the environment, which purpose is to load all context, environment specifig setup and feature files into that bundle.

For any iframe, window or react-renderer environment an html is also created, which imports the bundle in a script tag in the head.

Each entrypoint will fetch from a url (by default /configs) the configuration provided by the config URL param (or cli flag).

The engineer dev server or the run command will respond to these requests and return the configuration for that environment.

If the current running feature has running node environments, the mentioned above servers will also respond with a configuration to the communication feature which states the topology. This data is later used by The socket client initializer to connect browser environment and node environments launched in the previous step

5. if --feature flag is provided, open browser with relevant query parameters

build

  1. Analyze Features

  2. Compile Web entrypoints

  3. Generate a manifest file.

This file will store the results of the feature analysis, to later be consumed by the run phase. It will also store some metadata like the provided feature name and config name

run

  1. Read and analyze the Manifest file

  2. Run node environments

  3. Open the browser for the selected feature