What is the process for creating an Angular library using "npm pack" within a Java/Spring Boot application?

In my angular project, we have 5 custom libraries tailored to our needs. Using the com.github.eirslett maven plugin in our spring boot application, we build these libraries through the pom.xml file and then copy them to the dist/ folder. However, we also need to package these libraries as tarball (.tgz) files for use in another application. Currently, I have to manually navigate into each of the 5 folders within dist/ and run npm pack in the command line to generate the library_name.tgz files. Is there a way to automate this process like we do with building the libraries? The widely-used maven plugin mentioned earlier does not support the npm pack command.

Answer №1

Finally cracked the code!

After some digging in package.json

"build-utils": "ng build utils",
"package-utils": "cd dist/utils && npm pack",
"utils": "npm run build-utils && npm run package-utils"

Also, made modifications in pom.xml, within the com.github.eirslett plugin section, I included this new execution block

               <execution>
                    <id>utils-build</id>
                    <goals>
                        <goal>npm</goal>
                    </goals>
                    <configuration>
                        <arguments>run utils</arguments>
                    </configuration>
                    <phase>lifecycle-phase</phase>
                </execution>

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

Is it possible to incorporate regular React JSX with Material UI, or is it necessary to utilize TypeScript in this scenario?

I'm curious, does Material UI specifically require TypeScript or can we use React JSX code instead? I've been searching for an answer to this question without any luck, so I figured I'd ask here. ...

Unable to load the PDF file in Angular 8 due to an error

I've been attempting to display a PDF in a new browser tab using Angular 8. The PDF is retrieved from a Spring Boot API as a byte array: @GetMapping(value = "/pdf") public ResponseEntity<byte[]> beve(HttpServletRequest request) { return new ...

Retrieve the object property based on an array of indices

I am looking to create a function that can retrieve a specific property of an object based on an array of property names const getObjectProperty = (arr: string[], object: any) { // This function should return the desired object property } Expected Outco ...

What is the best approach for unit testing canActivate in Angular?

Is there a way to properly test the canActivate function in Angular that returns a function which ultimately provides a boolean value? I attempted to create instances of ActivatedRouteSnapshot and RouterStateSnapshot, and then pass them into the canActiva ...

Executing the outer function from within the inner function of a different outer function

Imagine this scenario: function firstFunction() { console.log("This is the first function") } secondFunction() { thirdFunction() { //call firstFunction inside thirdFunction } } What is the way to invoke firstFunction from thirdFunction? ...

Having trouble accessing functions in Typescript when importing JavaScript files, although able to access them in HTML

Recently, I started incorporating TypeScript and React into my company's existing JavaScript code base. It has been a bit of a rollercoaster ride, as I'm sure many can relate to. After conquering major obstacles such as setting up webpack correc ...

firebase connector for loopback

Here is my current situation and problem: Recently, I switched from MongoDB to Firebase in a loopback project. I successfully swapped out the loopback mongoDB connector for the loopback firestore connector. When running some POST methods, data was added t ...

The extended class possesses a distinct type from the base class, which is reinforced by an interface

Is it possible to write a method that is an extension of a base class, but with a different return type, if supported by the shared interface, without adding a type declaration in class 'a'? In practical terms, classes a & b exist in JavaScript ...

Converting integers to strings is not possible, just as converting strings to two-dimensional integer arrays is not

I find myself once again trying to solve the puzzle of error messages that keep appearing. Currently, I am delving into working with arrays - both regular and multi-dimensional. However, I am encountering difficulties in two areas: a) populating the arra ...

Dynamically assign values to object properties of varying data types using indexing

My goal is to dynamically update one object using another object of the same type. This object contains properties of different types: type TypeOne = 'good' | 'okay'; type TypeTwo = 'default' | 'one'; interface Opt ...

Enhancing ES6 capabilities with Angular polyfills

While exploring the Angular documentation and various online resources about Angular, I came across a question. If all code is written in Typescript, why would we need ES6 polyfills? My understanding is that webpack eventually transpiles the code to ES5, s ...

Tips for eliminating an unknown quantity of spaces following a particular word within a sentence using Java

I have the following String: abcfoobarfoo def xyzfoobcd fooaaafoo bar I require assistance in removing all spaces after foo only, if they exist. output: abcfoobarfoodef xyzfoobcd fooaaafoobar Thank you in advance. ...

Clickable Angular Material card

I am looking to make a mat-card component clickable by adding a routerlink. Here is my current component structure: <mat-card class="card" > <mat-card-content> <mat-card-title> {{title}}</mat-card-title> &l ...

What causes the return value of keyof to vary in this particular case?

type AppleNode = { type: 'Apple' name: string score: number } type BananaNode = { type: 'Banana' id: number score: number } type FruitNodes = AppleNode | BananaNode type fruitTest = { [P in keyof FruitNodes]: 21 } // Th ...

Should FormBuilder be utilized in the constructor or is it considered a poor practice?

section, you can find an example of implementation where declarations for formBuilder and services are done within the constructor(). While it is commonly known that using services inside the constructor() is not a recommended practice and should be done ...

Is it possible to access static members using a null reference? If so, what is the rationale behind allowing this behavior?

Is it possible to access static members from a null reference in Java? If so, what is the rationale behind allowing this behavior and how does it function internally? ...

React textarea trigger function on blur event

https://codesandbox.io/s/react-textarea-callback-on-blur-yoh8n?file=/src/App.tsx When working with a textarea in React, I have two main objectives: To remove focus and reset certain states when the user presses "Escape" To trigger a callback function (sa ...

What is the best way to forward all URLs to one central page?

I've recently started working with Angular and I'm currently developing a web app project using Angular 9. I could really use your help with this. My goal is to have a dynamic URL structure for the web app, such as https://www.myMainURL.com/***, ...

When using Angular2, I have found that I am unable to extract the body data from JSONP responses. However, I have discovered that this issue

Initially, I developed the SERVER using spring-boot framework. The code for this looks like: public class App { @RequestMapping("/") @ResponseBody String home(HttpServletRequest request) { String aa=request.getParameter("callback"); System.out.pri ...

Modify the color of Material UI's Select Component's IconComponent

Currently in my project, I am utilizing MUI's Select Component with the LanguageIcon as the designated IconComponent. My goal is to change the color of this icon from black (default) to white, but I have been unsuccessful in my attempts. I attempte ...