cli: add --build option to backend:image-build

This commit is contained in:
Patrik Oldsberg
2020-09-06 12:06:50 +02:00
parent 20158f0c36
commit 6fa721eb97
5 changed files with 16 additions and 3 deletions
@@ -32,6 +32,7 @@ export default async (cmd: Command) => {
const pkgPath = paths.resolveTarget(PKG_PATH);
const pkg = await fs.readJson(pkgPath);
const tempDistWorkspace = await createDistWorkspace([pkg.name], {
buildDependencies: Boolean(cmd.build),
files: [
'package.json',
'yarn.lock',
+1 -1
View File
@@ -41,7 +41,7 @@ export function registerCommands(program: CommanderStatic) {
.helpOption(', --backstage-cli-help') // Let docker handle --help
.option('--build', 'Build packages before packing them into the image')
.description(
'Build a docker , all extra options are forwarded to docker build',
'Bundles the package into a docker image. All extra args are forwarded to docker image build',
)
.action(lazy(() => import('./backend/buildImage').then(m => m.default)));
+12
View File
@@ -48,6 +48,11 @@ type Options = {
* Defaults to ['yarn.lock', 'package.json'].
*/
files?: FileEntry[];
/**
* If set to true, the target packages are built before they are packaged into the workspace.
*/
buildDependencies?: boolean;
};
/**
@@ -68,6 +73,13 @@ export async function createDistWorkspace(
const targets = await findTargetPackages(packageNames);
if (options.buildDependencies) {
const scopeArgs = targets.flatMap(target => ['--scope', target.name]);
await run('yarn', ['lerna', 'run', ...scopeArgs, 'build'], {
cwd: paths.targetRoot,
});
}
await moveToDistWorkspace(targetDir, targets);
const files: FileEntry[] = options.files ?? ['yarn.lock', 'package.json'];