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

Support corepack #1157

Merged
merged 4 commits into from
Aug 11, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update the README with the details of how to use corepack.
  • Loading branch information
stevestorey committed Jun 12, 2024
commit c63726c0d08373083e21999c8eb979dde9cbe7fc
90 changes: 90 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,11 @@ to see how it should be set up: https://github.com/eirslett/frontend-maven-plugi

- [Installing node and npm](#installing-node-and-npm)
- [Installing node and yarn](#installing-node-and-yarn)
- [Installing node and corepack](#installing-node-and-corepack)
- Running
- [npm](#running-npm)
- [yarn](#running-yarn)
- [corepack](#running-corepack)
- [bower](#running-bower)
- [grunt](#running-grunt)
- [gulp](#running-gulp)
Expand Down Expand Up @@ -171,6 +173,45 @@ https://github.com/eirslett/frontend-maven-plugin/blob/master/frontend-maven-plu
</plugin>
```

### Installing node and corepack

You can choose to let corepack manage the package manager version in use. Node is
downloaded from `https://nodejs.org/dist`, and corepack currently comes from
`https://repository.npmjs.org`, extracted and put into a `node` folder created
in your installation directory.

Node/corepack and any package managers will only be "installed" locally to your project.
It will not be installed globally on the whole system (and it will not interfere with any
Node/corepack installations already present).

Have a look at the example `POM` to see how it should be set up with corepack:
https://github.com/eirslett/frontend-maven-plugin/blob/master/frontend-maven-plugin/src/it/corepack-integration/pom.xml


```xml
<plugin>
...
<execution>
<!-- optional: you don't really need execution ids, but it looks nice in your build log. -->
<id>install-node-and-corepack</id>
<goals>
<goal>install-node-and-corepack</goal>
</goals>
<!-- optional: default phase is "generate-resources" -->
<phase>generate-resources</phase>
</execution>
<configuration>
<nodeVersion>v20.12.2</nodeVersion>
<corepackVersion>v0.25.2</corepackVersion>

<!-- optional: where to download node from. Defaults to https://nodejs.org/dist/ -->
<nodeDownloadRoot>https://myproxy.example.org/nodejs/</nodeDownloadRoot>
<!-- optional: where to download corepack from. Defaults to https://registry.npmjs.org/corepack/-/ -->
<corepackDownloadRoot>https://myproxy.example.org/corepack/</corepackDownloadRoot>
</configuration>
</plugin>
```

### Running npm

All node packaged modules will be installed in the `node_modules` folder in your [working directory](#working-directory).
Expand Down Expand Up @@ -274,6 +315,55 @@ Also you can set a registry using a tag `npmRegistryURL`
</execution>
```

### Running corepack

If your `packageManager` specifies `yarn`, then you'll want to have something like:


```xml
<execution>
<id>install</id>
<goals>
<goal>corepack</goal>
</goals>
<configuration>
<arguments>yarn install</arguments>
</configuration>
</execution>
<execution>
<id>build</id>
<goals>
<goal>corepack</goal>
</goals>
<configuration>
<arguments>yarn build</arguments>
</configuration>
</execution>
```

and if you're using `pnpm` instead, you'll want something like

```xml
<execution>
<id>install</id>
<goals>
<goal>corepack</goal>
</goals>
<configuration>
<arguments>pnpm install</arguments>
</configuration>
</execution>
<execution>
<id>build</id>
<goals>
<goal>corepack</goal>
</goals>
<configuration>
<arguments>pnpm build</arguments>
</configuration>
</execution>
```

### Running bower

All bower dependencies will be installed in the `bower_components` folder in your working directory.
Expand Down