Skip to content

Commit

Permalink
Merge pull request #654 from microsoft/sandy081/preReleases
Browse files Browse the repository at this point in the history
feat: add --pre-release flag and support
  • Loading branch information
joaomoreno committed Nov 24, 2021
2 parents 4d571f2 + 376a6a8 commit 2c60208
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ module.exports = function (argv: string[]): void {
.option('--no-gitHubIssueLinking', 'Disable automatic expansion of GitHub-style issue syntax into links')
.option('--no-gitLabIssueLinking', 'Disable automatic expansion of GitLab-style issue syntax into links')
.option('--no-dependencies', 'Disable dependency detection via npm or yarn')
.option('--pre-release', 'Mark this package as a pre-release')
.action(
(
version,
Expand All @@ -121,6 +122,7 @@ module.exports = function (argv: string[]): void {
gitHubIssueLinking,
gitLabIssueLinking,
dependencies,
preRelease,
}
) =>
main(
Expand All @@ -141,6 +143,7 @@ module.exports = function (argv: string[]): void {
gitHubIssueLinking,
gitLabIssueLinking,
dependencies,
preRelease,
})
)
);
Expand Down Expand Up @@ -176,6 +179,7 @@ module.exports = function (argv: string[]): void {
.option('--noVerify')
.option('--ignoreFile <path>', 'Indicate alternative .vscodeignore')
.option('--no-dependencies', 'Disable dependency detection via npm or yarn')
.option('--pre-release', 'Mark this package as a pre-release')
.action(
(
version,
Expand All @@ -194,6 +198,7 @@ module.exports = function (argv: string[]): void {
noVerify,
ignoreFile,
dependencies,
preRelease,
}
) =>
main(
Expand All @@ -213,6 +218,7 @@ module.exports = function (argv: string[]): void {
noVerify,
ignoreFile,
dependencies,
preRelease,
})
)
);
Expand Down
4 changes: 4 additions & 0 deletions src/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export interface IPackageOptions {
readonly gitHubIssueLinking?: boolean;
readonly gitLabIssueLinking?: boolean;
readonly dependencies?: boolean;
readonly preRelease?: boolean;
}

export interface IProcessor {
Expand Down Expand Up @@ -124,6 +125,7 @@ export interface VSIX {
extensionPack: string;
extensionKind: string;
localizedLanguages: string;
preRelease: boolean;
}

export class BaseProcessor implements IProcessor {
Expand Down Expand Up @@ -438,6 +440,7 @@ export class ManifestProcessor extends BaseProcessor {
.map(loc => loc.localizedLanguageName ?? loc.languageName ?? loc.languageId)
.join(',')
: '',
preRelease: !!this.options.preRelease,
};

if (isGitHub) {
Expand Down Expand Up @@ -1248,6 +1251,7 @@ export async function toVsixManifest(vsix: VSIX): Promise<string> {
<Property Id="Microsoft.VisualStudio.Code.ExtensionPack" Value="${escape(vsix.extensionPack)}" />
<Property Id="Microsoft.VisualStudio.Code.ExtensionKind" Value="${escape(vsix.extensionKind)}" />
<Property Id="Microsoft.VisualStudio.Code.LocalizedLanguages" Value="${escape(vsix.localizedLanguages)}" />
${vsix.preRelease ? `<Property Id="Microsoft.VisualStudio.Code.PreRelease" Value="${escape(vsix.preRelease)}" />` : ''}
${
!vsix.links.repository
? ''
Expand Down
1 change: 1 addition & 0 deletions src/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export interface IPublishOptions {
readonly pat?: string;
readonly noVerify?: boolean;
readonly dependencies?: boolean;
readonly preRelease?: boolean;
}

export async function publish(options: IPublishOptions = {}): Promise<any> {
Expand Down
18 changes: 18 additions & 0 deletions src/test/package.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1639,6 +1639,24 @@ describe('toVsixManifest', () => {

throw new Error('Should not reach here');
});

it('should add prerelease property when --pre-release flag is passed', async () => {
const manifest = createManifest();

const raw = await _toVsixManifest(manifest, [], { preRelease: true });
const xmlManifest = await parseXmlManifest(raw);

assertProperty(xmlManifest, 'Microsoft.VisualStudio.Code.PreRelease', 'true');
});

it('should not add prerelease property when --pre-release flag is not passed', async () => {
const manifest = createManifest();

const raw = await _toVsixManifest(manifest, []);
const xmlManifest = await parseXmlManifest(raw);

assertMissingProperty(xmlManifest, 'Microsoft.VisualStudio.Code.PreRelease');
});
});

describe('qna', () => {
Expand Down

0 comments on commit 2c60208

Please sign in to comment.