-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from contentstack/fix/DX-643/DX-644
fixed entry variant import for file fields and fixed project name dup…
- Loading branch information
Showing
8 changed files
with
126 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,34 @@ | ||
import { FsUtility } from '@contentstack/cli-utilities'; | ||
import { FsUtility, cliux } from '@contentstack/cli-utilities'; | ||
|
||
export const formatError = function (error: any) { | ||
try { | ||
if (typeof error === 'string') { | ||
error = JSON.parse(error); | ||
} else { | ||
error = JSON.parse(error.message); | ||
} | ||
} catch (e) {} | ||
let message = error.errorMessage || error.error_message || error.message || error; | ||
if (error.errors && Object.keys(error.errors).length > 0) { | ||
Object.keys(error.errors).forEach((e) => { | ||
let entity = e; | ||
if (e === 'authorization') entity = 'Management Token'; | ||
if (e === 'api_key') entity = 'Stack API key'; | ||
if (e === 'uid') entity = 'Content Type'; | ||
if (e === 'access_token') entity = 'Delivery Token'; | ||
message += ' ' + [entity, error.errors[e]].join(' '); | ||
}); | ||
try { | ||
if (typeof error === 'string') { | ||
error = JSON.parse(error); | ||
} else { | ||
error = JSON.parse(error.message); | ||
} | ||
return message; | ||
} catch (e) {} | ||
let message = error.errorMessage || error.error_message || error.message || error; | ||
if (error.errors && Object.keys(error.errors).length > 0) { | ||
Object.keys(error.errors).forEach((e) => { | ||
let entity = e; | ||
if (e === 'authorization') entity = 'Management Token'; | ||
if (e === 'api_key') entity = 'Stack API key'; | ||
if (e === 'uid') entity = 'Content Type'; | ||
if (e === 'access_token') entity = 'Delivery Token'; | ||
message += ' ' + [entity, error.errors[e]].join(' '); | ||
}); | ||
} | ||
return message; | ||
}; | ||
|
||
export const fsUtil = new FsUtility(); | ||
|
||
export const askProjectName = async (defaultValue: unknown): Promise<string> => { | ||
return await cliux.inquire({ | ||
type: 'input', | ||
name: 'name', | ||
default: defaultValue, | ||
message: 'Enter the project name:', | ||
}); | ||
}; |