cli: repo lint fixes

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2024-10-09 12:26:42 +02:00
parent 97f6320d15
commit 88407c3e79
4 changed files with 23 additions and 6 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/cli': patch
---
Running `repo lint` with the `--successCache` flag now respects `.gitinore`, and it ignores projects without a `lint` script.
+1
View File
@@ -109,6 +109,7 @@
"git-url-parse": "^15.0.0",
"glob": "^7.1.7",
"global-agent": "^3.0.0",
"globby": "^11.1.0",
"handlebars": "^4.7.3",
"html-webpack-plugin": "^5.3.1",
"inquirer": "^8.2.0",
+16 -6
View File
@@ -117,7 +117,7 @@ export async function command(opts: OptionValues, cmd: Command): Promise<void> {
cacheContext.lockfile.getDependencyTreeHash(pkg.packageJson.name),
);
hash.update('\0');
hash.update(JSON.stringify(lintOptions));
hash.update(JSON.stringify(lintOptions ?? {}));
hash.update('\0');
hash.update(process.version); // Node.js version
hash.update('\0');
@@ -131,18 +131,24 @@ export async function command(opts: OptionValues, cmd: Command): Promise<void> {
);
const resultsList = await runWorkerQueueThreads({
items,
items: items.filter(item => item.lintOptions), // Filter out packages without lint script
workerData: {
fix: Boolean(opts.fix),
format: opts.format as string | undefined,
shouldCache: Boolean(cacheContext),
successCache: cacheContext?.cache,
rootDir: paths.targetRoot,
},
workerFactory: async ({ fix, format, shouldCache, successCache }) => {
workerFactory: async ({
fix,
format,
shouldCache,
successCache,
rootDir,
}) => {
const { ESLint } = require('eslint') as typeof import('eslint');
const crypto = require('crypto') as typeof import('crypto');
const recursiveReadDir =
require('recursive-readdir') as typeof import('recursive-readdir');
const globby = require('globby') as typeof import('globby');
const { readFile } =
require('fs/promises') as typeof import('fs/promises');
const { relative: workerRelativePath } =
@@ -172,7 +178,11 @@ export async function command(opts: OptionValues, cmd: Command): Promise<void> {
let sha: string | undefined = undefined;
if (shouldCache) {
const result = await recursiveReadDir(fullDir);
const result = await globby(relativeDir, {
gitignore: true,
onlyFiles: true,
cwd: rootDir,
});
const hash = crypto.createHash('sha1');
hash.update(parentHash!);
+1
View File
@@ -3991,6 +3991,7 @@ __metadata:
git-url-parse: ^15.0.0
glob: ^7.1.7
global-agent: ^3.0.0
globby: ^11.1.0
handlebars: ^4.7.3
html-webpack-plugin: ^5.3.1
inquirer: ^8.2.0