@vscode/vsce 2.24.0 → 2.24.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/dist/vsce.d.ts CHANGED
@@ -172,6 +172,7 @@ export declare interface IPublishOptions {
172
172
  readonly allowMissingRepository?: boolean;
173
173
  readonly skipDuplicate?: boolean;
174
174
  readonly skipLicense?: boolean;
175
+ readonly sigzipPath?: string[];
175
176
  }
176
177
 
177
178
  /**
package/dummy.js ADDED
File without changes
package/out/main.js CHANGED
@@ -151,6 +151,7 @@ module.exports = function (argv) {
151
151
  .option('--no-git-tag-version', 'Do not create a version commit and tag when calling `npm version`. Valid only when [version] is provided.')
152
152
  .option('--no-update-package-json', 'Do not update `package.json`. Valid only when [version] is provided.')
153
153
  .option('-i, --packagePath <paths...>', 'Publish the provided VSIX packages.')
154
+ .option('--sigzipPath <paths...>', 'Signature archives to publish alongside the VSIX packages.')
154
155
  .option('--githubBranch <branch>', 'The GitHub branch used to infer relative links in README.md. Can be overridden by --baseContentUrl and --baseImagesUrl.')
155
156
  .option('--gitlabBranch <branch>', 'The GitLab branch used to infer relative links in README.md. Can be overridden by --baseContentUrl and --baseImagesUrl.')
156
157
  .option('--baseContentUrl <url>', 'Prepend all relative links in README.md with the specified URL.')
@@ -169,7 +170,7 @@ module.exports = function (argv) {
169
170
  .option('--allow-missing-repository', 'Allow missing a repository URL in package.json')
170
171
  .option('--skip-duplicate', 'Fail silently if version already exists on the marketplace')
171
172
  .option('--skip-license', 'Allow publishing without license file')
172
- .action((version, { pat, target, ignoreOtherTargetFolders, readmePath, changelogPath, message, gitTagVersion, updatePackageJson, packagePath, githubBranch, gitlabBranch, baseContentUrl, baseImagesUrl, yarn, noVerify, allowProposedApis, allowAllProposedApis, ignoreFile, dependencies, preRelease, allowStarActivation, allowMissingRepository, skipDuplicate, skipLicense, }) => main((0, publish_1.publish)({
173
+ .action((version, { pat, target, ignoreOtherTargetFolders, readmePath, changelogPath, message, gitTagVersion, updatePackageJson, packagePath, sigzipPath, githubBranch, gitlabBranch, baseContentUrl, baseImagesUrl, yarn, noVerify, allowProposedApis, allowAllProposedApis, ignoreFile, dependencies, preRelease, allowStarActivation, allowMissingRepository, skipDuplicate, skipLicense, }) => main((0, publish_1.publish)({
173
174
  pat,
174
175
  version,
175
176
  targets: target,
@@ -180,6 +181,7 @@ module.exports = function (argv) {
180
181
  gitTagVersion,
181
182
  updatePackageJson,
182
183
  packagePath,
184
+ sigzipPath,
183
185
  githubBranch,
184
186
  gitlabBranch,
185
187
  baseContentUrl,
package/out/package.js CHANGED
@@ -1160,12 +1160,21 @@ function getDependenciesOption(options) {
1160
1160
  return undefined;
1161
1161
  }
1162
1162
  }
1163
- function collectFiles(cwd, dependencies, dependencyEntryPoints, ignoreFile) {
1163
+ function collectFiles(cwd, dependencies, dependencyEntryPoints, ignoreFile, manifestFileIncludes) {
1164
1164
  return collectAllFiles(cwd, dependencies, dependencyEntryPoints).then(files => {
1165
1165
  files = files.filter(f => !/\r$/m.test(f));
1166
1166
  return (fs.promises
1167
1167
  .readFile(ignoreFile ? ignoreFile : path.join(cwd, '.vscodeignore'), 'utf8')
1168
- .catch(err => err.code !== 'ENOENT' ? Promise.reject(err) : ignoreFile ? Promise.reject(err) : Promise.resolve(''))
1168
+ .catch(err => err.code !== 'ENOENT' ?
1169
+ Promise.reject(err) :
1170
+ ignoreFile ?
1171
+ Promise.reject(err) :
1172
+ // No .vscodeignore file exists
1173
+ manifestFileIncludes ?
1174
+ // include all files in manifestFileIncludes and ignore the rest
1175
+ Promise.resolve(manifestFileIncludes.map(file => `!${file}`).concat(['**']).join('\n\r')) :
1176
+ // "files" property not used in package.json
1177
+ Promise.resolve(''))
1169
1178
  // Parse raw ignore by splitting output into lines and filtering out empty lines and comments
1170
1179
  .then(rawIgnore => rawIgnore
1171
1180
  .split(/[\n\r]/)
@@ -1233,7 +1242,7 @@ function collect(manifest, options = {}) {
1233
1242
  const packagedDependencies = options.dependencyEntryPoints || undefined;
1234
1243
  const ignoreFile = options.ignoreFile || undefined;
1235
1244
  const processors = createDefaultProcessors(manifest, options);
1236
- return collectFiles(cwd, getDependenciesOption(options), packagedDependencies, ignoreFile).then(fileNames => {
1245
+ return collectFiles(cwd, getDependenciesOption(options), packagedDependencies, ignoreFile, manifest.files).then(fileNames => {
1237
1246
  const files = fileNames.map(f => ({ path: `extension/${f}`, localPath: path.join(cwd, f) }));
1238
1247
  return processFiles(processors, files);
1239
1248
  });
@@ -1347,7 +1356,7 @@ async function listFiles(options = {}) {
1347
1356
  if (options.prepublish) {
1348
1357
  await prepublish(cwd, manifest, options.useYarn);
1349
1358
  }
1350
- return await collectFiles(cwd, getDependenciesOption(options), options.packagedDependencies, options.ignoreFile);
1359
+ return await collectFiles(cwd, getDependenciesOption(options), options.packagedDependencies, options.ignoreFile, manifest.files);
1351
1360
  }
1352
1361
  exports.listFiles = listFiles;
1353
1362
  /**
package/out/publish.js CHANGED
@@ -22,6 +22,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
25
28
  Object.defineProperty(exports, "__esModule", { value: true });
26
29
  exports.unpublish = exports.publish = void 0;
27
30
  const fs = __importStar(require("fs"));
@@ -34,6 +37,8 @@ const store_1 = require("./store");
34
37
  const util_2 = require("./util");
35
38
  const zip_1 = require("./zip");
36
39
  const validation_1 = require("./validation");
40
+ const form_data_1 = __importDefault(require("form-data"));
41
+ const path_1 = require("path");
37
42
  const tmpName = (0, util_1.promisify)(tmp.tmpName);
38
43
  async function publish(options = {}) {
39
44
  if (options.packagePath) {
@@ -43,7 +48,8 @@ async function publish(options = {}) {
43
48
  else if (options.targets) {
44
49
  throw new Error(`Both options not supported simultaneously: 'packagePath' and 'target'. Use 'vsce package --target <target>' to first create a platform specific package, then use 'vsce publish --packagePath <path>' to publish it.`);
45
50
  }
46
- for (const packagePath of options.packagePath) {
51
+ for (let index = 0; index < options.packagePath.length; index++) {
52
+ const packagePath = options.packagePath[index];
47
53
  const vsix = await (0, zip_1.readVSIXPackage)(packagePath);
48
54
  let target;
49
55
  try {
@@ -64,41 +70,34 @@ async function publish(options = {}) {
64
70
  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.`);
65
71
  }
66
72
  }
67
- await _publish(packagePath, vsix.manifest, { ...options, target });
73
+ validateMarketplaceRequirements(vsix.manifest, options);
74
+ await _publish(packagePath, options.sigzipPath?.[index], vsix.manifest, { ...options, target });
68
75
  }
69
76
  }
70
77
  else {
71
78
  const cwd = options.cwd || process.cwd();
72
79
  const manifest = await (0, package_1.readManifest)(cwd);
73
80
  (0, util_2.patchOptionsWithManifest)(options, manifest);
81
+ // Validate marketplace requirements before prepublish to avoid unnecessary work
82
+ validateMarketplaceRequirements(manifest, options);
74
83
  await (0, package_1.prepublish)(cwd, manifest, options.useYarn);
75
84
  await (0, package_1.versionBump)(options);
76
85
  if (options.targets) {
77
86
  for (const target of options.targets) {
78
87
  const packagePath = await tmpName();
79
88
  const packageResult = await (0, package_1.pack)({ ...options, target, packagePath });
80
- await _publish(packagePath, packageResult.manifest, { ...options, target });
89
+ await _publish(packagePath, undefined, packageResult.manifest, { ...options, target });
81
90
  }
82
91
  }
83
92
  else {
84
93
  const packagePath = await tmpName();
85
94
  const packageResult = await (0, package_1.pack)({ ...options, packagePath });
86
- await _publish(packagePath, packageResult.manifest, options);
95
+ await _publish(packagePath, undefined, packageResult.manifest, options);
87
96
  }
88
97
  }
89
98
  }
90
99
  exports.publish = publish;
91
- async function _publish(packagePath, manifest, options) {
92
- (0, validation_1.validatePublisher)(manifest.publisher);
93
- if (manifest.enableProposedApi && !options.allowAllProposedApis && !options.noVerify) {
94
- throw new Error("Extensions using proposed API (enableProposedApi: true) can't be published to the Marketplace. Use --allow-all-proposed-apis to bypass.");
95
- }
96
- if (manifest.enabledApiProposals && !options.allowAllProposedApis && !options.noVerify && manifest.enabledApiProposals?.some(p => !options.allowProposedApis?.includes(p))) {
97
- throw new Error(`Extensions using unallowed proposed API (enabledApiProposals: [${manifest.enabledApiProposals}], allowed: [${options.allowProposedApis ?? []}]) can't be published to the Marketplace. Use --allow-proposed-apis <APIS...> or --allow-all-proposed-apis to bypass.`);
98
- }
99
- if (semver.prerelease(manifest.version)) {
100
- throw new Error(`The VS Marketplace doesn't support prerelease versions: '${manifest.version}'`);
101
- }
100
+ async function _publish(packagePath, sigzipPath, manifest, options) {
102
101
  const pat = options.pat ?? (await (0, store_1.getPublisher)(manifest.publisher)).pat;
103
102
  const api = await (0, util_2.getGalleryAPI)(pat);
104
103
  const packageStream = fs.createReadStream(packagePath);
@@ -129,26 +128,36 @@ async function _publish(packagePath, manifest, options) {
129
128
  throw new Error(`${description} already exists.`);
130
129
  }
131
130
  }
132
- try {
133
- await api.updateExtension(undefined, packageStream, manifest.publisher, manifest.name);
131
+ if (sigzipPath) {
132
+ await _publishSignedPackage(api, (0, path_1.basename)(packagePath), packageStream, (0, path_1.basename)(sigzipPath), fs.createReadStream(sigzipPath), manifest);
134
133
  }
135
- catch (err) {
136
- if (err.statusCode === 409) {
137
- if (options.skipDuplicate) {
138
- util_2.log.done(`Version ${manifest.version} is already published. Skipping publish.`);
139
- return;
134
+ else {
135
+ try {
136
+ await api.updateExtension(undefined, packageStream, manifest.publisher, manifest.name);
137
+ }
138
+ catch (err) {
139
+ if (err.statusCode === 409) {
140
+ if (options.skipDuplicate) {
141
+ util_2.log.done(`Version ${manifest.version} is already published. Skipping publish.`);
142
+ return;
143
+ }
144
+ else {
145
+ throw new Error(`${description} already exists.`);
146
+ }
140
147
  }
141
148
  else {
142
- throw new Error(`${description} already exists.`);
149
+ throw err;
143
150
  }
144
151
  }
145
- else {
146
- throw err;
147
- }
148
152
  }
149
153
  }
150
154
  else {
151
- await api.createExtension(undefined, packageStream);
155
+ if (sigzipPath) {
156
+ await _publishSignedPackage(api, (0, path_1.basename)(packagePath), packageStream, (0, path_1.basename)(sigzipPath), fs.createReadStream(sigzipPath), manifest);
157
+ }
158
+ else {
159
+ await api.createExtension(undefined, packageStream);
160
+ }
152
161
  }
153
162
  }
154
163
  catch (err) {
@@ -165,6 +174,19 @@ async function _publish(packagePath, manifest, options) {
165
174
  util_2.log.info(`Hub URL: ${(0, util_2.getHubUrl)(manifest.publisher, manifest.name)}`);
166
175
  util_2.log.done(`Published ${description}.`);
167
176
  }
177
+ async function _publishSignedPackage(api, packageName, packageStream, sigzipName, sigzipStream, manifest) {
178
+ const extensionType = 'Visual Studio Code';
179
+ const form = new form_data_1.default();
180
+ const lineBreak = '\r\n';
181
+ form.setBoundary('0f411892-ef48-488f-89d3-4f0546e84723');
182
+ form.append('vsix', packageStream, {
183
+ header: `--${form.getBoundary()}${lineBreak}Content-Disposition: attachment; name=vsix; filename=${packageName}${lineBreak}Content-Type: application/octet-stream${lineBreak}${lineBreak}`
184
+ });
185
+ form.append('sigzip', sigzipStream, {
186
+ header: `--${form.getBoundary()}${lineBreak}Content-Disposition: attachment; name=sigzip; filename=${sigzipName}${lineBreak}Content-Type: application/octet-stream${lineBreak}${lineBreak}`
187
+ });
188
+ return await api.publishExtensionWithPublisherSignature(undefined, form, manifest.publisher, manifest.name, extensionType);
189
+ }
168
190
  async function unpublish(options = {}) {
169
191
  let publisher, name;
170
192
  if (options.id) {
@@ -188,4 +210,16 @@ async function unpublish(options = {}) {
188
210
  util_2.log.done(`Deleted extension: ${fullName}!`);
189
211
  }
190
212
  exports.unpublish = unpublish;
213
+ function validateMarketplaceRequirements(manifest, options) {
214
+ (0, validation_1.validatePublisher)(manifest.publisher);
215
+ if (manifest.enableProposedApi && !options.allowAllProposedApis && !options.noVerify) {
216
+ throw new Error("Extensions using proposed API (enableProposedApi: true) can't be published to the Marketplace. Use --allow-all-proposed-apis to bypass.");
217
+ }
218
+ if (manifest.enabledApiProposals && !options.allowAllProposedApis && !options.noVerify && manifest.enabledApiProposals?.some(p => !options.allowProposedApis?.includes(p))) {
219
+ throw new Error(`Extensions using unallowed proposed API (enabledApiProposals: [${manifest.enabledApiProposals}], allowed: [${options.allowProposedApis ?? []}]) can't be published to the Marketplace. Use --allow-proposed-apis <APIS...> or --allow-all-proposed-apis to bypass.`);
220
+ }
221
+ if (semver.prerelease(manifest.version)) {
222
+ 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`);
223
+ }
224
+ }
191
225
  //# sourceMappingURL=publish.js.map
package/out/store.js CHANGED
@@ -137,7 +137,7 @@ async function verifyPat(pat, publisherName) {
137
137
  }
138
138
  exports.verifyPat = verifyPat;
139
139
  async function requestPAT(publisherName) {
140
- console.log('https://marketplace.visualstudio.com/manage/publishers/');
140
+ console.log(`${(0, util_1.getMarketplaceUrl)()}/manage/publishers/`);
141
141
  const pat = await (0, util_1.read)(`Personal Access Token for publisher '${publisherName}':`, { silent: true, replace: '*' });
142
142
  await verifyPat(pat, publisherName);
143
143
  return pat;
package/out/util.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.patchOptionsWithManifest = exports.log = exports.sequence = exports.CancellationToken = exports.isCancelledError = exports.nonnull = exports.flatten = exports.chain = exports.normalize = exports.getPublicGalleryAPI = exports.getSecurityRolesAPI = exports.getGalleryAPI = exports.getHubUrl = exports.getPublishedUrl = exports.read = void 0;
6
+ exports.patchOptionsWithManifest = exports.log = exports.sequence = exports.CancellationToken = exports.isCancelledError = exports.nonnull = exports.flatten = exports.chain = exports.normalize = exports.getPublicGalleryAPI = exports.getSecurityRolesAPI = exports.getGalleryAPI = exports.getHubUrl = exports.getMarketplaceUrl = exports.getPublishedUrl = exports.read = void 0;
7
7
  const util_1 = require("util");
8
8
  const read_1 = __importDefault(require("read"));
9
9
  const WebApi_1 = require("azure-devops-node-api/WebApi");
@@ -24,6 +24,10 @@ function getPublishedUrl(extension) {
24
24
  return `${marketplaceUrl}/items?itemName=${extension}`;
25
25
  }
26
26
  exports.getPublishedUrl = getPublishedUrl;
27
+ function getMarketplaceUrl() {
28
+ return marketplaceUrl;
29
+ }
30
+ exports.getMarketplaceUrl = getMarketplaceUrl;
27
31
  function getHubUrl(publisher, name) {
28
32
  return `${marketplaceUrl}/manage/publishers/${publisher}/extensions/${name}/hub`;
29
33
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vscode/vsce",
3
- "version": "2.24.0",
3
+ "version": "2.24.1-1",
4
4
  "description": "VS Code Extensions Manager",
5
5
  "repository": {
6
6
  "type": "git",
@@ -38,10 +38,11 @@
38
38
  "node": ">= 14"
39
39
  },
40
40
  "dependencies": {
41
- "azure-devops-node-api": "^11.0.1",
41
+ "azure-devops-node-api": "^12.5.0",
42
42
  "chalk": "^2.4.2",
43
43
  "cheerio": "^1.0.0-rc.9",
44
44
  "commander": "^6.2.1",
45
+ "form-data": "^4.0.0",
45
46
  "glob": "^7.0.6",
46
47
  "hosted-git-info": "^4.0.2",
47
48
  "jsonc-parser": "^3.2.0",