@altronix/cli 0.2.0 → 0.3.0
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/build/about.d.ts +1 -0
- package/build/about.js +10 -0
- package/build/about.js.map +1 -0
- package/build/cloud.d.ts +2 -0
- package/build/cloud.js +16 -0
- package/build/cloud.js.map +1 -0
- package/build/common.d.ts +16 -0
- package/build/common.js +83 -0
- package/build/common.js.map +1 -0
- package/build/dhcp.d.ts +1 -0
- package/build/dhcp.js +10 -0
- package/build/dhcp.js.map +1 -0
- package/build/index.js +46 -7
- package/build/index.js.map +1 -1
- package/build/ip.d.ts +2 -0
- package/build/ip.js +14 -0
- package/build/ip.js.map +1 -0
- package/build/poe.d.ts +3 -0
- package/build/poe.js +20 -0
- package/build/poe.js.map +1 -0
- package/build/update.d.ts +1 -0
- package/build/update.js +83 -0
- package/build/update.js.map +1 -0
- package/package.json +6 -4
- package/src/about.ts +6 -0
- package/src/cloud.ts +12 -0
- package/src/common.ts +113 -0
- package/src/dhcp.ts +6 -0
- package/src/index.ts +52 -7
- package/src/ip.ts +10 -0
- package/src/poe.ts +16 -0
- package/src/update.ts +98 -0
- package/tsconfig.lib.tsbuildinfo +1 -1
- package/src/setCloud.ts +0 -41
- package/src/setDhcp.ts +0 -40
- package/src/setIp.ts +0 -44
package/src/setIp.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { ConnectedEvent, CONNECTED, getLogger } from "@altronix/device";
|
|
2
|
-
import { NetIp } from "@altronix/cbor";
|
|
3
|
-
import { take, filter, switchMap } from "rxjs/operators";
|
|
4
|
-
import { Observable, defer, EMPTY, concat } from "rxjs";
|
|
5
|
-
import linq from "./linq";
|
|
6
|
-
|
|
7
|
-
function request(serial: string, cbor: NetIp): Observable<never> {
|
|
8
|
-
return concat(
|
|
9
|
-
defer(() => linq.put(serial, "/api/v1/net/ip", cbor.cbor())),
|
|
10
|
-
defer(() => linq.get(serial, "/api/v1/exe/saveAndReboot"))
|
|
11
|
-
).pipe(switchMap(() => EMPTY));
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
function run(cbor: NetIp): Observable<never> {
|
|
15
|
-
return linq.listen().pipe(
|
|
16
|
-
filter((ev): ev is ConnectedEvent => ev.type == CONNECTED),
|
|
17
|
-
take(1),
|
|
18
|
-
switchMap(({ device }) => request(device.about.sid, cbor))
|
|
19
|
-
);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export default async function setIp(
|
|
23
|
-
ip: string,
|
|
24
|
-
sn: string,
|
|
25
|
-
gw: string
|
|
26
|
-
): Promise<void> {
|
|
27
|
-
const logger = getLogger();
|
|
28
|
-
return new Promise((resolve, reject) => {
|
|
29
|
-
const cbor = new NetIp({ ip, sn, gw });
|
|
30
|
-
logger.debug("update ip ->", { ...cbor.json() });
|
|
31
|
-
|
|
32
|
-
const sub = run(cbor).subscribe({
|
|
33
|
-
next: async () => (await linq.shutdown(), sub.unsubscribe(), resolve()),
|
|
34
|
-
error: async (error) => (await linq.shutdown(), reject(error)),
|
|
35
|
-
complete: async () => (await linq.shutdown(), resolve()),
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
process.on("SIGINT", async () => {
|
|
39
|
-
await linq.shutdown();
|
|
40
|
-
sub.unsubscribe();
|
|
41
|
-
resolve();
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
}
|