@altimateai/altimate-code 0.5.11 → 0.5.13
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/CHANGELOG.md +27 -0
- package/dbt-tools/dist/index.js +190 -146
- package/dbt-tools/dist/node_python_bridge.py +122 -0
- package/package.json +14 -14
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,33 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.5.13] - 2026-03-26
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- **Pin `@altimateai/altimate-core` to exact version** — prevents npm from resolving stale cached binaries during install (#475)
|
|
13
|
+
- **Flaky `dbt Profiles Auto-Discovery` tests in CI** — stabilized tests that failed intermittently due to timing issues
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
|
|
17
|
+
- **Bump `yaml` from 2.8.2 to 2.8.3** — dependency update in `packages/opencode` (#473)
|
|
18
|
+
|
|
19
|
+
## [0.5.12] - 2026-03-25
|
|
20
|
+
|
|
21
|
+
### Added
|
|
22
|
+
|
|
23
|
+
- **`altimate-dbt` auto-discover config** — `altimate-dbt` commands now auto-detect `dbt_project.yml` and Python from the current directory without requiring `altimate-dbt init` first; supports Windows paths (`Scripts/`, `.exe`, `path.delimiter`) (#464)
|
|
24
|
+
- **Local E2E sanity test harness** — Docker-based test suite (`test/sanity/`) for install verification, smoke tests, upgrade scenarios, and resilience checks; runnable via `bun run sanity` (#461)
|
|
25
|
+
|
|
26
|
+
### Fixed
|
|
27
|
+
|
|
28
|
+
- **`altimate-dbt` commands fail with hardcoded CI path** — published binary contained a baked-in `/home/runner/work/...` path for the Python bridge; `copy-python.ts` now patches `__dirname` to use `import.meta.dirname` at runtime (#467)
|
|
29
|
+
|
|
30
|
+
### Testing
|
|
31
|
+
|
|
32
|
+
- 42 adversarial tests for config auto-discovery and dbt resolution: `findProjectRoot` edge cases (deep nesting, symlinks, nonexistent dirs), `discoverPython` with broken symlinks and malicious env vars, `resolveDbt` with conflicting env vars and priority ordering, `validateDbt` timeout/garbage handling, Windows constant correctness, `path.delimiter` usage, `buildDbtEnv` mutation safety
|
|
33
|
+
- 484-line adversarial test suite for the `__dirname` patch: regex edge cases, ReDoS protection, mutation testing, idempotency, CI smoke test parity, bundle runtime structure validation
|
|
34
|
+
|
|
8
35
|
## [0.5.11] - 2026-03-25
|
|
9
36
|
|
|
10
37
|
### Fixed
|
package/dbt-tools/dist/index.js
CHANGED
|
@@ -66,11 +66,11 @@ var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
|
66
66
|
|
|
67
67
|
// src/check.ts
|
|
68
68
|
import { existsSync as existsSync2 } from "fs";
|
|
69
|
-
import { execFileSync } from "child_process";
|
|
69
|
+
import { execFileSync as execFileSync2 } from "child_process";
|
|
70
70
|
import { join as join2 } from "path";
|
|
71
71
|
function run(cmd, args) {
|
|
72
72
|
try {
|
|
73
|
-
const out =
|
|
73
|
+
const out = execFileSync2(cmd, args, { encoding: "utf-8", timeout: 1e4 });
|
|
74
74
|
return { ok: true, stdout: out.trim() };
|
|
75
75
|
} catch {
|
|
76
76
|
return { ok: false, stdout: "" };
|
|
@@ -173,7 +173,7 @@ var init_doctor = __esm(() => {
|
|
|
173
173
|
// src/dbt-resolve.ts
|
|
174
174
|
import { execFileSync as execFileSync3 } from "child_process";
|
|
175
175
|
import { existsSync as existsSync4, realpathSync } from "fs";
|
|
176
|
-
import { dirname, join as join4 } from "path";
|
|
176
|
+
import { delimiter, dirname, join as join4 } from "path";
|
|
177
177
|
function resolveDbt(pythonPath, projectRoot) {
|
|
178
178
|
const candidates = [];
|
|
179
179
|
const envOverride = process.env.ALTIMATE_DBT_PATH;
|
|
@@ -182,78 +182,95 @@ function resolveDbt(pythonPath, projectRoot) {
|
|
|
182
182
|
}
|
|
183
183
|
if (pythonPath && existsSync4(pythonPath)) {
|
|
184
184
|
const binDir = dirname(pythonPath);
|
|
185
|
-
const siblingDbt = join4(binDir,
|
|
185
|
+
const siblingDbt = join4(binDir, `dbt${EXE}`);
|
|
186
186
|
candidates.push({ path: siblingDbt, source: `sibling of pythonPath (${pythonPath})`, binDir });
|
|
187
187
|
try {
|
|
188
188
|
const realPython = realpathSync(pythonPath);
|
|
189
189
|
if (realPython !== pythonPath) {
|
|
190
190
|
const realBinDir = dirname(realPython);
|
|
191
|
-
const realDbt = join4(realBinDir,
|
|
191
|
+
const realDbt = join4(realBinDir, `dbt${EXE}`);
|
|
192
192
|
candidates.push({ path: realDbt, source: `real path of pythonPath (${realPython})`, binDir: realBinDir });
|
|
193
193
|
}
|
|
194
194
|
} catch {}
|
|
195
195
|
}
|
|
196
196
|
if (projectRoot) {
|
|
197
197
|
for (const venvDir of [".venv", "venv", "env"]) {
|
|
198
|
-
const localDbt = join4(projectRoot, venvDir,
|
|
199
|
-
candidates.push({
|
|
198
|
+
const localDbt = join4(projectRoot, venvDir, VENV_BIN2, `dbt${EXE}`);
|
|
199
|
+
candidates.push({
|
|
200
|
+
path: localDbt,
|
|
201
|
+
source: `${venvDir}/ in project root`,
|
|
202
|
+
binDir: join4(projectRoot, venvDir, VENV_BIN2)
|
|
203
|
+
});
|
|
200
204
|
}
|
|
201
205
|
}
|
|
202
206
|
const condaPrefix = process.env.CONDA_PREFIX;
|
|
203
207
|
if (condaPrefix) {
|
|
204
208
|
candidates.push({
|
|
205
|
-
path: join4(condaPrefix,
|
|
209
|
+
path: join4(condaPrefix, VENV_BIN2, `dbt${EXE}`),
|
|
206
210
|
source: `CONDA_PREFIX (${condaPrefix})`,
|
|
207
|
-
binDir: join4(condaPrefix,
|
|
211
|
+
binDir: join4(condaPrefix, VENV_BIN2)
|
|
208
212
|
});
|
|
209
213
|
}
|
|
210
214
|
const virtualEnv = process.env.VIRTUAL_ENV;
|
|
211
215
|
if (virtualEnv) {
|
|
212
216
|
candidates.push({
|
|
213
|
-
path: join4(virtualEnv,
|
|
217
|
+
path: join4(virtualEnv, VENV_BIN2, `dbt${EXE}`),
|
|
214
218
|
source: `VIRTUAL_ENV (${virtualEnv})`,
|
|
215
|
-
binDir: join4(virtualEnv,
|
|
219
|
+
binDir: join4(virtualEnv, VENV_BIN2)
|
|
216
220
|
});
|
|
217
221
|
}
|
|
218
222
|
const currentEnv = { ...process.env };
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
223
|
+
if (!isWindows2) {
|
|
224
|
+
const pyenvRoot = process.env.PYENV_ROOT ?? join4(process.env.HOME ?? "", ".pyenv");
|
|
225
|
+
if (existsSync4(join4(pyenvRoot, "shims", "dbt"))) {
|
|
226
|
+
try {
|
|
227
|
+
const realDbt = execFileSync3("pyenv", ["which", "dbt"], {
|
|
228
|
+
encoding: "utf-8",
|
|
229
|
+
timeout: 5000,
|
|
230
|
+
env: { ...currentEnv, PYENV_ROOT: pyenvRoot }
|
|
231
|
+
}).trim();
|
|
232
|
+
if (realDbt) {
|
|
233
|
+
candidates.push({ path: realDbt, source: `pyenv which dbt`, binDir: dirname(realDbt) });
|
|
234
|
+
}
|
|
235
|
+
} catch {}
|
|
236
|
+
}
|
|
237
|
+
const asdfDataDir = process.env.ASDF_DATA_DIR ?? join4(process.env.HOME ?? "", ".asdf");
|
|
238
|
+
if (existsSync4(join4(asdfDataDir, "shims", "dbt"))) {
|
|
239
|
+
try {
|
|
240
|
+
const realDbt = execFileSync3("asdf", ["which", "dbt"], {
|
|
241
|
+
encoding: "utf-8",
|
|
242
|
+
timeout: 5000,
|
|
243
|
+
env: currentEnv
|
|
244
|
+
}).trim();
|
|
245
|
+
if (realDbt) {
|
|
246
|
+
candidates.push({ path: realDbt, source: `asdf which dbt`, binDir: dirname(realDbt) });
|
|
247
|
+
}
|
|
248
|
+
} catch {}
|
|
249
|
+
}
|
|
244
250
|
}
|
|
251
|
+
const whichCmd = isWindows2 ? "where" : "which";
|
|
252
|
+
const dbtCmd = `dbt${EXE}`;
|
|
245
253
|
try {
|
|
246
|
-
const
|
|
254
|
+
const found = execFileSync3(whichCmd, [dbtCmd], {
|
|
247
255
|
encoding: "utf-8",
|
|
248
256
|
timeout: 5000,
|
|
249
257
|
env: currentEnv
|
|
250
|
-
}).trim();
|
|
251
|
-
if (
|
|
252
|
-
candidates.push({ path:
|
|
258
|
+
}).trim().split(/\r?\n/)[0];
|
|
259
|
+
if (found) {
|
|
260
|
+
candidates.push({ path: found, source: `${whichCmd} dbt (PATH)`, binDir: dirname(found) });
|
|
253
261
|
}
|
|
254
262
|
} catch {}
|
|
255
|
-
const home = process.env.HOME ?? "";
|
|
256
|
-
const knownPaths = [
|
|
263
|
+
const home = process.env.HOME ?? process.env.USERPROFILE ?? "";
|
|
264
|
+
const knownPaths = isWindows2 ? [
|
|
265
|
+
{
|
|
266
|
+
path: join4(home, "AppData", "Roaming", "Python", "Scripts", "dbt.exe"),
|
|
267
|
+
source: "%APPDATA%/Python/Scripts/dbt.exe (user pip)"
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
path: join4(home, "AppData", "Local", "Programs", "Python", "Scripts", "dbt.exe"),
|
|
271
|
+
source: "%LOCALAPPDATA%/Programs/Python/Scripts/dbt.exe (system pip)"
|
|
272
|
+
}
|
|
273
|
+
] : [
|
|
257
274
|
{ path: join4(home, ".local", "bin", "dbt"), source: "~/.local/bin/dbt (pipx/user pip)" },
|
|
258
275
|
{ path: "/usr/local/bin/dbt", source: "/usr/local/bin/dbt (system pip)" },
|
|
259
276
|
{ path: "/opt/homebrew/bin/dbt", source: "/opt/homebrew/bin/dbt (homebrew, deprecated)" }
|
|
@@ -266,16 +283,21 @@ function resolveDbt(pythonPath, projectRoot) {
|
|
|
266
283
|
return candidate;
|
|
267
284
|
}
|
|
268
285
|
}
|
|
269
|
-
return { path:
|
|
286
|
+
return { path: `dbt${EXE}`, source: "fallback (bare dbt on PATH)" };
|
|
270
287
|
}
|
|
271
288
|
function buildDbtEnv(resolved) {
|
|
272
289
|
const env = { ...process.env };
|
|
273
290
|
if (resolved.binDir) {
|
|
274
|
-
env.PATH = `${resolved.binDir}
|
|
291
|
+
env.PATH = `${resolved.binDir}${delimiter}${env.PATH ?? ""}`;
|
|
275
292
|
}
|
|
276
293
|
return env;
|
|
277
294
|
}
|
|
278
|
-
var
|
|
295
|
+
var isWindows2, VENV_BIN2, EXE;
|
|
296
|
+
var init_dbt_resolve = __esm(() => {
|
|
297
|
+
isWindows2 = process.platform === "win32";
|
|
298
|
+
VENV_BIN2 = isWindows2 ? "Scripts" : "bin";
|
|
299
|
+
EXE = isWindows2 ? ".exe" : "";
|
|
300
|
+
});
|
|
279
301
|
|
|
280
302
|
// src/dbt-cli.ts
|
|
281
303
|
var exports_dbt_cli = {};
|
|
@@ -303,12 +325,12 @@ function run2(args) {
|
|
|
303
325
|
const dbt2 = getDbt();
|
|
304
326
|
const env = buildDbtEnv(dbt2);
|
|
305
327
|
const cwd = globalOptions.projectRoot ?? process.cwd();
|
|
306
|
-
return new Promise((
|
|
328
|
+
return new Promise((resolve4, reject2) => {
|
|
307
329
|
execFile(dbt2.path, args, { timeout: 120000, maxBuffer: 10 * 1024 * 1024, env, cwd }, (err, stdout, stderr) => {
|
|
308
330
|
if (err)
|
|
309
331
|
reject2(err);
|
|
310
332
|
else
|
|
311
|
-
|
|
333
|
+
resolve4({ stdout, stderr });
|
|
312
334
|
});
|
|
313
335
|
});
|
|
314
336
|
}
|
|
@@ -1430,13 +1452,13 @@ var require_thenables = __commonJS((exports, module) => {
|
|
|
1430
1452
|
if (context)
|
|
1431
1453
|
context._popContext();
|
|
1432
1454
|
var synchronous = true;
|
|
1433
|
-
var result = util.tryCatch(then).call(x,
|
|
1455
|
+
var result = util.tryCatch(then).call(x, resolve4, reject2);
|
|
1434
1456
|
synchronous = false;
|
|
1435
1457
|
if (promise && result === errorObj) {
|
|
1436
1458
|
promise._rejectCallback(result.e, true, true);
|
|
1437
1459
|
promise = null;
|
|
1438
1460
|
}
|
|
1439
|
-
function
|
|
1461
|
+
function resolve4(value) {
|
|
1440
1462
|
if (!promise)
|
|
1441
1463
|
return;
|
|
1442
1464
|
promise._resolveCallback(value);
|
|
@@ -2024,9 +2046,9 @@ var require_debuggability = __commonJS((exports, module) => {
|
|
|
2024
2046
|
return false;
|
|
2025
2047
|
}
|
|
2026
2048
|
Promise2.prototype._fireEvent = defaultFireEvent;
|
|
2027
|
-
Promise2.prototype._execute = function(executor,
|
|
2049
|
+
Promise2.prototype._execute = function(executor, resolve4, reject2) {
|
|
2028
2050
|
try {
|
|
2029
|
-
executor(
|
|
2051
|
+
executor(resolve4, reject2);
|
|
2030
2052
|
} catch (e) {
|
|
2031
2053
|
return e;
|
|
2032
2054
|
}
|
|
@@ -2039,10 +2061,10 @@ var require_debuggability = __commonJS((exports, module) => {
|
|
|
2039
2061
|
Promise2.prototype._dereferenceTrace = function() {};
|
|
2040
2062
|
Promise2.prototype._clearCancellationData = function() {};
|
|
2041
2063
|
Promise2.prototype._propagateFrom = function(parent, flags) {};
|
|
2042
|
-
function cancellationExecute(executor,
|
|
2064
|
+
function cancellationExecute(executor, resolve4, reject2) {
|
|
2043
2065
|
var promise = this;
|
|
2044
2066
|
try {
|
|
2045
|
-
executor(
|
|
2067
|
+
executor(resolve4, reject2, function(onCancel) {
|
|
2046
2068
|
if (typeof onCancel !== "function") {
|
|
2047
2069
|
throw new TypeError("onCancel must be a function, got: " + util.toString(onCancel));
|
|
2048
2070
|
}
|
|
@@ -5649,7 +5671,7 @@ var require_bluebird = __commonJS((exports, module) => {
|
|
|
5649
5671
|
|
|
5650
5672
|
// ../../node_modules/.bun/python-bridge@1.1.0/node_modules/python-bridge/index.js
|
|
5651
5673
|
var require_python_bridge = __commonJS((exports, module) => {
|
|
5652
|
-
var __dirname = "
|
|
5674
|
+
var __dirname = typeof import.meta.dirname === "string" ? import.meta.dirname : __require("path").dirname(__require("url").fileURLToPath(import.meta.url));
|
|
5653
5675
|
var Promise2 = require_bluebird();
|
|
5654
5676
|
var path = __require("path");
|
|
5655
5677
|
var child_process = Promise2.promisifyAll(__require("child_process"));
|
|
@@ -5769,12 +5791,12 @@ var require_python_bridge = __commonJS((exports, module) => {
|
|
|
5769
5791
|
return function enqueue2(f) {
|
|
5770
5792
|
let wait = last;
|
|
5771
5793
|
let done;
|
|
5772
|
-
last = new Promise2((
|
|
5773
|
-
done =
|
|
5794
|
+
last = new Promise2((resolve4) => {
|
|
5795
|
+
done = resolve4;
|
|
5774
5796
|
});
|
|
5775
|
-
return new Promise2((
|
|
5797
|
+
return new Promise2((resolve4, reject2) => {
|
|
5776
5798
|
wait.finally(() => {
|
|
5777
|
-
Promise2.try(f).then(
|
|
5799
|
+
Promise2.try(f).then(resolve4, reject2);
|
|
5778
5800
|
});
|
|
5779
5801
|
}).finally(() => done());
|
|
5780
5802
|
};
|
|
@@ -14646,7 +14668,7 @@ var require_ponyfill_es2018 = __commonJS((exports, module) => {
|
|
|
14646
14668
|
return new originalPromise(executor);
|
|
14647
14669
|
}
|
|
14648
14670
|
function promiseResolvedWith(value) {
|
|
14649
|
-
return newPromise((
|
|
14671
|
+
return newPromise((resolve4) => resolve4(value));
|
|
14650
14672
|
}
|
|
14651
14673
|
function promiseRejectedWith(reason) {
|
|
14652
14674
|
return originalPromiseReject(reason);
|
|
@@ -14801,8 +14823,8 @@ var require_ponyfill_es2018 = __commonJS((exports, module) => {
|
|
|
14801
14823
|
return new TypeError("Cannot " + name + " a stream using a released reader");
|
|
14802
14824
|
}
|
|
14803
14825
|
function defaultReaderClosedPromiseInitialize(reader) {
|
|
14804
|
-
reader._closedPromise = newPromise((
|
|
14805
|
-
reader._closedPromise_resolve =
|
|
14826
|
+
reader._closedPromise = newPromise((resolve4, reject2) => {
|
|
14827
|
+
reader._closedPromise_resolve = resolve4;
|
|
14806
14828
|
reader._closedPromise_reject = reject2;
|
|
14807
14829
|
});
|
|
14808
14830
|
}
|
|
@@ -14965,8 +14987,8 @@ var require_ponyfill_es2018 = __commonJS((exports, module) => {
|
|
|
14965
14987
|
}
|
|
14966
14988
|
let resolvePromise;
|
|
14967
14989
|
let rejectPromise;
|
|
14968
|
-
const promise = newPromise((
|
|
14969
|
-
resolvePromise =
|
|
14990
|
+
const promise = newPromise((resolve4, reject2) => {
|
|
14991
|
+
resolvePromise = resolve4;
|
|
14970
14992
|
rejectPromise = reject2;
|
|
14971
14993
|
});
|
|
14972
14994
|
const readRequest = {
|
|
@@ -15062,8 +15084,8 @@ var require_ponyfill_es2018 = __commonJS((exports, module) => {
|
|
|
15062
15084
|
const reader = this._reader;
|
|
15063
15085
|
let resolvePromise;
|
|
15064
15086
|
let rejectPromise;
|
|
15065
|
-
const promise = newPromise((
|
|
15066
|
-
resolvePromise =
|
|
15087
|
+
const promise = newPromise((resolve4, reject2) => {
|
|
15088
|
+
resolvePromise = resolve4;
|
|
15067
15089
|
rejectPromise = reject2;
|
|
15068
15090
|
});
|
|
15069
15091
|
const readRequest = {
|
|
@@ -16060,8 +16082,8 @@ var require_ponyfill_es2018 = __commonJS((exports, module) => {
|
|
|
16060
16082
|
}
|
|
16061
16083
|
let resolvePromise;
|
|
16062
16084
|
let rejectPromise;
|
|
16063
|
-
const promise = newPromise((
|
|
16064
|
-
resolvePromise =
|
|
16085
|
+
const promise = newPromise((resolve4, reject2) => {
|
|
16086
|
+
resolvePromise = resolve4;
|
|
16065
16087
|
rejectPromise = reject2;
|
|
16066
16088
|
});
|
|
16067
16089
|
const readIntoRequest = {
|
|
@@ -16337,10 +16359,10 @@ var require_ponyfill_es2018 = __commonJS((exports, module) => {
|
|
|
16337
16359
|
wasAlreadyErroring = true;
|
|
16338
16360
|
reason = undefined;
|
|
16339
16361
|
}
|
|
16340
|
-
const promise = newPromise((
|
|
16362
|
+
const promise = newPromise((resolve4, reject2) => {
|
|
16341
16363
|
stream._pendingAbortRequest = {
|
|
16342
16364
|
_promise: undefined,
|
|
16343
|
-
_resolve:
|
|
16365
|
+
_resolve: resolve4,
|
|
16344
16366
|
_reject: reject2,
|
|
16345
16367
|
_reason: reason,
|
|
16346
16368
|
_wasAlreadyErroring: wasAlreadyErroring
|
|
@@ -16357,9 +16379,9 @@ var require_ponyfill_es2018 = __commonJS((exports, module) => {
|
|
|
16357
16379
|
if (state === "closed" || state === "errored") {
|
|
16358
16380
|
return promiseRejectedWith(new TypeError(`The stream (in ${state} state) is not in the writable state and cannot be closed`));
|
|
16359
16381
|
}
|
|
16360
|
-
const promise = newPromise((
|
|
16382
|
+
const promise = newPromise((resolve4, reject2) => {
|
|
16361
16383
|
const closeRequest = {
|
|
16362
|
-
_resolve:
|
|
16384
|
+
_resolve: resolve4,
|
|
16363
16385
|
_reject: reject2
|
|
16364
16386
|
};
|
|
16365
16387
|
stream._closeRequest = closeRequest;
|
|
@@ -16372,9 +16394,9 @@ var require_ponyfill_es2018 = __commonJS((exports, module) => {
|
|
|
16372
16394
|
return promise;
|
|
16373
16395
|
}
|
|
16374
16396
|
function WritableStreamAddWriteRequest(stream) {
|
|
16375
|
-
const promise = newPromise((
|
|
16397
|
+
const promise = newPromise((resolve4, reject2) => {
|
|
16376
16398
|
const writeRequest = {
|
|
16377
|
-
_resolve:
|
|
16399
|
+
_resolve: resolve4,
|
|
16378
16400
|
_reject: reject2
|
|
16379
16401
|
};
|
|
16380
16402
|
stream._writeRequests.push(writeRequest);
|
|
@@ -16939,8 +16961,8 @@ var require_ponyfill_es2018 = __commonJS((exports, module) => {
|
|
|
16939
16961
|
return new TypeError("Cannot " + name + " a stream using a released writer");
|
|
16940
16962
|
}
|
|
16941
16963
|
function defaultWriterClosedPromiseInitialize(writer) {
|
|
16942
|
-
writer._closedPromise = newPromise((
|
|
16943
|
-
writer._closedPromise_resolve =
|
|
16964
|
+
writer._closedPromise = newPromise((resolve4, reject2) => {
|
|
16965
|
+
writer._closedPromise_resolve = resolve4;
|
|
16944
16966
|
writer._closedPromise_reject = reject2;
|
|
16945
16967
|
writer._closedPromiseState = "pending";
|
|
16946
16968
|
});
|
|
@@ -16976,8 +16998,8 @@ var require_ponyfill_es2018 = __commonJS((exports, module) => {
|
|
|
16976
16998
|
writer._closedPromiseState = "resolved";
|
|
16977
16999
|
}
|
|
16978
17000
|
function defaultWriterReadyPromiseInitialize(writer) {
|
|
16979
|
-
writer._readyPromise = newPromise((
|
|
16980
|
-
writer._readyPromise_resolve =
|
|
17001
|
+
writer._readyPromise = newPromise((resolve4, reject2) => {
|
|
17002
|
+
writer._readyPromise_resolve = resolve4;
|
|
16981
17003
|
writer._readyPromise_reject = reject2;
|
|
16982
17004
|
});
|
|
16983
17005
|
writer._readyPromiseState = "pending";
|
|
@@ -17064,7 +17086,7 @@ var require_ponyfill_es2018 = __commonJS((exports, module) => {
|
|
|
17064
17086
|
source._disturbed = true;
|
|
17065
17087
|
let shuttingDown = false;
|
|
17066
17088
|
let currentWrite = promiseResolvedWith(undefined);
|
|
17067
|
-
return newPromise((
|
|
17089
|
+
return newPromise((resolve4, reject2) => {
|
|
17068
17090
|
let abortAlgorithm;
|
|
17069
17091
|
if (signal !== undefined) {
|
|
17070
17092
|
abortAlgorithm = () => {
|
|
@@ -17209,7 +17231,7 @@ var require_ponyfill_es2018 = __commonJS((exports, module) => {
|
|
|
17209
17231
|
if (isError) {
|
|
17210
17232
|
reject2(error);
|
|
17211
17233
|
} else {
|
|
17212
|
-
|
|
17234
|
+
resolve4(undefined);
|
|
17213
17235
|
}
|
|
17214
17236
|
return null;
|
|
17215
17237
|
}
|
|
@@ -17478,8 +17500,8 @@ var require_ponyfill_es2018 = __commonJS((exports, module) => {
|
|
|
17478
17500
|
let branch1;
|
|
17479
17501
|
let branch2;
|
|
17480
17502
|
let resolveCancelPromise;
|
|
17481
|
-
const cancelPromise = newPromise((
|
|
17482
|
-
resolveCancelPromise =
|
|
17503
|
+
const cancelPromise = newPromise((resolve4) => {
|
|
17504
|
+
resolveCancelPromise = resolve4;
|
|
17483
17505
|
});
|
|
17484
17506
|
function pullAlgorithm() {
|
|
17485
17507
|
if (reading) {
|
|
@@ -17569,8 +17591,8 @@ var require_ponyfill_es2018 = __commonJS((exports, module) => {
|
|
|
17569
17591
|
let branch1;
|
|
17570
17592
|
let branch2;
|
|
17571
17593
|
let resolveCancelPromise;
|
|
17572
|
-
const cancelPromise = newPromise((
|
|
17573
|
-
resolveCancelPromise =
|
|
17594
|
+
const cancelPromise = newPromise((resolve4) => {
|
|
17595
|
+
resolveCancelPromise = resolve4;
|
|
17574
17596
|
});
|
|
17575
17597
|
function forwardReaderError(thisReader) {
|
|
17576
17598
|
uponRejection(thisReader._closedPromise, (r) => {
|
|
@@ -18315,8 +18337,8 @@ var require_ponyfill_es2018 = __commonJS((exports, module) => {
|
|
|
18315
18337
|
const writableHighWaterMark = ExtractHighWaterMark(writableStrategy, 1);
|
|
18316
18338
|
const writableSizeAlgorithm = ExtractSizeAlgorithm(writableStrategy);
|
|
18317
18339
|
let startPromise_resolve;
|
|
18318
|
-
const startPromise = newPromise((
|
|
18319
|
-
startPromise_resolve =
|
|
18340
|
+
const startPromise = newPromise((resolve4) => {
|
|
18341
|
+
startPromise_resolve = resolve4;
|
|
18320
18342
|
});
|
|
18321
18343
|
InitializeTransformStream(this, startPromise, writableHighWaterMark, writableSizeAlgorithm, readableHighWaterMark, readableSizeAlgorithm);
|
|
18322
18344
|
SetUpTransformStreamDefaultControllerFromTransformer(this, transformer);
|
|
@@ -18403,8 +18425,8 @@ var require_ponyfill_es2018 = __commonJS((exports, module) => {
|
|
|
18403
18425
|
if (stream._backpressureChangePromise !== undefined) {
|
|
18404
18426
|
stream._backpressureChangePromise_resolve();
|
|
18405
18427
|
}
|
|
18406
|
-
stream._backpressureChangePromise = newPromise((
|
|
18407
|
-
stream._backpressureChangePromise_resolve =
|
|
18428
|
+
stream._backpressureChangePromise = newPromise((resolve4) => {
|
|
18429
|
+
stream._backpressureChangePromise_resolve = resolve4;
|
|
18408
18430
|
});
|
|
18409
18431
|
stream._backpressure = backpressure;
|
|
18410
18432
|
}
|
|
@@ -18562,8 +18584,8 @@ var require_ponyfill_es2018 = __commonJS((exports, module) => {
|
|
|
18562
18584
|
return controller._finishPromise;
|
|
18563
18585
|
}
|
|
18564
18586
|
const readable = stream._readable;
|
|
18565
|
-
controller._finishPromise = newPromise((
|
|
18566
|
-
controller._finishPromise_resolve =
|
|
18587
|
+
controller._finishPromise = newPromise((resolve4, reject2) => {
|
|
18588
|
+
controller._finishPromise_resolve = resolve4;
|
|
18567
18589
|
controller._finishPromise_reject = reject2;
|
|
18568
18590
|
});
|
|
18569
18591
|
const cancelPromise = controller._cancelAlgorithm(reason);
|
|
@@ -18589,8 +18611,8 @@ var require_ponyfill_es2018 = __commonJS((exports, module) => {
|
|
|
18589
18611
|
return controller._finishPromise;
|
|
18590
18612
|
}
|
|
18591
18613
|
const readable = stream._readable;
|
|
18592
|
-
controller._finishPromise = newPromise((
|
|
18593
|
-
controller._finishPromise_resolve =
|
|
18614
|
+
controller._finishPromise = newPromise((resolve4, reject2) => {
|
|
18615
|
+
controller._finishPromise_resolve = resolve4;
|
|
18594
18616
|
controller._finishPromise_reject = reject2;
|
|
18595
18617
|
});
|
|
18596
18618
|
const flushPromise = controller._flushAlgorithm();
|
|
@@ -18620,8 +18642,8 @@ var require_ponyfill_es2018 = __commonJS((exports, module) => {
|
|
|
18620
18642
|
return controller._finishPromise;
|
|
18621
18643
|
}
|
|
18622
18644
|
const writable = stream._writable;
|
|
18623
|
-
controller._finishPromise = newPromise((
|
|
18624
|
-
controller._finishPromise_resolve =
|
|
18645
|
+
controller._finishPromise = newPromise((resolve4, reject2) => {
|
|
18646
|
+
controller._finishPromise_resolve = resolve4;
|
|
18625
18647
|
controller._finishPromise_reject = reject2;
|
|
18626
18648
|
});
|
|
18627
18649
|
const cancelPromise = controller._cancelAlgorithm(reason);
|
|
@@ -20343,7 +20365,7 @@ import zlib from "node:zlib";
|
|
|
20343
20365
|
import Stream2, { PassThrough as PassThrough2, pipeline as pump } from "node:stream";
|
|
20344
20366
|
import { Buffer as Buffer3 } from "node:buffer";
|
|
20345
20367
|
async function fetch(url, options_) {
|
|
20346
|
-
return new Promise((
|
|
20368
|
+
return new Promise((resolve4, reject2) => {
|
|
20347
20369
|
const request = new Request(url, options_);
|
|
20348
20370
|
const { parsedURL, options: options2 } = getNodeRequestOptions(request);
|
|
20349
20371
|
if (!supportedSchemas.has(parsedURL.protocol)) {
|
|
@@ -20352,7 +20374,7 @@ async function fetch(url, options_) {
|
|
|
20352
20374
|
if (parsedURL.protocol === "data:") {
|
|
20353
20375
|
const data2 = dist_default(request.url);
|
|
20354
20376
|
const response2 = new Response(data2, { headers: { "Content-Type": data2.typeFull } });
|
|
20355
|
-
|
|
20377
|
+
resolve4(response2);
|
|
20356
20378
|
return;
|
|
20357
20379
|
}
|
|
20358
20380
|
const send = (parsedURL.protocol === "https:" ? https : http2).request;
|
|
@@ -20474,7 +20496,7 @@ async function fetch(url, options_) {
|
|
|
20474
20496
|
if (responseReferrerPolicy) {
|
|
20475
20497
|
requestOptions.referrerPolicy = responseReferrerPolicy;
|
|
20476
20498
|
}
|
|
20477
|
-
|
|
20499
|
+
resolve4(fetch(new Request(locationURL, requestOptions)));
|
|
20478
20500
|
finalize();
|
|
20479
20501
|
return;
|
|
20480
20502
|
}
|
|
@@ -20507,7 +20529,7 @@ async function fetch(url, options_) {
|
|
|
20507
20529
|
const codings = headers.get("Content-Encoding");
|
|
20508
20530
|
if (!request.compress || request.method === "HEAD" || codings === null || response_.statusCode === 204 || response_.statusCode === 304) {
|
|
20509
20531
|
response = new Response(body, responseOptions);
|
|
20510
|
-
|
|
20532
|
+
resolve4(response);
|
|
20511
20533
|
return;
|
|
20512
20534
|
}
|
|
20513
20535
|
const zlibOptions = {
|
|
@@ -20521,7 +20543,7 @@ async function fetch(url, options_) {
|
|
|
20521
20543
|
}
|
|
20522
20544
|
});
|
|
20523
20545
|
response = new Response(body, responseOptions);
|
|
20524
|
-
|
|
20546
|
+
resolve4(response);
|
|
20525
20547
|
return;
|
|
20526
20548
|
}
|
|
20527
20549
|
if (codings === "deflate" || codings === "x-deflate") {
|
|
@@ -20545,12 +20567,12 @@ async function fetch(url, options_) {
|
|
|
20545
20567
|
});
|
|
20546
20568
|
}
|
|
20547
20569
|
response = new Response(body, responseOptions);
|
|
20548
|
-
|
|
20570
|
+
resolve4(response);
|
|
20549
20571
|
});
|
|
20550
20572
|
raw.once("end", () => {
|
|
20551
20573
|
if (!response) {
|
|
20552
20574
|
response = new Response(body, responseOptions);
|
|
20553
|
-
|
|
20575
|
+
resolve4(response);
|
|
20554
20576
|
}
|
|
20555
20577
|
});
|
|
20556
20578
|
return;
|
|
@@ -20562,11 +20584,11 @@ async function fetch(url, options_) {
|
|
|
20562
20584
|
}
|
|
20563
20585
|
});
|
|
20564
20586
|
response = new Response(body, responseOptions);
|
|
20565
|
-
|
|
20587
|
+
resolve4(response);
|
|
20566
20588
|
return;
|
|
20567
20589
|
}
|
|
20568
20590
|
response = new Response(body, responseOptions);
|
|
20569
|
-
|
|
20591
|
+
resolve4(response);
|
|
20570
20592
|
});
|
|
20571
20593
|
writeToStream(request_, request).catch(reject2);
|
|
20572
20594
|
});
|
|
@@ -23300,11 +23322,11 @@ async function create(cfg) {
|
|
|
23300
23322
|
};
|
|
23301
23323
|
const exec = new Ht(term);
|
|
23302
23324
|
const infra = new St(runtime, term);
|
|
23303
|
-
const
|
|
23325
|
+
const python3 = new xt(exec, runtime, term, config);
|
|
23304
23326
|
const cli = (cwd, path) => new _t(exec, runtime, term, cwd, path);
|
|
23305
|
-
const core = (root, diag, defer, changed) => new X(infra, runtime, provider,
|
|
23327
|
+
const core = (root, diag, defer, changed) => new X(infra, runtime, provider, python3, cli, term, config, client, root, diag, defer, changed);
|
|
23306
23328
|
const cloud = (root, diag, defer, changed) => new Z2(infra, factory, cli, runtime, provider, term, root, diag, defer, changed);
|
|
23307
|
-
const command = (root, diag, defer, changed) => new Qt(infra, runtime, provider,
|
|
23329
|
+
const command = (root, diag, defer, changed) => new Qt(infra, runtime, provider, python3, cli, term, config, client, root, diag, defer, changed);
|
|
23308
23330
|
const fusion = (root, diag, defer, changed) => new Wt(infra, factory, cli, runtime, provider, term, root, diag, defer, changed);
|
|
23309
23331
|
const adapter = new Xt(config, factory, core, cloud, fusion, command, cfg.projectRoot, undefined, new Zt, new se(term), new oe(term), new ae(term), new ne(term), new ce(term), new de(term), new ee(term), new re(term), new te(term), term, new ie(term, client, config));
|
|
23310
23332
|
await adapter.initialize();
|
|
@@ -23572,42 +23594,25 @@ function flag6(args, name) {
|
|
|
23572
23594
|
}
|
|
23573
23595
|
|
|
23574
23596
|
// src/index.ts
|
|
23575
|
-
import { join as join8, resolve as
|
|
23597
|
+
import { join as join8, resolve as resolve4 } from "path";
|
|
23576
23598
|
import { existsSync as existsSync6 } from "fs";
|
|
23577
23599
|
|
|
23578
23600
|
// src/config.ts
|
|
23579
23601
|
import { homedir } from "os";
|
|
23580
|
-
import { join } from "path";
|
|
23602
|
+
import { join, resolve as resolve2 } from "path";
|
|
23581
23603
|
import { readFile, writeFile, mkdir } from "fs/promises";
|
|
23582
23604
|
import { existsSync } from "fs";
|
|
23605
|
+
import { execFileSync } from "child_process";
|
|
23583
23606
|
function configDir() {
|
|
23584
23607
|
return join(process.env.HOME || homedir(), ".altimate-code");
|
|
23585
23608
|
}
|
|
23586
23609
|
function configPath() {
|
|
23587
23610
|
return join(configDir(), "dbt.json");
|
|
23588
23611
|
}
|
|
23589
|
-
|
|
23590
|
-
const p = configPath();
|
|
23591
|
-
if (!existsSync(p))
|
|
23592
|
-
return null;
|
|
23593
|
-
const raw = await readFile(p, "utf-8");
|
|
23594
|
-
return JSON.parse(raw);
|
|
23595
|
-
}
|
|
23596
|
-
async function write(cfg) {
|
|
23597
|
-
const d = configDir();
|
|
23598
|
-
await mkdir(d, { recursive: true });
|
|
23599
|
-
await writeFile(join(d, "dbt.json"), JSON.stringify(cfg, null, 2));
|
|
23600
|
-
}
|
|
23601
|
-
|
|
23602
|
-
// src/commands/init.ts
|
|
23603
|
-
import { join as join3, resolve as resolve2 } from "path";
|
|
23604
|
-
import { existsSync as existsSync3 } from "fs";
|
|
23605
|
-
import { execFileSync as execFileSync2 } from "child_process";
|
|
23606
|
-
init_check();
|
|
23607
|
-
function find(start) {
|
|
23612
|
+
function findProjectRoot(start = process.cwd()) {
|
|
23608
23613
|
let dir = resolve2(start);
|
|
23609
23614
|
while (true) {
|
|
23610
|
-
if (
|
|
23615
|
+
if (existsSync(join(dir, "dbt_project.yml")))
|
|
23611
23616
|
return dir;
|
|
23612
23617
|
const parent = resolve2(dir, "..");
|
|
23613
23618
|
if (parent === dir)
|
|
@@ -23615,46 +23620,85 @@ function find(start) {
|
|
|
23615
23620
|
dir = parent;
|
|
23616
23621
|
}
|
|
23617
23622
|
}
|
|
23618
|
-
|
|
23619
|
-
|
|
23620
|
-
|
|
23621
|
-
|
|
23622
|
-
|
|
23623
|
+
var isWindows = process.platform === "win32";
|
|
23624
|
+
var VENV_BIN = isWindows ? "Scripts" : "bin";
|
|
23625
|
+
function discoverPython(projectRoot) {
|
|
23626
|
+
const pythonBins = isWindows ? ["python.exe", "python3.exe"] : ["python3", "python"];
|
|
23627
|
+
for (const venvDir of [".venv", "venv", "env"]) {
|
|
23628
|
+
for (const bin of pythonBins) {
|
|
23629
|
+
const py = join(projectRoot, venvDir, VENV_BIN, bin);
|
|
23630
|
+
if (existsSync(py))
|
|
23623
23631
|
return py;
|
|
23624
23632
|
}
|
|
23625
23633
|
}
|
|
23626
23634
|
const virtualEnv = process.env.VIRTUAL_ENV;
|
|
23627
23635
|
if (virtualEnv) {
|
|
23628
|
-
|
|
23629
|
-
|
|
23630
|
-
|
|
23636
|
+
for (const bin of pythonBins) {
|
|
23637
|
+
const py = join(virtualEnv, VENV_BIN, bin);
|
|
23638
|
+
if (existsSync(py))
|
|
23639
|
+
return py;
|
|
23640
|
+
}
|
|
23631
23641
|
}
|
|
23632
23642
|
const condaPrefix = process.env.CONDA_PREFIX;
|
|
23633
23643
|
if (condaPrefix) {
|
|
23634
|
-
|
|
23635
|
-
|
|
23636
|
-
|
|
23644
|
+
for (const bin of pythonBins) {
|
|
23645
|
+
const py = isWindows ? join(condaPrefix, bin) : join(condaPrefix, VENV_BIN, bin);
|
|
23646
|
+
if (existsSync(py))
|
|
23647
|
+
return py;
|
|
23648
|
+
}
|
|
23637
23649
|
}
|
|
23638
|
-
|
|
23650
|
+
const whichCmd = isWindows ? "where" : "which";
|
|
23651
|
+
const cmds = isWindows ? ["python.exe", "python3.exe", "python"] : ["python3", "python"];
|
|
23652
|
+
for (const cmd of cmds) {
|
|
23653
|
+
try {
|
|
23654
|
+
const first = execFileSync(whichCmd, [cmd], { encoding: "utf-8", timeout: 5000 }).trim().split(/\r?\n/)[0];
|
|
23655
|
+
if (first)
|
|
23656
|
+
return first;
|
|
23657
|
+
} catch {}
|
|
23658
|
+
}
|
|
23659
|
+
return isWindows ? "python.exe" : "python3";
|
|
23660
|
+
}
|
|
23661
|
+
async function read() {
|
|
23662
|
+
const p = configPath();
|
|
23663
|
+
if (existsSync(p)) {
|
|
23639
23664
|
try {
|
|
23640
|
-
|
|
23665
|
+
const raw = await readFile(p, "utf-8");
|
|
23666
|
+
return JSON.parse(raw);
|
|
23641
23667
|
} catch {}
|
|
23642
23668
|
}
|
|
23643
|
-
|
|
23669
|
+
const projectRoot = findProjectRoot();
|
|
23670
|
+
if (!projectRoot)
|
|
23671
|
+
return null;
|
|
23672
|
+
return {
|
|
23673
|
+
projectRoot,
|
|
23674
|
+
pythonPath: discoverPython(projectRoot),
|
|
23675
|
+
dbtIntegration: "corecommand",
|
|
23676
|
+
queryLimit: 500
|
|
23677
|
+
};
|
|
23644
23678
|
}
|
|
23679
|
+
async function write(cfg) {
|
|
23680
|
+
const d = configDir();
|
|
23681
|
+
await mkdir(d, { recursive: true });
|
|
23682
|
+
await writeFile(join(d, "dbt.json"), JSON.stringify(cfg, null, 2));
|
|
23683
|
+
}
|
|
23684
|
+
|
|
23685
|
+
// src/commands/init.ts
|
|
23686
|
+
import { resolve as resolve3, join as join3 } from "path";
|
|
23687
|
+
import { existsSync as existsSync3 } from "fs";
|
|
23688
|
+
init_check();
|
|
23645
23689
|
async function init(args) {
|
|
23646
23690
|
const idx = args.indexOf("--project-root");
|
|
23647
23691
|
const root = idx >= 0 ? args[idx + 1] : undefined;
|
|
23648
23692
|
const pidx = args.indexOf("--python-path");
|
|
23649
23693
|
const py = pidx >= 0 ? args[pidx + 1] : undefined;
|
|
23650
|
-
const project2 = root ?
|
|
23694
|
+
const project2 = root ? resolve3(root) : findProjectRoot(process.cwd());
|
|
23651
23695
|
if (!project2)
|
|
23652
23696
|
return { error: "No dbt_project.yml found. Use --project-root to specify." };
|
|
23653
23697
|
if (!existsSync3(join3(project2, "dbt_project.yml")))
|
|
23654
23698
|
return { error: `No dbt_project.yml in ${project2}` };
|
|
23655
23699
|
const cfg = {
|
|
23656
23700
|
projectRoot: project2,
|
|
23657
|
-
pythonPath: py ??
|
|
23701
|
+
pythonPath: py ?? discoverPython(project2),
|
|
23658
23702
|
dbtIntegration: "corecommand",
|
|
23659
23703
|
queryLimit: 500
|
|
23660
23704
|
};
|
|
@@ -23777,11 +23821,11 @@ async function main() {
|
|
|
23777
23821
|
return { error: "No config found. Run: altimate-dbt init" };
|
|
23778
23822
|
const dirFlag = flag7(rest, "project-dir");
|
|
23779
23823
|
if (dirFlag) {
|
|
23780
|
-
cfg.projectRoot =
|
|
23824
|
+
cfg.projectRoot = resolve4(dirFlag);
|
|
23781
23825
|
} else {
|
|
23782
23826
|
const cwdProject = join8(process.cwd(), "dbt_project.yml");
|
|
23783
|
-
if (existsSync6(cwdProject) &&
|
|
23784
|
-
cfg.projectRoot =
|
|
23827
|
+
if (existsSync6(cwdProject) && resolve4(process.cwd()) !== resolve4(cfg.projectRoot)) {
|
|
23828
|
+
cfg.projectRoot = resolve4(process.cwd());
|
|
23785
23829
|
}
|
|
23786
23830
|
}
|
|
23787
23831
|
if (cmd === "doctor")
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
from __future__ import unicode_literals
|
|
2
|
+
|
|
3
|
+
from codeop import Compile
|
|
4
|
+
import os
|
|
5
|
+
import sys
|
|
6
|
+
import json
|
|
7
|
+
import traceback
|
|
8
|
+
import platform
|
|
9
|
+
import struct
|
|
10
|
+
import math
|
|
11
|
+
|
|
12
|
+
NODE_CHANNEL_FD = int(os.environ['NODE_CHANNEL_FD'])
|
|
13
|
+
UNICODE_TYPE = unicode if sys.version_info[0] == 2 else str
|
|
14
|
+
|
|
15
|
+
if sys.version_info[0] <= 2:
|
|
16
|
+
# print('PY2')
|
|
17
|
+
def _exec(_code_, _globs_):
|
|
18
|
+
exec('exec _code_ in _globs_')
|
|
19
|
+
else:
|
|
20
|
+
_exec = getattr(__builtins__, 'exec')
|
|
21
|
+
|
|
22
|
+
_locals = {'__name__': '__console__', '__doc__': None}
|
|
23
|
+
_compile = Compile()
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
if platform.system() == 'Windows':
|
|
27
|
+
# hacky reimplementation of https://github.com/nodejs/node/blob/master/deps/uv/src/win/pipe.c
|
|
28
|
+
def read_data(f):
|
|
29
|
+
header = f.read(16)
|
|
30
|
+
if not header:
|
|
31
|
+
return header
|
|
32
|
+
try:
|
|
33
|
+
msg_length, = struct.unpack('<Q', header[8:])
|
|
34
|
+
return f.read(msg_length)
|
|
35
|
+
except:
|
|
36
|
+
raise ValueError('Error parsing msg with header: {}'.format(repr(header)))
|
|
37
|
+
def write_data(f, data):
|
|
38
|
+
header = struct.pack('<Q', 1) + struct.pack('<Q', len(data))
|
|
39
|
+
f.write(header + data)
|
|
40
|
+
f.flush()
|
|
41
|
+
else:
|
|
42
|
+
def read_data(f):
|
|
43
|
+
return reader.readline()
|
|
44
|
+
def write_data(f, data):
|
|
45
|
+
f.write(data)
|
|
46
|
+
f.flush()
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def format_exception(t=None, e=None, tb=None):
|
|
50
|
+
return dict(
|
|
51
|
+
exception=dict(
|
|
52
|
+
type=dict(
|
|
53
|
+
name=t.__name__,
|
|
54
|
+
module=t.__module__
|
|
55
|
+
) if t else None,
|
|
56
|
+
message=str(e),
|
|
57
|
+
args=getattr(e, 'args', None),
|
|
58
|
+
format=traceback.format_exception_only(t, e)
|
|
59
|
+
) if e else None,
|
|
60
|
+
traceback=dict(
|
|
61
|
+
lineno=traceback.tb_lineno(tb) if hasattr(traceback, 'tb_lineno') else tb.tb_lineno,
|
|
62
|
+
strack=traceback.format_stack(tb.tb_frame),
|
|
63
|
+
format=traceback.format_tb(tb)
|
|
64
|
+
) if tb else None,
|
|
65
|
+
format=traceback.format_exception(t, e, tb)
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
class JavaScriptEncoder(json.JSONEncoder):
|
|
70
|
+
def default(self, o):
|
|
71
|
+
if math.isnan(o):
|
|
72
|
+
return 'NaN'
|
|
73
|
+
if math.isinf(o):
|
|
74
|
+
return 'Infinity' if o > 0 else '-Infinity'
|
|
75
|
+
return o.__dict__
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
if __name__ == '__main__':
|
|
79
|
+
writer = os.fdopen(NODE_CHANNEL_FD, 'wb')
|
|
80
|
+
reader = os.fdopen(NODE_CHANNEL_FD, 'rb')
|
|
81
|
+
|
|
82
|
+
while True:
|
|
83
|
+
try:
|
|
84
|
+
# Read new command
|
|
85
|
+
line = read_data(reader)
|
|
86
|
+
if not line:
|
|
87
|
+
break
|
|
88
|
+
try:
|
|
89
|
+
data = json.loads(line.decode('utf-8'))
|
|
90
|
+
except ValueError:
|
|
91
|
+
raise ValueError('Could not decode IPC data:\n{}'.format(repr(line)))
|
|
92
|
+
|
|
93
|
+
# Assert data saneness
|
|
94
|
+
if data['type'] not in ['execute', 'evaluate']:
|
|
95
|
+
raise Exception('Python bridge call `type` must be `execute` or `evaluate`')
|
|
96
|
+
if not isinstance(data['code'], UNICODE_TYPE):
|
|
97
|
+
raise Exception('Python bridge call `code` must be a string.')
|
|
98
|
+
|
|
99
|
+
# Run Python code
|
|
100
|
+
if data['type'] == 'execute':
|
|
101
|
+
_exec(_compile(data['code'], '<input>', 'exec'), _locals)
|
|
102
|
+
response = dict(type='success')
|
|
103
|
+
else:
|
|
104
|
+
value = eval(_compile(data['code'], '<input>', 'eval'), _locals)
|
|
105
|
+
response = dict(type='success', value=json.dumps(value, separators=(',', ':'), cls=JavaScriptEncoder))
|
|
106
|
+
except:
|
|
107
|
+
t, e, tb = sys.exc_info()
|
|
108
|
+
response = dict(type='exception', value=format_exception(t, e, tb))
|
|
109
|
+
|
|
110
|
+
data = json.dumps(response, separators=(',', ':')).encode('utf-8') + b'\n'
|
|
111
|
+
write_data(writer, data)
|
|
112
|
+
|
|
113
|
+
# Closing is messy
|
|
114
|
+
try:
|
|
115
|
+
reader.close()
|
|
116
|
+
except IOError:
|
|
117
|
+
pass
|
|
118
|
+
|
|
119
|
+
try:
|
|
120
|
+
writer.close()
|
|
121
|
+
except IOError:
|
|
122
|
+
pass
|
package/package.json
CHANGED
|
@@ -7,24 +7,24 @@
|
|
|
7
7
|
"scripts": {
|
|
8
8
|
"postinstall": "bun ./postinstall.mjs || node ./postinstall.mjs"
|
|
9
9
|
},
|
|
10
|
-
"version": "0.5.
|
|
10
|
+
"version": "0.5.13",
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@altimateai/altimate-core": "
|
|
13
|
+
"@altimateai/altimate-core": "0.2.5"
|
|
14
14
|
},
|
|
15
15
|
"optionalDependencies": {
|
|
16
|
-
"@altimateai/altimate-code-linux-arm64": "0.5.
|
|
17
|
-
"@altimateai/altimate-code-windows-x64": "0.5.
|
|
18
|
-
"@altimateai/altimate-code-windows-x64-baseline": "0.5.
|
|
19
|
-
"@altimateai/altimate-code-darwin-x64": "0.5.
|
|
20
|
-
"@altimateai/altimate-code-windows-arm64": "0.5.
|
|
21
|
-
"@altimateai/altimate-code-linux-x64-baseline": "0.5.
|
|
22
|
-
"@altimateai/altimate-code-linux-arm64-musl": "0.5.
|
|
23
|
-
"@altimateai/altimate-code-linux-x64-musl": "0.5.
|
|
24
|
-
"@altimateai/altimate-code-linux-x64": "0.5.
|
|
25
|
-
"@altimateai/altimate-code-darwin-x64-baseline": "0.5.
|
|
26
|
-
"@altimateai/altimate-code-linux-x64-baseline-musl": "0.5.
|
|
27
|
-
"@altimateai/altimate-code-darwin-arm64": "0.5.
|
|
16
|
+
"@altimateai/altimate-code-linux-arm64": "0.5.13",
|
|
17
|
+
"@altimateai/altimate-code-windows-x64": "0.5.13",
|
|
18
|
+
"@altimateai/altimate-code-windows-x64-baseline": "0.5.13",
|
|
19
|
+
"@altimateai/altimate-code-darwin-x64": "0.5.13",
|
|
20
|
+
"@altimateai/altimate-code-windows-arm64": "0.5.13",
|
|
21
|
+
"@altimateai/altimate-code-linux-x64-baseline": "0.5.13",
|
|
22
|
+
"@altimateai/altimate-code-linux-arm64-musl": "0.5.13",
|
|
23
|
+
"@altimateai/altimate-code-linux-x64-musl": "0.5.13",
|
|
24
|
+
"@altimateai/altimate-code-linux-x64": "0.5.13",
|
|
25
|
+
"@altimateai/altimate-code-darwin-x64-baseline": "0.5.13",
|
|
26
|
+
"@altimateai/altimate-code-linux-x64-baseline-musl": "0.5.13",
|
|
27
|
+
"@altimateai/altimate-code-darwin-arm64": "0.5.13"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"pg": ">=8",
|