JSPM

  • Created
  • Published
  • Downloads 7031
  • Score
    100M100P100Q122868F
  • License Apache-2.0

Common utility functions

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 Travis Build Status Appveyor Build status

@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 region
  • disableProfile: don't print the AWS profile
  • version: the version to print out

utils.getLambdaName(fn)

Returns a valid AWS Lambda function name based on its URL (route).

utils.init(callback)

Initializes an Architect project directory structure based on contents read from a .arc file.

utils.inventory(arc)

Returns an object containing:

  1. an AWS inventory via the properties restapis, websocketapis, lambdas, types, iamroles, snstopics, sqstopics, s3buckets, cwerules and tables.
  2. 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:

  1. raw: the raw string contents of the arc project file.
  2. 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.