@architect/parser

中文文档
8.0.1发布于 2025/09/24Apache-2.0CommonJS零依赖近 30 天下载 403.3万

Architect Parser accepts plaintext, JSON, or YAML .arc manifests and returns a plain JavaScript Object

原始使用文档

@architect/parser GitHub CI status

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.

Architect looks in the following places for the primary definition/configuration manifest file:

The .arc format is unique to Architect with many readability advantages; but is not required


.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

Consider a file some-arc-file.txt with the following contents:

# this is a comment
@section-one
simple-string-value # String
another-value
4.2 # Number
true # Boolean

@section-of-arrays
vector of values
vector tuple

@vectors-section
named
  vector
  of
  values

@this-section-has-a-map
hello-world
  name some-value

Parsing the file with the following code:

#!/usr/bin/env node
const parse = require('@architect/parser')
const fs = require('node:fs')
const text = fs.readFileSync('./some-arc-file.txt').toString()
const result = parse(text)

console.log(result)

Prints the following plain object to the console:

{
  "section-one": [
    "simple-string-value",
    "another-value",
    4.2,
    true
  ],
  "section-of-arrays": [
    ["vector", "of", "values"],
    ["vector", "tuple"]
  ],
  "vectors-section": [
    {named: ["vector", "of", "values"]},
  ],
  "this-section-has-a-map": [{
    "hello-world": {
      "name": "some-value"
    }
  }]
}

Things to notice:

  • 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

版本与发布记录

@architect/parser 共发布 58 个版本,首次发布于 2017/07/21;过去 12 个月发布了 0 个版本。

版本发布日期距今
8.0.1latest2025/09/241.1 年前
8.0.0-RC.0RC2025/05/041.5 年前
7.0.12024/04/302 年前
7.0.02024/04/302 年前
6.0.32023/08/013 年前
6.0.22022/11/054 年前

关于 @architect/parser 的常见问题

@architect/parser 是什么?

Architect Parser accepts plaintext, JSON, or YAML .arc manifests and returns a plain JavaScript Object

如何安装 @architect/parser?

在项目目录运行 npm install @architect/parser,或使用 pnpm add / yarn add / bun add。

@architect/parser 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/architect__parser 是否存在。

@architect/parser 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@architect/parser 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@architect/parser 可以商用吗?

@architect/parser 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@architect/parser 的下载量有多少?

根据 npm 官方下载统计,@architect/parser 在 2026/10/07 – 2026/11/05 这 30 天内被下载 4,032,878 次,日均约 134,429 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@architect/parser 还在维护吗?

最新版本 8.0.1 发布于 2025/09/24(1.1 年前);至今共发布 58 个版本,其中过去 12 个月发布了 0 个;首次发布于 2017/07/21。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。