-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from snyk-tech-services/feat/introduce-yargs-an…
…d-json feat: json report + cli args
- Loading branch information
Showing
10 changed files
with
52 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { getApiToken } from '../lib/get-api-token'; | ||
import { generateOrgLicensesReport } from '../lib/generate-org-license-report'; | ||
|
||
export const command = 'json'; | ||
export const desc = 'Generate org licenses & dependencies data in JSON format'; | ||
export const builder = { | ||
orgPublicId: { | ||
required: true, | ||
default: undefined, | ||
}, | ||
}; | ||
export const aliases = ['j']; | ||
|
||
export async function handler(argv: { orgPublicId: string }) { | ||
try { | ||
// check SNYK_TOKEN is set as the sdk uses it | ||
getApiToken(); | ||
// TODO: define and pass options to help filter the response | ||
// based on filters available in API | ||
const data = await generateOrgLicensesReport(argv.orgPublicId, {}); | ||
console.log(JSON.stringify(data)); | ||
} catch (e) { | ||
console.error(e); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,8 @@ | ||
import { generateOrgLicensesReport, getApiToken } from './lib'; | ||
#!/usr/bin/env node | ||
import * as yargs from 'yargs'; | ||
|
||
export async function main() { | ||
// check SNYK_TOKEN is set as the sdk uses it | ||
getApiToken(); | ||
// check CLI properties passed in | ||
const orgPublicId = 'blah'; | ||
const options = {}; | ||
await generateOrgLicensesReport(orgPublicId, options); | ||
} | ||
yargs | ||
.commandDir('cmds') | ||
.demandCommand() | ||
.help() | ||
.argv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters