diff --git a/lib/interface/cli/commad-line-interface.js b/lib/interface/cli/commad-line-interface.js index 5d3114fe5..01d117dad 100644 --- a/lib/interface/cli/commad-line-interface.js +++ b/lib/interface/cli/commad-line-interface.js @@ -15,7 +15,7 @@ const PROCESS_ARGV = require('yargs-parser')(process.argv); const cliConfig = configManager.config(); -async function getConfigForSdk() { +async function getConfigForSdk(options = {}) { const configOptions = { configPath: PROCESS_ARGV.cfconfig, spec: { json: openapi }, @@ -27,16 +27,20 @@ async function getConfigForSdk() { 'Codefresh-User-Agent-Version': version, }, }, cliConfig.request, cliConfHelpers.getSdkConfigForPagination().request), + allowNoContext: options.allowNoContext, }; return Config.load(configOptions); } async function startCommandLine() { + const allowNoContext = process.argv.join(' ').includes('config use-context'); const [files, config] = await Promise.all([ recursive(path.resolve(__dirname, 'commands')), - getConfigForSdk(), + getConfigForSdk({ allowNoContext }), ]); - sdk.configure(config); + if (!allowNoContext) { + sdk.configure(config); + } const rootCommands = []; _.forEach(files, (file) => { diff --git a/lib/interface/cli/commands/auth/use-context.cmd.js b/lib/interface/cli/commands/auth/use-context.cmd.js index 0ada7b692..072459504 100644 --- a/lib/interface/cli/commands/auth/use-context.cmd.js +++ b/lib/interface/cli/commands/auth/use-context.cmd.js @@ -26,7 +26,7 @@ const command = new Command({ const contextName = argv.name; const configManager = Config.manager(); - await configManager.loadConfig({ configFilePath: argv.cfconfig }); + await configManager.loadConfig({ configFilePath: argv.cfconfig, allowNoContext: true }); const context = configManager.getContextByName(contextName); if (context) { diff --git a/package.json b/package.json index e3c1e4809..84b9a121e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codefresh", - "version": "0.82.1", + "version": "0.82.2", "description": "Codefresh command line utility", "main": "index.js", "preferGlobal": true, @@ -52,7 +52,7 @@ "cf-errors": "^0.1.16", "chalk": "^4.1.0", "cli-progress": "3.10.0", - "codefresh-sdk": "^1.11.1", + "codefresh-sdk": "^1.11.2", "colors": "1.4.0", "columnify": "^1.6.0", "compare-versions": "^3.4.0", diff --git a/yarn.lock b/yarn.lock index f5aa1840d..d2a39aa89 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1177,10 +1177,10 @@ code-point-at@^1.0.0: resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77" integrity sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c= -codefresh-sdk@^1.11.1: - version "1.11.1" - resolved "https://registry.yarnpkg.com/codefresh-sdk/-/codefresh-sdk-1.11.1.tgz#a4305e059da88b79378158bcda12f81ad463af1f" - integrity sha512-N23GarhBEjnFg7xDcHI3p7xsjnPP6ScyrE/bw2V8BumKznTN7dsQ/yY7cHbMdFkPKvz3XahD/qV6GU7EFiYEaA== +codefresh-sdk@^1.11.2: + version "1.11.2" + resolved "https://registry.yarnpkg.com/codefresh-sdk/-/codefresh-sdk-1.11.2.tgz#0e23804980311ca9d5dd1eaa3504e89ed5248a08" + integrity sha512-G6UEfMdnhCg89TnCOvc84aVp+CRHSmu7sGaLclFrvKBAlEYEYsWZR1DsWmtcMc/IoU8mdstkTlVyFZ4XYYkXsg== dependencies: "@codefresh-io/cf-receiver" "0.0.1-alpha19" bluebird "^3.7.2"