File tree Expand file tree Collapse file tree 2 files changed +29
-1
lines changed
Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " @contentstack/cli" ,
33 "description" : " Command-line tool (CLI) to interact with Contentstack" ,
4- "version" : " 2.0.0-beta.13 " ,
4+ "version" : " 2.0.0-beta.14 " ,
55 "author" : " Contentstack" ,
66 "bin" : {
77 "csdx" : " ./bin/run.js"
157157 ],
158158 "hooks" : {
159159 "prerun" : [
160+ " ./lib/hooks/prerun/init-context-for-command" ,
160161 " ./lib/hooks/prerun/default-rate-limit-check" ,
161162 " ./lib/hooks/prerun/latest-version-warning"
162163 ],
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments