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 24, 2024
1 parent 6683f56 commit ca56c69
Show file tree
Hide file tree
Showing 2 changed files with 57 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
56 changes: 56 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,62 @@ 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.lock)',
);
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 ca56c69

Please sign in to comment.