Skip to content

Commit 052f7ba

Browse files
fix cli not functional after deleting current-context (#791)
1 parent 3c6636a commit 052f7ba

File tree

4 files changed

+14
-10
lines changed

4 files changed

+14
-10
lines changed

lib/interface/cli/commad-line-interface.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const PROCESS_ARGV = require('yargs-parser')(process.argv);
1515

1616
const cliConfig = configManager.config();
1717

18-
async function getConfigForSdk() {
18+
async function getConfigForSdk(options = {}) {
1919
const configOptions = {
2020
configPath: PROCESS_ARGV.cfconfig,
2121
spec: { json: openapi },
@@ -27,16 +27,20 @@ async function getConfigForSdk() {
2727
'Codefresh-User-Agent-Version': version,
2828
},
2929
}, cliConfig.request, cliConfHelpers.getSdkConfigForPagination().request),
30+
allowNoContext: options.allowNoContext,
3031
};
3132
return Config.load(configOptions);
3233
}
3334
async function startCommandLine() {
35+
const allowNoContext = process.argv.join(' ').includes('config use-context');
3436
const [files, config] = await Promise.all([
3537
recursive(path.resolve(__dirname, 'commands')),
36-
getConfigForSdk(),
38+
getConfigForSdk({ allowNoContext }),
3739
]);
3840

39-
sdk.configure(config);
41+
if (!allowNoContext) {
42+
sdk.configure(config);
43+
}
4044

4145
const rootCommands = [];
4246
_.forEach(files, (file) => {

lib/interface/cli/commands/auth/use-context.cmd.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const command = new Command({
2626
const contextName = argv.name;
2727

2828
const configManager = Config.manager();
29-
await configManager.loadConfig({ configFilePath: argv.cfconfig });
29+
await configManager.loadConfig({ configFilePath: argv.cfconfig, allowNoContext: true });
3030

3131
const context = configManager.getContextByName(contextName);
3232
if (context) {

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "codefresh",
3-
"version": "0.82.1",
3+
"version": "0.82.2",
44
"description": "Codefresh command line utility",
55
"main": "index.js",
66
"preferGlobal": true,
@@ -52,7 +52,7 @@
5252
"cf-errors": "^0.1.16",
5353
"chalk": "^4.1.0",
5454
"cli-progress": "3.10.0",
55-
"codefresh-sdk": "^1.11.1",
55+
"codefresh-sdk": "^1.11.2",
5656
"colors": "1.4.0",
5757
"columnify": "^1.6.0",
5858
"compare-versions": "^3.4.0",

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,10 +1177,10 @@ code-point-at@^1.0.0:
11771177
resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77"
11781178
integrity sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=
11791179

1180-
codefresh-sdk@^1.11.1:
1181-
version "1.11.1"
1182-
resolved "https://registry.yarnpkg.com/codefresh-sdk/-/codefresh-sdk-1.11.1.tgz#a4305e059da88b79378158bcda12f81ad463af1f"
1183-
integrity sha512-N23GarhBEjnFg7xDcHI3p7xsjnPP6ScyrE/bw2V8BumKznTN7dsQ/yY7cHbMdFkPKvz3XahD/qV6GU7EFiYEaA==
1180+
codefresh-sdk@^1.11.2:
1181+
version "1.11.2"
1182+
resolved "https://registry.yarnpkg.com/codefresh-sdk/-/codefresh-sdk-1.11.2.tgz#0e23804980311ca9d5dd1eaa3504e89ed5248a08"
1183+
integrity sha512-G6UEfMdnhCg89TnCOvc84aVp+CRHSmu7sGaLclFrvKBAlEYEYsWZR1DsWmtcMc/IoU8mdstkTlVyFZ4XYYkXsg==
11841184
dependencies:
11851185
"@codefresh-io/cf-receiver" "0.0.1-alpha19"
11861186
bluebird "^3.7.2"

0 commit comments

Comments
 (0)