-
Notifications
You must be signed in to change notification settings - Fork 138
Expand file tree
/
Copy pathisvalid.ts
More file actions
73 lines (65 loc) · 2.4 KB
/
isvalid.ts
File metadata and controls
73 lines (65 loc) · 2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import { TfCommand } from "../../lib/tfcommand";
import args = require("../../lib/arguments");
import colors = require("colors");
import extBase = require("./default");
import extInfo = require("./_lib/extensioninfo");
import galleryContracts = require("azure-devops-node-api/interfaces/GalleryInterfaces");
import publishUtils = require("./_lib/publish");
import trace = require("../../lib/trace");
export function getCommand(args: string[]): extBase.ExtensionBase<galleryContracts.PublishedExtension> {
return new ExtensionIsValid(args);
}
export class ExtensionIsValid extends extBase.ExtensionBase<galleryContracts.PublishedExtension> {
protected description = "Show the validation status of a given extension.";
protected serverCommand = true;
protected setCommandArgs(): void {
super.setCommandArgs();
this.registerCommandArgument(
"version",
"Extension version",
"Specify the version of the extension of which to get the validation status. Defaults to the latest version.",
args.StringArgument,
null,
);
this.registerCommandArgument(
"serviceUrl",
"Market URL",
"URL to the VSS Marketplace.",
args.StringArgument,
extBase.ExtensionBase.getMarketplaceUrl,
);
}
protected getHelpArgs(): string[] {
return ["publisher", "extensionId", "vsix", "version"];
}
public async exec(): Promise<string> {
const galleryApi = await this.webApi.getGalleryApi(this.webApi.serverUrl);
const extInfo = await this.identifyExtension();
const version = await this.commandArgs.version.val();
const sharingMgr = new publishUtils.SharingManager({}, galleryApi, extInfo);
const validationStatus = await sharingMgr.getValidationStatus(version);
return validationStatus;
}
protected friendlyOutput(data: string): void {
if (data === publishUtils.GalleryBase.validated) {
trace.info(colors.green("Valid"));
} else if (data === publishUtils.GalleryBase.validationPending) {
trace.info(colors.yellow("Validation pending..."));
} else {
trace.info(colors.red("Validation error: " + data));
}
}
protected jsonOutput(data: string): void {
const result = <{ status: string; message?: string }>{
status: "error",
};
if (data === publishUtils.GalleryBase.validationPending) {
result.status = "pending";
} else if (data === publishUtils.GalleryBase.validated) {
result.status = "success";
} else {
result.message = data;
}
console.log(JSON.stringify(result, null, 4));
}
}