@paimaexample/npm-midnight-indexer 0.3.122 → 0.3.123
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/binary.js +24 -11
- package/index.js +4 -5
- package/package.json +1 -1
- package/run_midnight_indexer.js +8 -5
package/binary.js
CHANGED
|
@@ -5,6 +5,7 @@ const extract = require("extract-zip");
|
|
|
5
5
|
const path = require("path");
|
|
6
6
|
|
|
7
7
|
const CURRENT_BINARY_VERSION = "v2.1.4";
|
|
8
|
+
const FINAL_BINARY_NAME = "indexer-standalone";
|
|
8
9
|
|
|
9
10
|
/*
|
|
10
11
|
@returns {string} The platform and architecture of the current machine. Example: "linux-amd64"
|
|
@@ -76,20 +77,32 @@ async function unzipBinary() {
|
|
|
76
77
|
fs.mkdirSync(dir, { recursive: true });
|
|
77
78
|
}
|
|
78
79
|
await extract(path.join(__dirname, "indexer-standalone.zip"), { dir });
|
|
79
|
-
|
|
80
|
+
const dataDir = path.join(dir, "data");
|
|
81
|
+
if (!fs.existsSync(dataDir)) {
|
|
82
|
+
fs.mkdirSync(dataDir, { recursive: true });
|
|
83
|
+
}
|
|
80
84
|
|
|
81
85
|
const platform = getPlatform();
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
)
|
|
90
|
-
|
|
91
|
-
|
|
86
|
+
const extractedBinaryPath = path.join(
|
|
87
|
+
dir,
|
|
88
|
+
`indexer-standalone-${platform}`,
|
|
89
|
+
);
|
|
90
|
+
const finalBinaryPath = path.join(dir, FINAL_BINARY_NAME);
|
|
91
|
+
|
|
92
|
+
if (fs.existsSync(extractedBinaryPath) &&
|
|
93
|
+
extractedBinaryPath !== finalBinaryPath) {
|
|
94
|
+
if (fs.existsSync(finalBinaryPath)) {
|
|
95
|
+
fs.unlinkSync(finalBinaryPath);
|
|
96
|
+
}
|
|
97
|
+
fs.renameSync(extractedBinaryPath, finalBinaryPath);
|
|
92
98
|
}
|
|
99
|
+
|
|
100
|
+
if (!fs.existsSync(finalBinaryPath)) {
|
|
101
|
+
throw new Error(`Expected binary not found: ${finalBinaryPath}`);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
fs.chmodSync(finalBinaryPath, 0o755);
|
|
105
|
+
fs.unlinkSync(path.join(__dirname, "indexer-standalone.zip"));
|
|
93
106
|
}
|
|
94
107
|
|
|
95
108
|
async function binary() {
|
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { binary
|
|
1
|
+
const { binary } = require("./binary");
|
|
2
2
|
const { runMidnightIndexer } = require("./run_midnight_indexer");
|
|
3
3
|
const { checkIfDockerExists, pullDockerImage, runDockerContainer } = require(
|
|
4
4
|
"./docker",
|
|
@@ -8,12 +8,11 @@ const path = require("path");
|
|
|
8
8
|
const readline = require("readline");
|
|
9
9
|
const os = require("os");
|
|
10
10
|
|
|
11
|
+
const FINAL_BINARY_NAME = "indexer-standalone";
|
|
12
|
+
|
|
11
13
|
function checkIfBinaryExists() {
|
|
12
|
-
const platform = getPlatform();
|
|
13
|
-
const parts = platform.split("-");
|
|
14
|
-
const binaryName = `indexer-standalone-${platform}`;
|
|
15
14
|
return fs.existsSync(
|
|
16
|
-
path.join(__dirname, "indexer-standalone",
|
|
15
|
+
path.join(__dirname, "indexer-standalone", FINAL_BINARY_NAME),
|
|
17
16
|
);
|
|
18
17
|
}
|
|
19
18
|
|
package/package.json
CHANGED
package/run_midnight_indexer.js
CHANGED
|
@@ -2,7 +2,8 @@ const { spawn } = require("child_process");
|
|
|
2
2
|
const path = require("path");
|
|
3
3
|
const fs = require("fs");
|
|
4
4
|
const yaml = require("js-yaml");
|
|
5
|
-
|
|
5
|
+
|
|
6
|
+
const BINARY_NAME = "indexer-standalone";
|
|
6
7
|
/**
|
|
7
8
|
* Resolves the SQLite database path using the midnight-indexer configuration rules
|
|
8
9
|
* @param {Object} env - Environment variables
|
|
@@ -110,13 +111,10 @@ function handleCleanFlag(env, workingDir) {
|
|
|
110
111
|
* @returns {ChildProcess} The spawned child process
|
|
111
112
|
*/
|
|
112
113
|
function runMidnightIndexer(env = process.env, args = []) {
|
|
113
|
-
const platform = getPlatform();
|
|
114
|
-
const parts = platform.split("-");
|
|
115
|
-
const binaryName = `indexer-standalone-${platform}`;
|
|
116
114
|
const binaryPath = path.join(
|
|
117
115
|
__dirname,
|
|
118
116
|
"indexer-standalone",
|
|
119
|
-
|
|
117
|
+
BINARY_NAME,
|
|
120
118
|
);
|
|
121
119
|
const workingDir = path.join(__dirname, "indexer-standalone");
|
|
122
120
|
|
|
@@ -130,6 +128,11 @@ function runMidnightIndexer(env = process.env, args = []) {
|
|
|
130
128
|
|
|
131
129
|
console.log(`Starting midnight-indexer binary at: ${binaryPath}`);
|
|
132
130
|
|
|
131
|
+
const dataDir = path.join(workingDir, "data");
|
|
132
|
+
if (!fs.existsSync(dataDir)) {
|
|
133
|
+
fs.mkdirSync(dataDir, { recursive: true });
|
|
134
|
+
}
|
|
135
|
+
|
|
133
136
|
const childProcess = spawn(binaryPath, args, {
|
|
134
137
|
env: env,
|
|
135
138
|
stdio: "inherit", // Inherit stdin, stdout, stderr from parent process
|