Socket
Socket
Sign inDemoInstall

@architect/parser

Package Overview
Dependencies
Maintainers
4
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@architect/parser - npm Package Compare versions

Comparing version 1.2.2 to 2.0.0

schema.json

17

package.json
{
"name": "@architect/parser",
"version": "1.2.2",
"version": "2.0.0",
"description": "Architect Parser accepts plaintext, JSON, or YAML .arc manifests and returns a plain JavaScript Object",
"main": "index.js",
"main": "./src/index.js",
"scripts": {

@@ -10,8 +10,14 @@ "lint": "npx eslint . --fix",

"coverage": "nyc --reporter=lcov --reporter=text-summary npm run test:unit",
"test": "npm run lint && npm run coverage",
"_test": "npm run lint && npm run coverage",
"test": "npm run lint && npm run test:unit",
"rc": "npm version prerelease --preid RC"
},
"repository": {
"type": "git",
"url": "git+https://github.com/architect/parser.git"
},
"author": "Brian LeRoux",
"license": "Apache-2",
"license": "Apache-2.0",
"devDependencies": {
"assert-diff": "^2.0.3",
"codecov": "^3.6.1",

@@ -21,5 +27,4 @@ "eslint": "^6.6.0",

"tap-spec": "^5.0.0",
"tape": "^4.11.0",
"assert-diff": "^2.0.3"
"tape": "^4.11.0"
}
}
# [`@architect/parser`](https://www.npmjs.com/package/@architect/parser) [![GitHub CI status](https://github.com/architect/parser/workflows/Node%20CI/badge.svg)](https://github.com/architect/parser/actions?query=workflow%3A%22Node+CI%22)
<!-- [![codecov](https://codecov.io/gh/architect/parser/branch/master/graph/badge.svg)](https://codecov.io/gh/architect/parser) -->
> `.arc` is a simplistic text format for storing structured data; `@architect/parser`
> is a function that accepts text and returns a plain JavaScript `Object`
OpenJS Architect is an Infrastructure as Code (IaC) solution. The critical insight of *Infastructure as Code* is determinism. Infrastructure resources are defined in a declarative manifest file with the code that depends on them. This ensures deployment artifacts alway have the exact runtime resources expected for every version of the code.
The format:
Architect looks in the following places for the primary definition/configuration manifest file:
- Starts with a `@section`
- Sections start with `@`
- Sections contain either scalar values, `Vector` or `Map`
- Scalar values are either `String`, `Number` or `Boolean`
- `Vector` values are space seperated scalar values on a single line
- A `Map` is defined by a scalar value followed by Vectors indented two spaces
- Comments follow `#` symbols
- `.arc`
- `app.arc` - [example](/examples/arc.arc)
- `arc.json` - [example](/examples/arc.json) - [schema](https://arc.codes/schema.json)
- `arc.yaml` - [example](/examples/arc.yaml)
- `arc.toml` - [example](/examples/arc.toml)
## Install
> The `.arc` format is unique to Architect with many readability advantages; but is *not required*
npm i @architect/parser
---
# `.arc`
> `.arc` is a text format for storing structured configuration data; it is not for serializing or transporting data
The `.arc` format:
- Comments follow `#` symbols
- Top level keys start with `@` (example: `@pragma`)
- Pragmas contain: scalar values or complex values
- Scalar values are: `string`, `number` and `boolean`
- Complex values are: `array`, `vector` and `map`
- Whitespace is significant
## Example

@@ -33,6 +43,12 @@

@another-section-of-vectors
@section-of-arrays
vector of values
vector tuple
@vectors-section
named
vector
of
values
@this-section-has-a-map

@@ -43,12 +59,15 @@ hello-world

Running the following inside nodejs:
Parsing the file with the following code:
```javascript
var parser = require('@architect/parser')
var fs = require('fs')
var text = fs.readFileSync('./some-arc-file.txt').toString()
var result = parse(text)
#!/usr/bin/env node
const parser = require('@architect/parser')
const fs = require('fs')
const text = fs.readFileSync('./some-arc-file.txt').toString()
const result = parse(text)
console.log(result)
```
Would yield the following:
Prints the following plain object to the console:

@@ -63,6 +82,9 @@ ```javascript

],
"another-section-of-vectors": [
"section-of-arrays": [
["vector", "of", "values"],
["vector", "tuple"]
],
"vectors-section": [
{named: ["vector", "of", "values"]},
],
"this-section-has-a-map": [{

@@ -76,18 +98,8 @@ "hello-world": {

## API
Things to notice:
### `parse(text)`
- `array` values are space seperated scalar values on a single line
- `vector` is a named `array` with scalar values indented two spaces on newlines
- `map` is a named value followed by keys and values indented two spaces
Takes as input raw `.arc` file text and outputs an @architect parsed `Object`.
### `parse.json(jsonText)`
Takes as input raw JSON text representing an @architect parsed `Object` and
trims it down to only relevant @architect `Object` properties.
### `parse.yaml(yamlText)`
Takes as input raw YAML text representing an @architect parsed `Object`,
converts it to JSON and trims it down to only relevant @architect `Object` properties.
[npm]: https://www.npmjs.com/package/@architect/parser
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