Skip to content

Architect dependency hydrator and shared file manager

License

Notifications You must be signed in to change notification settings

architect/hydrate

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

66787f3 · Jul 17, 2021
Jun 21, 2021
Jul 17, 2021
Jul 17, 2021
Dec 20, 2020
Dec 20, 2020
Nov 19, 2019
Mar 3, 2020
May 29, 2019
Jun 21, 2021
Dec 20, 2020
Jul 11, 2019
Jun 17, 2021
Jul 5, 2021
Jun 17, 2021

Repository files navigation

@architect/hydrate GitHub CI status

@architect/hydrate ensures that all functions managed by architect have their dependencies installed. Functions containing all its required dependencies are considered to be 'hydrated' - thus the name!

@architect/hydrate supports dependencies managed in the following languages using the following package managers:

  • node.js via npm using package.json and package-lock.json files
  • python (3.7+) via pip3 using a requirements.txt file
  • ruby via bundle using Gemfile and Gemfile.lock files

Installation

npm install @architect/hydrate

API

All methods accept an options object can include the following properties:

  • autoinstall - Boolean - if truthy, enables automated Lambda dependency treeshaking via static code analysis; defaults to false, only used by install
  • cwd - String - root filesystem path of the project Hydrate is working in
    • Defaults to current working directory
    • May be the same or different from basepath; if using in conjunction with basepath, specify a subset of the project with basepath, for example:
      • { cwd: '/your/project/', basepath: '/your/project/src/http/' } runs Hydrate against /your/project/ (without having to use process.chdir) and only hydrates functions within /your/project/src/http/**
  • basepath - String - filesystem path in which Hydrate should search for functions
    • Defaults the current working directory
    • Useful if you want to hydrate one function or a subset of functions
  • inventory - Object - Architect Inventory object; generally used internally

Note on cwd vs basepath: cwd is necessary for Hydrate to find your project's manifest and key files and folders, while basepath scopes hydration to a specific path. When in doubt, include neither parameter, Hydrate will default to process working directory; if you know you need to aim Hydrate at a specific place but aren't sure which parameter to use, use cwd.

hydrate.install(options, callback)

Installs function dependencies, invoking hydrate.shared().

Note that for the default value of basepath='src', this means install will also hydrate shared folders like src/shared and src/views.

To ensure local development behavior is as close to staging and production as possible, hydrate.install() (and other hydrate functions) uses:

  • node.js: npm ci if package-lock.json is present and npm i if not
  • python: pip3 install
  • ruby: bundle install

hydrate.update(options, callback)

Updates function dependencies, invoking hydrate.shared(). Note that this will only functionally differ from hydrate.install() if you use a lockfile like package-lock.json or Gemfile.lock.

Note that for the default value of basepath='src', this means update will also update dependencies in shared folders like src/shared and src/views.

update is functionally almost identical to install, except it will update dependencies to newer versions if they exist. This is done via:

  • node.js: npm update
  • python: pip3 install -U --upgrade-strategy eager
  • ruby: bundle update

hydrate.shared(options, callback)

Copies shared code (from src/shared and src/views) into all functions.

hydrate(options)

A terser method to invoke Hydrate. By default, invokes hydrate.shared(); accepts the normal options, but can invoke install or update with either of the following options: