Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 10 additions & 16 deletions src/commands/tsgen.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -170,6 +170,7 @@
token: config.token,
environment: config.environment,
namespace: namespace,
logger: log,
};

// Add region or host based on whether it's a custom region
Expand Down Expand Up @@ -207,6 +208,7 @@
systemFields: includeSystemFields,
isEditableTags: includeEditableTags,
includeReferencedEntry,
logger: log,

Check failure on line 211 in src/commands/tsgen.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Object literal may only specify known properties, and 'logger' does not exist in type 'GenerateTSBase'.

Check failure on line 211 in src/commands/tsgen.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Object literal may only specify known properties, and 'logger' does not exist in type 'GenerateTSBase'.
});

fs.writeFileSync(outputPath, result || "");
Expand All @@ -219,24 +221,16 @@
"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}'.`)
Expand Down
23 changes: 6 additions & 17 deletions src/lib/helper.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cliux } from "@contentstack/cli-utilities";
import { log } from "@contentstack/cli-utilities";

export const sanitizePath = (str: string) => {
return str
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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()}`);
};
Loading