提交 e5054faf 编写于 作者: T Tomas Vik

refactor: convert CI config validator to TS

上级 21080d6c
const vscode = require('vscode');
const { gitExtensionWrapper } = require('./git/git_extension_wrapper');
const gitLabService = require('./gitlab_service');
import * as vscode from 'vscode';
import { gitExtensionWrapper } from './git/git_extension_wrapper';
import * as gitLabService from './gitlab_service';
const { showInformationMessage, showErrorMessage } = vscode.window;
async function validate() {
export async function validate(): Promise<void> {
const editor = vscode.window.activeTextEditor;
if (!editor) {
showInformationMessage('GitLab Workflow: No open file.');
await showInformationMessage('GitLab Workflow: No open file.');
return;
}
const content = editor.document.getText();
const response = await gitLabService.validateCIConfig(
gitExtensionWrapper.getActiveRepository().rootFsPath,
gitExtensionWrapper.getActiveRepository()!.rootFsPath,
content,
);
if (!response) {
showInformationMessage('GitLab Workflow: Failed to validate CI configuration.');
await showInformationMessage('GitLab Workflow: Failed to validate CI configuration.');
return;
}
const { status, errors, error } = response;
if (status === 'valid') {
showInformationMessage('GitLab Workflow: Your CI configuration is valid.');
await showInformationMessage('GitLab Workflow: Your CI configuration is valid.');
} else if (status === 'invalid') {
if (errors[0]) {
showErrorMessage(errors[0]);
await showErrorMessage(errors[0]);
}
showErrorMessage('GitLab Workflow: Invalid CI configuration.');
await showErrorMessage('GitLab Workflow: Invalid CI configuration.');
} else if (error) {
showErrorMessage(`GitLab Workflow: Failed to validate CI configuration. Reason: ${error}`);
await showErrorMessage(
`GitLab Workflow: Failed to validate CI configuration. Reason: ${error}`,
);
}
}
exports.validate = validate;
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册