snyk 1.749.0 → 1.750.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/dist/cli/784.index.js
CHANGED
|
@@ -3286,7 +3286,7 @@ exports.parse = parse;
|
|
|
3286
3286
|
"use strict";
|
|
3287
3287
|
|
|
3288
3288
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
3289
|
-
exports.getWorkspacesMap = exports.processYarnWorkspaces = void 0;
|
|
3289
|
+
exports.packageJsonBelongsToWorkspace = exports.getWorkspacesMap = exports.processYarnWorkspaces = void 0;
|
|
3290
3290
|
const baseDebug = __webpack_require__(15158);
|
|
3291
3291
|
const pathUtil = __webpack_require__(85622);
|
|
3292
3292
|
// import * as _ from 'lodash';
|
|
@@ -3295,24 +3295,11 @@ const groupBy = __webpack_require__(20276);
|
|
|
3295
3295
|
const micromatch = __webpack_require__(70850);
|
|
3296
3296
|
const debug = baseDebug('snyk-yarn-workspaces');
|
|
3297
3297
|
const lockFileParser = __webpack_require__(423);
|
|
3298
|
-
const path = __webpack_require__(85622);
|
|
3299
3298
|
const errors_1 = __webpack_require__(55191);
|
|
3300
3299
|
const get_file_contents_1 = __webpack_require__(84210);
|
|
3301
3300
|
async function processYarnWorkspaces(root, settings, targetFiles) {
|
|
3302
|
-
// the order of folders is important
|
|
3301
|
+
// the order of yarnTargetFiles folders is important
|
|
3303
3302
|
// must have the root level most folders at the top
|
|
3304
|
-
// const yarnTargetFiles: {
|
|
3305
|
-
// [dir: string]: Array<{
|
|
3306
|
-
// path: string;
|
|
3307
|
-
// base: string;
|
|
3308
|
-
// dir: string;
|
|
3309
|
-
// }>;
|
|
3310
|
-
// } = targetFiles
|
|
3311
|
-
// .map((p) => ({ path: p, ...pathUtil.parse(p) }))
|
|
3312
|
-
// .filter((res) => ['package.json'].includes(res.base))
|
|
3313
|
-
// .sortBy('dir')
|
|
3314
|
-
// .groupBy('dir')
|
|
3315
|
-
// .value();
|
|
3316
3303
|
const mappedAndFiltered = targetFiles
|
|
3317
3304
|
.map((p) => ({ path: p, ...pathUtil.parse(p) }))
|
|
3318
3305
|
.filter((res) => ['package.json'].includes(res.base));
|
|
@@ -3359,9 +3346,9 @@ async function processYarnWorkspaces(root, settings, targetFiles) {
|
|
|
3359
3346
|
}
|
|
3360
3347
|
if (isYarnWorkspacePackage || isRootPackageJson) {
|
|
3361
3348
|
const rootDir = isYarnWorkspacePackage
|
|
3362
|
-
?
|
|
3363
|
-
:
|
|
3364
|
-
const rootYarnLockfileName =
|
|
3349
|
+
? pathUtil.dirname(yarnWorkspacesFilesMap[packageJsonFileName].root)
|
|
3350
|
+
: pathUtil.dirname(packageJsonFileName);
|
|
3351
|
+
const rootYarnLockfileName = pathUtil.join(rootDir, 'yarn.lock');
|
|
3365
3352
|
const yarnLock = await get_file_contents_1.getFileContents(root, rootYarnLockfileName);
|
|
3366
3353
|
if (rootWorkspaceManifestContent.hasOwnProperty('resolutions') &&
|
|
3367
3354
|
lockFileParser.getYarnLockfileType(yarnLock.content) ===
|
|
@@ -3375,7 +3362,7 @@ async function processYarnWorkspaces(root, settings, targetFiles) {
|
|
|
3375
3362
|
const res = await lockFileParser.buildDepTree(packageJson.content, yarnLock.content, settings.dev, lockFileParser.LockfileType.yarn, settings.strictOutOfSync !== false);
|
|
3376
3363
|
const project = {
|
|
3377
3364
|
packageManager: 'yarn',
|
|
3378
|
-
targetFile:
|
|
3365
|
+
targetFile: pathUtil.relative(root, packageJson.fileName),
|
|
3379
3366
|
depTree: res,
|
|
3380
3367
|
plugin: {
|
|
3381
3368
|
name: 'snyk-nodejs-lockfile-parser',
|
|
@@ -3414,12 +3401,12 @@ function getWorkspacesMap(file) {
|
|
|
3414
3401
|
}
|
|
3415
3402
|
exports.getWorkspacesMap = getWorkspacesMap;
|
|
3416
3403
|
function packageJsonBelongsToWorkspace(packageJsonFileName, yarnWorkspacesMap, workspaceRoot) {
|
|
3417
|
-
const workspaceRootFolder =
|
|
3418
|
-
const workspacesGlobs = (yarnWorkspacesMap[workspaceRoot].workspaces || []).map((
|
|
3419
|
-
const
|
|
3420
|
-
const match = micromatch.isMatch(filePath, workspacesGlobs.map((p) => (p.endsWith('/**') ? p : p + '/**')));
|
|
3404
|
+
const workspaceRootFolder = pathUtil.dirname(workspaceRoot.replace(/\\/g, '/'));
|
|
3405
|
+
const workspacesGlobs = (yarnWorkspacesMap[workspaceRoot].workspaces || []).map((workspace) => pathUtil.join(workspaceRootFolder, workspace));
|
|
3406
|
+
const match = micromatch.isMatch(packageJsonFileName.replace(/\\/g, '/'), workspacesGlobs.map((p) => pathUtil.normalize(pathUtil.join(p, '**')).replace(/\\/g, '/')));
|
|
3421
3407
|
return match;
|
|
3422
3408
|
}
|
|
3409
|
+
exports.packageJsonBelongsToWorkspace = packageJsonBelongsToWorkspace;
|
|
3423
3410
|
|
|
3424
3411
|
|
|
3425
3412
|
/***/ }),
|