行动/语言服务
此软件包包含 GitHub 动作工作流程语言服务器的逻辑 .
安装
这个 软件包 包含TypeScript类型并编译了ECMAScript模块.
npm install @actions/languageservice
使用量
基本用途
概念
语文服务的特点使用三个信息来源:
- 工作流程 YAML 文件的内置静态方案
- 价值提供者 可以动态地将值添加到计划中,例如,在验证时,可以为寄存器添加可用的标签列表
runs-on。 。 。 . - 上下文提供者 能够动态地提供用于 表达式。例如,该指南的内容
github.event上下文.
验证
验证工作流程文件,返回一组 Diagnostic 对象.
const config: ValidationConfig = {
valueProviderConfig: valueProviders(sessionToken, repoContext, cache),
contextProviderConfig: contextProviders(sessionToken, repoContext, cache),
};
const result = await validate(textDocument, config); // result is an array of `Diagnostic`
缓冲
何时获取信息 徘徊着 超过工作流程文件中的一个符号.
import {hover} from "@actions/languageservice";
const document = {
uri: "file:///path/to/file",
getText: () => "on: push\n jobs:\n build:\n runs-on: ubuntu-latest\n steps:\n - run: echo hello"
};
const hover = await hover(document, {line: 0, character: 1}); // { contents: { kind: "markdown", value: "The event that triggers the workflow" } }
自动补全
import {complete} from "@actions/languageservice";
const document = {
uri: "file:///path/to/file",
getText: () => `on:
jobs:
build:
runs-on: ubuntu-latest
steps:
- run: echo hello`
};
// Trigger completion for `on: |`
const suggestions = await complete(document, {line: 0, character: 4});
将返回
[{
"documentation": {
"kind": "markdown",
"value": "Runs your workflow when branch protection rules in the workflow repository are changed.",
},
"label": "branch_protection_rule",
"textEdit": {
"newText": "branch_protection_rule",
"range": {
"end": {"character": 4, "line": 0,},
"start": {"character": 4, "line": 0},
},
},
},
//... other events
]
捐款
见 捐款额 作为一般准则和建议存放处的基础.
如果你想捐款,请跑 更美丽 用于格式化您的代码,并在提交您的PR前酌情添加单位测试.
构建
npm run build
或监视更改
npm run watch
测试
npm test
或监视更改和运行测试:
npm run test-watch
林特
npm run format-check
许可证
这个项目根据麻省理工学院开源许可证的规定获得许可. 请参考 麻省理工学院 全部条件.