fix(providence): add entries for debugging
This commit is contained in:
parent
6a614dda23
commit
0e678deccb
5 changed files with 19 additions and 0 deletions
5
.changeset/dull-geckos-fail.md
Normal file
5
.changeset/dull-geckos-fail.md
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'providence-analytics': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Enable debug logs in analyzers
|
||||||
|
|
@ -5,6 +5,7 @@ const { Analyzer } = require('./helpers/Analyzer.js');
|
||||||
const { trackDownIdentifier } = require('./helpers/track-down-identifier.js');
|
const { trackDownIdentifier } = require('./helpers/track-down-identifier.js');
|
||||||
const { normalizeSourcePaths } = require('./helpers/normalize-source-paths.js');
|
const { normalizeSourcePaths } = require('./helpers/normalize-source-paths.js');
|
||||||
const { aForEach } = require('../utils/async-array-utils.js');
|
const { aForEach } = require('../utils/async-array-utils.js');
|
||||||
|
const { LogService } = require('../services/LogService.js');
|
||||||
|
|
||||||
/** @typedef {import('./helpers/track-down-identifier.js').RootFile} RootFile */
|
/** @typedef {import('./helpers/track-down-identifier.js').RootFile} RootFile */
|
||||||
|
|
||||||
|
|
@ -136,6 +137,8 @@ function getLocalNameSpecifiers(node) {
|
||||||
* @param {FindExportsConfig} config
|
* @param {FindExportsConfig} config
|
||||||
*/
|
*/
|
||||||
function findExportsPerAstEntry(ast, { skipFileImports }) {
|
function findExportsPerAstEntry(ast, { skipFileImports }) {
|
||||||
|
LogService.debug(`Analyzer "find-exports": started findExportsPerAstEntry method`);
|
||||||
|
|
||||||
// Visit AST...
|
// Visit AST...
|
||||||
const transformedEntry = [];
|
const transformedEntry = [];
|
||||||
// Unfortunately, we cannot have async functions in babel traverse.
|
// Unfortunately, we cannot have async functions in babel traverse.
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ const { default: traverse } = require('@babel/traverse');
|
||||||
const { isRelativeSourcePath } = require('../utils/relative-source-path.js');
|
const { isRelativeSourcePath } = require('../utils/relative-source-path.js');
|
||||||
const { normalizeSourcePaths } = require('./helpers/normalize-source-paths.js');
|
const { normalizeSourcePaths } = require('./helpers/normalize-source-paths.js');
|
||||||
const { Analyzer } = require('./helpers/Analyzer.js');
|
const { Analyzer } = require('./helpers/Analyzer.js');
|
||||||
|
const { LogService } = require('../services/LogService.js');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Options that allow to filter 'on a file basis'.
|
* Options that allow to filter 'on a file basis'.
|
||||||
|
|
@ -45,6 +46,8 @@ function getImportOrReexportsSpecifiers(node) {
|
||||||
* @param {string} context.relativePath the file being currently processed
|
* @param {string} context.relativePath the file being currently processed
|
||||||
*/
|
*/
|
||||||
function findImportsPerAstEntry(ast) {
|
function findImportsPerAstEntry(ast) {
|
||||||
|
LogService.debug(`Analyzer "find-imports": started findImportsPerAstEntry method`);
|
||||||
|
|
||||||
// Visit AST...
|
// Visit AST...
|
||||||
const transformedEntry = [];
|
const transformedEntry = [];
|
||||||
traverse(ast, {
|
traverse(ast, {
|
||||||
|
|
|
||||||
|
|
@ -180,6 +180,7 @@ class Analyzer {
|
||||||
* @returns {CachedAnalyzerResult|undefined}
|
* @returns {CachedAnalyzerResult|undefined}
|
||||||
*/
|
*/
|
||||||
_prepare(cfg) {
|
_prepare(cfg) {
|
||||||
|
LogService.debug(`Analyzer "${this.name}": started _prepare method`);
|
||||||
this.constructor.__unwindProvidedResults(cfg);
|
this.constructor.__unwindProvidedResults(cfg);
|
||||||
|
|
||||||
if (!cfg.targetProjectResult) {
|
if (!cfg.targetProjectResult) {
|
||||||
|
|
@ -264,6 +265,8 @@ class Analyzer {
|
||||||
* @returns {AnalyzerResult}
|
* @returns {AnalyzerResult}
|
||||||
*/
|
*/
|
||||||
_finalize(queryOutput, cfg) {
|
_finalize(queryOutput, cfg) {
|
||||||
|
LogService.debug(`Analyzer "${this.name}": started _finalize method`);
|
||||||
|
|
||||||
const analyzerResult = ensureAnalyzerResultFormat(queryOutput, cfg, this);
|
const analyzerResult = ensureAnalyzerResultFormat(queryOutput, cfg, this);
|
||||||
LogService.success(`finished ${LogService.pad(this.name, 16)} for ${this.identifier}`);
|
LogService.success(`finished ${LogService.pad(this.name, 16)} for ${this.identifier}`);
|
||||||
return analyzerResult;
|
return analyzerResult;
|
||||||
|
|
@ -273,6 +276,8 @@ class Analyzer {
|
||||||
* @param {function} traverseEntry
|
* @param {function} traverseEntry
|
||||||
*/
|
*/
|
||||||
async _traverse(traverseEntry) {
|
async _traverse(traverseEntry) {
|
||||||
|
LogService.debug(`Analyzer "${this.name}": started _traverse method`);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create ASTs for our inputData
|
* Create ASTs for our inputData
|
||||||
*/
|
*/
|
||||||
|
|
@ -281,6 +286,8 @@ class Analyzer {
|
||||||
}
|
}
|
||||||
|
|
||||||
async execute(customConfig = {}) {
|
async execute(customConfig = {}) {
|
||||||
|
LogService.debug(`Analyzer "${this.name}": started execute method`);
|
||||||
|
|
||||||
const cfg = {
|
const cfg = {
|
||||||
targetProjectPath: null,
|
targetProjectPath: null,
|
||||||
referenceProjectPath: null,
|
referenceProjectPath: null,
|
||||||
|
|
|
||||||
|
|
@ -176,6 +176,7 @@ class QueryService {
|
||||||
* @returns {QueryResult}
|
* @returns {QueryResult}
|
||||||
*/
|
*/
|
||||||
static async astSearch(queryConfig, customConfig) {
|
static async astSearch(queryConfig, customConfig) {
|
||||||
|
LogService.debug('started astSearch method');
|
||||||
if (queryConfig.type !== 'analyzer') {
|
if (queryConfig.type !== 'analyzer') {
|
||||||
LogService.error('Only analyzers supported for ast searches at the moment');
|
LogService.error('Only analyzers supported for ast searches at the moment');
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue