From 14998303af9e38fef875e4edb4a3f8f1023829ec Mon Sep 17 00:00:00 2001 From: Pedro Ramos Date: Wed, 5 Jun 2024 15:44:37 +0200 Subject: [PATCH] feat: add metadata for some remaining commands (#1431) Co-authored-by: asyncapi-bot --- src/commands/config/analytics.ts | 3 +++ src/commands/diff.ts | 6 ++++++ src/commands/new/glee.ts | 4 ++++ src/commands/start/studio.ts | 3 +++ 4 files changed, 16 insertions(+) diff --git a/src/commands/config/analytics.ts b/src/commands/config/analytics.ts index d3e74db19eb..7fcb70292a5 100644 --- a/src/commands/config/analytics.ts +++ b/src/commands/config/analytics.ts @@ -26,9 +26,11 @@ export default class Analytics extends Command { if (flags.disable) { analyticsConfigFileContent.analyticsEnabled = 'false'; this.log('\nAnalytics disabled.\n'); + this.metricsMetadata.analytics_disabled = flags.disable; } else if (flags.enable) { analyticsConfigFileContent.analyticsEnabled = 'true'; this.log('\nAnalytics enabled.\n'); + this.metricsMetadata.analytics_enabled = flags.enable; } else if (!flags.status) { this.log('\nPlease append the "--disable" flag to the command in case you prefer to disable analytics, or use the "--enable" flag if you want to enable analytics back again. In case you do not know the analytics current status, then you can append the "--status" flag to be aware of it.\n'); return; @@ -41,6 +43,7 @@ export default class Analytics extends Command { } else { this.log('\nAnalytics are disabled. Please append the "--enable" flag to the command in case you prefer to enable analytics.\n'); } + this.metricsMetadata.analytics_status_checked = flags.status; } } catch (e: any) { switch (e.code) { diff --git a/src/commands/diff.ts b/src/commands/diff.ts index 009e00911e9..078825f56cb 100644 --- a/src/commands/diff.ts +++ b/src/commands/diff.ts @@ -76,6 +76,12 @@ export default class Diff extends Command { checkAndWarnFalseFlag(outputFormat, markdownSubtype); markdownSubtype = setDefaultMarkdownSubtype(outputFormat, markdownSubtype) as string; + this.metricsMetadata.output_format = outputFormat; + this.metricsMetadata.output_type = outputType; + if (outputFormat === 'md') { + this.metricsMetadata.output_markdown_subtype = flags['markdownSubtype']; + } + try { firstDocument = await load(firstDocumentPath); diff --git a/src/commands/new/glee.ts b/src/commands/new/glee.ts index f717ac7ced6..107fb55e631 100644 --- a/src/commands/new/glee.ts +++ b/src/commands/new/glee.ts @@ -213,6 +213,8 @@ export default class NewGlee extends Command { projectName, forceWrite ); + this.specFile = await load(flags.file); + this.metricsMetadata.template = flags.template; } else { try { await fPromises.mkdir(PROJECT_DIRECTORY); @@ -258,6 +260,8 @@ export default class NewGlee extends Command { `Unable to create the project. Please check the following message for further info about the error:\n\n${err}` ); } + this.specFile = await load(`${GLEE_TEMPLATES_DIRECTORY}/asyncapi.yaml`); + this.metricsMetadata.template = flags.template; } } } diff --git a/src/commands/start/studio.ts b/src/commands/start/studio.ts index 72865b403f8..1c459f06195 100644 --- a/src/commands/start/studio.ts +++ b/src/commands/start/studio.ts @@ -16,6 +16,9 @@ export default class StartStudio extends Command { const { flags } = await this.parse(StartStudio); const filePath = flags.file || (await load()).getFilePath(); const port = flags.port; + + this.specFile = await load(filePath); + this.metricsMetadata.port = port; startStudio(filePath as string, port); }