check for supported web extensions also while packing

This commit is contained in:
Sandeep Somavarapu 2020-08-24 16:35:44 +02:00
parent 665047b6d2
commit fb9170a707
3 changed files with 12 additions and 11 deletions

View file

@ -76,7 +76,7 @@ module.exports = function (argv: string[]): void {
.option('--yarn', 'Use yarn instead of npm')
.option('--ignoreFile [path]', 'Indicate alternative .vscodeignore')
.option('--noGitHubIssueLinking', 'Prevent automatic expansion of GitHub-style issue syntax into links')
.option('--web', 'Experimental flag to enable packing web extension')
.option('--web', 'Experimental flag to enable packing web extensions. Note: This is supported only for selected extensions.')
.action(({ out, githubBranch, baseContentUrl, baseImagesUrl, yarn, ignoreFile, noGitHubIssueLinking, web }) => main(packageCommand({ packagePath: out, githubBranch, baseContentUrl, baseImagesUrl, useYarn: yarn, ignoreFile, expandGitHubIssueLinks: noGitHubIssueLinking, web })));
program
@ -91,7 +91,7 @@ module.exports = function (argv: string[]): void {
.option('--yarn', 'Use yarn instead of npm while packing extension files')
.option('--noVerify')
.option('--ignoreFile [path]', 'Indicate alternative .vscodeignore')
.option('--web', 'Experimental flag to enable publishing web extension. Note: This is supported only for selected extensions.')
.option('--web', 'Experimental flag to enable packing web extensions. Note: This is supported only for selected extensions.')
.action((version, { pat, message, packagePath, githubBranch, baseContentUrl, baseImagesUrl, yarn, noVerify, ignoreFile, web }) => main(publish({ pat, commitMessage: message, version, packagePath, githubBranch, baseContentUrl, baseImagesUrl, useYarn: yarn, noVerify, ignoreFile, web })));
program

View file

@ -17,6 +17,7 @@ import * as urljoin from 'url-join';
import { validatePublisher, validateExtensionName, validateVersion, validateEngineCompatibility, validateVSCodeTypesCompatibility } from './validation';
import { getDependencies } from './npm';
import { IExtensionsReport } from './publicgalleryapi';
import { getPublicGalleryAPI } from './util';
const readFile = denodeify<string, string, string>(fs.readFile);
const unlink = denodeify<string, void>(fs.unlink as any);
@ -1060,6 +1061,13 @@ export async function pack(options: IPackageOptions = {}): Promise<IPackageResul
const manifest = await readManifest(cwd);
if (options.web && isWebKind(manifest)) {
const extensionsReport = await getPublicGalleryAPI().getExtensionsReport();
if (!isSupportedWebExtension(manifest, extensionsReport)) {
throw new Error(`This extension can\'t be packed as web extension because it is not supported`);
}
}
await prepublish(cwd, manifest, options.useYarn);
const files = await collect(manifest, options);

View file

@ -1,9 +1,9 @@
import * as fs from 'fs';
import { ExtensionQueryFlags, PublishedExtension } from 'azure-devops-node-api/interfaces/GalleryInterfaces';
import { pack, readManifest, IPackage, isWebKind, isSupportedWebExtension } from './package';
import { pack, readManifest, IPackage } from './package';
import * as tmp from 'tmp';
import { getPublisher } from './store';
import { getGalleryAPI, read, getPublishedUrl, log, getPublicGalleryAPI } from './util';
import { getGalleryAPI, read, getPublishedUrl, log } from './util';
import { Manifest } from './manifest';
import * as denodeify from 'denodeify';
import * as yauzl from 'yauzl';
@ -175,13 +175,6 @@ export function publish(options: IPublishOptions = {}): Promise<any> {
throw new Error('Extensions using proposed API (enableProposedApi: true) can\'t be published to the Marketplace');
}
if (options.web && isWebKind(manifest)) {
const extensionsReport = await getPublicGalleryAPI().getExtensionsReport();
if (!isSupportedWebExtension(manifest, extensionsReport)) {
throw new Error(`Unsupported web extensions can\'t be published to the Marketplace`);
}
}
const patPromise = options.pat
? Promise.resolve(options.pat)
: getPublisher(manifest.publisher).then(p => p.pat);