ern-container-transformer-git-patch
v1.0.4
Published
This transformer allows for patching any file of the Container using a patch file generated by git (through `git diff`). It accepts one or more patch files to apply. Each patch file will be applied sequentially by the transformer using the `git apply` co
Downloads
18
Maintainers
Readme
Git Patch Container Transformer
This transformer allows for patching any file of the Container using a patch file generated by git (through git diff
). It accepts one or more patch files to apply. Each patch file will be applied sequentially by the transformer using the git apply
command.
There are different ways to create a git patch file, one of them being to just use the git diff
command on a modified Container.
For example, after generating a Container locally, just cd
into the directory where the Container was generated and run git init .
to create a new git repository, followed by git commit -a -m "Initial Commit"
to create the first commit. Then you can do any changes that need to be done to the Container. Updating some of the source code of the Container, or some configuration files. Then once the changes are done, it is possible to create the patch file containing all changes through git diff > patch_file_name.patch
.
The patch can then be applied automatically after Container generation, using this transformer.
Inputs
containerPath
: Path to the Container to transformpatchFiles
: Array containing a list of path to git generated patch files to apply to the Container.
Paths can be local paths (for ex/Users/username/patch/git.patch
) or can be paths to a patch file stored in the Cauldron (for excauldron://patch/git.patch
).
As a reminder, it is possible to add a file to the Cauldron using Electrode Native cauldron add file command.
Notes
The patch will be applied from the root Container directory, so make sure to create the diff from the root of the Container.
Usage
With ern transform-container
CLI command
$ ern transform-container --containerPath /patch/to/container -t git-patch -e '{"patchFiles":["/local/path/to/a.git.patch", "cauldron://path/to/another.git.patch"]}' --platform android'
Instead of passing the whole configuration on the command line for --extra/-e
, it is also possible to use a file path to a json file holding the configuration, or a path to a file stored in the Cauldron. Check out the ern transform-container command documentation for more info.
With Cauldron
To automatically transform the Cauldron generated Containers of a target native application and platform, you can add a transformer entry in the Cauldron in the Container generator configuration object as follow:
Electrode Native <= 0.31
"transformers": [
{
"name": "ern-container-transformer-git-patch",
"extra": {
"patchFiles": [
"/local/path/to/a.git.patch",
"cauldron://path/to/another.git.patch"
]
}
}
]
Electrode Native >= 0.32
"pipeline": [
{
"name": "ern-container-transformer-git-patch",
"extra": {
"patchFiles": [
"/local/path/to/a.git.patch",
"cauldron://path/to/another.git.patch"
]
}
}
]
Programmatically
import GitPatchTransformer from 'ern-container-transformer-git-patch'
const transformer = new GitPatchTransformer()
transformer.transform(
{
/* Local file system path to the Container */
containerPath: string
/* Extra data specific to this publisher */
extra?: {
patchFiles: string[],
}
}
})