Skip to content

Enable beachball usage in Angular workspace #1104

@rajsite

Description

@rajsite

In an angular workspace the package.json for the library is not the package that npm publish is called on. Instead Angular creates a separate dist/my-lib folder with a new package.json that should be published. See the publishing your library Angular topic.

We have been able to workaround this behavior by:

  • Creating a custom invoke-publish command that redirects to the actual package to publish:
     "invoke-publish": "npm run invoke-publish:setup && cd ../dist/nimble-angular && npm publish", // call publish in the new built package
     "invoke-publish:setup": "cd ../ && npm run build:nimble" // rebuild the package in angular so it has the beachball bumped version
  • Patch beachball using patch-package to run the custom invoke-publish command
       diff --git a/node_modules/beachball/lib/packageManager/npmArgs.js b/node_modules/beachball/lib/packageManager/npmArgs.js
       index 9ed1d08..a3f064c 100644
       --- a/node_modules/beachball/lib/packageManager/npmArgs.js
       +++ b/node_modules/beachball/lib/packageManager/npmArgs.js
       @@ -9,7 +9,9 @@ function getNpmPublishArgs(packageInfo, options) {
            const { registry, token, authType, access } = options;
            const pkgCombinedOptions = packageInfo.combinedOptions;
            const args = [
       -        'publish',
       +        'run',
       +        'invoke-publish', // Note the new command name
       +        '--', // Note the -- flag used so that parameters are passed to the sub command of the new command
                '--registry',
                registry,
                '--tag',

An alternate publish command is required because one can't prevent the default publish behavior of the publish script.

Could beachball support a configurable publish command for this kind of scenario / be open to a contribution?
Related #651

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions