From 7471f8cc7ea7844979eb52bad1cde9dd2a6a3c9f Mon Sep 17 00:00:00 2001 From: Thijs Louisse Date: Mon, 10 Aug 2020 19:25:15 +0200 Subject: [PATCH] fix(providence-analytics): clean output extend-docs --- .changeset/clever-trains-remember.md | 14 +++++++++++--- .../providence-analytics/src/cli/cli-helpers.js | 1 + .../src/cli/generate-extend-docs-data.js | 7 +++++-- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/.changeset/clever-trains-remember.md b/.changeset/clever-trains-remember.md index 3c4861fad..ac4c322e2 100644 --- a/.changeset/clever-trains-remember.md +++ b/.changeset/clever-trains-remember.md @@ -2,6 +2,14 @@ 'providence-analytics': minor --- -Allowlist mode: autodetects whether analyzed repository is a "git" or "npm" (published artifact) repository. -Via the cli `--allowlist-mode 'npm|git|all'` and `--allowlist-mode-reference 'npm|git|all'` can be -configured to override the autodetected mode. +Allowlist modes + +#### Features + +- Allowlist mode: autodetects whether analyzed repository is a "git" or "npm" (published artifact) repository. + Via the cli `--allowlist-mode 'npm|git|all'` and `--allowlist-mode-reference 'npm|git|all'` can be + configured to override the autodetected mode. + +#### Bugfixes + +- Clean output extend-docs: strings like '[no-dependency]' will not end up in aggregated result diff --git a/packages/providence-analytics/src/cli/cli-helpers.js b/packages/providence-analytics/src/cli/cli-helpers.js index ef868d9e7..391a97022 100644 --- a/packages/providence-analytics/src/cli/cli-helpers.js +++ b/packages/providence-analytics/src/cli/cli-helpers.js @@ -178,4 +178,5 @@ module.exports = { spawnProcess, installDeps, pathsArrayFromCollectionName, + flatten, }; diff --git a/packages/providence-analytics/src/cli/generate-extend-docs-data.js b/packages/providence-analytics/src/cli/generate-extend-docs-data.js index e2234508e..39279fdaa 100644 --- a/packages/providence-analytics/src/cli/generate-extend-docs-data.js +++ b/packages/providence-analytics/src/cli/generate-extend-docs-data.js @@ -5,6 +5,7 @@ const { performance } = require('perf_hooks'); const { providence } = require('../program/providence.js'); const { QueryService } = require('../program/services/QueryService.js'); const { LogService } = require('../program/services/LogService.js'); +const { flatten } = require('./cli-helpers.js'); async function launchProvidenceWithExtendDocs({ referenceProjectPaths, @@ -35,11 +36,13 @@ async function launchProvidenceWithExtendDocs({ ); const outputFilePath = pathLib.join(outputFolder, 'providence-extend-docs-data.json'); - const queryOutputs = results.map(result => result.queryOutput).flat(); + const queryOutputs = flatten( + results.map(result => result.queryOutput).filter(o => typeof o !== 'string'), // filter out '[no-dependency]' etc. + ); if (fs.existsSync(outputFilePath)) { fs.unlinkSync(outputFilePath); } - fs.writeFile(outputFilePath, JSON.stringify(queryOutputs), err => { + fs.writeFile(outputFilePath, JSON.stringify(queryOutputs, null, 2), err => { if (err) { throw err; }