@vscode/vsce 3.0.0 → 3.0.1-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/out/package.js CHANGED
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.printAndValidatePackagedFiles = exports.ls = exports.listFiles = exports.packageCommand = exports.createSignatureArchive = exports.generateManifest = exports.signPackage = exports.pack = exports.prepublish = exports.collect = exports.createDefaultProcessors = exports.processFiles = exports.toContentTypes = exports.toVsixManifest = exports.readManifest = exports.validateManifest = exports.ValidationProcessor = exports.NLSProcessor = exports.isWebKind = exports.LicenseProcessor = exports.ChangelogProcessor = exports.ReadmeProcessor = exports.MarkdownProcessor = exports.TagsProcessor = exports.ManifestProcessor = exports.Targets = exports.versionBump = exports.BaseProcessor = exports.read = void 0;
29
+ exports.printAndValidatePackagedFiles = exports.ls = exports.listFiles = exports.packageCommand = exports.createSignatureArchive = exports.generateManifest = exports.signPackage = exports.pack = exports.prepublish = exports.collect = exports.createDefaultProcessors = exports.processFiles = exports.toContentTypes = exports.toVsixManifest = exports.readManifest = exports.validateManifestForPackaging = exports.ValidationProcessor = exports.NLSProcessor = exports.isWebKind = exports.LicenseProcessor = exports.ChangelogProcessor = exports.ReadmeProcessor = exports.MarkdownProcessor = exports.TagsProcessor = exports.ManifestProcessor = exports.Targets = exports.versionBump = exports.BaseProcessor = exports.read = void 0;
30
30
  const fs = __importStar(require("fs"));
31
31
  const path = __importStar(require("path"));
32
32
  const util_1 = require("util");
@@ -302,7 +302,7 @@ class ManifestProcessor extends BaseProcessor {
302
302
  if (target || preRelease) {
303
303
  let engineVersion;
304
304
  try {
305
- const engineSemver = (0, parse_semver_1.default)(`vscode@${manifest.engines['vscode']}`);
305
+ const engineSemver = (0, parse_semver_1.default)(`vscode@${manifest.engines.vscode}`);
306
306
  engineVersion = engineSemver.version;
307
307
  }
308
308
  catch (err) {
@@ -310,7 +310,7 @@ class ManifestProcessor extends BaseProcessor {
310
310
  }
311
311
  if (target) {
312
312
  if (engineVersion !== 'latest' && !semver.satisfies(engineVersion, '>=1.61', { includePrerelease: true })) {
313
- throw new Error(`Platform specific extension is supported by VS Code >=1.61. Current 'engines.vscode' is '${manifest.engines['vscode']}'.`);
313
+ throw new Error(`Platform specific extension is supported by VS Code >=1.61. Current 'engines.vscode' is '${manifest.engines.vscode}'.`);
314
314
  }
315
315
  if (!exports.Targets.has(target)) {
316
316
  throw new Error(`'${target}' is not a valid VS Code target. Valid targets: ${[...exports.Targets].join(', ')}`);
@@ -318,7 +318,7 @@ class ManifestProcessor extends BaseProcessor {
318
318
  }
319
319
  if (preRelease) {
320
320
  if (engineVersion !== 'latest' && !semver.satisfies(engineVersion, '>=1.63', { includePrerelease: true })) {
321
- throw new Error(`Pre-release versions are supported by VS Code >=1.63. Current 'engines.vscode' is '${manifest.engines['vscode']}'.`);
321
+ throw new Error(`Pre-release versions are supported by VS Code >=1.63. Current 'engines.vscode' is '${manifest.engines.vscode}'.`);
322
322
  }
323
323
  }
324
324
  }
@@ -329,7 +329,7 @@ class ManifestProcessor extends BaseProcessor {
329
329
  version: options.version && !(options.updatePackageJson ?? true) ? options.version : manifest.version,
330
330
  publisher: manifest.publisher,
331
331
  target,
332
- engine: manifest.engines['vscode'],
332
+ engine: manifest.engines.vscode,
333
333
  description: manifest.description ?? '',
334
334
  pricing: manifest.pricing ?? 'Free',
335
335
  categories: (manifest.categories ?? []).join(','),
@@ -908,24 +908,18 @@ class ValidationProcessor extends BaseProcessor {
908
908
  }
909
909
  }
910
910
  exports.ValidationProcessor = ValidationProcessor;
911
- function validateManifest(manifest) {
912
- (0, validation_1.validateExtensionName)(manifest.name);
913
- (0, validation_1.validatePublisher)(manifest.publisher);
914
- if (!manifest.version) {
915
- throw new Error('Manifest missing field: version');
916
- }
917
- if (manifest.pricing && !['Free', 'Trial'].includes(manifest.pricing)) {
918
- throw new Error('Pricing can only be "Free" or "Trial"');
919
- }
920
- (0, validation_1.validateVersion)(manifest.version);
911
+ function validateManifestForPackaging(manifest) {
921
912
  if (!manifest.engines) {
922
913
  throw new Error('Manifest missing field: engines');
923
914
  }
924
- if (!manifest.engines['vscode']) {
925
- throw new Error('Manifest missing field: engines.vscode');
915
+ const engines = { ...manifest.engines, vscode: (0, validation_1.validateEngineCompatibility)(manifest.engines.vscode) };
916
+ const name = (0, validation_1.validateExtensionName)(manifest.name);
917
+ const version = (0, validation_1.validateVersion)(manifest.version);
918
+ // allow users to package an extension without a publisher for testing reasons
919
+ const publisher = manifest.publisher ? (0, validation_1.validatePublisher)(manifest.publisher) : undefined;
920
+ if (manifest.pricing && !['Free', 'Trial'].includes(manifest.pricing)) {
921
+ throw new Error('Pricing can only be "Free" or "Trial"');
926
922
  }
927
- const engineVersion = manifest.engines['vscode'];
928
- (0, validation_1.validateEngineCompatibility)(engineVersion);
929
923
  const hasActivationEvents = !!manifest.activationEvents;
930
924
  const hasImplicitLanguageActivationEvents = manifest.contributes?.languages;
931
925
  const hasOtherImplicitActivationEvents = manifest.contributes?.commands ||
@@ -937,14 +931,14 @@ function validateManifest(manifest) {
937
931
  const hasBrowser = !!manifest.browser;
938
932
  let parsedEngineVersion;
939
933
  try {
940
- const engineSemver = (0, parse_semver_1.default)(`vscode@${engineVersion}`);
934
+ const engineSemver = (0, parse_semver_1.default)(`vscode@${engines.vscode}`);
941
935
  parsedEngineVersion = engineSemver.version;
942
936
  }
943
937
  catch (err) {
944
938
  throw new Error('Failed to parse semver of engines.vscode');
945
939
  }
946
940
  if (hasActivationEvents ||
947
- ((engineVersion === '*' || semver.satisfies(parsedEngineVersion, '>=1.74', { includePrerelease: true })) &&
941
+ ((engines.vscode === '*' || semver.satisfies(parsedEngineVersion, '>=1.74', { includePrerelease: true })) &&
948
942
  hasImplicitActivationEvents)) {
949
943
  if (!hasMain && !hasBrowser && (hasActivationEvents || !hasImplicitLanguageActivationEvents)) {
950
944
  throw new Error("Manifest needs either a 'main' or 'browser' property, given it has a 'activationEvents' property.");
@@ -957,7 +951,7 @@ function validateManifest(manifest) {
957
951
  throw new Error("Manifest needs the 'activationEvents' property, given it has a 'browser' property.");
958
952
  }
959
953
  if (manifest.devDependencies && manifest.devDependencies['@types/vscode']) {
960
- (0, validation_1.validateVSCodeTypesCompatibility)(manifest.engines['vscode'], manifest.devDependencies['@types/vscode']);
954
+ (0, validation_1.validateVSCodeTypesCompatibility)(engines.vscode, manifest.devDependencies['@types/vscode']);
961
955
  }
962
956
  if (/\.svg$/i.test(manifest.icon || '')) {
963
957
  throw new Error(`SVGs can't be used as icons: ${manifest.icon}`);
@@ -1008,9 +1002,15 @@ function validateManifest(manifest) {
1008
1002
  throw new Error(`Manifest contains invalid value '${manifest.sponsor.url}' in the 'sponsor' property. It must be a valid URL with a HTTP or HTTPS protocol.`);
1009
1003
  }
1010
1004
  }
1011
- return manifest;
1005
+ return {
1006
+ ...manifest,
1007
+ name,
1008
+ version,
1009
+ engines,
1010
+ publisher,
1011
+ };
1012
1012
  }
1013
- exports.validateManifest = validateManifest;
1013
+ exports.validateManifestForPackaging = validateManifestForPackaging;
1014
1014
  function readManifest(cwd = process.cwd(), nls = true) {
1015
1015
  const manifestPath = path.join(cwd, 'package.json');
1016
1016
  const manifestNLSPath = path.join(cwd, 'package.nls.json');
@@ -1026,7 +1026,7 @@ function readManifest(cwd = process.cwd(), nls = true) {
1026
1026
  throw e;
1027
1027
  }
1028
1028
  })
1029
- .then(validateManifest);
1029
+ .then(validateManifestForPackaging);
1030
1030
  if (!nls) {
1031
1031
  return manifest;
1032
1032
  }
package/out/publish.js CHANGED
@@ -77,7 +77,7 @@ async function publish(options = {}) {
77
77
  throw new Error(`Cannot use '--pre-release' flag with a package that was not packaged as pre-release. Please package it using the '--pre-release' flag and publish again.`);
78
78
  }
79
79
  }
80
- validateMarketplaceRequirements(vsix.manifest, options);
80
+ const manifestValidated = validateManifestForPublishing(vsix.manifest, options);
81
81
  let sigzipPath;
82
82
  if (options.manifestPath?.[index] && options.signaturePath?.[index]) {
83
83
  sigzipPath = await (0, package_1.createSignatureArchive)(options.manifestPath[index], options.signaturePath[index]);
@@ -88,7 +88,7 @@ async function publish(options = {}) {
88
88
  if (!sigzipPath && options.signTool) {
89
89
  sigzipPath = await (0, package_1.signPackage)(packagePath, options.signTool);
90
90
  }
91
- await _publish(packagePath, sigzipPath, vsix.manifest, { ...options, target });
91
+ await _publish(packagePath, sigzipPath, manifestValidated, { ...options, target });
92
92
  }
93
93
  }
94
94
  else {
@@ -96,22 +96,24 @@ async function publish(options = {}) {
96
96
  const manifest = await (0, package_1.readManifest)(cwd);
97
97
  (0, util_2.patchOptionsWithManifest)(options, manifest);
98
98
  // Validate marketplace requirements before prepublish to avoid unnecessary work
99
- validateMarketplaceRequirements(manifest, options);
99
+ validateManifestForPublishing(manifest, options);
100
100
  await (0, package_1.prepublish)(cwd, manifest, options.useYarn);
101
101
  await (0, package_1.versionBump)(options);
102
102
  if (options.targets) {
103
103
  for (const target of options.targets) {
104
104
  const packagePath = await tmpName();
105
105
  const packageResult = await (0, package_1.pack)({ ...options, target, packagePath });
106
+ const manifestValidated = validateManifestForPublishing(packageResult.manifest, options);
106
107
  const sigzipPath = options.signTool ? await (0, package_1.signPackage)(packagePath, options.signTool) : undefined;
107
- await _publish(packagePath, sigzipPath, packageResult.manifest, { ...options, target });
108
+ await _publish(packagePath, sigzipPath, manifestValidated, { ...options, target });
108
109
  }
109
110
  }
110
111
  else {
111
112
  const packagePath = await tmpName();
112
113
  const packageResult = await (0, package_1.pack)({ ...options, packagePath });
114
+ const manifestValidated = validateManifestForPublishing(packageResult.manifest, options);
113
115
  const sigzipPath = options.signTool ? await (0, package_1.signPackage)(packagePath, options.signTool) : undefined;
114
- await _publish(packagePath, sigzipPath, packageResult.manifest, options);
116
+ await _publish(packagePath, sigzipPath, manifestValidated, options);
115
117
  }
116
118
  }
117
119
  }
@@ -219,7 +221,7 @@ async function unpublish(options = {}) {
219
221
  }
220
222
  else {
221
223
  const manifest = await (0, package_1.readManifest)(options.cwd);
222
- publisher = manifest.publisher;
224
+ publisher = (0, validation_1.validatePublisher)(manifest.publisher);
223
225
  name = manifest.name;
224
226
  }
225
227
  const fullName = `${publisher}.${name}`;
@@ -235,8 +237,7 @@ async function unpublish(options = {}) {
235
237
  util_2.log.done(`Deleted extension: ${fullName}!`);
236
238
  }
237
239
  exports.unpublish = unpublish;
238
- function validateMarketplaceRequirements(manifest, options) {
239
- (0, validation_1.validatePublisher)(manifest.publisher);
240
+ function validateManifestForPublishing(manifest, options) {
240
241
  if (manifest.enableProposedApi && !options.allowAllProposedApis && !options.noVerify) {
241
242
  throw new Error("Extensions using proposed API (enableProposedApi: true) can't be published to the Marketplace. Use --allow-all-proposed-apis to bypass. https://code.visualstudio.com/api/advanced-topics/using-proposed-api");
242
243
  }
@@ -246,6 +247,7 @@ function validateMarketplaceRequirements(manifest, options) {
246
247
  if (semver.prerelease(manifest.version)) {
247
248
  throw new Error(`The VS Marketplace doesn't support prerelease versions: '${manifest.version}'. Checkout our pre-release versioning recommendation here: https://code.visualstudio.com/api/working-with-extensions/publishing-extension#prerelease-extensions`);
248
249
  }
250
+ return { ...manifest, publisher: (0, validation_1.validatePublisher)(manifest.publisher) };
249
251
  }
250
252
  async function getPAT(publisher, options) {
251
253
  if (options.pat) {
package/out/store.js CHANGED
@@ -113,7 +113,7 @@ class KeytarStore {
113
113
  }
114
114
  exports.KeytarStore = KeytarStore;
115
115
  async function verifyPat(options) {
116
- const publisherName = options.publisherName ?? (await (0, package_1.readManifest)()).publisher;
116
+ const publisherName = options.publisherName ?? (0, validation_1.validatePublisher)((await (0, package_1.readManifest)()).publisher);
117
117
  const pat = await (0, publish_1.getPAT)(publisherName, options);
118
118
  try {
119
119
  // If the caller of the `getRoleAssignments` API has any of the roles
package/out/validation.js CHANGED
@@ -37,6 +37,7 @@ function validatePublisher(publisher) {
37
37
  if (!nameRegex.test(publisher)) {
38
38
  throw new Error(`Invalid publisher name '${publisher}'. Expected the identifier of a publisher, not its human-friendly name. Learn more: https://code.visualstudio.com/api/working-with-extensions/publishing-extension#publishing-extensions`);
39
39
  }
40
+ return publisher;
40
41
  }
41
42
  exports.validatePublisher = validatePublisher;
42
43
  function validateExtensionName(name) {
@@ -46,6 +47,7 @@ function validateExtensionName(name) {
46
47
  if (!nameRegex.test(name)) {
47
48
  throw new Error(`Invalid extension name '${name}'`);
48
49
  }
50
+ return name;
49
51
  }
50
52
  exports.validateExtensionName = validateExtensionName;
51
53
  function validateVersion(version) {
@@ -55,6 +57,7 @@ function validateVersion(version) {
55
57
  if (!semver.valid(version)) {
56
58
  throw new Error(`Invalid extension version '${version}'`);
57
59
  }
60
+ return version;
58
61
  }
59
62
  exports.validateVersion = validateVersion;
60
63
  function validateEngineCompatibility(version) {
@@ -64,6 +67,7 @@ function validateEngineCompatibility(version) {
64
67
  if (!/^\*$|^(\^|>=)?((\d+)|x)\.((\d+)|x)\.((\d+)|x)(\-.*)?$/.test(version)) {
65
68
  throw new Error(`Invalid vscode engine compatibility version '${version}'`);
66
69
  }
70
+ return version;
67
71
  }
68
72
  exports.validateEngineCompatibility = validateEngineCompatibility;
69
73
  /**
package/out/zip.js CHANGED
@@ -4,6 +4,7 @@ exports.readVSIXPackage = exports.readZip = void 0;
4
4
  const yauzl_1 = require("yauzl");
5
5
  const xml_1 = require("./xml");
6
6
  const util_1 = require("./util");
7
+ const package_1 = require("./package");
7
8
  async function bufferStream(stream) {
8
9
  return await new Promise((c, e) => {
9
10
  const buffers = [];
@@ -49,8 +50,16 @@ async function readVSIXPackage(packagePath) {
49
50
  if (!rawXmlManifest) {
50
51
  throw new Error('VSIX manifest not found');
51
52
  }
53
+ const manifest = JSON.parse(rawManifest.toString('utf8'));
54
+ let manifestValidated;
55
+ try {
56
+ manifestValidated = (0, package_1.validateManifestForPackaging)(manifest);
57
+ }
58
+ catch (error) {
59
+ throw new Error(`Invalid extension VSIX manifest: ${error}`);
60
+ }
52
61
  return {
53
- manifest: JSON.parse(rawManifest.toString('utf8')),
62
+ manifest: manifestValidated,
54
63
  xmlManifest: await (0, xml_1.parseXmlManifest)(rawXmlManifest.toString('utf8')),
55
64
  };
56
65
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vscode/vsce",
3
- "version": "3.0.0",
3
+ "version": "3.0.1-1",
4
4
  "description": "VS Code Extensions Manager",
5
5
  "repository": {
6
6
  "type": "git",
@@ -50,7 +50,7 @@
50
50
  "hosted-git-info": "^4.0.2",
51
51
  "jsonc-parser": "^3.2.0",
52
52
  "leven": "^3.1.0",
53
- "markdown-it": "^12.3.2",
53
+ "markdown-it": "^14.1.0",
54
54
  "mime": "^1.3.4",
55
55
  "minimatch": "^3.0.3",
56
56
  "parse-semver": "^1.1.1",