Merge pull request #3538 from lowjoel/optional_npmrc
feat(cli): Support .npmrc when building distribution packages
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/cli': patch
|
||||
---
|
||||
|
||||
Support `.npmrc` when building with private NPM registries
|
||||
@@ -34,11 +34,15 @@ export default async (cmd: Command) => {
|
||||
const pkgPath = paths.resolveTarget(PKG_PATH);
|
||||
const pkg = await fs.readJson(pkgPath);
|
||||
const appConfigs = await findAppConfigs();
|
||||
const npmrc = (await fs.pathExists(paths.resolveTargetRoot('.npmrc')))
|
||||
? ['.npmrc']
|
||||
: [];
|
||||
const tempDistWorkspace = await createDistWorkspace([pkg.name], {
|
||||
buildDependencies: Boolean(cmd.build),
|
||||
files: [
|
||||
'package.json',
|
||||
'yarn.lock',
|
||||
...npmrc,
|
||||
...appConfigs,
|
||||
{ src: paths.resolveTarget('Dockerfile'), dest: 'Dockerfile' },
|
||||
],
|
||||
|
||||
@@ -55,7 +55,11 @@ export function registerCommands(program: CommanderStatic) {
|
||||
.helpOption(', --backstage-cli-help') // Let docker handle --help
|
||||
.option('--build', 'Build packages before packing them into the image')
|
||||
.description(
|
||||
'Bundles the package into a docker image. All extra args are forwarded to docker image build',
|
||||
// TODO: Add example use cases in Backstage documentation.
|
||||
// For example, if a $NPM_TOKEN needs to be exposed, run `backend:build-image --secret
|
||||
// id=NPM_TOKEN,src=/NPM_TOKEN.txt`.
|
||||
'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)));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user