@vscode/vsce 2.23.0 → 2.23.1-0
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/npm.js +47 -72
- package/out/package.js +17 -32
- package/package.json +1 -2
package/out/npm.js
CHANGED
|
@@ -30,8 +30,7 @@ exports.getLatestVersion = exports.getDependencies = exports.detectYarn = void 0
|
|
|
30
30
|
const path = __importStar(require("path"));
|
|
31
31
|
const fs = __importStar(require("fs"));
|
|
32
32
|
const cp = __importStar(require("child_process"));
|
|
33
|
-
const
|
|
34
|
-
const package_1 = require("./package");
|
|
33
|
+
const parse_semver_1 = __importDefault(require("parse-semver"));
|
|
35
34
|
const util_1 = require("./util");
|
|
36
35
|
const exists = (file) => fs.promises.stat(file).then(_ => true, _ => false);
|
|
37
36
|
function parseStdout({ stdout }) {
|
|
@@ -68,49 +67,29 @@ async function checkNPM(cancellationToken) {
|
|
|
68
67
|
function getNpmDependencies(cwd) {
|
|
69
68
|
return checkNPM()
|
|
70
69
|
.then(() => exec('npm list --production --parseable --depth=99999 --loglevel=error', { cwd, maxBuffer: 5000 * 1024 }))
|
|
71
|
-
.then(({ stdout }) => stdout.split(/[\r\n]/).filter(dir => path.isAbsolute(dir))
|
|
72
|
-
.map(dir => {
|
|
73
|
-
return {
|
|
74
|
-
src: dir,
|
|
75
|
-
dest: path.relative(cwd, dir)
|
|
76
|
-
};
|
|
77
|
-
}));
|
|
70
|
+
.then(({ stdout }) => stdout.split(/[\r\n]/).filter(dir => path.isAbsolute(dir)));
|
|
78
71
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
if (
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
const result = {
|
|
99
|
-
name,
|
|
100
|
-
path: {
|
|
101
|
-
src: depPath,
|
|
102
|
-
dest: path.relative(root, depPath),
|
|
103
|
-
},
|
|
104
|
-
children: [],
|
|
105
|
-
};
|
|
106
|
-
const shouldResolveChildren = !collected.has(depPath);
|
|
107
|
-
collected.set(depPath, result);
|
|
108
|
-
if (shouldResolveChildren) {
|
|
109
|
-
result.children = await resolve(depPath, Object.keys(depManifest.dependencies || {}), collected);
|
|
72
|
+
function asYarnDependency(prefix, tree, prune) {
|
|
73
|
+
if (prune && /@[\^~]/.test(tree.name)) {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
let name;
|
|
77
|
+
try {
|
|
78
|
+
const parseResult = (0, parse_semver_1.default)(tree.name);
|
|
79
|
+
name = parseResult.name;
|
|
80
|
+
}
|
|
81
|
+
catch (err) {
|
|
82
|
+
name = tree.name.replace(/^([^@+])@.*$/, '$1');
|
|
83
|
+
}
|
|
84
|
+
const dependencyPath = path.join(prefix, name);
|
|
85
|
+
const children = [];
|
|
86
|
+
for (const child of tree.children || []) {
|
|
87
|
+
const dep = asYarnDependency(path.join(prefix, name, 'node_modules'), child, prune);
|
|
88
|
+
if (dep) {
|
|
89
|
+
children.push(dep);
|
|
110
90
|
}
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
return resolve(root, rootDependencies);
|
|
91
|
+
}
|
|
92
|
+
return { name, path: dependencyPath, children };
|
|
114
93
|
}
|
|
115
94
|
function selectYarnDependencies(deps, packagedDependencies) {
|
|
116
95
|
const index = new (class {
|
|
@@ -156,38 +135,35 @@ function selectYarnDependencies(deps, packagedDependencies) {
|
|
|
156
135
|
packagedDependencies.forEach(visit);
|
|
157
136
|
return reached.values;
|
|
158
137
|
}
|
|
159
|
-
async function getYarnProductionDependencies(
|
|
138
|
+
async function getYarnProductionDependencies(cwd, packagedDependencies) {
|
|
139
|
+
const raw = await new Promise((c, e) => cp.exec('yarn list --prod --json', { cwd, encoding: 'utf8', env: { ...process.env }, maxBuffer: 5000 * 1024 }, (err, stdout) => (err ? e(err) : c(stdout))));
|
|
140
|
+
const match = /^{"type":"tree".*$/m.exec(raw);
|
|
141
|
+
if (!match || match.length !== 1) {
|
|
142
|
+
throw new Error('Could not parse result of `yarn list --json`');
|
|
143
|
+
}
|
|
160
144
|
const usingPackagedDependencies = Array.isArray(packagedDependencies);
|
|
161
|
-
|
|
145
|
+
const trees = JSON.parse(match[0]).data.trees;
|
|
146
|
+
let result = trees
|
|
147
|
+
.map(tree => asYarnDependency(path.join(cwd, 'node_modules'), tree, !usingPackagedDependencies))
|
|
148
|
+
.filter(util_1.nonnull);
|
|
162
149
|
if (usingPackagedDependencies) {
|
|
163
150
|
result = selectYarnDependencies(result, packagedDependencies);
|
|
164
151
|
}
|
|
165
152
|
return result;
|
|
166
153
|
}
|
|
167
|
-
async function getYarnDependencies(cwd,
|
|
168
|
-
const result = [
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
dep.children.forEach(flatten);
|
|
177
|
-
};
|
|
178
|
-
deps.forEach(flatten);
|
|
179
|
-
}
|
|
180
|
-
const dedup = new Map();
|
|
181
|
-
for (const item of result) {
|
|
182
|
-
if (!dedup.has(item.src)) {
|
|
183
|
-
dedup.set(item.src, item);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
return [...dedup.values()];
|
|
154
|
+
async function getYarnDependencies(cwd, packagedDependencies) {
|
|
155
|
+
const result = new Set([cwd]);
|
|
156
|
+
const deps = await getYarnProductionDependencies(cwd, packagedDependencies);
|
|
157
|
+
const flatten = (dep) => {
|
|
158
|
+
result.add(dep.path);
|
|
159
|
+
dep.children.forEach(flatten);
|
|
160
|
+
};
|
|
161
|
+
deps.forEach(flatten);
|
|
162
|
+
return [...result];
|
|
187
163
|
}
|
|
188
|
-
async function detectYarn(
|
|
164
|
+
async function detectYarn(cwd) {
|
|
189
165
|
for (const name of ['yarn.lock', '.yarnrc', '.yarnrc.yaml', '.pnp.cjs', '.yarn']) {
|
|
190
|
-
if (await exists(path.join(
|
|
166
|
+
if (await exists(path.join(cwd, name))) {
|
|
191
167
|
if (!process.env['VSCE_TESTS']) {
|
|
192
168
|
util_1.log.info(`Detected presence of ${name}. Using 'yarn' instead of 'npm' (to override this pass '--no-yarn' on the command line).`);
|
|
193
169
|
}
|
|
@@ -197,13 +173,12 @@ async function detectYarn(root) {
|
|
|
197
173
|
return false;
|
|
198
174
|
}
|
|
199
175
|
exports.detectYarn = detectYarn;
|
|
200
|
-
async function getDependencies(cwd,
|
|
201
|
-
const root = (0, find_yarn_workspace_root_1.default)(cwd) || cwd;
|
|
176
|
+
async function getDependencies(cwd, dependencies, packagedDependencies) {
|
|
202
177
|
if (dependencies === 'none') {
|
|
203
|
-
return [
|
|
178
|
+
return [cwd];
|
|
204
179
|
}
|
|
205
|
-
else if (dependencies === 'yarn' || (dependencies === undefined && (await detectYarn(
|
|
206
|
-
return await getYarnDependencies(cwd,
|
|
180
|
+
else if (dependencies === 'yarn' || (dependencies === undefined && (await detectYarn(cwd)))) {
|
|
181
|
+
return await getYarnDependencies(cwd, packagedDependencies);
|
|
207
182
|
}
|
|
208
183
|
else {
|
|
209
184
|
return await getNpmDependencies(cwd);
|
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.pack = exports.prepublish = exports.collect = exports.createDefaultProcessors = exports.processFiles = exports.toContentTypes = exports.toVsixManifest = exports.readManifest = exports.
|
|
29
|
+
exports.ls = exports.listFiles = exports.packageCommand = 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");
|
|
@@ -971,8 +971,9 @@ function validateManifest(manifest) {
|
|
|
971
971
|
return manifest;
|
|
972
972
|
}
|
|
973
973
|
exports.validateManifest = validateManifest;
|
|
974
|
-
function
|
|
974
|
+
function readManifest(cwd = process.cwd(), nls = true) {
|
|
975
975
|
const manifestPath = path.join(cwd, 'package.json');
|
|
976
|
+
const manifestNLSPath = path.join(cwd, 'package.nls.json');
|
|
976
977
|
const manifest = fs.promises
|
|
977
978
|
.readFile(manifestPath, 'utf8')
|
|
978
979
|
.catch(() => Promise.reject(`Extension manifest not found: ${manifestPath}`))
|
|
@@ -984,17 +985,11 @@ function readNodeManifest(cwd = process.cwd()) {
|
|
|
984
985
|
console.error(`Error parsing 'package.json' manifest file: not a valid JSON file.`);
|
|
985
986
|
throw e;
|
|
986
987
|
}
|
|
987
|
-
})
|
|
988
|
-
return manifest;
|
|
989
|
-
}
|
|
990
|
-
exports.readNodeManifest = readNodeManifest;
|
|
991
|
-
function readManifest(cwd = process.cwd(), nls = true) {
|
|
992
|
-
const manifest = readNodeManifest(cwd)
|
|
988
|
+
})
|
|
993
989
|
.then(validateManifest);
|
|
994
990
|
if (!nls) {
|
|
995
991
|
return manifest;
|
|
996
992
|
}
|
|
997
|
-
const manifestNLSPath = path.join(cwd, 'package.nls.json');
|
|
998
993
|
const manifestNLS = fs.promises
|
|
999
994
|
.readFile(manifestNLSPath, 'utf8')
|
|
1000
995
|
.catch(err => (err.code !== 'ENOENT' ? Promise.reject(err) : Promise.resolve('{}')))
|
|
@@ -1147,12 +1142,9 @@ const defaultIgnore = [
|
|
|
1147
1142
|
'**/.vscode-test-web/**',
|
|
1148
1143
|
];
|
|
1149
1144
|
const notIgnored = ['!package.json', '!README.md'];
|
|
1150
|
-
async function collectAllFiles(cwd,
|
|
1151
|
-
const deps = await (0, npm_1.getDependencies)(cwd,
|
|
1152
|
-
const promises = deps.map(dep => (0, util_1.promisify)(glob_1.default)('**', { cwd: dep
|
|
1153
|
-
src: path.relative(cwd, path.join(dep.src, f)).replace(/\\/g, '/'),
|
|
1154
|
-
dest: path.join(dep.dest, f).replace(/\\/g, '/')
|
|
1155
|
-
}))));
|
|
1145
|
+
async function collectAllFiles(cwd, dependencies, dependencyEntryPoints) {
|
|
1146
|
+
const deps = await (0, npm_1.getDependencies)(cwd, dependencies, dependencyEntryPoints);
|
|
1147
|
+
const promises = deps.map(dep => (0, util_1.promisify)(glob_1.default)('**', { cwd: dep, nodir: true, dot: true, ignore: 'node_modules/**' }).then(files => files.map(f => path.relative(cwd, path.join(dep, f))).map(f => f.replace(/\\/g, '/'))));
|
|
1156
1148
|
return Promise.all(promises).then(util.flatten);
|
|
1157
1149
|
}
|
|
1158
1150
|
function getDependenciesOption(options) {
|
|
@@ -1168,17 +1160,9 @@ function getDependenciesOption(options) {
|
|
|
1168
1160
|
return undefined;
|
|
1169
1161
|
}
|
|
1170
1162
|
}
|
|
1171
|
-
function collectFiles(cwd,
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
const target = options.target || undefined;
|
|
1175
|
-
return collectAllFiles(cwd, manifest, getDependenciesOption(options), packagedDependencies).then(files => {
|
|
1176
|
-
files = files.filter(f => !/\r$/m.test(f.src));
|
|
1177
|
-
// Filter data from other platforms
|
|
1178
|
-
if (target && options.ignoreOtherTargetFolders) {
|
|
1179
|
-
const regex = new RegExp(`(^|/)(${Array.from(exports.Targets, v => v).filter(v => v !== target).join('|')})/`);
|
|
1180
|
-
files = files.filter(f => !regex.test(f.src));
|
|
1181
|
-
}
|
|
1163
|
+
function collectFiles(cwd, dependencies, dependencyEntryPoints, ignoreFile) {
|
|
1164
|
+
return collectAllFiles(cwd, dependencies, dependencyEntryPoints).then(files => {
|
|
1165
|
+
files = files.filter(f => !/\r$/m.test(f));
|
|
1182
1166
|
return (fs.promises
|
|
1183
1167
|
.readFile(ignoreFile ? ignoreFile : path.join(cwd, '.vscodeignore'), 'utf8')
|
|
1184
1168
|
.catch(err => err.code !== 'ENOENT' ? Promise.reject(err) : ignoreFile ? Promise.reject(err) : Promise.resolve(''))
|
|
@@ -1199,8 +1183,8 @@ function collectFiles(cwd, manifest, options) {
|
|
|
1199
1183
|
.then(ignore => ignore.reduce((r, e) => (!/^\s*!/.test(e) ? [[...r[0], e], r[1]] : [r[0], [...r[1], e]]), [[], []]))
|
|
1200
1184
|
.then(r => ({ ignore: r[0], negate: r[1] }))
|
|
1201
1185
|
// Filter out files
|
|
1202
|
-
.then(({ ignore, negate }) => files.filter(f => !ignore.some(i => (0, minimatch_1.default)(f
|
|
1203
|
-
negate.some(i => (0, minimatch_1.default)(f
|
|
1186
|
+
.then(({ ignore, negate }) => files.filter(f => !ignore.some(i => (0, minimatch_1.default)(f, i, MinimatchOptions)) ||
|
|
1187
|
+
negate.some(i => (0, minimatch_1.default)(f, i.substr(1), MinimatchOptions)))));
|
|
1204
1188
|
});
|
|
1205
1189
|
}
|
|
1206
1190
|
function processFiles(processors, files) {
|
|
@@ -1246,9 +1230,11 @@ function createDefaultProcessors(manifest, options = {}) {
|
|
|
1246
1230
|
exports.createDefaultProcessors = createDefaultProcessors;
|
|
1247
1231
|
function collect(manifest, options = {}) {
|
|
1248
1232
|
const cwd = options.cwd || process.cwd();
|
|
1233
|
+
const packagedDependencies = options.dependencyEntryPoints || undefined;
|
|
1234
|
+
const ignoreFile = options.ignoreFile || undefined;
|
|
1249
1235
|
const processors = createDefaultProcessors(manifest, options);
|
|
1250
|
-
return collectFiles(cwd,
|
|
1251
|
-
const files = fileNames.map(f => ({ path: `extension/${f
|
|
1236
|
+
return collectFiles(cwd, getDependenciesOption(options), packagedDependencies, ignoreFile).then(fileNames => {
|
|
1237
|
+
const files = fileNames.map(f => ({ path: `extension/${f}`, localPath: path.join(cwd, f) }));
|
|
1252
1238
|
return processFiles(processors, files);
|
|
1253
1239
|
});
|
|
1254
1240
|
}
|
|
@@ -1361,8 +1347,7 @@ async function listFiles(options = {}) {
|
|
|
1361
1347
|
if (options.prepublish) {
|
|
1362
1348
|
await prepublish(cwd, manifest, options.useYarn);
|
|
1363
1349
|
}
|
|
1364
|
-
|
|
1365
|
-
return files.map(f => f.src);
|
|
1350
|
+
return await collectFiles(cwd, getDependenciesOption(options), options.packagedDependencies, options.ignoreFile);
|
|
1366
1351
|
}
|
|
1367
1352
|
exports.listFiles = listFiles;
|
|
1368
1353
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vscode/vsce",
|
|
3
|
-
"version": "2.23.0",
|
|
3
|
+
"version": "2.23.1-0",
|
|
4
4
|
"description": "VS Code Extensions Manager",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -42,7 +42,6 @@
|
|
|
42
42
|
"chalk": "^2.4.2",
|
|
43
43
|
"cheerio": "^1.0.0-rc.9",
|
|
44
44
|
"commander": "^6.2.1",
|
|
45
|
-
"find-yarn-workspace-root": "^2.0.0",
|
|
46
45
|
"glob": "^7.0.6",
|
|
47
46
|
"hosted-git-info": "^4.0.2",
|
|
48
47
|
"jsonc-parser": "^3.2.0",
|