# @alcops/core 中文文档

规范地址：https://npmcn.com/package/%40alcops/core/

版本：0\.2\.0
npm 元数据更新时间：2026-09-09T10:22:31.826Z
中文译文更新时间：2026-11-06T04:54:54.817Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40alcops/core
原文对照：https://npmcn.com/package/%40alcops/core/?lang=original
项目主页：https://github.com/ALCops/npm-package#readme
源码仓库：https://github.com/ALCops/npm-package

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：941 kB，28 个文件
- 模块格式：CommonJS
- TypeScript 类型：包内自带
- Node.js 要求：\>=20
- 运行依赖：2 个
- 首次发布：2026-04-26T16:24:40.360Z
- 最新版本发布：2026-09-09T10:22:31.463Z
- 近 30 天下载量：5033（2026-10-06 至 2026-11-04，npm 官方下载统计）
- 已发布版本数：4（近 12 个月 4 个）

## 中文简介

ALCops核心库和CLI - 为商务中心安装TFM检测和分析器

## 安装

```sh
npm install @alcops/core
```

也可以使用：`pnpm add @alcops/core`、`yarn add @alcops/core`、`bun add @alcops/core`

## README

# @ alcops/ core (韩语)

[![CI](https://github.com/ALCops/npm-package/actions/workflows/ci.yml/badge.svg)](https://github.com/ALCops/npm-package/actions/workflows/ci.yml) [![npm](https://img.shields.io/npm/v/@alcops/core)](https://www.npmjs.com/package/@alcops/core) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://npmcn.com/package/%40alcops/core/LICENSE)

自动检测商务中心的目标框架Moniker(TFM)并下载匹配的代码分析文件. 使用右侧分析器构建 AL 扩展, 不进行手动版本拼接 。 为CI/CD管道所设计.

## 特征

-   从四个不同来源检测出TFM:
    -   **BC 工艺品 URL** (例如沙盒或OnPrem文物)
    -   **VS 市场** (AL语言扩展名)
    -   **NuGet 开发工具** (微软的 AL 开发工具包)
    -   **本地编译器路径** (包含 AL 编译器 DLLs 的目录)
-   **下载和提取** ALCops 分析器 DLLs 检测到的 TFM
-   JSON 输出在 stdout, 日志在 stderr (方便管道)
-   需要零配置
-   可用作CLI或节点.js库

## 安装

```bash
# Install globally
npm install -g @alcops/core

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

## 所需资源

-   节点.js 20

## CLI 使用量

```
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
```

### 实例

从VS市场检测(最常见的):

```bash
alcops detect-tfm marketplace
```

从特定的 NuGet DevTools 版本检测 :

```bash
alcops detect-tfm nuget-devtools 26.0.12345
```

从 BC 文物 URL 中检测到 :

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

从本地编译器目录中检测 :

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

### 下载命令

这个 `download` 命令将 TFM 检测与分析器提取合并为一个步骤.

从 NuGet DevTools 自动检测到的 TFM 下载分析器 :

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

使用 BC 文物 URL 自动检测的 TFM 下载分析器 :

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

从本地编译器目录下载自动检测的 TFM 分析器 :

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

带有明确的 TFM( skips 检测) 的下载分析器 :

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

下载特定的ALCops版本 :

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

强制检测源 `--detect-from` (覆盖智能路由):

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

启用调试的动词记录 :

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

#### 下载输出

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

### 产出

所有命令都写出 JSON 命令 :

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

日志输入 stderr , 这样您就可以安全控制结果 :

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

### CI/CD 示例(GitHub 动作)

```yaml
- 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 }}"
```

或者用那个 `download` 命令,用于单步解决方案 :

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

### AL 18/BC 29号注解

-   AL Language 18 VSIX将它的编译二进制平放于 `extension/bin/` (无) `Analyzers/`, (中文(简体) ), `win32/`, (中文(简体) ), `linux/` 或者说 `darwin/` 文件夹). 探测器首先探测平面布局并倒回了后遗症路径,因此AL 18+和AL QQ 17的工作都没有改变.
-   那些二进制目标 **净额10.0** 并依赖框架:与 AL 18 工具集相编译需要.NET 10运行时间在机器或代理上.
-   微软DevTools NuGet软件包两艘 `net8.0` 财务报告和审定财务报表 `net10.0` 集会。 检测更喜欢最新的TFM,所以 `nuget-devtools` 报告 `net10.0`。 。 。 .
-   如果你的建筑运行 `net8.0` 工具盘,用鼠标检测 `--detect-from compiler-path` 或完全跳过检测 `--tfm net8.0`。 。 。 .

## 程序化 API

软件包导出所有检测功能用作库 :

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

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

见 [导出 API 表面](https://npmcn.com/package/%40alcops/core/src/index.ts) 用于完整列出可用的函数和类型.

## 捐款

见 [捐款额](https://npmcn.com/package/%40alcops/core/CONTRIBUTING.md) (c) 促进发展的设置和贡献准则.

## 许可证

[麻省理工学院](https://npmcn.com/package/%40alcops/core/LICENSE)

## 常见问题

### @alcops/core 是什么？

ALCops核心库和CLI - 为商务中心安装TFM检测和分析器

### 如何安装 @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 和提交记录判断。

