1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 | 'use strict';
|
40 |
|
41 | const fs = require('fs');
|
42 | const nodbUtil = require('../lib/util.js');
|
43 | const errors = require('../lib/errors.js');
|
44 | const constants = require('../lib/constants.js');
|
45 |
|
46 | let installUrl = constants.DEFAULT_ERROR_URL;
|
47 | let arch;
|
48 | let thickModeErrMsg;
|
49 |
|
50 |
|
51 | function log(message) {
|
52 | const args = Array.from(arguments);
|
53 | args.unshift('oracledb');
|
54 | console.log.apply(console, args);
|
55 | }
|
56 |
|
57 |
|
58 | function error(message) {
|
59 | const args = Array.from(arguments);
|
60 | args.unshift('oracledb \x1b[31mERR!\x1b[0m');
|
61 | console.error.apply(console, args);
|
62 | }
|
63 |
|
64 |
|
65 | function warn(message) {
|
66 | const args = Array.from(arguments);
|
67 | args.unshift('oracledb \x1b[31mWARN!\x1b[0m');
|
68 | console.error.apply(console, args);
|
69 | }
|
70 |
|
71 |
|
72 |
|
73 |
|
74 |
|
75 |
|
76 |
|
77 | function checkVersion() {
|
78 | const vs = process.version.substring(1).split(".").map(Number);
|
79 | errors.assert(vs[0] > 14 || (vs[0] === 14 && vs[1] >= 6),
|
80 | errors.ERR_NODE_TOO_OLD, nodbUtil.PACKAGE_JSON_VERSION, "14.6");
|
81 | }
|
82 |
|
83 |
|
84 |
|
85 | function checkThickMode() {
|
86 | try {
|
87 | fs.statSync(nodbUtil.RELEASE_DIR + '/' + nodbUtil.BINARY_FILE);
|
88 | } catch (err) {
|
89 | errors.throwErr(errors.ERR_NO_BINARY_AVAILABLE, process.platform + ' ' + process.arch);
|
90 | }
|
91 | }
|
92 |
|
93 | try {
|
94 | checkVersion();
|
95 | } catch (err) {
|
96 |
|
97 | error(err.message);
|
98 | error('An older node-oracledb version may work with Node.js ' + process.version);
|
99 | process.exit(87);
|
100 | }
|
101 |
|
102 | try {
|
103 | checkThickMode();
|
104 | } catch (err) {
|
105 |
|
106 | thickModeErrMsg = err.message;
|
107 | }
|
108 |
|
109 |
|
110 |
|
111 | if (process.arch === 'x64' || process.arch === 'arm64') {
|
112 | arch = '64-bit';
|
113 | } else {
|
114 | arch = '32-bit';
|
115 | }
|
116 |
|
117 | if (process.platform === 'linux') {
|
118 | installUrl += '#node-oracledb-installation-on-linux';
|
119 | } else if (process.platform === 'darwin') {
|
120 | installUrl += '#node-oracledb-installation-on-apple-macos-intel-x86';
|
121 | } else if (process.platform === 'win32') {
|
122 | installUrl += '#node-oracledb-installation-on-microsoft-windowsstallation';
|
123 | }
|
124 |
|
125 | log('********************************************************************************');
|
126 | log('** Node-oracledb ' + nodbUtil.PACKAGE_JSON_VERSION + ' installed in Node.js ' + process.versions.node + ' (' + process.platform + ', ' + process.arch + ')');
|
127 | log('** To use node-oracledb in Thin mode, no additional steps are needed.');
|
128 | if (thickModeErrMsg) {
|
129 | warn(thickModeErrMsg);
|
130 | warn('If you want to use the optional Thick mode, compile node-oracledb code using');
|
131 | warn(installUrl + '#github');
|
132 | } else {
|
133 | log('** To use the optional Thick mode, the Oracle Client libraries (' + arch + ')');
|
134 | log('** must be available, see the installation instructions:');
|
135 | log('** ' + installUrl);
|
136 | }
|
137 | log('********************************************************************************\n');
|