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

windows support for bun #1142

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ It's supposed to work on Windows, OS X and Linux.
If you prefer [Yarn](https://yarnpkg.com/) over [NPM](https://www.npmjs.com/) for your node package fetching,
this plugin can also download Node and Yarn and then run `yarn install` for your project.

The new [Bun](https://bun.sh/) Javascript Toolkit is also supported.

#### What is this plugin meant to do?
- Let you keep your frontend and backend builds as separate as possible, by
reducing the amount of interaction between them to the bare minimum; using only 1 plugin.
Expand Down Expand Up @@ -56,9 +58,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 bun](#installing-bun)
- Running
- [npm](#running-npm)
- [yarn](#running-yarn)
- [bun](#running-bun)
- [bower](#running-bower)
- [grunt](#running-grunt)
- [gulp](#running-gulp)
Expand Down Expand Up @@ -171,6 +175,26 @@ https://github.com/eirslett/frontend-maven-plugin/blob/master/frontend-maven-plu
</plugin>
```

### Installing Bun

The new alternative is to use Bun, which combines features of a runtime and a package manager.

```xml
<plugin>
...
<execution>
<id>install bun runtime</id>
<goals>
<goal>install-bun</goal>
</goals>
</execution>
<configuration>
<bunVersion>v1.1.2</bunVersion>
<installDirectory>target</installDirectory>
</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 +298,22 @@ Also you can set a registry using a tag `npmRegistryURL`
</execution>
```

### Running bun

This works exactly like yarn, all node packaged modules will be installed in the `node_modules` folder in your [working directory](#working-directory).

```xml
<execution>
<id>bun install</id>
<goals>
<goal>bun</goal>
</goals>
<configuration>
<arguments>install</arguments>
</configuration>
</execution>
```

### Running bower

All bower dependencies will be installed in the `bower_components` folder in your working directory.
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
invoker.os.family = !windows, unix, mac
invoker.os.family = windows, unix, mac
2 changes: 1 addition & 1 deletion frontend-maven-plugin/src/it/bun-integration/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<goal>install-bun</goal>
</goals>
<configuration>
<bunVersion>v1.0.10</bunVersion>
<bunVersion>v1.1.2</bunVersion>
</configuration>
</execution>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ public void install() throws InstallationException {
if (!bunIsAlreadyInstalled()) {
if (!this.bunVersion.startsWith("v")) {
this.logger.warn("Bun version does not start with naming convention 'v'.");
}
if (this.config.getPlatform().isWindows()) {
throw new InstallationException("Unable to install bun on windows!");
} else {
installBunDefault();
}
Expand Down Expand Up @@ -132,8 +129,11 @@ private void installBunDefault() throws InstallationException {
}

// Search for the bun binary
String binaryFile = OS.guess().equals(OS.Windows) ? "bun.exe" : "bun";

File bunBinary =
new File(getInstallDirectory(), File.separator + createBunTargetArchitecturePath() + File.separator + "bun");
new File(getInstallDirectory(), File.separator + createBunTargetArchitecturePath() + File.separator + binaryFile);

if (!bunBinary.exists()) {
throw new FileNotFoundException(
"Could not find the downloaded bun binary in " + bunBinary);
Expand Down Expand Up @@ -180,7 +180,7 @@ private String createDownloadUrl() {
private String createBunTargetArchitecturePath() {
OS os = OS.guess();
Architecture architecture = Architecture.guess();
String destOs = os.equals(OS.Linux) ? "linux" : os.equals(OS.Mac) ? "darwin" : null;
String destOs = os.equals(OS.Linux) ? "linux" : os.equals(OS.Mac) ? "darwin" : os.equals(OS.Windows) ? "windows" : null;
String destArc = architecture.equals(Architecture.x64) ? "x64" : architecture.equals(
Architecture.arm64) ? "aarch64" : null;
return String.format("%s-%s-%s", INSTALL_PATH, destOs, destArc);
Expand Down
Loading