Skip to content

Commit

Permalink
feat: enable cocoapods to send graphs for cli monitor
Browse files Browse the repository at this point in the history
  • Loading branch information
JCheung2004 committed Sep 20, 2024
1 parent ea78b29 commit 946f813
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/lib/package-managers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export const GRAPH_SUPPORTED_PACKAGE_MANAGERS: SupportedPackageManagers[] = [
'yarn',
'rubygems',
'poetry',
'cocoapods',
];
// For ecosystems with a flat set of libraries (e.g. Python, JVM), one can
// "pin" a transitive dependency
Expand Down
52 changes: 52 additions & 0 deletions test/tap/cli-monitor.acceptance.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1475,6 +1475,58 @@ if (!isWindows) {
);
});

test('`monitor cocoapods-app with just Podfile.lock`', async (t) => {
chdirWorkspaces('cocoapods-app');
const plugin = {
async inspect() {
return {
plugin: {
targetFile: 'Podfile.lock',
name: 'snyk-cocoapods-plugin',
runtime: 'cocoapods',
},
package: {},
};
},
};
console.log(plugin)
const spyPlugin = sinon.spy(plugin, 'inspect');

const loadPlugin = sinon.stub(plugins, 'loadPlugin');
t.teardown(loadPlugin.restore);
loadPlugin.withArgs('cocoapods').returns(plugin);

await cli.monitor('./', {
file: 'Podfile.lock',
});
const req = server.popRequest();
t.equal(req.method, 'PUT', 'makes PUT request');
t.equal(
req.headers['x-snyk-cli-version'],
versionNumber,
'sends version number',
);
const depGraphJSON = req.body.depGraphJSON;
t.ok(depGraphJSON);
t.match(req.url, '/monitor/cocoapods/graph', 'puts at correct url');
t.equal(req.body.targetFile, 'Podfile.lock', 'sends the targetFile (Podfile)');
t.same(
spyPlugin.getCall(0).args,
[
'./',
'Podfile.lock',
{
args: null,
file: 'Podfile.lock',
packageManager: 'cocoapods',
path: './',
},
snykHttpClient,
],
'calls CocoaPods plugin',
);
});

test('`monitor large-mono-repo --file=bundler-app/Gemfile` suggest to use --all-projects', async (t) => {
chdirWorkspaces('large-mono-repo');
const res = await cli.monitor({ file: 'bundler-app/Gemfile' });
Expand Down

0 comments on commit 946f813

Please sign in to comment.