Skip to content

Commit 747f2a0

Browse files
feat(rebuild): citizenfx-rebuild
1 parent cb372cd commit 747f2a0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+2240
-7257
lines changed

.circleci/config.yml

-86
This file was deleted.

.github/CODEOWNERS

-1
This file was deleted.

.github/dependabot.yml

-6
This file was deleted.

.github/workflows/add-to-project.yml

-29
This file was deleted.

.github/workflows/publish.yml

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Release & Publish
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v2
14+
- name: Create Release
15+
id: create_release
16+
uses: actions/create-release@v1
17+
env:
18+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19+
with:
20+
tag_name: ${{ github.ref }}
21+
release_name: ${{ github.ref }}
22+
draft: false
23+
prerelease: false
24+
25+
publish:
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: actions/checkout@v2
29+
- name: Setup .npmrc file to publish to npm
30+
uses: actions/setup-node@v1
31+
with:
32+
node-version: '22.x'
33+
registry-url: 'https://registry.npmjs.org'
34+
- name: Install modules and build project
35+
run: yarn install
36+
- name: Get version from tag
37+
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV
38+
if: startsWith(github.ref, 'refs/tags/')
39+
- name: Adjust version number
40+
run: npm version $VERSION --no-git-tag-version
41+
- name: Publish to npm
42+
run: npm publish --access public
43+
env:
44+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/semantic.yml

-26
This file was deleted.

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,5 @@ node_modules
2929

3030
lib
3131
test-dist
32+
.idea
33+
package-lock.json

.releaserc.json

-9
This file was deleted.

README.md

+19-129
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,37 @@
1-
## Electron Rebuild
1+
## CitizenFX Node Rebuild
22

3-
[![CircleCI](https://circleci.com/gh/electron/rebuild.svg?style=svg)](https://circleci.com/gh/electron/rebuild)
4-
[![NPM](https://img.shields.io/npm/v/@electron/rebuild.svg?style=flat)](https://npm.im/@electron/rebuild)
5-
[![Coverage Status](https://codecov.io/gh/electron/rebuild/branch/main/graph/badge.svg)](https://codecov.io/gh/electron/rebuild)
3+
[![NPM](https://img.shields.io/npm/v/@citizenfx/node-rebuild.svg?style=flat)](https://npm.im/@citizenfx/node-rebuild)
64

7-
This executable rebuilds native Node.js modules against the version of Node.js
8-
that your Electron project is using. This allows you to use native Node.js
9-
modules in Electron apps without your system version of Node.js matching exactly
10-
(which is often not the case, and sometimes not even possible).
5+
This package is based on [electron-rebuild](https://github.com/electron/rebuild).
6+
7+
This executable is rebuilding the native NodeJS modules
8+
you are using inside your FXServer resource
9+
against the NodeJS version that is used by the FXServer.
1110

1211
### How does it work?
1312

14-
Install the package with `--save-dev`:
13+
Install the @citizenfx/node-rebuild as a dev dependency with `--save-dev`:
1514

1615
```sh
17-
npm install --save-dev @electron/rebuild
16+
npm install --save-dev @citizenfx/node-rebuild
1817
```
1918

20-
Then, whenever you install a new npm package, rerun electron-rebuild:
19+
Then, whenever you install a new package inside your FXServer resource, rerun node-rebuild:
2120

2221
```sh
23-
$(npm bin)/electron-rebuild
22+
$(npm bin)/node-rebuild
2423
```
2524

2625
Or if you're on Windows:
2726

2827
```sh
29-
.\node_modules\.bin\electron-rebuild.cmd
28+
.\node_modules\.bin\node-rebuild.cmd
3029
```
31-
If you have a good node-gyp config but you see an error about a missing element on Windows like `Could not load the Visual C++ component "VCBuild.exe"`, try to launch electron-rebuild in an npm script:
30+
The same works inside a script in your `package.json`:
3231

3332
```json
3433
"scripts": {
35-
"rebuild": "electron-rebuild -f -w yourmodule"
34+
"rebuild": "node-rebuild -f"
3635
}
3736
```
3837

@@ -44,123 +43,14 @@ npm run rebuild
4443

4544
### What are the requirements?
4645

47-
Node v12.13.0 or higher is required. Building native modules from source uses
46+
Node v22.6.0 or higher is required. Building native modules from source uses
4847
[`node-gyp`](https://github.com/nodejs/node-gyp#installation), refer to the link for its
4948
installation/runtime requirements.
5049

51-
### CLI Arguments
52-
53-
```
54-
Usage: electron-rebuild --version [version] --module-dir [path]
55-
56-
Options:
57-
-v, --version The version of Electron to build against [string]
58-
-f, --force Force rebuilding modules, even if we would skip
59-
it otherwise [boolean]
60-
-a, --arch Override the target architecture to something
61-
other than your system's [string]
62-
-m, --module-dir The path to the node_modules directory to rebuild
63-
[string]
64-
-w, --which-module A specific module to build, or comma separated
65-
list of modules. Modules will only be rebuilt if
66-
they also match the types of dependencies being
67-
rebuilt (see --types). [string]
68-
-o, --only Only build specified module, or comma separated
69-
list of modules. All others are ignored. [string]
70-
-e, --electron-prebuilt-dir The path to the prebuilt electron module [string]
71-
-d, --dist-url Custom header tarball URL [string]
72-
-t, --types The types of dependencies to rebuild. Comma
73-
separated list of "prod", "dev" and "optional".
74-
Default is "prod,optional" [string]
75-
-p, --parallel Rebuild in parallel, this is enabled by default
76-
on macOS and Linux [boolean]
77-
-s, --sequential Rebuild modules sequentially, this is enabled by
78-
default on Windows [boolean]
79-
-b, --debug Build debug version of modules [boolean]
80-
--prebuild-tag-prefix GitHub tag prefix passed to prebuild-install.
81-
Default is "v" [string]
82-
--force-abi Override the ABI version for the version of
83-
Electron you are targeting. Only use when
84-
targeting Nightly releases. [number]
85-
--use-electron-clang Use the clang executable that Electron used when
86-
building its binary. This will guarantee compiler
87-
compatibility [boolean]
88-
--disable-pre-gyp-copy Disables the pre-gyp copy step [boolean]
89-
--build-from-source Skips prebuild download and rebuilds module from
90-
source. [boolean]
91-
-h, --help Show help [boolean]
92-
```
93-
94-
### How can I use this with [Electron Forge](https://github.com/electron/forge)?
95-
96-
This package is automatically used with Electron Forge when packaging an Electron app.
97-
98-
### How can I integrate this into [Electron Packager](https://github.com/electron/packager)?
50+
### What if the NodeJS version changed inside the FXServer?
9951

100-
electron-rebuild provides a function compatible with the [`afterCopy` hook](https://electron.github.io/packager/main/interfaces/electronpackager.options.html#aftercopy)
101-
for Electron Packager. For example:
52+
The node-rebuild can be manually adjusted to rebuild against the NodeJS version that is required by providing the version as a cli argument.
10253

103-
```javascript
104-
import packager from '@electron/packager';
105-
import rebuild from '@electron/rebuild';
106-
107-
packager({
108-
// … other options
109-
afterCopy: [(buildPath, electronVersion, platform, arch, callback) => {
110-
rebuild({ buildPath, electronVersion, arch })
111-
.then(() => callback())
112-
.catch((error) => callback(error));
113-
}],
114-
// … other options
115-
});
116-
```
117-
118-
### How can I integrate this with [prebuild](https://github.com/prebuild/prebuild)?
119-
120-
If your module uses [prebuild](https://github.com/prebuild/prebuild) for creating prebuilt binaries,
121-
it also uses [prebuild-install](https://github.com/prebuild/prebuild-install) to download them. If
122-
this is the case, then `electron-rebuild` will run `prebuild-install` to download the correct
123-
binaries from the project's GitHub Releases instead of rebuilding them.
124-
125-
### How can I integrate this into Grunt / Gulp / Whatever?
126-
127-
electron-rebuild is also a library that you can require into your app or
128-
build process. It has a very simple API:
129-
130-
```javascript
131-
import rebuild from '@electron/rebuild';
132-
133-
// Public: Rebuilds a node_modules directory with the given Electron version.
134-
//
135-
// options: Object with the following properties
136-
// buildPath - An absolute path to your app's directory. (The directory that contains your node_modules)
137-
// electronVersion - The version of Electron to rebuild for
138-
// arch (optional) - Default: process.arch - The arch to rebuild for
139-
// extraModules (optional) - Default: [] - An array of modules to rebuild as well as the detected modules
140-
// onlyModules (optional) - Default: null - An array of modules to rebuild, ONLY these module names will be rebuilt.
141-
// The "types" property will be ignored if this option is set.
142-
// force (optional) - Default: false - Force a rebuild of modules regardless of their current build state
143-
// headerURL (optional) - Default: https://www.electronjs.org/headers - The URL to download Electron header files from
144-
// types (optional) - Default: ['prod', 'optional'] - The types of modules to rebuild
145-
// mode (optional) - The rebuild mode, either 'sequential' or 'parallel' - Default varies per platform (probably shouldn't mess with this one)
146-
// useElectronClang (optional) - Whether to use the clang executable that Electron used when building its binary. This will guarantee compiler compatibility
147-
148-
// Returns a Promise indicating whether the operation succeeded or not
149-
```
150-
151-
A full build process might look something like:
152-
153-
```javascript
154-
const childProcess = require('child_process');
155-
const pathToElectron = require('electron');
156-
157-
rebuild({
158-
buildPath: __dirname,
159-
electronVersion: '1.4.12'
160-
})
161-
.then(() => console.info('Rebuild Successful'))
162-
.catch((e) => {
163-
console.error("Building modules didn't work!");
164-
console.error(e);
165-
});
54+
```sh
55+
node-rebuild --nodeVersion 22.6.0
16656
```

0 commit comments

Comments
 (0)