Skip to content

Commit

Permalink
feat: expose all options to packaging and publishing APIs (#759)
Browse files Browse the repository at this point in the history
* 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`
  • Loading branch information
nhedger authored Aug 29, 2022
1 parent 5110bcf commit 8e193c9
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 96 deletions.
114 changes: 18 additions & 96 deletions src/api.ts
Original file line number Diff line number Diff line change
@@ -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<IPackageOptions, 'cwd' | 'packagePath'> & IBaseVSIXOptions;

/**
* The supported list of package managers.
Expand Down Expand Up @@ -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<IPackageOptions, 'target'>;

export type IPublishOptions = _IPublishOptions;

/**
* Creates a VSIX from the extension in the current working directory.
*/
export function createVSIX(options: ICreateVSIXOptions = {}): Promise<any> {
export function createVSIX(options: IPackageOptions = {}): Promise<any> {
return packageCommand(options);
}

Expand Down
43 changes: 43 additions & 0 deletions src/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
24 changes: 24 additions & 0 deletions src/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 8e193c9

Please sign in to comment.