'use strict';

var createDistWorkspace = require('./createDistWorkspace-CLrZPAfL.cjs.js');
var role = require('./role-6YZbMsXe.cjs.js');
var cliNode = require('@backstage/cli-node');
var index = require('./index-CCLafGQH.cjs.js');
var buildBackend = require('./buildBackend-Cv6N14cB.cjs.js');
var config = require('./config-OeQcmdz6.cjs.js');
require('chalk');
require('fs-extra');
require('path');
require('p-limit');
require('os');
require('tar');
require('lodash/partition');
require('./run-BcxUFacd.cjs.js');
require('child_process');
require('util');
require('@backstage/errors');
require('rollup');
require('@rollup/plugin-commonjs');
require('@rollup/plugin-node-resolve');
require('rollup-plugin-postcss');
require('rollup-plugin-esbuild');
require('@svgr/rollup');
require('rollup-plugin-dts');
require('@rollup/plugin-json');
require('@rollup/plugin-yaml');
require('rollup-pluginutils');
require('./svgrTemplate-BTjBQ3by.cjs.js');
require('./entryPoints-CoHH4lBA.cjs.js');
require('./parallel-BszNaKyc.cjs.js');
require('worker_threads');
require('./productionPack-DotlEIE2.cjs.js');
require('npm-packlist');
require('commander');
require('semver');
require('@backstage/cli-common');
require('webpack');
require('eslint-webpack-plugin');
require('fork-ts-checker-webpack-plugin');
require('html-webpack-plugin');
require('react-dev-utils/ModuleScopePlugin');
require('run-script-webpack-plugin');
require('@manypkg/get-packages');
require('webpack-node-externals');
require('./packageDetection-C__AGK-g.cjs.js');
require('lodash/pickBy');
require('mini-css-extract-plugin');
require('@pmmmwh/react-refresh-webpack-plugin');
require('yn');
require('@backstage/config');
require('chokidar');
require('p-queue');
require('react-dev-utils/FileSizeReporter');
require('react-dev-utils/formatWebpackMessages');
require('lodash/uniq');
require('react-dev-utils/openBrowser');
require('webpack-dev-server');
require('@yarnpkg/parsers');
require('@yarnpkg/lockfile');
require('minimatch');
require('./yarn-BDZCENk5.cjs.js');
require('@backstage/config-loader');

async function command(opts) {
  const role$1 = await role.findRoleFromCommand(opts);
  if (role$1 === "frontend" || role$1 === "backend") {
    const configPaths = opts.config.map((arg) => {
      if (config.isValidUrl(arg)) {
        return arg;
      }
      return index.paths.resolveTarget(arg);
    });
    if (role$1 === "frontend") {
      return buildBackend.buildFrontend({
        targetDir: index.paths.targetDir,
        configPaths,
        writeStats: Boolean(opts.stats)
      });
    }
    return buildBackend.buildBackend({
      targetDir: index.paths.targetDir,
      configPaths,
      skipBuildDependencies: Boolean(opts.skipBuildDependencies),
      minify: Boolean(opts.minify)
    });
  }
  const roleInfo = cliNode.PackageRoles.getRoleInfo(role$1);
  const outputs = /* @__PURE__ */ new Set();
  if (roleInfo.output.includes("cjs")) {
    outputs.add(createDistWorkspace.Output.cjs);
  }
  if (roleInfo.output.includes("esm")) {
    outputs.add(createDistWorkspace.Output.esm);
  }
  if (roleInfo.output.includes("types")) {
    outputs.add(createDistWorkspace.Output.types);
  }
  return createDistWorkspace.buildPackage({
    outputs,
    minify: Boolean(opts.minify)
  });
}

exports.command = command;
//# sourceMappingURL=index-B7dlVlWC.cjs.js.map
