diff --git a/.talismanrc b/.talismanrc index 909fefc..e978e98 100644 --- a/.talismanrc +++ b/.talismanrc @@ -7,7 +7,7 @@ fileignoreconfig: - filename: src/commands/tsgen.ts checksum: 5817a6320d368fb82354709962cdb9d357c6dcba870ba53bf21eade9708505ba - filename: package-lock.json - checksum: dd92a547e2cd5cfa522f5a27b0946c0686d144fb50f058f9e05c0f7125f70574 + checksum: 1fb8fa608b49d45308537a8e296caaa0b87e94ef5cdd3f5435fffed67bdc3353 - filename: src/lib/helper.ts checksum: f71633c99463fdf8da3708f4fe8736bcb9ad32595e4977af5ebab5af4b496395 version: "1.0" diff --git a/package-lock.json b/package-lock.json index 9575faf..b988837 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,8 +9,8 @@ "version": "4.7.0", "license": "MIT", "dependencies": { - "@contentstack/cli-command": "^1.5.0", - "@contentstack/cli-utilities": "^1.11.0", + "@contentstack/cli-command": "^1.6.1", + "@contentstack/cli-utilities": "^1.14.4", "@contentstack/types-generator": "^3.8.0", "dotenv": "^16.6.1" }, diff --git a/package.json b/package.json index 22343af..2d4e074 100644 --- a/package.json +++ b/package.json @@ -5,8 +5,8 @@ "author": "Michael Davis", "bugs": "https://github.com/Contentstack-Solutions/contentstack-cli-tsgen/issues", "dependencies": { - "@contentstack/cli-command": "^1.5.0", - "@contentstack/cli-utilities": "^1.11.0", + "@contentstack/cli-command": "^1.6.1", + "@contentstack/cli-utilities": "^1.14.4", "@contentstack/types-generator": "^3.8.0", "dotenv": "^16.6.1" }, diff --git a/src/commands/tsgen.ts b/src/commands/tsgen.ts index 34b04c2..fc14f90 100644 --- a/src/commands/tsgen.ts +++ b/src/commands/tsgen.ts @@ -1,5 +1,5 @@ import { Command } from "@contentstack/cli-command"; -import { flags, FlagInput } from "@contentstack/cli-utilities"; +import { flags, FlagInput, log } from "@contentstack/cli-utilities"; import * as path from "path"; import * as fs from "fs"; import { cliux } from "@contentstack/cli-utilities"; @@ -170,6 +170,7 @@ export default class TypeScriptCodeGeneratorCommand extends Command { token: config.token, environment: config.environment, namespace: namespace, + logger: log, }; // Add region or host based on whether it's a custom region @@ -207,6 +208,7 @@ export default class TypeScriptCodeGeneratorCommand extends Command { systemFields: includeSystemFields, isEditableTags: includeEditableTags, includeReferencedEntry, + logger: log, }); fs.writeFileSync(outputPath, result || ""); @@ -219,24 +221,16 @@ export default class TypeScriptCodeGeneratorCommand extends Command { "Generation completed successfully with partial schema", ) ) { - cliux.print("", {}); - cliux.print( - "Type generation completed successfully with partial schema!", - { color: "green", bold: true }, + cliux.print(""); + log.success("Type generation completed successfully with partial schema!"); + log.warn( + "Some content types were skipped due to validation issues, but types were generated for valid content types." ); - cliux.print( - "Some content types were skipped due to validation issues, but types were generated for valid content types.", - { color: "yellow" }, - ); - cliux.print( - "Check the output above for details on what was skipped and suggestions for fixing issues.", - { color: "cyan" }, + log.info( + "Check the output above for details on what was skipped and suggestions for fixing issues." ); } else { - cliux.print( - `Successfully added the Content Types to '${outputPath}'.`, - { color: "green" }, - ); + log.success(`Successfully added the Content Types to '${outputPath}'.`); } // this.log(`Wrote ${outputPath} Content Types to '${result.outputPath}'.`) diff --git a/src/lib/helper.ts b/src/lib/helper.ts index bb02d2d..5ea7a7a 100644 --- a/src/lib/helper.ts +++ b/src/lib/helper.ts @@ -1,4 +1,4 @@ -import { cliux } from "@contentstack/cli-utilities"; +import { log } from "@contentstack/cli-utilities"; export const sanitizePath = (str: string) => { return str @@ -32,10 +32,7 @@ export const printFormattedError = (error: FormattedError, context: string) => { error.error_message.includes("numeric identifiers") ) { // Just print our detailed message as-is, no extra formatting - cliux.print(error.error_message, { - color: "red", - bold: true, - }); + log.error(error.error_message); return; } @@ -83,20 +80,12 @@ export const printFormattedError = (error: FormattedError, context: string) => { } // Print formatted error output - cliux.print(`Type generation failed: ${errorMessage}`, { - color: "red", - bold: true, - }); + log.error(`Type generation failed: ${errorMessage}`); if (hint) { - cliux.print(`Tip: ${hint}`, { color: "yellow" }); + log.warn(`Tip: ${hint}`); } - cliux.print(`Error context: ${context}`, { - color: "cyan", - }); - - cliux.print(`Timestamp: ${error?.timestamp || new Date().toISOString()}`, { - color: "gray", - }); + log.info(`Error context: ${context}`); + log.info(`Timestamp: ${error?.timestamp || new Date().toISOString()}`); };