@fluidgrids/cli 2026.1107.1 → 2026.1109.1
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/README.md +98 -6
- package/dist/cli.js +9705 -33
- package/package.json +42 -35
- package/dist/auth/device-login.d.ts +0 -31
- package/dist/auth/device-login.d.ts.map +0 -1
- package/dist/auth/device-login.js +0 -75
- package/dist/auth/device-login.js.map +0 -1
- package/dist/auth/token-auth.d.ts +0 -49
- package/dist/auth/token-auth.d.ts.map +0 -1
- package/dist/auth/token-auth.js +0 -279
- package/dist/auth/token-auth.js.map +0 -1
- package/dist/cli.d.ts +0 -10
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/code-first/api.d.ts +0 -601
- package/dist/code-first/api.d.ts.map +0 -1
- package/dist/code-first/api.js +0 -432
- package/dist/code-first/api.js.map +0 -1
- package/dist/code-first/code-upload.d.ts +0 -53
- package/dist/code-first/code-upload.d.ts.map +0 -1
- package/dist/code-first/code-upload.js +0 -165
- package/dist/code-first/code-upload.js.map +0 -1
- package/dist/code-first/commands/codegen.d.ts +0 -20
- package/dist/code-first/commands/codegen.d.ts.map +0 -1
- package/dist/code-first/commands/codegen.js +0 -50
- package/dist/code-first/commands/codegen.js.map +0 -1
- package/dist/code-first/commands/diff.d.ts +0 -28
- package/dist/code-first/commands/diff.d.ts.map +0 -1
- package/dist/code-first/commands/diff.js +0 -73
- package/dist/code-first/commands/diff.js.map +0 -1
- package/dist/code-first/commands/hotfix.d.ts +0 -54
- package/dist/code-first/commands/hotfix.d.ts.map +0 -1
- package/dist/code-first/commands/hotfix.js +0 -225
- package/dist/code-first/commands/hotfix.js.map +0 -1
- package/dist/code-first/commands/import.d.ts +0 -40
- package/dist/code-first/commands/import.d.ts.map +0 -1
- package/dist/code-first/commands/import.js +0 -235
- package/dist/code-first/commands/import.js.map +0 -1
- package/dist/code-first/commands/init.d.ts +0 -33
- package/dist/code-first/commands/init.d.ts.map +0 -1
- package/dist/code-first/commands/init.js +0 -177
- package/dist/code-first/commands/init.js.map +0 -1
- package/dist/code-first/commands/interface.d.ts +0 -12
- package/dist/code-first/commands/interface.d.ts.map +0 -1
- package/dist/code-first/commands/interface.js +0 -21
- package/dist/code-first/commands/interface.js.map +0 -1
- package/dist/code-first/commands/pull.d.ts +0 -63
- package/dist/code-first/commands/pull.d.ts.map +0 -1
- package/dist/code-first/commands/pull.js +0 -266
- package/dist/code-first/commands/pull.js.map +0 -1
- package/dist/code-first/commands/push.d.ts +0 -97
- package/dist/code-first/commands/push.d.ts.map +0 -1
- package/dist/code-first/commands/push.js +0 -313
- package/dist/code-first/commands/push.js.map +0 -1
- package/dist/code-first/commands/replay.d.ts +0 -44
- package/dist/code-first/commands/replay.d.ts.map +0 -1
- package/dist/code-first/commands/replay.js +0 -238
- package/dist/code-first/commands/replay.js.map +0 -1
- package/dist/code-first/commands/runs.d.ts +0 -160
- package/dist/code-first/commands/runs.d.ts.map +0 -1
- package/dist/code-first/commands/runs.js +0 -565
- package/dist/code-first/commands/runs.js.map +0 -1
- package/dist/code-first/commands/suite.d.ts +0 -57
- package/dist/code-first/commands/suite.d.ts.map +0 -1
- package/dist/code-first/commands/suite.js +0 -197
- package/dist/code-first/commands/suite.js.map +0 -1
- package/dist/code-first/commands/validate.d.ts +0 -38
- package/dist/code-first/commands/validate.d.ts.map +0 -1
- package/dist/code-first/commands/validate.js +0 -140
- package/dist/code-first/commands/validate.js.map +0 -1
- package/dist/code-first/commands/versions.d.ts +0 -63
- package/dist/code-first/commands/versions.d.ts.map +0 -1
- package/dist/code-first/commands/versions.js +0 -204
- package/dist/code-first/commands/versions.js.map +0 -1
- package/dist/code-first/connections.d.ts +0 -55
- package/dist/code-first/connections.d.ts.map +0 -1
- package/dist/code-first/connections.js +0 -180
- package/dist/code-first/connections.js.map +0 -1
- package/dist/code-first/durable-operations.d.ts +0 -41
- package/dist/code-first/durable-operations.d.ts.map +0 -1
- package/dist/code-first/durable-operations.js +0 -135
- package/dist/code-first/durable-operations.js.map +0 -1
- package/dist/code-first/history.d.ts +0 -30
- package/dist/code-first/history.d.ts.map +0 -1
- package/dist/code-first/history.js +0 -139
- package/dist/code-first/history.js.map +0 -1
- package/dist/code-first/imports.d.ts +0 -22
- package/dist/code-first/imports.d.ts.map +0 -1
- package/dist/code-first/imports.js +0 -67
- package/dist/code-first/imports.js.map +0 -1
- package/dist/code-first/index.d.ts +0 -18
- package/dist/code-first/index.d.ts.map +0 -1
- package/dist/code-first/index.js +0 -36
- package/dist/code-first/index.js.map +0 -1
- package/dist/code-first/junit.d.ts +0 -24
- package/dist/code-first/junit.d.ts.map +0 -1
- package/dist/code-first/junit.js +0 -163
- package/dist/code-first/junit.js.map +0 -1
- package/dist/code-first/lowering.d.ts +0 -94
- package/dist/code-first/lowering.d.ts.map +0 -1
- package/dist/code-first/lowering.js +0 -248
- package/dist/code-first/lowering.js.map +0 -1
- package/dist/code-first/operations.d.ts +0 -55
- package/dist/code-first/operations.d.ts.map +0 -1
- package/dist/code-first/operations.js +0 -165
- package/dist/code-first/operations.js.map +0 -1
- package/dist/code-first/parity-operations.d.ts +0 -44
- package/dist/code-first/parity-operations.d.ts.map +0 -1
- package/dist/code-first/parity-operations.js +0 -211
- package/dist/code-first/parity-operations.js.map +0 -1
- package/dist/code-first/parity.d.ts +0 -83
- package/dist/code-first/parity.d.ts.map +0 -1
- package/dist/code-first/parity.js +0 -301
- package/dist/code-first/parity.js.map +0 -1
- package/dist/code-first/presigned.d.ts +0 -21
- package/dist/code-first/presigned.d.ts.map +0 -1
- package/dist/code-first/presigned.js +0 -85
- package/dist/code-first/presigned.js.map +0 -1
- package/dist/code-first/project.d.ts +0 -123
- package/dist/code-first/project.d.ts.map +0 -1
- package/dist/code-first/project.js +0 -301
- package/dist/code-first/project.js.map +0 -1
- package/dist/code-first/python.d.ts +0 -81
- package/dist/code-first/python.d.ts.map +0 -1
- package/dist/code-first/python.js +0 -249
- package/dist/code-first/python.js.map +0 -1
- package/dist/code-first/redact.d.ts +0 -31
- package/dist/code-first/redact.d.ts.map +0 -1
- package/dist/code-first/redact.js +0 -159
- package/dist/code-first/redact.js.map +0 -1
- package/dist/code-first/register.d.ts +0 -35
- package/dist/code-first/register.d.ts.map +0 -1
- package/dist/code-first/register.js +0 -415
- package/dist/code-first/register.js.map +0 -1
- package/dist/code-first/remote.d.ts +0 -58
- package/dist/code-first/remote.d.ts.map +0 -1
- package/dist/code-first/remote.js +0 -126
- package/dist/code-first/remote.js.map +0 -1
- package/dist/code-first/replay.d.ts +0 -36
- package/dist/code-first/replay.d.ts.map +0 -1
- package/dist/code-first/replay.js +0 -52
- package/dist/code-first/replay.js.map +0 -1
- package/dist/code-first/shared.d.ts +0 -53
- package/dist/code-first/shared.d.ts.map +0 -1
- package/dist/code-first/shared.js +0 -94
- package/dist/code-first/shared.js.map +0 -1
- package/dist/code-first/test-suite-operations.d.ts +0 -16
- package/dist/code-first/test-suite-operations.d.ts.map +0 -1
- package/dist/code-first/test-suite-operations.js +0 -44
- package/dist/code-first/test-suite-operations.js.map +0 -1
- package/dist/modules.d.ts +0 -15
- package/dist/modules.d.ts.map +0 -1
- package/dist/modules.js +0 -61
- package/dist/modules.js.map +0 -1
- package/dist/product-defaults.d.ts +0 -11
- package/dist/product-defaults.d.ts.map +0 -1
- package/dist/product-defaults.js +0 -25
- package/dist/product-defaults.js.map +0 -1
- package/dist/program.d.ts +0 -20
- package/dist/program.d.ts.map +0 -1
- package/dist/program.js +0 -44
- package/dist/program.js.map +0 -1
|
@@ -1,301 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The code-first project on disk (spec 06 §7, 07 §7):
|
|
3
|
-
*
|
|
4
|
-
* ```
|
|
5
|
-
* fluidgrids.config.json language, workspace, default task queue, Python interpreter
|
|
6
|
-
* workflows/<key>.ts|.py tier-1 source (with <key>.layout.json / <key>.pinned.json sidecars)
|
|
7
|
-
* workflows/<key>.json canvas-authored workflows kept as the JSON export envelope
|
|
8
|
-
* activities/ code imported by workflows
|
|
9
|
-
* .fluidgrids/nodes.ts|.py generated node clients (`fluidgrids codegen`)
|
|
10
|
-
* lock.json registry snapshot, node versions, SDK version, pulled versions
|
|
11
|
-
* ```
|
|
12
|
-
*
|
|
13
|
-
* The `workflows/` and `.fluidgrids/` names are fixed: the lift and lower in
|
|
14
|
-
* `@fluidgrids/workflows` read and write sidecars at `workflows/<key>.*`.
|
|
15
|
-
*/
|
|
16
|
-
import { existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync } from 'fs';
|
|
17
|
-
import { dirname, isAbsolute, join, posix, resolve, sep } from 'path';
|
|
18
|
-
import { CliUserError } from '@burdenoff/cli-sdk/core';
|
|
19
|
-
import { SDK_VERSION } from '@fluidgrids/workflows';
|
|
20
|
-
import { stableStringify } from '@fluidgrids/workflows/ir';
|
|
21
|
-
export const CONFIG_FILE = 'fluidgrids.config.json';
|
|
22
|
-
export const LOCK_FILE = 'lock.json';
|
|
23
|
-
export const WORKFLOWS_DIR = 'workflows';
|
|
24
|
-
export const ACTIVITIES_DIR = 'activities';
|
|
25
|
-
export const GENERATED_DIR = '.fluidgrids';
|
|
26
|
-
export const CONFIG_FORMAT_VERSION = 1;
|
|
27
|
-
export const LOCK_FORMAT_VERSION = 1;
|
|
28
|
-
export const PROJECT_LANGUAGES = ['ts', 'py'];
|
|
29
|
-
export const WORKFLOW_FORMATS = ['ts', 'py', 'json'];
|
|
30
|
-
function isRecord(value) {
|
|
31
|
-
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
32
|
-
}
|
|
33
|
-
function readJson(path) {
|
|
34
|
-
let text;
|
|
35
|
-
try {
|
|
36
|
-
text = readFileSync(path, 'utf8');
|
|
37
|
-
}
|
|
38
|
-
catch (error) {
|
|
39
|
-
const reason = error instanceof Error ? error.message : String(error);
|
|
40
|
-
throw new CliUserError(`Cannot read ${path}: ${reason}`);
|
|
41
|
-
}
|
|
42
|
-
try {
|
|
43
|
-
return JSON.parse(text);
|
|
44
|
-
}
|
|
45
|
-
catch {
|
|
46
|
-
throw new CliUserError(`${path} is not valid JSON.`);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
function optionalString(record, key, where) {
|
|
50
|
-
const value = record[key];
|
|
51
|
-
if (value === undefined)
|
|
52
|
-
return undefined;
|
|
53
|
-
if (typeof value !== 'string' || value.trim() === '') {
|
|
54
|
-
throw new CliUserError(`${where}: "${key}" must be a non-empty string.`);
|
|
55
|
-
}
|
|
56
|
-
return value;
|
|
57
|
-
}
|
|
58
|
-
export function parseConfig(value, where) {
|
|
59
|
-
if (!isRecord(value))
|
|
60
|
-
throw new CliUserError(`${where} must be a JSON object.`);
|
|
61
|
-
if (value['formatVersion'] !== CONFIG_FORMAT_VERSION) {
|
|
62
|
-
throw new CliUserError(`${where}: "formatVersion" must be ${CONFIG_FORMAT_VERSION}.`);
|
|
63
|
-
}
|
|
64
|
-
const language = value['language'];
|
|
65
|
-
if (language !== 'ts' && language !== 'py') {
|
|
66
|
-
throw new CliUserError(`${where}: "language" must be "ts" or "py".`);
|
|
67
|
-
}
|
|
68
|
-
const config = {
|
|
69
|
-
formatVersion: CONFIG_FORMAT_VERSION,
|
|
70
|
-
language,
|
|
71
|
-
defaultTaskQueue: optionalString(value, 'defaultTaskQueue', where) ?? 'managed',
|
|
72
|
-
};
|
|
73
|
-
const workspaceId = optionalString(value, 'workspaceId', where);
|
|
74
|
-
if (workspaceId)
|
|
75
|
-
config.workspaceId = workspaceId;
|
|
76
|
-
const python = optionalString(value, 'python', where);
|
|
77
|
-
if (python)
|
|
78
|
-
config.python = python;
|
|
79
|
-
return config;
|
|
80
|
-
}
|
|
81
|
-
export function emptyLock() {
|
|
82
|
-
return {
|
|
83
|
-
formatVersion: LOCK_FORMAT_VERSION,
|
|
84
|
-
sdkVersion: SDK_VERSION,
|
|
85
|
-
registrySnapshot: null,
|
|
86
|
-
nodes: [],
|
|
87
|
-
workflows: {},
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
function parseLockedWorkflow(value, key, where) {
|
|
91
|
-
if (!isRecord(value) ||
|
|
92
|
-
typeof value['version'] !== 'string' ||
|
|
93
|
-
typeof value['irHash'] !== 'string' ||
|
|
94
|
-
typeof value['path'] !== 'string' ||
|
|
95
|
-
!WORKFLOW_FORMATS.includes(value['format'])) {
|
|
96
|
-
throw new CliUserError(`${where}: workflows["${key}"] is not a valid entry.`);
|
|
97
|
-
}
|
|
98
|
-
const buildId = value['buildId'];
|
|
99
|
-
if (buildId !== undefined && typeof buildId !== 'string') {
|
|
100
|
-
throw new CliUserError(`${where}: workflows["${key}"].buildId must be a string.`);
|
|
101
|
-
}
|
|
102
|
-
return {
|
|
103
|
-
version: value['version'],
|
|
104
|
-
irHash: value['irHash'],
|
|
105
|
-
format: value['format'],
|
|
106
|
-
path: safeRelativePath(value['path'], where),
|
|
107
|
-
...(buildId !== undefined ? { buildId } : {}),
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
function parseLockedBundle(value, where) {
|
|
111
|
-
if (value === undefined)
|
|
112
|
-
return undefined;
|
|
113
|
-
if (!isRecord(value) ||
|
|
114
|
-
typeof value['buildId'] !== 'string' ||
|
|
115
|
-
typeof value['sourceHash'] !== 'string' ||
|
|
116
|
-
typeof value['sdkVersion'] !== 'string') {
|
|
117
|
-
throw new CliUserError(`${where}: "bundle" must be { buildId, sourceHash, sdkVersion }.`);
|
|
118
|
-
}
|
|
119
|
-
return {
|
|
120
|
-
buildId: value['buildId'],
|
|
121
|
-
sourceHash: value['sourceHash'],
|
|
122
|
-
sdkVersion: value['sdkVersion'],
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
export function parseLock(value, where) {
|
|
126
|
-
if (!isRecord(value) || value['formatVersion'] !== LOCK_FORMAT_VERSION) {
|
|
127
|
-
throw new CliUserError(`${where}: "formatVersion" must be ${LOCK_FORMAT_VERSION}.`);
|
|
128
|
-
}
|
|
129
|
-
const snapshot = value['registrySnapshot'];
|
|
130
|
-
if (snapshot !== null && typeof snapshot !== 'string') {
|
|
131
|
-
throw new CliUserError(`${where}: "registrySnapshot" must be a string or null.`);
|
|
132
|
-
}
|
|
133
|
-
const nodesValue = value['nodes'];
|
|
134
|
-
if (!Array.isArray(nodesValue))
|
|
135
|
-
throw new CliUserError(`${where}: "nodes" must be an array.`);
|
|
136
|
-
const nodes = nodesValue.map((node, index) => {
|
|
137
|
-
if (!isRecord(node) ||
|
|
138
|
-
typeof node['nodeType'] !== 'string' ||
|
|
139
|
-
(node['nodeVersion'] !== null && typeof node['nodeVersion'] !== 'string')) {
|
|
140
|
-
throw new CliUserError(`${where}: nodes[${index}] is not a valid entry.`);
|
|
141
|
-
}
|
|
142
|
-
return { nodeType: node['nodeType'], nodeVersion: node['nodeVersion'] };
|
|
143
|
-
});
|
|
144
|
-
const workflowsValue = value['workflows'];
|
|
145
|
-
if (!isRecord(workflowsValue)) {
|
|
146
|
-
throw new CliUserError(`${where}: "workflows" must be an object.`);
|
|
147
|
-
}
|
|
148
|
-
const workflows = {};
|
|
149
|
-
for (const [key, entry] of Object.entries(workflowsValue)) {
|
|
150
|
-
Object.defineProperty(workflows, key, {
|
|
151
|
-
value: parseLockedWorkflow(entry, key, where),
|
|
152
|
-
enumerable: true,
|
|
153
|
-
writable: true,
|
|
154
|
-
configurable: true,
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
const bundle = parseLockedBundle(value['bundle'], where);
|
|
158
|
-
return {
|
|
159
|
-
formatVersion: LOCK_FORMAT_VERSION,
|
|
160
|
-
sdkVersion: typeof value['sdkVersion'] === 'string' ? value['sdkVersion'] : SDK_VERSION,
|
|
161
|
-
registrySnapshot: snapshot,
|
|
162
|
-
nodes,
|
|
163
|
-
workflows,
|
|
164
|
-
...(bundle ? { bundle } : {}),
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
/** The nearest directory at or above `start` that holds `fluidgrids.config.json`. */
|
|
168
|
-
export function findProjectRoot(start) {
|
|
169
|
-
let dir = resolve(start);
|
|
170
|
-
for (;;) {
|
|
171
|
-
if (existsSync(join(dir, CONFIG_FILE)))
|
|
172
|
-
return dir;
|
|
173
|
-
const parent = dirname(dir);
|
|
174
|
-
if (parent === dir)
|
|
175
|
-
return null;
|
|
176
|
-
dir = parent;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
/** Load the project at `projectDir`, or the nearest one above the working directory. */
|
|
180
|
-
export function loadProject(projectDir, cwd = process.cwd()) {
|
|
181
|
-
const root = projectDir ? resolve(cwd, projectDir) : findProjectRoot(cwd);
|
|
182
|
-
if (!root || !existsSync(join(root, CONFIG_FILE))) {
|
|
183
|
-
throw new CliUserError(`No ${CONFIG_FILE} found.`, {
|
|
184
|
-
hint: 'Run `fluidgrids init` to create a project, or pass --project <dir>.',
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
const config = parseConfig(readJson(join(root, CONFIG_FILE)), CONFIG_FILE);
|
|
188
|
-
const lockPath = join(root, LOCK_FILE);
|
|
189
|
-
const lock = existsSync(lockPath) ? parseLock(readJson(lockPath), LOCK_FILE) : emptyLock();
|
|
190
|
-
return { root, config, lock };
|
|
191
|
-
}
|
|
192
|
-
/** Deterministic JSON text for a file the CLI owns: sorted keys, two spaces, final newline. */
|
|
193
|
-
export function jsonText(value) {
|
|
194
|
-
return stableStringify(value);
|
|
195
|
-
}
|
|
196
|
-
export function writeLock(project) {
|
|
197
|
-
writeProjectFile(project.root, LOCK_FILE, jsonText({ ...project.lock, sdkVersion: SDK_VERSION }));
|
|
198
|
-
}
|
|
199
|
-
/**
|
|
200
|
-
* A project-relative path with `/` separators. Absolute paths, `..` segments,
|
|
201
|
-
* empty segments and backslashes are refused, so a path from a server response
|
|
202
|
-
* or a lock file can never point outside the project.
|
|
203
|
-
*/
|
|
204
|
-
export function safeRelativePath(path, where) {
|
|
205
|
-
const refuse = () => {
|
|
206
|
-
throw new CliUserError(`${where}: refusing the path "${path}".`);
|
|
207
|
-
};
|
|
208
|
-
if (path === '' || path.includes('\\') || path.includes('\0') || isAbsolute(path))
|
|
209
|
-
refuse();
|
|
210
|
-
const segments = path.split('/');
|
|
211
|
-
if (segments.some((segment) => segment === '' || segment === '.' || segment === '..'))
|
|
212
|
-
refuse();
|
|
213
|
-
return posix.normalize(path);
|
|
214
|
-
}
|
|
215
|
-
/** Write a file inside the project, creating its directory. */
|
|
216
|
-
export function writeProjectFile(root, path, content) {
|
|
217
|
-
const relative = safeRelativePath(path, 'write');
|
|
218
|
-
const target = join(root, ...relative.split('/'));
|
|
219
|
-
mkdirSync(dirname(target), { recursive: true });
|
|
220
|
-
writeFileSync(target, content, 'utf8');
|
|
221
|
-
}
|
|
222
|
-
export function readProjectFile(root, path) {
|
|
223
|
-
const target = join(root, ...safeRelativePath(path, 'read').split('/'));
|
|
224
|
-
return existsSync(target) ? readFileSync(target, 'utf8') : null;
|
|
225
|
-
}
|
|
226
|
-
const SKIPPED_DIRS = new Set(['node_modules', '__pycache__', '.venv', 'venv', '.git']);
|
|
227
|
-
function walk(root, dir, out) {
|
|
228
|
-
const absolute = join(root, ...dir.split('/'));
|
|
229
|
-
if (!existsSync(absolute) || !statSync(absolute).isDirectory())
|
|
230
|
-
return;
|
|
231
|
-
for (const entry of readdirSync(absolute, { withFileTypes: true })) {
|
|
232
|
-
const relative = `${dir}/${entry.name}`;
|
|
233
|
-
if (entry.isDirectory()) {
|
|
234
|
-
if (!SKIPPED_DIRS.has(entry.name))
|
|
235
|
-
walk(root, relative, out);
|
|
236
|
-
}
|
|
237
|
-
else if (entry.isFile()) {
|
|
238
|
-
out.push(relative);
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
/** Every file under the project's source directories, sorted. */
|
|
243
|
-
export function listSourcePaths(root) {
|
|
244
|
-
const out = [];
|
|
245
|
-
for (const dir of [WORKFLOWS_DIR, ACTIVITIES_DIR, GENERATED_DIR])
|
|
246
|
-
walk(root, dir, out);
|
|
247
|
-
return out.sort();
|
|
248
|
-
}
|
|
249
|
-
export function isSidecar(path) {
|
|
250
|
-
return path.endsWith('.layout.json') || path.endsWith('.pinned.json');
|
|
251
|
-
}
|
|
252
|
-
/** A canvas workflow kept as JSON: `workflows/**.json` that is not a sidecar. */
|
|
253
|
-
export function isJsonWorkflow(path) {
|
|
254
|
-
return path.startsWith(`${WORKFLOWS_DIR}/`) && path.endsWith('.json') && !isSidecar(path);
|
|
255
|
-
}
|
|
256
|
-
/** Source modules of the given language that may define workflows (tests and declarations excluded). */
|
|
257
|
-
export function isWorkflowModule(path, language) {
|
|
258
|
-
if (!path.startsWith(`${WORKFLOWS_DIR}/`))
|
|
259
|
-
return false;
|
|
260
|
-
if (language === 'ts') {
|
|
261
|
-
return path.endsWith('.ts') && !path.endsWith('.d.ts') && !/\.(test|spec)\.ts$/.test(path);
|
|
262
|
-
}
|
|
263
|
-
const name = posix.basename(path);
|
|
264
|
-
return path.endsWith('.py') && !name.startsWith('test_') && !name.endsWith('_test.py');
|
|
265
|
-
}
|
|
266
|
-
/** Files of the given language that lowering reads: modules plus sidecars. */
|
|
267
|
-
export function isLoweringInput(path, language) {
|
|
268
|
-
if (isSidecar(path))
|
|
269
|
-
return path.startsWith(`${WORKFLOWS_DIR}/`);
|
|
270
|
-
return language === 'ts' ? path.endsWith('.ts') : path.endsWith('.py');
|
|
271
|
-
}
|
|
272
|
-
export function readProjectFiles(root, paths) {
|
|
273
|
-
return paths.map((path) => ({
|
|
274
|
-
path,
|
|
275
|
-
content: readFileSync(join(root, ...path.split('/')), 'utf8'),
|
|
276
|
-
}));
|
|
277
|
-
}
|
|
278
|
-
/** The OS-specific form of a project-relative path, for messages. */
|
|
279
|
-
export function displayPath(path) {
|
|
280
|
-
return path.split('/').join(sep);
|
|
281
|
-
}
|
|
282
|
-
/**
|
|
283
|
-
* Refuse to work against a workspace other than the one the project records in
|
|
284
|
-
* `fluidgrids.config.json` (`workspaceId`), so a `push` or `pull` never lands in
|
|
285
|
-
* the wrong workspace after `fluidgrids workspace set` switched the CLI. A
|
|
286
|
-
* project without `workspaceId` works against any workspace, and so does a
|
|
287
|
-
* session whose workspace is not known (token mode with only
|
|
288
|
-
* `FLUIDGRIDS_WORKSPACE_TOKEN`).
|
|
289
|
-
*/
|
|
290
|
-
export function assertProjectWorkspace(env, project) {
|
|
291
|
-
const expected = project.config.workspaceId;
|
|
292
|
-
if (!expected || !env.ctx.auth.isAuthenticated())
|
|
293
|
-
return;
|
|
294
|
-
const current = env.ctx.auth.read()?.workspaceId;
|
|
295
|
-
if (!current || current === expected)
|
|
296
|
-
return;
|
|
297
|
-
throw new CliUserError(`This project targets workspace ${expected}, but the CLI is using workspace ${current}.`, {
|
|
298
|
-
hint: `Run \`${env.ctx.productName} workspace set ${expected}\` (or set FLUIDGRIDS_WORKSPACE_ID=${expected}), or remove "workspaceId" from ${CONFIG_FILE} to use the project with any workspace.`,
|
|
299
|
-
});
|
|
300
|
-
}
|
|
301
|
-
//# sourceMappingURL=project.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"project.js","sourceRoot":"","sources":["../../src/code-first/project.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AAC/F,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAEtE,OAAO,EAAE,YAAY,EAAmB,MAAM,yBAAyB,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE3D,MAAM,CAAC,MAAM,WAAW,GAAG,wBAAwB,CAAC;AACpD,MAAM,CAAC,MAAM,SAAS,GAAG,WAAW,CAAC;AACrC,MAAM,CAAC,MAAM,aAAa,G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G,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,WAAW,CAAC;IACjD,IAAI,CAAC,OAAO,IAAI,OAAO,KAAK,QAAQ;QAAE,OAAO;IAC7C,MAAM,IAAI,YAAY,CACpB,kCAAkC,QAAQ,oCAAoC,OAAO,GAAG,EACxF;QACE,IAAI,EAAE,SAAS,GAAG,CAAC,GAAG,CAAC,WAAW,kBAAkB,QAAQ,sCAAsC,QAAQ,mCAAmC,WAAW,yCAAyC;KAClM,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Lowering a Python project. The Python tier-1 builder lives in the
|
|
3
|
-
* `fluidgrids-workflows` package (module `fluidgrids_workflows`), so the CLI runs
|
|
4
|
-
* that package's command line in the project directory:
|
|
5
|
-
*
|
|
6
|
-
* <python> -m fluidgrids_workflows lower <project> --connections - --entry workflows/a.py …
|
|
7
|
-
*
|
|
8
|
-
* - stdin: a JSON object of connection name to `{ "connectionId", "adapter" }`;
|
|
9
|
-
* - stdout (exit status 0):
|
|
10
|
-
* `{ "format": "fluidgrids.python-lower-result", "sdkVersion", "sourceHash",
|
|
11
|
-
* "workflows": [{ "key", "module", "exportName", "irHash", "definition" }] }`;
|
|
12
|
-
* - stderr (exit status 1): `fluidgrids-workflows: <message>[ (<reason>)]` when the
|
|
13
|
-
* project cannot be lowered; exit status 2 for a usage problem.
|
|
14
|
-
*
|
|
15
|
-
* The Python package reads the project files itself, so the `sourceHash` it
|
|
16
|
-
* reports covers what it lowered. Its definitions must be byte-identical to
|
|
17
|
-
* what the TypeScript builder produces for the same graph (spec 03 §2), so the
|
|
18
|
-
* CLI recomputes each `irHash` with `@fluidgrids/workflows` and warns when the
|
|
19
|
-
* two SDKs disagree.
|
|
20
|
-
*/
|
|
21
|
-
import { CliUserError } from '@burdenoff/cli-sdk/core';
|
|
22
|
-
import { type ConnectionRef } from '@fluidgrids/workflows/ir';
|
|
23
|
-
export declare const PYTHON_MODULE = "fluidgrids_workflows";
|
|
24
|
-
export declare const PYTHON_PACKAGE = "fluidgrids-workflows";
|
|
25
|
-
export declare const LOWER_RESULT_FORMAT = "fluidgrids.python-lower-result";
|
|
26
|
-
/** Largest stdout plus stderr the CLI reads from the lowering process. */
|
|
27
|
-
export declare const MAX_PYTHON_OUTPUT_BYTES: number;
|
|
28
|
-
export declare const DEFAULT_PYTHON_TIMEOUT_MS = 120000;
|
|
29
|
-
export interface PythonLoweredWorkflow {
|
|
30
|
-
key: string;
|
|
31
|
-
module: string;
|
|
32
|
-
exportName: string;
|
|
33
|
-
definition: Record<string, unknown>;
|
|
34
|
-
}
|
|
35
|
-
export interface PythonLowerResult {
|
|
36
|
-
sdkVersion: string;
|
|
37
|
-
sourceHash: string;
|
|
38
|
-
workflows: PythonLoweredWorkflow[];
|
|
39
|
-
/** Disagreements between the Python and TypeScript SDKs, one line each. */
|
|
40
|
-
warnings: string[];
|
|
41
|
-
/** Durable-function findings (`durable.phaseC`) that `push` refuses. */
|
|
42
|
-
issues: PythonLowerIssue[];
|
|
43
|
-
}
|
|
44
|
-
/** A finding the Python lowering reports (`LowerResult.issues` of `fluidgrids_workflows`). */
|
|
45
|
-
export interface PythonLowerIssue {
|
|
46
|
-
code: string;
|
|
47
|
-
message: string;
|
|
48
|
-
module: string;
|
|
49
|
-
key?: string;
|
|
50
|
-
}
|
|
51
|
-
/** Raised when the Python side reports connection names it could not resolve. */
|
|
52
|
-
export declare class PythonUnresolvedConnectionsError extends CliUserError {
|
|
53
|
-
readonly names: string[];
|
|
54
|
-
constructor(message: string, names: string[]);
|
|
55
|
-
}
|
|
56
|
-
export interface PythonLowerOptions {
|
|
57
|
-
/** Interpreter to run; see {@link resolvePythonInterpreter}. */
|
|
58
|
-
python: string;
|
|
59
|
-
/** The project root; also the working directory. */
|
|
60
|
-
root: string;
|
|
61
|
-
/** `workflows/*.py` modules to lower. */
|
|
62
|
-
entries: readonly string[];
|
|
63
|
-
connections: Readonly<Record<string, ConnectionRef>>;
|
|
64
|
-
timeoutMs?: number;
|
|
65
|
-
/** Largest stdout plus stderr to read; default {@link MAX_PYTHON_OUTPUT_BYTES}. */
|
|
66
|
-
maxOutputBytes?: number;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* The interpreter for a Python project: `FLUIDGRIDS_PYTHON`, then the config's
|
|
70
|
-
* `python`, then the project's `.venv`, then `python3` (`python` on Windows).
|
|
71
|
-
*/
|
|
72
|
-
export declare function resolvePythonInterpreter(root: string, configured: string | undefined, env?: Readonly<Record<string, string | undefined>>): string;
|
|
73
|
-
/** Parse the lowering result; `irHash` values are checked against this CLI's SDK. */
|
|
74
|
-
export declare function parseLowerResult(stdout: string): PythonLowerResult;
|
|
75
|
-
/** The optional `issues` of a lowering result (present only when there are some). */
|
|
76
|
-
export declare function parseIssues(value: unknown): PythonLowerIssue[];
|
|
77
|
-
/** The connection names in an "unresolved connections" message, or null. */
|
|
78
|
-
export declare function unresolvedNames(message: string): string[] | null;
|
|
79
|
-
/** Run the Python lowering and return its workflows. */
|
|
80
|
-
export declare function lowerPython(options: PythonLowerOptions): Promise<PythonLowerResult>;
|
|
81
|
-
//# sourceMappingURL=python.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"python.d.ts","sourceRoot":"","sources":["../../src/code-first/python.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAMH,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAU,KAAK,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEtE,eAAO,MAAM,aAAa,yBAAyB,CAAC;AACpD,eAAO,MAAM,cAAc,yBAAyB,CAAC;AACrD,eAAO,MAAM,mBAAmB,mCAAmC,CAAC;AAEpE,0EAA0E;AAC1E,eAAO,MAAM,uBAAuB,QAAmB,CAAC;AACxD,eAAO,MAAM,yBAAyB,SAAU,CAAC;AAKjD,MAAM,WAAW,qBAAqB;IACpC,G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,GAC9D,MAAM,CAUR;AAqBD,qFAAqF;AACrF,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,iBAAiB,CAiDlE;AAED,qFAAqF;AACrF,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,gBAAgB,EAAE,CA0B9D;AAED,4EAA4E;AAC5E,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,CAUhE;AA4CD,wDAAwD;AACxD,wBAAgB,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAgFnF"}
|
|
@@ -1,249 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Lowering a Python project. The Python tier-1 builder lives in the
|
|
3
|
-
* `fluidgrids-workflows` package (module `fluidgrids_workflows`), so the CLI runs
|
|
4
|
-
* that package's command line in the project directory:
|
|
5
|
-
*
|
|
6
|
-
* <python> -m fluidgrids_workflows lower <project> --connections - --entry workflows/a.py …
|
|
7
|
-
*
|
|
8
|
-
* - stdin: a JSON object of connection name to `{ "connectionId", "adapter" }`;
|
|
9
|
-
* - stdout (exit status 0):
|
|
10
|
-
* `{ "format": "fluidgrids.python-lower-result", "sdkVersion", "sourceHash",
|
|
11
|
-
* "workflows": [{ "key", "module", "exportName", "irHash", "definition" }] }`;
|
|
12
|
-
* - stderr (exit status 1): `fluidgrids-workflows: <message>[ (<reason>)]` when the
|
|
13
|
-
* project cannot be lowered; exit status 2 for a usage problem.
|
|
14
|
-
*
|
|
15
|
-
* The Python package reads the project files itself, so the `sourceHash` it
|
|
16
|
-
* reports covers what it lowered. Its definitions must be byte-identical to
|
|
17
|
-
* what the TypeScript builder produces for the same graph (spec 03 §2), so the
|
|
18
|
-
* CLI recomputes each `irHash` with `@fluidgrids/workflows` and warns when the
|
|
19
|
-
* two SDKs disagree.
|
|
20
|
-
*/
|
|
21
|
-
import { spawn } from 'child_process';
|
|
22
|
-
import { existsSync } from 'fs';
|
|
23
|
-
import { join } from 'path';
|
|
24
|
-
import { CliUserError } from '@burdenoff/cli-sdk/core';
|
|
25
|
-
import { irHash } from '@fluidgrids/workflows/ir';
|
|
26
|
-
export const PYTHON_MODULE = 'fluidgrids_workflows';
|
|
27
|
-
export const PYTHON_PACKAGE = 'fluidgrids-workflows';
|
|
28
|
-
export const LOWER_RESULT_FORMAT = 'fluidgrids.python-lower-result';
|
|
29
|
-
/** Largest stdout plus stderr the CLI reads from the lowering process. */
|
|
30
|
-
export const MAX_PYTHON_OUTPUT_BYTES = 64 * 1024 * 1024;
|
|
31
|
-
export const DEFAULT_PYTHON_TIMEOUT_MS = 120_000;
|
|
32
|
-
/** The message prefix `fluidgrids_workflows` uses for connection names it cannot resolve. */
|
|
33
|
-
const UNRESOLVED_PREFIX = 'Create these connections in the workspace first: ';
|
|
34
|
-
/** Raised when the Python side reports connection names it could not resolve. */
|
|
35
|
-
export class PythonUnresolvedConnectionsError extends CliUserError {
|
|
36
|
-
names;
|
|
37
|
-
constructor(message, names) {
|
|
38
|
-
super(message);
|
|
39
|
-
this.names = names;
|
|
40
|
-
this.name = 'PythonUnresolvedConnectionsError';
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* The interpreter for a Python project: `FLUIDGRIDS_PYTHON`, then the config's
|
|
45
|
-
* `python`, then the project's `.venv`, then `python3` (`python` on Windows).
|
|
46
|
-
*/
|
|
47
|
-
export function resolvePythonInterpreter(root, configured, env = process.env) {
|
|
48
|
-
const fromEnv = env['FLUIDGRIDS_PYTHON'];
|
|
49
|
-
if (fromEnv && fromEnv.trim() !== '')
|
|
50
|
-
return fromEnv.trim();
|
|
51
|
-
if (configured)
|
|
52
|
-
return configured;
|
|
53
|
-
const venv = process.platform === 'win32'
|
|
54
|
-
? join(root, '.venv', 'Scripts', 'python.exe')
|
|
55
|
-
: join(root, '.venv', 'bin', 'python');
|
|
56
|
-
if (existsSync(venv))
|
|
57
|
-
return venv;
|
|
58
|
-
return process.platform === 'win32' ? 'python' : 'python3';
|
|
59
|
-
}
|
|
60
|
-
function isRecord(value) {
|
|
61
|
-
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
62
|
-
}
|
|
63
|
-
function parseJsonObject(text) {
|
|
64
|
-
try {
|
|
65
|
-
const value = JSON.parse(text);
|
|
66
|
-
return isRecord(value) ? value : null;
|
|
67
|
-
}
|
|
68
|
-
catch {
|
|
69
|
-
return null;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
function lastLines(text, count) {
|
|
73
|
-
return text.trim().split(/\r?\n/).slice(-count).join('\n');
|
|
74
|
-
}
|
|
75
|
-
const UPGRADE_HINT = `Upgrade the ${PYTHON_PACKAGE} package to a version that matches this CLI.`;
|
|
76
|
-
/** Parse the lowering result; `irHash` values are checked against this CLI's SDK. */
|
|
77
|
-
export function parseLowerResult(stdout) {
|
|
78
|
-
const value = parseJsonObject(stdout);
|
|
79
|
-
if (!value ||
|
|
80
|
-
value['format'] !== LOWER_RESULT_FORMAT ||
|
|
81
|
-
typeof value['sourceHash'] !== 'string' ||
|
|
82
|
-
!Array.isArray(value['workflows'])) {
|
|
83
|
-
throw new CliUserError(`python -m ${PYTHON_MODULE} lower returned an unexpected result (expected ${LOWER_RESULT_FORMAT}).`, { hint: UPGRADE_HINT });
|
|
84
|
-
}
|
|
85
|
-
const sdkVersion = typeof value['sdkVersion'] === 'string' ? value['sdkVersion'] : 'unknown';
|
|
86
|
-
const warnings = [];
|
|
87
|
-
const workflows = value['workflows'].map((item, index) => {
|
|
88
|
-
if (!isRecord(item) ||
|
|
89
|
-
typeof item['key'] !== 'string' ||
|
|
90
|
-
typeof item['module'] !== 'string' ||
|
|
91
|
-
typeof item['exportName'] !== 'string' ||
|
|
92
|
-
!isRecord(item['definition'])) {
|
|
93
|
-
throw new CliUserError(`python -m ${PYTHON_MODULE} lower returned a malformed workflow at index ${index}.`, { hint: UPGRADE_HINT });
|
|
94
|
-
}
|
|
95
|
-
const reported = item['irHash'];
|
|
96
|
-
const computed = irHash(item['definition']);
|
|
97
|
-
if (typeof reported === 'string' && reported !== computed) {
|
|
98
|
-
warnings.push(`${item['key']}: ${PYTHON_PACKAGE} ${sdkVersion} reports irHash ${reported}, this CLI computes ${computed}; align the two SDK versions`);
|
|
99
|
-
}
|
|
100
|
-
return {
|
|
101
|
-
key: item['key'],
|
|
102
|
-
module: item['module'],
|
|
103
|
-
exportName: item['exportName'],
|
|
104
|
-
definition: item['definition'],
|
|
105
|
-
};
|
|
106
|
-
});
|
|
107
|
-
return {
|
|
108
|
-
sdkVersion,
|
|
109
|
-
sourceHash: value['sourceHash'],
|
|
110
|
-
workflows,
|
|
111
|
-
warnings,
|
|
112
|
-
issues: parseIssues(value['issues']),
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
/** The optional `issues` of a lowering result (present only when there are some). */
|
|
116
|
-
export function parseIssues(value) {
|
|
117
|
-
if (value === undefined)
|
|
118
|
-
return [];
|
|
119
|
-
if (!Array.isArray(value)) {
|
|
120
|
-
throw new CliUserError(`python -m ${PYTHON_MODULE} lower returned malformed issues.`, {
|
|
121
|
-
hint: UPGRADE_HINT,
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
return value.map((item, index) => {
|
|
125
|
-
if (!isRecord(item) ||
|
|
126
|
-
typeof item['code'] !== 'string' ||
|
|
127
|
-
typeof item['message'] !== 'string' ||
|
|
128
|
-
typeof item['module'] !== 'string') {
|
|
129
|
-
throw new CliUserError(`python -m ${PYTHON_MODULE} lower returned a malformed issue at index ${index}.`, { hint: UPGRADE_HINT });
|
|
130
|
-
}
|
|
131
|
-
return {
|
|
132
|
-
code: item['code'],
|
|
133
|
-
message: item['message'],
|
|
134
|
-
module: item['module'],
|
|
135
|
-
...(typeof item['key'] === 'string' ? { key: item['key'] } : {}),
|
|
136
|
-
};
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
/** The connection names in an "unresolved connections" message, or null. */
|
|
140
|
-
export function unresolvedNames(message) {
|
|
141
|
-
const at = message.indexOf(UNRESOLVED_PREFIX);
|
|
142
|
-
if (at < 0)
|
|
143
|
-
return null;
|
|
144
|
-
const names = message
|
|
145
|
-
.slice(at + UNRESOLVED_PREFIX.length)
|
|
146
|
-
.split(/\r?\n/)[0]
|
|
147
|
-
?.split(',')
|
|
148
|
-
.map((name) => name.trim())
|
|
149
|
-
.filter((name) => name !== '');
|
|
150
|
-
return names && names.length > 0 ? names : null;
|
|
151
|
-
}
|
|
152
|
-
/** The message the package wrote, without its program-name prefix. */
|
|
153
|
-
function reportedMessage(stderr) {
|
|
154
|
-
const lines = stderr
|
|
155
|
-
.split(/\r?\n/)
|
|
156
|
-
.filter((line) => line.startsWith('fluidgrids-workflows: '))
|
|
157
|
-
.map((line) => line.slice('fluidgrids-workflows: '.length).trim());
|
|
158
|
-
return lines.length > 0 ? lines.join('\n') : null;
|
|
159
|
-
}
|
|
160
|
-
function failure(code, signal, stderr, python) {
|
|
161
|
-
if (/No module named '?fluidgrids_workflows'?/.test(stderr)) {
|
|
162
|
-
return new CliUserError(`The ${PYTHON_PACKAGE} Python package is not installed for ${python}.`, {
|
|
163
|
-
hint: `Install it with \`${python} -m pip install ${PYTHON_PACKAGE}\`, or point FLUIDGRIDS_PYTHON (or "python" in fluidgrids.config.json) at an interpreter that has it.`,
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
if (code === 2 && /invalid choice: 'lower'|unrecognized arguments/.test(stderr)) {
|
|
167
|
-
return new CliUserError(`The installed ${PYTHON_PACKAGE} package cannot lower projects.`, {
|
|
168
|
-
hint: UPGRADE_HINT,
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
const message = reportedMessage(stderr);
|
|
172
|
-
if (message) {
|
|
173
|
-
const names = unresolvedNames(message);
|
|
174
|
-
if (names)
|
|
175
|
-
return new PythonUnresolvedConnectionsError(message, names);
|
|
176
|
-
return new CliUserError(`Lowering the Python workflows failed: ${message}`);
|
|
177
|
-
}
|
|
178
|
-
const how = signal ? `was stopped by ${signal}` : `exited with status ${String(code)}`;
|
|
179
|
-
const detail = lastLines(stderr, 20);
|
|
180
|
-
return new CliUserError(`${python} -m ${PYTHON_MODULE} lower ${how}.`, detail ? { hint: detail } : undefined);
|
|
181
|
-
}
|
|
182
|
-
/** Run the Python lowering and return its workflows. */
|
|
183
|
-
export function lowerPython(options) {
|
|
184
|
-
const args = ['-m', PYTHON_MODULE, 'lower', options.root, '--connections', '-'];
|
|
185
|
-
for (const entry of options.entries)
|
|
186
|
-
args.push('--entry', entry);
|
|
187
|
-
return new Promise((resolve, reject) => {
|
|
188
|
-
const child = spawn(options.python, args, {
|
|
189
|
-
cwd: options.root,
|
|
190
|
-
stdio: ['pipe', 'pipe', 'pipe'],
|
|
191
|
-
env: { ...process.env, PYTHONDONTWRITEBYTECODE: '1', PYTHONIOENCODING: 'utf-8' },
|
|
192
|
-
});
|
|
193
|
-
const stdout = [];
|
|
194
|
-
const stderr = [];
|
|
195
|
-
let bytes = 0;
|
|
196
|
-
const maxOutputBytes = options.maxOutputBytes ?? MAX_PYTHON_OUTPUT_BYTES;
|
|
197
|
-
const timeoutMs = options.timeoutMs ?? DEFAULT_PYTHON_TIMEOUT_MS;
|
|
198
|
-
let settled = false;
|
|
199
|
-
const settle = (fn) => {
|
|
200
|
-
if (settled)
|
|
201
|
-
return;
|
|
202
|
-
settled = true;
|
|
203
|
-
clearTimeout(timer);
|
|
204
|
-
fn();
|
|
205
|
-
};
|
|
206
|
-
const timer = setTimeout(() => {
|
|
207
|
-
child.kill('SIGKILL');
|
|
208
|
-
settle(() => reject(new CliUserError(`python -m ${PYTHON_MODULE} lower did not finish within ${timeoutMs} ms.`)));
|
|
209
|
-
}, timeoutMs);
|
|
210
|
-
const collect = (into) => (chunk) => {
|
|
211
|
-
bytes += chunk.length;
|
|
212
|
-
if (bytes > maxOutputBytes) {
|
|
213
|
-
child.kill('SIGKILL');
|
|
214
|
-
settle(() => reject(new CliUserError(`python -m ${PYTHON_MODULE} lower wrote more than ${maxOutputBytes} bytes; stopped it.`)));
|
|
215
|
-
return;
|
|
216
|
-
}
|
|
217
|
-
into.push(chunk);
|
|
218
|
-
};
|
|
219
|
-
child.stdout.on('data', collect(stdout));
|
|
220
|
-
child.stderr.on('data', collect(stderr));
|
|
221
|
-
child.on('error', (error) => {
|
|
222
|
-
settle(() => reject(error.code === 'ENOENT'
|
|
223
|
-
? new CliUserError(`Python interpreter "${options.python}" was not found.`, {
|
|
224
|
-
hint: `Install Python 3.11 or later with the ${PYTHON_PACKAGE} package, or set FLUIDGRIDS_PYTHON.`,
|
|
225
|
-
})
|
|
226
|
-
: new CliUserError(`Could not start ${options.python}: ${error.message}`)));
|
|
227
|
-
});
|
|
228
|
-
child.on('close', (code, signal) => {
|
|
229
|
-
const out = Buffer.concat(stdout).toString('utf8');
|
|
230
|
-
const err = Buffer.concat(stderr).toString('utf8');
|
|
231
|
-
settle(() => {
|
|
232
|
-
if (code !== 0) {
|
|
233
|
-
reject(failure(code, signal, err, options.python));
|
|
234
|
-
return;
|
|
235
|
-
}
|
|
236
|
-
try {
|
|
237
|
-
resolve(parseLowerResult(out));
|
|
238
|
-
}
|
|
239
|
-
catch (error) {
|
|
240
|
-
reject(error);
|
|
241
|
-
}
|
|
242
|
-
});
|
|
243
|
-
});
|
|
244
|
-
// A child that exits before reading stdin raises EPIPE here; the close handler reports it.
|
|
245
|
-
child.stdin.on('error', () => undefined);
|
|
246
|
-
child.stdin.end(JSON.stringify(options.connections), 'utf8');
|
|
247
|
-
});
|
|
248
|
-
}
|
|
249
|
-
//# sourceMappingURL=python.js.map
|