Pass configs from build:backend to app builds. Fixes #15274
When using `build:backend` with `--config` options, they're not passed down to the packaging of the FE app. Thus, that's picking up the default configs, which includes the `app-config.local.yaml`, but it's also missing the production yaml, if requested. Pass the given `configPaths` around for the backend build like the frontend build already does. Signed-off-by: Axel Hecht <axel@pike.org>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/cli': patch
|
||||
---
|
||||
|
||||
Support building the frontend with the same set of configs as the backend.
|
||||
@@ -28,10 +28,11 @@ const SKELETON_FILE = 'skeleton.tar.gz';
|
||||
interface BuildBackendOptions {
|
||||
targetDir: string;
|
||||
skipBuildDependencies: boolean;
|
||||
configPaths?: string[];
|
||||
}
|
||||
|
||||
export async function buildBackend(options: BuildBackendOptions) {
|
||||
const { targetDir, skipBuildDependencies } = options;
|
||||
const { targetDir, skipBuildDependencies, configPaths } = options;
|
||||
const pkg = await fs.readJson(resolvePath(targetDir, 'package.json'));
|
||||
|
||||
// We build the target package without generating type declarations.
|
||||
@@ -45,6 +46,7 @@ export async function buildBackend(options: BuildBackendOptions) {
|
||||
try {
|
||||
await createDistWorkspace([pkg.name], {
|
||||
targetDir: tmpDir,
|
||||
configPaths,
|
||||
buildDependencies: !skipBuildDependencies,
|
||||
buildExcludes: [pkg.name],
|
||||
parallelism: getEnvironmentParallelism(),
|
||||
|
||||
@@ -34,6 +34,7 @@ export async function command(opts: OptionValues): Promise<void> {
|
||||
if (role === 'backend') {
|
||||
return buildBackend({
|
||||
targetDir: paths.targetDir,
|
||||
configPaths: opts.config as string[],
|
||||
skipBuildDependencies: Boolean(opts.skipBuildDependencies),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ export async function loadCliConfig(options: Options) {
|
||||
const configTargets: ConfigTarget[] = [];
|
||||
options.args.forEach(arg => {
|
||||
if (!isValidUrl(arg)) {
|
||||
configTargets.push({ path: paths.resolveTarget(arg) });
|
||||
configTargets.push({ path: paths.resolveTargetRoot(arg) });
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -60,6 +60,11 @@ type Options = {
|
||||
*/
|
||||
targetDir?: string;
|
||||
|
||||
/**
|
||||
* Configuration files to load during packaging.
|
||||
*/
|
||||
configPaths?: string[];
|
||||
|
||||
/**
|
||||
* Files to copy into the target workspace.
|
||||
*
|
||||
@@ -127,13 +132,18 @@ export async function createDistWorkspace(
|
||||
|
||||
if (options.buildDependencies) {
|
||||
const exclude = options.buildExcludes ?? [];
|
||||
const configPaths = options.configPaths ?? [];
|
||||
|
||||
const toBuild = new Set(
|
||||
targets.map(_ => _.name).filter(name => !exclude.includes(name)),
|
||||
);
|
||||
|
||||
const standardBuilds = new Array<BuildOptions>();
|
||||
const customBuild = new Array<{ dir: string; name: string }>();
|
||||
const customBuild = new Array<{
|
||||
dir: string;
|
||||
name: string;
|
||||
args?: string[];
|
||||
}>();
|
||||
|
||||
for (const pkg of packages) {
|
||||
if (!toBuild.has(pkg.packageJson.name)) {
|
||||
@@ -166,7 +176,10 @@ export async function createDistWorkspace(
|
||||
console.warn(
|
||||
`Building ${pkg.packageJson.name} separately because it is a bundled package`,
|
||||
);
|
||||
customBuild.push({ dir: pkg.dir, name: pkg.packageJson.name });
|
||||
const args = buildScript.includes('--config')
|
||||
? []
|
||||
: configPaths.map(p => ['--config', p]).flat();
|
||||
customBuild.push({ dir: pkg.dir, name: pkg.packageJson.name, args });
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -193,8 +206,8 @@ export async function createDistWorkspace(
|
||||
if (customBuild.length > 0) {
|
||||
await runParallelWorkers({
|
||||
items: customBuild,
|
||||
worker: async ({ name, dir }) => {
|
||||
await run('yarn', ['run', 'build'], {
|
||||
worker: async ({ name, dir, args }) => {
|
||||
await run('yarn', ['run', 'build', ...(args || [])], {
|
||||
cwd: dir,
|
||||
stdoutLogFunc: prefixLogFunc(`${name}: `, 'stdout'),
|
||||
stderrLogFunc: prefixLogFunc(`${name}: `, 'stderr'),
|
||||
|
||||
Reference in New Issue
Block a user