Skip to content

Commit bd50ebd

Browse files
Merge pull request #2445 from contentstack/fix/dx-4439-v1-dev-interactive-mode-messages
Fix/dx 4439 v1 dev interactive mode messages
2 parents 1ede212 + 5525d2a commit bd50ebd

6 files changed

Lines changed: 415 additions & 374 deletions

File tree

.github/workflows/sca-scan.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@ jobs:
1313
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
1414
with:
1515
args: --all-projects --fail-on=all
16+
json: true
17+
continue-on-error: true
18+
- uses: contentstack/sca-policy@main

packages/contentstack-auth/messages/index.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"CLI_AUTH_LOGOUT_DESCRIPTION": "User session logout",
1919
"CLI_AUTH_LOGOUT_FLAG_FORCE": "Force logging out for skipping the confirmation",
2020
"CLI_AUTH_LOGOUT_ALREADY": "You're already logged out",
21+
"CLI_AUTH_LOGOUT_CANCELLED": "Log out cancelled",
2122
"CLI_AUTH_LOGOUT_NO_AUTHORIZATIONS": "No authorizations found",
2223
"CLI_AUTH_LOGOUT_NO_AUTHORIZATIONS_USER": "No authorizations found for current user",
2324
"CLI_AUTH_WHOAMI_LOGGED_IN_AS": "You are currently logged in with email:",

packages/contentstack-auth/src/commands/auth/logout.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,10 @@ export default class LogoutCommand extends BaseCommand<typeof LogoutCommand> {
9393
confirm,
9494
isAuthenticated: oauthHandler.isAuthenticated(),
9595
});
96-
log.success(messageHandler.parse('CLI_AUTH_LOGOUT_ALREADY'), this.contextDetails);
96+
const messageKey = confirm === false && oauthHandler.isAuthenticated()
97+
? 'CLI_AUTH_LOGOUT_CANCELLED'
98+
: 'CLI_AUTH_LOGOUT_ALREADY';
99+
log.success(messageHandler.parse(messageKey), this.contextDetails);
97100
}
98101
} catch (error) {
99102
log.debug('Logout failed.', { ...this.contextDetails, error: error.message });

packages/contentstack/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@
156156
],
157157
"hooks": {
158158
"prerun": [
159+
"./lib/hooks/prerun/init-context-for-command",
159160
"./lib/hooks/prerun/command-deprecation-check",
160161
"./lib/hooks/prerun/default-rate-limit-check",
161162
"./lib/hooks/prerun/latest-version-warning"
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import {
2+
cliux,
3+
messageHandler,
4+
managementSDKInitiator,
5+
marketplaceSDKInitiator,
6+
} from '@contentstack/cli-utilities';
7+
import { CsdxContext } from '../../utils';
8+
9+
/**
10+
* When an invalid command is corrected (e.g. loginasda → login), init ran with the invalid
11+
* command so context.messageFilePath was never set. Re-build context and re-init utilities
12+
* for the actual command so i18n prompts show human-readable text.
13+
*/
14+
export default async function (opts: {
15+
Command?: { id?: string };
16+
config?: any;
17+
}): Promise<void> {
18+
const config = opts?.config ?? this.config;
19+
const commandId = opts?.Command?.id;
20+
if (!config?.context?.messageFilePath && commandId) {
21+
config.context = new CsdxContext({ id: commandId }, config);
22+
messageHandler.init(config.context);
23+
cliux.init(config.context);
24+
managementSDKInitiator.init(config.context);
25+
marketplaceSDKInitiator.init(config.context);
26+
}
27+
}

0 commit comments

Comments
 (0)