@alcops/core

中文文档
0.2.0发布于 2026/09/09MITTypeScriptCommonJS构建来源已验证近 30 天下载 5033

ALCops core library and CLI - TFM detection and analyzer installation for Business Central

原始使用文档
文档目录12 节
  1. Features
  2. Installation
  3. Requirements
  4. CLI Usage
  5. Examples
  6. Download Command
  7. Output
  8. CI/CD Example (GitHub Actions)
  9. AL 18 / BC 29 notes
  10. Programmatic API
  11. Contributing
  12. License

@alcops/core

CI npm License: MIT

Automatically detect the Target Framework Moniker (TFM) for Business Central and download the matching code analyzer files. Build AL extensions with the right analyzers, without manual version juggling. Designed for CI/CD pipelines.

Features

  • Detect the TFM from four different sources:
    • BC artifact URL (e.g. a sandbox or OnPrem artifact)
    • VS Marketplace (the AL Language extension)
    • NuGet DevTools (Microsoft's AL development tools package)
    • Local compiler path (a directory containing the AL compiler DLLs)
  • Download and extract ALCops analyzer DLLs for a detected TFM
  • JSON output on stdout, logs on stderr (pipe-friendly)
  • Zero configuration required
  • Usable as a CLI or as a Node.js library

Installation

# Install globally
npm install -g @alcops/core

# Or run directly with npx
npx @alcops/core detect-tfm marketplace

Requirements

  • Node.js >= 20

CLI Usage

alcops <command> [args]

Commands:
  detect-tfm bc-artifact <url>         Detect TFM from a BC artifact URL
  detect-tfm marketplace [channel|version]     Detect TFM from VS Marketplace (default: current)
  detect-tfm nuget-devtools [version|channel]  Detect TFM from NuGet DevTools (default: latest)
  detect-tfm compiler-path <dir>       Detect TFM from a local compiler directory
  download --output <dir>               Download and extract ALCops analyzers

Download options:
  --output <dir>                       Required. Directory to extract analyzer DLLs into
  --detect-using <input>               TFM detection input (URL, path, channel, or version)
  --tfm <tfm>                          Explicit TFM (skips auto-detection)
  --version <ver>                      ALCops package version (default: latest)
  --detect-from <source>               Force detection source (bc-artifact, marketplace,
                                         nuget-devtools, compiler-path)

Global options:
  --verbose   Enable debug-level logging
  --help      Show this help message

Examples

Detect from the VS Marketplace (most common):

alcops detect-tfm marketplace

Detect from a specific NuGet DevTools version:

alcops detect-tfm nuget-devtools 26.0.12345

Detect from a BC artifact URL:

alcops detect-tfm bc-artifact "https://bcartifacts.azureedge.net/sandbox/26.0.12345.0/us"

Detect from a local compiler directory:

alcops detect-tfm compiler-path ./path/to/compiler

Download Command

The download command combines TFM detection with analyzer extraction in a single step.

Download analyzers with auto-detected TFM from the latest NuGet DevTools:

alcops download --detect-using latest --output ./analyzers

Download analyzers with auto-detected TFM from a BC artifact URL:

alcops download --detect-using "https://bcartifacts.azureedge.net/sandbox/26.0.12345.0/us" --output ./analyzers

Download analyzers with auto-detected TFM from a local compiler directory:

alcops download --detect-using ./path/to/compiler --output ./analyzers

Download analyzers with an explicit TFM (skips detection):

alcops download --tfm net8.0 --output ./analyzers

Download a specific ALCops version:

alcops download --detect-using latest --output ./analyzers --version 1.0.0

Force a detection source with --detect-from (overrides smart routing):

alcops download --detect-using 18.0.2293710 --detect-from marketplace --output ./analyzers

Enable verbose logging for debugging:

alcops download --detect-using latest --output ./analyzers --verbose

Download Output

{
  "version": "1.0.0",
  "tfm": "net8.0",
  "outputDir": "/absolute/path/to/analyzers",
  "files": [
    "/absolute/path/to/analyzers/ALCops.Analyzers.dll"
  ]
}

Output

All commands write JSON to stdout:

{
  "tfm": "net8.0",
  "source": "marketplace",
  "details": "AL Language extension v14.0.12345"
}

Logs go to stderr, so you can safely pipe the result:

TFM=$(alcops detect-tfm marketplace | jq -r '.tfm')
echo "Building with TFM: $TFM"

CI/CD Example (GitHub Actions)

- name: Detect TFM
  id: tfm
  run: |
    result=$(npx @alcops/core detect-tfm marketplace)
    echo "tfm=$(echo "$result" | jq -r '.tfm')" >> "$GITHUB_OUTPUT"

- name: Use TFM
  run: echo "Target framework is ${{ steps.tfm.outputs.tfm }}"

Or use the download command for a one-step solution:

- name: Download ALCops Analyzers
  run: npx @alcops/core download --detect-using latest --output ./analyzers --verbose

AL 18 / BC 29 notes

  • The AL Language 18 VSIX ships its compiler binaries flat in extension/bin/ (no more Analyzers/, win32/, linux/ or darwin/ folders). Detection probes the flat layout first and falls back to the legacy path, so both AL 18+ and AL <= 17 work unchanged.
  • Those binaries target net10.0 and are framework-dependent: compiling with the AL 18 toolset needs a .NET 10 runtime on the machine or agent.
  • The Microsoft DevTools NuGet package ships both net8.0 and net10.0 assemblies. Detection prefers the newest TFM, so nuget-devtools reports net10.0.
  • If your build runs the net8.0 toolset, point detection at it with --detect-from compiler-path or skip detection entirely with --tfm net8.0.

Programmatic API

The package exports all detection functions for use as a library:

import { detectFromMarketplace, createConsoleLogger } from '@alcops/core';

const logger = createConsoleLogger();
const result = await detectFromMarketplace('current', logger);
console.log(result.tfm); // e.g. "net8.0"

See the exported API surface for the full list of available functions and types.

Contributing

See CONTRIBUTING.md for development setup and contribution guidelines.

License

MIT

版本与发布记录

@alcops/core 共发布 4 个版本,首次发布于 2026/04/27;过去 12 个月发布了 4 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.2.0latest2026/09/091 个月前
0.1.22026/04/306 个月前
0.1.12026/04/296 个月前
0.1.02026/04/276 个月前

关于 @alcops/core 的常见问题

@alcops/core 是什么?

ALCops core library and CLI - TFM detection and analyzer installation for Business Central

如何安装 @alcops/core?

在项目目录运行 npm install @alcops/core,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 alcops,可以用 npx alcops 直接运行。

@alcops/core 支持 TypeScript 吗?

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

@alcops/core 支持 ESM 还是 CommonJS?

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

@alcops/core 需要什么版本的 Node.js?

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

@alcops/core 可以商用吗?

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

@alcops/core 的下载量有多少?

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

@alcops/core 还在维护吗?

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