@lenso/cli 0.2.16 → 0.2.17

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/bin/lenso.js CHANGED
@@ -1,75 +1,74 @@
1
1
  #!/usr/bin/env node
2
- 'use strict';
3
-
4
- const { spawn } = require('node:child_process');
5
- const path = require('node:path');
6
-
2
+ "use strict";
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.platformTag = platformTag;
8
+ exports.binaryPath = binaryPath;
9
+ exports.forwardTerminationSignals = forwardTerminationSignals;
10
+ const node_child_process_1 = require("node:child_process");
11
+ const node_path_1 = __importDefault(require("node:path"));
12
+ const SUPPORTED_PLATFORMS = new Set(["darwin", "linux", "win32"]);
13
+ const SUPPORTED_ARCHES = new Set(["arm64", "x64"]);
7
14
  function platformTag(platform = process.platform, arch = process.arch) {
8
- const platforms = new Set(['darwin', 'linux', 'win32']);
9
- const arches = new Set(['arm64', 'x64']);
10
- if (!platforms.has(platform) || !arches.has(arch)) {
11
- return null;
12
- }
13
- return `${platform}-${arch}`;
15
+ if (!SUPPORTED_PLATFORMS.has(platform) || !SUPPORTED_ARCHES.has(arch)) {
16
+ return null;
17
+ }
18
+ return `${platform}-${arch}`;
14
19
  }
15
-
16
- function binaryPath(baseDir = path.join(__dirname, '..'), platform = process.platform, arch = process.arch) {
17
- const tag = platformTag(platform, arch);
18
- if (!tag) {
19
- return null;
20
- }
21
- const exe = platform === 'win32' ? 'lenso.exe' : 'lenso';
22
- return path.join(baseDir, 'vendor', tag, exe);
20
+ function binaryPath(baseDir = node_path_1.default.join(__dirname, ".."), platform = process.platform, arch = process.arch) {
21
+ const tag = platformTag(platform, arch);
22
+ if (!tag) {
23
+ return null;
24
+ }
25
+ const exe = platform === "win32" ? "lenso.exe" : "lenso";
26
+ return node_path_1.default.join(baseDir, "vendor", tag, exe);
23
27
  }
24
-
25
- function forwardTerminationSignals(parent, child, signals = ['SIGINT', 'SIGTERM']) {
26
- const handlers = new Map(signals.map((signal) => [
27
- signal,
28
- () => {
29
- if (child.exitCode === null && child.signalCode === null) {
30
- child.kill(signal);
31
- }
32
- },
33
- ]));
34
- for (const [signal, handler] of handlers) {
35
- parent.on(signal, handler);
36
- }
37
- return () => {
28
+ function forwardTerminationSignals(parent, child, signals = ["SIGINT", "SIGTERM"]) {
29
+ const handlers = new Map(signals.map((signal) => [
30
+ signal,
31
+ () => {
32
+ if (child.exitCode === null && child.signalCode === null) {
33
+ child.kill(signal);
34
+ }
35
+ },
36
+ ]));
38
37
  for (const [signal, handler] of handlers) {
39
- parent.off(signal, handler);
38
+ parent.on(signal, handler);
40
39
  }
41
- };
40
+ return () => {
41
+ for (const [signal, handler] of handlers) {
42
+ parent.off(signal, handler);
43
+ }
44
+ };
42
45
  }
43
-
44
46
  function run() {
45
- const exe = binaryPath();
46
- if (!exe) {
47
- console.error(`lenso: unsupported platform ${process.platform}/${process.arch}`);
48
- process.exit(1);
49
- }
50
-
51
- const child = spawn(exe, process.argv.slice(2), { stdio: 'inherit' });
52
- const stopForwardingSignals = forwardTerminationSignals(process, child);
53
- child.on('error', (error) => {
54
- if (error.code === 'ENOENT') {
55
- console.error(`lenso: bundled binary is missing for ${process.platform}/${process.arch}`);
56
- } else {
57
- console.error(`lenso: ${error.message}`);
58
- }
59
- process.exit(1);
60
- });
61
- child.on('exit', (code, signal) => {
62
- stopForwardingSignals();
63
- if (signal) {
64
- process.kill(process.pid, signal);
65
- return;
47
+ const exe = binaryPath();
48
+ if (!exe) {
49
+ console.error(`lenso: unsupported platform ${process.platform}/${process.arch}`);
50
+ process.exit(1);
66
51
  }
67
- process.exit(code ?? 1);
68
- });
52
+ const child = (0, node_child_process_1.spawn)(exe, process.argv.slice(2), { stdio: "inherit" });
53
+ const stopForwardingSignals = forwardTerminationSignals(process, child);
54
+ child.on("error", (error) => {
55
+ if (error.code === "ENOENT") {
56
+ console.error(`lenso: bundled binary is missing for ${process.platform}/${process.arch}`);
57
+ }
58
+ else {
59
+ console.error(`lenso: ${error.message}`);
60
+ }
61
+ process.exit(1);
62
+ });
63
+ child.on("exit", (code, signal) => {
64
+ stopForwardingSignals();
65
+ if (signal) {
66
+ process.kill(process.pid, signal);
67
+ return;
68
+ }
69
+ process.exit(code ?? 1);
70
+ });
69
71
  }
70
-
71
72
  if (require.main === module) {
72
- run();
73
+ run();
73
74
  }
74
-
75
- module.exports = { binaryPath, forwardTerminationSignals, platformTag };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lenso/cli",
3
- "version": "0.2.16",
3
+ "version": "0.2.17",
4
4
  "description": "Lenso command-line interface for scaffolding and operating Lenso backend projects.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/LioRael/lenso-cli",
@@ -16,7 +16,9 @@
16
16
  "vendor"
17
17
  ],
18
18
  "devDependencies": {
19
- "@changesets/cli": "2.31.1"
19
+ "@changesets/cli": "2.31.1",
20
+ "@types/node": "25.9.4",
21
+ "typescript": "7.0.2"
20
22
  },
21
23
  "publishConfig": {
22
24
  "access": "public"
@@ -25,10 +27,12 @@
25
27
  "node": ">=18"
26
28
  },
27
29
  "scripts": {
30
+ "build:shim": "node node_modules/typescript/bin/tsc -p tsconfig.json",
28
31
  "changeset": "changeset",
29
32
  "check:npm-publish": "node scripts/check-npm-publish.mjs",
30
- "check:npm-shim": "node scripts/check-npm-shim.mjs",
31
- "package:npm": "node scripts/package-npm.mjs",
33
+ "check:shim-generated": "pnpm build:shim && node scripts/check-shim-generated.mjs",
34
+ "check:npm-shim": "pnpm check:shim-generated && node scripts/check-npm-shim.mjs",
35
+ "package:npm": "pnpm build:shim && node scripts/package-npm.mjs",
32
36
  "release": "npm run check:npm-publish && changeset publish",
33
37
  "version": "changeset version"
34
38
  }
Binary file
Binary file
Binary file
Binary file