From 0d9d1550d51056d8d489e993383e449010936ae6 Mon Sep 17 00:00:00 2001 From: Charlie Gerard Date: Sat, 15 Jun 2024 14:28:18 -0700 Subject: [PATCH 01/10] wip --- lib/commands/repos/create.js | 164 +++++++++++++++++++++++++++++++++++ lib/commands/repos/delete.js | 105 ++++++++++++++++++++++ lib/commands/repos/index.js | 31 +++++++ lib/commands/repos/list.js | 105 ++++++++++++++++++++++ lib/commands/repos/update.js | 105 ++++++++++++++++++++++ lib/commands/repos/view.js | 104 ++++++++++++++++++++++ 6 files changed, 614 insertions(+) create mode 100644 lib/commands/repos/create.js create mode 100644 lib/commands/repos/delete.js create mode 100644 lib/commands/repos/index.js create mode 100644 lib/commands/repos/list.js create mode 100644 lib/commands/repos/update.js create mode 100644 lib/commands/repos/view.js diff --git a/lib/commands/repos/create.js b/lib/commands/repos/create.js new file mode 100644 index 00000000..39d91721 --- /dev/null +++ b/lib/commands/repos/create.js @@ -0,0 +1,164 @@ +// @ts-nocheck +/* eslint-disable no-console */ + +// import chalk from 'chalk' +import meow from 'meow' +import ora from 'ora' + +import { outputFlags } from '../../flags/index.js' +// import { handleApiCall, handleUnsuccessfulApiResponse } from '../../utils/api-helpers.js' +import { InputError } from '../../utils/errors.js' +import { prepareFlags } from '../../utils/flags.js' +import { printFlagList } from '../../utils/formatting.js' +// import { getDefaultKey, setupSdk } from '../../utils/sdk.js' + +/** @type {import('../../utils/meow-with-subcommands').CliSubcommand} */ +export const create = { + description: 'Create a repository in an organization', + async run (argv, importMeta, { parentName }) { + const name = parentName + ' create' + + const input = setupCommand(name, create.description, argv, importMeta) + if (input) { + const spinnerText = 'Creating repository... \n' + const spinner = ora(spinnerText).start() + await createRepo(input.orgSlug, input, spinner) + } + } +} + +const listFullScanFlags = prepareFlags({ + sort: { + type: 'string', + shortFlag: 's', + default: 'created_at', + description: 'Sorting option (`name` or `created_at`) - default is `created_at`', + }, + direction: { + type: 'string', + shortFlag: 'd', + default: 'desc', + description: 'Direction option (`desc` or `asc`) - Default is `desc`', + }, + perPage: { + type: 'number', + shortFlag: 'pp', + default: 30, + description: 'Results per page - Default is 30', + }, + page: { + type: 'number', + shortFlag: 'p', + default: 1, + description: 'Page number - Default is 1', + }, + fromTime: { + type: 'string', + shortFlag: 'f', + default: '', + description: 'From time - as a unix timestamp', + }, + untilTime: { + type: 'string', + shortFlag: 'u', + default: '', + description: 'Until time - as a unix timestamp', + } +}) + +// Internal functions + +/** + * @typedef CommandContext + * @property {boolean} outputJson + * @property {boolean} outputMarkdown + * @property {string} orgSlug + * @property {string} sort + * @property {string} direction + * @property {number} perPage + * @property {number} page + * @property {string} fromTime + * @property {string} untilTime + */ + +/** + * @param {string} name + * @param {string} description + * @param {readonly string[]} argv + * @param {ImportMeta} importMeta + * @returns {void|CommandContext} + */ +function setupCommand (name, description, argv, importMeta) { + const flags = { + ...outputFlags, + ...listFullScanFlags + } + + const cli = meow(` + Usage + $ ${name} + + Options + ${printFlagList(flags, 6)} + + Examples + $ ${name} FakeOrg + `, { + argv, + description, + importMeta, + flags + }) + + const { + json: outputJson, + markdown: outputMarkdown, + sort, + direction, + perPage, + page, + fromTime, + untilTime + } = cli.flags + + if (!cli.input[0]) { + throw new InputError(`Please specify an organization slug. \n +Example: +socket scan list FakeOrg +`) + } + + const orgSlug = cli.input[0] || '' + + return { + outputJson, + outputMarkdown, + orgSlug, + sort, + direction, + perPage, + page, + fromTime, + untilTime + } +} + +/** + * @typedef FullScansData + * @property {import('@socketsecurity/sdk').SocketSdkReturnType<'getOrgFullScanList'>["data"]} data + */ + +/** + * @param {string} orgSlug + * @param {CommandContext} input + * @param {import('ora').Ora} spinner + * @returns {Promise} + */ +async function createRepo (orgSlug, input, spinner) { + // const socketSdk = await setupSdk(getDefaultKey()) + console.log(input) + +// return { +// // data: result.data +// } +} diff --git a/lib/commands/repos/delete.js b/lib/commands/repos/delete.js new file mode 100644 index 00000000..02369e2c --- /dev/null +++ b/lib/commands/repos/delete.js @@ -0,0 +1,105 @@ +// @ts-nocheck +/* eslint-disable no-console */ + +// import chalk from 'chalk' +import meow from 'meow' +import ora from 'ora' + +import { outputFlags } from '../../flags/index.js' +// import { handleApiCall, handleUnsuccessfulApiResponse } from '../../utils/api-helpers.js' +import { InputError } from '../../utils/errors.js' +import { printFlagList } from '../../utils/formatting.js' +// import { getDefaultKey, setupSdk } from '../../utils/sdk.js' + +/** @type {import('../../utils/meow-with-subcommands').CliSubcommand} */ +export const del = { + description: 'Delete a repository in an organization', + async run (argv, importMeta, { parentName }) { + const name = parentName + ' del' + + const input = setupCommand(name, del.description, argv, importMeta) + if (input) { + const spinnerText = 'Deleting repository... \n' + const spinner = ora(spinnerText).start() + await deleteRepository(input.orgSlug, input, spinner) + } + } +} + +// Internal functions + +/** + * @typedef CommandContext + * @property {boolean} outputJson + * @property {boolean} outputMarkdown + * @property {string} orgSlug + */ + +/** + * @param {string} name + * @param {string} description + * @param {readonly string[]} argv + * @param {ImportMeta} importMeta + * @returns {void|CommandContext} + */ +function setupCommand (name, description, argv, importMeta) { + const flags = { + ...outputFlags + } + + const cli = meow(` + Usage + $ ${name} + + Options + ${printFlagList(flags, 6)} + + Examples + $ ${name} FakeOrg + `, { + argv, + description, + importMeta, + flags + }) + + const { + json: outputJson, + markdown: outputMarkdown + } = cli.flags + + if (!cli.input[0]) { + throw new InputError(`Please specify an organization slug. \n +Example: +socket scan list FakeOrg +`) + } + + const orgSlug = cli.input[0] || '' + + return { + outputJson, + outputMarkdown, + orgSlug + } +} + +/** + * @typedef RepositoryData + * @property {import('@socketsecurity/sdk').SocketSdkReturnType<'getOrgFullScanList'>["data"]} data + */ + +/** + * @param {string} orgSlug + * @param {CommandContext} input + * @param {import('ora').Ora} spinner + * @returns {Promise} + */ +async function deleteRepository (orgSlug, input, spinner) { + // const socketSdk = await setupSdk(getDefaultKey()) + console.log(input) + +// return { +// // data: result.data +// } +} diff --git a/lib/commands/repos/index.js b/lib/commands/repos/index.js new file mode 100644 index 00000000..8c4c9053 --- /dev/null +++ b/lib/commands/repos/index.js @@ -0,0 +1,31 @@ +// @ts-nocheck +import { create } from './create.js' +import { del } from './delete.js' +import { list } from './list.js' +import { update } from './update.js' +import { view } from './view.js' +import { meowWithSubcommands } from '../../utils/meow-with-subcommands.js' + +const description = 'Repositories related commands' + +/** @type {import('../../utils/meow-with-subcommands').CliSubcommand} */ +export const repo = { + description, + run: async (argv, importMeta, { parentName }) => { + await meowWithSubcommands( + { + create, + view, + list, + del, + update + }, + { + argv, + description, + importMeta, + name: parentName + ' repo', + } + ) + } +} diff --git a/lib/commands/repos/list.js b/lib/commands/repos/list.js new file mode 100644 index 00000000..2fedcd70 --- /dev/null +++ b/lib/commands/repos/list.js @@ -0,0 +1,105 @@ +// @ts-nocheck +/* eslint-disable no-console */ + +// import chalk from 'chalk' +import meow from 'meow' +import ora from 'ora' + +import { outputFlags } from '../../flags/index.js' +// import { handleApiCall, handleUnsuccessfulApiResponse } from '../../utils/api-helpers.js' +import { InputError } from '../../utils/errors.js' +import { printFlagList } from '../../utils/formatting.js' +// import { getDefaultKey, setupSdk } from '../../utils/sdk.js' + +/** @type {import('../../utils/meow-with-subcommands').CliSubcommand} */ +export const list = { + description: 'List repositories in an organization', + async run (argv, importMeta, { parentName }) { + const name = parentName + ' list' + + const input = setupCommand(name, list.description, argv, importMeta) + if (input) { + const spinnerText = 'Listing repositories... \n' + const spinner = ora(spinnerText).start() + await listOrgRepos(input.orgSlug, input, spinner) + } + } +} + +// Internal functions + +/** + * @typedef CommandContext + * @property {boolean} outputJson + * @property {boolean} outputMarkdown + * @property {string} orgSlug + */ + +/** + * @param {string} name + * @param {string} description + * @param {readonly string[]} argv + * @param {ImportMeta} importMeta + * @returns {void|CommandContext} + */ +function setupCommand (name, description, argv, importMeta) { + const flags = { + ...outputFlags + } + + const cli = meow(` + Usage + $ ${name} + + Options + ${printFlagList(flags, 6)} + + Examples + $ ${name} FakeOrg + `, { + argv, + description, + importMeta, + flags + }) + + const { + json: outputJson, + markdown: outputMarkdown + } = cli.flags + + if (!cli.input[0]) { + throw new InputError(`Please specify an organization slug. \n +Example: +socket scan list FakeOrg +`) + } + + const orgSlug = cli.input[0] || '' + + return { + outputJson, + outputMarkdown, + orgSlug + } +} + +/** + * @typedef RepositoryData + * @property {import('@socketsecurity/sdk').SocketSdkReturnType<'getOrgFullScanList'>["data"]} data + */ + +/** + * @param {string} orgSlug + * @param {CommandContext} input + * @param {import('ora').Ora} spinner + * @returns {Promise} + */ +async function listOrgRepos (orgSlug, input, spinner) { + // const socketSdk = await setupSdk(getDefaultKey()) + console.log(input) + +// return { +// // data: result.data +// } +} diff --git a/lib/commands/repos/update.js b/lib/commands/repos/update.js new file mode 100644 index 00000000..2484d9cb --- /dev/null +++ b/lib/commands/repos/update.js @@ -0,0 +1,105 @@ +// @ts-nocheck +/* eslint-disable no-console */ + +// import chalk from 'chalk' +import meow from 'meow' +import ora from 'ora' + +import { outputFlags } from '../../flags/index.js' +// import { handleApiCall, handleUnsuccessfulApiResponse } from '../../utils/api-helpers.js' +import { InputError } from '../../utils/errors.js' +import { printFlagList } from '../../utils/formatting.js' +// import { getDefaultKey, setupSdk } from '../../utils/sdk.js' + +/** @type {import('../../utils/meow-with-subcommands').CliSubcommand} */ +export const update = { + description: 'Update a repository in an organization', + async run (argv, importMeta, { parentName }) { + const name = parentName + ' update' + + const input = setupCommand(name, update.description, argv, importMeta) + if (input) { + const spinnerText = 'Updating repository... \n' + const spinner = ora(spinnerText).start() + await updateRepository(input.orgSlug, input, spinner) + } + } +} + +// Internal functions + +/** + * @typedef CommandContext + * @property {boolean} outputJson + * @property {boolean} outputMarkdown + * @property {string} orgSlug + */ + +/** + * @param {string} name + * @param {string} description + * @param {readonly string[]} argv + * @param {ImportMeta} importMeta + * @returns {void|CommandContext} + */ +function setupCommand (name, description, argv, importMeta) { + const flags = { + ...outputFlags + } + + const cli = meow(` + Usage + $ ${name} + + Options + ${printFlagList(flags, 6)} + + Examples + $ ${name} FakeOrg + `, { + argv, + description, + importMeta, + flags + }) + + const { + json: outputJson, + markdown: outputMarkdown + } = cli.flags + + if (!cli.input[0]) { + throw new InputError(`Please specify an organization slug. \n +Example: +socket scan list FakeOrg +`) + } + + const orgSlug = cli.input[0] || '' + + return { + outputJson, + outputMarkdown, + orgSlug + } +} + +/** + * @typedef RepositoryData + * @property {import('@socketsecurity/sdk').SocketSdkReturnType<'getOrgFullScanList'>["data"]} data + */ + +/** + * @param {string} orgSlug + * @param {CommandContext} input + * @param {import('ora').Ora} spinner + * @returns {Promise} + */ +async function updateRepository (orgSlug, input, spinner) { + // const socketSdk = await setupSdk(getDefaultKey()) + console.log(input) + +// return { +// // data: result.data +// } +} diff --git a/lib/commands/repos/view.js b/lib/commands/repos/view.js new file mode 100644 index 00000000..e8c4fd0d --- /dev/null +++ b/lib/commands/repos/view.js @@ -0,0 +1,104 @@ +// @ts-nocheck +/* eslint-disable no-console */ + +import meow from 'meow' +import ora from 'ora' + +import { outputFlags } from '../../flags/index.js' +// import { handleApiCall, handleUnsuccessfulApiResponse } from '../../utils/api-helpers.js' +import { InputError } from '../../utils/errors.js' +import { printFlagList } from '../../utils/formatting.js' +// import { getDefaultKey, setupSdk } from '../../utils/sdk.js' + +/** @type {import('../../utils/meow-with-subcommands').CliSubcommand} */ +export const view = { + description: 'View repositories in an organization', + async run (argv, importMeta, { parentName }) { + const name = parentName + ' view' + + const input = setupCommand(name, view.description, argv, importMeta) + if (input) { + const spinnerText = 'Fetching repository... \n' + const spinner = ora(spinnerText).start() + await viewRepository(input.orgSlug, input, spinner) + } + } +} + +// Internal functions + +/** + * @typedef CommandContext + * @property {boolean} outputJson + * @property {boolean} outputMarkdown + * @property {string} orgSlug + */ + +/** + * @param {string} name + * @param {string} description + * @param {readonly string[]} argv + * @param {ImportMeta} importMeta + * @returns {void|CommandContext} + */ +function setupCommand (name, description, argv, importMeta) { + const flags = { + ...outputFlags + } + + const cli = meow(` + Usage + $ ${name} + + Options + ${printFlagList(flags, 6)} + + Examples + $ ${name} FakeOrg + `, { + argv, + description, + importMeta, + flags + }) + + const { + json: outputJson, + markdown: outputMarkdown + } = cli.flags + + if (!cli.input[0]) { + throw new InputError(`Please specify an organization slug. \n +Example: +socket scan list FakeOrg +`) + } + + const orgSlug = cli.input[0] || '' + + return { + outputJson, + outputMarkdown, + orgSlug + } +} + +/** + * @typedef RepositoryData + * @property {import('@socketsecurity/sdk').SocketSdkReturnType<'getOrgFullScanList'>["data"]} data + */ + +/** + * @param {string} orgSlug + * @param {CommandContext} input + * @param {import('ora').Ora} spinner + * @returns {Promise} + */ +async function viewRepository (orgSlug, input, spinner) { + // const socketSdk = await setupSdk(getDefaultKey()) + console.log(input) + +// return { +// // data: result.data +// } +} From 2e27283da06dbce8773264b1a12ea162d319a1b0 Mon Sep 17 00:00:00 2001 From: Charlie Gerard Date: Tue, 18 Jun 2024 11:16:10 -0700 Subject: [PATCH 02/10] improve list command --- lib/commands/index.js | 1 + lib/commands/repos/list.js | 104 ++++++++++++++++++++++++++++++------- 2 files changed, 85 insertions(+), 20 deletions(-) diff --git a/lib/commands/index.js b/lib/commands/index.js index 0bdadb52..ade80f5c 100644 --- a/lib/commands/index.js +++ b/lib/commands/index.js @@ -10,3 +10,4 @@ export * from './report/index.js' export * from './wrapper/index.js' export * from './scan/index.js' export * from './audit-log/index.js' +export * from './repos/index.js' diff --git a/lib/commands/repos/list.js b/lib/commands/repos/list.js index 2fedcd70..8390a783 100644 --- a/lib/commands/repos/list.js +++ b/lib/commands/repos/list.js @@ -1,17 +1,17 @@ -// @ts-nocheck /* eslint-disable no-console */ -// import chalk from 'chalk' +import chalk from 'chalk' +import chalkTable from 'chalk-table' import meow from 'meow' import ora from 'ora' import { outputFlags } from '../../flags/index.js' -// import { handleApiCall, handleUnsuccessfulApiResponse } from '../../utils/api-helpers.js' -import { InputError } from '../../utils/errors.js' +import { handleApiCall, handleUnsuccessfulApiResponse } from '../../utils/api-helpers.js' +import { prepareFlags } from '../../utils/flags.js' import { printFlagList } from '../../utils/formatting.js' -// import { getDefaultKey, setupSdk } from '../../utils/sdk.js' +import { getDefaultKey, setupSdk } from '../../utils/sdk.js' -/** @type {import('../../utils/meow-with-subcommands').CliSubcommand} */ +/** @type {import('../../utils/meow-with-subcommands.js').CliSubcommand} */ export const list = { description: 'List repositories in an organization', async run (argv, importMeta, { parentName }) { @@ -26,6 +26,32 @@ export const list = { } } +const listRepoFlags = prepareFlags({ + sort: { + type: 'string', + shortFlag: 's', + default: 'created_at', + description: 'Sorting option', + }, + direction: { + type: 'string', + default: 'desc', + description: 'Direction option', + }, + perPage: { + type: 'number', + shortFlag: 'pp', + default: 30, + description: 'Number of results per page' + }, + page: { + type: 'number', + shortFlag: 'p', + default: 1, + description: 'Page number' + }, +}) + // Internal functions /** @@ -33,6 +59,10 @@ export const list = { * @property {boolean} outputJson * @property {boolean} outputMarkdown * @property {string} orgSlug + * @property {string} sort + * @property {string} direction + * @property {number} per_page + * @property {number} page */ /** @@ -44,7 +74,8 @@ export const list = { */ function setupCommand (name, description, argv, importMeta) { const flags = { - ...outputFlags + ...outputFlags, + ...listRepoFlags } const cli = meow(` @@ -65,28 +96,35 @@ function setupCommand (name, description, argv, importMeta) { const { json: outputJson, - markdown: outputMarkdown + markdown: outputMarkdown, + perPage, + sort, + direction, + page } = cli.flags if (!cli.input[0]) { - throw new InputError(`Please specify an organization slug. \n -Example: -socket scan list FakeOrg -`) + console.error(`${chalk.bgRed('Input error')}: Please provide an organization slug \n`) + cli.showHelp() + return } - const orgSlug = cli.input[0] || '' + const [orgSlug = ''] = cli.input return { outputJson, outputMarkdown, - orgSlug + orgSlug, + sort, + direction, + page, + per_page: perPage } } /** * @typedef RepositoryData - * @property {import('@socketsecurity/sdk').SocketSdkReturnType<'getOrgFullScanList'>["data"]} data + * @property {import('@socketsecurity/sdk').SocketSdkReturnType<'getOrgRepoList'>["data"]} data */ /** @@ -96,10 +134,36 @@ socket scan list FakeOrg * @returns {Promise} */ async function listOrgRepos (orgSlug, input, spinner) { - // const socketSdk = await setupSdk(getDefaultKey()) - console.log(input) + const socketSdk = await setupSdk(getDefaultKey()) + const result = await handleApiCall(socketSdk.getOrgRepoList(orgSlug, input), 'looking up package') + + if (!result.success) { + return handleUnsuccessfulApiResponse('getOrgRepoList', result, spinner) + } + + spinner.stop() -// return { -// // data: result.data -// } + const options = { + columns: [ + { field: 'id', name: chalk.magenta('ID') }, + { field: 'name', name: chalk.magenta('Name') }, + { field: 'visibility', name: chalk.magenta('Visibility') }, + { field: 'default_branch', name: chalk.magenta('Default branch') }, + { field: 'archived', name: chalk.magenta('Archived') } + ] + } + + const formattedResults = result.data.results.map(d => { + return { + ...d + } + }) + + const table = chalkTable(options, formattedResults) + + console.log(table, '\n') + + return { + data: result.data + } } From fd826e81fa4cbcb0c8d51869df1465d8a67bbf67 Mon Sep 17 00:00:00 2001 From: Charlie Gerard Date: Tue, 18 Jun 2024 11:17:46 -0700 Subject: [PATCH 03/10] wip --- lib/commands/repos/create.js | 2 +- lib/commands/repos/delete.js | 2 +- lib/commands/repos/index.js | 2 +- lib/commands/repos/update.js | 2 +- lib/commands/repos/view.js | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/commands/repos/create.js b/lib/commands/repos/create.js index 39d91721..e4802ab0 100644 --- a/lib/commands/repos/create.js +++ b/lib/commands/repos/create.js @@ -12,7 +12,7 @@ import { prepareFlags } from '../../utils/flags.js' import { printFlagList } from '../../utils/formatting.js' // import { getDefaultKey, setupSdk } from '../../utils/sdk.js' -/** @type {import('../../utils/meow-with-subcommands').CliSubcommand} */ +/** @type {import('../../utils/meow-with-subcommands.js').CliSubcommand} */ export const create = { description: 'Create a repository in an organization', async run (argv, importMeta, { parentName }) { diff --git a/lib/commands/repos/delete.js b/lib/commands/repos/delete.js index 02369e2c..2811dcc6 100644 --- a/lib/commands/repos/delete.js +++ b/lib/commands/repos/delete.js @@ -11,7 +11,7 @@ import { InputError } from '../../utils/errors.js' import { printFlagList } from '../../utils/formatting.js' // import { getDefaultKey, setupSdk } from '../../utils/sdk.js' -/** @type {import('../../utils/meow-with-subcommands').CliSubcommand} */ +/** @type {import('../../utils/meow-with-subcommands.js').CliSubcommand} */ export const del = { description: 'Delete a repository in an organization', async run (argv, importMeta, { parentName }) { diff --git a/lib/commands/repos/index.js b/lib/commands/repos/index.js index 8c4c9053..628d3066 100644 --- a/lib/commands/repos/index.js +++ b/lib/commands/repos/index.js @@ -8,7 +8,7 @@ import { meowWithSubcommands } from '../../utils/meow-with-subcommands.js' const description = 'Repositories related commands' -/** @type {import('../../utils/meow-with-subcommands').CliSubcommand} */ +/** @type {import('../../utils/meow-with-subcommands.js').CliSubcommand} */ export const repo = { description, run: async (argv, importMeta, { parentName }) => { diff --git a/lib/commands/repos/update.js b/lib/commands/repos/update.js index 2484d9cb..a8807263 100644 --- a/lib/commands/repos/update.js +++ b/lib/commands/repos/update.js @@ -11,7 +11,7 @@ import { InputError } from '../../utils/errors.js' import { printFlagList } from '../../utils/formatting.js' // import { getDefaultKey, setupSdk } from '../../utils/sdk.js' -/** @type {import('../../utils/meow-with-subcommands').CliSubcommand} */ +/** @type {import('../../utils/meow-with-subcommands.js').CliSubcommand} */ export const update = { description: 'Update a repository in an organization', async run (argv, importMeta, { parentName }) { diff --git a/lib/commands/repos/view.js b/lib/commands/repos/view.js index e8c4fd0d..575844a4 100644 --- a/lib/commands/repos/view.js +++ b/lib/commands/repos/view.js @@ -10,7 +10,7 @@ import { InputError } from '../../utils/errors.js' import { printFlagList } from '../../utils/formatting.js' // import { getDefaultKey, setupSdk } from '../../utils/sdk.js' -/** @type {import('../../utils/meow-with-subcommands').CliSubcommand} */ +/** @type {import('../../utils/meow-with-subcommands.js').CliSubcommand} */ export const view = { description: 'View repositories in an organization', async run (argv, importMeta, { parentName }) { From 49eadb7545c927bd5877944771c6673b81e6e360 Mon Sep 17 00:00:00 2001 From: Charlie Gerard Date: Tue, 18 Jun 2024 11:19:40 -0700 Subject: [PATCH 04/10] wip --- lib/commands/repos/list.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/commands/repos/list.js b/lib/commands/repos/list.js index 8390a783..c42aeb36 100644 --- a/lib/commands/repos/list.js +++ b/lib/commands/repos/list.js @@ -1,6 +1,7 @@ /* eslint-disable no-console */ import chalk from 'chalk' +// @ts-ignore import chalkTable from 'chalk-table' import meow from 'meow' import ora from 'ora' @@ -135,6 +136,7 @@ function setupCommand (name, description, argv, importMeta) { */ async function listOrgRepos (orgSlug, input, spinner) { const socketSdk = await setupSdk(getDefaultKey()) + // @ts-ignore const result = await handleApiCall(socketSdk.getOrgRepoList(orgSlug, input), 'looking up package') if (!result.success) { @@ -153,6 +155,7 @@ async function listOrgRepos (orgSlug, input, spinner) { ] } + // @ts-ignore const formattedResults = result.data.results.map(d => { return { ...d From 764bdfb3f2101a500f1047a8ae9b817f234f5c72 Mon Sep 17 00:00:00 2001 From: Charlie Gerard Date: Tue, 18 Jun 2024 11:48:45 -0700 Subject: [PATCH 05/10] update view command --- lib/commands/repos/list.js | 2 +- lib/commands/repos/view.js | 64 +++++++++++++++++++++++++++----------- 2 files changed, 46 insertions(+), 20 deletions(-) diff --git a/lib/commands/repos/list.js b/lib/commands/repos/list.js index c42aeb36..a9d058b0 100644 --- a/lib/commands/repos/list.js +++ b/lib/commands/repos/list.js @@ -137,7 +137,7 @@ function setupCommand (name, description, argv, importMeta) { async function listOrgRepos (orgSlug, input, spinner) { const socketSdk = await setupSdk(getDefaultKey()) // @ts-ignore - const result = await handleApiCall(socketSdk.getOrgRepoList(orgSlug, input), 'looking up package') + const result = await handleApiCall(socketSdk.getOrgRepoList(orgSlug, input), 'listing repositories') if (!result.success) { return handleUnsuccessfulApiResponse('getOrgRepoList', result, spinner) diff --git a/lib/commands/repos/view.js b/lib/commands/repos/view.js index 575844a4..338cc49f 100644 --- a/lib/commands/repos/view.js +++ b/lib/commands/repos/view.js @@ -1,14 +1,15 @@ -// @ts-nocheck /* eslint-disable no-console */ +import chalk from 'chalk' +// @ts-ignore +import chalkTable from 'chalk-table' import meow from 'meow' import ora from 'ora' import { outputFlags } from '../../flags/index.js' -// import { handleApiCall, handleUnsuccessfulApiResponse } from '../../utils/api-helpers.js' -import { InputError } from '../../utils/errors.js' +import { handleApiCall, handleUnsuccessfulApiResponse } from '../../utils/api-helpers.js' import { printFlagList } from '../../utils/formatting.js' -// import { getDefaultKey, setupSdk } from '../../utils/sdk.js' +import { getDefaultKey, setupSdk } from '../../utils/sdk.js' /** @type {import('../../utils/meow-with-subcommands.js').CliSubcommand} */ export const view = { @@ -20,7 +21,7 @@ export const view = { if (input) { const spinnerText = 'Fetching repository... \n' const spinner = ora(spinnerText).start() - await viewRepository(input.orgSlug, input, spinner) + await viewRepository(input.orgSlug, input.repositoryName, spinner) } } } @@ -32,6 +33,7 @@ export const view = { * @property {boolean} outputJson * @property {boolean} outputMarkdown * @property {string} orgSlug + * @property {string} repositoryName */ /** @@ -68,37 +70,61 @@ function setupCommand (name, description, argv, importMeta) { } = cli.flags if (!cli.input[0]) { - throw new InputError(`Please specify an organization slug. \n -Example: -socket scan list FakeOrg -`) + console.error(`${chalk.bgRed('Input error')}: Please provide an organization slug \n`) + cli.showHelp() + return } - const orgSlug = cli.input[0] || '' + const [orgSlug = '', repositoryName = ''] = cli.input return { outputJson, outputMarkdown, - orgSlug + orgSlug, + repositoryName } } /** * @typedef RepositoryData - * @property {import('@socketsecurity/sdk').SocketSdkReturnType<'getOrgFullScanList'>["data"]} data + * @property {import('@socketsecurity/sdk').SocketSdkReturnType<'getOrgRepo'>["data"]} data */ /** * @param {string} orgSlug - * @param {CommandContext} input + * @param {string} repoName * @param {import('ora').Ora} spinner * @returns {Promise} */ -async function viewRepository (orgSlug, input, spinner) { - // const socketSdk = await setupSdk(getDefaultKey()) - console.log(input) +async function viewRepository (orgSlug, repoName, spinner) { + const socketSdk = await setupSdk(getDefaultKey()) + // @ts-ignore + const result = await handleApiCall(socketSdk.getOrgRepo(orgSlug, repoName), 'fetching repository') -// return { -// // data: result.data -// } + if (!result.success) { + return handleUnsuccessfulApiResponse('getOrgRepo', result, spinner) + } + + spinner.stop() + + const options = { + columns: [ + { field: 'id', name: chalk.magenta('ID') }, + { field: 'name', name: chalk.magenta('Name') }, + { field: 'visibility', name: chalk.magenta('Visibility') }, + { field: 'default_branch', name: chalk.magenta('Default branch') }, + { field: 'homepage', name: chalk.magenta('Homepage') }, + { field: 'archived', name: chalk.magenta('Archived') }, + { field: 'created_at', name: chalk.magenta('Created at') } + ] + } + + const table = chalkTable(options, [result.data]) + + console.log(table, '\n') + + return { + // @ts-ignore + data: result.data + } } From 7d35f64bbe1122d0eec331ce5099e4651a37fa51 Mon Sep 17 00:00:00 2001 From: Charlie Gerard Date: Tue, 18 Jun 2024 12:17:59 -0700 Subject: [PATCH 06/10] improve create command --- lib/commands/repos/create.js | 135 ++++++++++++++++++----------------- 1 file changed, 69 insertions(+), 66 deletions(-) diff --git a/lib/commands/repos/create.js b/lib/commands/repos/create.js index e4802ab0..fa0803ea 100644 --- a/lib/commands/repos/create.js +++ b/lib/commands/repos/create.js @@ -1,16 +1,14 @@ -// @ts-nocheck /* eslint-disable no-console */ -// import chalk from 'chalk' +import chalk from 'chalk' import meow from 'meow' import ora from 'ora' import { outputFlags } from '../../flags/index.js' -// import { handleApiCall, handleUnsuccessfulApiResponse } from '../../utils/api-helpers.js' -import { InputError } from '../../utils/errors.js' +import { handleApiCall, handleUnsuccessfulApiResponse } from '../../utils/api-helpers.js' import { prepareFlags } from '../../utils/flags.js' import { printFlagList } from '../../utils/formatting.js' -// import { getDefaultKey, setupSdk } from '../../utils/sdk.js' +import { getDefaultKey, setupSdk } from '../../utils/sdk.js' /** @type {import('../../utils/meow-with-subcommands.js').CliSubcommand} */ export const create = { @@ -27,42 +25,36 @@ export const create = { } } -const listFullScanFlags = prepareFlags({ - sort: { +const repositoryCreationFlags = prepareFlags({ + repoName: { type: 'string', - shortFlag: 's', - default: 'created_at', - description: 'Sorting option (`name` or `created_at`) - default is `created_at`', + shortFlag: 'n', + default: '', + description: 'Repository name', }, - direction: { + repoDescription: { type: 'string', shortFlag: 'd', - default: 'desc', - description: 'Direction option (`desc` or `asc`) - Default is `desc`', - }, - perPage: { - type: 'number', - shortFlag: 'pp', - default: 30, - description: 'Results per page - Default is 30', - }, - page: { - type: 'number', - shortFlag: 'p', - default: 1, - description: 'Page number - Default is 1', + default: '', + description: 'Repository description', }, - fromTime: { + homepage: { type: 'string', - shortFlag: 'f', + shortFlag: 'h', default: '', - description: 'From time - as a unix timestamp', + description: 'Repository url', }, - untilTime: { + defaultBranch: { type: 'string', - shortFlag: 'u', - default: '', - description: 'Until time - as a unix timestamp', + shortFlag: 'b', + default: 'main', + description: 'Repository default branch', + }, + visibility: { + type: 'string', + shortFlag: 'v', + default: 'private', + description: 'Repository visibility (Default Private)', } }) @@ -73,12 +65,11 @@ const listFullScanFlags = prepareFlags({ * @property {boolean} outputJson * @property {boolean} outputMarkdown * @property {string} orgSlug - * @property {string} sort - * @property {string} direction - * @property {number} perPage - * @property {number} page - * @property {string} fromTime - * @property {string} untilTime + * @property {string} name + * @property {string} description + * @property {string} homepage + * @property {string} default_branch + * @property {string} visibility */ /** @@ -91,7 +82,7 @@ const listFullScanFlags = prepareFlags({ function setupCommand (name, description, argv, importMeta) { const flags = { ...outputFlags, - ...listFullScanFlags + ...repositoryCreationFlags } const cli = meow(` @@ -102,7 +93,7 @@ function setupCommand (name, description, argv, importMeta) { ${printFlagList(flags, 6)} Examples - $ ${name} FakeOrg + $ ${name} FakeOrg --repoName=test-repo `, { argv, description, @@ -113,52 +104,64 @@ function setupCommand (name, description, argv, importMeta) { const { json: outputJson, markdown: outputMarkdown, - sort, - direction, - perPage, - page, - fromTime, - untilTime + repoName, + repoDescription, + homepage, + defaultBranch, + visibility } = cli.flags - if (!cli.input[0]) { - throw new InputError(`Please specify an organization slug. \n -Example: -socket scan list FakeOrg -`) + const [orgSlug = ''] = cli.input + + if (!orgSlug) { + console.error(`${chalk.bgRed('Input error')}: Please provide an organization slug \n`) + cli.showHelp() + return } - const orgSlug = cli.input[0] || '' + if (!repoName) { + console.error(`${chalk.bgRed('Input error')}: Repository name is required. \n`) + cli.showHelp() + return + } return { outputJson, outputMarkdown, orgSlug, - sort, - direction, - perPage, - page, - fromTime, - untilTime + name: repoName, + description: repoDescription, + homepage, + default_branch: defaultBranch, + visibility } } /** - * @typedef FullScansData - * @property {import('@socketsecurity/sdk').SocketSdkReturnType<'getOrgFullScanList'>["data"]} data + * @typedef RepositoryData + * @property {import('@socketsecurity/sdk').SocketSdkReturnType<'createOrgRepo'>["data"]} data */ /** * @param {string} orgSlug * @param {CommandContext} input * @param {import('ora').Ora} spinner - * @returns {Promise} + * @returns {Promise} */ async function createRepo (orgSlug, input, spinner) { - // const socketSdk = await setupSdk(getDefaultKey()) - console.log(input) + const socketSdk = await setupSdk(getDefaultKey()) + // @ts-ignore + const result = await handleApiCall(socketSdk.createOrgRepo(orgSlug, input), 'listing repositories') + + if (!result.success) { + return handleUnsuccessfulApiResponse('createOrgRepo', result, spinner) + } + + spinner.stop() -// return { -// // data: result.data -// } + console.log('\n✅ Repository created successfully \n') + + return { + data: result.data + } } From 4d6e8b3094c522b0b80bd07f8421d63107da6433 Mon Sep 17 00:00:00 2001 From: Charlie Gerard Date: Tue, 18 Jun 2024 13:01:02 -0700 Subject: [PATCH 07/10] improve update command --- lib/commands/repos/delete.js | 75 +++++++++++--------------- lib/commands/repos/update.js | 102 ++++++++++++++++++++++++++++------- lib/commands/repos/view.js | 2 +- 3 files changed, 115 insertions(+), 64 deletions(-) diff --git a/lib/commands/repos/delete.js b/lib/commands/repos/delete.js index 2811dcc6..9db5ab09 100644 --- a/lib/commands/repos/delete.js +++ b/lib/commands/repos/delete.js @@ -1,15 +1,11 @@ -// @ts-nocheck /* eslint-disable no-console */ -// import chalk from 'chalk' +import chalk from 'chalk' import meow from 'meow' import ora from 'ora' -import { outputFlags } from '../../flags/index.js' -// import { handleApiCall, handleUnsuccessfulApiResponse } from '../../utils/api-helpers.js' -import { InputError } from '../../utils/errors.js' -import { printFlagList } from '../../utils/formatting.js' -// import { getDefaultKey, setupSdk } from '../../utils/sdk.js' +import { handleApiCall, handleUnsuccessfulApiResponse } from '../../utils/api-helpers.js' +import { getDefaultKey, setupSdk } from '../../utils/sdk.js' /** @type {import('../../utils/meow-with-subcommands.js').CliSubcommand} */ export const del = { @@ -21,7 +17,7 @@ export const del = { if (input) { const spinnerText = 'Deleting repository... \n' const spinner = ora(spinnerText).start() - await deleteRepository(input.orgSlug, input, spinner) + await deleteRepository(input.orgSlug, input.repoName, spinner) } } } @@ -30,9 +26,8 @@ export const del = { /** * @typedef CommandContext - * @property {boolean} outputJson - * @property {boolean} outputMarkdown * @property {string} orgSlug + * @property {string} repoName */ /** @@ -43,63 +38,57 @@ export const del = { * @returns {void|CommandContext} */ function setupCommand (name, description, argv, importMeta) { - const flags = { - ...outputFlags - } - const cli = meow(` Usage - $ ${name} - - Options - ${printFlagList(flags, 6)} + $ ${name} Examples - $ ${name} FakeOrg + $ ${name} FakeOrg test-repo `, { argv, description, - importMeta, - flags + importMeta }) - const { - json: outputJson, - markdown: outputMarkdown - } = cli.flags + const [orgSlug = '', repoName = ''] = cli.input - if (!cli.input[0]) { - throw new InputError(`Please specify an organization slug. \n -Example: -socket scan list FakeOrg -`) + if (!orgSlug || !repoName) { + console.error(`${chalk.bgRed('Input error')}: Please provide an organization slug and repository slug \n`) + cli.showHelp() + return } - const orgSlug = cli.input[0] || '' - return { - outputJson, - outputMarkdown, - orgSlug + orgSlug, + repoName } } /** * @typedef RepositoryData - * @property {import('@socketsecurity/sdk').SocketSdkReturnType<'getOrgFullScanList'>["data"]} data + * @property {import('@socketsecurity/sdk').SocketSdkReturnType<'deleteOrgRepo'>["data"]} data */ /** * @param {string} orgSlug - * @param {CommandContext} input + * @param {string} repoName * @param {import('ora').Ora} spinner * @returns {Promise} */ -async function deleteRepository (orgSlug, input, spinner) { - // const socketSdk = await setupSdk(getDefaultKey()) - console.log(input) +async function deleteRepository (orgSlug, repoName, spinner) { + const socketSdk = await setupSdk(getDefaultKey()) + // @ts-ignore + const result = await handleApiCall(socketSdk.deleteOrgRepo(orgSlug, repoName), 'deleting repository') + + if (!result.success) { + return handleUnsuccessfulApiResponse('deleteOrgRepo', result, spinner) + } + + spinner.stop() + + console.log('\n✅ Repository deleted successfully \n') -// return { -// // data: result.data -// } + return { + data: result.data + } } diff --git a/lib/commands/repos/update.js b/lib/commands/repos/update.js index a8807263..21def25f 100644 --- a/lib/commands/repos/update.js +++ b/lib/commands/repos/update.js @@ -1,15 +1,14 @@ -// @ts-nocheck /* eslint-disable no-console */ -// import chalk from 'chalk' +import chalk from 'chalk' import meow from 'meow' import ora from 'ora' import { outputFlags } from '../../flags/index.js' -// import { handleApiCall, handleUnsuccessfulApiResponse } from '../../utils/api-helpers.js' -import { InputError } from '../../utils/errors.js' +import { handleApiCall, handleUnsuccessfulApiResponse } from '../../utils/api-helpers.js' +import { prepareFlags } from '../../utils/flags.js' import { printFlagList } from '../../utils/formatting.js' -// import { getDefaultKey, setupSdk } from '../../utils/sdk.js' +import { getDefaultKey, setupSdk } from '../../utils/sdk.js' /** @type {import('../../utils/meow-with-subcommands.js').CliSubcommand} */ export const update = { @@ -26,6 +25,39 @@ export const update = { } } +const repositoryUpdateFlags = prepareFlags({ + repoName: { + type: 'string', + shortFlag: 'n', + default: '', + description: 'Repository name', + }, + repoDescription: { + type: 'string', + shortFlag: 'd', + default: '', + description: 'Repository description', + }, + homepage: { + type: 'string', + shortFlag: 'h', + default: '', + description: 'Repository url', + }, + defaultBranch: { + type: 'string', + shortFlag: 'b', + default: 'main', + description: 'Repository default branch', + }, + visibility: { + type: 'string', + shortFlag: 'v', + default: 'private', + description: 'Repository visibility (Default Private)', + } +}) + // Internal functions /** @@ -33,6 +65,11 @@ export const update = { * @property {boolean} outputJson * @property {boolean} outputMarkdown * @property {string} orgSlug + * @property {string} name + * @property {string} description + * @property {string} homepage + * @property {string} default_branch + * @property {string} visibility */ /** @@ -44,7 +81,8 @@ export const update = { */ function setupCommand (name, description, argv, importMeta) { const flags = { - ...outputFlags + ...outputFlags, + ...repositoryUpdateFlags } const cli = meow(` @@ -65,28 +103,43 @@ function setupCommand (name, description, argv, importMeta) { const { json: outputJson, - markdown: outputMarkdown + markdown: outputMarkdown, + repoName, + repoDescription, + homepage, + defaultBranch, + visibility } = cli.flags - if (!cli.input[0]) { - throw new InputError(`Please specify an organization slug. \n -Example: -socket scan list FakeOrg -`) + const [orgSlug = ''] = cli.input + + if (!orgSlug) { + console.error(`${chalk.bgRed('Input error')}: Please provide an organization slug and repository name \n`) + cli.showHelp() + return } - const orgSlug = cli.input[0] || '' + if (!repoName) { + console.error(`${chalk.bgRed('Input error')}: Repository name is required. \n`) + cli.showHelp() + return + } return { outputJson, outputMarkdown, - orgSlug + orgSlug, + name: repoName, + description: repoDescription, + homepage, + default_branch: defaultBranch, + visibility } } /** * @typedef RepositoryData - * @property {import('@socketsecurity/sdk').SocketSdkReturnType<'getOrgFullScanList'>["data"]} data + * @property {import('@socketsecurity/sdk').SocketSdkReturnType<'updateOrgRepo'>["data"]} data */ /** @@ -96,10 +149,19 @@ socket scan list FakeOrg * @returns {Promise} */ async function updateRepository (orgSlug, input, spinner) { - // const socketSdk = await setupSdk(getDefaultKey()) - console.log(input) + const socketSdk = await setupSdk(getDefaultKey()) + // @ts-ignore + const result = await handleApiCall(socketSdk.updateOrgRepo(orgSlug, input.name, input), 'listing repositories') + + if (!result.success) { + return handleUnsuccessfulApiResponse('updateOrgRepo', result, spinner) + } + + spinner.stop() + + console.log('\n✅ Repository updated successfully \n') -// return { -// // data: result.data -// } + return { + data: result.data + } } diff --git a/lib/commands/repos/view.js b/lib/commands/repos/view.js index 338cc49f..02a78e1e 100644 --- a/lib/commands/repos/view.js +++ b/lib/commands/repos/view.js @@ -70,7 +70,7 @@ function setupCommand (name, description, argv, importMeta) { } = cli.flags if (!cli.input[0]) { - console.error(`${chalk.bgRed('Input error')}: Please provide an organization slug \n`) + console.error(`${chalk.bgRed('Input error')}: Please provide an organization slug and repository name \n`) cli.showHelp() return } From 2c64e33f6444f43e6e79c65b4d06bbadd9435f4a Mon Sep 17 00:00:00 2001 From: Charlie Gerard Date: Thu, 20 Jun 2024 08:34:14 -0700 Subject: [PATCH 08/10] update --- lib/commands/repos/delete.js | 1 - lib/commands/repos/index.js | 1 - lib/commands/repos/list.js | 2 -- lib/commands/repos/view.js | 2 -- 4 files changed, 6 deletions(-) diff --git a/lib/commands/repos/delete.js b/lib/commands/repos/delete.js index 9db5ab09..50339804 100644 --- a/lib/commands/repos/delete.js +++ b/lib/commands/repos/delete.js @@ -77,7 +77,6 @@ function setupCommand (name, description, argv, importMeta) { */ async function deleteRepository (orgSlug, repoName, spinner) { const socketSdk = await setupSdk(getDefaultKey()) - // @ts-ignore const result = await handleApiCall(socketSdk.deleteOrgRepo(orgSlug, repoName), 'deleting repository') if (!result.success) { diff --git a/lib/commands/repos/index.js b/lib/commands/repos/index.js index 628d3066..719b0b6c 100644 --- a/lib/commands/repos/index.js +++ b/lib/commands/repos/index.js @@ -1,4 +1,3 @@ -// @ts-nocheck import { create } from './create.js' import { del } from './delete.js' import { list } from './list.js' diff --git a/lib/commands/repos/list.js b/lib/commands/repos/list.js index a9d058b0..45f80aa4 100644 --- a/lib/commands/repos/list.js +++ b/lib/commands/repos/list.js @@ -136,7 +136,6 @@ function setupCommand (name, description, argv, importMeta) { */ async function listOrgRepos (orgSlug, input, spinner) { const socketSdk = await setupSdk(getDefaultKey()) - // @ts-ignore const result = await handleApiCall(socketSdk.getOrgRepoList(orgSlug, input), 'listing repositories') if (!result.success) { @@ -155,7 +154,6 @@ async function listOrgRepos (orgSlug, input, spinner) { ] } - // @ts-ignore const formattedResults = result.data.results.map(d => { return { ...d diff --git a/lib/commands/repos/view.js b/lib/commands/repos/view.js index 02a78e1e..a6251a75 100644 --- a/lib/commands/repos/view.js +++ b/lib/commands/repos/view.js @@ -98,7 +98,6 @@ function setupCommand (name, description, argv, importMeta) { */ async function viewRepository (orgSlug, repoName, spinner) { const socketSdk = await setupSdk(getDefaultKey()) - // @ts-ignore const result = await handleApiCall(socketSdk.getOrgRepo(orgSlug, repoName), 'fetching repository') if (!result.success) { @@ -124,7 +123,6 @@ async function viewRepository (orgSlug, repoName, spinner) { console.log(table, '\n') return { - // @ts-ignore data: result.data } } From fab4d7cf0c8f9609e2c118a7e47323083f7673ec Mon Sep 17 00:00:00 2001 From: Charlie Gerard Date: Fri, 21 Jun 2024 09:03:17 -0700 Subject: [PATCH 09/10] wip --- lib/commands/repos/create.js | 2 +- lib/commands/repos/update.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/commands/repos/create.js b/lib/commands/repos/create.js index fa0803ea..4155c5fb 100644 --- a/lib/commands/repos/create.js +++ b/lib/commands/repos/create.js @@ -151,7 +151,7 @@ function setupCommand (name, description, argv, importMeta) { async function createRepo (orgSlug, input, spinner) { const socketSdk = await setupSdk(getDefaultKey()) // @ts-ignore - const result = await handleApiCall(socketSdk.createOrgRepo(orgSlug, input), 'listing repositories') + const result = await handleApiCall(socketSdk.createOrgRepo(orgSlug, input), 'creating repository') if (!result.success) { return handleUnsuccessfulApiResponse('createOrgRepo', result, spinner) diff --git a/lib/commands/repos/update.js b/lib/commands/repos/update.js index 21def25f..cae93ebc 100644 --- a/lib/commands/repos/update.js +++ b/lib/commands/repos/update.js @@ -151,7 +151,7 @@ function setupCommand (name, description, argv, importMeta) { async function updateRepository (orgSlug, input, spinner) { const socketSdk = await setupSdk(getDefaultKey()) // @ts-ignore - const result = await handleApiCall(socketSdk.updateOrgRepo(orgSlug, input.name, input), 'listing repositories') + const result = await handleApiCall(socketSdk.updateOrgRepo(orgSlug, input.name, input), 'updating repository') if (!result.success) { return handleUnsuccessfulApiResponse('updateOrgRepo', result, spinner) From 3a61d871f352f586fcd687cbad943c9470e75adc Mon Sep 17 00:00:00 2001 From: Charlie Gerard Date: Fri, 21 Jun 2024 11:13:45 -0700 Subject: [PATCH 10/10] update --- lib/commands/repos/create.js | 1 - lib/commands/repos/update.js | 1 - package-lock.json | 8 ++++---- package.json | 2 +- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/commands/repos/create.js b/lib/commands/repos/create.js index 4155c5fb..5390495d 100644 --- a/lib/commands/repos/create.js +++ b/lib/commands/repos/create.js @@ -150,7 +150,6 @@ function setupCommand (name, description, argv, importMeta) { */ async function createRepo (orgSlug, input, spinner) { const socketSdk = await setupSdk(getDefaultKey()) - // @ts-ignore const result = await handleApiCall(socketSdk.createOrgRepo(orgSlug, input), 'creating repository') if (!result.success) { diff --git a/lib/commands/repos/update.js b/lib/commands/repos/update.js index cae93ebc..298a2ebc 100644 --- a/lib/commands/repos/update.js +++ b/lib/commands/repos/update.js @@ -150,7 +150,6 @@ function setupCommand (name, description, argv, importMeta) { */ async function updateRepository (orgSlug, input, spinner) { const socketSdk = await setupSdk(getDefaultKey()) - // @ts-ignore const result = await handleApiCall(socketSdk.updateOrgRepo(orgSlug, input.name, input), 'updating repository') if (!result.success) { diff --git a/package-lock.json b/package-lock.json index 000b3ad4..0f6e6386 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,7 @@ "@cyclonedx/cdxgen": "^10.5.2", "@inquirer/select": "^2.3.5", "@socketsecurity/config": "^2.1.3", - "@socketsecurity/sdk": "^1.1.0", + "@socketsecurity/sdk": "^1.1.1", "chalk": "^5.3.0", "chalk-table": "^1.0.2", "execa": "^9.1.0", @@ -1615,9 +1615,9 @@ } }, "node_modules/@socketsecurity/sdk": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@socketsecurity/sdk/-/sdk-1.1.0.tgz", - "integrity": "sha512-9bI6C48C1p9dsug8JVUqCnsM0oMdILw8jPJaUZhdCEDupnkb2aqSM25s3u6sfV0U+9YNS5Dv5HTRHv04cESScQ==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@socketsecurity/sdk/-/sdk-1.1.1.tgz", + "integrity": "sha512-ACVBe0UiZxy3S1C/2OvetAOoaZDumanKRzr2gXq5qOjhI6neLr2tZxC5xI+UcMKAcTDkwOZM8mpqvMdSjd6EEw==", "dependencies": { "formdata-node": "^5.0.0", "got": "^12.5.3", diff --git a/package.json b/package.json index b722c346..2c9dda8e 100644 --- a/package.json +++ b/package.json @@ -87,7 +87,7 @@ "@cyclonedx/cdxgen": "^10.5.2", "@inquirer/select": "^2.3.5", "@socketsecurity/config": "^2.1.3", - "@socketsecurity/sdk": "^1.1.0", + "@socketsecurity/sdk": "^1.1.1", "chalk": "^5.3.0", "chalk-table": "^1.0.2", "execa": "^9.1.0",