-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(split): Split code to publish on crates.io x-win package to make…
… usable on rust project
- Loading branch information
1 parent
d49d350
commit 9b403a1
Showing
47 changed files
with
1,128 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
name: Build & Test & publich Rust package "x-win" | ||
|
||
env: | ||
APP_NAME: x-win | ||
MACOSX_DEPLOYMENT_TARGET: '10.13' | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
tags-ignore: | ||
- '**' | ||
paths-ignore: | ||
- '**/*.md' | ||
- LICENSE | ||
- '**/*.gitignore' | ||
- .editorconfig | ||
- docs/** | ||
pull_request: null | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
build-n-test: | ||
defaults: | ||
run: | ||
working-directory: ./x-win-rs | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
settings: | ||
# Build matrix for MacOS (x64) | ||
- host: macos-latest | ||
target: x86_64-apple-darwin | ||
|
||
# Build matrix for MacOS (arm64) | ||
- host: macos-latest | ||
target: aarch64-apple-darwin | ||
|
||
# Build matrix for Windows (x64) | ||
- host: windows-latest | ||
target: x86_64-pc-windows-msvc | ||
|
||
# Build matrix for Windows (x32) | ||
- host: windows-latest | ||
target: i686-pc-windows-msvc | ||
architecture: 'x86' | ||
|
||
# Build matrix for Windows (arm64) | ||
- host: windows-latest | ||
target: aarch64-pc-windows-msvc | ||
|
||
# Build for linux (using Ubuntu) (x64) | ||
- host: ubuntu-latest | ||
target: x86_64-unknown-linux-gnu | ||
|
||
# Build for linux (using Ubuntu) (x64) | ||
- host: ubuntu-latest | ||
target: x86_64-unknown-linux-musl | ||
|
||
name: stable - ${{ matrix.settings.target }} | ||
runs-on: ${{ matrix.settings.host }} | ||
steps: | ||
# Add actions/checkout | ||
- uses: actions/checkout@v4 | ||
|
||
# Install lib dev required for compilation of the project | ||
- name: (Linux) Install libx11 & libxcb for building | ||
if: ${{ matrix.settings.host == 'ubuntu-latest' }} | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y libx11-dev libxcb-ewmh-dev libxcb-randr0-dev | ||
# Install Rust version | ||
- name: Install Rust | ||
if: ${{ !matrix.settings.docker }} | ||
uses: dtolnay/rust-toolchain@stable | ||
with: | ||
toolchain: stable | ||
targets: ${{ matrix.settings.target }} | ||
|
||
# Set Cache cargo | ||
- name: Cache cargo | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/.cargo/registry/index/ | ||
~/.cargo/registry/cache/ | ||
~/.cargo/git/db/ | ||
.cargo-cache | ||
target/ | ||
key: ${{ matrix.settings.target }}-cargo-${{ matrix.settings.host }} | ||
|
||
# Lint Rust code | ||
- name: Lint | ||
run: cargo fmt -- --check | ||
|
||
# Check clippy code | ||
- name: Clippy | ||
run: cargo clippy -- -D warnings | ||
|
||
- name: Build | ||
run: cargo build --release --target ${{ matrix.settings.target }} | ||
|
||
- name: Open finder to have an active window (MacOS) | ||
if: ${{ matrix.settings.host == 'macos-latest' }} | ||
run: open . | ||
|
||
- name: Open explorer to have an active window (windows) | ||
if: ${{ matrix.settings.host == 'windows-latest' }} | ||
run: explorer . | ||
|
||
- name: Test | ||
if: ${{ matrix.settings.host != 'ubuntu-latest' }} | ||
run: cargo test | ||
|
||
# Upload artifact for the next steps (macos and test) | ||
- name: Upload artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: build-${{ matrix.settings.target }} | ||
path: target | ||
if-no-files-found: error | ||
|
||
|
||
|
||
publish: | ||
defaults: | ||
run: | ||
working-directory: ./x-win-rs | ||
if: ${{ github.event_name == 'release' && github.ref_type == 'tag' }} | ||
name: Publish ${{ github.ref_name }} (${{ github.ref }}) | ||
runs-on: ubuntu-latest | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | ||
TAG: ${{ github.ref_name }} | ||
needs: | ||
- build-n-test | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
# Install Rust version | ||
- name: Install Rust | ||
uses: dtolnay/rust-toolchain@stable | ||
with: | ||
toolchain: stable | ||
|
||
- name: Publish package | ||
run: cargo publish |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
cd x-win-rs && cargo fmt -- --check && cargo clippy -- -D warnings && cargo test | ||
cargo fmt -- --check | ||
cargo clippy -- -D warnings | ||
yarn test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
[package] | ||
edition = "2021" | ||
name = "x-win" | ||
version = "1.6.0" | ||
name = "x-win-napi" | ||
version = "0.0.0" | ||
authors = ["BENKHADRA Hocine <[email protected]>"] | ||
keywords = ["window", "active", "current", "position", "title", "list", "open"] | ||
description = "This package allows you to retrieve precise information about active and open windows on Windows, MacOS, and Linux. You can obtain the position, size, title, and other memory of windows." | ||
|
@@ -12,48 +12,14 @@ crate-type = ["cdylib"] | |
|
||
[dependencies] | ||
# Default enable napi4 feature, see https://nodejs.org/api/n-api.html#node-api-version-matrix | ||
napi = { version = "2.16.8", default-features = false, features = ["napi4", "async"] } | ||
napi-derive = "2.16.8" | ||
napi = { version = "2.16.8", default-features = false, features = [ | ||
"napi4", | ||
"async", | ||
] } | ||
napi-derive = "2.16.9" | ||
once_cell = "1.19.0" | ||
base64 = "0.22.1" | ||
|
||
[target.'cfg(target_os = "windows")'.dependencies] | ||
windows = { version = "0.58.0", features = [ | ||
"Win32_Foundation", | ||
"Win32_UI_WindowsAndMessaging", | ||
"Win32_System_Threading", | ||
"Win32_Storage_FileSystem", | ||
"Win32_System_ProcessStatus", | ||
"Win32_System_StationsAndDesktops", | ||
"Win32_UI_Input_KeyboardAndMouse", | ||
"Win32_Graphics_Dwm", | ||
"UI_UIAutomation", | ||
"Win32_System_Com", | ||
"Win32_UI_Accessibility", | ||
"Win32_System_Ole", | ||
"Win32_UI_Shell_PropertiesSystem", | ||
"Win32_UI_Shell_Common", | ||
"Win32_System_Variant", | ||
"Win32_Graphics_Gdi", | ||
"Win32_Graphics_Imaging" | ||
]} | ||
png = "0.17.13" | ||
|
||
[target.'cfg(target_os = "linux")'.dependencies] | ||
xcb = { version = "1.4.0" } | ||
x11 = { version = "2.21.0", features = ["xlib"], optional = true } | ||
zbus = { version = "1.9.2" } | ||
serde_json = { version = "1.0.117" } | ||
image = "0.25.1" | ||
|
||
[target.'cfg(target_os = "macos")'.dependencies] | ||
cocoa = "0.25.0" | ||
libc = "0.2.155" | ||
cocoa-foundation = "0.1.2" | ||
core-foundation = "0.9.4" | ||
core-foundation-sys = "0.8.6" | ||
core-graphics = "0.23.2" | ||
objc = "0.2.7" | ||
x-win = { path = "./x-win-rs" } | ||
|
||
[build-dependencies] | ||
napi-build = "2.1.3" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,12 +42,15 @@ | |
], | ||
"devDependencies": { | ||
"@napi-rs/cli": "^2.18.3", | ||
"ava": "^6.1.3" | ||
"ava": "^6.1.3", | ||
"husky": "^9.1.4" | ||
}, | ||
"ava": { | ||
"timeout": "3m", | ||
"failFast": true, | ||
"files": ["__test__/**/*.mjs"] | ||
"files": [ | ||
"__test__/**/*.mjs" | ||
] | ||
}, | ||
"engines": { | ||
"node": ">= 14" | ||
|
@@ -59,7 +62,8 @@ | |
"prepublishOnly": "napi prepublish -t npm", | ||
"test": "ava", | ||
"universal": "napi universal", | ||
"version": "napi version" | ||
"version": "napi version", | ||
"prepare": "husky" | ||
}, | ||
"packageManager": "[email protected]" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
#![deny(unused_imports)] | ||
|
||
pub mod thread; | ||
pub mod x_win_struct; | ||
pub mod api; | ||
pub mod thread; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
#![deny(unused_imports)] | ||
|
||
pub mod usage_info; | ||
pub mod icon_info; | ||
pub mod process_info; | ||
pub mod window_position; | ||
pub mod usage_info; | ||
pub mod window_info; | ||
pub mod icon_info; | ||
pub mod window_position; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.