Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@architect/utils

Package Overview
Dependencies
Maintainers
5
Versions
124
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@architect/utils - npm Package Compare versions

Comparing version 2.0.3 to 2.0.4

13

changelog.md

@@ -5,2 +5,15 @@ # Architect Utils changelog

## [2.0.4] 2021-01-05
### Added
- Add `updater.raw()`, a console.log passthrough that respects Architect quietude
### Changed
- Updated `updater` tests
---
## [2.0.3] 2020-12-19

@@ -7,0 +20,0 @@

4

package.json
{
"name": "@architect/utils",
"version": "2.0.3",
"version": "2.0.4",
"description": "Common utility functions",

@@ -36,3 +36,3 @@ "main": "index.js",

"cross-env": "7.0.3",
"eslint": "7.16.0",
"eslint": "7.17.0",
"husky": "^4.3.6",

@@ -39,0 +39,0 @@ "proxyquire": "^2.1.3",

@@ -14,9 +14,11 @@ # `@architect/utils` [![GitHub CI status](https://github.com/architect/utils/workflows/Node%20CI/badge.svg)](https://github.com/architect/utils/actions?query=workflow%3A%22Node+CI%22)

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.
Responsible for printing the standard banner, and loading the basic environment variables and necessary AWS credentials necessary to run Architect.
`params` is an object which can provide the following properties to customize this behaviour:
`params` are required with the following available properties:
- `inventory` (required): Inventory object from `@architect/inventory`
- `disableBanner`: run Architect's environment bootstrapping routines, but don't display the actual banner
- `disableRegion`: don't print the AWS region
- `disableProfile`: don't print the AWS profile
- `version`: the version to print out
- `version`: the package version string to print out (e.g. `Architect 1.2.3`)

@@ -29,35 +31,2 @@

## `utils.getLayers(arc)`
Returns Lambda layers defined in an Architect project manifest. `arc` is an object returned by the [`@architect/parser`][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`][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][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`][parser], parsed from an Architect project manifest file. (If no `arc` object is passed, it will attempt to parse one itself.)
## `utils.pathToUnix(pathString)`

@@ -68,34 +37,34 @@

## `utils.portInUse(port, callback)`
## `utils.toLogicalID(str)`
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.
Converts `str` into PascalCase for CloudFormation use.
## `utils.readArc(params={})`
## `utils.updater(name, params)`
Returns an object containing the following properties:
`name` (a string) is required; `params` may include the boolean option `quiet` to manually override Architect's global printing status.
1. `raw`: the raw string contents of the arc project file
2. `arc`: the parsed (via [@architect/parser][parser]) contents of the Architect project manifest
Returns a function to be reused for standardized logging updates with the following methods:
The project file is attempted to be parsed, in order, from `.arc`, `app.arc`, `arc.yaml`, and `arc.json`.
- `status` - prints an affirmative status update
- optional: arbitrary number of supporting info on new lines with each additional param
- `start` - starts an animated progress indicator
- aliases: `update`
- `done` - ends current progress indicator with an update
- aliases: `stop`
- `cancel` - cancels current progress indicator without an update
- `err` - pretty prints an error
- aliases: `error` and `fail`
- `warn` - cancels current progress indicator and prints a warning
- aliases: `warn`
- `raw` - just logs a message as-is (while respecting quiet)
Automatically respects Architect's global printing status, and also respects the following env vars:
## `utils.toLogicalID(str)`
- `ARC_QUIET` - if truthy, disables printing
- `CI` - if truthy, disables certain terminal progress animations
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`][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
[arc]: https://github.com/architect
[npm]: https://www.npmjs.com/package/@architect/utils
[env]: https://github.com/architect/env
[parser]: https://www.npmjs.com/package/@architect/parser

@@ -8,10 +8,13 @@ let chalk = require('chalk')

* - `status` - prints an affirmative status update - `chars.start`
* - optional: supporting info on new lines with additional params
* - optional: supporting info on new lines with each additional param
* - `start` - start progress indicator - `spinner`||`chars.start`
* - aliases: `update`
* - `start` - start progress indicator - `spinner`||`chars.start`
* - `done` - end progress indicator with an update - `chars.done`
* - aliases: `stop`
* - `cancel` - cancel progress indicator without update - !char
* - `err` - pretty print an error - `chars.err`
* - `err` - pretty print an error - `chars.err`
* - aliases: `error` and `fail`
* - `warn` - cancel progress indicator and print a warning
* - aliases: `warn`
* - `raw` - just logs a message as-is (respecting quiet)
*

@@ -117,2 +120,7 @@ * Each method should also return a value to enable capture of progress data

function raw (msg) {
if (!quiet()) console.log(msg)
return msg
}
return {

@@ -129,3 +137,4 @@ start,

warn,
warning: warn
warning: warn,
raw,
}

@@ -132,0 +141,0 @@ }

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc