diff --git a/package-lock.json b/package-lock.json index a925d0a..c40473f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -294,6 +294,17 @@ "@jridgewell/sourcemap-codec": "^1.4.10" } }, + "node_modules/@e965/xlsx": { + "version": "0.20.0", + "resolved": "https://registry.npmjs.org/@e965/xlsx/-/xlsx-0.20.0.tgz", + "integrity": "sha512-rOBiPtww7CtlRP2Ggtz+ugagrmlpQHrqKZNLMAxLtpMRPK1AFzj2JurmDT55x+pKAVY80nTFJzmtLZDQhCk2qw==", + "bin": { + "xlsx": "bin/xlsx.njs" + }, + "engines": { + "node": ">=0.8" + } + }, "node_modules/@es-joy/jsdoccomment": { "version": "0.40.1", "resolved": "https://registry.npmjs.org/@es-joy/jsdoccomment/-/jsdoccomment-0.40.1.tgz", @@ -964,9 +975,9 @@ } }, "node_modules/@oclif/core": { - "version": "3.0.0-beta.25", - "resolved": "https://registry.npmjs.org/@oclif/core/-/core-3.0.0-beta.25.tgz", - "integrity": "sha512-3z96nymhHD7KJIsY+6T6cHFFzgBYun9qgPXejtCv/S5q0xbSAeOelvptJPvm4IvuGAdeiwZH6IYYalKXUCn4ww==", + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/@oclif/core/-/core-3.2.1.tgz", + "integrity": "sha512-QY9csFjADbRa4RH7wcKSvIowaGI+Kc5oFCODYrKy9nj3x/RPGXG9KJ2848+9ZWJKUxv3KPHBX9CULHwvrwpVdg==", "dependencies": { "ansi-escapes": "^4.3.2", "ansi-styles": "^4.3.0", @@ -975,7 +986,7 @@ "clean-stack": "^3.0.1", "cli-progress": "^3.12.0", "debug": "^4.3.4", - "ejs": "^3.1.8", + "ejs": "^3.1.9", "get-package-type": "^0.1.0", "globby": "^11.1.0", "hyperlinker": "^1.0.0", @@ -1019,78 +1030,20 @@ } }, "node_modules/@oclif/plugin-help": { - "version": "5.2.20", - "resolved": "https://registry.npmjs.org/@oclif/plugin-help/-/plugin-help-5.2.20.tgz", - "integrity": "sha512-u+GXX/KAGL9S10LxAwNUaWdzbEBARJ92ogmM7g3gDVud2HioCmvWQCDohNRVZ9GYV9oKwZ/M8xwd6a1d95rEKQ==", - "dependencies": { - "@oclif/core": "^2.15.0" - }, - "engines": { - "node": ">=12.0.0" - } - }, - "node_modules/@oclif/plugin-help/node_modules/@oclif/core": { - "version": "2.15.0", - "resolved": "https://registry.npmjs.org/@oclif/core/-/core-2.15.0.tgz", - "integrity": "sha512-fNEMG5DzJHhYmI3MgpByTvltBOMyFcnRIUMxbiz2ai8rhaYgaTHMG3Q38HcosfIvtw9nCjxpcQtC8MN8QtVCcA==", + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/@oclif/plugin-help/-/plugin-help-6.0.2.tgz", + "integrity": "sha512-rHe19ySqU+sIA1qJYQrnB8Jh+LvdMxIN2cIQPSsMobhdOThW5R7jRpMDe9iZwO+okQmvXiP/gIx/vEnWST33HQ==", "dependencies": { - "@types/cli-progress": "^3.11.0", - "ansi-escapes": "^4.3.2", - "ansi-styles": "^4.3.0", - "cardinal": "^2.1.1", - "chalk": "^4.1.2", - "clean-stack": "^3.0.1", - "cli-progress": "^3.12.0", - "debug": "^4.3.4", - "ejs": "^3.1.8", - "get-package-type": "^0.1.0", - "globby": "^11.1.0", - "hyperlinker": "^1.0.0", - "indent-string": "^4.0.0", - "is-wsl": "^2.2.0", - "js-yaml": "^3.14.1", - "natural-orderby": "^2.0.3", - "object-treeify": "^1.1.33", - "password-prompt": "^1.1.2", - "slice-ansi": "^4.0.0", - "string-width": "^4.2.3", - "strip-ansi": "^6.0.1", - "supports-color": "^8.1.1", - "supports-hyperlinks": "^2.2.0", - "ts-node": "^10.9.1", - "tslib": "^2.5.0", - "widest-line": "^3.1.0", - "wordwrap": "^1.0.0", - "wrap-ansi": "^7.0.0" + "@oclif/core": "^3.0.9" }, "engines": { - "node": ">=14.0.0" - } - }, - "node_modules/@oclif/plugin-help/node_modules/argparse": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", - "dependencies": { - "sprintf-js": "~1.0.2" - } - }, - "node_modules/@oclif/plugin-help/node_modules/js-yaml": { - "version": "3.14.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", - "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", - "dependencies": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" - }, - "bin": { - "js-yaml": "bin/js-yaml.js" + "node": ">=18.0.0" } }, "node_modules/@oclif/plugin-plugins": { - "version": "3.8.4", - "resolved": "https://registry.npmjs.org/@oclif/plugin-plugins/-/plugin-plugins-3.8.4.tgz", - "integrity": "sha512-msar390ub3aCohh4ZsbbS/mKobmF3p/BUd3J1WQ62XE9UDbrzkhVAowf3fsmgSSYCQxMwgGokJwj24O6ZpW+6w==", + "version": "3.9.1", + "resolved": "https://registry.npmjs.org/@oclif/plugin-plugins/-/plugin-plugins-3.9.1.tgz", + "integrity": "sha512-86155GW6fQ8ZsmscffIOuvjjCCnXfuUJ/3dA+s6vqVgyGu8VshsHxnA9LCVja/Gz53j9TeaEog08IMcMDsmS7g==", "dependencies": { "@oclif/core": "^2.15.0", "chalk": "^4.1.2", @@ -11341,9 +11294,10 @@ "dependencies": { "@2bad/mimir-translator": "0.0.0", "@2bad/mimir-validator": "0.0.0", - "@oclif/core": "3.0.0-beta.25", - "@oclif/plugin-help": "5.2.20", - "@oclif/plugin-plugins": "3.8.4", + "@e965/xlsx": "0.20.0", + "@oclif/core": "3.2.1", + "@oclif/plugin-help": "6.0.2", + "@oclif/plugin-plugins": "3.9.1", "chalk": "5.3.0", "easy-table": "1.2.0" }, diff --git a/packages/cli/package.json b/packages/cli/package.json index c409867..29680bc 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -43,9 +43,10 @@ "dependencies": { "@2bad/mimir-translator": "0.0.0", "@2bad/mimir-validator": "0.0.0", - "@oclif/core": "3.0.0-beta.25", - "@oclif/plugin-help": "5.2.20", - "@oclif/plugin-plugins": "3.8.4", + "@e965/xlsx": "0.20.0", + "@oclif/core": "3.2.1", + "@oclif/plugin-help": "6.0.2", + "@oclif/plugin-plugins": "3.9.1", "chalk": "5.3.0", "easy-table": "1.2.0" }, diff --git a/packages/cli/source/commands/validate.ts b/packages/cli/source/commands/validate.ts index 7961373..d8f3dbe 100644 --- a/packages/cli/source/commands/validate.ts +++ b/packages/cli/source/commands/validate.ts @@ -18,6 +18,10 @@ export default class Validate extends Command { rules: Flags.string({ char: 'r', summary: 'This option specifies the rules to be used.' }), keys: Flags.string({ char: 'k', summary: 'This option specifies the keys to be scanned.' }), ignoreKeys: Flags.string({ char: 'i', summary: 'This option specifies the keys to be ignored.' }), + outputFile: Flags.string({ + char: 'o', + summary: 'This option specifies the name of the file where report should be saved' + }), format: Flags.string({ char: 'f', summary: 'This option specifies the output format for the console.', @@ -58,6 +62,10 @@ export default class Validate extends Command { case 'json': this.log(format.json(report)) break + case 'xlsx': + format.xlsx(report, flags.outputFile) + this.log() + break case 'compact': this.log(format.compact(report, flags.path)) break diff --git a/packages/cli/source/formatters/format.ts b/packages/cli/source/formatters/format.ts index 707004f..1ac08fa 100644 --- a/packages/cli/source/formatters/format.ts +++ b/packages/cli/source/formatters/format.ts @@ -2,3 +2,4 @@ export { compact } from '~/formatters/compact.js' export { json } from '~/formatters/json.js' export { stylish } from '~/formatters/stylish.js' +export { xlsx } from '~/formatters/xlsx.js' diff --git a/packages/cli/source/formatters/xlsx.ts b/packages/cli/source/formatters/xlsx.ts new file mode 100644 index 0000000..1c1eddc --- /dev/null +++ b/packages/cli/source/formatters/xlsx.ts @@ -0,0 +1,18 @@ +import { type Problem } from '@2bad/mimir-validator' +import { utils, writeFile } from '@e965/xlsx' +import { resolve } from 'node:path' + +/** + * + * @param data + * @param report + * @param filePath + */ +export const xlsx = (report: Problem[], filePath = './report.xlsx'): void => { + const worksheet = utils.json_to_sheet(report) + + const workbook = utils.book_new() + utils.book_append_sheet(workbook, worksheet, 'Translations') + + writeFile(workbook, resolve(filePath)) +}