hydrate plugins

hydrate lifecycle hook plugins expose functionality to extend the capabilities of Hydrate, Architect’s tool for managing dependencies and shared code.

hydrate.copy (experimental)

Note: this API is currently experimental and collecting feedback here, please let us know what you think!

Copy arbitrary files or folders into your project’s Lambdas’ shared code directories (e.g. ./src/$pragma/$name/node_modules/@architect/shared/ or ./src/$pragma/$name/vendor), and run arbitrary operations.

hydrate.copy runs after all dependency installation and shared file operations are complete, ensuring that any filesystem mutations will be present in final deployment artifacts.

hydrate.copy plugins are either async or synchronous functions, and receive a single argument, which is an object containing the following properties:

Property Type Description
arc object Raw Architect project object
inventory object Inventory object
copy async function Copy file(s)

Copy function

hydrate.copy plugins are provided an async copy function capable of copying one or more files or folders into all Lambdas in the project (including Lambdas created by plugins with set methods) that have code sharing enabled. Invocations must include the following properties:

Property Type Description
source string Relative or absolute path of the source file or folder
target string Relative path of the target file or folder

Source paths

The source path is a relative or absolute file path of the source file or folder to be copied into your Lambdas.

Note: as of right now, source must be found somewhere within the project directory. This may change in the future based on feedback.

Target paths

The target path is a relative path of the source file or folder to be copied into your Lambdas.

For example, if you specify a target of hi/there.json, your Lambda will have one of two file paths written (based on its runtime):

  • ./src/$pragma/$name/node_modules/@architect/shared/hi/there.json
  • ./src/$pragma/$name/vendor/hi/there.json

Examples

// Copy a single file or folder to the same name
module.exports = { hydrate: {
  copy: async ({ arc, inventory, copy }) => {
    await copy({
      source: 'project/relative/path/file.txt',
      target: 'file.txt',
    })
    //
  }
} }
// Copy multiple files or folders
module.exports = { hydrate: {
  copy: async ({ arc, inventory, copy }) => {
    await copy([
      {
        source: 'project/relative/path/file.txt',
        target: 'file.txt',
      },
      {
        source: 'project/relative/path/subfolder',
        target: 'some-subfolder',
      },
    ])
  }
} }