@altronix/cli 0.5.0 → 0.6.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.
Files changed (67) hide show
  1. package/bin/atx +2 -2
  2. package/build/about.d.ts +3 -1
  3. package/build/about.js +37 -16
  4. package/build/about.js.map +1 -1
  5. package/build/cloud.d.ts +2 -2
  6. package/build/cloud.js +41 -19
  7. package/build/cloud.js.map +1 -1
  8. package/build/common.d.ts +5 -5
  9. package/build/common.js +48 -48
  10. package/build/common.js.map +1 -1
  11. package/build/confirmDevice.d.ts +5 -5
  12. package/build/confirmDevice.js +35 -35
  13. package/build/dhcp.d.ts +1 -1
  14. package/build/dhcp.js +9 -9
  15. package/build/dhcp.js.map +1 -1
  16. package/build/exe.d.ts +4 -0
  17. package/build/exe.js +43 -0
  18. package/build/exe.js.map +1 -0
  19. package/build/index.d.ts +1 -1
  20. package/build/index.js +81 -78
  21. package/build/index.js.map +1 -1
  22. package/build/ip.d.ts +2 -2
  23. package/build/ip.js +17 -17
  24. package/build/ip.js.map +1 -1
  25. package/build/linq.d.ts +3 -3
  26. package/build/linq.js +5 -5
  27. package/build/net.d.ts +3 -0
  28. package/build/net.js +47 -0
  29. package/build/net.js.map +1 -0
  30. package/build/poe.d.ts +4 -3
  31. package/build/poe.js +28 -23
  32. package/build/poe.js.map +1 -1
  33. package/build/reboot.d.ts +1 -0
  34. package/build/reboot.js +16 -0
  35. package/build/reboot.js.map +1 -0
  36. package/build/site.d.ts +2 -1
  37. package/build/site.js +18 -13
  38. package/build/site.js.map +1 -1
  39. package/build/stress.d.ts +1 -0
  40. package/build/stress.js +23 -0
  41. package/build/stress.js.map +1 -0
  42. package/build/unix.d.ts +1 -1
  43. package/build/unix.js +13 -13
  44. package/build/unix.js.map +1 -1
  45. package/build/update.d.ts +1 -1
  46. package/build/update.js +82 -82
  47. package/build/update.js.map +1 -1
  48. package/jest.config.js +6 -6
  49. package/package.json +3 -3
  50. package/src/about.ts +47 -13
  51. package/src/cloud.ts +55 -16
  52. package/src/exe.ts +54 -0
  53. package/src/index.ts +95 -89
  54. package/src/net.ts +68 -0
  55. package/src/stress.ts +30 -0
  56. package/src/{update.ts → update.ts.bak} +98 -98
  57. package/tsconfig.json +29 -29
  58. package/tsconfig.lib.json +8 -8
  59. package/tsconfig.lib.tsbuildinfo +1 -1
  60. package/src/common.ts +0 -63
  61. package/src/confirmDevice.ts +0 -51
  62. package/src/dhcp.ts +0 -6
  63. package/src/ip.ts +0 -14
  64. package/src/linq.ts +0 -9
  65. package/src/poe.ts +0 -22
  66. package/src/site.ts +0 -10
  67. package/src/unix.ts +0 -10
@@ -1,51 +0,0 @@
1
- import { from, Observable, Subject, EMPTY } from "rxjs";
2
- import { getLogger, CONNECTED, ConnectedEvent } from "@altronix/device";
3
- import { tap, take, filter, map, switchMap, expand } from "rxjs/operators";
4
- import linq from "./linq";
5
-
6
- type Device = ConnectedEvent["device"];
7
- type YES = "y" | "Y";
8
- type NO = "n" | "N";
9
-
10
- function isNo(c: string): c is NO {
11
- return c == "n" || c == "N";
12
- }
13
-
14
- function isChar(c: string): c is YES {
15
- if (isNo(c)) throw new Error("User rejected device");
16
- return (c.length == 1 && c == "y") || c == "Y" || c == "n" || c == "N";
17
- }
18
-
19
- function log(serial: string) {
20
- getLogger().info("confirm? (y/n)", { serial });
21
- }
22
-
23
- function chars(): Observable<string> {
24
- const subj = new Subject<string>();
25
- process.stdin.on("data", (data) => subj.next(data.toString().charAt(0)));
26
- process.stdin.on("error", (e) => subj.error(e));
27
- process.stdin.on("close", () => subj.complete());
28
- return subj.asObservable();
29
- }
30
-
31
- function confirm(): Observable<YES> {
32
- const source$ = chars();
33
- return source$.pipe(
34
- expand((c) => (isChar(c) ? EMPTY : source$)),
35
- filter(isChar)
36
- );
37
- }
38
-
39
- export default function confirmDevice(): Observable<Device> {
40
- return linq.listen().pipe(
41
- filter((ev): ev is ConnectedEvent => ev.type == CONNECTED),
42
- take(1),
43
- tap(({ device }) => log(device.about.sid)),
44
- switchMap(({ device }) => {
45
- return from(linq.get(device.about.sid, "/api/v1/about")).pipe(
46
- switchMap(() => confirm()),
47
- map(() => device)
48
- );
49
- })
50
- );
51
- }
package/src/dhcp.ts DELETED
@@ -1,6 +0,0 @@
1
- import { NetIp } from "@altronix/cbor";
2
- import { cliRunPut } from "./common";
3
-
4
- export async function setter(): Promise<void> {
5
- return cliRunPut("/api/v1/net/ip", new NetIp({ dhcp: true }));
6
- }
package/src/ip.ts DELETED
@@ -1,14 +0,0 @@
1
- import { NetIp } from "@altronix/cbor";
2
- import { cliRunGet, cliRunPut } from "./common";
3
- import { getLogger } from "@altronix/device";
4
-
5
- export function setter(ip: string, sn: string, gw: string): Promise<void> {
6
- return cliRunPut("/api/v1/net/ip", new NetIp({ ip, sn, gw }));
7
- }
8
-
9
- export async function getter(): Promise<void> {
10
- const path = "/api/v1/net/ip";
11
- const logger = getLogger();
12
- logger.debug(`GET ${path}`);
13
- logger.info("<-", { ...NetIp.fromCbor(await cliRunGet(path)).json() });
14
- }
package/src/linq.ts DELETED
@@ -1,9 +0,0 @@
1
- import {
2
- installDebugLogger,
3
- UsbTransport,
4
- TcpTransport,
5
- Listener,
6
- } from "@altronix/device";
7
-
8
- installDebugLogger();
9
- export default new Listener([new UsbTransport(), new TcpTransport(33422)]);
package/src/poe.ts DELETED
@@ -1,22 +0,0 @@
1
- import { PoePort } from "@altronix/netway";
2
- import { cliRunGet, cliRunPut } from "./common";
3
- import { getLogger } from "@altronix/device";
4
-
5
- export async function getPorts(): Promise<void> {
6
- const path = "/api/v1/netway/ports";
7
- const logger = getLogger();
8
- logger.debug(`GET ${path}`);
9
- PoePort.fromCborArray(await cliRunGet(path)).forEach((d, idx) =>
10
- logger.info(`<- ${idx}`, { ...d.json() })
11
- );
12
- }
13
-
14
- export function setPortOn(port: number): Promise<void> {
15
- let data = new PoePort({ enabled: true });
16
- return cliRunPut(`/api/v1/netway/ports?port=${port}`, data);
17
- }
18
-
19
- export function setPortOff(port: number): Promise<void> {
20
- let data = new PoePort({ enabled: false });
21
- return cliRunPut(`/api/v1/netway/ports?port=${port}`, data);
22
- }
package/src/site.ts DELETED
@@ -1,10 +0,0 @@
1
- import { cliRunGet } from "./common";
2
- import { cborDecodeStr } from "@altronix/cbor";
3
- import { getLogger } from "@altronix/device";
4
-
5
- export async function getter(): Promise<void> {
6
- const path = "/api/v1/about/site";
7
- const logger = getLogger();
8
- logger.debug(`GET ${path}`);
9
- logger.info("<-", { site: cborDecodeStr(await cliRunGet(path)) });
10
- }
package/src/unix.ts DELETED
@@ -1,10 +0,0 @@
1
- import { cliRunGet } from "./common";
2
- import { cborDecodeNum } from "@altronix/cbor";
3
- import { getLogger } from "@altronix/device";
4
-
5
- export async function getter(): Promise<void> {
6
- const path = "/api/v1/unix";
7
- const logger = getLogger();
8
- logger.debug(`GET ${path}`);
9
- logger.info("<-", { unix: cborDecodeNum(await cliRunGet(path)) });
10
- }