craft_parts.plugins.npm_plugin module¶
The npm plugin.
- class craft_parts.plugins.npm_plugin.NpmPlugin(*args, **kwargs)[source]¶
Bases:
Plugin
A plugin for npm projects.
This plugin uses the common plugin keywords as well as those for “sources”. For more information check the ‘plugins’ topic for the former and the ‘sources’ topic for the latter.
- Additionally, this plugin uses the following plugin-specific keywords:
npm-include-node (bool; default: False) If true, download and include the node binary and its dependencies. If npm-include-node is true, then npm-node-version must be defined.
npm-node-version (str; default: None) Which version of node to download. Required if npm-include-node is set to true. The option accepts a NVM-style version string, you can specify:
exact version (e.g. “20.12.2”)
major+minor version (e.g. “20.12”)
major version (e.g. “20”)
LTS code name (e.g. “lts/iron”)
latest mainline version (“node”)
Note that “system” and “iojs” options are not supported.
- Parameters:
args (
Any
)kwargs (
Any
)
- get_build_commands()[source]¶
Return a list of commands to run during the build step.
- Return type:
list
[str
]
- get_build_environment()[source]¶
Return a dictionary with the environment to use in the build step.
- Return type:
dict
[str
,str
]
- get_build_packages()[source]¶
Return a set of required packages to install in the build environment.
- Return type:
set
[str
]
- get_build_snaps()[source]¶
Return a set of required snaps to install in the build environment.
- Return type:
set
[str
]
- get_pull_commands()[source]¶
Return a list of commands to run during the pull step.
- Return type:
list
[str
]
- properties_class¶
alias of
NpmPluginProperties
- validator_class¶
alias of
NpmPluginEnvironmentValidator
- class craft_parts.plugins.npm_plugin.NpmPluginEnvironmentValidator(*, part_name, env, properties)[source]¶
Bases:
PluginEnvironmentValidator
Check the execution environment for the npm plugin.
- Parameters:
part_name (
str
) – The part whose build environment is being validated.env (
str
) – A string containing the build step environment setup.properties (
PluginProperties
)
- class craft_parts.plugins.npm_plugin.NpmPluginProperties(**data)[source]¶
Bases:
PluginProperties
The part properties used by the npm plugin.
- Parameters:
data (
Any
)
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}¶
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function PluginProperties.<lambda>>, 'extra': 'forbid', 'frozen': True, 'validate_assignment': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[Dict[str, FieldInfo]] = {'npm_include_node': FieldInfo(annotation=bool, required=False, default=False, alias='npm-include-node', alias_priority=1), 'npm_node_version': FieldInfo(annotation=Union[str, NoneType], required=False, default=None, alias='npm-node-version', alias_priority=1), 'plugin': FieldInfo(annotation=Literal['npm'], required=False, default='npm', alias='plugin', alias_priority=1), 'source': FieldInfo(annotation=str, required=True, alias='source', alias_priority=1)}¶
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
- node_version_defined()[source]¶
If npm-include-node is true, then npm-node-version must be defined.
- Return type:
Self
-
npm_include_node:
bool
¶
-
npm_node_version:
str
|None
¶
-
plugin:
Literal
['npm'
]¶
-
source:
str
¶