Socket
Socket
Sign inDemoInstall

@architect/utils

Package Overview
Dependencies
31
Maintainers
5
Versions
124
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @architect/utils

Common utility functions


Version published
Maintainers
5
Created

Changelog

Source

[1.5.14] 2020-11-05

Added

  • updater errors now include stack traces

Changed

  • updater errors can no longer be quieted – errors are important!

Readme

Source

@architect/utils GitHub CI status

@architect/utils are common utilities for the @architect suite of projects.

Installation

npm i @architect/utils

API

utils.banner(params)

Reads a project's the Architect manifest and prints out: app name, AWS region, AWS profile, version, and current working directory, in addition to loading basic environment variables and necessary AWS credentials.

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.getLayers(arc)

Returns Lambda layers defined in an Architect project manifest. arc is an object returned by the @architect/parser, parsed from an Architect project manifest file.

utils.getRuntime(arc)

Returns the Lambda runtime defined in an Architect project manifest. arc is an object returned by the @architect/parser, parsed from an Architect project manifest file.

utils.getRuntime.allowed(runtime)

Takes a runtime string and returns the same string if it' iss' a runtime allowed in Architect. Otherwise, returns a default runtime which Architect will use (currently nodejs10.x).

utils.initEnv(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.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, which is an object returned by the @architect/parser, parsed from an Architect project manifest file. (If no arc object is passed, it will attempt to parse one itself.)

utils.pathToUnix(pathString)

Converts any path to a Unix style path, with / as the seperator. This works around Windows issues where / is assumed across other parts of Architect.

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 Architect project manifest

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 object returned by the @architect/parser, parsed from an Architect project manifest file
  • raw: the raw Architect project manifest file text
  • callback: 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

FAQs

Last updated on 05 Nov 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc