Fix prettier existence checks and import order
Use fs.pathExists instead of checking resolved path strings which are always truthy. Fix import ordering in e2e-test runCommand.ts. Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com> Co-authored-by: Cursor <cursoragent@cursor.com> Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com> Co-authored-by: Cursor <cursoragent@cursor.com> Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com> Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/repo-tools': patch
|
||||
---
|
||||
|
||||
Fixed prettier existence checks in OpenAPI commands to use `fs.pathExists` instead of checking the resolved path string, which was always truthy.
|
||||
@@ -27,11 +27,11 @@ import { waitFor, print } from '../lib/helpers';
|
||||
import mysql from 'mysql2/promise';
|
||||
import pgtools from 'pgtools';
|
||||
|
||||
import { OptionValues } from 'commander';
|
||||
import { findOwnPaths, runOutput, run } from '@backstage/cli-common';
|
||||
|
||||
/* eslint-disable-next-line no-restricted-syntax */
|
||||
const ownPaths = findOwnPaths(__dirname);
|
||||
import { OptionValues } from 'commander';
|
||||
|
||||
const templatePackagePaths = [
|
||||
'packages/cli/templates/frontend-plugin/package.json.hbs',
|
||||
|
||||
@@ -87,7 +87,7 @@ async function generate(
|
||||
|
||||
await fs.writeFile(
|
||||
resolve(parentDirectory, 'index.ts'),
|
||||
`//
|
||||
`//
|
||||
export * from './generated';`,
|
||||
);
|
||||
|
||||
@@ -96,7 +96,7 @@ async function generate(
|
||||
});
|
||||
|
||||
const prettier = targetPaths.resolveRoot('node_modules/.bin/prettier');
|
||||
if (prettier) {
|
||||
if (await fs.pathExists(prettier)) {
|
||||
await exec(`${prettier} --write ${parentDirectory}`, [], {
|
||||
signal: abortSignal?.signal,
|
||||
});
|
||||
|
||||
@@ -77,7 +77,9 @@ export const createOpenApiRouter = async (
|
||||
);
|
||||
|
||||
await exec(`yarn backstage-cli package lint`, ['--fix', tsPath, indexFile]);
|
||||
if (await targetPaths.resolveRoot('node_modules/.bin/prettier')) {
|
||||
if (
|
||||
await fs.pathExists(targetPaths.resolveRoot('node_modules/.bin/prettier'))
|
||||
) {
|
||||
await exec(`yarn prettier`, ['--write', tsPath, indexFile], {
|
||||
cwd: targetPaths.rootDir,
|
||||
});
|
||||
|
||||
@@ -61,10 +61,12 @@ capture:
|
||||
# 🔧 Specify a command that will generate traffic
|
||||
command: yarn backstage-cli package test --no-watch ${ROUTER_TEST_PATHS.map(
|
||||
e => `"${e}"`,
|
||||
).join(' ')}
|
||||
).join(' ')}
|
||||
`,
|
||||
);
|
||||
if (await targetPaths.resolveRoot('node_modules/.bin/prettier')) {
|
||||
if (
|
||||
await fs.pathExists(targetPaths.resolveRoot('node_modules/.bin/prettier'))
|
||||
) {
|
||||
await exec(`yarn prettier`, ['--write', opticConfigFilePath]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +82,9 @@ async function test(
|
||||
throw err;
|
||||
}
|
||||
if (
|
||||
(await targetPaths.resolveRoot('node_modules/.bin/prettier')) &&
|
||||
(await fs.pathExists(
|
||||
targetPaths.resolveRoot('node_modules/.bin/prettier'),
|
||||
)) &&
|
||||
options?.update
|
||||
) {
|
||||
await exec(`yarn prettier`, ['--write', openapiPath]);
|
||||
|
||||
Reference in New Issue
Block a user