@fluidgrids/cli 2026.1115.5 → 2026.1115.6
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/dist/cli.js +73 -4
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -2055,6 +2055,37 @@ import { existsSync as existsSync3 } from "fs";
|
|
|
2055
2055
|
import { join as join3 } from "path";
|
|
2056
2056
|
import { CliUserError as CliUserError11 } from "@burdenoff/cli-sdk/core";
|
|
2057
2057
|
import { irHash } from "@fluidgrids/workflows/ir";
|
|
2058
|
+
function calverAtLeast(a, b) {
|
|
2059
|
+
const parse = (value) => {
|
|
2060
|
+
const match = /^(\d+)\.(\d+)\.(\d+)$/.exec(value.trim());
|
|
2061
|
+
return match ? [Number(match[1]), Number(match[2]), Number(match[3])] : null;
|
|
2062
|
+
};
|
|
2063
|
+
const left = parse(a);
|
|
2064
|
+
const right = parse(b);
|
|
2065
|
+
if (!left || !right)
|
|
2066
|
+
return false;
|
|
2067
|
+
for (let index = 0;index < 3; index += 1) {
|
|
2068
|
+
const difference = (left[index] ?? 0) - (right[index] ?? 0);
|
|
2069
|
+
if (difference !== 0)
|
|
2070
|
+
return difference > 0;
|
|
2071
|
+
}
|
|
2072
|
+
return true;
|
|
2073
|
+
}
|
|
2074
|
+
async function pythonCutsNodeClients(python, root) {
|
|
2075
|
+
try {
|
|
2076
|
+
const { stdout } = await runPythonCli({
|
|
2077
|
+
python,
|
|
2078
|
+
root,
|
|
2079
|
+
command: "--version",
|
|
2080
|
+
args: ["--version"],
|
|
2081
|
+
stdin: ""
|
|
2082
|
+
});
|
|
2083
|
+
const version = /(\d+\.\d+\.\d+)\s*$/.exec(stdout.trim())?.[1];
|
|
2084
|
+
return version !== undefined && calverAtLeast(version, CUT_NODE_CLIENTS_SDK);
|
|
2085
|
+
} catch {
|
|
2086
|
+
return false;
|
|
2087
|
+
}
|
|
2088
|
+
}
|
|
2058
2089
|
function resolvePythonInterpreter(root, configured, env = process.env) {
|
|
2059
2090
|
const fromEnv = env["FLUIDGRIDS_PYTHON"];
|
|
2060
2091
|
if (fromEnv && fromEnv.trim() !== "")
|
|
@@ -2104,14 +2135,38 @@ function parseLowerResult(stdout) {
|
|
|
2104
2135
|
definition: item["definition"]
|
|
2105
2136
|
};
|
|
2106
2137
|
});
|
|
2138
|
+
const sourceFiles = parseSourceFiles(value["sourceFiles"]);
|
|
2107
2139
|
return {
|
|
2108
2140
|
sdkVersion,
|
|
2109
2141
|
sourceHash: value["sourceHash"],
|
|
2142
|
+
...sourceFiles ? { sourceFiles } : {},
|
|
2110
2143
|
workflows,
|
|
2111
2144
|
warnings,
|
|
2112
2145
|
issues: parseIssues(value["issues"])
|
|
2113
2146
|
};
|
|
2114
2147
|
}
|
|
2148
|
+
function parseSourceFiles(value) {
|
|
2149
|
+
if (value === undefined)
|
|
2150
|
+
return;
|
|
2151
|
+
if (!isRecord7(value)) {
|
|
2152
|
+
throw new CliUserError11(`python -m ${PYTHON_MODULE} lower returned malformed sourceFiles.`, {
|
|
2153
|
+
hint: UPGRADE_HINT
|
|
2154
|
+
});
|
|
2155
|
+
}
|
|
2156
|
+
const files = {};
|
|
2157
|
+
for (const [path, content] of Object.entries(value)) {
|
|
2158
|
+
if (typeof content !== "string" || path === "" || path.startsWith("/") || path.split("/").includes("..")) {
|
|
2159
|
+
throw new CliUserError11(`python -m ${PYTHON_MODULE} lower returned a malformed source file (${JSON.stringify(path)}).`, { hint: UPGRADE_HINT });
|
|
2160
|
+
}
|
|
2161
|
+
Object.defineProperty(files, path, {
|
|
2162
|
+
value: content,
|
|
2163
|
+
enumerable: true,
|
|
2164
|
+
writable: true,
|
|
2165
|
+
configurable: true
|
|
2166
|
+
});
|
|
2167
|
+
}
|
|
2168
|
+
return files;
|
|
2169
|
+
}
|
|
2115
2170
|
function parseIssues(value) {
|
|
2116
2171
|
if (value === undefined)
|
|
2117
2172
|
return [];
|
|
@@ -2228,6 +2283,8 @@ async function lowerPython(options) {
|
|
|
2228
2283
|
const args = ["lower", options.root, "--connections", "-"];
|
|
2229
2284
|
for (const entry of options.entries)
|
|
2230
2285
|
args.push("--entry", entry);
|
|
2286
|
+
if (options.cutNodeClients)
|
|
2287
|
+
args.push("--cut-node-clients");
|
|
2231
2288
|
const { stdout } = await runPythonCli({
|
|
2232
2289
|
python: options.python,
|
|
2233
2290
|
root: options.root,
|
|
@@ -2239,7 +2296,7 @@ async function lowerPython(options) {
|
|
|
2239
2296
|
});
|
|
2240
2297
|
return parseLowerResult(stdout);
|
|
2241
2298
|
}
|
|
2242
|
-
var PYTHON_MODULE = "fluidgrids_workflows", PYTHON_PACKAGE = "fluidgrids-workflows", LOWER_RESULT_FORMAT = "fluidgrids.python-lower-result", MAX_PYTHON_OUTPUT_BYTES, DEFAULT_PYTHON_TIMEOUT_MS = 120000, UNRESOLVED_PREFIX = "Create these connections in the workspace first: ", PythonUnresolvedConnectionsError, UPGRADE_HINT;
|
|
2299
|
+
var PYTHON_MODULE = "fluidgrids_workflows", PYTHON_PACKAGE = "fluidgrids-workflows", LOWER_RESULT_FORMAT = "fluidgrids.python-lower-result", MAX_PYTHON_OUTPUT_BYTES, DEFAULT_PYTHON_TIMEOUT_MS = 120000, UNRESOLVED_PREFIX = "Create these connections in the workspace first: ", PythonUnresolvedConnectionsError, CUT_NODE_CLIENTS_SDK = "2026.1115.6", UPGRADE_HINT;
|
|
2243
2300
|
var init_python = __esm(() => {
|
|
2244
2301
|
MAX_PYTHON_OUTPUT_BYTES = 64 * 1024 * 1024;
|
|
2245
2302
|
PythonUnresolvedConnectionsError = class PythonUnresolvedConnectionsError extends CliUserError11 {
|
|
@@ -3091,6 +3148,8 @@ async function buildPython(options) {
|
|
|
3091
3148
|
const args = ["build", options.root, "--out", out, "--connections", "-"];
|
|
3092
3149
|
for (const entry of options.entries)
|
|
3093
3150
|
args.push("--entry", entry);
|
|
3151
|
+
if (options.cutNodeClients)
|
|
3152
|
+
args.push("--cut-node-clients");
|
|
3094
3153
|
const { stdout } = await runPythonCli({
|
|
3095
3154
|
python: options.python,
|
|
3096
3155
|
root: options.root,
|
|
@@ -3376,7 +3435,14 @@ async function lowerProject(project, options) {
|
|
|
3376
3435
|
try {
|
|
3377
3436
|
const python = resolvePythonInterpreter(project.root, project.config.python);
|
|
3378
3437
|
const connections = connectionMap(options.connectionNames, options.connections);
|
|
3379
|
-
const
|
|
3438
|
+
const cutNodeClients = await pythonCutsNodeClients(python, project.root);
|
|
3439
|
+
const lowered = await lowerPython({
|
|
3440
|
+
python,
|
|
3441
|
+
root: project.root,
|
|
3442
|
+
entries,
|
|
3443
|
+
connections,
|
|
3444
|
+
cutNodeClients
|
|
3445
|
+
});
|
|
3380
3446
|
result.python = python;
|
|
3381
3447
|
result.sourceHash = lowered.sourceHash;
|
|
3382
3448
|
result.warnings.push(...lowered.warnings);
|
|
@@ -3403,8 +3469,11 @@ async function lowerProject(project, options) {
|
|
|
3403
3469
|
const [buildId] = [...buildIds];
|
|
3404
3470
|
if (buildId !== undefined) {
|
|
3405
3471
|
result.buildId = buildId;
|
|
3406
|
-
|
|
3407
|
-
|
|
3472
|
+
if (cutNodeClients && !lowered.sourceFiles) {
|
|
3473
|
+
throw new CliUserError16(`python -m ${PYTHON_MODULE} lower --cut-node-clients listed no sourceFiles.`, { hint: "Reinstall the fluidgrids-workflows package." });
|
|
3474
|
+
}
|
|
3475
|
+
result.sourceFiles = lowered.sourceFiles ?? pythonSourceFiles(project.root);
|
|
3476
|
+
result.buildPython = () => buildPython({ python, root: project.root, entries, connections, cutNodeClients });
|
|
3408
3477
|
}
|
|
3409
3478
|
} catch (error) {
|
|
3410
3479
|
if (error instanceof PythonUnresolvedConnectionsError) {
|
package/package.json
CHANGED