Skip to content

Commit 03c822f

Browse files
committed
chore: init
0 parents  commit 03c822f

File tree

19 files changed

+1064
-0
lines changed

19 files changed

+1064
-0
lines changed

.cargo/config.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[target.x86_64-pc-windows-msvc]
2+
rustflags = ["-C", "target-feature=+crt-static"]

.cargo/rustfmt.toml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# require the shorthand instead of it being optional
2+
use_field_init_shorthand = true
3+
newline_style = "unix"
4+
max_width = 140
5+
chain_width = 100
6+
fn_call_width = 100
7+
# Format string literals where necessary
8+
format_strings = true
9+
# Format macro invocations
10+
format_macro_matchers = true
11+
# Reorder impl items
12+
reorder_impl_items = true
13+
# Format code inside macro declarations
14+
format_macro_bodies = true
15+
# Merge imports with the same prefix
16+
imports_granularity = "Crate"
17+
# Group imports
18+
group_imports = "StdExternalCrate"
19+
# Format type annotations
20+
format_code_in_doc_comments = true
21+
# Format doc comments
22+
doc_comment_code_block_width = 100
23+
# Format comments
24+
comment_width = 100
25+
wrap_comments = true

.github/workflows/CI.yml

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
name: CI
2+
env:
3+
DEBUG: napi:*
4+
APP_NAME: logger
5+
MACOSX_DEPLOYMENT_TARGET: "10.13"
6+
permissions:
7+
contents: write
8+
id-token: write
9+
"on":
10+
push:
11+
branches:
12+
- main
13+
tags-ignore:
14+
- "**"
15+
paths-ignore:
16+
- "**/*.md"
17+
- LICENSE
18+
- "**/*.gitignore"
19+
- .editorconfig
20+
- docs/**
21+
pull_request: null
22+
jobs:
23+
build:
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
settings:
28+
- host: macos-latest
29+
target: x86_64-apple-darwin
30+
build: pnpm build --target x86_64-apple-darwin
31+
- host: windows-latest
32+
build: pnpm build --target x86_64-pc-windows-msvc
33+
target: x86_64-pc-windows-msvc
34+
- host: ubuntu-latest
35+
target: x86_64-unknown-linux-gnu
36+
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian
37+
build: pnpm build --target x86_64-unknown-linux-gnu
38+
name: stable - ${{ matrix.settings.target }} - node@20
39+
runs-on: ${{ matrix.settings.host }}
40+
steps:
41+
- uses: actions/checkout@v4
42+
- name: Install pnpm
43+
uses: pnpm/action-setup@v4
44+
- name: Use Node.js ${{ matrix.node-version }}
45+
uses: actions/setup-node@v4
46+
if: ${{ !matrix.settings.docker }}
47+
with:
48+
node-version: ${{ matrix.node-version }}
49+
cache: "pnpm"
50+
- name: Install
51+
uses: dtolnay/rust-toolchain@stable
52+
if: ${{ !matrix.settings.docker }}
53+
with:
54+
toolchain: stable
55+
targets: ${{ matrix.settings.target }}
56+
- name: Cache cargo
57+
uses: actions/cache@v4
58+
with:
59+
path: |
60+
~/.cargo/registry/index/
61+
~/.cargo/registry/cache/
62+
~/.cargo/git/db/
63+
.cargo-cache
64+
target/
65+
key: ${{ matrix.settings.target }}-cargo-${{ matrix.settings.host }}
66+
- uses: goto-bus-stop/setup-zig@v2
67+
if: ${{ matrix.settings.target == 'armv7-unknown-linux-gnueabihf' || matrix.settings.target == 'armv7-unknown-linux-musleabihf' }}
68+
with:
69+
version: 0.13.0
70+
- name: Setup toolchain
71+
run: ${{ matrix.settings.setup }}
72+
if: ${{ matrix.settings.setup }}
73+
shell: bash
74+
- name: Setup node x86
75+
if: matrix.settings.target == 'i686-pc-windows-msvc'
76+
run: pnpm config set supportedArchitectures.cpu "ia32"
77+
shell: bash
78+
- name: Install dependencies
79+
run: pnpm install
80+
- name: Setup node x86
81+
uses: actions/setup-node@v4
82+
if: matrix.settings.target == 'i686-pc-windows-msvc'
83+
with:
84+
node-version: 20
85+
cache: pnpm
86+
architecture: x86
87+
- name: Build in docker
88+
uses: addnab/docker-run-action@v3
89+
if: ${{ matrix.settings.docker }}
90+
with:
91+
image: ${{ matrix.settings.docker }}
92+
options: "--user 0:0 -v ${{ github.workspace }}/.cargo-cache/git/db:/usr/local/cargo/git/db -v ${{ github.workspace }}/.cargo/registry/cache:/usr/local/cargo/registry/cache -v ${{ github.workspace }}/.cargo/registry/index:/usr/local/cargo/registry/index -v ${{ github.workspace }}:/build -w /build"
93+
run: ${{ matrix.settings.build }}
94+
- name: Build
95+
run: ${{ matrix.settings.build }}
96+
if: ${{ !matrix.settings.docker }}
97+
shell: bash
98+
- name: Upload artifact
99+
uses: actions/upload-artifact@v4
100+
with:
101+
name: bindings-${{ matrix.settings.target }}
102+
path: ${{ env.APP_NAME }}.*.node
103+
if-no-files-found: error
104+
publish:
105+
name: Publish
106+
runs-on: ubuntu-latest
107+
steps:
108+
- uses: actions/checkout@v4
109+
- name: Install pnpm
110+
uses: pnpm/action-setup@v4
111+
- name: Use Node.js ${{ matrix.node-version }}
112+
uses: actions/setup-node@v4
113+
if: ${{ !matrix.settings.docker }}
114+
with:
115+
node-version: ${{ matrix.node-version }}
116+
cache: "pnpm"
117+
- name: Install dependencies
118+
run: pnpm install
119+
- name: Download all artifacts
120+
uses: actions/download-artifact@v4
121+
with:
122+
path: artifacts
123+
- name: Move artifacts
124+
run: pnpm artifacts
125+
- name: List packages
126+
run: ls -R ./npm
127+
shell: bash
128+
- name: Publish
129+
run: |
130+
npm config set provenance true
131+
if git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+$";
132+
then
133+
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
134+
npm publish --access public
135+
elif git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+";
136+
then
137+
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
138+
npm publish --tag next --access public
139+
else
140+
echo "Not a release, skipping publish"
141+
fi
142+
env:
143+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
144+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

.gitignore

Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
# Created by https://www.toptal.com/developers/gitignore/api/node
2+
# Edit at https://www.toptal.com/developers/gitignore?templates=node
3+
4+
### Node ###
5+
# Logs
6+
logs
7+
*.log
8+
npm-debug.log*
9+
yarn-debug.log*
10+
yarn-error.log*
11+
lerna-debug.log*
12+
13+
# Diagnostic reports (https://nodejs.org/api/report.html)
14+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
15+
16+
# Runtime data
17+
pids
18+
*.pid
19+
*.seed
20+
*.pid.lock
21+
22+
# Directory for instrumented libs generated by jscoverage/JSCover
23+
lib-cov
24+
25+
# Coverage directory used by tools like istanbul
26+
coverage
27+
*.lcov
28+
29+
# nyc test coverage
30+
.nyc_output
31+
32+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
33+
.grunt
34+
35+
# Bower dependency directory (https://bower.io/)
36+
bower_components
37+
38+
# node-waf configuration
39+
.lock-wscript
40+
41+
# Compiled binary addons (https://nodejs.org/api/addons.html)
42+
build/Release
43+
44+
# Dependency directories
45+
node_modules/
46+
jspm_packages/
47+
48+
# TypeScript v1 declaration files
49+
typings/
50+
51+
# TypeScript cache
52+
*.tsbuildinfo
53+
54+
# Optional npm cache directory
55+
.npm
56+
57+
# Optional eslint cache
58+
.eslintcache
59+
60+
# Microbundle cache
61+
.rpt2_cache/
62+
.rts2_cache_cjs/
63+
.rts2_cache_es/
64+
.rts2_cache_umd/
65+
66+
# Optional REPL history
67+
.node_repl_history
68+
69+
# Output of 'npm pack'
70+
*.tgz
71+
72+
# Yarn Integrity file
73+
.yarn-integrity
74+
75+
# dotenv environment variables file
76+
.env
77+
.env.test
78+
79+
# parcel-bundler cache (https://parceljs.org/)
80+
.cache
81+
82+
# Next.js build output
83+
.next
84+
85+
# Nuxt.js build / generate output
86+
.nuxt
87+
dist
88+
89+
# Gatsby files
90+
.cache/
91+
# Comment in the public line in if your project uses Gatsby and not Next.js
92+
# https://nextjs.org/blog/next-9-1#public-directory-support
93+
# public
94+
95+
# vuepress build output
96+
.vuepress/dist
97+
98+
# Serverless directories
99+
.serverless/
100+
101+
# FuseBox cache
102+
.fusebox/
103+
104+
# DynamoDB Local files
105+
.dynamodb/
106+
107+
# TernJS port file
108+
.tern-port
109+
110+
# Stores VSCode versions used for testing VSCode extensions
111+
.vscode-test
112+
113+
# End of https://www.toptal.com/developers/gitignore/api/node
114+
115+
# Created by https://www.toptal.com/developers/gitignore/api/macos
116+
# Edit at https://www.toptal.com/developers/gitignore?templates=macos
117+
118+
### macOS ###
119+
# General
120+
.DS_Store
121+
.AppleDouble
122+
.LSOverride
123+
124+
# Icon must end with two
125+
Icon
126+
127+
128+
# Thumbnails
129+
._*
130+
131+
# Files that might appear in the root of a volume
132+
.DocumentRevisions-V100
133+
.fseventsd
134+
.Spotlight-V100
135+
.TemporaryItems
136+
.Trashes
137+
.VolumeIcon.icns
138+
.com.apple.timemachine.donotpresent
139+
140+
# Directories potentially created on remote AFP share
141+
.AppleDB
142+
.AppleDesktop
143+
Network Trash Folder
144+
Temporary Items
145+
.apdisk
146+
147+
### macOS Patch ###
148+
# iCloud generated files
149+
*.icloud
150+
151+
# End of https://www.toptal.com/developers/gitignore/api/macos
152+
153+
# Created by https://www.toptal.com/developers/gitignore/api/windows
154+
# Edit at https://www.toptal.com/developers/gitignore?templates=windows
155+
156+
### Windows ###
157+
# Windows thumbnail cache files
158+
Thumbs.db
159+
Thumbs.db:encryptable
160+
ehthumbs.db
161+
ehthumbs_vista.db
162+
163+
# Dump file
164+
*.stackdump
165+
166+
# Folder config file
167+
[Dd]esktop.ini
168+
169+
# Recycle Bin used on file shares
170+
$RECYCLE.BIN/
171+
172+
# Windows Installer files
173+
*.cab
174+
*.msi
175+
*.msix
176+
*.msm
177+
*.msp
178+
179+
# Windows shortcuts
180+
*.lnk
181+
182+
# End of https://www.toptal.com/developers/gitignore/api/windows
183+
184+
#Added by cargo
185+
186+
/target
187+
Cargo.lock
188+
189+
.pnp.*
190+
.yarn/*
191+
!.yarn/patches
192+
!.yarn/plugins
193+
!.yarn/releases
194+
!.yarn/sdks
195+
!.yarn/versions
196+
197+
*.node
198+
index.js
199+
index.d.ts

.npmignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
target
2+
Cargo.lock
3+
.cargo
4+
.github
5+
npm
6+
.eslintrc
7+
.prettierignore
8+
rustfmt.toml
9+
yarn.lock
10+
*.node
11+
.yarn
12+
__test__
13+
renovate.json

0 commit comments

Comments
 (0)