@mimersql/node-mimer 1.0.0 → 1.0.2
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/README.md +32 -48
- package/binding.gyp +66 -0
- package/lib/native.js +6 -23
- package/package.json +25 -3
- package/prebuilds/darwin-arm64/@mimersql+node-mimer.node +0 -0
- package/prebuilds/darwin-x64/@mimersql+node-mimer.node +0 -0
- package/prebuilds/linux-arm64/@mimersql+node-mimer.node +0 -0
- package/prebuilds/linux-x64/@mimersql+node-mimer.node +0 -0
- package/prebuilds/win32-x64/@mimersql+node-mimer.node +0 -0
- package/scripts/check-mimer.js +149 -0
- package/scripts/find-mimer-windows.js +179 -0
- package/src/connection.cc +473 -0
- package/src/connection.h +77 -0
- package/src/helpers.cc +440 -0
- package/src/helpers.h +79 -0
- package/src/mimer_addon.cc +49 -0
- package/src/resultset.cc +161 -0
- package/src/resultset.h +74 -0
- package/src/statement.cc +201 -0
- package/src/statement.h +74 -0
- package/lib/find-mimer-library.js +0 -154
- package/lib/koffi-binding.js +0 -970
package/README.md
CHANGED
|
@@ -4,8 +4,8 @@ Node.js driver for Mimer SQL using the Mimer SQL C API.
|
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
7
|
+
- Native C++ bindings to the Mimer SQL C API via Node-API — no ODBC required
|
|
8
|
+
- Prebuilt binaries for supported platforms — no compiler needed at install time
|
|
9
9
|
- Promise-based API
|
|
10
10
|
- Parameterized queries with `?` placeholders (SQL injection safe)
|
|
11
11
|
- Prepared statements for repeated execution
|
|
@@ -21,16 +21,16 @@ Node.js driver for Mimer SQL using the Mimer SQL C API.
|
|
|
21
21
|
- Node.js 18.0 or later
|
|
22
22
|
- Mimer SQL 11.0 or later installed (the `libmimerapi` shared library must be available)
|
|
23
23
|
|
|
24
|
-
No C++ compiler is required. The package uses Koffi FFI to call the Mimer SQL C API
|
|
25
|
-
directly from JavaScript.
|
|
26
|
-
|
|
27
24
|
## Installation
|
|
28
25
|
|
|
29
26
|
```bash
|
|
30
27
|
npm install @mimersql/node-mimer
|
|
31
28
|
```
|
|
32
29
|
|
|
33
|
-
|
|
30
|
+
Prebuilt binaries are included for supported platforms (linux-x64, linux-arm64,
|
|
31
|
+
darwin-x64, darwin-arm64, win32-x64). On other platforms, the install script
|
|
32
|
+
will compile from source using `node-gyp` (requires a C++ compiler and Mimer SQL
|
|
33
|
+
development headers).
|
|
34
34
|
|
|
35
35
|
### Verifying Mimer SQL is found
|
|
36
36
|
|
|
@@ -363,24 +363,6 @@ try {
|
|
|
363
363
|
| BOOLEAN | Boolean |
|
|
364
364
|
| NULL | null |
|
|
365
365
|
|
|
366
|
-
## Backend Selection
|
|
367
|
-
|
|
368
|
-
By default, `node-mimer` uses the Koffi FFI backend (pure JavaScript).
|
|
369
|
-
|
|
370
|
-
If the optional [`node-mimer-native`](https://github.com/user/node-mimer-native)
|
|
371
|
-
package is installed, it will be used instead. This can be useful as a fallback
|
|
372
|
-
if Koffi is ever unavailable for a given platform.
|
|
373
|
-
|
|
374
|
-
You can force a specific backend with the `NODE_MIMER_BACKEND` environment variable:
|
|
375
|
-
|
|
376
|
-
```bash
|
|
377
|
-
# Force Koffi FFI (default)
|
|
378
|
-
NODE_MIMER_BACKEND=koffi npm test
|
|
379
|
-
|
|
380
|
-
# Force native C++ addon (requires node-mimer-native)
|
|
381
|
-
NODE_MIMER_BACKEND=native npm test
|
|
382
|
-
```
|
|
383
|
-
|
|
384
366
|
## API Reference
|
|
385
367
|
|
|
386
368
|
### MimerClient
|
|
@@ -573,16 +555,10 @@ npm test
|
|
|
573
555
|
|
|
574
556
|
# Run a single test file
|
|
575
557
|
node --test test/unicode.test.js
|
|
576
|
-
|
|
577
|
-
# Test with a specific backend
|
|
578
|
-
NODE_MIMER_BACKEND=koffi npm test
|
|
579
|
-
NODE_MIMER_BACKEND=native npm test # requires node-mimer-native
|
|
580
558
|
```
|
|
581
559
|
|
|
582
560
|
## Architecture
|
|
583
561
|
|
|
584
|
-
The library has two layers:
|
|
585
|
-
|
|
586
562
|
```
|
|
587
563
|
Application (JavaScript)
|
|
588
564
|
|
|
|
@@ -592,13 +568,13 @@ JavaScript Wrapper (Promise-based)
|
|
|
592
568
|
index.js, lib/client.js, lib/prepared.js,
|
|
593
569
|
lib/resultset.js, lib/pool.js
|
|
594
570
|
|
|
|
595
|
-
| lib/native.js (
|
|
571
|
+
| lib/native.js (loads native addon)
|
|
596
572
|
v
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
573
|
+
C++ Native Addon (Node-API)
|
|
574
|
+
src/connection.cc, src/statement.cc,
|
|
575
|
+
src/resultset.cc, src/helpers.cc
|
|
600
576
|
|
|
|
601
|
-
|
|
|
577
|
+
| C API calls
|
|
602
578
|
v
|
|
603
579
|
Mimer SQL C API (libmimerapi.so)
|
|
604
580
|
|
|
|
@@ -606,14 +582,12 @@ Mimer SQL C API (libmimerapi.so)
|
|
|
606
582
|
Mimer SQL Database
|
|
607
583
|
```
|
|
608
584
|
|
|
609
|
-
The
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
C++ Node-API addon. It can be installed alongside `node-mimer` as a drop-in
|
|
616
|
-
replacement if needed.
|
|
585
|
+
The package ships prebuilt `.node` binaries for supported platforms via
|
|
586
|
+
[prebuildify](https://github.com/prebuild/prebuildify). At install time,
|
|
587
|
+
`prebuild-install` downloads the matching binary. If no prebuilt is available,
|
|
588
|
+
the addon is compiled from source using `node-gyp`. The native addon uses
|
|
589
|
+
[Node-API](https://nodejs.org/api/n-api.html) (N-API v8), so binaries are
|
|
590
|
+
stable across Node.js versions without recompilation.
|
|
617
591
|
|
|
618
592
|
### Mimer SQL C API Functions Used
|
|
619
593
|
|
|
@@ -633,18 +607,28 @@ replacement if needed.
|
|
|
633
607
|
|
|
634
608
|
```
|
|
635
609
|
node-mimer/
|
|
610
|
+
├── src/ # C++ native addon
|
|
611
|
+
│ ├── mimer_addon.cc # Module entry point
|
|
612
|
+
│ ├── connection.cc/h # Connection class
|
|
613
|
+
│ ├── statement.cc/h # Prepared statement class
|
|
614
|
+
│ ├── resultset.cc/h # Cursor/streaming result set class
|
|
615
|
+
│ └── helpers.cc/h # Parameter binding, row fetching, errors
|
|
616
|
+
│
|
|
636
617
|
├── lib/ # JavaScript modules
|
|
637
|
-
│ ├── native.js #
|
|
638
|
-
│ ├── koffi-binding.js # Koffi FFI backend
|
|
639
|
-
│ ├── find-mimer-library.js # Platform-specific library detection
|
|
618
|
+
│ ├── native.js # Loads native addon via node-gyp-build
|
|
640
619
|
│ ├── client.js # MimerClient, connect()
|
|
641
620
|
│ ├── prepared.js # PreparedStatement
|
|
642
621
|
│ ├── resultset.js # ResultSet (cursor wrapper)
|
|
643
622
|
│ └── pool.js # Pool, PoolClient
|
|
644
623
|
│
|
|
624
|
+
├── prebuilds/ # Prebuilt binaries (per platform)
|
|
625
|
+
│ └── linux-x64/ # Example: Linux x64 binary
|
|
626
|
+
│
|
|
645
627
|
├── scripts/
|
|
646
|
-
│
|
|
628
|
+
│ ├── check-mimer.js # Verify Mimer installation
|
|
629
|
+
│ └── find-mimer-windows.js # Auto-detect Mimer on Windows
|
|
647
630
|
│
|
|
631
|
+
├── binding.gyp # Native addon build configuration
|
|
648
632
|
├── index.js # Re-exports from lib/
|
|
649
633
|
├── index.d.ts # TypeScript type definitions
|
|
650
634
|
├── package.json
|
|
@@ -667,4 +651,4 @@ Contributions are welcome! Please submit pull requests or open issues on GitHub.
|
|
|
667
651
|
|
|
668
652
|
- [Mimer SQL Documentation](https://developer.mimer.com/documentation)
|
|
669
653
|
- [Mimer SQL C API Reference](https://developer.mimer.com/mimerapi)
|
|
670
|
-
- [
|
|
654
|
+
- [Node-API Documentation](https://nodejs.org/api/n-api.html)
|
package/binding.gyp
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
{
|
|
2
|
+
"targets": [
|
|
3
|
+
{
|
|
4
|
+
"target_name": "mimer",
|
|
5
|
+
"sources": [
|
|
6
|
+
"src/mimer_addon.cc",
|
|
7
|
+
"src/connection.cc",
|
|
8
|
+
"src/statement.cc",
|
|
9
|
+
"src/helpers.cc",
|
|
10
|
+
"src/resultset.cc"
|
|
11
|
+
],
|
|
12
|
+
"include_dirs": [
|
|
13
|
+
"<!@(node -p \"require('node-addon-api').include\")"
|
|
14
|
+
],
|
|
15
|
+
"cflags!": [ "-fno-exceptions" ],
|
|
16
|
+
"cflags_cc!": [ "-fno-exceptions" ],
|
|
17
|
+
"defines": [
|
|
18
|
+
"NAPI_CPP_EXCEPTIONS"
|
|
19
|
+
],
|
|
20
|
+
"conditions": [
|
|
21
|
+
["OS=='linux'", {
|
|
22
|
+
"libraries": [
|
|
23
|
+
"-lmimerapi"
|
|
24
|
+
],
|
|
25
|
+
"conditions": [
|
|
26
|
+
["target_arch=='arm64'", {
|
|
27
|
+
"libraries": [
|
|
28
|
+
"-L<!(pwd)/platform_lib/linux-arm64"
|
|
29
|
+
]
|
|
30
|
+
}]
|
|
31
|
+
]
|
|
32
|
+
}],
|
|
33
|
+
["OS=='mac'", {
|
|
34
|
+
"libraries": [
|
|
35
|
+
"-lmimerapi"
|
|
36
|
+
],
|
|
37
|
+
"xcode_settings": {
|
|
38
|
+
"GCC_ENABLE_CPP_EXCEPTIONS": "YES",
|
|
39
|
+
"CLANG_CXX_LIBRARY": "libc++",
|
|
40
|
+
"MACOSX_DEPLOYMENT_TARGET": "10.15"
|
|
41
|
+
}
|
|
42
|
+
}],
|
|
43
|
+
["OS=='win'", {
|
|
44
|
+
"variables": {
|
|
45
|
+
# Automatically find Mimer SQL installation
|
|
46
|
+
# Searches for latest version in Program Files
|
|
47
|
+
# Falls back to "C:\Program Files\Mimer SQL Experience 11.0" if not found
|
|
48
|
+
"mimer_home": "<!(node scripts/find-mimer-windows.js)"
|
|
49
|
+
},
|
|
50
|
+
"include_dirs": [
|
|
51
|
+
"<(mimer_home)/dev/include"
|
|
52
|
+
],
|
|
53
|
+
"libraries": [
|
|
54
|
+
"<(mimer_home)/dev/lib/amd64/mimapi64.lib"
|
|
55
|
+
],
|
|
56
|
+
"defines": ["_HAS_EXCEPTIONS=1"],
|
|
57
|
+
"msvs_settings": {
|
|
58
|
+
"VCCLCompilerTool": {
|
|
59
|
+
"ExceptionHandling": 1
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}]
|
|
63
|
+
]
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
}
|
package/lib/native.js
CHANGED
|
@@ -23,30 +23,13 @@
|
|
|
23
23
|
'use strict';
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
26
|
+
* Load the native Mimer SQL binding.
|
|
27
27
|
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* Override with NODE_MIMER_BACKEND environment variable:
|
|
32
|
-
* NODE_MIMER_BACKEND=koffi — force Koffi FFI backend
|
|
33
|
-
* NODE_MIMER_BACKEND=native — force node-mimer-native (C++ addon)
|
|
28
|
+
* Uses node-gyp-build to find the binary:
|
|
29
|
+
* 1. prebuilds/<platform>-<arch>/ (shipped in the npm package)
|
|
30
|
+
* 2. build/Release/ (compiled from source at install time)
|
|
34
31
|
*/
|
|
35
32
|
|
|
36
|
-
|
|
37
|
-
const backend = process.env.NODE_MIMER_BACKEND;
|
|
38
|
-
|
|
39
|
-
if (backend === 'koffi') {
|
|
40
|
-
binding = require('./koffi-binding');
|
|
41
|
-
} else if (backend === 'native') {
|
|
42
|
-
binding = require('node-mimer-native');
|
|
43
|
-
} else {
|
|
44
|
-
// Default: try node-mimer-native if installed, otherwise Koffi
|
|
45
|
-
try {
|
|
46
|
-
binding = require('node-mimer-native');
|
|
47
|
-
} catch {
|
|
48
|
-
binding = require('./koffi-binding');
|
|
49
|
-
}
|
|
50
|
-
}
|
|
33
|
+
const path = require('path');
|
|
51
34
|
|
|
52
|
-
module.exports =
|
|
35
|
+
module.exports = require('node-gyp-build')(path.join(__dirname, '..'));
|
package/package.json
CHANGED
|
@@ -1,16 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mimersql/node-mimer",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Node.js bindings for Mimer SQL using Mimer API",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
7
|
+
"gypfile": true,
|
|
7
8
|
"files": [
|
|
8
9
|
"index.js",
|
|
9
10
|
"index.d.ts",
|
|
10
|
-
"lib/"
|
|
11
|
+
"lib/",
|
|
12
|
+
"src/",
|
|
13
|
+
"scripts/check-mimer.js",
|
|
14
|
+
"scripts/find-mimer-windows.js",
|
|
15
|
+
"binding.gyp",
|
|
16
|
+
"prebuilds/"
|
|
11
17
|
],
|
|
12
18
|
"scripts": {
|
|
19
|
+
"install": "prebuild-install || node-gyp rebuild",
|
|
20
|
+
"build": "node-gyp rebuild",
|
|
13
21
|
"test": "node --test test/*.test.js",
|
|
22
|
+
"prebuild": "prebuildify --napi --strip",
|
|
23
|
+
"prebuild-macos": "prebuildify --napi --strip --arch x64 && prebuildify --napi --strip --arch arm64",
|
|
24
|
+
"prebuild-linux": "prebuildify --napi --strip && bash scripts/prebuild-linux-arm64.sh",
|
|
14
25
|
"check-mimer": "node scripts/check-mimer.js"
|
|
15
26
|
},
|
|
16
27
|
"keywords": [
|
|
@@ -30,9 +41,20 @@
|
|
|
30
41
|
"author": "Fredrik Ålund <fredrik.alund@mimer.com>",
|
|
31
42
|
"license": "MIT",
|
|
32
43
|
"dependencies": {
|
|
33
|
-
"
|
|
44
|
+
"node-addon-api": "^8.0.0",
|
|
45
|
+
"node-gyp-build": "^4.8.4",
|
|
46
|
+
"prebuild-install": "^7.1.2"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"node-gyp": "^10.0.0",
|
|
50
|
+
"prebuildify": "^6.0.1"
|
|
34
51
|
},
|
|
35
52
|
"engines": {
|
|
36
53
|
"node": ">=18.0.0"
|
|
54
|
+
},
|
|
55
|
+
"binary": {
|
|
56
|
+
"napi_versions": [
|
|
57
|
+
8
|
|
58
|
+
]
|
|
37
59
|
}
|
|
38
60
|
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Verify Mimer SQL installation and configuration
|
|
4
|
+
* Run this to check if Mimer SQL can be found before building
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const fs = require('fs');
|
|
8
|
+
const path = require('path');
|
|
9
|
+
const os = require('os');
|
|
10
|
+
|
|
11
|
+
function checkLinux() {
|
|
12
|
+
console.log('Checking Mimer SQL on Linux...\n');
|
|
13
|
+
|
|
14
|
+
const locations = [
|
|
15
|
+
'/usr/include/mimerapi.h',
|
|
16
|
+
'/usr/lib/libmimerapi.so',
|
|
17
|
+
'/usr/lib64/libmimerapi.so',
|
|
18
|
+
'/usr/lib/x86_64-linux-gnu/libmimerapi.so'
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
let found = false;
|
|
22
|
+
for (const loc of locations) {
|
|
23
|
+
if (fs.existsSync(loc)) {
|
|
24
|
+
console.log(`✓ Found: ${loc}`);
|
|
25
|
+
found = true;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (!found) {
|
|
30
|
+
console.log('✗ Mimer SQL not found in standard locations');
|
|
31
|
+
console.log(' Install with: sudo dpkg -i mimerapi_*.deb');
|
|
32
|
+
console.log(' or: sudo rpm -i mimerapi-*.rpm');
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function checkMacOS() {
|
|
40
|
+
console.log('Checking Mimer SQL on macOS...\n');
|
|
41
|
+
|
|
42
|
+
const headerPath = '/usr/local/include/mimerapi.h';
|
|
43
|
+
const libPath = '/usr/local/lib/libmimerapi.dylib';
|
|
44
|
+
|
|
45
|
+
if (!fs.existsSync(headerPath)) {
|
|
46
|
+
console.log(`✗ Header not found: ${headerPath}`);
|
|
47
|
+
console.log(' Install Mimer SQL from https://developer.mimer.com');
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
console.log(`✓ Found: ${headerPath}`);
|
|
51
|
+
|
|
52
|
+
if (!fs.existsSync(libPath)) {
|
|
53
|
+
console.log(`✗ Library not found: ${libPath}`);
|
|
54
|
+
console.log(' Install Mimer SQL from https://developer.mimer.com');
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
console.log(`✓ Found: ${libPath}`);
|
|
58
|
+
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function checkWindows() {
|
|
63
|
+
console.log('Checking Mimer SQL on Windows...\n');
|
|
64
|
+
|
|
65
|
+
// Use the same auto-detection logic as binding.gyp
|
|
66
|
+
const findMimer = require('./find-mimer-windows.js');
|
|
67
|
+
|
|
68
|
+
let mimerHome;
|
|
69
|
+
try {
|
|
70
|
+
mimerHome = require('./find-mimer-windows');
|
|
71
|
+
} catch (e) {
|
|
72
|
+
// Execute the script to get output
|
|
73
|
+
const { execSync } = require('child_process');
|
|
74
|
+
mimerHome = execSync('node scripts/find-mimer-windows.js', { encoding: 'utf8' }).trim();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
console.log(`Detected MIMER_HOME: ${mimerHome}\n`);
|
|
78
|
+
|
|
79
|
+
const headerPath = path.join(mimerHome, 'dev', 'include', 'mimerapi.h');
|
|
80
|
+
const libPath = path.join(mimerHome, 'dev', 'lib', 'amd64', 'mimapi64.lib');
|
|
81
|
+
const dllPath = path.join(mimerHome, 'bin', 'mimapi64.dll');
|
|
82
|
+
|
|
83
|
+
let allFound = true;
|
|
84
|
+
|
|
85
|
+
if (!fs.existsSync(headerPath)) {
|
|
86
|
+
console.log(`✗ Header not found: ${headerPath}`);
|
|
87
|
+
allFound = false;
|
|
88
|
+
} else {
|
|
89
|
+
console.log(`✓ Found: ${headerPath}`);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (!fs.existsSync(libPath)) {
|
|
93
|
+
console.log(`✗ Library not found: ${libPath}`);
|
|
94
|
+
allFound = false;
|
|
95
|
+
} else {
|
|
96
|
+
console.log(`✓ Found: ${libPath}`);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (!fs.existsSync(dllPath)) {
|
|
100
|
+
console.log(`✗ DLL not found: ${dllPath}`);
|
|
101
|
+
console.log(' (This may cause runtime errors)');
|
|
102
|
+
} else {
|
|
103
|
+
console.log(`✓ Found: ${dllPath}`);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (!allFound) {
|
|
107
|
+
console.log('\nTo override auto-detection, set MIMER_HOME:');
|
|
108
|
+
console.log(' $env:MIMER_HOME="C:\\Program Files\\Mimer SQL Experience 11.0"');
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function main() {
|
|
116
|
+
console.log('=== Mimer SQL Installation Check ===\n');
|
|
117
|
+
|
|
118
|
+
const platform = os.platform();
|
|
119
|
+
let success = false;
|
|
120
|
+
|
|
121
|
+
if (platform === 'linux') {
|
|
122
|
+
success = checkLinux();
|
|
123
|
+
} else if (platform === 'darwin') {
|
|
124
|
+
success = checkMacOS();
|
|
125
|
+
} else if (platform === 'win32') {
|
|
126
|
+
success = checkWindows();
|
|
127
|
+
} else {
|
|
128
|
+
console.log(`Unsupported platform: ${platform}`);
|
|
129
|
+
process.exit(1);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
console.log('\n' + '='.repeat(40));
|
|
133
|
+
|
|
134
|
+
if (success) {
|
|
135
|
+
console.log('✓ Mimer SQL is properly installed');
|
|
136
|
+
console.log(' You can now run: npm run build');
|
|
137
|
+
process.exit(0);
|
|
138
|
+
} else {
|
|
139
|
+
console.log('✗ Mimer SQL installation issues detected');
|
|
140
|
+
console.log(' Please install or configure Mimer SQL before building');
|
|
141
|
+
process.exit(1);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (require.main === module) {
|
|
146
|
+
main();
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
module.exports = { checkLinux, checkMacOS, checkWindows };
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Copyright (c) 2026 Mimer Information Technology
|
|
3
|
+
//
|
|
4
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
// of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
// in the Software without restriction, including without limitation the rights
|
|
7
|
+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
// copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
// furnished to do so, subject to the following conditions:
|
|
10
|
+
//
|
|
11
|
+
// The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
// copies or substantial portions of the Software.
|
|
13
|
+
//
|
|
14
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
// SOFTWARE.
|
|
21
|
+
//
|
|
22
|
+
// See license for more details.
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* find-mimer-windows.js
|
|
26
|
+
* Automatically find Mimer SQL installation on Windows
|
|
27
|
+
*
|
|
28
|
+
* Search order:
|
|
29
|
+
* 1. MIMER_HOME environment variable
|
|
30
|
+
* 2. Windows Registry
|
|
31
|
+
* 3. Program Files (latest version)
|
|
32
|
+
* 4. Default fallback path
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
const fs = require('fs');
|
|
36
|
+
const path = require('path');
|
|
37
|
+
|
|
38
|
+
// Helper to check if Mimer is installed at path
|
|
39
|
+
function isMimerInstalled(mimerPath) {
|
|
40
|
+
if (!mimerPath) return false;
|
|
41
|
+
const headerPath = path.join(mimerPath, 'dev', 'include', 'mimerapi.h');
|
|
42
|
+
return fs.existsSync(headerPath);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Try 1: Use MIMER_HOME environment variable
|
|
46
|
+
if (process.env.MIMER_HOME && isMimerInstalled(process.env.MIMER_HOME)) {
|
|
47
|
+
console.log(process.env.MIMER_HOME);
|
|
48
|
+
process.exit(0);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Try 2: Read from Windows Registry
|
|
52
|
+
// Mimer SQL stores each version under HKLM\SOFTWARE\Mimer\Mimer SQL\<version>\PathName
|
|
53
|
+
// e.g. HKLM\SOFTWARE\Mimer\Mimer SQL\11.0\PathName
|
|
54
|
+
// We enumerate all version subkeys and pick the highest version.
|
|
55
|
+
if (process.platform === 'win32') {
|
|
56
|
+
try {
|
|
57
|
+
const { execSync } = require('child_process');
|
|
58
|
+
// List all version subkeys under "Mimer SQL"
|
|
59
|
+
const regEnum = 'reg query "HKLM\\SOFTWARE\\Mimer\\Mimer SQL" 2>nul';
|
|
60
|
+
const output = execSync(regEnum, { encoding: 'utf8' });
|
|
61
|
+
|
|
62
|
+
const registryVersions = [];
|
|
63
|
+
for (const line of output.split('\n')) {
|
|
64
|
+
// Each subkey line looks like: HKEY_LOCAL_MACHINE\SOFTWARE\Mimer\Mimer SQL\11.0
|
|
65
|
+
const versionMatch = line.match(/Mimer SQL\\(\d+\.\d+)\s*$/);
|
|
66
|
+
if (versionMatch) {
|
|
67
|
+
const version = versionMatch[1];
|
|
68
|
+
try {
|
|
69
|
+
const pathQuery = `reg query "HKLM\\SOFTWARE\\Mimer\\Mimer SQL\\${version}" /v PathName 2>nul`;
|
|
70
|
+
const pathOutput = execSync(pathQuery, { encoding: 'utf8' });
|
|
71
|
+
const pathMatch = pathOutput.match(/PathName\s+REG_SZ\s+(.+)/);
|
|
72
|
+
if (pathMatch && pathMatch[1]) {
|
|
73
|
+
const mimerPath = pathMatch[1].trim();
|
|
74
|
+
if (isMimerInstalled(mimerPath)) {
|
|
75
|
+
registryVersions.push({ version, path: mimerPath });
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
} catch (err) {
|
|
79
|
+
// Could not read PathName for this version, skip
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Sort by version descending and use the highest
|
|
85
|
+
if (registryVersions.length > 0) {
|
|
86
|
+
registryVersions.sort((a, b) => {
|
|
87
|
+
const va = a.version.split('.').map(Number);
|
|
88
|
+
const vb = b.version.split('.').map(Number);
|
|
89
|
+
if (va[0] !== vb[0]) return vb[0] - va[0];
|
|
90
|
+
return vb[1] - va[1];
|
|
91
|
+
});
|
|
92
|
+
console.log(registryVersions[0].path);
|
|
93
|
+
process.exit(0);
|
|
94
|
+
}
|
|
95
|
+
} catch (err) {
|
|
96
|
+
// Registry key not found, continue
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Try 3: Find in Program Files - get highest version
|
|
101
|
+
const programFiles = [
|
|
102
|
+
process.env.ProgramFiles,
|
|
103
|
+
process.env['ProgramFiles(x86)']
|
|
104
|
+
].filter(Boolean);
|
|
105
|
+
|
|
106
|
+
const foundPaths = [];
|
|
107
|
+
|
|
108
|
+
for (const pf of programFiles) {
|
|
109
|
+
if (!fs.existsSync(pf)) continue;
|
|
110
|
+
|
|
111
|
+
try {
|
|
112
|
+
const entries = fs.readdirSync(pf, { withFileTypes: true });
|
|
113
|
+
|
|
114
|
+
for (const entry of entries) {
|
|
115
|
+
if (entry.isDirectory() && entry.name.startsWith('Mimer SQL Experience')) {
|
|
116
|
+
const fullPath = path.join(pf, entry.name);
|
|
117
|
+
if (isMimerInstalled(fullPath)) {
|
|
118
|
+
foundPaths.push({
|
|
119
|
+
path: fullPath,
|
|
120
|
+
name: entry.name,
|
|
121
|
+
// Extract version for sorting (e.g., "11.0" from "Mimer SQL Experience 11.0")
|
|
122
|
+
version: entry.name.match(/(\d+\.\d+)/)?.[1] || '0.0'
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
} catch (err) {
|
|
128
|
+
// Permission error or directory doesn't exist, continue
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Sort by version (highest first) and return the first one
|
|
133
|
+
if (foundPaths.length > 0) {
|
|
134
|
+
foundPaths.sort((a, b) => {
|
|
135
|
+
const versionA = a.version.split('.').map(Number);
|
|
136
|
+
const versionB = b.version.split('.').map(Number);
|
|
137
|
+
|
|
138
|
+
// Compare major version
|
|
139
|
+
if (versionA[0] !== versionB[0]) {
|
|
140
|
+
return versionB[0] - versionA[0];
|
|
141
|
+
}
|
|
142
|
+
// Compare minor version
|
|
143
|
+
return versionB[1] - versionA[1];
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
console.log(foundPaths[0].path);
|
|
147
|
+
process.exit(0);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// Try 4: Common default locations (in order of preference)
|
|
151
|
+
const defaultPaths = [
|
|
152
|
+
'C:\\Program Files\\Mimer SQL Experience 12.0',
|
|
153
|
+
'C:\\Program Files\\Mimer SQL Experience 11.0',
|
|
154
|
+
'C:\\Program Files (x86)\\Mimer SQL Experience 12.0',
|
|
155
|
+
'C:\\Program Files (x86)\\Mimer SQL Experience 11.0'
|
|
156
|
+
];
|
|
157
|
+
|
|
158
|
+
for (const defaultPath of defaultPaths) {
|
|
159
|
+
if (isMimerInstalled(defaultPath)) {
|
|
160
|
+
console.log(defaultPath);
|
|
161
|
+
process.exit(0);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// Not found - output a reasonable default that will give a clear error message
|
|
166
|
+
console.error('ERROR: Mimer SQL installation not found.');
|
|
167
|
+
console.error('Searched:');
|
|
168
|
+
console.error(' 1. MIMER_HOME environment variable');
|
|
169
|
+
console.error(' 2. Windows Registry (HKLM\\SOFTWARE\\Mimer\\Mimer SQL\\<version>\\PathName)');
|
|
170
|
+
console.error(' 3. Program Files directories');
|
|
171
|
+
console.error(' 4. Default installation paths');
|
|
172
|
+
console.error('');
|
|
173
|
+
console.error('Please:');
|
|
174
|
+
console.error(' 1. Install Mimer SQL from https://developer.mimer.com');
|
|
175
|
+
console.error(' 2. Or set MIMER_HOME environment variable to your installation path');
|
|
176
|
+
|
|
177
|
+
// Output a default path that will fail gracefully
|
|
178
|
+
console.log('C:\\Program Files\\Mimer SQL Experience 11.0');
|
|
179
|
+
process.exit(1);
|