CID Design
First of all, CID is a generic framework for tool plugin processing.
Tool types
There are the following types of tool plugins:
- Generic (
SubTool
) - all plugins implement this interface. - Build (
BuildTool
) - plugins supportingcid build
procedure. - Test (
TestTool
) - plugins supportingcid check
procedure. - Migration (
MigrationTool
) - plugins supportingcid migrate
procedure. - VCS (
VcsTool
) - plugins supportingcid vcs
operations. - RMS (
RmsTool
) - plugins supportingcid rms
operations. - Runtime Environment (
RunEnvTool
) - plugins providing infrastructure to others (e.g. “nvm”). - Runtime (
RuntimeTool
) - plugins supporting execution of commands and services (e.g. “exe”, “node”, “java”)
Note: a single tool may implement more than one interface.
Global state
There is a single global tree-like state passed to plugins during invocation.
The details of this strictly defined state tree is available in futoin.json
description.
Some operations must not depend on project configuration - only .env
part is passed then.
Entry Points
Entry points are used to describe service runtime type, startup file and runtime tune. More details are in dedicated section.
Tool auto-detection
This behavior is triggered on demand.
- Tools used in entry points are marked as “detected”.
- If
.tools
is set then use it instead of auto detection. -
Otherwise:
- load all available plugins.
- walk through each tool and call its auto-detection API
- Add all dependencies of “detected” tools as “detected” too.
Tool dependencies
Usually, plugins require other plugins.
For example: grunt
requires npm
which requires node
which requires nvm
which requires bash
in turn.
CID automatically resolves all dependencies and initializes the plugins in order of the dependency chain.
Tool initialization
Each “detected” plugin may contribute own environment to the global state. If actual tool installation is not found or version constraint mismatches then plugin tries to install the tool and retry initalization.
Typically, tools contribute .{tool}Bin
and .{toolVer}
environment variables.
For example, nodeBin=/path/to/bin/node
and nodeVer=8
.
Tool API reference
Below are links to related plugin base classes. This API may get extended or changed over time.
Performance considerations
Traditional Python programs load all required dependencies as part of each module load. That may significantly affect startup time and memory usage, if such dependencies are not used in particular invocation.
As CID is quite sensitive to startup time, there is a special on-demand loading concept. Plugins
must never load any dependencies when they are loaded. Most of standard dependencies are already
provided through OnDemandMixIn
.
Other dependencies should be loaded right-before-use in plugin code.
CID also tries to avoid loading all plugins unless strictly necessary. Therefore, it’s desired
to define .tools
configuration to avoid auto-detection procedure.
Custom plugins
Custom plugins can be added either globally or for specific project.
Please check how this guide uses release
plugin bundled with CID, but not enabled by default.
Full example is also available.
{
"plugins": {
"release": "futoin.cid.misc.releasetool"
}
}