pmxtjs 1.0.1 → 1.0.3
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.
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { DefaultApi, Configuration } from "../generated/src/index.js";
|
|
7
7
|
import { readFileSync, existsSync } from "fs";
|
|
8
8
|
import { homedir } from "os";
|
|
9
|
-
import { join } from "path";
|
|
9
|
+
import { join, dirname } from "path";
|
|
10
10
|
export class ServerManager {
|
|
11
11
|
baseUrl;
|
|
12
12
|
maxRetries;
|
|
@@ -90,10 +90,27 @@ export class ServerManager {
|
|
|
90
90
|
if (await this.isServerRunning()) {
|
|
91
91
|
return;
|
|
92
92
|
}
|
|
93
|
+
// Locate pmxt-ensure-server
|
|
94
|
+
let launcherPath = 'pmxt-ensure-server'; // Default to PATH
|
|
95
|
+
try {
|
|
96
|
+
// Try to resolve from pmxt-core dependency
|
|
97
|
+
// For CommonJS build (which is primary), we can use require directly
|
|
98
|
+
// For ESM build, this will be transpiled appropriately
|
|
99
|
+
const corePackageJson = require.resolve('pmxt-core/package.json');
|
|
100
|
+
const coreDir = dirname(corePackageJson);
|
|
101
|
+
const binPath = join(coreDir, 'bin', 'pmxt-ensure-server');
|
|
102
|
+
if (existsSync(binPath)) {
|
|
103
|
+
launcherPath = binPath;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
// If resolution fails, fall back to PATH
|
|
108
|
+
// This could happen in dev environments where pmxt-core is globally installed
|
|
109
|
+
}
|
|
93
110
|
// Try to start the server using pmxt-ensure-server
|
|
94
111
|
const { spawn } = await import("child_process");
|
|
95
112
|
try {
|
|
96
|
-
const proc = spawn(
|
|
113
|
+
const proc = spawn(launcherPath, [], {
|
|
97
114
|
detached: true,
|
|
98
115
|
stdio: "ignore",
|
|
99
116
|
});
|
|
@@ -126,10 +126,27 @@ class ServerManager {
|
|
|
126
126
|
if (await this.isServerRunning()) {
|
|
127
127
|
return;
|
|
128
128
|
}
|
|
129
|
+
// Locate pmxt-ensure-server
|
|
130
|
+
let launcherPath = 'pmxt-ensure-server'; // Default to PATH
|
|
131
|
+
try {
|
|
132
|
+
// Try to resolve from pmxt-core dependency
|
|
133
|
+
// For CommonJS build (which is primary), we can use require directly
|
|
134
|
+
// For ESM build, this will be transpiled appropriately
|
|
135
|
+
const corePackageJson = require.resolve('pmxt-core/package.json');
|
|
136
|
+
const coreDir = (0, path_1.dirname)(corePackageJson);
|
|
137
|
+
const binPath = (0, path_1.join)(coreDir, 'bin', 'pmxt-ensure-server');
|
|
138
|
+
if ((0, fs_1.existsSync)(binPath)) {
|
|
139
|
+
launcherPath = binPath;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
catch (error) {
|
|
143
|
+
// If resolution fails, fall back to PATH
|
|
144
|
+
// This could happen in dev environments where pmxt-core is globally installed
|
|
145
|
+
}
|
|
129
146
|
// Try to start the server using pmxt-ensure-server
|
|
130
147
|
const { spawn } = await Promise.resolve().then(() => __importStar(require("child_process")));
|
|
131
148
|
try {
|
|
132
|
-
const proc = spawn(
|
|
149
|
+
const proc = spawn(launcherPath, [], {
|
|
133
150
|
detached: true,
|
|
134
151
|
stdio: "ignore",
|
|
135
152
|
});
|
package/generated/package.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmxtjs",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "Unified prediction market data API - The ccxt for prediction markets",
|
|
5
5
|
"author": "PMXT Contributors",
|
|
6
6
|
"repository": {
|
|
@@ -41,6 +41,9 @@
|
|
|
41
41
|
"api",
|
|
42
42
|
"unified"
|
|
43
43
|
],
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"pmxt-core": "1.0.3"
|
|
46
|
+
},
|
|
44
47
|
"devDependencies": {
|
|
45
48
|
"@types/jest": "^30.0.0",
|
|
46
49
|
"@types/node": "^20.0.0",
|
package/pmxt/server-manager.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import { DefaultApi, Configuration } from "../generated/src/index.js";
|
|
8
8
|
import { readFileSync, existsSync } from "fs";
|
|
9
9
|
import { homedir } from "os";
|
|
10
|
-
import { join } from "path";
|
|
10
|
+
import { join, dirname } from "path";
|
|
11
11
|
|
|
12
12
|
export interface ServerManagerOptions {
|
|
13
13
|
baseUrl?: string;
|
|
@@ -113,11 +113,30 @@ export class ServerManager {
|
|
|
113
113
|
return;
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
+
// Locate pmxt-ensure-server
|
|
117
|
+
let launcherPath = 'pmxt-ensure-server'; // Default to PATH
|
|
118
|
+
|
|
119
|
+
try {
|
|
120
|
+
// Try to resolve from pmxt-core dependency
|
|
121
|
+
// For CommonJS build (which is primary), we can use require directly
|
|
122
|
+
// For ESM build, this will be transpiled appropriately
|
|
123
|
+
const corePackageJson = require.resolve('pmxt-core/package.json');
|
|
124
|
+
const coreDir = dirname(corePackageJson);
|
|
125
|
+
const binPath = join(coreDir, 'bin', 'pmxt-ensure-server');
|
|
126
|
+
|
|
127
|
+
if (existsSync(binPath)) {
|
|
128
|
+
launcherPath = binPath;
|
|
129
|
+
}
|
|
130
|
+
} catch (error) {
|
|
131
|
+
// If resolution fails, fall back to PATH
|
|
132
|
+
// This could happen in dev environments where pmxt-core is globally installed
|
|
133
|
+
}
|
|
134
|
+
|
|
116
135
|
// Try to start the server using pmxt-ensure-server
|
|
117
136
|
const { spawn } = await import("child_process");
|
|
118
137
|
|
|
119
138
|
try {
|
|
120
|
-
const proc = spawn(
|
|
139
|
+
const proc = spawn(launcherPath, [], {
|
|
121
140
|
detached: true,
|
|
122
141
|
stdio: "ignore",
|
|
123
142
|
});
|