@sie-js/apoxi-tool 1.0.6 → 1.0.7

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/dist/src/cli.js CHANGED
@@ -6,12 +6,11 @@ import debug from "debug";
6
6
  import { getDefaultPort } from "#src/utils/serial.js";
7
7
  import { cliBruteforceDWDKeys, cliListSerialPorts } from "#src/cli/misc.js";
8
8
  import { cliUnlockBoot } from "#src/cli/unlock.js";
9
- import { readPackage } from "read-pkg";
10
- const pkg = await readPackage();
9
+ import { getVersion } from "#src/utils/version.js";
11
10
  const DEFAULT_PORT = await getDefaultPort();
12
11
  program
13
12
  .name("apoxi-tool")
14
- .version(pkg.version, '-v, --version')
13
+ .version(getVersion(), '-v, --version')
15
14
  .description('CLI tool for APOXI phones.')
16
15
  .option('-p, --port <port>', 'serial port name', DEFAULT_PORT)
17
16
  .option('-b, --baudrate <baudrate>', 'limit maximum baudrate (0 - use maximum)', '0')
@@ -0,0 +1 @@
1
+ export declare function getVersion(): string;
@@ -0,0 +1,20 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ export function getVersion() {
4
+ let currentDir = import.meta.dirname;
5
+ while (true) {
6
+ const pkgPath = path.join(currentDir, "package.json");
7
+ if (fs.existsSync(pkgPath)) {
8
+ const pkg = JSON.parse(fs.readFileSync(pkgPath).toString());
9
+ if (pkg.version) {
10
+ return pkg.version;
11
+ }
12
+ }
13
+ const parentDir = path.dirname(currentDir);
14
+ if (parentDir === currentDir) {
15
+ break;
16
+ }
17
+ currentDir = parentDir;
18
+ }
19
+ return "1.0.0";
20
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sie-js/apoxi-tool",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "CLI tools for APOXI phones.",
5
5
  "bin": {
6
6
  "apoxi-tool": "./dist/src/cli.js"
@@ -38,7 +38,6 @@
38
38
  "commander": "^14.0.0",
39
39
  "debug": "^4.4.1",
40
40
  "inquirer": "^12.9.1",
41
- "read-pkg": "^9.0.1",
42
41
  "serialport": "^13.0.0",
43
42
  "sprintf-js": "^1.1.3",
44
43
  "table": "^6.9.0"