feat(providence): do not throw on unparseable files, but allow to proceed run for rest of projects
This commit is contained in:
parent
244bdf7f53
commit
7f6eb15a21
4 changed files with 28 additions and 6 deletions
5
.changeset/big-gifts-reflect copy 2.md
Normal file
5
.changeset/big-gifts-reflect copy 2.md
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'providence-analytics': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
feat: allow to resolve outside node_modules as well
|
||||||
5
.changeset/big-gifts-reflect copy 3.md
Normal file
5
.changeset/big-gifts-reflect copy 3.md
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'providence-analytics': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
feat: do not throw on unparseable files, but allow to proceed run for rest of projects
|
||||||
5
.changeset/big-gifts-reflect copy.md
Normal file
5
.changeset/big-gifts-reflect copy.md
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'providence-analytics': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: swc-traverse does not fail on object proto builtins like "toString"
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/* eslint-disable no-param-reassign */
|
/* eslint-disable no-param-reassign */
|
||||||
import semver from 'semver';
|
import semver from 'semver';
|
||||||
import pathLib from 'path';
|
import path from 'path';
|
||||||
import { LogService } from './LogService.js';
|
import { LogService } from './LogService.js';
|
||||||
import { QueryService } from './QueryService.js';
|
import { QueryService } from './QueryService.js';
|
||||||
import { ReportService } from './ReportService.js';
|
import { ReportService } from './ReportService.js';
|
||||||
|
|
@ -33,9 +33,17 @@ async function analyzePerAstFile(projectData, astAnalysis, analyzerCfg) {
|
||||||
for (const { file, ast, context: astContext } of projectData.entries) {
|
for (const { file, ast, context: astContext } of projectData.entries) {
|
||||||
const relativePath = getFilePathRelativeFromRoot(file, projectData.project.path);
|
const relativePath = getFilePathRelativeFromRoot(file, projectData.project.path);
|
||||||
const context = { code: astContext.code, relativePath, projectData, analyzerCfg };
|
const context = { code: astContext.code, relativePath, projectData, analyzerCfg };
|
||||||
LogService.debug(`${pathLib.resolve(projectData.project.path, file)}`);
|
|
||||||
|
const fullPath = path.resolve(projectData.project.path, file);
|
||||||
|
LogService.debug(`[analyzePerAstFile]: ${fullPath}`);
|
||||||
|
|
||||||
|
// We do a try and catch here, so that unparseable files do not block all metrics we're gathering in a run
|
||||||
|
try {
|
||||||
const { result, meta } = await astAnalysis(ast, context);
|
const { result, meta } = await astAnalysis(ast, context);
|
||||||
entries.push({ file: relativePath, meta, result });
|
entries.push({ file: relativePath, meta, result });
|
||||||
|
} catch (e) {
|
||||||
|
LogService.error(`[analyzePerAstFile]: ${fullPath} throws: ${e}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
const filteredEntries = entries.filter(({ result }) => Boolean(result.length));
|
const filteredEntries = entries.filter(({ result }) => Boolean(result.length));
|
||||||
return filteredEntries;
|
return filteredEntries;
|
||||||
|
|
@ -137,15 +145,14 @@ const checkForMatchCompatibility = (
|
||||||
/** @type {PathFromSystemRoot} */ referencePath,
|
/** @type {PathFromSystemRoot} */ referencePath,
|
||||||
/** @type {PathFromSystemRoot} */ targetPath,
|
/** @type {PathFromSystemRoot} */ targetPath,
|
||||||
) => {
|
) => {
|
||||||
// const refFile = pathLib.resolve(referencePath, 'package.json');
|
|
||||||
const referencePkg = InputDataService.getPackageJson(referencePath);
|
const referencePkg = InputDataService.getPackageJson(referencePath);
|
||||||
// const targetFile = pathLib.resolve(targetPath, 'package.json');
|
|
||||||
const targetPkg = InputDataService.getPackageJson(targetPath);
|
const targetPkg = InputDataService.getPackageJson(targetPath);
|
||||||
|
|
||||||
const allTargetDeps = [
|
const allTargetDeps = [
|
||||||
...Object.entries(targetPkg?.devDependencies || {}),
|
...Object.entries(targetPkg?.devDependencies || {}),
|
||||||
...Object.entries(targetPkg?.dependencies || {}),
|
...Object.entries(targetPkg?.dependencies || {}),
|
||||||
];
|
];
|
||||||
|
|
||||||
const importEntry = allTargetDeps.find(([name]) => referencePkg?.name === name);
|
const importEntry = allTargetDeps.find(([name]) => referencePkg?.name === name);
|
||||||
if (!importEntry) {
|
if (!importEntry) {
|
||||||
return { compatible: false, reason: 'no-dependency' };
|
return { compatible: false, reason: 'no-dependency' };
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue