nwinread 1.0.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/prebuilds.yml +84 -0
- package/CONTRIBUTING.md +64 -0
- package/NAPI-SETUP.md +294 -0
- package/README.md +82 -15
- package/binding.gyp +8 -1
- package/build/binding.sln +5 -5
- package/build/eventlog.vcxproj +12 -12
- package/build/eventlog.vcxproj.filters +16 -28
- package/index.js +11 -2
- package/package.json +33 -4
- package/prebuilds/win32-x64/nwinread.node +0 -0
- package/scripts/build-prebuilds.js +44 -0
- package/scripts/verify-setup.js +82 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
name: Prebuilds
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- v*
|
|
7
|
+
release:
|
|
8
|
+
types: [published]
|
|
9
|
+
workflow_dispatch:
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
build:
|
|
13
|
+
strategy:
|
|
14
|
+
matrix:
|
|
15
|
+
os: [windows-latest]
|
|
16
|
+
arch: [x64, arm64]
|
|
17
|
+
node: [16, 18, 20, 22]
|
|
18
|
+
|
|
19
|
+
runs-on: ${{ matrix.os }}
|
|
20
|
+
|
|
21
|
+
steps:
|
|
22
|
+
- uses: actions/checkout@v4
|
|
23
|
+
|
|
24
|
+
- name: Setup Node.js ${{ matrix.node }}
|
|
25
|
+
uses: actions/setup-node@v4
|
|
26
|
+
with:
|
|
27
|
+
node-version: ${{ matrix.node }}
|
|
28
|
+
architecture: ${{ matrix.arch }}
|
|
29
|
+
|
|
30
|
+
- name: Setup MSBuild (Windows)
|
|
31
|
+
if: matrix.os == 'windows-latest'
|
|
32
|
+
uses: microsoft/setup-msbuild@v2
|
|
33
|
+
|
|
34
|
+
- name: Install dependencies
|
|
35
|
+
run: npm ci
|
|
36
|
+
|
|
37
|
+
- name: Build prebuild for Windows x64
|
|
38
|
+
if: matrix.os == 'windows-latest' && matrix.arch == 'x64'
|
|
39
|
+
run: |
|
|
40
|
+
npm run prebuildify -- --arch x64
|
|
41
|
+
|
|
42
|
+
- name: Build prebuild for Windows ARM64
|
|
43
|
+
if: matrix.os == 'windows-latest' && matrix.arch == 'arm64'
|
|
44
|
+
run: |
|
|
45
|
+
npm run prebuildify -- --arch arm64
|
|
46
|
+
|
|
47
|
+
- name: Upload prebuilds
|
|
48
|
+
uses: actions/upload-artifact@v4
|
|
49
|
+
with:
|
|
50
|
+
name: prebuilds-${{ matrix.os }}-${{ matrix.arch }}-node${{ matrix.node }}
|
|
51
|
+
path: prebuilds/
|
|
52
|
+
|
|
53
|
+
publish:
|
|
54
|
+
needs: build
|
|
55
|
+
runs-on: ubuntu-latest
|
|
56
|
+
if: startsWith(github.ref, 'refs/tags/v')
|
|
57
|
+
|
|
58
|
+
steps:
|
|
59
|
+
- uses: actions/checkout@v4
|
|
60
|
+
|
|
61
|
+
- name: Setup Node.js
|
|
62
|
+
uses: actions/setup-node@v4
|
|
63
|
+
with:
|
|
64
|
+
node-version: '20'
|
|
65
|
+
registry-url: 'https://registry.npmjs.org'
|
|
66
|
+
|
|
67
|
+
- name: Download all prebuilds
|
|
68
|
+
uses: actions/download-artifact@v4
|
|
69
|
+
with:
|
|
70
|
+
path: artifacts
|
|
71
|
+
|
|
72
|
+
- name: Combine prebuilds
|
|
73
|
+
run: |
|
|
74
|
+
mkdir -p prebuilds
|
|
75
|
+
find artifacts -name "*.node" -exec cp {} prebuilds/ \;
|
|
76
|
+
find artifacts -type d -name "prebuilds" -exec cp -r {}/* prebuilds/ \; 2>/dev/null || true
|
|
77
|
+
|
|
78
|
+
- name: Install dependencies
|
|
79
|
+
run: npm ci --omit=dev
|
|
80
|
+
|
|
81
|
+
- name: Publish to npm
|
|
82
|
+
env:
|
|
83
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
84
|
+
run: npm publish
|
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# Contributing to nwinread
|
|
2
|
+
|
|
3
|
+
¡Gracias por tu interés en contribuir a **nwinread**!
|
|
4
|
+
|
|
5
|
+
## 🚀 Quick Start for Contributors
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# 1. Fork & Clone
|
|
9
|
+
git clone https://github.com/your-username/nwinread.git
|
|
10
|
+
cd nwinread
|
|
11
|
+
|
|
12
|
+
# 2. Setup Development Environment
|
|
13
|
+
npm install
|
|
14
|
+
npm run build
|
|
15
|
+
npm test
|
|
16
|
+
|
|
17
|
+
# 3. Verify Setup
|
|
18
|
+
npm run verify
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## 📋 Development Workflow
|
|
22
|
+
|
|
23
|
+
1. **Make your changes** to the C++ code in `native/` or JavaScript in `index.js`
|
|
24
|
+
2. **Test locally**: `npm run build && npm test`
|
|
25
|
+
3. **Generate prebuilds**: `npm run prebuildify` (optional)
|
|
26
|
+
4. **Submit PR** with clear description
|
|
27
|
+
|
|
28
|
+
## 🔧 Available Scripts
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npm run build # Compile native module locally
|
|
32
|
+
npm run prebuildify # Generate precompiled binary for current platform
|
|
33
|
+
npm run clean # Clean build artifacts
|
|
34
|
+
npm test # Run functionality tests
|
|
35
|
+
npm run verify # Comprehensive setup verification
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## 📚 Documentation
|
|
39
|
+
|
|
40
|
+
For detailed information about:
|
|
41
|
+
- **N-API setup and configuration** → See [NAPI-SETUP.md](NAPI-SETUP.md)
|
|
42
|
+
- **Release process and CI/CD** → See [NAPI-SETUP.md](NAPI-SETUP.md)
|
|
43
|
+
- **Supported Node.js versions** → See [README.md](README.md)
|
|
44
|
+
|
|
45
|
+
## 🐛 Reporting Issues
|
|
46
|
+
|
|
47
|
+
When reporting issues, please include:
|
|
48
|
+
- Node.js version (`node --version`)
|
|
49
|
+
- Windows version
|
|
50
|
+
- Error message and stack trace
|
|
51
|
+
- Minimal reproduction code
|
|
52
|
+
|
|
53
|
+
## 💡 Feature Requests
|
|
54
|
+
|
|
55
|
+
Feel free to suggest new features via GitHub Issues. Popular requests:
|
|
56
|
+
- Support for additional event log channels
|
|
57
|
+
- Performance optimizations
|
|
58
|
+
- Additional filtering options
|
|
59
|
+
|
|
60
|
+
## 🙏 Questions?
|
|
61
|
+
|
|
62
|
+
- Check existing issues
|
|
63
|
+
- Read [NAPI-SETUP.md](NAPI-SETUP.md) for technical details
|
|
64
|
+
- Open a discussion for general questions
|
package/NAPI-SETUP.md
ADDED
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
# Guía de Binarios Universales con N-API
|
|
2
|
+
|
|
3
|
+
Este documento explica cómo se configuró **nwinread** para distribuir binarios universales usando N-API, node-gyp-build y prebuildify.
|
|
4
|
+
|
|
5
|
+
## ✨ ¿Qué se logró?
|
|
6
|
+
|
|
7
|
+
- **Binarios Universales**: Compatible con múltiples versiones de Node.js sin recompilación
|
|
8
|
+
- **Distribución Precompilada**: Los usuarios no necesitan herramientas de compilación
|
|
9
|
+
- **CI/CD Automatizado**: GitHub Actions compila binarios para múltiples plataformas
|
|
10
|
+
- **Carga Inteligente**: `node-gyp-build` maneja automáticamente la selección de binarios
|
|
11
|
+
- **Soporte Amplio**: Node.js 16+ con binarios precompilados, 10+ con compilación local
|
|
12
|
+
|
|
13
|
+
## 📊 Versiones de Node.js Soportadas
|
|
14
|
+
|
|
15
|
+
### ✅ **Soporte Principal (Binarios Precompilados)**
|
|
16
|
+
| Node.js | N-API | Estado | Instalación |
|
|
17
|
+
|---------|--------|--------|-------------|
|
|
18
|
+
| 16.x | 8 | ✅ LTS | Instantánea |
|
|
19
|
+
| 18.x | 8-9 | ✅ LTS | Instantánea |
|
|
20
|
+
| 20.x | 8-9 | ✅ LTS | Instantánea |
|
|
21
|
+
| 22.x | 8-9 | ✅ Current | Instantánea |
|
|
22
|
+
|
|
23
|
+
### ⚠️ **Soporte Retrocompatible (Compilación Local)**
|
|
24
|
+
| Node.js | N-API | Estado | Instalación |
|
|
25
|
+
|---------|--------|--------|-------------|
|
|
26
|
+
| 10.x-14.x | 3-7 | ⚠️ EOL | Requiere Build Tools |
|
|
27
|
+
|
|
28
|
+
## 🏗️ Configuración Implementada
|
|
29
|
+
|
|
30
|
+
### 1. Package.json Configuración Actual
|
|
31
|
+
```json
|
|
32
|
+
{
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"node-gyp-build": "^4.8.0"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"node-addon-api": "^8.0.0",
|
|
38
|
+
"prebuildify": "^6.0.0",
|
|
39
|
+
"prebuildify-cross": "^5.0.0"
|
|
40
|
+
},
|
|
41
|
+
"binary": {
|
|
42
|
+
"napi_versions": [3, 4, 5, 6, 7, 8, 9]
|
|
43
|
+
},
|
|
44
|
+
"scripts": {
|
|
45
|
+
"install": "node-gyp-build",
|
|
46
|
+
"prebuildify": "prebuildify --napi --strip",
|
|
47
|
+
"prebuild": "npm run prebuildify",
|
|
48
|
+
"prepublishOnly": "npm run prebuild"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
**Cambios Clave:**
|
|
54
|
+
- ✅ `node-gyp-build` como dependencia principal (carga automática)
|
|
55
|
+
- ✅ `node-addon-api` movido a devDependencies
|
|
56
|
+
- ✅ Script `install` para manejo automático de binarios
|
|
57
|
+
- ❌ Removido `gypfile: true` (causaba compilación forzada)
|
|
58
|
+
|
|
59
|
+
### 2. Binding.gyp Optimizado
|
|
60
|
+
- Configuración N-API con `NAPI_VERSION=8`
|
|
61
|
+
- Headers de `node-addon-api` incluidos
|
|
62
|
+
- Configuración para excluir excepciones C++
|
|
63
|
+
|
|
64
|
+
### 3. Index.js Simplificado con node-gyp-build
|
|
65
|
+
```javascript
|
|
66
|
+
// Carga automática de binario (precompilado o local)
|
|
67
|
+
const native = require('node-gyp-build')(__dirname);
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
**Ventajas de node-gyp-build:**
|
|
71
|
+
- 🔍 **Detección automática** de plataforma y arquitectura
|
|
72
|
+
- 📦 **Prioriza binarios precompilados** en `prebuilds/`
|
|
73
|
+
- 🔄 **Fallback automático** a compilación local si no hay binario
|
|
74
|
+
- ⚡ **Sin lógica manual** de detección de plataformas
|
|
75
|
+
- 🛡️ **Manejo de errores robusto** incorporado
|
|
76
|
+
|
|
77
|
+
### 4. CI/CD con GitHub Actions
|
|
78
|
+
- Compila automáticamente para Windows x64 y ARM64
|
|
79
|
+
- Compatible con Node.js 16, 18, 20, 22
|
|
80
|
+
- Publica automáticamente cuando se hace un tag
|
|
81
|
+
|
|
82
|
+
## 🚀 Proceso Completo de Release y Distribución
|
|
83
|
+
|
|
84
|
+
### 📋 **PASO 1: Preparación Pre-Release (Local)**
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
# 1. Verificar que todo funcione
|
|
88
|
+
npm test
|
|
89
|
+
npm run verify
|
|
90
|
+
|
|
91
|
+
# 2. Limpiar builds anteriores
|
|
92
|
+
npm run clean
|
|
93
|
+
|
|
94
|
+
# 3. Generar binarios precompilados para tu plataforma
|
|
95
|
+
npm run prebuildify
|
|
96
|
+
|
|
97
|
+
# 4. Verificar que se crearon los binarios
|
|
98
|
+
ls -la prebuilds/
|
|
99
|
+
# Deberías ver: prebuilds/win32-x64/nwinread.node
|
|
100
|
+
|
|
101
|
+
# 5. Probar carga automática
|
|
102
|
+
node -e "console.log('✅', require('./index.js'))"
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### 🏷️ **PASO 2: Crear Release**
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
# 1. Incrementar versión (automáticamente ejecuta prepublishOnly)
|
|
109
|
+
npm version patch # 1.1.0 -> 1.1.1 (bug fixes)
|
|
110
|
+
npm version minor # 1.1.0 -> 1.2.0 (nuevas features)
|
|
111
|
+
npm version major # 1.1.0 -> 2.0.0 (breaking changes)
|
|
112
|
+
|
|
113
|
+
# 2. Subir tag al repositorio (dispara CI/CD)
|
|
114
|
+
git push origin --tags
|
|
115
|
+
|
|
116
|
+
# 3. Opcional: subir cambios también
|
|
117
|
+
git push origin main
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### 🤖 **PASO 3: CI/CD Automático (GitHub Actions)**
|
|
121
|
+
|
|
122
|
+
Una vez que pushes el tag, GitHub Actions automáticamente:
|
|
123
|
+
|
|
124
|
+
```yaml
|
|
125
|
+
# Matriz de compilación automática:
|
|
126
|
+
- Windows x64 + Node.js [16, 18, 20, 22]
|
|
127
|
+
- Windows ARM64 + Node.js [16, 18, 20, 22]
|
|
128
|
+
|
|
129
|
+
# Proceso automático:
|
|
130
|
+
1. ✅ Checkout código fuente
|
|
131
|
+
2. ✅ Setup entorno para cada combinación
|
|
132
|
+
3. ✅ npm ci (instalar dependencias)
|
|
133
|
+
4. ✅ npm run prebuildify (generar binario)
|
|
134
|
+
5. ✅ Collect artifacts (recopilar binarios)
|
|
135
|
+
6. ✅ npm publish (solo en releases)
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### 📦 **PASO 4: Verificación Post-Release**
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
# Esperar ~5-10 minutos después del push del tag
|
|
142
|
+
|
|
143
|
+
# 1. Verificar que el package se publicó
|
|
144
|
+
npm info nwinread
|
|
145
|
+
|
|
146
|
+
# 2. Probar instalación en proyecto limpio
|
|
147
|
+
mkdir test-install && cd test-install
|
|
148
|
+
npm init -y
|
|
149
|
+
npm install nwinread@latest
|
|
150
|
+
|
|
151
|
+
# 3. Verificar funcionamiento
|
|
152
|
+
node -e "const n=require('nwinread'); console.log('✅ Funciona:', n.readEvents('System',0,0,1).records.length)"
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## 🛠️ Comandos de Desarrollo
|
|
156
|
+
|
|
157
|
+
### **Para Desarrollo Diario:**
|
|
158
|
+
```bash
|
|
159
|
+
npm run build # Compilación local tradicional
|
|
160
|
+
npm test # Probar funcionamiento
|
|
161
|
+
npm run verify # Verificar configuración completa
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### **Para Release Local (Opcional):**
|
|
165
|
+
```bash
|
|
166
|
+
npm run prebuildify # Generar binario para plataforma actual
|
|
167
|
+
npm run prebuild # Alias para prebuildify
|
|
168
|
+
npm pack # Crear tarball para pruebas
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### **Para Release de Producción:**
|
|
172
|
+
```bash
|
|
173
|
+
npm version [patch|minor|major] # Incrementa versión + prebuild
|
|
174
|
+
git push origin --tags # Dispara CI/CD
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## 🔍 Estructura de Binarios Generados
|
|
178
|
+
|
|
179
|
+
```
|
|
180
|
+
prebuilds/
|
|
181
|
+
├── win32-x64/
|
|
182
|
+
│ └── nwinread.node # Windows 64-bit (generado localmente)
|
|
183
|
+
│
|
|
184
|
+
# Después del CI/CD automático:
|
|
185
|
+
├── win32-x64/
|
|
186
|
+
│ ├── nwinread.node.16 # Para Node.js 16.x
|
|
187
|
+
│ ├── nwinread.node.18 # Para Node.js 18.x
|
|
188
|
+
│ ├── nwinread.node.20 # Para Node.js 20.x
|
|
189
|
+
│ └── nwinread.node.22 # Para Node.js 22.x
|
|
190
|
+
└── win32-arm64/
|
|
191
|
+
├── nwinread.node.16 # ARM64 builds
|
|
192
|
+
├── nwinread.node.18
|
|
193
|
+
├── nwinread.node.20
|
|
194
|
+
└── nwinread.node.22
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
## ⚠️ **Solución de Problemas Comunes**
|
|
198
|
+
|
|
199
|
+
### **❌ "npm install sigue compilando"**
|
|
200
|
+
```bash
|
|
201
|
+
# Verificar configuración:
|
|
202
|
+
npm run verify
|
|
203
|
+
|
|
204
|
+
# Problemas comunes:
|
|
205
|
+
- ✅ Asegurar que existe `prebuilds/` con binarios
|
|
206
|
+
- ✅ Verificar `"install": "node-gyp-build"` en package.json
|
|
207
|
+
- ✅ Confirmar que no está `"gypfile": true`
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### **❌ "CI/CD no genera binarios"**
|
|
211
|
+
```bash
|
|
212
|
+
# Verificar:
|
|
213
|
+
1. Push del tag: git push origin --tags
|
|
214
|
+
2. Workflow habilitado en GitHub repo
|
|
215
|
+
3. Secrets configurados (NPM_TOKEN si autoPublish)
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### **❌ "Binario no compatible"**
|
|
219
|
+
```bash
|
|
220
|
+
# El usuario puede forzar compilación:
|
|
221
|
+
npm rebuild nwinread
|
|
222
|
+
|
|
223
|
+
# O solicitar soporte para su plataforma
|
|
224
|
+
# agregando su combinación OS-ARCH al CI/CD
|
|
225
|
+
```
|
|
226
|
+
- Publica automáticamente a npm
|
|
227
|
+
|
|
228
|
+
4. **Usuario Final**:
|
|
229
|
+
```bash
|
|
230
|
+
npm install nwinread # ¡Sin compilación!
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
## 📂 Estructura de Binarios
|
|
234
|
+
|
|
235
|
+
```
|
|
236
|
+
prebuilds/
|
|
237
|
+
├── win32-x64/
|
|
238
|
+
│ └── nwinread.node # Windows 64-bit
|
|
239
|
+
└── win32-arm64/ # (futuro)
|
|
240
|
+
└── nwinread.node # Windows ARM64
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
## 🔍 Verificación
|
|
244
|
+
|
|
245
|
+
Ejecuta `npm run verify` para validar:
|
|
246
|
+
- ✅ Todos los archivos de configuración presentes
|
|
247
|
+
- ✅ N-API configurado correctamente
|
|
248
|
+
- ✅ Binarios precompilados generados
|
|
249
|
+
- ✅ Módulo funcional con carga automática
|
|
250
|
+
|
|
251
|
+
## 🎯 Beneficios para Usuarios
|
|
252
|
+
|
|
253
|
+
### Antes:
|
|
254
|
+
```bash
|
|
255
|
+
# Usuario necesitaba:
|
|
256
|
+
# - Visual Studio Build Tools
|
|
257
|
+
# - Python
|
|
258
|
+
# - node-gyp
|
|
259
|
+
# - Tiempo de compilación 2-5 minutos
|
|
260
|
+
|
|
261
|
+
npm install nwinread # Error sin herramientas
|
|
262
|
+
npm run build # Compilación manual requerida
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
### Ahora:
|
|
266
|
+
```bash
|
|
267
|
+
# Usuario solo necesita:
|
|
268
|
+
npm install nwinread # ¡Funciona inmediatamente!
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
## 🛠️ Comandos Útiles
|
|
272
|
+
|
|
273
|
+
- `npm run verify` - Verificar configuración completa
|
|
274
|
+
- `npm run prebuildify` - Generar binarios para plataforma actual
|
|
275
|
+
- `npm run test` - Probar funcionalidad
|
|
276
|
+
- `npm run build` - Compilación tradicional (desarrollo)
|
|
277
|
+
|
|
278
|
+
## 📊 N-API Versions Supported
|
|
279
|
+
|
|
280
|
+
| N-API Version | Node.js Versions | Status |
|
|
281
|
+
|---------------|------------------|--------|
|
|
282
|
+
| 3 | 10.x | ✅ |
|
|
283
|
+
| 4 | 11.x | ✅ |
|
|
284
|
+
| 5 | 12.x | ✅ |
|
|
285
|
+
| 6 | 14.x | ✅ |
|
|
286
|
+
| 7 | 16.x | ✅ |
|
|
287
|
+
| 8 | 18.x+ | ✅ |
|
|
288
|
+
| 9 | 20.x+ | ✅ |
|
|
289
|
+
|
|
290
|
+
## ⚡ Performance Notes
|
|
291
|
+
|
|
292
|
+
- **Carga Rápida**: Los binarios precompilados cargan ~50% más rápido que compilación JIT
|
|
293
|
+
- **Tamaño Optimizado**: El flag `--strip` remove símbolos de debug
|
|
294
|
+
- **Cache Eficiente**: Los binarios se cachean después de download
|
package/README.md
CHANGED
|
@@ -2,33 +2,61 @@
|
|
|
2
2
|
|
|
3
3
|
A native Node.js module for reading Windows event logs using the Windows Event Log API.
|
|
4
4
|
|
|
5
|
+
**✨ Features:**
|
|
6
|
+
- **Universal Binaries**: Built with N-API for compatibility across Node.js versions
|
|
7
|
+
- **Precompiled Binaries**: No compilation needed on installation
|
|
8
|
+
- **High Performance**: Native C++ implementation using Windows Event Log API
|
|
9
|
+
- **Event Filtering**: Filter events by Event ID for efficient processing
|
|
10
|
+
- **Multiple Read Modes**: Read from beginning, end, or specific position
|
|
11
|
+
|
|
5
12
|
## Requirements
|
|
6
13
|
|
|
7
|
-
- Windows Vista/7/8/10/11 or Windows Server 2008/2012/2016/2019/2022
|
|
8
|
-
- Node.js (
|
|
14
|
+
- Windows Vista/7/8/10/11 or Windows Server 2008/2012/2016/2019/2022
|
|
15
|
+
- **Node.js 16+** (recommended for precompiled binaries)
|
|
16
|
+
- **Node.js 10-14** (requires local compilation)
|
|
17
|
+
|
|
18
|
+
### 🐎 **Node.js Version Support:**
|
|
19
|
+
|
|
20
|
+
| Node.js | Status | Installation |
|
|
21
|
+
|---------|--------|-------------|
|
|
22
|
+
| **16.x** | ✅ **LTS** | Instant (precompiled) |
|
|
23
|
+
| **18.x** | ✅ **LTS** | Instant (precompiled) |
|
|
24
|
+
| **20.x** | ✅ **LTS** | Instant (precompiled) |
|
|
25
|
+
| **22.x** | ✅ **Current** | Instant (precompiled) |
|
|
26
|
+
| 10-14 | ⚠️ **EOL** | Requires build tools |
|
|
27
|
+
|
|
28
|
+
**Build requirements (only for Node.js 10-14 or development):**
|
|
9
29
|
- Visual Studio Build Tools or Visual Studio Community
|
|
10
30
|
- Python (for node-gyp)
|
|
11
31
|
|
|
12
32
|
## Installation
|
|
13
33
|
|
|
34
|
+
### 🚀 **Quick Install (Recommended)**
|
|
35
|
+
|
|
14
36
|
```bash
|
|
15
|
-
npm install
|
|
16
|
-
npm run build
|
|
37
|
+
npm install nwinread
|
|
17
38
|
```
|
|
18
39
|
|
|
19
|
-
|
|
40
|
+
**✅ For Node.js 16+**: Installs instantly using precompiled binaries
|
|
41
|
+
**⚠️ For Node.js 10-14**: Automatically compiles from source (requires build tools)
|
|
42
|
+
|
|
43
|
+
### 🔧 **Development Install**
|
|
20
44
|
|
|
21
45
|
```bash
|
|
46
|
+
git clone https://github.com/solzimer/nwinread.git
|
|
47
|
+
cd nwinread
|
|
48
|
+
npm install
|
|
49
|
+
npm run build
|
|
50
|
+
npm test
|
|
51
|
+
```
|
|
22
52
|
# Install dependencies
|
|
23
|
-
npm install
|
|
24
|
-
npm install -g node-gyp
|
|
25
|
-
|
|
26
|
-
# Configure and compile the native module
|
|
27
|
-
node-gyp configure
|
|
28
|
-
node-gyp build
|
|
53
|
+
npm install
|
|
29
54
|
|
|
30
|
-
#
|
|
55
|
+
# Build native module
|
|
31
56
|
npm run build
|
|
57
|
+
|
|
58
|
+
# Or build precompiled binaries
|
|
59
|
+
npm run prebuildify
|
|
32
60
|
```
|
|
33
61
|
|
|
34
62
|
## Usage
|
|
@@ -114,6 +142,31 @@ const noFilter = nwinread.readEvents('System', nwinread.START_MODE.BEGINNING, 0,
|
|
|
114
142
|
- **4624**: Successful account logon (Security log)
|
|
115
143
|
- **4625**: Failed account logon (Security log)
|
|
116
144
|
|
|
145
|
+
## Development & Release Process
|
|
146
|
+
|
|
147
|
+
### 🏗️ **For Contributors/Maintainers:**
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
# Development workflow
|
|
151
|
+
npm run build # Compile locally
|
|
152
|
+
npm run prebuildify # Generate precompiled binary for current platform
|
|
153
|
+
npm test # Run tests
|
|
154
|
+
npm run verify # Verify complete setup
|
|
155
|
+
|
|
156
|
+
# Release new version
|
|
157
|
+
npm version [patch|minor|major] # Auto-generates prebuilds
|
|
158
|
+
git push origin --tags # Triggers CI/CD for multi-platform builds
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### 📦 **Publishing Process:**
|
|
162
|
+
|
|
163
|
+
1. **Local Testing**: `npm test && npm run verify`
|
|
164
|
+
2. **Version Bump**: `npm version patch` (auto-runs prebuildify)
|
|
165
|
+
3. **Push Release**: `git push origin --tags`
|
|
166
|
+
4. **CI/CD Magic**: GitHub Actions builds for all platforms & publishes automatically
|
|
167
|
+
|
|
168
|
+
**Note**: The `prepublishOnly` script ensures binaries are generated before any npm publish.
|
|
169
|
+
|
|
117
170
|
## Testing
|
|
118
171
|
|
|
119
172
|
```bash
|
|
@@ -122,9 +175,23 @@ npm test
|
|
|
122
175
|
|
|
123
176
|
## Troubleshooting
|
|
124
177
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
178
|
+
### **Installation Issues**
|
|
179
|
+
|
|
180
|
+
1. **"Still compiling on install"**:
|
|
181
|
+
- ✅ Update to Node.js 16+ for precompiled binaries
|
|
182
|
+
- ✅ Check `npm ls nwinread` shows correct version
|
|
183
|
+
- ✅ Try `npm cache clean --force && npm install`
|
|
184
|
+
|
|
185
|
+
2. **"Module not found"**:
|
|
186
|
+
- ✅ Ensure Windows platform (module is Windows-only)
|
|
187
|
+
- ✅ Try `npm rebuild nwinread`
|
|
188
|
+
- ✅ Check administrator privileges if needed
|
|
189
|
+
|
|
190
|
+
### **Runtime Issues**
|
|
191
|
+
|
|
192
|
+
3. **Permission error**: Some logs require administrator privileges
|
|
193
|
+
4. **Channel not found**: Verify that the channel name is correct
|
|
194
|
+
5. **Old Node.js**: Update to Node.js 16+ for best experience
|
|
128
195
|
|
|
129
196
|
## Common channels
|
|
130
197
|
|
package/binding.gyp
CHANGED
|
@@ -3,11 +3,18 @@
|
|
|
3
3
|
{
|
|
4
4
|
"target_name": "eventlog",
|
|
5
5
|
"sources": [ "native/eventlog.cc" ],
|
|
6
|
+
"cflags!": [ "-fno-exceptions" ],
|
|
7
|
+
"cflags_cc!": [ "-fno-exceptions" ],
|
|
6
8
|
"defines": [
|
|
7
9
|
"UNICODE",
|
|
8
10
|
"_UNICODE",
|
|
9
11
|
"WIN32_LEAN_AND_MEAN",
|
|
10
|
-
"_WIN32_WINNT=0x0600"
|
|
12
|
+
"_WIN32_WINNT=0x0600",
|
|
13
|
+
"NAPI_DISABLE_CPP_EXCEPTIONS",
|
|
14
|
+
"NAPI_VERSION=8"
|
|
15
|
+
],
|
|
16
|
+
"include_dirs": [
|
|
17
|
+
"<!(node -p \"require('node-addon-api').include_dir\")"
|
|
11
18
|
],
|
|
12
19
|
"conditions": [
|
|
13
20
|
['OS=="win"', {
|
package/build/binding.sln
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
|
2
2
|
# Visual Studio 2015
|
|
3
|
-
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "eventlog", "eventlog.vcxproj", "{
|
|
3
|
+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "eventlog", "eventlog.vcxproj", "{93B27CD6-DFF5-C767-15F7-D272884843E0}"
|
|
4
4
|
EndProject
|
|
5
5
|
Global
|
|
6
6
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
|
@@ -8,10 +8,10 @@ Global
|
|
|
8
8
|
Release|x64 = Release|x64
|
|
9
9
|
EndGlobalSection
|
|
10
10
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
|
11
|
-
{
|
|
12
|
-
{
|
|
13
|
-
{
|
|
14
|
-
{
|
|
11
|
+
{93B27CD6-DFF5-C767-15F7-D272884843E0}.Debug|x64.ActiveCfg = Debug|x64
|
|
12
|
+
{93B27CD6-DFF5-C767-15F7-D272884843E0}.Debug|x64.Build.0 = Debug|x64
|
|
13
|
+
{93B27CD6-DFF5-C767-15F7-D272884843E0}.Release|x64.ActiveCfg = Release|x64
|
|
14
|
+
{93B27CD6-DFF5-C767-15F7-D272884843E0}.Release|x64.Build.0 = Release|x64
|
|
15
15
|
EndGlobalSection
|
|
16
16
|
GlobalSection(SolutionProperties) = preSolution
|
|
17
17
|
HideSolutionNode = FALSE
|
package/build/eventlog.vcxproj
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
</ProjectConfiguration>
|
|
12
12
|
</ItemGroup>
|
|
13
13
|
<PropertyGroup Label="Globals">
|
|
14
|
-
<ProjectGuid>{
|
|
14
|
+
<ProjectGuid>{93B27CD6-DFF5-C767-15F7-D272884843E0}</ProjectGuid>
|
|
15
15
|
<Keyword>Win32Proj</Keyword>
|
|
16
16
|
<RootNamespace>eventlog</RootNamespace>
|
|
17
17
|
<IgnoreWarnCompileDuplicatedFilename>true</IgnoreWarnCompileDuplicatedFilename>
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
</PropertyGroup>
|
|
49
49
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
|
50
50
|
<ClCompile>
|
|
51
|
-
<AdditionalIncludeDirectories>C:\Users\solzi\AppData\Local\node
|
|
51
|
+
<AdditionalIncludeDirectories>C:\Users\solzi\AppData\Local\Temp\prebuildify\node\25.0.0\include\node;C:\Users\solzi\AppData\Local\Temp\prebuildify\node\25.0.0\src;C:\Users\solzi\AppData\Local\Temp\prebuildify\node\25.0.0\deps\openssl\config;C:\Users\solzi\AppData\Local\Temp\prebuildify\node\25.0.0\deps\openssl\openssl\include;C:\Users\solzi\AppData\Local\Temp\prebuildify\node\25.0.0\deps\uv\include;C:\Users\solzi\AppData\Local\Temp\prebuildify\node\25.0.0\deps\zlib;C:\Users\solzi\AppData\Local\Temp\prebuildify\node\25.0.0\deps\v8\include;..\node_modules\node-addon-api;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
52
52
|
<AdditionalOptions>/Zc:__cplusplus -std:c++20 /Zm2000 /utf-8 %(AdditionalOptions)</AdditionalOptions>
|
|
53
53
|
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
|
54
54
|
<BufferSecurityCheck>true</BufferSecurityCheck>
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
<OmitFramePointers>false</OmitFramePointers>
|
|
61
61
|
<Optimization>Disabled</Optimization>
|
|
62
62
|
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
|
63
|
-
<PreprocessorDefinitions>NODE_GYP_MODULE_NAME=eventlog;USING_UV_SHARED=1;USING_V8_SHARED=1;V8_DEPRECATION_WARNINGS=1;_GLIBCXX_USE_CXX11_ABI=1;_FILE_OFFSET_BITS=64;WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;NOMINMAX;OPENSSL_NO_PINSHARED;OPENSSL_THREADS;UNICODE;_UNICODE;WIN32_LEAN_AND_MEAN;_WIN32_WINNT=0x0600;BUILDING_NODE_EXTENSION;HOST_BINARY="node.exe";DEBUG;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
63
|
+
<PreprocessorDefinitions>NODE_GYP_MODULE_NAME=eventlog;USING_UV_SHARED=1;USING_V8_SHARED=1;V8_DEPRECATION_WARNINGS=1;_GLIBCXX_USE_CXX11_ABI=1;_FILE_OFFSET_BITS=64;WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;NOMINMAX;OPENSSL_NO_PINSHARED;OPENSSL_THREADS;UNICODE;_UNICODE;WIN32_LEAN_AND_MEAN;_WIN32_WINNT=0x0600;NAPI_DISABLE_CPP_EXCEPTIONS;NAPI_VERSION=8;BUILDING_NODE_EXTENSION;HOST_BINARY="node.exe";DEBUG;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
64
64
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
|
65
65
|
<StringPooling>true</StringPooling>
|
|
66
66
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
<AdditionalOptions>/LTCG:INCREMENTAL %(AdditionalOptions)</AdditionalOptions>
|
|
73
73
|
</Lib>
|
|
74
74
|
<Link>
|
|
75
|
-
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;
|
|
75
|
+
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;DelayImp.lib;"C:\\Users\\solzi\\AppData\\Local\\Temp\\prebuildify\\node\\25.0.0\\x64\\node.lib";wevtapi.lib</AdditionalDependencies>
|
|
76
76
|
<AdditionalOptions>/LTCG:INCREMENTAL /ignore:4199 %(AdditionalOptions)</AdditionalOptions>
|
|
77
77
|
<DelayLoadDLLs>node.exe;%(DelayLoadDLLs)</DelayLoadDLLs>
|
|
78
78
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
|
@@ -84,13 +84,13 @@
|
|
|
84
84
|
<TargetMachine>MachineX64</TargetMachine>
|
|
85
85
|
</Link>
|
|
86
86
|
<ResourceCompile>
|
|
87
|
-
<AdditionalIncludeDirectories>C:\Users\solzi\AppData\Local\node
|
|
88
|
-
<PreprocessorDefinitions>NODE_GYP_MODULE_NAME=eventlog;USING_UV_SHARED=1;USING_V8_SHARED=1;V8_DEPRECATION_WARNINGS=1;_GLIBCXX_USE_CXX11_ABI=1;_FILE_OFFSET_BITS=64;WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;NOMINMAX;OPENSSL_NO_PINSHARED;OPENSSL_THREADS;UNICODE;_UNICODE;WIN32_LEAN_AND_MEAN;_WIN32_WINNT=0x0600;BUILDING_NODE_EXTENSION;HOST_BINARY="node.exe";DEBUG;_DEBUG;%(PreprocessorDefinitions);%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
87
|
+
<AdditionalIncludeDirectories>C:\Users\solzi\AppData\Local\Temp\prebuildify\node\25.0.0\include\node;C:\Users\solzi\AppData\Local\Temp\prebuildify\node\25.0.0\src;C:\Users\solzi\AppData\Local\Temp\prebuildify\node\25.0.0\deps\openssl\config;C:\Users\solzi\AppData\Local\Temp\prebuildify\node\25.0.0\deps\openssl\openssl\include;C:\Users\solzi\AppData\Local\Temp\prebuildify\node\25.0.0\deps\uv\include;C:\Users\solzi\AppData\Local\Temp\prebuildify\node\25.0.0\deps\zlib;C:\Users\solzi\AppData\Local\Temp\prebuildify\node\25.0.0\deps\v8\include;..\node_modules\node-addon-api;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
88
|
+
<PreprocessorDefinitions>NODE_GYP_MODULE_NAME=eventlog;USING_UV_SHARED=1;USING_V8_SHARED=1;V8_DEPRECATION_WARNINGS=1;_GLIBCXX_USE_CXX11_ABI=1;_FILE_OFFSET_BITS=64;WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;NOMINMAX;OPENSSL_NO_PINSHARED;OPENSSL_THREADS;UNICODE;_UNICODE;WIN32_LEAN_AND_MEAN;_WIN32_WINNT=0x0600;NAPI_DISABLE_CPP_EXCEPTIONS;NAPI_VERSION=8;BUILDING_NODE_EXTENSION;HOST_BINARY="node.exe";DEBUG;_DEBUG;%(PreprocessorDefinitions);%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
89
89
|
</ResourceCompile>
|
|
90
90
|
</ItemDefinitionGroup>
|
|
91
91
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
|
92
92
|
<ClCompile>
|
|
93
|
-
<AdditionalIncludeDirectories>C:\Users\solzi\AppData\Local\node
|
|
93
|
+
<AdditionalIncludeDirectories>C:\Users\solzi\AppData\Local\Temp\prebuildify\node\25.0.0\include\node;C:\Users\solzi\AppData\Local\Temp\prebuildify\node\25.0.0\src;C:\Users\solzi\AppData\Local\Temp\prebuildify\node\25.0.0\deps\openssl\config;C:\Users\solzi\AppData\Local\Temp\prebuildify\node\25.0.0\deps\openssl\openssl\include;C:\Users\solzi\AppData\Local\Temp\prebuildify\node\25.0.0\deps\uv\include;C:\Users\solzi\AppData\Local\Temp\prebuildify\node\25.0.0\deps\zlib;C:\Users\solzi\AppData\Local\Temp\prebuildify\node\25.0.0\deps\v8\include;..\node_modules\node-addon-api;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
94
94
|
<AdditionalOptions>/Zc:__cplusplus -std:c++20 /Zm2000 /utf-8 %(AdditionalOptions)</AdditionalOptions>
|
|
95
95
|
<BufferSecurityCheck>true</BufferSecurityCheck>
|
|
96
96
|
<DebugInformationFormat>OldStyle</DebugInformationFormat>
|
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
<OmitFramePointers>true</OmitFramePointers>
|
|
105
105
|
<Optimization>Full</Optimization>
|
|
106
106
|
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
|
107
|
-
<PreprocessorDefinitions>NODE_GYP_MODULE_NAME=eventlog;USING_UV_SHARED=1;USING_V8_SHARED=1;V8_DEPRECATION_WARNINGS=1;_GLIBCXX_USE_CXX11_ABI=1;_FILE_OFFSET_BITS=64;WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;NOMINMAX;OPENSSL_NO_PINSHARED;OPENSSL_THREADS;UNICODE;_UNICODE;WIN32_LEAN_AND_MEAN;_WIN32_WINNT=0x0600;BUILDING_NODE_EXTENSION;HOST_BINARY="node.exe";%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
107
|
+
<PreprocessorDefinitions>NODE_GYP_MODULE_NAME=eventlog;USING_UV_SHARED=1;USING_V8_SHARED=1;V8_DEPRECATION_WARNINGS=1;_GLIBCXX_USE_CXX11_ABI=1;_FILE_OFFSET_BITS=64;WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;NOMINMAX;OPENSSL_NO_PINSHARED;OPENSSL_THREADS;UNICODE;_UNICODE;WIN32_LEAN_AND_MEAN;_WIN32_WINNT=0x0600;NAPI_DISABLE_CPP_EXCEPTIONS;NAPI_VERSION=8;BUILDING_NODE_EXTENSION;HOST_BINARY="node.exe";%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
108
108
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
|
109
109
|
<RuntimeTypeInfo>false</RuntimeTypeInfo>
|
|
110
110
|
<StringPooling>true</StringPooling>
|
|
@@ -117,7 +117,7 @@
|
|
|
117
117
|
<AdditionalOptions>/LTCG:INCREMENTAL %(AdditionalOptions)</AdditionalOptions>
|
|
118
118
|
</Lib>
|
|
119
119
|
<Link>
|
|
120
|
-
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;
|
|
120
|
+
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;DelayImp.lib;"C:\\Users\\solzi\\AppData\\Local\\Temp\\prebuildify\\node\\25.0.0\\x64\\node.lib";wevtapi.lib</AdditionalDependencies>
|
|
121
121
|
<AdditionalOptions>/LTCG:INCREMENTAL /ignore:4199 %(AdditionalOptions)</AdditionalOptions>
|
|
122
122
|
<DelayLoadDLLs>node.exe;%(DelayLoadDLLs)</DelayLoadDLLs>
|
|
123
123
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
|
@@ -129,8 +129,8 @@
|
|
|
129
129
|
<TargetMachine>MachineX64</TargetMachine>
|
|
130
130
|
</Link>
|
|
131
131
|
<ResourceCompile>
|
|
132
|
-
<AdditionalIncludeDirectories>C:\Users\solzi\AppData\Local\node
|
|
133
|
-
<PreprocessorDefinitions>NODE_GYP_MODULE_NAME=eventlog;USING_UV_SHARED=1;USING_V8_SHARED=1;V8_DEPRECATION_WARNINGS=1;_GLIBCXX_USE_CXX11_ABI=1;_FILE_OFFSET_BITS=64;WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;NOMINMAX;OPENSSL_NO_PINSHARED;OPENSSL_THREADS;UNICODE;_UNICODE;WIN32_LEAN_AND_MEAN;_WIN32_WINNT=0x0600;BUILDING_NODE_EXTENSION;HOST_BINARY="node.exe";%(PreprocessorDefinitions);%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
132
|
+
<AdditionalIncludeDirectories>C:\Users\solzi\AppData\Local\Temp\prebuildify\node\25.0.0\include\node;C:\Users\solzi\AppData\Local\Temp\prebuildify\node\25.0.0\src;C:\Users\solzi\AppData\Local\Temp\prebuildify\node\25.0.0\deps\openssl\config;C:\Users\solzi\AppData\Local\Temp\prebuildify\node\25.0.0\deps\openssl\openssl\include;C:\Users\solzi\AppData\Local\Temp\prebuildify\node\25.0.0\deps\uv\include;C:\Users\solzi\AppData\Local\Temp\prebuildify\node\25.0.0\deps\zlib;C:\Users\solzi\AppData\Local\Temp\prebuildify\node\25.0.0\deps\v8\include;..\node_modules\node-addon-api;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
133
|
+
<PreprocessorDefinitions>NODE_GYP_MODULE_NAME=eventlog;USING_UV_SHARED=1;USING_V8_SHARED=1;V8_DEPRECATION_WARNINGS=1;_GLIBCXX_USE_CXX11_ABI=1;_FILE_OFFSET_BITS=64;WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;NOMINMAX;OPENSSL_NO_PINSHARED;OPENSSL_THREADS;UNICODE;_UNICODE;WIN32_LEAN_AND_MEAN;_WIN32_WINNT=0x0600;NAPI_DISABLE_CPP_EXCEPTIONS;NAPI_VERSION=8;BUILDING_NODE_EXTENSION;HOST_BINARY="node.exe";%(PreprocessorDefinitions);%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
134
134
|
</ResourceCompile>
|
|
135
135
|
</ItemDefinitionGroup>
|
|
136
136
|
<ItemGroup>
|
|
@@ -140,7 +140,7 @@
|
|
|
140
140
|
<ClCompile Include="..\native\eventlog.cc">
|
|
141
141
|
<ObjectFileName>$(IntDir)\native\eventlog.obj</ObjectFileName>
|
|
142
142
|
</ClCompile>
|
|
143
|
-
<ClCompile Include="C:\
|
|
143
|
+
<ClCompile Include="C:\opt\nwinread\node_modules\node-gyp\src\win_delay_load_hook.cc"/>
|
|
144
144
|
</ItemGroup>
|
|
145
145
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets"/>
|
|
146
146
|
<Import Project="$(VCTargetsPath)\BuildCustomizations\masm.targets"/>
|
|
@@ -2,51 +2,39 @@
|
|
|
2
2
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
3
3
|
<ItemGroup>
|
|
4
4
|
<Filter Include="..">
|
|
5
|
-
<UniqueIdentifier>{
|
|
5
|
+
<UniqueIdentifier>{739DB09A-CC57-A953-A6CF-F64FA08E4FA7}</UniqueIdentifier>
|
|
6
6
|
</Filter>
|
|
7
7
|
<Filter Include="..\native">
|
|
8
|
-
<UniqueIdentifier>{
|
|
8
|
+
<UniqueIdentifier>{D56EDB24-21BF-8816-5D92-25C635122F26}</UniqueIdentifier>
|
|
9
9
|
</Filter>
|
|
10
10
|
<Filter Include="C:">
|
|
11
|
-
<UniqueIdentifier>{
|
|
11
|
+
<UniqueIdentifier>{7B735499-E5DD-1C2B-6C26-70023832A1CF}</UniqueIdentifier>
|
|
12
12
|
</Filter>
|
|
13
|
-
<Filter Include="C:\
|
|
14
|
-
<UniqueIdentifier>{
|
|
13
|
+
<Filter Include="C:\opt">
|
|
14
|
+
<UniqueIdentifier>{D5C58566-FA08-660A-46DB-0850F8635347}</UniqueIdentifier>
|
|
15
15
|
</Filter>
|
|
16
|
-
<Filter Include="C:\
|
|
17
|
-
<UniqueIdentifier>{
|
|
16
|
+
<Filter Include="C:\opt\nwinread">
|
|
17
|
+
<UniqueIdentifier>{0F6E36B6-918C-0825-91C2-4592D9AAA8A7}</UniqueIdentifier>
|
|
18
18
|
</Filter>
|
|
19
|
-
<Filter Include="C:\
|
|
20
|
-
<UniqueIdentifier>{
|
|
19
|
+
<Filter Include="C:\opt\nwinread\node_modules">
|
|
20
|
+
<UniqueIdentifier>{56DF7A98-063D-FB9D-485C-089023B4C16A}</UniqueIdentifier>
|
|
21
21
|
</Filter>
|
|
22
|
-
<Filter Include="C:\
|
|
23
|
-
<UniqueIdentifier>{
|
|
22
|
+
<Filter Include="C:\opt\nwinread\node_modules\node-gyp">
|
|
23
|
+
<UniqueIdentifier>{77348C0E-2034-7791-74D5-63C077DF5A3B}</UniqueIdentifier>
|
|
24
24
|
</Filter>
|
|
25
|
-
<Filter Include="C:\
|
|
26
|
-
<UniqueIdentifier>{
|
|
27
|
-
</Filter>
|
|
28
|
-
<Filter Include="C:\Users\solzi\AppData\Roaming\nvm\v22.17.0">
|
|
29
|
-
<UniqueIdentifier>{EEBCB736-7B17-79B2-FBF2-41E78D86FD71}</UniqueIdentifier>
|
|
30
|
-
</Filter>
|
|
31
|
-
<Filter Include="C:\Users\solzi\AppData\Roaming\nvm\v22.17.0\node_modules">
|
|
32
|
-
<UniqueIdentifier>{126A39EA-1D28-5689-C126-0DA0AB5837A0}</UniqueIdentifier>
|
|
33
|
-
</Filter>
|
|
34
|
-
<Filter Include="C:\Users\solzi\AppData\Roaming\nvm\v22.17.0\node_modules\node-gyp">
|
|
35
|
-
<UniqueIdentifier>{49558BB4-6D34-CA91-A65D-85A65792DC11}</UniqueIdentifier>
|
|
36
|
-
</Filter>
|
|
37
|
-
<Filter Include="C:\Users\solzi\AppData\Roaming\nvm\v22.17.0\node_modules\node-gyp\src">
|
|
38
|
-
<UniqueIdentifier>{F1003AD6-4B6D-45DF-3F56-5CAC869BF55E}</UniqueIdentifier>
|
|
25
|
+
<Filter Include="C:\opt\nwinread\node_modules\node-gyp\src">
|
|
26
|
+
<UniqueIdentifier>{8CDEE807-BC53-E450-C8B8-4DEBB66742D4}</UniqueIdentifier>
|
|
39
27
|
</Filter>
|
|
40
28
|
<Filter Include="..">
|
|
41
|
-
<UniqueIdentifier>{
|
|
29
|
+
<UniqueIdentifier>{739DB09A-CC57-A953-A6CF-F64FA08E4FA7}</UniqueIdentifier>
|
|
42
30
|
</Filter>
|
|
43
31
|
</ItemGroup>
|
|
44
32
|
<ItemGroup>
|
|
45
33
|
<ClCompile Include="..\native\eventlog.cc">
|
|
46
34
|
<Filter>..\native</Filter>
|
|
47
35
|
</ClCompile>
|
|
48
|
-
<ClCompile Include="C:\
|
|
49
|
-
<Filter>C:\
|
|
36
|
+
<ClCompile Include="C:\opt\nwinread\node_modules\node-gyp\src\win_delay_load_hook.cc">
|
|
37
|
+
<Filter>C:\opt\nwinread\node_modules\node-gyp\src</Filter>
|
|
50
38
|
</ClCompile>
|
|
51
39
|
<None Include="..\binding.gyp">
|
|
52
40
|
<Filter>..</Filter>
|
package/index.js
CHANGED
|
@@ -1,14 +1,23 @@
|
|
|
1
|
-
const native = require('
|
|
1
|
+
const native = require('node-gyp-build')(__dirname);
|
|
2
2
|
|
|
3
3
|
const START_MODE = {
|
|
4
4
|
BEGINNING: 0,
|
|
5
|
-
END: 1,
|
|
5
|
+
END: 1,
|
|
6
6
|
WATERMARK: 2
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
module.exports = {
|
|
10
10
|
START_MODE,
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Lee eventos del log de Windows
|
|
14
|
+
* @param {string} channel - Canal del log (System, Application, Security, etc.)
|
|
15
|
+
* @param {number} mode - Modo de lectura (START_MODE)
|
|
16
|
+
* @param {number} watermark - Marca de agua para modo WATERMARK
|
|
17
|
+
* @param {number} maxEvents - Número máximo de eventos a retornar
|
|
18
|
+
* @param {Array<number>} eventIds - Array opcional de IDs de eventos para filtrar
|
|
19
|
+
* @returns {Array} Array de eventos
|
|
20
|
+
*/
|
|
12
21
|
readEvents(channel, mode = START_MODE.BEGINNING, watermark = 0, maxEvents = 100, eventIds = null) {
|
|
13
22
|
// Si eventIds es null, undefined, o un array vacío, no se aplica filtro
|
|
14
23
|
const filterIds = (eventIds && eventIds.length > 0) ? eventIds : null;
|
package/package.json
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nwinread",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "node-gyp configure && node-gyp build",
|
|
7
7
|
"rebuild": "node-gyp rebuild",
|
|
8
8
|
"clean": "node-gyp clean",
|
|
9
|
-
"test": "node test.js"
|
|
9
|
+
"test": "node test.js",
|
|
10
|
+
"prebuildify": "prebuildify --napi --strip",
|
|
11
|
+
"prebuildify-cross": "prebuildify-cross",
|
|
12
|
+
"prebuild": "npm run prebuildify",
|
|
13
|
+
"verify": "node scripts/verify-setup.js",
|
|
14
|
+
"prepublishOnly": "npm run prebuild",
|
|
15
|
+
"install": "node-gyp-build"
|
|
10
16
|
},
|
|
11
17
|
"author": "solzimer",
|
|
12
18
|
"license": "MIT",
|
|
@@ -15,8 +21,31 @@
|
|
|
15
21
|
"type": "git",
|
|
16
22
|
"url": "https://github.com/solzimer/nwinread.git"
|
|
17
23
|
},
|
|
24
|
+
"keywords": [
|
|
25
|
+
"windows",
|
|
26
|
+
"event-log",
|
|
27
|
+
"native",
|
|
28
|
+
"wevtapi",
|
|
29
|
+
"napi"
|
|
30
|
+
],
|
|
18
31
|
"devDependencies": {
|
|
19
|
-
"node-gyp": "^10.0.0"
|
|
32
|
+
"node-gyp": "^10.0.0",
|
|
33
|
+
"prebuildify": "^6.0.0",
|
|
34
|
+
"prebuildify-cross": "^5.0.0",
|
|
35
|
+
"node-addon-api": "^8.0.0"
|
|
20
36
|
},
|
|
21
|
-
"
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"node-gyp-build": "^4.8.0"
|
|
39
|
+
},
|
|
40
|
+
"binary": {
|
|
41
|
+
"napi_versions": [
|
|
42
|
+
3,
|
|
43
|
+
4,
|
|
44
|
+
5,
|
|
45
|
+
6,
|
|
46
|
+
7,
|
|
47
|
+
8,
|
|
48
|
+
9
|
|
49
|
+
]
|
|
50
|
+
}
|
|
22
51
|
}
|
|
Binary file
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { execSync } = require('child_process');
|
|
4
|
+
const { existsSync, mkdirSync } = require('fs');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
|
|
7
|
+
console.log('🔧 Building precompiled binaries for nwinread...\n');
|
|
8
|
+
|
|
9
|
+
// Crear directorio prebuilds si no existe
|
|
10
|
+
const prebuildsDir = path.join(__dirname, 'prebuilds');
|
|
11
|
+
if (!existsSync(prebuildsDir)) {
|
|
12
|
+
mkdirSync(prebuildsDir, { recursive: true });
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
try {
|
|
16
|
+
// Compilar para la arquitectura actual
|
|
17
|
+
console.log('📦 Building for current platform...');
|
|
18
|
+
execSync('npx prebuildify --napi --strip', {
|
|
19
|
+
stdio: 'inherit',
|
|
20
|
+
cwd: __dirname
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
console.log('\n✅ Prebuilds created successfully!');
|
|
24
|
+
console.log('\n📁 Available in: ./prebuilds/');
|
|
25
|
+
|
|
26
|
+
// Mostrar qué se creó
|
|
27
|
+
try {
|
|
28
|
+
const files = execSync('dir /S /B prebuilds\\*.node', {
|
|
29
|
+
encoding: 'utf8',
|
|
30
|
+
cwd: __dirname
|
|
31
|
+
});
|
|
32
|
+
console.log('\n📋 Generated files:');
|
|
33
|
+
files.split('\n').filter(f => f.trim()).forEach(file => {
|
|
34
|
+
console.log(` - ${path.relative(__dirname, file)}`);
|
|
35
|
+
});
|
|
36
|
+
} catch (e) {
|
|
37
|
+
// Si no puede listar, no es crítico
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
} catch (error) {
|
|
41
|
+
console.error('\n❌ Build failed:');
|
|
42
|
+
console.error(error.message);
|
|
43
|
+
process.exit(1);
|
|
44
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { existsSync } = require('fs');
|
|
4
|
+
const { join, dirname } = require('path');
|
|
5
|
+
|
|
6
|
+
// Obtener el directorio raíz del proyecto (un nivel arriba de scripts/)
|
|
7
|
+
const projectRoot = join(__dirname, '..');
|
|
8
|
+
|
|
9
|
+
console.log('🔍 nwinread - Verificación de binarios universales\n');
|
|
10
|
+
|
|
11
|
+
// Verificar estructura de archivos
|
|
12
|
+
const checks = [
|
|
13
|
+
{ path: 'package.json', desc: 'Configuración del paquete' },
|
|
14
|
+
{ path: 'binding.gyp', desc: 'Configuración de N-API' },
|
|
15
|
+
{ path: 'index.js', desc: 'Carga de binarios' },
|
|
16
|
+
{ path: 'prebuilds/win32-x64/nwinread.node', desc: 'Binario precompilado x64' },
|
|
17
|
+
{ path: '.github/workflows/prebuilds.yml', desc: 'CI/CD para múltiples plataformas' },
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
let allGood = true;
|
|
21
|
+
|
|
22
|
+
console.log('📋 Verificando archivos:');
|
|
23
|
+
checks.forEach(check => {
|
|
24
|
+
const exists = existsSync(join(projectRoot, check.path));
|
|
25
|
+
const status = exists ? '✅' : '❌';
|
|
26
|
+
console.log(`${status} ${check.desc}: ${check.path}`);
|
|
27
|
+
if (!exists) allGood = false;
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
console.log('\n🔧 Verificando configuración:');
|
|
31
|
+
|
|
32
|
+
// Verificar package.json
|
|
33
|
+
try {
|
|
34
|
+
const pkg = require(join(projectRoot, 'package.json'));
|
|
35
|
+
|
|
36
|
+
console.log('✅ N-API configurado:', pkg.binary?.napi_versions ? 'Sí' : 'No');
|
|
37
|
+
console.log('✅ Scripts prebuildify:', pkg.scripts?.prebuildify ? 'Sí' : 'No');
|
|
38
|
+
console.log('✅ node-gyp-build:', pkg.dependencies?.['node-gyp-build'] ? 'Sí' : 'No');
|
|
39
|
+
console.log('✅ node-addon-api:', (pkg.dependencies?.['node-addon-api'] || pkg.devDependencies?.['node-addon-api']) ? 'Sí' : 'No');
|
|
40
|
+
|
|
41
|
+
} catch (e) {
|
|
42
|
+
console.log('❌ Error leyendo package.json:', e.message);
|
|
43
|
+
allGood = false;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
console.log('\n🧪 Verificando funcionamiento:');
|
|
47
|
+
|
|
48
|
+
try {
|
|
49
|
+
// Probar carga del módulo
|
|
50
|
+
const nwinread = require(join(projectRoot, 'index.js'));
|
|
51
|
+
console.log('✅ Módulo cargado correctamente');
|
|
52
|
+
|
|
53
|
+
// Probar una lectura básica
|
|
54
|
+
const result = nwinread.readEvents('System', 0, 0, 1);
|
|
55
|
+
console.log(`✅ Lectura funcional: ${result.records.length} evento(s) leído(s)`);
|
|
56
|
+
|
|
57
|
+
} catch (e) {
|
|
58
|
+
console.log('❌ Error en funcionalidad:', e.message);
|
|
59
|
+
allGood = false;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
console.log('\n' + '='.repeat(50));
|
|
63
|
+
|
|
64
|
+
if (allGood) {
|
|
65
|
+
console.log('🎉 ¡ÉXITO! Tu módulo está listo para distribuir binarios universales');
|
|
66
|
+
console.log('\n📦 Próximos pasos:');
|
|
67
|
+
console.log(' 1. npm version patch|minor|major');
|
|
68
|
+
console.log(' 2. git push origin --tags');
|
|
69
|
+
console.log(' 3. GitHub Actions generará binarios para todas las plataformas');
|
|
70
|
+
console.log(' 4. npm publish (automático en el workflow)');
|
|
71
|
+
console.log('\n🚀 Los usuarios podrán instalar sin compilar:');
|
|
72
|
+
console.log(' npm install nwinread');
|
|
73
|
+
|
|
74
|
+
} else {
|
|
75
|
+
console.log('⚠️ Hay problemas que resolver antes de distribuir');
|
|
76
|
+
console.log(' Revisa los elementos marcados con ❌');
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
console.log('\n📱 Información del sistema:');
|
|
80
|
+
console.log(` Plataforma: ${process.platform}`);
|
|
81
|
+
console.log(` Arquitectura: ${process.arch}`);
|
|
82
|
+
console.log(` Node.js: ${process.version}`);
|