@linguacode/cli 1.3.0 → 1.4.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 +6 -3
- package/bin/lingua.cjs +75 -24
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -25,9 +25,12 @@ lingua --version
|
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
Release pages also carry standalone Windows and Linux x64 archives. Those
|
|
28
|
-
archives embed the matching Node.js runtime
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
archives embed the matching Node.js runtime for the CLI itself, so utilities
|
|
29
|
+
and Capsule validation do not require a separate Node installation. Running or
|
|
30
|
+
replaying JavaScript and TypeScript still requires Node.js 24 on `PATH`; other
|
|
31
|
+
languages need their own command-line toolchains. Extract the archive, place
|
|
32
|
+
`lingua` or `lingua.exe` on `PATH`, and verify it against the release
|
|
33
|
+
`SHA256SUMS.txt` before use.
|
|
31
34
|
|
|
32
35
|
## Examples
|
|
33
36
|
|
package/bin/lingua.cjs
CHANGED
|
@@ -337,6 +337,7 @@ var TOOLCHAIN_KEYS = [
|
|
|
337
337
|
"NODE_PATH",
|
|
338
338
|
"NPM_CONFIG_CACHE",
|
|
339
339
|
"NPM_CONFIG_PREFIX",
|
|
340
|
+
"PYTHON",
|
|
340
341
|
"VIRTUAL_ENV",
|
|
341
342
|
"PYTHONPATH",
|
|
342
343
|
"PYENV_VERSION",
|
|
@@ -459,8 +460,9 @@ function buildMissingRuntimeRecovery(command, runtime, platform = process.platfo
|
|
|
459
460
|
verifyExecutable: executable,
|
|
460
461
|
installGuide: CLI_RUNTIME_HELP_URL
|
|
461
462
|
};
|
|
463
|
+
const verifyExecutable = key === "python" ? executable : descriptor.verifyExecutable;
|
|
462
464
|
const installCommand = platform === "darwin" && descriptor.homebrewFormula ? `brew install ${descriptor.homebrewFormula}` : void 0;
|
|
463
|
-
const verifyCommand = `${
|
|
465
|
+
const verifyCommand = `${verifyExecutable} --version`;
|
|
464
466
|
const recovery = {
|
|
465
467
|
runtime: descriptor.name,
|
|
466
468
|
executable,
|
|
@@ -493,7 +495,9 @@ function executableName(command) {
|
|
|
493
495
|
}
|
|
494
496
|
function runtimeKey(executable, runtime) {
|
|
495
497
|
const normalizedRuntime = runtime.toLowerCase();
|
|
496
|
-
if (executable.startsWith("python") || normalizedRuntime.startsWith("python"))
|
|
498
|
+
if (executable === "py" || executable.startsWith("python") || normalizedRuntime.startsWith("python")) {
|
|
499
|
+
return "python";
|
|
500
|
+
}
|
|
497
501
|
if (executable === "go" || normalizedRuntime.startsWith("go")) return "go";
|
|
498
502
|
if (["rustc", "cargo"].includes(executable) || normalizedRuntime.startsWith("rust")) return "rust";
|
|
499
503
|
if (executable === "ruby" || normalizedRuntime.startsWith("ruby")) return "ruby";
|
|
@@ -734,9 +738,11 @@ function killProcessTree(child, signal) {
|
|
|
734
738
|
}
|
|
735
739
|
|
|
736
740
|
// src/cli/runtime/targets.ts
|
|
741
|
+
var import_node_fs = require("node:fs");
|
|
737
742
|
var import_promises2 = require("node:fs/promises");
|
|
738
743
|
var import_node_os = __toESM(require("node:os"));
|
|
739
744
|
var import_node_path2 = __toESM(require("node:path"));
|
|
745
|
+
var import_node_sea = require("node:sea");
|
|
740
746
|
|
|
741
747
|
// node_modules/acorn/dist/acorn.mjs
|
|
742
748
|
var astralIdentifierCodes = [509, 0, 227, 0, 150, 4, 294, 9, 1368, 2, 2, 1, 6, 3, 41, 2, 5, 0, 166, 1, 574, 3, 9, 9, 7, 9, 32, 4, 318, 1, 78, 5, 71, 10, 50, 3, 123, 2, 54, 14, 32, 10, 3, 1, 11, 3, 46, 10, 8, 0, 46, 9, 7, 2, 37, 13, 2, 9, 6, 1, 45, 0, 13, 2, 49, 13, 9, 3, 2, 11, 83, 11, 7, 0, 3, 0, 158, 11, 6, 9, 7, 3, 56, 1, 2, 6, 3, 1, 3, 2, 10, 0, 11, 1, 3, 6, 4, 4, 68, 8, 2, 0, 3, 0, 2, 3, 2, 4, 2, 0, 15, 1, 83, 17, 10, 9, 5, 0, 82, 19, 13, 9, 214, 6, 3, 8, 28, 1, 83, 16, 16, 9, 82, 12, 9, 9, 7, 19, 58, 14, 5, 9, 243, 14, 166, 9, 71, 5, 2, 1, 3, 3, 2, 0, 2, 1, 13, 9, 120, 6, 3, 6, 4, 0, 29, 9, 41, 6, 2, 3, 9, 0, 10, 10, 47, 15, 199, 7, 137, 9, 54, 7, 2, 7, 17, 9, 57, 21, 2, 13, 123, 5, 4, 0, 2, 1, 2, 6, 2, 0, 9, 9, 49, 4, 2, 1, 2, 4, 9, 9, 55, 9, 266, 3, 10, 1, 2, 0, 49, 6, 4, 4, 14, 10, 5350, 0, 7, 14, 11465, 27, 2343, 9, 87, 9, 39, 4, 60, 6, 26, 9, 535, 9, 470, 0, 2, 54, 8, 3, 82, 0, 12, 1, 19628, 1, 4178, 9, 519, 45, 3, 22, 543, 4, 4, 5, 9, 7, 3, 6, 31, 3, 149, 2, 1418, 49, 513, 54, 5, 49, 9, 0, 15, 0, 23, 4, 2, 14, 1361, 6, 2, 16, 3, 6, 2, 1, 2, 4, 101, 0, 161, 6, 10, 9, 357, 0, 62, 13, 499, 13, 245, 1, 2, 9, 233, 0, 3, 0, 8, 1, 6, 0, 475, 6, 110, 6, 6, 9, 4759, 9, 787719, 239];
|
|
@@ -6442,7 +6448,7 @@ var ExecutionTargetError = class extends Error {
|
|
|
6442
6448
|
}
|
|
6443
6449
|
reason;
|
|
6444
6450
|
};
|
|
6445
|
-
async function resolveExecutionTarget(target, programArgs) {
|
|
6451
|
+
async function resolveExecutionTarget(target, programArgs, env = process.env) {
|
|
6446
6452
|
const absolute = import_node_path2.default.resolve(target);
|
|
6447
6453
|
let targetStat;
|
|
6448
6454
|
try {
|
|
@@ -6455,17 +6461,17 @@ async function resolveExecutionTarget(target, programArgs) {
|
|
|
6455
6461
|
);
|
|
6456
6462
|
}
|
|
6457
6463
|
if (targetStat.isFile()) {
|
|
6458
|
-
return planFile(absolute, target, programArgs);
|
|
6464
|
+
return planFile(absolute, target, programArgs, env);
|
|
6459
6465
|
}
|
|
6460
6466
|
if (targetStat.isDirectory()) {
|
|
6461
|
-
return planProject(absolute, target, programArgs);
|
|
6467
|
+
return planProject(absolute, target, programArgs, env);
|
|
6462
6468
|
}
|
|
6463
6469
|
throw new ExecutionTargetError(
|
|
6464
6470
|
"unsupported-file-type",
|
|
6465
6471
|
`Target must be a regular file or directory: ${target}`
|
|
6466
6472
|
);
|
|
6467
6473
|
}
|
|
6468
|
-
async function resolveCapsuleSource(input, programArgs) {
|
|
6474
|
+
async function resolveCapsuleSource(input, programArgs, env = process.env) {
|
|
6469
6475
|
if (input.runtimeMode === "browser-preview") {
|
|
6470
6476
|
throw new ExecutionTargetError(
|
|
6471
6477
|
"unsupported-runtime-mode",
|
|
@@ -6482,7 +6488,7 @@ async function resolveCapsuleSource(input, programArgs) {
|
|
|
6482
6488
|
return planJavaScriptCapsule(displayTarget, cwd, input, programArgs, true);
|
|
6483
6489
|
}
|
|
6484
6490
|
case "python":
|
|
6485
|
-
return singleStep(displayTarget, "python", cwd, await findPython(cwd), [
|
|
6491
|
+
return singleStep(displayTarget, "python", cwd, await findPython(cwd, env), [
|
|
6486
6492
|
"-c",
|
|
6487
6493
|
input.source,
|
|
6488
6494
|
...programArgs
|
|
@@ -6510,7 +6516,7 @@ async function resolveCapsuleSource(input, programArgs) {
|
|
|
6510
6516
|
);
|
|
6511
6517
|
}
|
|
6512
6518
|
}
|
|
6513
|
-
async function planProject(root, displayTarget, programArgs) {
|
|
6519
|
+
async function planProject(root, displayTarget, programArgs, env) {
|
|
6514
6520
|
const packageJson = import_node_path2.default.join(root, "package.json");
|
|
6515
6521
|
if (await exists(packageJson)) {
|
|
6516
6522
|
let manifest;
|
|
@@ -6534,7 +6540,7 @@ async function planProject(root, displayTarget, programArgs) {
|
|
|
6534
6540
|
}
|
|
6535
6541
|
if (isRecord2(manifest) && typeof manifest.main === "string") {
|
|
6536
6542
|
const mainPath = import_node_path2.default.resolve(root, manifest.main);
|
|
6537
|
-
if (await isFile(mainPath)) return planFile(mainPath, displayTarget, programArgs);
|
|
6543
|
+
if (await isFile(mainPath)) return planFile(mainPath, displayTarget, programArgs, env);
|
|
6538
6544
|
}
|
|
6539
6545
|
}
|
|
6540
6546
|
if (await exists(import_node_path2.default.join(root, "go.mod"))) {
|
|
@@ -6554,7 +6560,7 @@ async function planProject(root, displayTarget, programArgs) {
|
|
|
6554
6560
|
}
|
|
6555
6561
|
for (const candidate of PROJECT_ENTRY_CANDIDATES) {
|
|
6556
6562
|
const entry = import_node_path2.default.join(root, candidate);
|
|
6557
|
-
if (await isFile(entry)) return planFile(entry, displayTarget, programArgs);
|
|
6563
|
+
if (await isFile(entry)) return planFile(entry, displayTarget, programArgs, env);
|
|
6558
6564
|
}
|
|
6559
6565
|
throw new ExecutionTargetError(
|
|
6560
6566
|
"no-project-entry",
|
|
@@ -6579,24 +6585,27 @@ var PROJECT_ENTRY_CANDIDATES = [
|
|
|
6579
6585
|
"index.ts",
|
|
6580
6586
|
"src/index.ts"
|
|
6581
6587
|
];
|
|
6582
|
-
async function planFile(absolute, displayTarget, programArgs) {
|
|
6588
|
+
async function planFile(absolute, displayTarget, programArgs, env) {
|
|
6583
6589
|
const cwd = import_node_path2.default.dirname(absolute);
|
|
6584
6590
|
const extension = import_node_path2.default.extname(absolute).toLowerCase();
|
|
6585
6591
|
switch (extension) {
|
|
6586
6592
|
case ".js":
|
|
6587
6593
|
case ".mjs":
|
|
6588
6594
|
case ".cjs":
|
|
6589
|
-
return singleStep(displayTarget, "node", cwd,
|
|
6595
|
+
return singleStep(displayTarget, "node", cwd, nodeRuntimeExecutable(), [
|
|
6596
|
+
absolute,
|
|
6597
|
+
...programArgs
|
|
6598
|
+
]);
|
|
6590
6599
|
case ".ts":
|
|
6591
6600
|
case ".mts":
|
|
6592
6601
|
case ".cts":
|
|
6593
|
-
return singleStep(displayTarget, "node-typescript", cwd,
|
|
6602
|
+
return singleStep(displayTarget, "node-typescript", cwd, nodeRuntimeExecutable(), [
|
|
6594
6603
|
"--experimental-strip-types",
|
|
6595
6604
|
absolute,
|
|
6596
6605
|
...programArgs
|
|
6597
6606
|
]);
|
|
6598
6607
|
case ".py":
|
|
6599
|
-
return singleStep(displayTarget, "python", cwd, await findPython(cwd), [
|
|
6608
|
+
return singleStep(displayTarget, "python", cwd, await findPython(cwd, env), [
|
|
6600
6609
|
absolute,
|
|
6601
6610
|
...programArgs
|
|
6602
6611
|
]);
|
|
@@ -6694,7 +6703,7 @@ function planJavaScriptCapsule(displayTarget, cwd, input, programArgs, typescrip
|
|
|
6694
6703
|
displayTarget,
|
|
6695
6704
|
typescript ? "node-typescript-worker" : "node-worker",
|
|
6696
6705
|
cwd,
|
|
6697
|
-
|
|
6706
|
+
nodeRuntimeExecutable(),
|
|
6698
6707
|
[
|
|
6699
6708
|
...typescript ? ["--experimental-strip-types"] : [],
|
|
6700
6709
|
"--input-type=commonjs",
|
|
@@ -6709,7 +6718,7 @@ function planJavaScriptCapsule(displayTarget, cwd, input, programArgs, typescrip
|
|
|
6709
6718
|
displayTarget,
|
|
6710
6719
|
typescript ? "node-typescript" : "node",
|
|
6711
6720
|
cwd,
|
|
6712
|
-
|
|
6721
|
+
nodeRuntimeExecutable(),
|
|
6713
6722
|
[
|
|
6714
6723
|
...typescript ? ["--experimental-strip-types"] : [],
|
|
6715
6724
|
`--input-type=${sourceRequiresModuleInput(input.source) ? "module" : "commonjs"}`,
|
|
@@ -6724,7 +6733,14 @@ function planJavaScriptCapsule(displayTarget, cwd, input, programArgs, typescrip
|
|
|
6724
6733
|
`Capsule runtime mode ${JSON.stringify(input.runtimeMode)} is not replayable by the CLI for ${typescript ? "TypeScript" : "JavaScript"}; supported modes are worker and node.`
|
|
6725
6734
|
);
|
|
6726
6735
|
}
|
|
6727
|
-
|
|
6736
|
+
function pythonCommandCandidates(platform = process.platform) {
|
|
6737
|
+
return platform === "win32" ? ["python", "py", "python3"] : ["python3", "python"];
|
|
6738
|
+
}
|
|
6739
|
+
function nodeRuntimeExecutable(options) {
|
|
6740
|
+
const sea = options?.sea ?? (0, import_node_sea.isSea)();
|
|
6741
|
+
return sea ? commandName("node") : options?.execPath ?? process.execPath;
|
|
6742
|
+
}
|
|
6743
|
+
async function findPython(startDirectory, env = process.env) {
|
|
6728
6744
|
let current2 = startDirectory;
|
|
6729
6745
|
while (true) {
|
|
6730
6746
|
const local = process.platform === "win32" ? import_node_path2.default.join(current2, ".venv", "Scripts", "python.exe") : import_node_path2.default.join(current2, ".venv", "bin", "python");
|
|
@@ -6733,7 +6749,31 @@ async function findPython(startDirectory) {
|
|
|
6733
6749
|
if (parent === current2) break;
|
|
6734
6750
|
current2 = parent;
|
|
6735
6751
|
}
|
|
6736
|
-
|
|
6752
|
+
if (env.PYTHON) return env.PYTHON;
|
|
6753
|
+
const candidates = pythonCommandCandidates();
|
|
6754
|
+
for (const candidate of candidates) {
|
|
6755
|
+
if (await executableIsOnPath(candidate, process.platform, env)) return commandName(candidate);
|
|
6756
|
+
}
|
|
6757
|
+
return commandName(candidates[0]);
|
|
6758
|
+
}
|
|
6759
|
+
async function executableIsOnPath(executable, platform = process.platform, env = process.env) {
|
|
6760
|
+
const pathValue = env.PATH ?? env.Path ?? env.path;
|
|
6761
|
+
if (!pathValue) return false;
|
|
6762
|
+
const windows = platform === "win32";
|
|
6763
|
+
const pathApi = windows ? import_node_path2.default.win32 : import_node_path2.default.posix;
|
|
6764
|
+
const delimiter = windows ? ";" : ":";
|
|
6765
|
+
const extensions = windows ? (env.PATHEXT ?? ".COM;.EXE;.BAT;.CMD").split(";").filter(Boolean).map((extension) => extension.toLowerCase()) : [""];
|
|
6766
|
+
const hasExtension = pathApi.extname(executable).length > 0;
|
|
6767
|
+
for (const rawEntry of pathValue.split(delimiter)) {
|
|
6768
|
+
const entry = rawEntry.trim().replace(/^"|"$/gu, "");
|
|
6769
|
+
if (!entry) continue;
|
|
6770
|
+
const base = pathApi.join(entry, executable);
|
|
6771
|
+
const candidates = windows && !hasExtension ? extensions.map((extension) => base + extension) : [base];
|
|
6772
|
+
for (const candidate of candidates) {
|
|
6773
|
+
if (await isExecutableFile(candidate, platform)) return true;
|
|
6774
|
+
}
|
|
6775
|
+
}
|
|
6776
|
+
return false;
|
|
6737
6777
|
}
|
|
6738
6778
|
function commandName(name) {
|
|
6739
6779
|
return process.platform === "win32" && ["npm", "npx"].includes(name) ? `${name}.cmd` : name;
|
|
@@ -6753,6 +6793,16 @@ async function isFile(filePath) {
|
|
|
6753
6793
|
return false;
|
|
6754
6794
|
}
|
|
6755
6795
|
}
|
|
6796
|
+
async function isExecutableFile(filePath, platform = process.platform) {
|
|
6797
|
+
if (!await isFile(filePath)) return false;
|
|
6798
|
+
if (platform === "win32") return true;
|
|
6799
|
+
try {
|
|
6800
|
+
await (0, import_promises2.access)(filePath, import_node_fs.constants.X_OK);
|
|
6801
|
+
return true;
|
|
6802
|
+
} catch {
|
|
6803
|
+
return false;
|
|
6804
|
+
}
|
|
6805
|
+
}
|
|
6756
6806
|
function isRecord2(value) {
|
|
6757
6807
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6758
6808
|
}
|
|
@@ -6800,7 +6850,7 @@ async function runTargetCommand(args, io) {
|
|
|
6800
6850
|
}
|
|
6801
6851
|
let plan;
|
|
6802
6852
|
try {
|
|
6803
|
-
plan = await resolveExecutionTarget(args.target, args.programArgs);
|
|
6853
|
+
plan = await resolveExecutionTarget(args.target, args.programArgs, env);
|
|
6804
6854
|
} catch (error) {
|
|
6805
6855
|
if (error instanceof ExecutionTargetError) {
|
|
6806
6856
|
const unsupported = [
|
|
@@ -6937,7 +6987,8 @@ async function runReplayCapsuleCommand(args, io) {
|
|
|
6937
6987
|
source: capsule.source.content,
|
|
6938
6988
|
capsuleId: capsule.capsuleId
|
|
6939
6989
|
},
|
|
6940
|
-
capsule.input.args ?? []
|
|
6990
|
+
capsule.input.args ?? [],
|
|
6991
|
+
env
|
|
6941
6992
|
);
|
|
6942
6993
|
} catch (error) {
|
|
6943
6994
|
if (error instanceof ExecutionTargetError) {
|
|
@@ -7036,7 +7087,7 @@ function errorMessage3(error) {
|
|
|
7036
7087
|
}
|
|
7037
7088
|
|
|
7038
7089
|
// src/cli/commands/completionInstall.ts
|
|
7039
|
-
var
|
|
7090
|
+
var import_node_fs2 = require("node:fs");
|
|
7040
7091
|
var import_promises3 = require("node:fs/promises");
|
|
7041
7092
|
var import_node_os2 = __toESM(require("node:os"));
|
|
7042
7093
|
var import_node_path3 = __toESM(require("node:path"));
|
|
@@ -7428,7 +7479,7 @@ var defaultDependencies = {
|
|
|
7428
7479
|
homedir: import_node_os2.default.homedir,
|
|
7429
7480
|
async isExecutable(filePath) {
|
|
7430
7481
|
try {
|
|
7431
|
-
await (0, import_promises3.access)(filePath,
|
|
7482
|
+
await (0, import_promises3.access)(filePath, import_node_fs2.constants.X_OK);
|
|
7432
7483
|
return true;
|
|
7433
7484
|
} catch {
|
|
7434
7485
|
return false;
|
|
@@ -10870,8 +10921,8 @@ function assertSingleTarget(command, positionals, help, label) {
|
|
|
10870
10921
|
|
|
10871
10922
|
// src/cli/lingua.ts
|
|
10872
10923
|
function resolveCliVersion() {
|
|
10873
|
-
if ("1.
|
|
10874
|
-
return "1.
|
|
10924
|
+
if ("1.4.1".length > 0) {
|
|
10925
|
+
return "1.4.1";
|
|
10875
10926
|
}
|
|
10876
10927
|
return "0.0.0-dev";
|
|
10877
10928
|
}
|
package/package.json
CHANGED