Skip to content

Commit d0de72e

Browse files
authored
feat: transform into monorepo (#3)
1 parent 83f072a commit d0de72e

Some content is hidden

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

55 files changed

+7935
-1753
lines changed

.editorconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
root = true
2+
3+
[*]
4+
end_of_line = lf
5+
insert_final_newline = true
6+
7+
[*.{js,json,yml}]
8+
charset = utf-8
9+
indent_style = space
10+
indent_size = 2

.github/workflows/CI.yml

Lines changed: 62 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,16 @@ jobs:
2727
target: x86_64-apple-darwin
2828
architecture: x64
2929
build: |
30-
yarn build
31-
strip -x *.node
30+
yarn build -- --features with_simd
31+
strip -x packages/*/*.node
3232
- host: windows-latest
3333
build: |
34-
yarn build
34+
yarn build -- --features with_simd
3535
target: x86_64-pc-windows-msvc
3636
architecture: x64
3737
- host: windows-latest
3838
build: |
39-
yarn build --target i686-pc-windows-msvc
39+
yarn build -- --features with_simd
4040
yarn test
4141
target: i686-pc-windows-msvc
4242
architecture: x86
@@ -47,37 +47,38 @@ jobs:
4747
docker pull $DOCKER_REGISTRY_URL/napi-rs/napi-rs/nodejs-rust:lts-debian
4848
docker tag $DOCKER_REGISTRY_URL/napi-rs/napi-rs/nodejs-rust:lts-debian builder
4949
build: |
50-
docker run --rm -v ~/.cargo/git:/root/.cargo/git -v ~/.cargo/registry:/root/.cargo/registry -v $(pwd):/build -w /build builder yarn build && strip *.node
50+
docker run --env RUST_TARGET --rm -v ~/.cargo/git:/root/.cargo/git -v ~/.cargo/registry:/root/.cargo/registry -v $(pwd):/build -w /build builder yarn build -- --features with_simd && strip packages/*/*.node
5151
- host: ubuntu-latest
5252
target: x86_64-unknown-linux-musl
5353
architecture: x64
5454
docker: |
5555
docker pull $DOCKER_REGISTRY_URL/napi-rs/napi-rs/nodejs-rust:lts-alpine
5656
docker tag $DOCKER_REGISTRY_URL/napi-rs/napi-rs/nodejs-rust:lts-alpine builder
57-
build: docker run --rm -v ~/.cargo/git:/root/.cargo/git -v ~/.cargo/registry:/root/.cargo/registry -v $(pwd):/build -w /build builder sh -c "unset RUSTFLAGS && unset CC && yarn build && strip *.node"
57+
build: |
58+
docker run --env RUST_TARGET --rm -v ~/.cargo/git:/root/.cargo/git -v ~/.cargo/registry:/root/.cargo/registry -v $(pwd):/build -w /build builder sh -c "unset RUSTFLAGS && unset CC && yarn build -- --features with_simd && strip packages/*/*.node"
5859
- host: macos-latest
5960
target: aarch64-apple-darwin
6061
build: |
61-
yarn build --target=aarch64-apple-darwin
62-
strip -x *.node
63-
- host: ubuntu-latest
62+
yarn build -- --features with_simd
63+
strip -x packages/*/*.node
64+
- host: ubuntu-18.04
6465
architecture: x64
6566
target: aarch64-unknown-linux-gnu
6667
setup: |
6768
sudo apt-get update
6869
sudo apt-get install g++-aarch64-linux-gnu gcc-aarch64-linux-gnu -y
6970
build: |
70-
yarn build --target=aarch64-unknown-linux-gnu
71-
aarch64-linux-gnu-strip *.node
72-
- host: ubuntu-latest
71+
yarn build -- --features with_simd
72+
aarch64-linux-gnu-strip packages/*/*.node
73+
- host: ubuntu-18.04
7374
architecture: x64
7475
target: armv7-unknown-linux-gnueabihf
7576
setup: |
7677
sudo apt-get update
7778
sudo apt-get install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf -y
7879
build: |
79-
yarn build --target=armv7-unknown-linux-gnueabihf
80-
arm-linux-gnueabihf-strip *.node
80+
yarn build -- --features oxipng_libdeflater
81+
arm-linux-gnueabihf-strip packages/*/*.node
8182
- host: ubuntu-latest
8283
architecture: x64
8384
target: aarch64-linux-android
@@ -86,8 +87,8 @@ jobs:
8687
export CC="${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android24-clang"
8788
export CXX="${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android24-clang++"
8889
export PATH="${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin:${PATH}"
89-
yarn build --target aarch64-linux-android
90-
${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android-strip *.node
90+
yarn build -- --features with_simd
91+
${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android-strip packages/*/*.node
9192
- host: ubuntu-latest
9293
architecture: x64
9394
target: armv7-linux-androideabi
@@ -96,8 +97,8 @@ jobs:
9697
export CC="${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi24-clang"
9798
export CXX="${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi24-clang++"
9899
export PATH="${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin:${PATH}"
99-
yarn build --target armv7-linux-androideabi
100-
${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/arm-linux-androideabi-strip *.node
100+
yarn build -- --features oxipng_libdeflater
101+
${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/arm-linux-androideabi-strip packages/*/*.node
101102
- host: ubuntu-latest
102103
architecture: x64
103104
target: aarch64-unknown-linux-musl
@@ -106,9 +107,11 @@ jobs:
106107
docker pull ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
107108
docker tag ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine builder
108109
build: |
109-
docker run --rm -v ~/.cargo/git:/root/.cargo/git -v ~/.cargo/registry:/root/.cargo/registry -v $(pwd):/build -w /build builder sh -c "yarn build --target=aarch64-unknown-linux-musl && /aarch64-linux-musl-cross/bin/aarch64-linux-musl-strip *.node"
110+
docker run --env RUST_TARGET --rm -v ~/.cargo/git:/root/.cargo/git -v ~/.cargo/registry:/root/.cargo/registry -v $(pwd):/build -w /build builder sh -c "yarn build -- --features with_simd && /aarch64-linux-musl-cross/bin/aarch64-linux-musl-strip packages/*/*.node"
110111
name: stable - ${{ matrix.settings.target }} - node@16
111112
runs-on: ${{ matrix.settings.host }}
113+
env:
114+
RUST_TARGET: ${{ matrix.settings.target }}
112115
steps:
113116
- uses: actions/checkout@v2
114117
- name: Setup node
@@ -157,15 +160,15 @@ jobs:
157160
if: ${{ matrix.settings.setup }}
158161
shell: bash
159162
- name: Install dependencies
160-
run: yarn install --ignore-scripts --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
163+
run: yarn install
161164
- name: Build
162165
run: ${{ matrix.settings.build }}
163166
shell: bash
164167
- name: Upload artifact
165168
uses: actions/upload-artifact@v2
166169
with:
167170
name: bindings-${{ matrix.settings.target }}
168-
path: ${{ env.APP_NAME }}.*.node
171+
path: packages/*/*.node
169172
if-no-files-found: error
170173
build-freebsd:
171174
runs-on: macos-10.15
@@ -199,22 +202,23 @@ jobs:
199202
yarn --version
200203
run: |
201204
export PATH="/usr/local/cargo/bin:$PATH"
205+
export RUST_TARGET="x86_64-unknown-freebsd"
202206
pwd
203207
ls -lah
204208
whoami
205209
env
206210
freebsd-version
207-
yarn install --ignore-scripts --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
208-
yarn build
209-
strip -x *.node
211+
yarn install
212+
yarn build -- --features with_simd
213+
strip -x packages/*/*.node
210214
yarn test
211215
rm -rf node_modules
212216
rm -rf target
213217
- name: Upload artifact
214218
uses: actions/upload-artifact@v2
215219
with:
216220
name: bindings-freebsd
217-
path: ${{ env.APP_NAME }}.*.node
221+
path: packages/*/*.node
218222
if-no-files-found: error
219223
test-macOS-windows-binding:
220224
name: Test bindings on ${{ matrix.settings.target }} - node@${{ matrix.node }}
@@ -245,12 +249,15 @@ jobs:
245249
path: node_modules
246250
key: npm-cache-test-${{ matrix.settings.target }}-${{ matrix.node }}-${{ hashFiles('yarn.lock') }}
247251
- name: Install dependencies
248-
run: yarn install --ignore-scripts --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
252+
run: yarn install
249253
- name: Download artifacts
250254
uses: actions/download-artifact@v2
251255
with:
252256
name: bindings-${{ matrix.settings.target }}
253-
path: .
257+
path: artifacts
258+
- name: Move artifacts
259+
run: yarn artifacts
260+
shell: bash
254261
- name: List packages
255262
run: ls -R .
256263
shell: bash
@@ -282,12 +289,15 @@ jobs:
282289
path: node_modules
283290
key: npm-cache-test-linux-x64-gnu-${{ matrix.node }}-${{ hashFiles('yarn.lock') }}
284291
- name: Install dependencies
285-
run: yarn install --ignore-scripts --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
292+
run: yarn install
286293
- name: Download artifacts
287294
uses: actions/download-artifact@v2
288295
with:
289296
name: bindings-x86_64-unknown-linux-gnu
290-
path: .
297+
path: artifacts
298+
- name: Move artifacts
299+
run: yarn artifacts
300+
shell: bash
291301
- name: List packages
292302
run: ls -R .
293303
shell: bash
@@ -319,12 +329,15 @@ jobs:
319329
path: node_modules
320330
key: npm-cache-test-x86_64-unknown-linux-musl-${{ matrix.node }}-${{ hashFiles('yarn.lock') }}
321331
- name: Install dependencies
322-
run: yarn install --ignore-scripts --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
332+
run: yarn install
323333
- name: Download artifacts
324334
uses: actions/download-artifact@v2
325335
with:
326336
name: bindings-x86_64-unknown-linux-musl
327-
path: .
337+
path: artifacts
338+
- name: Move artifacts
339+
run: yarn artifacts
340+
shell: bash
328341
- name: List packages
329342
run: ls -R .
330343
shell: bash
@@ -349,17 +362,20 @@ jobs:
349362
uses: actions/download-artifact@v2
350363
with:
351364
name: bindings-aarch64-unknown-linux-gnu
352-
path: .
353-
- name: List packages
354-
run: ls -R .
355-
shell: bash
365+
path: artifacts
356366
- name: Cache NPM dependencies
357367
uses: actions/cache@v2
358368
with:
359369
path: node_modules
360370
key: npm-cache-test-linux-aarch64-gnu-${{ matrix.node }}-${{ hashFiles('yarn.lock') }}
361371
- name: Install dependencies
362-
run: yarn install --ignore-scripts --ignore-platform --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
372+
run: yarn install
373+
- name: Move artifacts
374+
run: yarn artifacts
375+
shell: bash
376+
- name: List packages
377+
run: ls -R packages
378+
shell: bash
363379
- name: Setup and run tests
364380
uses: addnab/docker-run-action@v3
365381
with:
@@ -388,17 +404,20 @@ jobs:
388404
uses: actions/download-artifact@v2
389405
with:
390406
name: bindings-armv7-unknown-linux-gnueabihf
391-
path: .
392-
- name: List packages
393-
run: ls -R .
394-
shell: bash
407+
path: artifacts
395408
- name: Cache NPM dependencies
396409
uses: actions/cache@v2
397410
with:
398411
path: node_modules
399412
key: npm-cache-test-linux-arm-gnueabihf-${{ matrix.node }}-${{ hashFiles('yarn.lock') }}
400413
- name: Install dependencies
401-
run: yarn install --ignore-scripts --ignore-platform --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
414+
run: yarn install
415+
- name: Move artifacts
416+
run: yarn artifacts
417+
shell: bash
418+
- name: List packages
419+
run: ls -R packages
420+
shell: bash
402421
- name: Setup and run tests
403422
uses: addnab/docker-run-action@v3
404423
with:
@@ -434,15 +453,15 @@ jobs:
434453
restore-keys: |
435454
npm-cache-
436455
- name: Install dependencies
437-
run: yarn install --ignore-scripts --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
456+
run: yarn install
438457
- name: Download all artifacts
439458
uses: actions/download-artifact@v2
440459
with:
441460
path: artifacts
442461
- name: Move artifacts
443462
run: yarn artifacts
444463
- name: List packages
445-
run: ls -R ./npm
464+
run: ls -R ./packages
446465
shell: bash
447466
- name: Publish
448467
run: |

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,12 @@ node_modules
44
Cargo.lock
55
.swc
66
.DS_Store
7+
.pnp.*
8+
.yarn/*
9+
!.yarn/patches
10+
!.yarn/plugins
11+
!.yarn/releases
12+
!.yarn/sdks
13+
!.yarn/versions
14+
.turbo
15+
*.tsbuildinfo

.yarn/releases/yarn-3.1.1.cjs

Lines changed: 768 additions & 0 deletions
Large diffs are not rendered by default.

.yarnrc.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
nodeLinker: node-modules
2+
3+
yarnPath: .yarn/releases/yarn-3.1.1.cjs

Cargo.toml

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,8 @@
1-
[package]
2-
edition = "2021"
3-
name = "napi-rs_pngquant"
4-
version = "0.0.0"
5-
6-
[lib]
7-
crate-type = ["cdylib"]
8-
9-
[dependencies]
10-
libc = "0.2"
11-
napi = {version = "2", default-features = false, features = ["napi3"]}
12-
napi-derive = {version = "2", default-features = false, features = ["type-def"]}
13-
14-
[target.'cfg(not(any(target_arch = "x86_64", target_arch = "x86", target_arch = "aarch64")))'.dependencies.oxipng]
15-
default-features = false
16-
features = ["parallel", "libdeflater"]
17-
version = "5"
18-
19-
[target.'cfg(any(target_arch = "x86_64", target_arch = "x86", target_arch = "aarch64"))'.dependencies.oxipng]
20-
default-features = false
21-
features = ["parallel"]
22-
version = "5"
23-
24-
[target.'cfg(not(all(target_os = "linux", target_arch = "arm")))'.dependencies.mozjpeg-sys]
25-
version = "1"
26-
27-
[target.'cfg(all(target_os = "linux", target_arch = "arm"))'.dependencies.mozjpeg-sys]
28-
default-features = false
29-
version = "1"
30-
31-
[build-dependencies]
32-
napi-build = "1"
1+
[workspace]
2+
members = [
3+
"./packages/binding",
4+
]
335

346
[profile.release]
7+
codegen-units = 1
358
lto = true

lerna.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"packages": ["packages/*"],
3+
"npmClient": "yarn",
4+
"useWorkspaces": true,
5+
"version": "independent",
6+
"command": {
7+
"version": {
8+
"message": "chore(release): publish"
9+
}
10+
}
11+
}

optimize-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const { readFileSync, writeFileSync } = require('fs')
22

3-
const { losslessCompressPng, compressJpeg } = require('./index')
3+
const { losslessCompressPng, compressJpeg } = require('./packages/binding')
44

55
writeFileSync('optimized-lossless.png', losslessCompressPng(readFileSync('./un-optimized.png')))
66

0 commit comments

Comments
 (0)