Skip to content

Commit 2c60208

Browse files
authored
Merge pull request #654 from microsoft/sandy081/preReleases
feat: add --pre-release flag and support
2 parents 4d571f2 + 376a6a8 commit 2c60208

File tree

4 files changed

+29
-0
lines changed

4 files changed

+29
-0
lines changed

src/main.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ module.exports = function (argv: string[]): void {
102102
.option('--no-gitHubIssueLinking', 'Disable automatic expansion of GitHub-style issue syntax into links')
103103
.option('--no-gitLabIssueLinking', 'Disable automatic expansion of GitLab-style issue syntax into links')
104104
.option('--no-dependencies', 'Disable dependency detection via npm or yarn')
105+
.option('--pre-release', 'Mark this package as a pre-release')
105106
.action(
106107
(
107108
version,
@@ -121,6 +122,7 @@ module.exports = function (argv: string[]): void {
121122
gitHubIssueLinking,
122123
gitLabIssueLinking,
123124
dependencies,
125+
preRelease,
124126
}
125127
) =>
126128
main(
@@ -141,6 +143,7 @@ module.exports = function (argv: string[]): void {
141143
gitHubIssueLinking,
142144
gitLabIssueLinking,
143145
dependencies,
146+
preRelease,
144147
})
145148
)
146149
);
@@ -176,6 +179,7 @@ module.exports = function (argv: string[]): void {
176179
.option('--noVerify')
177180
.option('--ignoreFile <path>', 'Indicate alternative .vscodeignore')
178181
.option('--no-dependencies', 'Disable dependency detection via npm or yarn')
182+
.option('--pre-release', 'Mark this package as a pre-release')
179183
.action(
180184
(
181185
version,
@@ -194,6 +198,7 @@ module.exports = function (argv: string[]): void {
194198
noVerify,
195199
ignoreFile,
196200
dependencies,
201+
preRelease,
197202
}
198203
) =>
199204
main(
@@ -213,6 +218,7 @@ module.exports = function (argv: string[]): void {
213218
noVerify,
214219
ignoreFile,
215220
dependencies,
221+
preRelease,
216222
})
217223
)
218224
);

src/package.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ export interface IPackageOptions {
8585
readonly gitHubIssueLinking?: boolean;
8686
readonly gitLabIssueLinking?: boolean;
8787
readonly dependencies?: boolean;
88+
readonly preRelease?: boolean;
8889
}
8990

9091
export interface IProcessor {
@@ -124,6 +125,7 @@ export interface VSIX {
124125
extensionPack: string;
125126
extensionKind: string;
126127
localizedLanguages: string;
128+
preRelease: boolean;
127129
}
128130

129131
export class BaseProcessor implements IProcessor {
@@ -438,6 +440,7 @@ export class ManifestProcessor extends BaseProcessor {
438440
.map(loc => loc.localizedLanguageName ?? loc.languageName ?? loc.languageId)
439441
.join(',')
440442
: '',
443+
preRelease: !!this.options.preRelease,
441444
};
442445

443446
if (isGitHub) {
@@ -1248,6 +1251,7 @@ export async function toVsixManifest(vsix: VSIX): Promise<string> {
12481251
<Property Id="Microsoft.VisualStudio.Code.ExtensionPack" Value="${escape(vsix.extensionPack)}" />
12491252
<Property Id="Microsoft.VisualStudio.Code.ExtensionKind" Value="${escape(vsix.extensionKind)}" />
12501253
<Property Id="Microsoft.VisualStudio.Code.LocalizedLanguages" Value="${escape(vsix.localizedLanguages)}" />
1254+
${vsix.preRelease ? `<Property Id="Microsoft.VisualStudio.Code.PreRelease" Value="${escape(vsix.preRelease)}" />` : ''}
12511255
${
12521256
!vsix.links.repository
12531257
? ''

src/publish.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export interface IPublishOptions {
3030
readonly pat?: string;
3131
readonly noVerify?: boolean;
3232
readonly dependencies?: boolean;
33+
readonly preRelease?: boolean;
3334
}
3435

3536
export async function publish(options: IPublishOptions = {}): Promise<any> {

src/test/package.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1639,6 +1639,24 @@ describe('toVsixManifest', () => {
16391639

16401640
throw new Error('Should not reach here');
16411641
});
1642+
1643+
it('should add prerelease property when --pre-release flag is passed', async () => {
1644+
const manifest = createManifest();
1645+
1646+
const raw = await _toVsixManifest(manifest, [], { preRelease: true });
1647+
const xmlManifest = await parseXmlManifest(raw);
1648+
1649+
assertProperty(xmlManifest, 'Microsoft.VisualStudio.Code.PreRelease', 'true');
1650+
});
1651+
1652+
it('should not add prerelease property when --pre-release flag is not passed', async () => {
1653+
const manifest = createManifest();
1654+
1655+
const raw = await _toVsixManifest(manifest, []);
1656+
const xmlManifest = await parseXmlManifest(raw);
1657+
1658+
assertMissingProperty(xmlManifest, 'Microsoft.VisualStudio.Code.PreRelease');
1659+
});
16421660
});
16431661

16441662
describe('qna', () => {

0 commit comments

Comments
 (0)