diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..a94b667 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,15 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_size = 2 +indent_style = space +insert_final_newline = true +trim_trailing_whitespace = true + +[*.bat] +end_of_line = crlf + +[*.rs] +indent_size = 4 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..75a4320 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +native/target +native/index.node +prebuilds/ +**/node_modules +**/.DS_Store +.idea +npm-debug.log* diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..d631121 --- /dev/null +++ b/.npmignore @@ -0,0 +1,6 @@ +native/target +native/index.node +**/*~ +.github +.vscode +.idea diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..1ab8fe5 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,10 @@ +{ + "arrowParens": "avoid", + "bracketSameLine": true, + "endOfLine": "lf", + "jsxSingleQuote": true, + "printWidth": 100, + "semi": false, + "singleQuote": true, + "trailingComma": "all" +} diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..fa3fa22 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2024 Travis Collins + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..175c871 --- /dev/null +++ b/README.md @@ -0,0 +1,11 @@ +# @shieldbattery/windows-registry + +A Rust/neon-based node.js native module for accessing and modifying the Windows Registry. + +## OS Support + +Currently we only publish builds for x64, and require Windows 10+. + +## License + +MIT diff --git a/native/Cargo.lock b/native/Cargo.lock new file mode 100644 index 0000000..c399fa8 --- /dev/null +++ b/native/Cargo.lock @@ -0,0 +1,163 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "anyhow" +version = "1.0.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "libloading" +version = "0.6.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "351a32417a12d5f7e82c368a66781e307834dae04c6ce0cd4456d52989229883" +dependencies = [ + "cfg-if", + "winapi", +] + +[[package]] +name = "native" +version = "0.1.0" +dependencies = [ + "anyhow", + "neon", +] + +[[package]] +name = "neon" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28e15415261d880aed48122e917a45e87bb82cf0260bb6db48bbab44b7464373" +dependencies = [ + "neon-build", + "neon-macros", + "neon-runtime", + "semver", + "smallvec", +] + +[[package]] +name = "neon-build" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8bac98a702e71804af3dacfde41edde4a16076a7bbe889ae61e56e18c5b1c811" + +[[package]] +name = "neon-macros" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7288eac8b54af7913c60e0eb0e2a7683020dffa342ab3fd15e28f035ba897cf" +dependencies = [ + "quote", + "syn", + "syn-mid", +] + +[[package]] +name = "neon-runtime" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4676720fa8bb32c64c3d9f49c47a47289239ec46b4bdb66d0913cc512cb0daca" +dependencies = [ + "cfg-if", + "libloading", + "smallvec", +] + +[[package]] +name = "proc-macro2" +version = "1.0.76" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95fc56cda0b5c3325f5fbbd7ff9fda9e02bb00bb3dac51252d2f1bfa1cb8cc8c" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "semver" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +dependencies = [ + "semver-parser", +] + +[[package]] +name = "semver-parser" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" + +[[package]] +name = "smallvec" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2593d31f82ead8df961d8bd23a64c2ccf2eb5dd34b0a34bfb4dd54011c72009e" + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn-mid" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fea305d57546cc8cd04feb14b62ec84bf17f50e3f7b12560d7bfa9265f39d9ed" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/native/Cargo.toml b/native/Cargo.toml new file mode 100644 index 0000000..4585165 --- /dev/null +++ b/native/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = "native" +version = "0.1.0" +description = "A Rust/neon-based node.js native module for accessing and modifying the Windows registry." +license = "MIT" +edition = "2021" +exclude = ["index.node"] + +[lib] +crate-type = ["cdylib"] + +[dependencies] +anyhow = "1.0" + +[dependencies.neon] +version = "0.10" +default-features = false +features = ["napi-6", "promise-api", "channel-api"] diff --git a/native/src/lib.rs b/native/src/lib.rs new file mode 100644 index 0000000..9fd52d6 --- /dev/null +++ b/native/src/lib.rs @@ -0,0 +1,11 @@ +use neon::prelude::*; + +fn hello(mut cx: FunctionContext) -> JsResult { + Ok(cx.string("hello node")) +} + +#[neon::main] +fn main(mut cx: ModuleContext) -> NeonResult<()> { + cx.export_function("hello", hello)?; + Ok(()) +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..7f6ed6e --- /dev/null +++ b/package.json @@ -0,0 +1,31 @@ +{ + "name": "windows-registry", + "version": "1.0.0", + "description": "A Rust/neon-based node.js native module for accessing and modifying the Windows registry.", + "main": "index.js", + "scripts": { + "build": "cd native && cargo-cp-artifact -nc index.node -- cargo build --target=x86_64-pc-windows-msvc --message-format=json-render-diagnostics", + "build-debug": "npm run build --", + "build-release": "npm run build -- --release", + "tag-prebuild": "node ./tag-prebuild.js", + "test": "cd native && cargo test" + }, + "keywords": [ + "windows", + "registry" + ], + "author": "Travis Collins (http://tec27.com)", + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/ShieldBattery/windows-registry.git" + }, + "bugs": { + "url": "https://github.com/ShieldBattery/windows-registry/issues" + }, + "homepage": "https://github.com/ShieldBattery/windows-registry#readme", + "devDependencies": { + "cargo-cp-artifact": "^0.1.8", + "neon-tag-prebuild": "^1.1.1" + } +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml new file mode 100644 index 0000000..50b613f --- /dev/null +++ b/pnpm-lock.yaml @@ -0,0 +1,45 @@ +lockfileVersion: '6.0' + +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false + +devDependencies: + cargo-cp-artifact: + specifier: ^0.1.8 + version: 0.1.8 + neon-tag-prebuild: + specifier: ^1.1.1 + version: 1.1.1 + +packages: + + /cargo-cp-artifact@0.1.8: + resolution: {integrity: sha512-3j4DaoTrsCD1MRkTF2Soacii0Nx7UHCce0EwUf4fHnggwiE4fbmF2AbnfzayR36DF8KGadfh7M/Yfy625kgPlA==} + hasBin: true + dev: true + + /mkdirp@1.0.4: + resolution: {integrity: sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==} + engines: {node: '>=10'} + hasBin: true + dev: true + + /neon-tag-prebuild@1.1.1: + resolution: {integrity: sha512-uZlQlOAMl4XlR98rbp1Y0JlvP3phJ5X6qfdinEhvI+HFHVieaE5cPk2k38u7LCbcVyYcVmMac3yW5YS+wES3DQ==} + hasBin: true + dependencies: + mkdirp: 1.0.4 + node-abi: 2.30.1 + dev: true + + /node-abi@2.30.1: + resolution: {integrity: sha512-/2D0wOQPgaUWzVSVgRMx+trKJRC2UG4SUc4oCJoXx9Uxjtp0Vy3/kt7zcbxHF8+Z/pK3UloLWzBISg72brfy1w==} + dependencies: + semver: 5.7.2 + dev: true + + /semver@5.7.2: + resolution: {integrity: sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==} + hasBin: true + dev: true