@dev-build-deploy/diagnose-it

中文文档
1.4.2发布于 2023/12/11MITTypeScriptCommonJS近 30 天下载 9171

Expressive Diagnostics library

原始使用文档
文档目录7 节
  1. Features
  2. Usage
  3. Create an Expressive Diagnostics message
  4. Parse a file
  5. Output format
  6. Contributing
  7. License

DiagnoseIt - Expressive Diagnostics Library

Lightweight diagnostics logger, based on LLVMs Expressive Diagnostics specification:

Features

Usage

Create an Expressive Diagnostics message

import { DiagnosticsMessage, FixItHint } from '@dev-build-deploy/diagnose-it';
const lines = `steps:
  - uses: actions/checkout@v2
  - neds: [build, test]
    - uses: actions/setup-node@v2`;
  
// Example use case
const message = DiagnosticsMessage.createError(
  "example.yaml",
  {
    text: "Invalid keyword 'neds'",
    linenumber: 9,
    column: 5
  }
)
  // Add context to the diagnostics message
  .setContext(7, lines)
  // Add a FixIt Hint
  .addFixitHint(FixItHint.createReplacement({ index: 5, length: 4 }, "needs"));

// Convert to string
console.log(message.toString());

// Apply FixIt Hints
console.log("Results after applying FixIt Hints:", message.applyFixitHints());

// Throw as an Error
throw message;

Parse a file

You can parse a (compiler output) file to retrieve any Expressive Diagnostic message:

import * as diagnoseIt from '@dev-build-deploy/diagnose-it';

for await(const message of diagnoseIt.extractFromFile("build.log")) {
  if (message.toJSON().type === "error") {
    // Oh noes!
  }
}

NOTE: Any .sarif or .sarif.json file will be parsed for valid SARIF results content

Output format

DiagnoseIt is inspired by the LLVMs Expressive Diagnostics formatting;

However, it does not aim to provide full compatibility.

Contributing

If you have suggestions for how DiagnoseIt could be improved, or want to report a bug, open an issue! We'd love all and any contributions.

For more, check out the Contributing Guide.

License

版本与发布记录

@dev-build-deploy/diagnose-it 共发布 30 个版本,首次发布于 2023/06/14;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.4.2latest2023/12/112 年前
1.4.12023/11/292 年前
1.4.02023/11/292 年前
1.3.22023/11/242 年前
1.3.12023/11/242 年前
1.3.02023/11/222 年前

关于 @dev-build-deploy/diagnose-it 的常见问题

@dev-build-deploy/diagnose-it 是什么?

Expressive Diagnostics library

如何安装 @dev-build-deploy/diagnose-it?

在项目目录运行 npm install @dev-build-deploy/diagnose-it,或使用 pnpm add / yarn add / bun add。

@dev-build-deploy/diagnose-it 支持 TypeScript 吗?

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

@dev-build-deploy/diagnose-it 支持 ESM 还是 CommonJS?

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

@dev-build-deploy/diagnose-it 可以商用吗?

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

@dev-build-deploy/diagnose-it 的下载量有多少?

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

@dev-build-deploy/diagnose-it 还在维护吗?

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