@architect/hydrate
Advanced tools
Comparing version 1.0.1 to 1.1.0
34
index.js
let series = require('run-series') | ||
let installDeps = require('./src/install-deps') | ||
let copyArc = require('./src/copy-arc') | ||
let copyShared = require('./src/copy-shared') | ||
let copyViews = require('./src/copy-views') | ||
let copyStaticJSON = require('./src/copy-static-json') | ||
/** | ||
* populates the deps for all lambdas | ||
* populates or updates the deps for all lambdas. will always copy shared | ||
* resources into lambdas. | ||
* | ||
* @param {object} params | ||
* @param {boolean} params.install | ||
* @param {boolean} params.update | ||
*/ | ||
@@ -25,13 +22,14 @@ module.exports = function hydrate(params={}, callback) { | ||
} | ||
// always do these tasks | ||
let tasks = [ | ||
copyShared, | ||
copyViews, | ||
copyStaticJSON, | ||
copyArc, | ||
] | ||
// maybe do these | ||
let tasks = [] | ||
if (params.install) | ||
tasks.unshift(installDeps) | ||
// order important! | ||
tasks.push(function install(callback) { | ||
module.exports.install(params.basepath, callback) // `install` includes `shared` | ||
}) | ||
else if (params.update) | ||
tasks.push(function update(callback) { | ||
module.exports.update(params.basepath, callback) // `update` includes `shared` | ||
}) | ||
else | ||
tasks.push(module.exports.shared) | ||
series(tasks, function done(err) { | ||
@@ -43,1 +41,5 @@ if (err) callback(err) | ||
} | ||
module.exports.install = require('./src/install') | ||
module.exports.shared = require('./src/shared') | ||
module.exports.update = require('./src/update') |
{ | ||
"name": "@architect/hydrate", | ||
"version": "1.0.1", | ||
"description": "", | ||
"version": "1.1.0", | ||
"description": "Architect dependency hydrator and shared file manager", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "tape test/*-test.js | tap-spec", | ||
"test": "npm run lint && npm run test:unit && npm run test:integration", | ||
"test:unit": "tape test/unit-tests.js | tap-spec", | ||
"test:integration": "tape test/integration-tests.js | tap-spec", | ||
"lint": "eslint . --fix --ignore-pattern node_modules" | ||
@@ -27,2 +29,3 @@ }, | ||
"glob": "^7.1.4", | ||
"rimraf": "^2.6.3", | ||
"run-series": "^1.1.8" | ||
@@ -32,3 +35,4 @@ }, | ||
"eslint": "^5.16.0", | ||
"rimraf": "^2.6.3", | ||
"mkdirp": "^0.5.1", | ||
"sinon": "^7.3.2", | ||
"tap-spec": "^5.0.0", | ||
@@ -35,0 +39,0 @@ "tape": "^4.10.2" |
@@ -1,3 +0,72 @@ | ||
# `@architect/hydrate` | ||
# Hydrate [![Travis Build Status](https://travis-ci.com/architect/hydrate.svg?branch=master)](https://travis-ci.com/architect/hydrate) [![Appveyor Build Status](https://ci.appveyor.com/api/projects/status/1svykswtyce1k3u9/branch/master?svg=true)](https://ci.appveyor.com/project/ArchitectCI/hydrate/branch/master) | ||
[@architect/hydrate][npm] 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][npm] 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 | ||
## `hydrate(options)` | ||
`options` object can include the following properties: | ||
- `basepath`: What path hydrate should consider as the root for searching for | ||
functions to hydrate. Useful if you want to hydrate a subset of functions. | ||
Defaults to `src` in the current working directory. | ||
- `install`: If truthy, will invoke [`hydrate.install()`][install]. | ||
- `update`: If truthy, will invoke [`hydrate.update()`][update]. | ||
By default, invokes [`hydrate.shared()`][shared]. | ||
## `hydrate.install(basepath='src', callback)` | ||
Installs dependencies for all Functions found in the specified `basepath`. Invokes | ||
[`hydrate.shared()`][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(basepath='src', callback)` | ||
Updates dependencies in all Functions found in the specified `basepath`. Invokes | ||
[`hydrate.shared()`][shared]. Note that this will only functionally differ from | ||
[`hydrate.install()`][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`][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(callback)` | ||
Copies shared code (from `src/shared` and `src/views`) into all Functions. | ||
[shared]: #hydratesharedcallback | ||
[install]: #hydrateinstallbasepathsrc-callback | ||
[update]: #hydrateupdatebasepathsrc-callback | ||
[npm]: https://www.npmjs.com/package/@architect/hydrate |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
31107
16
430
73
7
5
4
+ Addedrimraf@^2.6.3