Resolve config paths early for backend builds
Signed-off-by: Axel Hecht <axel@pike.org>
This commit is contained in:
@@ -1,5 +0,0 @@
|
||||
---
|
||||
'@backstage/cli': patch
|
||||
---
|
||||
|
||||
Resolve config options against both the current directory and the monorepo root directory.
|
||||
@@ -18,6 +18,7 @@ import os from 'os';
|
||||
import fs from 'fs-extra';
|
||||
import { resolve as resolvePath } from 'path';
|
||||
import tar, { CreateOptions } from 'tar';
|
||||
import { paths } from '../../lib/paths';
|
||||
import { createDistWorkspace } from '../../lib/packager';
|
||||
import { getEnvironmentParallelism } from '../../lib/parallel';
|
||||
import { buildPackage, Output } from '../../lib/builder';
|
||||
@@ -42,11 +43,18 @@ export async function buildBackend(options: BuildBackendOptions) {
|
||||
outputs: new Set([Output.cjs]),
|
||||
});
|
||||
|
||||
const resolvedConfigPaths = configPaths?.map(p => {
|
||||
let path = paths.resolveTarget(p);
|
||||
if (!fs.pathExistsSync(path)) {
|
||||
path = paths.resolveOwnRoot(p);
|
||||
}
|
||||
return path;
|
||||
});
|
||||
const tmpDir = await fs.mkdtemp(resolvePath(os.tmpdir(), 'backstage-bundle'));
|
||||
try {
|
||||
await createDistWorkspace([pkg.name], {
|
||||
targetDir: tmpDir,
|
||||
configPaths,
|
||||
configPaths: resolvedConfigPaths,
|
||||
buildDependencies: !skipBuildDependencies,
|
||||
buildExcludes: [pkg.name],
|
||||
parallelism: getEnvironmentParallelism(),
|
||||
|
||||
@@ -24,7 +24,6 @@ import { paths } from './paths';
|
||||
import { isValidUrl } from './urls';
|
||||
import { getPackages } from '@manypkg/get-packages';
|
||||
import { PackageGraph } from './monorepo';
|
||||
import { pathExistsSync } from 'fs-extra';
|
||||
|
||||
type Options = {
|
||||
args: string[];
|
||||
@@ -39,11 +38,7 @@ export async function loadCliConfig(options: Options) {
|
||||
const configTargets: ConfigTarget[] = [];
|
||||
options.args.forEach(arg => {
|
||||
if (!isValidUrl(arg)) {
|
||||
let path = paths.resolveTarget(arg);
|
||||
if (!pathExistsSync(path)) {
|
||||
path = paths.resolveOwnRoot(arg);
|
||||
}
|
||||
configTargets.push({ path });
|
||||
configTargets.push({ path: paths.resolveTarget(arg) });
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user