Skip to content

Commit

Permalink
fix: include provider info in cdktf debug
Browse files Browse the repository at this point in the history
  • Loading branch information
Maed223 committed Oct 15, 2023
1 parent fe8c11c commit ee92c9b
Showing 1 changed file with 23 additions and 43 deletions.
66 changes: 23 additions & 43 deletions packages/cdktf-cli/src/bin/cmds/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export async function deploy(argv: any) {

let outputsPath: string | undefined = undefined;
// eslint-disable-next-line @typescript-eslint/no-empty-function
let onOutputsRetrieved: (outputs: NestedTerraformOutputs) => void = () => { };
let onOutputsRetrieved: (outputs: NestedTerraformOutputs) => void = () => {};

if (argv.outputsFile) {
outputsPath = normalizeOutputPath(argv.outputsFile);
Expand Down Expand Up @@ -293,7 +293,7 @@ export async function get(argv: {
}) {
const printPerformanceInfo = argv.showPerformanceInfo
? startPerformanceMonitoring()
: () => { }; // eslint-disable-line @typescript-eslint/no-empty-function
: () => {}; // eslint-disable-line @typescript-eslint/no-empty-function

try {
throwIfNotProjectDirectory();
Expand Down Expand Up @@ -425,7 +425,7 @@ export async function login(argv: { tfeHostname: string }) {
export async function synth(argv: any) {
const printPerformanceInfo = argv.showPerformanceInfo
? startPerformanceMonitoring()
: () => { }; // eslint-disable-line @typescript-eslint/no-empty-function
: () => {}; // eslint-disable-line @typescript-eslint/no-empty-function

try {
await initializErrorReporting(askForCrashReportingConsent);
Expand Down Expand Up @@ -499,7 +499,7 @@ export async function output(argv: any) {
const skipSynth = argv.skipSynth;
let outputsPath: string | undefined = undefined;
// eslint-disable-next-line @typescript-eslint/no-empty-function
let onOutputsRetrieved: (outputs: NestedTerraformOutputs) => void = () => { };
let onOutputsRetrieved: (outputs: NestedTerraformOutputs) => void = () => {};

if (argv.outputsFile) {
outputsPath = normalizeOutputPath(argv.outputsFile);
Expand All @@ -522,44 +522,24 @@ export async function output(argv: any) {
export async function debug(argv: any) {
const jsonOutput = argv.json;
const debugOutput = await collectDebugInformation();
const allProviders = await getProviders();
if (jsonOutput) {
console.log(JSON.stringify({
...debugOutput,
providers: allProviders
}, null, 2))
console.log(
JSON.stringify(
{
...debugOutput,
providers: await providerList({ internal: true }),
},
null,
2
)
);
} else {
console.log(chalkColour`{bold {greenBright cdktf debug}}`);

Object.entries(debugOutput).forEach(([key, value]) => {
console.log(`${key}: ${value === null ? "null" : value}`);
});

//TODO: how to integrate this in well
console.log(
chalkColour`{bold {yellowBright provider versions}}`
)
const data = []
for (const provider of allProviders.local) {
data.push({
"Provider Name": provider.providerName || "",
"Provider Version": provider.providerVersion || "",
CDKTF: "",
Constraint: provider.providerConstraint || "",
"Package Name": "",
"Package Version": "",
});
}
for (const provider of allProviders.prebuilt) {
data.push({
"Provider Name": provider.providerName || "",
"Provider Version": provider.providerVersion || "",
CDKTF: provider.cdktfVersion || "",
Constraint: "",
"Package Name": provider.packageName || "",
"Package Version": provider.packageVersion || "",
});
}
providerList({});
}
}

Expand Down Expand Up @@ -623,7 +603,8 @@ export async function providerUpgrade(argv: any) {
if (constraintsToUpdate.length > 0) {
const singular = constraintsToUpdate.length === 1;
console.log(
`${constraintsToUpdate.length} local provider${singular ? " has" : "s have"
`${constraintsToUpdate.length} local provider${
singular ? " has" : "s have"
} been updated. Running cdktf get to update...`
);

Expand Down Expand Up @@ -652,7 +633,7 @@ export async function providerUpgrade(argv: any) {
}
}

async function getProviders() {
export async function providerList(argv: any) {
const config = CdktfConfig.read();
const language = config.language;
const cdktfVersion = await getPackageVersion(language, "cdktf");
Expand All @@ -666,17 +647,15 @@ async function getProviders() {
cdktfVersion,
config.projectDirectory
);
console.log("hits here")
return await manager.allProviders();
}

export async function providerList(argv: any) {
const allProviders = await getProviders();
const allProviders = await manager.allProviders();

if (argv.json) {
console.log(JSON.stringify(allProviders));
return;
}
if (argv.internal) {
return allProviders;
}
const data = [];
for (const provider of allProviders.local) {
data.push({
Expand All @@ -699,4 +678,5 @@ export async function providerList(argv: any) {
});
}
renderInk(React.createElement(ProviderListTable, { data }));
return;
}

0 comments on commit ee92c9b

Please sign in to comment.