From 8e193c9f074da4560ffdfcb18b8e80e0a343c167 Mon Sep 17 00:00:00 2001 From: Nicolas Hedger <649677+nhedger@users.noreply.github.com> Date: Mon, 29 Aug 2022 09:34:16 +0200 Subject: [PATCH] feat: expose all options to packaging and publishing APIs (#759) * feat: expose all options to packaging api * feat: expose all options to the publishing api * fix: remove extraneous version property * feat: re-export `IPackageOptions` * chore: move comments * fix: export type `IPackageOptions` --- src/api.ts | 114 ++++++++----------------------------------------- src/package.ts | 43 +++++++++++++++++++ src/publish.ts | 24 +++++++++++ 3 files changed, 85 insertions(+), 96 deletions(-) diff --git a/src/api.ts b/src/api.ts index 87ec33fc..1dafb675 100644 --- a/src/api.ts +++ b/src/api.ts @@ -1,93 +1,20 @@ -import { publish as _publish } from './publish'; -import { packageCommand, listFiles as _listFiles } from './package'; +import { publish as _publish, IPublishOptions as _IPublishOptions } from './publish'; +import { packageCommand, listFiles as _listFiles, IPackageOptions } from './package'; -export interface IBaseVSIXOptions { - /** - * The base URL for links detected in Markdown files. - */ - baseContentUrl?: string; - - /** - * The base URL for images detected in Markdown files. - */ - baseImagesUrl?: string; - - /** - * Github branch used to publish the package. Used to automatically infer - * the base content and images URI. - */ - githubBranch?: string; - - /** - * Gitlab branch used to publish the package. Used to automatically infer - * the base content and images URI. - */ - gitlabBranch?: string; - - /** - * 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; - - /** - * Mark this package as a pre-release - */ - preRelease?: boolean; -} - -export interface ICreateVSIXOptions extends IBaseVSIXOptions { - /** - * 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; -} - -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; +export type { IPackageOptions } from './package'; - /** - * The base URL for images detected in Markdown files. - */ - baseImagesUrl?: string; +/** + * @deprecated prefer IPackageOptions instead + */ +export type IBaseVSIXOptions = Pick< + IPackageOptions, + 'baseContentUrl' | 'baseImagesUrl' | 'githubBranch' | 'gitlabBranch' | 'useYarn' | 'target' | 'preRelease' +>; - /** - * Should use Yarn instead of NPM. - */ - useYarn?: boolean; -} +/** + * @deprecated prefer IPackageOptions instead + */ +export type ICreateVSIXOptions = Pick & IBaseVSIXOptions; /** * The supported list of package managers. @@ -124,19 +51,14 @@ export interface IListFilesOptions { ignoreFile?: string; } -export interface IPublishVSIXOptions extends IBaseVSIXOptions { - /** - * The Personal Access Token to use. - * - * Defaults to the stored one. - */ - pat?: string; -} +export type IPublishVSIXOptions = IPublishOptions & Pick; + +export type IPublishOptions = _IPublishOptions; /** * Creates a VSIX from the extension in the current working directory. */ -export function createVSIX(options: ICreateVSIXOptions = {}): Promise { +export function createVSIX(options: IPackageOptions = {}): Promise { return packageCommand(options); } diff --git a/src/package.ts b/src/package.ts index e3669af6..9faf7a10 100644 --- a/src/package.ts +++ b/src/package.ts @@ -67,24 +67,67 @@ export interface IAsset { } export interface IPackageOptions { + /** + * The destination of the packaged the VSIX. + * + * Defaults to `NAME-VERSION.vsix`. + */ readonly packagePath?: string; readonly version?: string; + + /** + * Optional target the extension should run on. + * + * https://code.visualstudio.com/api/working-with-extensions/publishing-extension#platformspecific-extensions + */ readonly target?: string; readonly commitMessage?: string; readonly gitTagVersion?: boolean; readonly updatePackageJson?: boolean; + + /** + * The location of the extension in the file system. + * + * Defaults to `process.cwd()`. + */ readonly cwd?: string; + + /** + * Github branch used to publish the package. Used to automatically infer + * the base content and images URI. + */ readonly githubBranch?: string; + + /** + * Gitlab branch used to publish the package. Used to automatically infer + * the base content and images URI. + */ readonly gitlabBranch?: string; + readonly rewriteRelativeLinks?: boolean; + /** + * The base URL for links detected in Markdown files. + */ readonly baseContentUrl?: string; + + /** + * The base URL for images detected in Markdown files. + */ readonly baseImagesUrl?: string; + + /** + * Should use Yarn instead of NPM. + */ readonly useYarn?: boolean; readonly dependencyEntryPoints?: string[]; readonly ignoreFile?: string; readonly gitHubIssueLinking?: boolean; readonly gitLabIssueLinking?: boolean; readonly dependencies?: boolean; + + /** + * Mark this package as a pre-release + */ readonly preRelease?: boolean; readonly allowStarActivation?: boolean; readonly allowMissingRepository?: boolean; diff --git a/src/publish.ts b/src/publish.ts index 110b03f4..8c0ea447 100644 --- a/src/publish.ts +++ b/src/publish.ts @@ -19,14 +19,38 @@ export interface IPublishOptions { readonly commitMessage?: string; readonly gitTagVersion?: boolean; readonly updatePackageJson?: boolean; + + /** + * The location of the extension in the file system. + * + * Defaults to `process.cwd()`. + */ readonly cwd?: string; readonly githubBranch?: string; readonly gitlabBranch?: string; + + /** + * The base URL for links detected in Markdown files. + */ readonly baseContentUrl?: string; + + /** + * The base URL for images detected in Markdown files. + */ readonly baseImagesUrl?: string; + + /** + * Should use Yarn instead of NPM. + */ readonly useYarn?: boolean; readonly dependencyEntryPoints?: string[]; readonly ignoreFile?: string; + + /** + * The Personal Access Token to use. + * + * Defaults to the stored one. + */ readonly pat?: string; readonly noVerify?: boolean; readonly dependencies?: boolean;