@altronix/cli 0.7.21 → 0.8.1
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/build.js +32 -12
- package/dist/concurrent.d.ts +2 -0
- package/dist/concurrent.js +26 -0
- package/dist/index.js +24 -0
- package/dist/sample.d.ts +3 -0
- package/dist/sample.js +30 -0
- package/package.json +3 -3
package/dist/build.js
CHANGED
|
@@ -348,9 +348,12 @@ function cmake(opts) {
|
|
|
348
348
|
}
|
|
349
349
|
function emulateBytePages(board) {
|
|
350
350
|
return (board.startsWith('atsame54_xpro') ||
|
|
351
|
-
board.startsWith('
|
|
351
|
+
board.startsWith('netwaysp4b') ||
|
|
352
|
+
board.startsWith('netwaysp4bt') ||
|
|
352
353
|
board.startsWith('netway4eb') ||
|
|
354
|
+
board.startsWith('netway4ebt') ||
|
|
353
355
|
board.startsWith('netway5pq') ||
|
|
356
|
+
board.startsWith('netway5btq') ||
|
|
354
357
|
board.startsWith('oa2b'));
|
|
355
358
|
}
|
|
356
359
|
function extraAppConfs(extraConfs, config) {
|
|
@@ -441,6 +444,9 @@ function tovoid() {
|
|
|
441
444
|
export async function build() {
|
|
442
445
|
const config = this.opts()['config'] || path.resolve('./', 'atx.json');
|
|
443
446
|
const verbose = this.optsWithGlobals()['verbose'];
|
|
447
|
+
const mBoard = new RegExp(this.opts()['matchesBoard'] || '(.*)');
|
|
448
|
+
const mApplication = new RegExp(this.opts()['matchesApplication'] || '(.*)');
|
|
449
|
+
const mConfig = new RegExp(this.opts()['matchesConfig'] || '(.*)');
|
|
444
450
|
const cwd = path.resolve(path.dirname(config));
|
|
445
451
|
const data = await fs.promises.readFile(config, 'ascii');
|
|
446
452
|
const atx = JSON.parse(data);
|
|
@@ -450,13 +456,23 @@ export async function build() {
|
|
|
450
456
|
throw validate.errors;
|
|
451
457
|
const env = path.resolve(cwd, '.env');
|
|
452
458
|
dotenv.config({ path: env });
|
|
453
|
-
const apps = keys(atx.applications)
|
|
454
|
-
|
|
455
|
-
|
|
459
|
+
const apps = keys(atx.applications)
|
|
460
|
+
.filter(({ __key }) => __key.match(mApplication))
|
|
461
|
+
.flatMap((app) => {
|
|
462
|
+
return keys(app.boards)
|
|
463
|
+
.filter(({ __key }) => __key.match(mBoard))
|
|
464
|
+
.flatMap((board) => {
|
|
465
|
+
return keys(board)
|
|
466
|
+
.filter(({ __key }) => __key.match(mConfig))
|
|
467
|
+
.map((config) => {
|
|
468
|
+
return westOptionsNormalize(board.__key, config, app, cwd, verbose);
|
|
469
|
+
});
|
|
456
470
|
});
|
|
457
471
|
});
|
|
458
472
|
const bootloaders = keys(atx.bootloaders).flatMap((app) => {
|
|
459
|
-
return keys(app.boards)
|
|
473
|
+
return keys(app.boards)
|
|
474
|
+
.filter(({ __key }) => __key.match(mBoard))
|
|
475
|
+
.flatMap((board) => {
|
|
460
476
|
return keys(board).map((config) => westOptionsNormalize(board.__key, config, app, cwd, verbose));
|
|
461
477
|
});
|
|
462
478
|
});
|
|
@@ -492,13 +508,17 @@ export async function build() {
|
|
|
492
508
|
dst: path.join(d, `${board}-${name}-${config}.bin`)
|
|
493
509
|
};
|
|
494
510
|
}))).pipe(copy(), tovoid());
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
511
|
+
try {
|
|
512
|
+
await lastValueFrom(ready$);
|
|
513
|
+
const items = await lastValueFrom(items$);
|
|
514
|
+
const renderer = render(React.createElement(Ui, { items: items, "progress$": build$, onComplete: () => renderer.unmount() }));
|
|
515
|
+
await renderer.waitUntilExit();
|
|
516
|
+
renderer.cleanup();
|
|
517
|
+
return lastValueFrom(install$);
|
|
518
|
+
}
|
|
519
|
+
catch (e) {
|
|
501
520
|
if (!(e instanceof EmptyError))
|
|
502
521
|
throw e;
|
|
503
|
-
|
|
522
|
+
console.log('nothing to build');
|
|
523
|
+
}
|
|
504
524
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Linq } from '@altronix/device';
|
|
2
|
+
import logger from './logger.js';
|
|
3
|
+
import { select, first } from './select.js';
|
|
4
|
+
import progress from './progress.js';
|
|
5
|
+
import { defer, EmptyError, finalize, merge, lastValueFrom, switchMap } from 'rxjs';
|
|
6
|
+
export async function concurrent(count) {
|
|
7
|
+
logger(this.optsWithGlobals()['verbose'] ? 'silly' : 'info');
|
|
8
|
+
const linq = new Linq();
|
|
9
|
+
// const request = {
|
|
10
|
+
// path: '/api/v1/about',
|
|
11
|
+
// meth: METH_CONSTANTS.GET,
|
|
12
|
+
// retry: 20,
|
|
13
|
+
// timeout: 10000
|
|
14
|
+
// };
|
|
15
|
+
const obs$ = linq.connections().pipe(this.optsWithGlobals()['first'] ? first() : select(), switchMap((serial) => {
|
|
16
|
+
const n = parseInt(count);
|
|
17
|
+
const requests = new Array(n)
|
|
18
|
+
.fill(0)
|
|
19
|
+
.map(() => defer(() => linq.get(serial, '/api/v1/about')));
|
|
20
|
+
return merge(...requests).pipe(progress(n));
|
|
21
|
+
}), finalize(() => linq.shutdown()));
|
|
22
|
+
return lastValueFrom(obs$).catch((e) => {
|
|
23
|
+
if (!(e instanceof EmptyError))
|
|
24
|
+
throw e;
|
|
25
|
+
});
|
|
26
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -11,6 +11,8 @@ import { getCloud, setCloud } from './cloud.js';
|
|
|
11
11
|
import { stress } from './stress.js';
|
|
12
12
|
import { update } from './update.js';
|
|
13
13
|
import { listen } from './listen.js';
|
|
14
|
+
import { getDemo, getHello } from './sample.js';
|
|
15
|
+
import { concurrent } from './concurrent.js';
|
|
14
16
|
// https://stackoverflow.com/questions/8817423/why-is-dirname-not-defined-in-node-repl
|
|
15
17
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
16
18
|
// Parse package.json to get version
|
|
@@ -44,6 +46,9 @@ program
|
|
|
44
46
|
.option('-A, --application', 'build applications')
|
|
45
47
|
.option('-B, --bootloader', 'build bootloaders')
|
|
46
48
|
.option('-W, --wasm', 'build wasm')
|
|
49
|
+
.option('--matches-board [regex]', 'board regex match expr')
|
|
50
|
+
.option('--matches-application [regex]', 'application regex match expr')
|
|
51
|
+
.option('--matches-config [regex]', 'config regex match expr')
|
|
47
52
|
.option('-y, --yes', 'answer yes automatically')
|
|
48
53
|
.action(build);
|
|
49
54
|
const device = program
|
|
@@ -116,6 +121,25 @@ device
|
|
|
116
121
|
.description('listen for alerts and heartbeats')
|
|
117
122
|
.argument('<duration>', 'how long to listen')
|
|
118
123
|
.action(listen);
|
|
124
|
+
device
|
|
125
|
+
.command('concurrent')
|
|
126
|
+
.description('make a number of requests concurrently')
|
|
127
|
+
.argument('<count>', 'how many requests to make concurrently')
|
|
128
|
+
.action(concurrent);
|
|
129
|
+
const sample = program
|
|
130
|
+
.command('sample')
|
|
131
|
+
.description('manage zephyr device settings')
|
|
132
|
+
.option('-p, --port <PORT>', 'listen port for incoming device connections')
|
|
133
|
+
.option('-v, --verbose', 'print extra debug informating during request')
|
|
134
|
+
.option('-f, --first', 'perform request on first device we see (any device)');
|
|
135
|
+
sample
|
|
136
|
+
.command('get-demo')
|
|
137
|
+
.description('read the demo data from the sample')
|
|
138
|
+
.action(getDemo);
|
|
139
|
+
sample
|
|
140
|
+
.command('get-hello')
|
|
141
|
+
.description('read the hello data from the sample')
|
|
142
|
+
.action(getHello);
|
|
119
143
|
// Load plugins
|
|
120
144
|
// (await plugins()).forEach(({ plugin: _, path: __, description: ___ }) => {});
|
|
121
145
|
program.parseAsync().catch((e) => console.error(e));
|
package/dist/sample.d.ts
ADDED
package/dist/sample.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// sample.tsx
|
|
2
|
+
import { Demo } from '@altronix/zdk/sample';
|
|
3
|
+
import { Linq } from '@altronix/device';
|
|
4
|
+
import { EmptyError, finalize, firstValueFrom, map, switchMap } from 'rxjs';
|
|
5
|
+
import logger from './logger.js';
|
|
6
|
+
import { select, first } from './select.js';
|
|
7
|
+
export async function getDemo() {
|
|
8
|
+
logger(this.optsWithGlobals()['verbose'] ? 'silly' : 'info');
|
|
9
|
+
const linq = new Linq();
|
|
10
|
+
const path = '/sample/demo';
|
|
11
|
+
const obs = linq.connections().pipe(this.optsWithGlobals()['first'] ? first() : select(), switchMap((sid) => linq.get(sid, path)), map((resp) => Demo.fromCbor(resp.body)), finalize(() => linq.shutdown()));
|
|
12
|
+
return firstValueFrom(obs)
|
|
13
|
+
.then((about) => console.log(JSON.stringify(about.toJson(), null, 2)))
|
|
14
|
+
.catch((e) => {
|
|
15
|
+
if (!(e instanceof EmptyError))
|
|
16
|
+
throw e;
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
export async function getHello() {
|
|
20
|
+
logger(this.optsWithGlobals()['verbose'] ? 'silly' : 'info');
|
|
21
|
+
const linq = new Linq();
|
|
22
|
+
const path = '/sample/hello';
|
|
23
|
+
const obs = linq.connections().pipe(this.optsWithGlobals()['first'] ? first() : select(), switchMap((sid) => linq.get(sid, path)), map((resp) => JSON.parse(new TextDecoder().decode(resp.body))), finalize(() => linq.shutdown()));
|
|
24
|
+
return firstValueFrom(obs)
|
|
25
|
+
.then((about) => console.log(JSON.stringify(about, null, 2)))
|
|
26
|
+
.catch((e) => {
|
|
27
|
+
if (!(e instanceof EmptyError))
|
|
28
|
+
throw e;
|
|
29
|
+
});
|
|
30
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@altronix/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"react": "^18.2.0",
|
|
23
23
|
"rxjs": "^7.8.1",
|
|
24
24
|
"winston": "^3.13.0",
|
|
25
|
-
"@altronix/
|
|
26
|
-
"@altronix/
|
|
25
|
+
"@altronix/device": "0.7.2",
|
|
26
|
+
"@altronix/zdk": "0.7.3"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@sindresorhus/tsconfig": "^3.0.1",
|