@architect/create
Advanced tools
Comparing version 1.3.3 to 1.4.0-RC.0
@@ -5,2 +5,10 @@ # Architect Create changelog | ||
## [1.4.0] 2021-03-02 | ||
### Added | ||
- Added support for `@plugins` pragma, allowing plugin authors to create new Lambda directories in arc projects | ||
--- | ||
## [1.3.3] 2021-01-18 | ||
@@ -7,0 +15,0 @@ |
{ | ||
"name": "@architect/create", | ||
"version": "1.3.3", | ||
"version": "1.4.0-RC.0", | ||
"description": "Idempotently initialize Architect projects", | ||
@@ -16,3 +16,3 @@ "main": "src/index.js", | ||
"test:unit": "cross-env PORT=6666 tape 'test/unit/**/*-test.js' | tap-spec", | ||
"coverage": "nyc --reporter=lcov --reporter=text-summary npm run test:unit", | ||
"coverage": "nyc --reporter=lcov --reporter=text npm run test:unit", | ||
"lint": "eslint . --fix", | ||
@@ -26,3 +26,3 @@ "rc": "npm version prerelease --preid RC" | ||
"dependencies": { | ||
"@architect/inventory": "~1.2.0", | ||
"@architect/inventory": "~1.3.0-RC.0", | ||
"@architect/utils": "~2.0.2", | ||
@@ -29,0 +29,0 @@ "chalk": "~4.1.0", |
@@ -46,3 +46,3 @@ let { updater } = require('@architect/utils') | ||
let prefs = inv._project.preferences | ||
let { http, events, queues, scheduled, static, streams, ws } = inv | ||
let { http, events, queues, scheduled, static, streams, ws, plugins } = inv | ||
@@ -78,2 +78,11 @@ let supported = [ 'node', 'deno', 'ruby', 'python', 'rb', 'py', 'js' ] | ||
if (streams) functions.push(...streams.map(binder.streams)) | ||
if (Object.keys(plugins).length > 0) { | ||
functions.push(...Object.values(plugins). | ||
map(pluginModule => pluginModule.pluginFunctions). | ||
filter(functionMethod => functionMethod). // ensure plugin exports a `pluginFunctions` method; ignore ones that do not | ||
map(pluginFunctions => pluginFunctions(inventory.inv._project.arc, inventory)). // returns an array of new lambdas defined by each plugin | ||
flat(). // since we have an array of lambdas _per plugin_, flatten it down to a simple array of lambdas regardless of plugin | ||
map(pluginLambda => code.bind({}, { ...pluginLambda, runtime, type: 'plugin' })) | ||
) | ||
} | ||
@@ -108,2 +117,32 @@ parallel(functions, function done (err, results) { | ||
// In order to support nodejs v10 | ||
// Stolen from https://stackoverflow.com/questions/53072385/array-prototype-flat-is-undefined-in-nodejs | ||
if (!Array.prototype.flat) { | ||
Array.prototype.flat = function (maxDepth, currentDepth) { | ||
let array = this | ||
maxDepth = maxDepth === Infinity | ||
? Number.MAX_SAFE_INTEGER | ||
: parseInt(maxDepth, 10) || 1 | ||
currentDepth = parseInt(currentDepth, 10) || 0 | ||
// It's not an array or it's an empty array, return the object. | ||
if (!Array.isArray(array) || !array.length) { | ||
return array | ||
} | ||
// If the first element is itself an array and we're not at maxDepth, | ||
// flatten it with a recursive call first. | ||
// If the first element is not an array, an array with just that element IS the | ||
// flattened representation. | ||
// **Edge case**: If the first element is an empty element/an "array hole", skip it. | ||
// (see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat#Examples) | ||
let firstElemFlattened = (Array.isArray(array[0]) && currentDepth < maxDepth) | ||
? array[0].flat(maxDepth, currentDepth + 1) | ||
: array[0] === undefined ? [] : [ array[0] ] | ||
return firstElemFlattened.concat(array.slice(1).flat(maxDepth, currentDepth)) | ||
} | ||
} | ||
module.exports.bootstrap = bootstrap |
@@ -17,3 +17,3 @@ let { existsSync, mkdirSync } = require('fs') | ||
module.exports = function code (params, callback) { | ||
let { arcStaticAssetProxy, src, type, runtime, prefs } = params | ||
let { arcStaticAssetProxy, src, type, runtime, prefs, body } = params | ||
@@ -42,3 +42,4 @@ // Immediate bail if source dir already exists | ||
runtime, | ||
handlerFile | ||
handlerFile, | ||
body | ||
}, callback) | ||
@@ -45,0 +46,0 @@ } |
@@ -9,7 +9,7 @@ let { writeFile } = require('fs') | ||
module.exports = function writeCode ({ handlerFile, type, runtime }, callback) { | ||
module.exports = function writeCode ({ handlerFile, type, runtime, body }, callback) { | ||
let types = { http, events, queues, ws, scheduled, streams } | ||
let run = runtime.split(/\d/)[0] | ||
let body = types[type][run] | ||
body = body || types[type][run] | ||
writeFile(handlerFile, body, callback) | ||
} |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
52758
884
2
+ Added@architect/inventory@1.3.3(transitive)
- Removed@architect/inventory@1.2.3(transitive)