@vscode/vsce 3.0.1-2 → 3.0.1-4
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 +18 -5
- package/out/util.js +3 -0
- package/package.json +1 -1
package/out/package.js
CHANGED
|
@@ -1449,7 +1449,7 @@ async function ls(options = {}) {
|
|
|
1449
1449
|
const manifest = await readManifest(cwd);
|
|
1450
1450
|
const files = await listFiles({ ...options, cwd, manifest });
|
|
1451
1451
|
if (options.tree) {
|
|
1452
|
-
const printableFileStructure = await util.generateFileStructureTree(getDefaultPackageName(manifest, options), files.map(f => ({ origin: f, tree: f })));
|
|
1452
|
+
const printableFileStructure = await util.generateFileStructureTree(getDefaultPackageName(manifest, options), files.map(f => ({ origin: path.join(cwd, f), tree: f })));
|
|
1453
1453
|
console.log(printableFileStructure.join('\n'));
|
|
1454
1454
|
}
|
|
1455
1455
|
else {
|
|
@@ -1491,15 +1491,28 @@ async function printAndValidatePackagedFiles(files, cwd, manifest, options) {
|
|
|
1491
1491
|
// Throw an error if the extension uses the files property in package.json and
|
|
1492
1492
|
// the package does not include at least one file for each include pattern
|
|
1493
1493
|
else if (manifest.files !== undefined && manifest.files.length > 0 && !options.allowUnusedFilesPattern) {
|
|
1494
|
-
const
|
|
1495
|
-
const
|
|
1494
|
+
const localPaths = files.filter(f => !isInMemoryFile(f)).map(f => util.normalize(f.localPath));
|
|
1495
|
+
const filesIncludePatterns = manifest.files.map(includePattern => util.normalize(path.join(cwd, includePattern)));
|
|
1496
|
+
const unusedIncludePatterns = filesIncludePatterns.filter(includePattern => {
|
|
1497
|
+
// Check if the pattern provided by the user matches any file in the package
|
|
1498
|
+
if (localPaths.some(localFilePath => (0, minimatch_1.default)(localFilePath, includePattern, MinimatchOptions))) {
|
|
1499
|
+
return false;
|
|
1500
|
+
}
|
|
1501
|
+
// Check if the pattern provided by the user matches any folder in the package
|
|
1502
|
+
if (!/(^|\/)[^/]*\*[^/]*$/.test(includePattern)) {
|
|
1503
|
+
includePattern = (/\/$/.test(includePattern) ? `${includePattern}**` : `${includePattern}/**`);
|
|
1504
|
+
return !localPaths.some(localFilePath => (0, minimatch_1.default)(localFilePath, includePattern, MinimatchOptions));
|
|
1505
|
+
}
|
|
1506
|
+
// Pattern does not match any file or folder
|
|
1507
|
+
return true;
|
|
1508
|
+
});
|
|
1496
1509
|
if (unusedIncludePatterns.length > 0) {
|
|
1497
1510
|
let message = '';
|
|
1498
1511
|
message += `The following include patterns in the ${chalk_1.default.bold('"files"')} property in package.json do not match any files packaged in the extension:\n`;
|
|
1499
1512
|
message += unusedIncludePatterns.map(p => ` - ${p}`).join('\n');
|
|
1500
1513
|
message += '\nRemove any include pattern which is not needed.\n';
|
|
1501
1514
|
message += `\n=> Run ${chalk_1.default.bold('vsce ls --tree')} to see all included files.\n`;
|
|
1502
|
-
message += `=> Use ${chalk_1.default.bold('--allow-unused-files-
|
|
1515
|
+
message += `=> Use ${chalk_1.default.bold('--allow-unused-files-pattern')} to skip this check`;
|
|
1503
1516
|
util.log.error(message);
|
|
1504
1517
|
process.exit(1);
|
|
1505
1518
|
}
|
|
@@ -1507,7 +1520,7 @@ async function printAndValidatePackagedFiles(files, cwd, manifest, options) {
|
|
|
1507
1520
|
// Print the files included in the package
|
|
1508
1521
|
const printableFileStructure = await util.generateFileStructureTree(getDefaultPackageName(manifest, options), files.map(f => ({
|
|
1509
1522
|
// File path relative to the extension root
|
|
1510
|
-
origin: util.vsixPathToFilePath(f.path),
|
|
1523
|
+
origin: !isInMemoryFile(f) ? f.localPath : util.vsixPathToFilePath(f.path),
|
|
1511
1524
|
// File path in the VSIX
|
|
1512
1525
|
tree: f.path
|
|
1513
1526
|
})), 35 // Print up to 35 files/folders
|
package/out/util.js
CHANGED
|
@@ -281,6 +281,9 @@ async function generateFileStructureTree(rootFolder, filePaths, printLinesLimit
|
|
|
281
281
|
const parts = filePath.split('/');
|
|
282
282
|
let currentLevel = folderTree;
|
|
283
283
|
parts.forEach(part => {
|
|
284
|
+
if (currentLevel === undefined) {
|
|
285
|
+
throw new Error(`currentLevel is undefined for ${part} in ${filePath}`);
|
|
286
|
+
}
|
|
284
287
|
if (typeof currentLevel[part] === 'number') {
|
|
285
288
|
currentLevel[part] = size;
|
|
286
289
|
}
|