Package Exports
- @architect/utils
- @architect/utils/get-lambda-name
- @architect/utils/init
- @architect/utils/populate-env
- @architect/utils/port-in-use
- @architect/utils/read-arc
- @architect/utils/to-logical-id
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@architect/utils) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@architect/utils

@architect/utils are common utilities for the @architect suite of projects.
Installation
npm i @architect/utils
API
utils.banner(params)
Based on information read from the .arc
project file, prints out app name, AWS
region, AWS profile, version and current working directory.
params
is an object which can provide the following properties to customize
this behaviour:
disableRegion
: don't print the AWS regiondisableProfile
: don't print the AWS profileversion
: the version to print out
utils.getLambdaName(fn)
Returns a valid AWS Lambda function name based on its URL (route).
utils.getLayers(arc)
Returns any layers defined in a project arc file. arc
is an
@architect/parser
-parsed arc file object.
utils.getRuntime(arc)
Returns the runtime defined in a project arc file. arc
is an
@architect/parser
-parsed arc file object.
utils.getRuntime.allowed(runtime)
Based on the passed-in runtime
string, will return the same string if it is an
allowed Architect Function runtime. Otherwise, will return a default runtime
which Architect will use (at the time of this writing, the default is
nodejs10.x
.
utils.init(callback)
Initializes an Architect project directory structure based on contents read from
a .arc
file.
utils.inventory(arc)
Returns an object containing:
- an AWS inventory via the properties
restapis
,websocketapis
,lambdas
,types
,iamroles
,snstopics
,sqstopics
,s3buckets
,cwerules
andtables
. - a list of
localPaths
mapping inventory code (where applicable) to paths on the local filesystem.
The returned object is based on the provided arc
argument, which should be a
parsed .arc
file (or will attempt to parse one if none is passed).
utils.populateEnv(callback)
Populates the runtime environment with variables from a .arc-env
if present.
Details about this functionality can be found in the @architect/env
project (pending resolution of architect/env#2).
utils.portInUse(port, callback)
Tests that the port specified by port
is available to be used. If an error is
raised attempting to listen on the specified port, callback
will be invoked
with an error argument. If it is available, callback
will be invoked with no
arguments.
utils.readArc(params={})
Returns an object containing the following properties:
raw
: the raw string contents of the arc project file.arc
: the parsed (via @architect/parser) contents of the arc project file.
The project file is attempted to be parsed, in order, from .arc
, app.arc
,
arc.yaml
, and arc.json
.
utils.toLogicalID(str)
Converts str
into PascalCase.
utils.validate(arc, raw, callback)
Validates a parsed arc file. Parameters to this function are:
arc
: an@architect/parser
-parsed arc file objectraw
: the raw arc file textcallback
: will be invoked with an error as its first argument if validation fails; otherwise will invoke passing null as the first argument and the parsed arc object as the second argument.