@anvil-works/anvil-cli 0.7.0-canary.19 → 0.7.0-canary.20

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 CHANGED
@@ -198,7 +198,7 @@ anvil validate .
198
198
 
199
199
  HTML validation parses the template with `@anvil-works/form-template-parser`, checks optional YAML frontmatter, and reports semantic issues such as duplicate explicit component names or invalid component types.
200
200
 
201
- Python validation checks syntax using a local Python interpreter (`ANVIL_PYTHON`, `python3`, or `python`). Form Python under `client_code/` also checks for the matching designer-template import and form class inheritance when a sibling form template exists.
201
+ Python validation checks syntax using a local Python interpreter (`ANVIL_PYTHON`, `uv`, `python3`, or `python`). Form Python under `client_code/` also checks for the matching designer-template import and form class inheritance when a sibling form template exists.
202
202
 
203
203
  When the file is valid, the command prints a success message and exits with status `0`. When the file is invalid, it prints path-specific validation issues and exits with a non-zero status.
204
204
 
package/dist/cli.js CHANGED
@@ -16356,14 +16356,35 @@ if class_name:
16356
16356
 
16357
16357
  print(json.dumps({"issues": issues}))
16358
16358
  `;
16359
- function findPythonInterpreter() {
16359
+ function findPythonInterpreter(env = process.env, probe = external_child_process_namespaceObject.spawnSync) {
16360
16360
  const candidates = [
16361
- process.env.ANVIL_PYTHON,
16362
- "python3",
16363
- "python"
16364
- ].filter((candidate)=>"string" == typeof candidate && candidate.length > 0);
16361
+ ..."string" == typeof env.ANVIL_PYTHON && env.ANVIL_PYTHON.length > 0 ? [
16362
+ {
16363
+ command: env.ANVIL_PYTHON,
16364
+ args: []
16365
+ }
16366
+ ] : [],
16367
+ {
16368
+ command: "uv",
16369
+ args: [
16370
+ "run",
16371
+ "--no-project",
16372
+ "--no-python-downloads",
16373
+ "python"
16374
+ ]
16375
+ },
16376
+ {
16377
+ command: "python3",
16378
+ args: []
16379
+ },
16380
+ {
16381
+ command: "python",
16382
+ args: []
16383
+ }
16384
+ ];
16365
16385
  for (const candidate of candidates){
16366
- const result = (0, external_child_process_namespaceObject.spawnSync)(candidate, [
16386
+ const result = probe(candidate.command, [
16387
+ ...candidate.args,
16367
16388
  "--version"
16368
16389
  ], {
16369
16390
  encoding: "utf8"
@@ -16397,14 +16418,15 @@ print(json.dumps({"issues": issues}))
16397
16418
  issues: [
16398
16419
  {
16399
16420
  path: "root",
16400
- message: "Python validation requires python3 or python on PATH, or ANVIL_PYTHON to be set"
16421
+ message: "Python validation requires uv, python3, or python on PATH, or ANVIL_PYTHON to be set"
16401
16422
  }
16402
16423
  ]
16403
16424
  };
16404
16425
  const absolutePath = external_path_default().resolve(filePath);
16405
16426
  const clientCodeRoot = appRoot ? external_path_default().join(appRoot, "client_code") : null;
16406
16427
  const formClassName = clientCodeRoot && isUnderDirectory(absolutePath, clientCodeRoot) ? expectedFormClassName(absolutePath) : null;
16407
- const result = (0, external_child_process_namespaceObject.spawnSync)(interpreter, [
16428
+ const result = (0, external_child_process_namespaceObject.spawnSync)(interpreter.command, [
16429
+ ...interpreter.args,
16408
16430
  "-c",
16409
16431
  PYTHON_VALIDATOR_SCRIPT,
16410
16432
  filePath,
package/dist/index.js CHANGED
@@ -16385,14 +16385,35 @@ if class_name:
16385
16385
 
16386
16386
  print(json.dumps({"issues": issues}))
16387
16387
  `;
16388
- function findPythonInterpreter() {
16388
+ function findPythonInterpreter(env = process.env, probe = external_child_process_namespaceObject.spawnSync) {
16389
16389
  const candidates = [
16390
- process.env.ANVIL_PYTHON,
16391
- "python3",
16392
- "python"
16393
- ].filter((candidate)=>"string" == typeof candidate && candidate.length > 0);
16390
+ ..."string" == typeof env.ANVIL_PYTHON && env.ANVIL_PYTHON.length > 0 ? [
16391
+ {
16392
+ command: env.ANVIL_PYTHON,
16393
+ args: []
16394
+ }
16395
+ ] : [],
16396
+ {
16397
+ command: "uv",
16398
+ args: [
16399
+ "run",
16400
+ "--no-project",
16401
+ "--no-python-downloads",
16402
+ "python"
16403
+ ]
16404
+ },
16405
+ {
16406
+ command: "python3",
16407
+ args: []
16408
+ },
16409
+ {
16410
+ command: "python",
16411
+ args: []
16412
+ }
16413
+ ];
16394
16414
  for (const candidate of candidates){
16395
- const result = (0, external_child_process_namespaceObject.spawnSync)(candidate, [
16415
+ const result = probe(candidate.command, [
16416
+ ...candidate.args,
16396
16417
  "--version"
16397
16418
  ], {
16398
16419
  encoding: "utf8"
@@ -16426,14 +16447,15 @@ print(json.dumps({"issues": issues}))
16426
16447
  issues: [
16427
16448
  {
16428
16449
  path: "root",
16429
- message: "Python validation requires python3 or python on PATH, or ANVIL_PYTHON to be set"
16450
+ message: "Python validation requires uv, python3, or python on PATH, or ANVIL_PYTHON to be set"
16430
16451
  }
16431
16452
  ]
16432
16453
  };
16433
16454
  const absolutePath = external_path_default().resolve(filePath);
16434
16455
  const clientCodeRoot = appRoot ? external_path_default().join(appRoot, "client_code") : null;
16435
16456
  const formClassName = clientCodeRoot && isUnderDirectory(absolutePath, clientCodeRoot) ? expectedFormClassName(absolutePath) : null;
16436
- const result = (0, external_child_process_namespaceObject.spawnSync)(interpreter, [
16457
+ const result = (0, external_child_process_namespaceObject.spawnSync)(interpreter.command, [
16458
+ ...interpreter.args,
16437
16459
  "-c",
16438
16460
  PYTHON_VALIDATOR_SCRIPT,
16439
16461
  filePath,
@@ -6,5 +6,17 @@ export type PythonValidationResult = {
6
6
  message: string;
7
7
  issues: ValidationIssue[];
8
8
  };
9
+ export type PythonInterpreterCommand = {
10
+ command: string;
11
+ args: string[];
12
+ };
13
+ type PythonProbe = (command: string, args: string[], options: {
14
+ encoding: BufferEncoding;
15
+ }) => {
16
+ error?: Error;
17
+ status: number | null;
18
+ };
19
+ export declare function findPythonInterpreter(env?: NodeJS.ProcessEnv, probe?: PythonProbe): PythonInterpreterCommand | null;
9
20
  export declare function validatePython(filePath: string, fileContent: string, appRoot: string | null): PythonValidationResult;
21
+ export {};
10
22
  //# sourceMappingURL=validatePython.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"validatePython.d.ts","sourceRoot":"","sources":["../src/validatePython.ts"],"names":[],"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AE,MAAM,GAAG,IAAI,GAAG,sBAAsB,CAsEpH"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anvil-works/anvil-cli",
3
- "version": "0.7.0-canary.19",
3
+ "version": "0.7.0-canary.20",
4
4
  "description": "CLI tool for developing Anvil apps locally",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/api.d.ts",