@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.
- package/bin/atx +2 -2
- package/build/about.d.ts +3 -1
- package/build/about.js +37 -16
- package/build/about.js.map +1 -1
- package/build/cloud.d.ts +2 -2
- package/build/cloud.js +41 -19
- package/build/cloud.js.map +1 -1
- package/build/common.d.ts +5 -5
- package/build/common.js +48 -48
- package/build/common.js.map +1 -1
- package/build/confirmDevice.d.ts +5 -5
- package/build/confirmDevice.js +35 -35
- package/build/dhcp.d.ts +1 -1
- package/build/dhcp.js +9 -9
- package/build/dhcp.js.map +1 -1
- package/build/exe.d.ts +4 -0
- package/build/exe.js +43 -0
- package/build/exe.js.map +1 -0
- package/build/index.d.ts +1 -1
- package/build/index.js +81 -78
- package/build/index.js.map +1 -1
- package/build/ip.d.ts +2 -2
- package/build/ip.js +17 -17
- package/build/ip.js.map +1 -1
- package/build/linq.d.ts +3 -3
- package/build/linq.js +5 -5
- package/build/net.d.ts +3 -0
- package/build/net.js +47 -0
- package/build/net.js.map +1 -0
- package/build/poe.d.ts +4 -3
- package/build/poe.js +28 -23
- package/build/poe.js.map +1 -1
- package/build/reboot.d.ts +1 -0
- package/build/reboot.js +16 -0
- package/build/reboot.js.map +1 -0
- package/build/site.d.ts +2 -1
- package/build/site.js +18 -13
- package/build/site.js.map +1 -1
- package/build/stress.d.ts +1 -0
- package/build/stress.js +23 -0
- package/build/stress.js.map +1 -0
- package/build/unix.d.ts +1 -1
- package/build/unix.js +13 -13
- package/build/unix.js.map +1 -1
- package/build/update.d.ts +1 -1
- package/build/update.js +82 -82
- package/build/update.js.map +1 -1
- package/jest.config.js +6 -6
- package/package.json +3 -3
- package/src/about.ts +47 -13
- package/src/cloud.ts +55 -16
- package/src/exe.ts +54 -0
- package/src/index.ts +95 -89
- package/src/net.ts +68 -0
- package/src/stress.ts +30 -0
- package/src/{update.ts → update.ts.bak} +98 -98
- package/tsconfig.json +29 -29
- package/tsconfig.lib.json +8 -8
- package/tsconfig.lib.tsbuildinfo +1 -1
- package/src/common.ts +0 -63
- package/src/confirmDevice.ts +0 -51
- package/src/dhcp.ts +0 -6
- package/src/ip.ts +0 -14
- package/src/linq.ts +0 -9
- package/src/poe.ts +0 -22
- package/src/site.ts +0 -10
- package/src/unix.ts +0 -10
package/src/confirmDevice.ts
DELETED
|
@@ -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
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
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
|
-
}
|