question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Need help to find correct configuration for monorepo project.

See original GitHub issue

Hi @pmowrer, @alisd23,

I am unable to find out correct configuration to publish(to artifactory) only those components where file is modified.

Below is the command executed after I change any src file of component: git add . git cz (commitzen)

Below is the command I execute for testing, building and publishing component:

npm install
node_modules/.bin/ng lint component1 --force=true --format=json > component1_lint-out.json
node_modules/.bin/ng test component1 --code-coverage --browsers ChromeHeadless
node_modules/.bin/ng lint component2 --force=true --format=json > component2_lint-out.json
node_modules/.bin/ng test component2 --code-coverage --browsers ChromeHeadless
node_modules/.bin/ng lint component3 --force=true --format=json > component3_lint-out.json
node_modules/.bin/ng test component3 --code-coverage --browsers ChromeHeadless
node_modules/.bin/ng build component1
node_modules/.bin/ng build component2
node_modules/.bin/ng build component3
npx semantic-release -e semantic-release-monorepo

here only component1 gets published to JFrog Artifactory

Here I wanted to avoid building each component, and instead of that have config in root package.json to achieve that.

I have following monorepo project structure:

master-project(Project root)

|_-> apps
|_-> e2e
|_-> libs
|_-> projects
       |_-> component1 -> package.json
       |_-> component2 -> package.json
       |_-> component3 -> package.json
|_-> package.json

project root package.json content:

{
	"name": "master-project",
	"version": "0.0.0-semantically-released",
	"scripts": {
		"ng": "ng",
		"start": "ng serve",
		"build": "ng build",
		"test": "ng test",
		"lint": "ng lint",
		"e2e": "ng e2e"
	},
	"private": false,
	"dependencies": {
		"@angular/animations": "^6.1.0",
		"@angular/common": "^6.1.0",
		"@angular/compiler": "^6.1.0",
		"@angular/core": "^6.1.0",
		"@angular/forms": "^6.1.0",
		"@angular/http": "^6.1.0",
		"@angular/platform-browser": "^6.1.0",
		"@angular/platform-browser-dynamic": "^6.1.0",
		"@angular/router": "^6.1.0",
		"core-js": "^2.5.4",
		"rxjs": "^6.0.0"
	},
	"devDependencies": {
		"@angular-devkit/build-angular": "~0.7.0",
		"@angular-devkit/build-ng-packagr": "~0.7.0",
		"@angular/cli": "~6.1.1",
		"@angular/compiler-cli": "^6.1.0",
		"@angular/language-service": "^6.1.0",
		"@semantic-release/changelog": "github:semantic-release/changelog",
		"@types/jasmine": "~2.8.6",
		"@types/jasminewd2": "~2.0.3",
		"@types/node": "~8.9.4",
		"codelyzer": "~4.2.1",
		"cz-conventional-changelog": "^2.1.0",
		"jasmine-core": "~2.99.1",
		"jasmine-spec-reporter": "~4.2.1",
		"karma": "~1.7.1",
		"karma-chrome-launcher": "~2.2.0",
		"karma-coverage-istanbul-reporter": "^2.0.0",
		"karma-jasmine": "~1.1.1",
		"karma-jasmine-html-reporter": "^0.2.2",
		"karma-sonarqube-reporter": "^1.0.4",
		"ng-packagr": "^3.0.0",
		"protractor": "~5.3.0",
		"semantic-release": "^15.9.16",
		"semantic-release-gerrit": "^1.1.4",
		"semantic-release-monorepo": "^6.1.1",
		"ts-node": "~5.0.1"
	},
	"config": {
		"commitizen": {
			"path": "./node_modules/cz-conventional-changelog"
		}
	},
	"release": {
		"monorepo": {
			"analyzeCommits": "@semantic-release/commit-analyzer",
			"generateNotes": [{
				"path": "semantic-release-gerrit",
				"gerritUrl": "https://gerrit.com/#/admin/projects/master-project"
			}]
		},
		"verifyConditions": "@semantic-release/npm",
		"analyzeCommits": "@semantic-release/commit-analyzer",
		"generateNotes": [{
			"path": "semantic-release-gerrit",
			"gerritUrl": "https://gerrit.com/#/admin/projects/master-project"
		}],
		"prepare": [{
				"path": "@semantic-release/changelog",
				"changelogFile": "docs/changelog.md"
			},
			"@semantic-release/npm"
		],
		"publish": "@semantic-release/npm",
		"success": false,
		"fail": false,
		"pkgRoot": "./dist/component1/",
		"npmPublish": true,
		"tarballDir": "dist",
		"branch": "master"
	},
	"repository": {
		"type": "git",
		"url": "https://gerrit.com/a/master-project.git"
	}
}

component1 package.json content:

{
  "name": "component1",
  "version": "0.0.1-semantically-released",
  "peerDependencies": {
    "@angular/common": "^6.0.0-rc.0 || ^6.0.0",
    "@angular/core": "^6.0.0-rc.0 || ^6.0.0"
  }
}

I know “pkgRoot”: “./dist/component1/” is the one which is causing only component1 to publish. But if I try “pkgRoot”: [“./dist/component1/”, “./dist/component2/”, “./dist/component3/”] it is throwing error.

Please suggest on how to achieve:

  1. Publish only those component where actully file got changed.
  2. Version bump (minor or major or patch) only for specific component where file got changed.

Help wanted!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
swapniljvcommented, Oct 11, 2018

Thanks @pmowrer for your input. And yes integrating lerna did help. Right now I am testing it, and results are on positive side.

1reaction
pmowrercommented, Oct 11, 2018

Hi @swapniljv!

Please suggest on how to achieve:

  1. Publish only those component where actully file got changed.
  2. Version bump (minor or major or patch) only for specific component where file got changed.

Both points listed is exactly why semantic-release-monorepo exists!

I would suggest using lerna to run semantic-release-monorepo across each package in your monorepro. See README for more details.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Need help to find correct configuration for monorepo project.
I am unable to find out correct configuration to publish(to artifactory) only those components where file is modified. Below is the command ...
Read more >
A Guide to Monorepos for Front-end Code
A monorepo or monorepository is a code management and architectural concept whereby you keep all your isolated bits of code inside one super...
Read more >
11 Great Tools for a Monorepo in 2021 | Bits and Pieces
Best tools to build a monorepo. Develop, build, and publish packages, and scale development. Discover Lerna, Nx, Rush, Bit, Yarn Workspaces, and more....
Read more >
Getting Started
This is a very quick tutorial to help you set up your own monorepo, a repository that includes multiple javascript packages, all managed...
Read more >
What is monorepo? (and should you use it?)
Monorepos can foster rapid development workflows. In this post, we'll examine if they are the right fit for you and your company.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found