From 35e97165087283eb851026637eec72f84922a5cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Moreno?= Date: Thu, 4 Nov 2021 16:29:23 +0100 Subject: [PATCH] fix: validate version with prerelease at publish time Closes: #425 --- src/publish.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/publish.ts b/src/publish.ts index 3e4293e4..7bb583c4 100644 --- a/src/publish.ts +++ b/src/publish.ts @@ -1,5 +1,6 @@ import * as fs from 'fs'; import { promisify } from 'util'; +import * as semver from 'semver'; import { ExtensionQueryFlags, PublishedExtension } from 'azure-devops-node-api/interfaces/GalleryInterfaces'; import { pack, readManifest, versionBump, prepublish } from './package'; import * as tmp from 'tmp'; @@ -81,6 +82,10 @@ async function _publish(packagePath: string, manifest: Manifest, options: IInter throw new Error("Extensions using proposed API (enableProposedApi: true) can't be published to the Marketplace"); } + if (semver.prerelease(manifest.version)) { + throw new Error(`The VS Marketplace doesn't support prerelease versions: '${manifest.version}'`); + } + const pat = options.pat ?? (await getPublisher(manifest.publisher)).pat; const api = await getGalleryAPI(pat); const packageStream = fs.createReadStream(packagePath);