Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating build package.json and root package.json version #403

Open
kikajanovcik opened this issue Apr 17, 2024 · 0 comments
Open

Updating build package.json and root package.json version #403

kikajanovcik opened this issue Apr 17, 2024 · 0 comments

Comments

@kikajanovcik
Copy link

I have an nx library that at the build step, adds dependencies to the package.json and adds this package.json to dist folder. However at npm publish only the root package.json is updated with the next version and added to release. Because of this, I changed my config to take the package.json from the dist folder, which gets updated with the next release version and publishes to npm. Now it all works fine, but my root package.json doesn't have this change. I am currently handling it by adding a custom script to semantic release plugins. What am I doing wrong? :)

The build target:

"build": {
  "executor": "@nx/esbuild:esbuild",
  "options": {
    "main": "{projectRoot}/src/index.ts",
    "tsConfig": "{projectRoot}/tsconfig.json",
    "outputPath": "{projectRoot}/dist",
    "packageJson": "{projectRoot}/package.json",
    "generatePackageJson": true,
    ...
  }
},

The release target:

"release": {
    "executor": "nx:run-commands",
    "dependsOn": ["build"],
    "options": {
      "commands": ["npx semantic-release-plus"],
      "cwd": "{projectRoot}"
    }
  }

semantic release config:

module.exports = {
extends: 'my-semantic-release-config',
tagFormat: 'my-lib/v${version}',
commitPaths: [
  '*', // anything in this directory
],
pkgRoot: 'dist',
plugins: [
  ...baseConfig.plugins,
  [
    "@semantic-release/exec",
    {
      "prepareCmd": "my-update-root-package-json-script"
    }
  ]
],
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant