@vscode/vsce 2.29.0 → 2.29.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/auth.js ADDED
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAzureCredentialAccessToken = void 0;
4
+ const identity_1 = require("@azure/identity");
5
+ function createChainedTokenCredential() {
6
+ return new identity_1.ChainedTokenCredential(new identity_1.EnvironmentCredential(), new identity_1.AzureCliCredential(), new identity_1.ManagedIdentityCredential({ clientId: process.env.AZURE_CLIENT_ID }), new identity_1.AzurePowerShellCredential({ tenantId: process.env.AZURE_TENANT_ID }), new identity_1.AzureDeveloperCliCredential({ tenantId: process.env.AZURE_TENANT_ID }));
7
+ }
8
+ async function getAzureCredentialAccessToken() {
9
+ try {
10
+ const credential = createChainedTokenCredential();
11
+ const token = await credential.getToken('499b84ac-1321-427f-aa17-267ca6975798/.default', {
12
+ tenantId: process.env.AZURE_TENANT_ID
13
+ });
14
+ return token.token;
15
+ }
16
+ catch (error) {
17
+ throw new Error('Can not acquire a Microsoft Entra ID access token. Additional information:\n\n' + error);
18
+ }
19
+ }
20
+ exports.getAzureCredentialAccessToken = getAzureCredentialAccessToken;
21
+ //# sourceMappingURL=auth.js.map
package/out/main.js CHANGED
@@ -64,7 +64,7 @@ function main(task) {
64
64
  }
65
65
  task.catch(fatal).then(() => {
66
66
  if (latestVersion && semver.gt(latestVersion, pkg.version)) {
67
- util_1.log.info(`\nThe latest version of ${pkg.name} is ${latestVersion} and you have ${pkg.version}.\nUpdate it now: npm install -g ${pkg.name}`);
67
+ util_1.log.info(`The latest version of ${pkg.name} is ${latestVersion} and you have ${pkg.version}.\nUpdate it now: npm install -g ${pkg.name}`);
68
68
  }
69
69
  else {
70
70
  token.cancel();
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.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.printPackagedFiles = 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;
30
30
  const fs = __importStar(require("fs"));
31
31
  const path = __importStar(require("path"));
32
32
  const util_1 = require("util");
@@ -42,6 +42,7 @@ const url = __importStar(require("url"));
42
42
  const mime_1 = __importDefault(require("mime"));
43
43
  const semver = __importStar(require("semver"));
44
44
  const url_join_1 = __importDefault(require("url-join"));
45
+ const chalk_1 = __importDefault(require("chalk"));
45
46
  const validation_1 = require("./validation");
46
47
  const npm_1 = require("./npm");
47
48
  const GitHost = __importStar(require("hosted-git-info"));
@@ -388,7 +389,11 @@ class ManifestProcessor extends BaseProcessor {
388
389
  }
389
390
  }
390
391
  if (!this.options.allowStarActivation && this.manifest.activationEvents?.some(e => e === '*')) {
391
- util.log.warn(`Using '*' activation is usually a bad idea as it impacts performance.\nMore info: https://code.visualstudio.com/api/references/activation-events#Start-up\nUse --allow-star-activation to bypass.`);
392
+ let message = '';
393
+ message += `Using '*' activation is usually a bad idea as it impacts performance.\n`;
394
+ message += `More info: https://code.visualstudio.com/api/references/activation-events#Start-up\n`;
395
+ message += `Use --allow-star-activation to bypass.`;
396
+ util.log.warn(message);
392
397
  if (!/^y$/i.test(await util.read('Do you want to continue? [y/N] '))) {
393
398
  throw new Error('Aborted');
394
399
  }
@@ -1340,10 +1345,7 @@ async function pack(options = {}) {
1340
1345
  const cwd = options.cwd || process.cwd();
1341
1346
  const manifest = await readManifest(cwd);
1342
1347
  const files = await collect(manifest, options);
1343
- const jsFiles = files.filter(f => /\.js$/i.test(f.path));
1344
- if (files.length > 5000 || jsFiles.length > 100) {
1345
- console.log(`This extension consists of ${files.length} files, out of which ${jsFiles.length} are JavaScript files. For performance reasons, you should bundle your extension: https://aka.ms/vscode-bundle-extension . You should also exclude unnecessary files by adding them to your .vscodeignore: https://aka.ms/vscode-vscodeignore`);
1346
- }
1348
+ printPackagedFiles(files, cwd, manifest, options);
1347
1349
  if (options.version && !(options.updatePackageJson ?? true)) {
1348
1350
  manifest.version = options.version;
1349
1351
  }
@@ -1425,4 +1427,40 @@ async function ls(options = {}) {
1425
1427
  }
1426
1428
  }
1427
1429
  exports.ls = ls;
1430
+ /**
1431
+ * Prints the packaged files of an extension.
1432
+ */
1433
+ function printPackagedFiles(files, cwd, manifest, options) {
1434
+ // Warn if the extension contains a lot of files
1435
+ const jsFiles = files.filter(f => /\.js$/i.test(f.path));
1436
+ if (files.length > 5000 || jsFiles.length > 100) {
1437
+ let message = '\n';
1438
+ message += `This extension consists of ${chalk_1.default.bold(String(files.length))} files, out of which ${chalk_1.default.bold(String(jsFiles.length))} are JavaScript files. `;
1439
+ message += `For performance reasons, you should bundle your extension: ${chalk_1.default.underline('https://aka.ms/vscode-bundle-extension')}. `;
1440
+ message += `You should also exclude unnecessary files by adding them to your .vscodeignore: ${chalk_1.default.underline('https://aka.ms/vscode-vscodeignore')}.\n`;
1441
+ console.log(message);
1442
+ }
1443
+ // Warn if the extension does not have a .vscodeignore file or a files property in package.json
1444
+ if (!options.ignoreFile && !manifest.files) {
1445
+ const hasDeaultIgnore = fs.existsSync(path.join(cwd, '.vscodeignore'));
1446
+ if (!hasDeaultIgnore) {
1447
+ let message = '';
1448
+ message += `Neither a ${chalk_1.default.bold('.vscodeignore')} file nor a ${chalk_1.default.bold('"files"')} property in package.json was found. `;
1449
+ message += `To ensure only necessary files are included in your extension package, `;
1450
+ message += `add a .vscodeignore file or specify the "files" property in package.json. More info: ${chalk_1.default.underline('https://aka.ms/vscode-vscodeignore')}`;
1451
+ util.log.warn(message);
1452
+ }
1453
+ }
1454
+ // Print the files included in the package
1455
+ const printableFileStructure = util.generateFileStructureTree(getDefaultPackageName(manifest, options), files.map(f => f.path), 35);
1456
+ let message = '';
1457
+ message += chalk_1.default.bold.blue(`Files included in the VSIX:\n`);
1458
+ message += printableFileStructure.join('\n');
1459
+ if (files.length + 1 > printableFileStructure.length) {
1460
+ // If not all files have been printed, mention how all files can be printed
1461
+ message += `\n\n=> Run ${chalk_1.default.bold('vsce ls')} to see a list of all included files.\n`;
1462
+ }
1463
+ util.log.info(message);
1464
+ }
1465
+ exports.printPackagedFiles = printPackagedFiles;
1428
1466
  //# sourceMappingURL=package.js.map
package/out/publish.js CHANGED
@@ -40,6 +40,7 @@ const validation_1 = require("./validation");
40
40
  const form_data_1 = __importDefault(require("form-data"));
41
41
  const path_1 = require("path");
42
42
  const cockatiel_1 = require("cockatiel");
43
+ const auth_1 = require("./auth");
43
44
  const tmpName = (0, util_1.promisify)(tmp.tmpName);
44
45
  async function publish(options = {}) {
45
46
  if (options.packagePath) {
@@ -251,7 +252,7 @@ async function getPAT(publisher, options) {
251
252
  return options.pat;
252
253
  }
253
254
  if (options.azureCredential) {
254
- return await (0, util_2.getAzureCredentialAccessToken)();
255
+ return await (0, auth_1.getAzureCredentialAccessToken)();
255
256
  }
256
257
  return (await (0, store_1.getPublisher)(publisher)).pat;
257
258
  }
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.getAzureCredentialAccessToken = exports.getPublicGalleryAPI = exports.getSecurityRolesAPI = exports.getGalleryAPI = exports.getHubUrl = exports.getMarketplaceUrl = exports.getPublishedUrl = exports.read = void 0;
6
+ exports.generateFileStructureTree = 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");
@@ -11,7 +11,6 @@ const GalleryApi_1 = require("azure-devops-node-api/GalleryApi");
11
11
  const chalk_1 = __importDefault(require("chalk"));
12
12
  const publicgalleryapi_1 = require("./publicgalleryapi");
13
13
  const os_1 = require("os");
14
- const identity_1 = require("@azure/identity");
15
14
  const __read = (0, util_1.promisify)(read_1.default);
16
15
  function read(prompt, options = {}) {
17
16
  if (process.env['VSCE_TESTS'] || !process.stdout.isTTY) {
@@ -51,17 +50,6 @@ function getPublicGalleryAPI() {
51
50
  return new publicgalleryapi_1.PublicGalleryAPI(marketplaceUrl, '3.0-preview.1');
52
51
  }
53
52
  exports.getPublicGalleryAPI = getPublicGalleryAPI;
54
- async function getAzureCredentialAccessToken() {
55
- try {
56
- const credential = new identity_1.DefaultAzureCredential();
57
- const token = await credential.getToken('499b84ac-1321-427f-aa17-267ca6975798/.default');
58
- return token.token;
59
- }
60
- catch (error) {
61
- throw new Error('Can not acquire a Microsoft Entra ID access token. Additional information:\n\n' + error);
62
- }
63
- }
64
- exports.getAzureCredentialAccessToken = getAzureCredentialAccessToken;
65
53
  function normalize(path) {
66
54
  return path.replace(/\\/g, '/');
67
55
  }
@@ -178,4 +166,82 @@ function patchOptionsWithManifest(options, manifest) {
178
166
  }
179
167
  }
180
168
  exports.patchOptionsWithManifest = patchOptionsWithManifest;
169
+ function generateFileStructureTree(rootFolder, filePaths, maxPrint = Number.MAX_VALUE) {
170
+ const folderTree = {};
171
+ const depthCounts = [];
172
+ // Build a tree structure from the file paths
173
+ filePaths.forEach(filePath => {
174
+ const parts = filePath.split('/');
175
+ let currentLevel = folderTree;
176
+ parts.forEach((part, depth) => {
177
+ if (!currentLevel[part]) {
178
+ currentLevel[part] = depth === parts.length - 1 ? null : {};
179
+ if (depthCounts.length <= depth) {
180
+ depthCounts.push(0);
181
+ }
182
+ depthCounts[depth]++;
183
+ }
184
+ currentLevel = currentLevel[part];
185
+ });
186
+ });
187
+ // Get max depth
188
+ let currentDepth = 0;
189
+ let countUpToCurrentDepth = depthCounts[0];
190
+ for (let i = 1; i < depthCounts.length; i++) {
191
+ if (countUpToCurrentDepth + depthCounts[i] > maxPrint) {
192
+ break;
193
+ }
194
+ currentDepth++;
195
+ countUpToCurrentDepth += depthCounts[i];
196
+ }
197
+ const maxDepth = currentDepth;
198
+ let message = [];
199
+ // Helper function to print the tree
200
+ const printTree = (tree, depth, prefix) => {
201
+ // Print all files before folders
202
+ const sortedFolderKeys = Object.keys(tree).filter(key => tree[key] !== null).sort();
203
+ const sortedFileKeys = Object.keys(tree).filter(key => tree[key] === null).sort();
204
+ const sortedKeys = [...sortedFileKeys, ...sortedFolderKeys];
205
+ for (let i = 0; i < sortedKeys.length; i++) {
206
+ const key = sortedKeys[i];
207
+ const isLast = i === sortedKeys.length - 1;
208
+ const localPrefix = prefix + (isLast ? '└─ ' : '├─ ');
209
+ const childPrefix = prefix + (isLast ? ' ' : '│ ');
210
+ if (tree[key] === null) {
211
+ // It's a file
212
+ message.push(localPrefix + key);
213
+ }
214
+ else {
215
+ // It's a folder
216
+ if (depth < maxDepth) {
217
+ // maxdepth is not reached, print the folder and its children
218
+ message.push(localPrefix + chalk_1.default.bold(`${key}/`));
219
+ printTree(tree[key], depth + 1, childPrefix);
220
+ }
221
+ else {
222
+ // max depth is reached, print the folder but not its children
223
+ const filesCount = countFiles(tree[key]);
224
+ message.push(localPrefix + chalk_1.default.bold(`${key}/`) + chalk_1.default.green(` (${filesCount} ${filesCount === 1 ? 'file' : 'files'})`));
225
+ }
226
+ }
227
+ }
228
+ };
229
+ // Helper function to count the number of files in a tree
230
+ const countFiles = (tree) => {
231
+ let filesCount = 0;
232
+ for (const key in tree) {
233
+ if (tree[key] === null) {
234
+ filesCount++;
235
+ }
236
+ else {
237
+ filesCount += countFiles(tree[key]);
238
+ }
239
+ }
240
+ return filesCount;
241
+ };
242
+ message.push(chalk_1.default.bold(rootFolder));
243
+ printTree(folderTree, 0, '');
244
+ return message;
245
+ }
246
+ exports.generateFileStructureTree = generateFileStructureTree;
181
247
  //# sourceMappingURL=util.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vscode/vsce",
3
- "version": "2.29.0",
3
+ "version": "2.29.1-1",
4
4
  "description": "VS Code Extensions Manager",
5
5
  "repository": {
6
6
  "type": "git",