From ee92c9bc19e333185bc522e94c035e9261b528fe Mon Sep 17 00:00:00 2001 From: Mark DeCrane Date: Sun, 15 Oct 2023 17:42:09 -0400 Subject: [PATCH] fix: include provider info in cdktf debug --- packages/cdktf-cli/src/bin/cmds/handlers.ts | 66 +++++++-------------- 1 file changed, 23 insertions(+), 43 deletions(-) diff --git a/packages/cdktf-cli/src/bin/cmds/handlers.ts b/packages/cdktf-cli/src/bin/cmds/handlers.ts index f9cf445f05..4428e0e6d7 100644 --- a/packages/cdktf-cli/src/bin/cmds/handlers.ts +++ b/packages/cdktf-cli/src/bin/cmds/handlers.ts @@ -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); @@ -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(); @@ -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); @@ -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); @@ -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({}); } } @@ -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...` ); @@ -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"); @@ -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({ @@ -699,4 +678,5 @@ export async function providerList(argv: any) { }); } renderInk(React.createElement(ProviderListTable, { data })); + return; }