Skip to content

Commit

Permalink
chore: move to pnpm
Browse files Browse the repository at this point in the history
  • Loading branch information
Bilb committed May 3, 2024
1 parent 70a495b commit 308d689
Show file tree
Hide file tree
Showing 6 changed files with 751 additions and 610 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# This script will run tests anytime a pull request is added
name: Plop

on:
push:
branches:
- test-pnpm

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-2022, macos-11, ubuntu-20.04]
env:
SIGNAL_ENV: production
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- run: git config --global core.autocrlf false

- name: Checkout git repo
uses: actions/checkout@v3
with:
submodules: recursive

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 18.15.0

- uses: pnpm/action-setup@v3
with:
version: 9

- uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v2
if: runner.os == 'Windows'

- name: Setup node for windows
if: runner.os == 'Windows'
shell: bash
run: |
pnpm add -g node-gyp@latest
- name: Install dependencies
shell: bash
run: pnpm install --frozen-lockfile
- name: Lint Files
# no need to lint files on all platforms. Just do it once on the quicker one
if: runner.os == 'Linux'
run: pnpm lint-full

- name: Unit Test
run: pnpm test
4 changes: 2 additions & 2 deletions BUILDING.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Building instructions

yarn install
pnpm install

For more advanced/customized builds, you may want to invoke `yarn cmake-js ...` directly.
For more advanced/customized builds, you may want to invoke `pnpm cmake-js ...` directly.
16 changes: 8 additions & 8 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This library is the wrappers around libsession-util for NodeJS. It is built using the [node-addon-api](https://github.com/nodejs/node-addon-api) and [cmake-js](https://github.com/cmake-js/cmake-js). The build and dev instructions are quite custom, so check them out below.

### Issue with Yarn
### Issue with pnpm

The yarn package manager (used on session-desktop) does understand what is a git url in a dependency as part of a package.json file, but won't do a full clone including submodules when forking such a repository. For more details, see https://github.com/yarnpkg/yarn/issues/1488

Expand All @@ -20,16 +20,16 @@ git clone --recursive [email protected]:oxen-io/libsession-util-nodejs.git
```

Always do your changes in `[FOLDER_NOT_IN_SESSION_DESKTOP]/libsession-util-nodejs`, never in the one under session-desktop's `node_modules` as you might override your local changes.
Then, you can quickly compile a non-electron build by running `yarn cmake-js` from that folder. This is a quick incremental build which can check for C++ compilation errors.
Then, you can quickly compile a non-electron build by running `pnpm cmake-js` from that folder. This is a quick incremental build which can check for C++ compilation errors.
Once your changes are ready to be tested in the `session-desktop` you can compile an electron build using this command:

```
cd [SESSION_DESKTOP_PATH]; rm -rf node_modules/libsession_util_nodejs; cp -R [THIS_PROJECT_PATH] node_modules/libsession_util_nodejs; cd node_modules/libsession_util_nodejs && rm -rf build && yarn install && cd [SESSION_DESKTOP_PATH] && yarn build:workers
cd [SESSION_DESKTOP_PATH]; rm -rf node_modules/libsession_util_nodejs; cp -R [THIS_PROJECT_PATH] node_modules/libsession_util_nodejs; cd node_modules/libsession_util_nodejs && rm -rf build && pnpm install && cd [SESSION_DESKTOP_PATH] && pnpm build:workers
```

Replace `[SESSION_DESKTOP_PATH]` with the full path to your `session-desktop` folder, replace `[THIS_PROJECT_PATH]` with the path to the root of this project folder.

Every part of this command is needed and might need to be updated using your paths. Also, the `worker:libsession` needs to be recompiled too to include the just created .node file in itself. This is done by the `yarn build:workers` command.
Every part of this command is needed and might need to be updated using your paths. Also, the `worker:libsession` needs to be recompiled too to include the just created .node file in itself. This is done by the `pnpm build:workers` command.

Note: The `electron` property in the `config` object will need to be updated in the `package.json` every time we update `electron` package in [session-desktop](https://github.com/oxen-io/session-desktop/) so that the versions match. It is a node version, but not part of the official node docs. If you compiled the node module for an incorrect electron/node version you will get an error on `session-desktop` start.

Expand Down Expand Up @@ -62,15 +62,15 @@ And then upload the generated `libsession_util_nodejs-v$PACKAGE_VERSION.tar.gz`
The git-archive-all relies on the `.gitattributes` to know what to include or exclude.

Once this is done, update the dependency on `session-desktop`.
Make sure to remove the existing one first (with the include `yarn remove` below) as you might have messed up your `node_modules` doing the dev instructions.
Make sure to remove the existing one first (with the include `pnpm remove` below) as you might have messed up your `node_modules` doing the dev instructions.

```
yarn remove libsession_util_nodejs && yarn add https://github.com/oxen-io/libsession-util-nodejs/releases/download/v0.1.15/libsession_util_nodejs-v0.1.15.tar.gz
pnpm remove libsession_util_nodejs && pnpm add https://github.com/oxen-io/libsession-util-nodejs/releases/download/v0.1.15/libsession_util_nodejs-v0.1.15.tar.gz
```

Keep in mind that you need to update the two version numbers (e.g. `0.1.15`) to the just created release version of this project.

The cmake-js script will be run on the yarn add and should recompile your latest release of the `libsession-util-nodejs` as part of the build process and as part of the github actions on `session-desktop`.
You most likely need to recompile the workers to include those new changes: `yarn worker:utils && yarn worker:libsession`.
The cmake-js script will be run on the pnpm add and should recompile your latest release of the `libsession-util-nodejs` as part of the build process and as part of the github actions on `session-desktop`.
You most likely need to recompile the workers to include those new changes: `pnpm worker:utils && pnpm worker:libsession`.

You should have your changes in the next release!
13 changes: 4 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,22 @@
"main": "index.js",
"name": "libsession_util_nodejs",
"description": "Wrappers for the Session Util Library",
"version": "0.3.4",
"version": "0.3.5",
"license": "GPL-3.0",
"author": {
"name": "Oxen Project",
"email": "[email protected]"
},
"config": {
"electron": "25.8.4"
},
"scripts": {
"install": "run-script-os",
"install:default": "cmake-js compile --runtime=electron --runtime-version=$npm_package_config_electron -p16",
"install:win32": "cmake-js compile --runtime=electron --runtime-version=%npm_package_config_electron% -p16"
"preinstall": "npx only-allow pnpm",
"install": "cmake-js compile --runtime=electron --runtime-version=25.8.4 -p16 --log-level=verbose"
},
"devDependencies": {
"clang-format": "^1.8.0"
},
"dependencies": {
"cmake-js": "^7.2.1",
"node-addon-api": "^6.1.0",
"run-script-os": "^1.1.6"
"node-addon-api": "^6.1.0"
},
"typings": "index.d.ts"
}
Loading

0 comments on commit 308d689

Please sign in to comment.