From 4d571f22828a301ecc016eb0cdbdfe1d2c3ab5a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Moreno?= Date: Mon, 22 Nov 2021 13:31:43 +0100 Subject: [PATCH] feat(api): :sparkles: add target options to API Closes: #652 --- .vscode/settings.json | 3 ++- src/api.ts | 20 ++++++++++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index dd7a48ba..2d381754 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -14,5 +14,6 @@ }, "[typescript]": { "editor.defaultFormatter": "esbenp.prettier-vscode" - } + }, + "conventionalCommits.scopes": ["api"] } diff --git a/src/api.ts b/src/api.ts index 99c21e51..21d3d14b 100644 --- a/src/api.ts +++ b/src/api.ts @@ -1,7 +1,7 @@ import { publish as _publish } from './publish'; import { packageCommand, listFiles as _listFiles } from './package'; -export interface IVSIXOptions { +export interface IBaseVSIXOptions { /** * The base URL for links detected in Markdown files. */ @@ -28,9 +28,16 @@ export interface IVSIXOptions { * Should use Yarn instead of NPM. */ useYarn?: boolean; + + /** + * Optional target the extension should run on. + * + * https://code.visualstudio.com/api/working-with-extensions/publishing-extension#platformspecific-extensions + */ + target?: string; } -export interface ICreateVSIXOptions extends IVSIXOptions { +export interface ICreateVSIXOptions extends IBaseVSIXOptions { /** * The location of the extension in the file system. * @@ -112,7 +119,7 @@ export interface IListFilesOptions { ignoreFile?: string; } -export interface IPublishVSIXOptions extends IVSIXOptions { +export interface IPublishVSIXOptions extends IBaseVSIXOptions { /** * The Personal Access Token to use. * @@ -146,5 +153,10 @@ export function listFiles(options: IListFilesOptions = {}): Promise { * Publishes a pre-build VSIX. */ export function publishVSIX(packagePath: string | string[], options: IPublishVSIXOptions = {}): Promise { - return _publish({ packagePath: typeof packagePath === 'string' ? [packagePath] : packagePath, ...options }); + return _publish({ + packagePath: typeof packagePath === 'string' ? [packagePath] : packagePath, + ...options, + targets: typeof options.target === 'string' ? [options.target] : undefined, + ...{ target: undefined }, + }); }