Navigating the process of updating canary versions in a monorepo using Lerna across various branches

Imagine we're working on a TypeScript project with a monorepo structure and using Lerna for versioning and publishing packages. We need to make two separate changes that affect the same package.

Firstly, we have the package foo. One developer has added a new feature on their branch (dev-foo) and wants to test it. By running:

lerna version --include-merged-tags --conventional-prerelease

Lerna will update the version of package foo to v1.0.0-alpha, commit the prerelease, and push it to the remote repository.

Meanwhile, another developer made a second change on their own branch (dev-bar) and also wants to do a prerelease. If they run the same command, Lerna would try to update the version of package bar to v2.0.0-alpha, but it will fail because the tag v1.0.0-alpha already exists - even after a git fetch.

How can we avoid this situation? A possible solution is to update those versions to v1.0.1-alpha and v2.0.0-alpha. But how do we do that?

How can we stop Lerna from updating the package version to one that already exists but hasn't been merged yet? For example, bumping a canary version on the dev-foo branch. Essentially, how do we support independent development and prerelase tagging within the same workspace?

Answer №1

To achieve this, simply utilize the command

lerna publish --canary --preid beta
to obtain the desired tag as outlined in the official lerna documentation.

--preid Contrary to the lerna version option with the same name, this specific option exclusively impacts the --canary version computation.

lerna publish --canary
# generates the subsequent semantic prerelease version, for instance:
# 1.0.0 => 1.0.1-alpha.0

lerna publish --canary --preid next
# produces the forthcoming semantic prerelease version alongside a particular prerelease designation, like:
# 1.0.0 => 1.0.1-next.0

By utilizing this directive, when executing lerna publish --canary, the software will elevate premajor, preminor, prepatch, or prerelease semver increments utilizing the indicated prerelease identifier.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Angular 5 seems to be experiencing issues with the function ngOnChanges() not functioning correctly

I have been attempting to trigger the ngOnChanges() function in my Angular 5.x component whenever there is a change in the variable this.test either in the component lifecycle or the template. However, I am encountering an issue where the ngOnChanges() fun ...

Retrieve only data that results in either a 1 or 0 when filtering

Currently, I am utilizing Angular2 with Typescript and making use of the filter method. The functionality of the filter() method involves creating a new array that contains elements which successfully pass the test defined by the given function. However, ...

Global error handling fails to catch re-thrown HTTP errors in rxjs throwError scenario

Purpose: Implementing a global error handler for server errors and application errors generated in Typescript code. Approach: Utilizing a custom ErrorHandler from a library project within the same workspace. The library structure is as follows: https://i ...

Is it possible to invoke a component's function within the click function of a Chartjs chart?

How do I trigger a function in my Component from an onclick event in my chart.js? export class ReportesComponent implements OnInit { constructor(public _router: Router, private data: ReporteService) {} this.chart = new Chart('myChart', { ...

Is it possible to assign a variable in typescript using the interface as its type?

Here's the snippet of code I have written interface apiResult { Token: string; Result: any; } const result: apiResult = payload.Result; I am wondering about the significance of this code. Is it possible to assign a type from an interface to ...

Creating Typescript tuple function arguments using key-based approach

Currently, I am developing an API that utilizes tuples and I'm working on inferring the function arguments within these tuples. To make things easier to understand, I have created a simple example showcasing what I am attempting to accomplish. type I ...

Utilizing React's useCallback with dependencies based on a function called within the callback

I've been working on a web application using React and came across an interesting implementation. Here's how it looks: const onAddNewAccount = useCallback(async () => { await refetch(); setOtherState((prev) => {...}); }, [refetch]); ...

Angular 9 - Refresh page while redirecting to the same URL, triggering only the API call specific to the current page

Is there a way to redirect to the same URL and also refresh the page without calling all APIs from the beginning of the application? I have attempted using an anchor tag with href, but it results in refreshing the entire page and fetching all APIs again. I ...

Creating a Type in Typescript that Inherits Keys from Another Type

Imagine you're faced with this scenario involving a Typescript class: class Person { name: string; age: number; } If you were to create an object type with the same properties, using the any type, but with all properties being optional - how wou ...

Issue: The UserComponent is attempting to set the property 'id' of an undefined object, resulting in an error

An error has occurred indicating that the property 'id' cannot be set as it is undefined in the UserComponent file of user.component.ts. Here is the TypeScript code: import { Component, OnInit } from "@angular/core"; import { ActivatedRoute, Rou ...

Every time I attempt to maintain an object's state, TypeScript keeps throwing this error at me

interface Data { petname: string, petprice: string, category: string, pettype: string, gender: string, short: string, details: string } const [petdata, setPetdata] = useState<Data>({}); const [img, setImg] = useSt ...

Guide on converting general objects into a TypeScript class

Having recently started working with Typescript, I have a JSON object that needs to be mapped to a generic interface. However, my initial attempt at creating the interface seems to be incorrect. I need assistance in constructing a generic interface or cl ...

Is the Google Maps Javascript API compatible with Ionic 2?

Hi everyone, I hope you're all doing well :) In my development of a basic application using Ionic Framework with Google Maps (Map + Places SearchBox), everything is working smoothly until I encounter an issue when trying to search for an address (e.g ...

Can anyone clarify what the term 'this' is referring to in this particular snippet of code?

Upon analyzing the following code snippet: export abstract class CustomError extends Error { abstract statusCode: number; constructor(message: string) { super(message); Object.setPrototypeOf(this, CustomError.prototype); } abstract seri ...

Error encountered during conversion to Typescript for select event and default value

When trying to set the defaultValue in a Select component, TSlint throws an error - Type 'string' is not assignable to type 'ChangeEvent<HTMLInputElement> | undefined - for the code snippet below: const App = () => { const [ mont ...

What is the best way to specify the type of a dictionary with keys that are a subset of a union of literal types?

When working with TypeScript, I have a union literal type named Color defined as: export type Color = | 'red' | 'green' | 'blue' | 'teal' | 'purple' My challenge is to define the type of a dictio ...

What is the best way to obtain a signed cookie in aws-sdk-js-v3?

I am looking to utilize signed cookies for accessing private content stored on S3 using CloudFront for CDN. I am struggling to identify the appropriate commands to generate signed cookies in aws-sdk-js-v3. According to the updated SDK documentation, it sh ...

The specified type '{ state: any; dispatch: React.Dispatch<{ type: string; value: any; }>; }' is not compatible with the expected type

I've been working on a UI layout that includes checkboxes on the left, a data table on the right, and a drop zone box. The aim is to keep the table data updated whenever a new file is dropped, and also filter the data based on checkbox selection. I ma ...

Is it possible for mapStateToProps to limit the scope of props?

I'm currently in the process of adding type annotations to an older component, but I am uncertain about whether connect's types support my current objectives. This particular component is a connected component that receives a prop with a general ...