-
Notifications
You must be signed in to change notification settings - Fork 211
/
api.ts
124 lines (103 loc) · 2.41 KB
/
api.ts
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
import { publish as _publish } from './publish';
import { packageCommand, listFiles as _listFiles } from './package';
export interface ICreateVSIXOptions {
/**
* The location of the extension in the file system.
*
* Defaults to `process.cwd()`.
*/
cwd?: string;
/**
* The destination of the packaged the VSIX.
*
* Defaults to `NAME-VERSION.vsix`.
*/
packagePath?: string;
/**
* The base URL for links detected in Markdown files.
*/
baseContentUrl?: string;
/**
* The base URL for images detected in Markdown files.
*/
baseImagesUrl?: string;
}
export interface IPublishOptions {
/**
* The location of the extension in the file system.
*
* Defaults to `process.cwd()`.
*/
cwd?: string;
/**
* The Personal Access Token to use.
*
* Defaults to the stored one.
*/
pat?: string;
/**
* The base URL for links detected in Markdown files.
*/
baseContentUrl?: string;
/**
* The base URL for images detected in Markdown files.
*/
baseImagesUrl?: string;
}
/**
* The supported list of package managers.
*/
export enum PackageManager {
Npm,
Yarn
}
export interface IListFilesOptions {
/**
* The working directory of the extension. Defaults to `process.cwd()`.
*/
cwd?: string;
/**
* The package manager to use. Defaults to `PackageManager.Npm`.
*/
packageManager?: PackageManager;
}
export interface IPublishVSIXOptions {
/**
* The Personal Access Token to use.
*
* Defaults to the stored one.
*/
pat?: string;
/**
* The base URL for links detected in Markdown files.
*/
baseContentUrl?: string;
/**
* The base URL for images detected in Markdown files.
*/
baseImagesUrl?: string;
}
/**
* Creates a VSIX from the extension in the current working directory.
*/
export function createVSIX(options: ICreateVSIXOptions = {}): Promise<any> {
return packageCommand(options);
}
/**
* Publishes the extension in the current working directory.
*/
export function publish(options: IPublishOptions = {}): Promise<any> {
return _publish(options);
}
/**
* Lists the files included in the extension's package.
*/
export function listFiles(options: IListFilesOptions = {}): Promise<string[]> {
return _listFiles(options.cwd, options.packageManager === PackageManager.Yarn);
}
/**
* Publishes a pre-build VSIX.
*/
export function publishVSIX(packagePath: string, options: IPublishVSIXOptions = {}): Promise<any> {
return _publish({ packagePath, ...options });
}