@contentstack/cli-migration 2.0.0-beta.7 → 2.0.0-beta.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/lib/utils/error-helper.js +6 -6
- package/lib/utils/error-helper.js.map +1 -1
- package/oclif.manifest.json +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@ $ npm install -g @contentstack/cli-migration
|
|
|
21
21
|
$ csdx COMMAND
|
|
22
22
|
running command...
|
|
23
23
|
$ csdx (--version)
|
|
24
|
-
@contentstack/cli-migration/2.0.0-beta.
|
|
24
|
+
@contentstack/cli-migration/2.0.0-beta.9 linux-x64 node-v22.22.1
|
|
25
25
|
$ csdx --help [COMMAND]
|
|
26
26
|
USAGE
|
|
27
27
|
$ csdx COMMAND
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
// @ts-ignore - no types available
|
|
5
5
|
const cardinal_1 = require("cardinal");
|
|
6
|
-
const
|
|
6
|
+
const cli_utilities_1 = require("@contentstack/cli-utilities");
|
|
7
7
|
const isEmpty_1 = tslib_1.__importDefault(require("lodash/isEmpty"));
|
|
8
8
|
const migration_logger_1 = tslib_1.__importDefault(require("./migration-logger"));
|
|
9
9
|
const fs_helper_1 = require("./fs-helper");
|
|
@@ -43,7 +43,7 @@ exports.default = (errors, filePath) => {
|
|
|
43
43
|
const fileContents = (0, fs_helper_1.readFile)(file);
|
|
44
44
|
const highlightedCode = (0, cardinal_1.highlight)(fileContents, { linenos: true });
|
|
45
45
|
const lines = highlightedCode.split('\n');
|
|
46
|
-
const fileErrorsMessage = (0,
|
|
46
|
+
const fileErrorsMessage = ((0, cli_utilities_1.getChalk)()) `{red Errors in ${file}}\n\n`;
|
|
47
47
|
errorLogs[file].fileErrorsMessage = fileErrorsMessage.replace(/\u001b\[\d+m/g, '');
|
|
48
48
|
const errorMessages = errorsByFile[file]
|
|
49
49
|
.map((error) => {
|
|
@@ -51,9 +51,9 @@ exports.default = (errors, filePath) => {
|
|
|
51
51
|
const callsite = error.meta.callsite;
|
|
52
52
|
const context = 2;
|
|
53
53
|
let { before, line, after } = getLineWithContext(lines, callsite.line, context);
|
|
54
|
-
const beforeLines = before.map((_line) => (0,
|
|
55
|
-
const afterLines = after.map((_line) => (0,
|
|
56
|
-
const highlightedLine = (0,
|
|
54
|
+
const beforeLines = before.map((_line) => ((0, cli_utilities_1.getChalk)()) `${_line}\n`);
|
|
55
|
+
const afterLines = after.map((_line) => ((0, cli_utilities_1.getChalk)()) `${_line}\n`);
|
|
56
|
+
const highlightedLine = ((0, cli_utilities_1.getChalk)()) `{bold ${line}}\n`;
|
|
57
57
|
before = removeSpecialCharacter(before.join('\n'));
|
|
58
58
|
after = removeSpecialCharacter(after.join('\n'));
|
|
59
59
|
line = removeSpecialCharacter(line);
|
|
@@ -90,7 +90,7 @@ exports.default = (errors, filePath) => {
|
|
|
90
90
|
}
|
|
91
91
|
if ((0, isEmpty_1.default)(messages) && errors !== undefined && (0, isEmpty_1.default)(errorsByFile)) {
|
|
92
92
|
logger.log('error', { errors: errors });
|
|
93
|
-
console.log((0,
|
|
93
|
+
console.log(((0, cli_utilities_1.getChalk)()) `{bold.red migration unsuccessful}`);
|
|
94
94
|
}
|
|
95
95
|
else {
|
|
96
96
|
logger.log('error', { error: messages.join('\n') });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-helper.js","sourceRoot":"","sources":["../../src/utils/error-helper.ts"],"names":[],"mappings":";;;AAAA,kCAAkC;AAClC,uCAAqC;AACrC
|
|
1
|
+
{"version":3,"file":"error-helper.js","sourceRoot":"","sources":["../../src/utils/error-helper.ts"],"names":[],"mappings":";;;AAAA,kCAAkC;AAClC,uCAAqC;AACrC,+DAAuD;AACvD,qEAAqC;AACrC,kFAAiD;AAEjD,2CAAuC;AACvC,kEAAiC;AAEjC,MA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\nimport isEmpty from 'lodash/isEmpty';\nimport MigrationLogger from './migration-logger';\nimport fs from 'fs';\nimport { readFile } from './fs-helper';\nimport groupBy from './group-by';\n\nconst getLineWithContext = (lines: string[], lineNumber: number, context: number): any => {\n const line = lineNumber - 1;\n\n const firstLine = line > context ? line - context : 0;\n const lastLine = line + context < lines.length ? line + context : lines.length;\n\n return {\n before: lines.slice(firstLine, line),\n line: lines[line],\n after: lines.slice(line + 1, lastLine + 1),\n };\n};\n\nfunction removeSpecialCharacter(str: string): string {\n return str.replace(/\\u001b\\[\\d+m/g, '');\n}\n\nexport default (errors: any, filePath?: string): void => {\n const logger = new MigrationLogger(process.env.CS_CLI_LOG_PATH ?? process.cwd());\n\n const errorsByFile = groupBy(errors, 'file');\n const messages: string[] = [];\n if (filePath) {\n if (errors.request) {\n errors.data = errors.request?.data;\n delete errors.request;\n }\n if (errors.message) {\n delete errors.message;\n }\n logger.log('error', { [filePath]: errors });\n } else {\n for (const file of Object.keys(errorsByFile)) {\n const errorLogs: any = {};\n errorLogs[file] = {};\n const fileContents = readFile(file);\n const highlightedCode = highlight(fileContents, { linenos: true });\n const lines = highlightedCode.split('\\n');\n\n const fileErrorsMessage = (getChalk())`{red Errors in ${file}}\\n\\n`;\n errorLogs[file].fileErrorsMessage = fileErrorsMessage.replace(/\\u001b\\[\\d+m/g, '');\n const errorMessages = errorsByFile[file]\n .map((error: any) => {\n const callsite = error.meta.callsite;\n const context = 2;\n let { before, line, after } = getLineWithContext(lines, callsite.line, context);\n\n const beforeLines = before.map((_line: string) => (getChalk())`${_line}\\n`);\n const afterLines = after.map((_line: string) => (getChalk())`${_line}\\n`);\n const highlightedLine = (getChalk())`{bold ${line}}\\n`;\n\n before = removeSpecialCharacter(before.join('\\n'));\n after = removeSpecialCharacter(after.join('\\n'));\n line = removeSpecialCharacter(line);\n errorLogs[file].lines = { before, line, after };\n if (error.request) {\n error.data = error.request?.data;\n delete error.request;\n }\n if (error.message) {\n delete error.message;\n }\n const formattedCode = beforeLines + highlightedLine + afterLines;\n if (error.payload?.apiError) {\n errorLogs[file].apiError = true;\n errorLogs[file].errorCode = error.payload.apiError.errorCode;\n errorLogs[file].errors = error.payload.apiError.errors;\n errorLogs[file].data = error.data;\n }\n if (error.message && !error.payload.apiError) {\n errorLogs[file].apiError = false;\n errorLogs[file].error = error.message;\n }\n })\n .join('\\n');\n\n messages.push(`${fileErrorsMessage}${errorMessages}`);\n logger.log('error', errorLogs);\n }\n if (errors?.request) {\n errors.data = errors.request?.data;\n delete errors.request;\n }\n if (errors?.message) {\n delete errors.message;\n }\n if (isEmpty(messages) && errors !== undefined && isEmpty(errorsByFile)) {\n logger.log('error', { errors: errors });\n console.log((getChalk())`{bold.red migration unsuccessful}`);\n } else {\n logger.log('error', { error: messages.join('\\n') });\n }\n }\n // eslint-disable-next-line\n // console.log(chalk`{bold.red Migration unsuccessful}`);\n};\n"]}
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentstack/cli-migration",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.9",
|
|
4
4
|
"author": "@contentstack",
|
|
5
5
|
"bugs": "https://github.com/contentstack/cli/issues",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@contentstack/cli-command": "~2.0.0-beta.
|
|
8
|
-
"@contentstack/cli-utilities": "~2.0.0-beta.
|
|
7
|
+
"@contentstack/cli-command": "~2.0.0-beta.4",
|
|
8
|
+
"@contentstack/cli-utilities": "~2.0.0-beta.4",
|
|
9
9
|
"@oclif/core": "^4.3.0",
|
|
10
10
|
"@oclif/plugin-help": "^6.2.28",
|
|
11
11
|
"async": "^3.2.6",
|
|
12
12
|
"callsites": "^3.1.0",
|
|
13
13
|
"cardinal": "^2.1.1",
|
|
14
|
-
"chalk": "^
|
|
14
|
+
"chalk": "^5.6.2",
|
|
15
15
|
"concat-stream": "^2.0.0",
|
|
16
16
|
"listr": "^0.14.3",
|
|
17
17
|
"rxjs": "^6.6.7",
|
|
@@ -71,4 +71,4 @@
|
|
|
71
71
|
"cm:stacks:migration": "MGRTN"
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
|
-
}
|
|
74
|
+
}
|