@ast-grep/lang-bicep

中文文档
0.0.2发布于 2026/03/15ISCTypeScriptCommonJS近 30 天下载 20.1万

Azure Bicep language support for ast-grep

原始使用文档
文档目录4 节
  1. Installation
  2. Usage
  3. About Bicep
  4. Pattern Matching

ast-grep napi language for bicep

Installation

In a pnpm project, run:

pnpm install @ast-grep/lang-bicep
pnpm install @ast-grep/napi
# install the tree-sitter-cli if no prebuild is available
pnpm install tree-sitter-cli --save-dev

Usage

import bicep from '@ast-grep/lang-bicep'
import { registerDynamicLanguage, parse } from '@ast-grep/napi'

registerDynamicLanguage({ bicep })

const code = `
param location string = 'eastus'
param storageAccountName string = 'mystorageaccount'

resource storageAccount 'Microsoft.Storage/storageAccounts@2023-05-01' = {
  name: storageAccountName
  location: location
  sku: {
    name: 'Standard_LRS'
  }
  kind: 'StorageV2'
}
`

const sg = parse('bicep', code)
sg.root().kind()

About Bicep

Azure Bicep is a domain-specific language (DSL) for deploying Azure resources declaratively. It provides a transparent abstraction over ARM templates and aims to drastically simplify the authoring experience.

For more information, visit the official Bicep documentation.

Pattern Matching

Since Bicep does not support $ as an identifier character, ast-grep uses _ (underscore) as the expando character for pattern matching:

// Find all parameter declarations
const params = sg.root().findAll('param $NAME string')

// Find all resource declarations
const resources = sg.root().findAll('resource $NAME $TYPE = { $$$ }')

Note: While you write $ in your pattern strings, ast-grep internally translates them to _ when parsing Bicep code.

版本与发布记录

@ast-grep/lang-bicep 共发布 2 个版本,首次发布于 2026/01/18;过去 12 个月发布了 2 个版本。

版本发布日期距今
0.0.2latest2026/03/157 个月前
0.0.12026/01/189 个月前

关于 @ast-grep/lang-bicep 的常见问题

@ast-grep/lang-bicep 是什么?

Azure Bicep language support for ast-grep

如何安装 @ast-grep/lang-bicep?

在项目目录运行 npm install @ast-grep/lang-bicep,或使用 pnpm add / yarn add / bun add。

@ast-grep/lang-bicep 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@ast-grep/lang-bicep 支持 ESM 还是 CommonJS?

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

@ast-grep/lang-bicep 可以商用吗?

@ast-grep/lang-bicep 使用 ISC 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@ast-grep/lang-bicep 的下载量有多少?

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

@ast-grep/lang-bicep 还在维护吗?

最新版本 0.0.2 发布于 2026/03/15(7 个月前);至今共发布 2 个版本,其中过去 12 个月发布了 2 个;首次发布于 2026/01/18。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。