-
Notifications
You must be signed in to change notification settings - Fork 213
/
Copy pathapi.ts
122 lines (106 loc) · 3.08 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
import { publish as _publish, IPublishOptions, unpublish as _unpublish, IUnpublishOptions } from './publish';
import { packageCommand, listFiles as _listFiles, IPackageOptions } from './package';
/**
* @deprecated prefer IPackageOptions instead
* @public
*/
export type IBaseVSIXOptions = Pick<
IPackageOptions,
'baseContentUrl' | 'baseImagesUrl' | 'githubBranch' | 'gitlabBranch' | 'useYarn' | 'target' | 'preRelease'
>;
/**
* @deprecated prefer IPackageOptions instead
* @public
*/
export type ICreateVSIXOptions = Pick<IPackageOptions, 'cwd' | 'packagePath'> & IBaseVSIXOptions;
/**
* The supported list of package managers.
* @public
*/
export enum PackageManager {
Npm,
Yarn,
None,
}
/**
* Options for the `listFiles` function.
* @public
*/
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;
/**
* A subset of the top level dependencies which should be included. The
* default is `undefined` which include all dependencies, an empty array means
* no dependencies will be included.
*/
packagedDependencies?: string[];
/**
* The location of an alternative .vscodeignore file to be used.
* The `.vscodeignore` file located at the root of the project will be taken
* instead, if none is specified.
*/
ignoreFile?: string;
}
export type { IPackageOptions } from './package';
/**
* Creates a VSIX from the extension in the current working directory.
* @public
*/
export function createVSIX(options: IPackageOptions = {}): Promise<any> {
return packageCommand(options);
}
export type { IPublishOptions } from './publish';
/**
* Publishes the extension in the current working directory.
* @public
*/
export function publish(options: IPublishOptions = {}): Promise<any> {
return _publish(options);
}
/**
* Lists the files included in the extension's package.
* @public
*/
export function listFiles(options: IListFilesOptions = {}): Promise<string[]> {
return _listFiles({
...options,
useYarn: options.packageManager === PackageManager.Yarn,
dependencies: options.packageManager !== PackageManager.None,
});
}
/**
* Options for the `publishVSIX` function.
* @public
*/
export type IPublishVSIXOptions = IPublishOptions & Pick<IPackageOptions, 'target'>;
/**
* Publishes a pre-build VSIX.
* @public
*/
export function publishVSIX(packagePath: string | string[], options: IPublishVSIXOptions = {}): Promise<any> {
return _publish({
packagePath: typeof packagePath === 'string' ? [packagePath] : packagePath,
...options,
targets: typeof options.target === 'string' ? [options.target] : undefined,
...{ target: undefined },
});
}
/**
* Options for the `unpublishVSIX` function.
* @public
*/
export type IUnpublishVSIXOptions = IPublishOptions & Pick<IUnpublishOptions, 'id'>;
/**
* Deletes a specific extension from the marketplace.
* @public
*/
export function unpublishVSIX(options: IUnpublishVSIXOptions = {}): Promise<any> {
return _unpublish({ force: true, ...options });
}