Skip to content

Commit

Permalink
fix cli not functional after deleting current-context (#791)
Browse files Browse the repository at this point in the history
  • Loading branch information
roi-codefresh authored Feb 19, 2023
1 parent 3c6636a commit 052f7ba
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
10 changes: 7 additions & 3 deletions lib/interface/cli/commad-line-interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand All @@ -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) => {
Expand Down
2 changes: 1 addition & 1 deletion lib/interface/cli/commands/auth/use-context.cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "codefresh",
"version": "0.82.1",
"version": "0.82.2",
"description": "Codefresh command line utility",
"main": "index.js",
"preferGlobal": true,
Expand Down Expand Up @@ -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",
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 052f7ba

Please sign in to comment.