Skip to content

Commit

Permalink
Merge pull request #1376 from snyk/feat/remove-yarn-2-support-to-reen…
Browse files Browse the repository at this point in the history
…able-node-8

feat: remove yarn2 support
  • Loading branch information
orsagie committed Sep 7, 2020
2 parents 4d30f5f + 210408e commit f95b4bd
Show file tree
Hide file tree
Showing 4 changed files with 214 additions and 214 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -82,7 +82,7 @@
"snyk-gradle-plugin": "3.6.2",
"snyk-module": "3.1.0",
"snyk-mvn-plugin": "2.19.1",
"snyk-nodejs-lockfile-parser": "1.27.0",
"snyk-nodejs-lockfile-parser": "1.28.0",
"snyk-nuget-plugin": "1.18.1",
"snyk-php-plugin": "1.9.0",
"snyk-policy": "1.14.1",
Expand Down
86 changes: 43 additions & 43 deletions test/acceptance/cli-monitor/cli-monitor.acceptance.test.ts
Expand Up @@ -390,49 +390,49 @@ if (!isWindows) {
}
});

test('`monitor yarn v2 project`', async (t) => {
const nodeVersion = parseInt(process.version.slice(1).split('.')[0], 10);

if (nodeVersion < 10) {
return t.skip();
}

chdirWorkspaces();

await cli.monitor('yarn-v2');
const req = server.popRequest();
t.equal(req.method, 'PUT', 'makes PUT request');
t.equal(
req.headers['x-snyk-cli-version'],
versionNumber,
'sends version number',
);
t.match(req.url, '/monitor/yarn/graph', 'puts at correct url');

const depGraphJSON = req.body.depGraphJSON;
t.ok(depGraphJSON);
const lodash = depGraphJSON.pkgs.find((pkg) => pkg.info.name === 'lodash');

t.ok(lodash, 'dependency');
t.notOk(req.body.targetFile, 'doesnt send the targetFile');
t.notOk(depGraphJSON.from, 'no "from" array on root');
t.notOk(lodash.from, 'no "from" array on dep');
if (process.platform === 'win32') {
t.true(
req.body.targetFileRelativePath.endsWith(
'\\test\\acceptance\\workspaces\\yarn-v2\\yarn.lock',
),
'matching file path win32',
);
} else {
t.true(
req.body.targetFileRelativePath.endsWith(
'/test/acceptance/workspaces/yarn-v2/yarn.lock',
),
'matching file path',
);
}
});
// test('`monitor yarn v2 project`', async (t) => {
// const nodeVersion = parseInt(process.version.slice(1).split('.')[0], 10);
//
// if (nodeVersion < 10) {
// return t.skip();
// }
//
// chdirWorkspaces();
//
// await cli.monitor('yarn-v2');
// const req = server.popRequest();
// t.equal(req.method, 'PUT', 'makes PUT request');
// t.equal(
// req.headers['x-snyk-cli-version'],
// versionNumber,
// 'sends version number',
// );
// t.match(req.url, '/monitor/yarn/graph', 'puts at correct url');
//
// const depGraphJSON = req.body.depGraphJSON;
// t.ok(depGraphJSON);
// const lodash = depGraphJSON.pkgs.find((pkg) => pkg.info.name === 'lodash');
//
// t.ok(lodash, 'dependency');
// t.notOk(req.body.targetFile, 'doesnt send the targetFile');
// t.notOk(depGraphJSON.from, 'no "from" array on root');
// t.notOk(lodash.from, 'no "from" array on dep');
// if (process.platform === 'win32') {
// t.true(
// req.body.targetFileRelativePath.endsWith(
// '\\test\\acceptance\\workspaces\\yarn-v2\\yarn.lock',
// ),
// 'matching file path win32',
// );
// } else {
// t.true(
// req.body.targetFileRelativePath.endsWith(
// '/test/acceptance/workspaces/yarn-v2/yarn.lock',
// ),
// 'matching file path',
// );
// }
// });

test('`monitor yarn-package from within folder`', async (t) => {
chdirWorkspaces('yarn-package');
Expand Down
290 changes: 145 additions & 145 deletions test/acceptance/cli-test/cli-test.yarn-workspaces.spec.ts
Expand Up @@ -218,150 +218,150 @@ export const YarnWorkspacesTests: AcceptanceTests = {
});
t.equal(policyCount, 2, '2 policies found in a workspace');
},
'test --yarn-workspaces --detection-depth=5 --strict-out-of-sync=false (yarn v2)': (
params,
utils,
) => async (t) => {
// Yarn workspaces for Yarn 2 is only supported on Node 10+
if (nodeVersion < 10) {
return t.skip();
}
utils.chdirWorkspaces();
const result = await params.cli.test('yarn-workspaces-v2', {
yarnWorkspaces: true,
detectionDepth: 5,
strictOutOfSync: false,
});
const loadPlugin = sinon.spy(params.plugins, 'loadPlugin');
// the parser is used directly
t.ok(loadPlugin.withArgs('yarn').notCalled, 'skips load plugin');
t.teardown(() => {
loadPlugin.restore();
});
t.match(
result.getDisplayResults(),
'✓ Tested 1 dependencies for known vulnerabilities, no vulnerable paths found.',
'correctly showing dep number',
);
t.match(result.getDisplayResults(), 'Package manager: yarn\n');
t.match(
result.getDisplayResults(),
'Project name: package.json',
'yarn project in output',
);
t.match(
result.getDisplayResults(),
'Project name: tomatoes',
'yarn project in output',
);
t.match(
result.getDisplayResults(),
'Project name: apples',
'yarn project in output',
);
t.match(
result.getDisplayResults(),
'Tested 3 projects, no vulnerable paths were found.',
'no vulnerable paths found as both policies detected and applied.',
);
},
'test --yarn-workspaces --detection-depth=5 multiple workspaces found': (
params,
utils,
) => async (t) => {
// Yarn workspaces for Yarn 2 is only supported on Node 10+
if (nodeVersion < 10) {
return t.skip();
}
utils.chdirWorkspaces();
const result = await params.cli.test({
yarnWorkspaces: true,
detectionDepth: 5,
strictOutOfSync: false,
});
const loadPlugin = sinon.spy(params.plugins, 'loadPlugin');
// the parser is used directly
t.ok(loadPlugin.withArgs('yarn').notCalled, 'skips load plugin');
t.teardown(() => {
loadPlugin.restore();
});
t.match(
result.getDisplayResults(),
'✓ Tested 1 dependencies for known vulnerabilities, no vulnerable paths found.',
'correctly showing dep number',
);
t.match(result.getDisplayResults(), 'Package manager: yarn\n');
t.match(
result.getDisplayResults(),
'Project name: package.json',
'yarn project in output',
);
t.match(
result.getDisplayResults(),
'Project name: tomatoes',
'yarn project in output',
);
t.match(
result.getDisplayResults(),
'Project name: apples',
'yarn project in output',
);
t.match(
result.getDisplayResults(),
'Tested 9 projects, no vulnerable paths were found.',
'Tested 9 projects',
);
let policyCount = 0;
const applesWorkspace =
process.platform === 'win32'
? '\\apples\\package.json'
: 'apples/package.json';
const tomatoesWorkspace =
process.platform === 'win32'
? '\\tomatoes\\package.json'
: 'tomatoes/package.json';
const rootWorkspace =
process.platform === 'win32'
? '\\yarn-workspaces\\package.json'
: 'yarn-workspaces/package.json';

params.server.popRequests(6).forEach((req) => {
t.equal(req.method, 'POST', 'makes POST request');
t.equal(
req.headers['x-snyk-cli-version'],
params.versionNumber,
'sends version number',
);
t.match(req.url, '/api/v1/test-dep-graph', 'posts to correct url');
t.ok(req.body.depGraph, 'body contains depGraph');
if (req.body.targetFileRelativePath.endsWith(applesWorkspace)) {
t.match(
req.body.policy,
'npm:node-uuid:20160328',
'policy is as expected',
);
t.ok(req.body.policy, 'body contains policy');
policyCount += 1;
} else if (
req.body.targetFileRelativePath.endsWith(tomatoesWorkspace)
) {
t.notOk(req.body.policy, 'body does not contain policy');
} else if (req.body.targetFileRelativePath.endsWith(rootWorkspace)) {
t.match(
req.body.policy,
'npm:node-uuid:20111130',
'policy is as expected',
);
t.ok(req.body.policy, 'body contains policy');
policyCount += 1;
}
t.equal(
req.body.depGraph.pkgManager.name,
'yarn',
'depGraph has package manager',
);
});
t.equal(policyCount, 3, '3 policies found in a workspace');
},
// 'test --yarn-workspaces --detection-depth=5 --strict-out-of-sync=false (yarn v2)': (
// params,
// utils,
// ) => async (t) => {
// // Yarn workspaces for Yarn 2 is only supported on Node 10+
// if (nodeVersion < 10) {
// return t.skip();
// }
// utils.chdirWorkspaces();
// const result = await params.cli.test('yarn-workspaces-v2', {
// yarnWorkspaces: true,
// detectionDepth: 5,
// strictOutOfSync: false,
// });
// const loadPlugin = sinon.spy(params.plugins, 'loadPlugin');
// // the parser is used directly
// t.ok(loadPlugin.withArgs('yarn').notCalled, 'skips load plugin');
// t.teardown(() => {
// loadPlugin.restore();
// });
// t.match(
// result.getDisplayResults(),
// '✓ Tested 1 dependencies for known vulnerabilities, no vulnerable paths found.',
// 'correctly showing dep number',
// );
// t.match(result.getDisplayResults(), 'Package manager: yarn\n');
// t.match(
// result.getDisplayResults(),
// 'Project name: package.json',
// 'yarn project in output',
// );
// t.match(
// result.getDisplayResults(),
// 'Project name: tomatoes',
// 'yarn project in output',
// );
// t.match(
// result.getDisplayResults(),
// 'Project name: apples',
// 'yarn project in output',
// );
// t.match(
// result.getDisplayResults(),
// 'Tested 3 projects, no vulnerable paths were found.',
// 'no vulnerable paths found as both policies detected and applied.',
// );
// },
// 'test --yarn-workspaces --detection-depth=5 multiple workspaces found': (
// params,
// utils,
// ) => async (t) => {
// // Yarn workspaces for Yarn 2 is only supported on Node 10+
// if (nodeVersion < 10) {
// return t.skip();
// }
// utils.chdirWorkspaces();
// const result = await params.cli.test({
// yarnWorkspaces: true,
// detectionDepth: 5,
// strictOutOfSync: false,
// });
// const loadPlugin = sinon.spy(params.plugins, 'loadPlugin');
// // the parser is used directly
// t.ok(loadPlugin.withArgs('yarn').notCalled, 'skips load plugin');
// t.teardown(() => {
// loadPlugin.restore();
// });
// t.match(
// result.getDisplayResults(),
// '✓ Tested 1 dependencies for known vulnerabilities, no vulnerable paths found.',
// 'correctly showing dep number',
// );
// t.match(result.getDisplayResults(), 'Package manager: yarn\n');
// t.match(
// result.getDisplayResults(),
// 'Project name: package.json',
// 'yarn project in output',
// );
// t.match(
// result.getDisplayResults(),
// 'Project name: tomatoes',
// 'yarn project in output',
// );
// t.match(
// result.getDisplayResults(),
// 'Project name: apples',
// 'yarn project in output',
// );
// t.match(
// result.getDisplayResults(),
// 'Tested 9 projects, no vulnerable paths were found.',
// 'Tested 9 projects',
// );
// let policyCount = 0;
// const applesWorkspace =
// process.platform === 'win32'
// ? '\\apples\\package.json'
// : 'apples/package.json';
// const tomatoesWorkspace =
// process.platform === 'win32'
// ? '\\tomatoes\\package.json'
// : 'tomatoes/package.json';
// const rootWorkspace =
// process.platform === 'win32'
// ? '\\yarn-workspaces\\package.json'
// : 'yarn-workspaces/package.json';
//
// params.server.popRequests(6).forEach((req) => {
// t.equal(req.method, 'POST', 'makes POST request');
// t.equal(
// req.headers['x-snyk-cli-version'],
// params.versionNumber,
// 'sends version number',
// );
// t.match(req.url, '/api/v1/test-dep-graph', 'posts to correct url');
// t.ok(req.body.depGraph, 'body contains depGraph');
// if (req.body.targetFileRelativePath.endsWith(applesWorkspace)) {
// t.match(
// req.body.policy,
// 'npm:node-uuid:20160328',
// 'policy is as expected',
// );
// t.ok(req.body.policy, 'body contains policy');
// policyCount += 1;
// } else if (
// req.body.targetFileRelativePath.endsWith(tomatoesWorkspace)
// ) {
// t.notOk(req.body.policy, 'body does not contain policy');
// } else if (req.body.targetFileRelativePath.endsWith(rootWorkspace)) {
// t.match(
// req.body.policy,
// 'npm:node-uuid:20111130',
// 'policy is as expected',
// );
// t.ok(req.body.policy, 'body contains policy');
// policyCount += 1;
// }
// t.equal(
// req.body.depGraph.pkgManager.name,
// 'yarn',
// 'depGraph has package manager',
// );
// });
// t.equal(policyCount, 3, '3 policies found in a workspace');
// },
},
};

0 comments on commit f95b4bd

Please sign in to comment.