@cs-object/cli 0.1.0 → 0.1.2
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 +33 -1
- package/dist/{chunk-7XCJ6AF3.js → chunk-74QLD4IY.js} +6 -21
- package/dist/{chunk-MOM6Q2VG.js → chunk-DIYNSURK.js} +23 -1
- package/dist/{chunk-KYWIVB2V.js → chunk-O4PZOHKA.js} +10 -21
- package/dist/{chunk-OYQDZWT7.js → chunk-PC7UAF4D.js} +1 -1
- package/dist/{chunk-UCPKZ67Z.js → chunk-PXJXS4ZR.js} +2 -2
- package/dist/cli.js +15 -19
- package/dist/{dev-server-BVY4Q6R6.js → dev-server-IP2WWWK2.js} +15 -30
- package/dist/development.js +13 -25
- package/dist/html-H5XKL7IB.js +9 -0
- package/dist/pdf-6NJX7NN3.js +9 -0
- package/package.json +2 -2
- package/dist/html-AAIMIB2S.js +0 -9
- package/dist/pdf-WXWGZ6NC.js +0 -9
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ retain the unverified development paths.
|
|
|
9
9
|
|
|
10
10
|
Follow [setup](../../docs/development.md#setup). In the workspace use
|
|
11
11
|
`node packages/cso-cli/dist/cli.js`; an installed consumer uses `cso`.
|
|
12
|
-
`PYTHON` selects the interpreter with the installed `
|
|
12
|
+
`PYTHON` selects the interpreter with the installed `cs-object` wheel.
|
|
13
13
|
|
|
14
14
|
```sh
|
|
15
15
|
cso bindings examples/two-panel
|
|
@@ -33,6 +33,38 @@ and 2 means invalid usage. Reports retain known source hashes, function, inputs,
|
|
|
33
33
|
versions and diagnostics; successful HTML/PDF reports include output path and hash.
|
|
34
34
|
Unknown provenance is not fabricated. See [report schemas](../../packages/cso-core/src/contracts/reports.ts).
|
|
35
35
|
|
|
36
|
+
### PowerShell 5.1 and 7
|
|
37
|
+
|
|
38
|
+
Complete [repository setup](../../docs/development.md#setup), then run these
|
|
39
|
+
commands from its root. They use the local CLI wrapper and the installed wheel
|
|
40
|
+
in `.venv`. A generated project's corresponding commands are in its `authoring.md`.
|
|
41
|
+
|
|
42
|
+
<!-- docs:canonical-report:start -->
|
|
43
|
+
```powershell
|
|
44
|
+
$env:PYTHON = Join-Path $PWD '.venv\Scripts\python.exe'
|
|
45
|
+
$cso = Join-Path $PWD 'packages\cso-cli\dist\cli.js'
|
|
46
|
+
$source = Join-Path $PWD 'examples\two-panel\estimate.cso.py'
|
|
47
|
+
$reference = Join-Path $PWD 'examples\two-panel\reference.json'
|
|
48
|
+
& node.exe $cso bindings (Join-Path $PWD 'examples\two-panel')
|
|
49
|
+
if ($LASTEXITCODE -ne 0) { throw 'Binding generation failed.' }
|
|
50
|
+
& node.exe $cso verify $source --function estimate --input width=2 --reference $reference --format json
|
|
51
|
+
if ($LASTEXITCODE -ne 0) { throw 'Calculation verification failed.' }
|
|
52
|
+
New-Item -ItemType Directory -Force (Join-Path $PWD 'output') | Out-Null
|
|
53
|
+
& node.exe $cso html $source --function estimate --input width=2 --reference $reference --out (Join-Path $PWD 'output\panels.html') --check-layout --format json
|
|
54
|
+
if ($LASTEXITCODE -ne 0) { throw 'Checked HTML generation failed.' }
|
|
55
|
+
& node.exe $cso pdf $source --function estimate --input width=2 --reference $reference --out (Join-Path $PWD 'output\panels.pdf') --format json
|
|
56
|
+
if ($LASTEXITCODE -ne 0) { throw 'PDF generation failed.' }
|
|
57
|
+
```
|
|
58
|
+
<!-- docs:canonical-report:end -->
|
|
59
|
+
|
|
60
|
+
Keep `PYTHON` as one executable path and invoke path variables with `&`.
|
|
61
|
+
For a standalone install, point it at the environment containing `cs-object`.
|
|
62
|
+
Use `--input name=value` to avoid shell-dependent JSON quoting.
|
|
63
|
+
If you save stdout, select UTF-8 explicitly; the generated project's
|
|
64
|
+
[reference recipe](../create-cs-object/template/references/README.md#bind-an-independent-case)
|
|
65
|
+
shows a PowerShell 5.1/7 capture and BOM-free UTF-8/LF write. Do not use
|
|
66
|
+
PowerShell 5.1 redirection to write source or JSON files.
|
|
67
|
+
|
|
36
68
|
## Numerical checks
|
|
37
69
|
|
|
38
70
|
[verifyExecution](../../packages/cso-core/src/verification/verify.ts) checks inputs,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
parseStrictJson
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-O4PZOHKA.js";
|
|
4
4
|
import {
|
|
5
5
|
stringifyJson
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-DIYNSURK.js";
|
|
7
7
|
|
|
8
8
|
// src/evidence.ts
|
|
9
9
|
import {
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
|
|
26
26
|
// src/assets.ts
|
|
27
27
|
import { readFileSync, realpathSync, statSync } from "fs";
|
|
28
|
-
import { dirname, isAbsolute, relative, resolve } from "path";
|
|
28
|
+
import { dirname, isAbsolute, relative, resolve, sep } from "path";
|
|
29
29
|
import { createHash } from "crypto";
|
|
30
30
|
import {
|
|
31
31
|
ResolvedAssetSchema
|
|
@@ -41,7 +41,7 @@ function captureAssets(sourcePath, execution) {
|
|
|
41
41
|
resolve(root, dirname(asset.moduleId), asset.path)
|
|
42
42
|
);
|
|
43
43
|
const within = relative(root, path);
|
|
44
|
-
if (within === ".." || within.startsWith(
|
|
44
|
+
if (within === ".." || within.startsWith(`..${sep}`) || isAbsolute(within))
|
|
45
45
|
throw new Error("Asset resolves outside the entry source directory");
|
|
46
46
|
if (!statSync(path).isFile())
|
|
47
47
|
throw new Error("Asset is not a regular file");
|
|
@@ -231,7 +231,7 @@ import { createRequire } from "module";
|
|
|
231
231
|
import { createElement } from "react";
|
|
232
232
|
import { renderToStaticMarkup } from "react-dom/server";
|
|
233
233
|
import { PreparedFormulaSheet } from "@cs-object/react";
|
|
234
|
-
function buildPreparedHtml(preparedDocument
|
|
234
|
+
function buildPreparedHtml(preparedDocument) {
|
|
235
235
|
const css = readFileSync3(
|
|
236
236
|
createRequire(import.meta.url).resolve("@cs-object/react/style.css"),
|
|
237
237
|
"utf8"
|
|
@@ -239,27 +239,12 @@ function buildPreparedHtml(preparedDocument, reviewNotice) {
|
|
|
239
239
|
const markup = renderToStaticMarkup(
|
|
240
240
|
createElement(PreparedFormulaSheet, { document: preparedDocument })
|
|
241
241
|
);
|
|
242
|
-
const notice = reviewNotice ? renderToStaticMarkup(
|
|
243
|
-
createElement(
|
|
244
|
-
"p",
|
|
245
|
-
{
|
|
246
|
-
"data-cso-review-notice": true,
|
|
247
|
-
style: {
|
|
248
|
-
fontSize: "10pt",
|
|
249
|
-
margin: "0 0 4mm",
|
|
250
|
-
padding: "2mm",
|
|
251
|
-
border: "1px solid #bbb"
|
|
252
|
-
}
|
|
253
|
-
},
|
|
254
|
-
reviewNotice
|
|
255
|
-
)
|
|
256
|
-
) : "";
|
|
257
242
|
return [
|
|
258
243
|
'<!doctype html><html lang="en"><head><meta charset="utf-8">',
|
|
259
244
|
renderToStaticMarkup(createElement("title", null, preparedDocument.title)),
|
|
260
245
|
`<meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src data:; style-src 'unsafe-inline'; font-src data:">`,
|
|
261
246
|
`<meta name="viewport" content="width=device-width, initial-scale=1"><style>${css}</style></head><body class="formula-sheet-printing cso-standalone-report">`,
|
|
262
|
-
`<div data-formula-sheet-print-root="true">${
|
|
247
|
+
`<div data-formula-sheet-print-root="true">${markup}</div></body></html>`
|
|
263
248
|
].join("");
|
|
264
249
|
}
|
|
265
250
|
|
|
@@ -39,6 +39,28 @@ function stringifyJson(value) {
|
|
|
39
39
|
return encoded;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
// src/python-process.ts
|
|
43
|
+
import { spawnSync } from "child_process";
|
|
44
|
+
function isolatedEnvironment() {
|
|
45
|
+
const environment = { ...process.env };
|
|
46
|
+
for (const key of ["PYTHONPATH", "PYTHONHOME", "NODE_PATH"])
|
|
47
|
+
Reflect.deleteProperty(environment, key);
|
|
48
|
+
return environment;
|
|
49
|
+
}
|
|
50
|
+
function runPythonProcess({
|
|
51
|
+
command,
|
|
52
|
+
args,
|
|
53
|
+
...limits
|
|
54
|
+
}) {
|
|
55
|
+
return spawnSync(
|
|
56
|
+
process.env.PYTHON ?? "python3",
|
|
57
|
+
["-I", "-X", "utf8", "-m", "cso_python", command, ...args],
|
|
58
|
+
{ env: isolatedEnvironment(), ...limits }
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
42
62
|
export {
|
|
43
|
-
stringifyJson
|
|
63
|
+
stringifyJson,
|
|
64
|
+
isolatedEnvironment,
|
|
65
|
+
runPythonProcess
|
|
44
66
|
};
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
|
+
runPythonProcess,
|
|
2
3
|
stringifyJson
|
|
3
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-DIYNSURK.js";
|
|
4
5
|
|
|
5
6
|
// src/reports.ts
|
|
6
7
|
import { CommandReportSchema } from "@cs-object/core";
|
|
7
8
|
|
|
8
9
|
// package.json
|
|
9
|
-
var version = "0.1.
|
|
10
|
+
var version = "0.1.2";
|
|
10
11
|
|
|
11
12
|
// src/reports.ts
|
|
12
13
|
function initialReport(command) {
|
|
@@ -165,37 +166,25 @@ function captureReference(path, execution) {
|
|
|
165
166
|
}
|
|
166
167
|
|
|
167
168
|
// src/execution.ts
|
|
168
|
-
import { spawnSync } from "child_process";
|
|
169
169
|
import {
|
|
170
170
|
ExecutionResponseSchema,
|
|
171
171
|
contractIssuesToDiagnostics as contractIssuesToDiagnostics2
|
|
172
172
|
} from "@cs-object/core";
|
|
173
173
|
var message = (error) => error instanceof Error ? error.message : String(error);
|
|
174
174
|
function runPythonExecution(options, timeoutMs) {
|
|
175
|
-
const
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
}
|
|
179
|
-
const result = spawnSync(
|
|
180
|
-
process.env.PYTHON ?? "python3",
|
|
181
|
-
[
|
|
182
|
-
"-I",
|
|
183
|
-
"-m",
|
|
184
|
-
"cso_python",
|
|
185
|
-
"execute",
|
|
175
|
+
const result = runPythonProcess({
|
|
176
|
+
command: "execute",
|
|
177
|
+
args: [
|
|
186
178
|
options.sourcePath,
|
|
187
179
|
"--function",
|
|
188
180
|
options.functionName,
|
|
189
181
|
"--inputs-json",
|
|
190
182
|
stringifyJson(options.inputs)
|
|
191
183
|
],
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
killSignal: "SIGKILL"
|
|
197
|
-
}
|
|
198
|
-
);
|
|
184
|
+
maxBuffer: 64 * 1024 * 1024,
|
|
185
|
+
timeout: timeoutMs,
|
|
186
|
+
killSignal: "SIGKILL"
|
|
187
|
+
});
|
|
199
188
|
if (result.stderr) {
|
|
200
189
|
process.stderr.write(result.stderr);
|
|
201
190
|
}
|
|
@@ -133,7 +133,7 @@ Options:
|
|
|
133
133
|
--help Show usage without executing Python or launching Chromium.
|
|
134
134
|
|
|
135
135
|
Paths resolve from the caller's directory. Set PYTHON to the interpreter with the
|
|
136
|
-
|
|
136
|
+
cs-object wheel installed. dev-render requires Playwright Chromium.
|
|
137
137
|
Development exit codes: 0 exported/rendered, 1 execution/render/write failed,
|
|
138
138
|
2 invalid usage. verify/html/pdf --format json emit one public CommandReport.
|
|
139
139
|
`;
|
|
@@ -8,10 +8,10 @@ import {
|
|
|
8
8
|
renderPreparedPdf,
|
|
9
9
|
retainSource,
|
|
10
10
|
sha256
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-74QLD4IY.js";
|
|
12
12
|
import {
|
|
13
13
|
executeAndVerify
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-O4PZOHKA.js";
|
|
15
15
|
|
|
16
16
|
// src/document.ts
|
|
17
17
|
import { CommandReportSchema } from "@cs-object/core";
|
package/dist/cli.js
CHANGED
|
@@ -3,15 +3,16 @@ import {
|
|
|
3
3
|
UsageError,
|
|
4
4
|
help,
|
|
5
5
|
parseCliArgs
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-PC7UAF4D.js";
|
|
7
7
|
import {
|
|
8
8
|
initialReport,
|
|
9
9
|
usageReport,
|
|
10
10
|
verifyCommand
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-O4PZOHKA.js";
|
|
12
12
|
import {
|
|
13
|
+
runPythonProcess,
|
|
13
14
|
stringifyJson
|
|
14
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-DIYNSURK.js";
|
|
15
16
|
|
|
16
17
|
// src/cli.ts
|
|
17
18
|
import { CommandReportSchema } from "@cs-object/core";
|
|
@@ -111,7 +112,7 @@ Paths resolve against the caller directory. --help executes neither Python nor C
|
|
|
111
112
|
`;
|
|
112
113
|
return `Usage: cso ${command2} <file.cso.py> --function <name> [--input <name=number>] [--reference <file.json>]${command2 === "pdf" ? " --out <path.pdf>" : ""} [--format json]${command2 === "pdf" ? " [--no-evidence]" : ""}
|
|
113
114
|
|
|
114
|
-
${command2 === "verify" ? "Execute once with installed
|
|
115
|
+
${command2 === "verify" ? "Execute once with installed cs-object and independently evaluate every documented result." : "Verify once, render the captured execution, and atomically replace the PDF. Evidence is retained unless --no-evidence is set."}
|
|
115
116
|
Repeat --input for distinct parameters. Duplicate, unknown and invalid inputs fail.
|
|
116
117
|
--reference captures one explicit versioned reference file. Missing matches are not_applicable.
|
|
117
118
|
--format json emits one public CommandReport, including on errors.
|
|
@@ -124,25 +125,20 @@ ${command2 === "pdf" ? "PDF evidence is retained at <output>.evidence/<manifest-
|
|
|
124
125
|
}
|
|
125
126
|
|
|
126
127
|
// src/bindings.ts
|
|
127
|
-
import { spawnSync } from "child_process";
|
|
128
128
|
var bindingsHelp = `Usage: cso bindings <directory> [--check]
|
|
129
129
|
|
|
130
130
|
Generate importable _cso_bindings modules and typed signatures from .cso.py files.
|
|
131
131
|
--check reports stale or missing files without writing. Calculations are not executed.
|
|
132
132
|
Python-only equivalent: python -m cso_python bindings <directory> [--check]
|
|
133
|
-
Set PYTHON to the interpreter with
|
|
133
|
+
Set PYTHON to the interpreter with cs-object installed.
|
|
134
134
|
Exit codes: 0 current/generated, 1 stale/source/write failure, 2 invalid usage.
|
|
135
135
|
`;
|
|
136
136
|
function bindingsCommand(args2) {
|
|
137
|
-
const
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
process.env.PYTHON ?? "python3",
|
|
143
|
-
["-I", "-m", "cso_python", "bindings", ...args2],
|
|
144
|
-
{ env: environment, maxBuffer: 64 * 1024 * 1024 }
|
|
145
|
-
);
|
|
137
|
+
const result = runPythonProcess({
|
|
138
|
+
command: "bindings",
|
|
139
|
+
args: args2,
|
|
140
|
+
maxBuffer: 64 * 1024 * 1024
|
|
141
|
+
});
|
|
146
142
|
if (result.stderr) process.stderr.write(result.stderr);
|
|
147
143
|
if (result.error || result.signal) {
|
|
148
144
|
process.stdout.write(
|
|
@@ -175,11 +171,11 @@ if (command === "--help" || command === void 0 || [
|
|
|
175
171
|
"dev-render"
|
|
176
172
|
].includes(command) && args.includes("--help")) {
|
|
177
173
|
process.stdout.write(
|
|
178
|
-
command === "verify" || command === "pdf" || command === "html" ? verifiedHelp(command) : command === "dev" ? (await import("./dev-server-
|
|
174
|
+
command === "verify" || command === "pdf" || command === "html" ? verifiedHelp(command) : command === "dev" ? (await import("./dev-server-IP2WWWK2.js")).devHelp : command === "bindings" ? bindingsHelp : help
|
|
179
175
|
);
|
|
180
176
|
} else if (command === "dev") {
|
|
181
177
|
try {
|
|
182
|
-
const { devCommand } = await import("./dev-server-
|
|
178
|
+
const { devCommand } = await import("./dev-server-IP2WWWK2.js");
|
|
183
179
|
await devCommand(args);
|
|
184
180
|
} catch (error) {
|
|
185
181
|
process.stderr.write(
|
|
@@ -195,10 +191,10 @@ if (command === "--help" || command === void 0 || [
|
|
|
195
191
|
try {
|
|
196
192
|
const options = parseVerifiedArgs(command, args);
|
|
197
193
|
if (options.command === "html") {
|
|
198
|
-
const { htmlCommand } = await import("./html-
|
|
194
|
+
const { htmlCommand } = await import("./html-H5XKL7IB.js");
|
|
199
195
|
outcome = await htmlCommand(options);
|
|
200
196
|
} else if (options.command === "pdf") {
|
|
201
|
-
const { pdfCommand } = await import("./pdf-
|
|
197
|
+
const { pdfCommand } = await import("./pdf-6NJX7NN3.js");
|
|
202
198
|
outcome = await pdfCommand(options);
|
|
203
199
|
} else {
|
|
204
200
|
outcome = verifyCommand(options);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
UsageError
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-PC7UAF4D.js";
|
|
4
4
|
import {
|
|
5
5
|
LayoutInspectionError,
|
|
6
6
|
buildPreparedHtml,
|
|
@@ -8,12 +8,14 @@ import {
|
|
|
8
8
|
jsonBytes,
|
|
9
9
|
renderPreparedPdf,
|
|
10
10
|
sha256
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-74QLD4IY.js";
|
|
12
12
|
import {
|
|
13
13
|
executeAndVerify,
|
|
14
14
|
parseStrictJson
|
|
15
|
-
} from "./chunk-
|
|
16
|
-
import
|
|
15
|
+
} from "./chunk-O4PZOHKA.js";
|
|
16
|
+
import {
|
|
17
|
+
runPythonProcess
|
|
18
|
+
} from "./chunk-DIYNSURK.js";
|
|
17
19
|
|
|
18
20
|
// src/dev-server.ts
|
|
19
21
|
import {
|
|
@@ -34,7 +36,6 @@ var HttpError = class extends Error {
|
|
|
34
36
|
};
|
|
35
37
|
|
|
36
38
|
// src/dev-runtime.ts
|
|
37
|
-
import { spawnSync } from "child_process";
|
|
38
39
|
import { randomUUID } from "crypto";
|
|
39
40
|
import {
|
|
40
41
|
CalculationDefinitionResponseSchema
|
|
@@ -49,27 +50,13 @@ var defaults = {
|
|
|
49
50
|
maximumAgeMs: 30 * 6e4
|
|
50
51
|
};
|
|
51
52
|
function describe(options) {
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
"-m",
|
|
60
|
-
"cso_python",
|
|
61
|
-
"describe",
|
|
62
|
-
options.sourcePath,
|
|
63
|
-
"--function",
|
|
64
|
-
options.functionName
|
|
65
|
-
],
|
|
66
|
-
{
|
|
67
|
-
env,
|
|
68
|
-
timeout: 3e4,
|
|
69
|
-
killSignal: "SIGKILL",
|
|
70
|
-
maxBuffer: 4 * 1024 * 1024
|
|
71
|
-
}
|
|
72
|
-
);
|
|
53
|
+
const result = runPythonProcess({
|
|
54
|
+
command: "describe",
|
|
55
|
+
args: [options.sourcePath, "--function", options.functionName],
|
|
56
|
+
timeout: 3e4,
|
|
57
|
+
killSignal: "SIGKILL",
|
|
58
|
+
maxBuffer: 4 * 1024 * 1024
|
|
59
|
+
});
|
|
73
60
|
if (result.error || result.signal)
|
|
74
61
|
throw new HttpError(
|
|
75
62
|
422,
|
|
@@ -219,9 +206,7 @@ function createDevRuntime(options, limits = defaults) {
|
|
|
219
206
|
execution,
|
|
220
207
|
assets: captureAssets(options.sourcePath, execution)
|
|
221
208
|
});
|
|
222
|
-
const
|
|
223
|
-
const notice = `Source-to-document consistency passed. Independent numerical reference: ${independent === "passed" ? "passed" : "pending, no matching reference"}. Human visual inspection is pending. These checks do not establish engineering approval.`;
|
|
224
|
-
const html = Buffer.from(buildPreparedHtml(document, notice));
|
|
209
|
+
const html = Buffer.from(buildPreparedHtml(document));
|
|
225
210
|
const bytes = html.length + jsonBytes(document).length + verified.capture.executionBytes.length + (verified.capture.referenceBytes?.length ?? 0) + jsonBytes(verified.capture.verification).length;
|
|
226
211
|
prune(bytes, 1);
|
|
227
212
|
const run = {
|
|
@@ -439,7 +424,7 @@ pdf.addEventListener('click', async event => {
|
|
|
439
424
|
var devHelp = `Usage: cso dev <file.cso.py> --function <name> [--port <0-65535>] [--reference <file.json>]
|
|
440
425
|
|
|
441
426
|
Serve a verified calculation on 127.0.0.1. Port 0 chooses an available port.
|
|
442
|
-
PYTHON selects the installed
|
|
427
|
+
PYTHON selects the installed cs-object interpreter. Source path and function are fixed at startup.
|
|
443
428
|
`;
|
|
444
429
|
function parseDevArgs(args) {
|
|
445
430
|
const [source, ...rest] = args;
|
package/dist/development.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
UsageError,
|
|
3
3
|
parseCliArgs
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-PC7UAF4D.js";
|
|
5
5
|
import {
|
|
6
|
+
isolatedEnvironment,
|
|
7
|
+
runPythonProcess,
|
|
6
8
|
stringifyJson
|
|
7
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-DIYNSURK.js";
|
|
8
10
|
|
|
9
11
|
// src/development.ts
|
|
10
|
-
import { spawnSync } from "child_process";
|
|
11
12
|
import {
|
|
12
13
|
existsSync,
|
|
13
14
|
mkdirSync,
|
|
@@ -31,13 +32,6 @@ var defaultCssPath = createRequire(import.meta.url).resolve(
|
|
|
31
32
|
"@cs-object/react/style.css"
|
|
32
33
|
);
|
|
33
34
|
var escapeHtml = (value) => value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
34
|
-
function isolatedEnvironment() {
|
|
35
|
-
const environment = { ...process.env };
|
|
36
|
-
Reflect.deleteProperty(environment, "NODE_PATH");
|
|
37
|
-
Reflect.deleteProperty(environment, "PYTHONPATH");
|
|
38
|
-
Reflect.deleteProperty(environment, "PYTHONHOME");
|
|
39
|
-
return environment;
|
|
40
|
-
}
|
|
41
35
|
function writeAtomically(outPath, bytes) {
|
|
42
36
|
mkdirSync(dirname(outPath), { recursive: true });
|
|
43
37
|
const temporary = join(
|
|
@@ -56,37 +50,31 @@ var runPythonExporter = ({
|
|
|
56
50
|
inputs,
|
|
57
51
|
sourcePath
|
|
58
52
|
}) => {
|
|
59
|
-
const result =
|
|
60
|
-
|
|
61
|
-
[
|
|
62
|
-
"-I",
|
|
63
|
-
"-m",
|
|
64
|
-
"cso_python",
|
|
65
|
-
"export",
|
|
53
|
+
const result = runPythonProcess({
|
|
54
|
+
command: "export",
|
|
55
|
+
args: [
|
|
66
56
|
sourcePath,
|
|
67
57
|
"--function",
|
|
68
58
|
functionName,
|
|
69
59
|
"--inputs-json",
|
|
70
60
|
stringifyJson(inputs)
|
|
71
61
|
],
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
env: isolatedEnvironment(),
|
|
75
|
-
maxBuffer: 32 * 1024 * 1024
|
|
76
|
-
}
|
|
77
|
-
);
|
|
62
|
+
maxBuffer: 32 * 1024 * 1024
|
|
63
|
+
});
|
|
78
64
|
if (result.error) {
|
|
79
65
|
throw result.error;
|
|
80
66
|
}
|
|
81
67
|
if (result.status !== 0) {
|
|
82
|
-
const message = result.stderr.trim() || "Python exporter failed";
|
|
68
|
+
const message = result.stderr.toString("utf8").trim() || "Python exporter failed";
|
|
83
69
|
if (result.status === 2) throw new UsageError(message);
|
|
84
70
|
throw new Error(message);
|
|
85
71
|
}
|
|
86
72
|
if (result.stderr) {
|
|
87
73
|
process.stderr.write(result.stderr);
|
|
88
74
|
}
|
|
89
|
-
return CalculationSourceObjectSchema.parse(
|
|
75
|
+
return CalculationSourceObjectSchema.parse(
|
|
76
|
+
JSON.parse(result.stdout.toString("utf8"))
|
|
77
|
+
);
|
|
90
78
|
};
|
|
91
79
|
var renderFormulaSheetHtml = (sheet, { css, title }) => {
|
|
92
80
|
const sheetMarkup = renderToStaticMarkup(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cs-object/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Installed calculation verification and development export/render commands.",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"tsup": "^8.5.1",
|
|
40
40
|
"typescript": "^5",
|
|
41
|
-
"vitest": "^5.0.
|
|
41
|
+
"vitest": "^5.0.2",
|
|
42
42
|
"@types/node": "^26",
|
|
43
43
|
"@types/react": "^19",
|
|
44
44
|
"@types/react-dom": "^19",
|
package/dist/html-AAIMIB2S.js
DELETED