@altronix/cli 0.8.1 → 0.10.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/dist/build.js +63 -62
- package/dist/keys.d.ts +2 -1
- package/dist/keys.js +11 -2
- package/package.json +1 -1
- package/dist/app.d.ts +0 -6
- package/dist/app.js +0 -7
- package/dist/cli.d.ts +0 -2
- package/dist/cli.js +0 -24
- package/dist/stress.ui.d.ts +0 -3
- package/dist/stress.ui.js +0 -31
package/dist/build.js
CHANGED
|
@@ -10,64 +10,69 @@ import { render } from 'ink';
|
|
|
10
10
|
import React from 'react';
|
|
11
11
|
import Ui, { BuildError } from './build.ui.js';
|
|
12
12
|
import { keys } from './keys.js';
|
|
13
|
-
const
|
|
13
|
+
const schemaBoard = {
|
|
14
14
|
type: 'object',
|
|
15
|
-
required: [],
|
|
16
|
-
|
|
17
|
-
'
|
|
15
|
+
required: ['images'],
|
|
16
|
+
properties: {
|
|
17
|
+
version: { type: 'string', nullable: true },
|
|
18
|
+
soc: { type: 'string', nullable: true },
|
|
19
|
+
cpu: { type: 'string', nullable: true },
|
|
20
|
+
variant: { type: 'string', nullable: true },
|
|
21
|
+
images: {
|
|
18
22
|
type: 'object',
|
|
19
|
-
required: [
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
'.*': {
|
|
33
|
-
type: 'object',
|
|
34
|
-
properties: {
|
|
35
|
-
configs: {
|
|
36
|
-
type: 'array',
|
|
37
|
-
items: { type: 'string' },
|
|
38
|
-
nullable: true
|
|
39
|
-
},
|
|
40
|
-
overlays: {
|
|
41
|
-
type: 'array',
|
|
42
|
-
items: { type: 'string' },
|
|
43
|
-
nullable: true
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
23
|
+
required: [],
|
|
24
|
+
additionalProperties: {
|
|
25
|
+
type: 'object',
|
|
26
|
+
properties: {
|
|
27
|
+
configs: {
|
|
28
|
+
type: 'array',
|
|
29
|
+
items: { type: 'string' },
|
|
30
|
+
nullable: true
|
|
31
|
+
},
|
|
32
|
+
overlays: {
|
|
33
|
+
type: 'array',
|
|
34
|
+
items: { type: 'string' },
|
|
35
|
+
nullable: true
|
|
49
36
|
}
|
|
50
37
|
}
|
|
51
38
|
}
|
|
52
39
|
}
|
|
53
40
|
}
|
|
54
41
|
};
|
|
55
|
-
const
|
|
42
|
+
const schemaBuild = {
|
|
56
43
|
type: 'object',
|
|
57
44
|
required: [],
|
|
58
|
-
|
|
59
|
-
'
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
45
|
+
additionalProperties: {
|
|
46
|
+
type: 'object',
|
|
47
|
+
required: ['sourceDir', 'binaryDir', 'installDir', 'boards'],
|
|
48
|
+
properties: {
|
|
49
|
+
sourceDir: { type: 'string' },
|
|
50
|
+
binaryDir: { type: 'string' },
|
|
51
|
+
installDir: { type: 'string' },
|
|
52
|
+
boards: {
|
|
53
|
+
type: 'object',
|
|
54
|
+
required: [],
|
|
55
|
+
additionalProperties: {
|
|
56
|
+
anyOf: [{ ...schemaBoard }, { type: 'array', items: schemaBoard }]
|
|
57
|
+
}
|
|
67
58
|
}
|
|
68
59
|
}
|
|
69
60
|
}
|
|
70
61
|
};
|
|
62
|
+
const schemaSeedle = {
|
|
63
|
+
type: 'object',
|
|
64
|
+
required: [],
|
|
65
|
+
additionalProperties: {
|
|
66
|
+
type: 'object',
|
|
67
|
+
required: ['installDir', 'files'],
|
|
68
|
+
properties: {
|
|
69
|
+
namespace: { type: 'string', nullable: true },
|
|
70
|
+
prefix: { type: 'string', nullable: true },
|
|
71
|
+
installDir: { type: 'string' },
|
|
72
|
+
files: { type: 'array', items: { type: 'string' } }
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
};
|
|
71
76
|
const schema = {
|
|
72
77
|
type: 'object',
|
|
73
78
|
required: ['applications', 'bootloaders', 'wasm'],
|
|
@@ -143,9 +148,12 @@ function formatVersion(ver) {
|
|
|
143
148
|
async function westOptionsNormalize(board, config, build, cwd, verbose) {
|
|
144
149
|
const resolve = await resolver(cwd);
|
|
145
150
|
const name = build.__key;
|
|
151
|
+
const boardTarget = [board.__key, board.soc, board.cpu, board.variant]
|
|
152
|
+
.filter((item) => !!item)
|
|
153
|
+
.join('/');
|
|
146
154
|
const installDir = resolve(build.installDir);
|
|
147
155
|
const sourceDir = resolve(build.sourceDir);
|
|
148
|
-
const binaryDir = path.join(resolve(build.binaryDir),
|
|
156
|
+
const binaryDir = path.join(resolve(build.binaryDir), boardTarget.replaceAll('/', '-'), config.__key);
|
|
149
157
|
const versionFile = path.join(sourceDir, 'VERSION');
|
|
150
158
|
const version = formatVersion(await parseAppVersion(versionFile));
|
|
151
159
|
const confs = config.configs
|
|
@@ -156,7 +164,8 @@ async function westOptionsNormalize(board, config, build, cwd, verbose) {
|
|
|
156
164
|
: [];
|
|
157
165
|
return {
|
|
158
166
|
name,
|
|
159
|
-
board,
|
|
167
|
+
board: boardTarget.replaceAll('/', '-'),
|
|
168
|
+
boardTarget,
|
|
160
169
|
config: config.__key,
|
|
161
170
|
cwd,
|
|
162
171
|
version,
|
|
@@ -178,12 +187,12 @@ function westItem(opts) {
|
|
|
178
187
|
};
|
|
179
188
|
}
|
|
180
189
|
function west(args) {
|
|
181
|
-
const { cwd,
|
|
190
|
+
const { cwd, boardTarget, sourceDir, binaryDir, confs, overlays } = args;
|
|
182
191
|
const { item } = westItem(args);
|
|
183
192
|
const expect = path.join(binaryDir, 'zephyr', 'zephyr.bin');
|
|
184
193
|
return of([
|
|
185
194
|
`build`,
|
|
186
|
-
`-b ${
|
|
195
|
+
`-b ${boardTarget}`,
|
|
187
196
|
`-s ${sourceDir}`,
|
|
188
197
|
`-d ${binaryDir}`,
|
|
189
198
|
`--`,
|
|
@@ -347,13 +356,8 @@ function cmake(opts) {
|
|
|
347
356
|
return concat(cmakeConfigure(opts), cmakeBuild(opts), of({ item, complete: true })).pipe(catchError(of));
|
|
348
357
|
}
|
|
349
358
|
function emulateBytePages(board) {
|
|
350
|
-
return (board.startsWith('
|
|
351
|
-
board.startsWith('
|
|
352
|
-
board.startsWith('netwaysp4bt') ||
|
|
353
|
-
board.startsWith('netway4eb') ||
|
|
354
|
-
board.startsWith('netway4ebt') ||
|
|
355
|
-
board.startsWith('netway5pq') ||
|
|
356
|
-
board.startsWith('netway5btq') ||
|
|
359
|
+
return (board.startsWith('same54_xpro') ||
|
|
360
|
+
board.startsWith('netway') ||
|
|
357
361
|
board.startsWith('oa2b'));
|
|
358
362
|
}
|
|
359
363
|
function extraAppConfs(extraConfs, config) {
|
|
@@ -373,10 +377,7 @@ function extraBootConfs(board, extraConfs) {
|
|
|
373
377
|
if (!key)
|
|
374
378
|
throw new Error('missing ALTRONIX_RELEASE_KEY from environment');
|
|
375
379
|
const extraConfsData = emulateBytePages(board)
|
|
376
|
-
? [
|
|
377
|
-
`CONFIG_BOOT_SIGNATURE_KEY_FILE="${key}"`,
|
|
378
|
-
`CONFIG_SOC_FLASH_SAM0_EMULATE_BYTE_PAGES=y`
|
|
379
|
-
]
|
|
380
|
+
? [`CONFIG_BOOT_SIGNATURE_KEY_FILE="${key}"`]
|
|
380
381
|
: [`CONFIG_BOOT_SIGNATURE_KEY_FILE="${key}"`];
|
|
381
382
|
return from(fs.promises.writeFile(extraConfs, extraConfsData.join('\r\n')));
|
|
382
383
|
}
|
|
@@ -462,10 +463,10 @@ export async function build() {
|
|
|
462
463
|
return keys(app.boards)
|
|
463
464
|
.filter(({ __key }) => __key.match(mBoard))
|
|
464
465
|
.flatMap((board) => {
|
|
465
|
-
return keys(board)
|
|
466
|
+
return keys(board.images)
|
|
466
467
|
.filter(({ __key }) => __key.match(mConfig))
|
|
467
468
|
.map((config) => {
|
|
468
|
-
return westOptionsNormalize(board
|
|
469
|
+
return westOptionsNormalize(board, config, app, cwd, verbose);
|
|
469
470
|
});
|
|
470
471
|
});
|
|
471
472
|
});
|
|
@@ -473,7 +474,7 @@ export async function build() {
|
|
|
473
474
|
return keys(app.boards)
|
|
474
475
|
.filter(({ __key }) => __key.match(mBoard))
|
|
475
476
|
.flatMap((board) => {
|
|
476
|
-
return keys(board).map((config) => westOptionsNormalize(board
|
|
477
|
+
return keys(board.images).map((config) => westOptionsNormalize(board, config, app, cwd, verbose));
|
|
477
478
|
});
|
|
478
479
|
});
|
|
479
480
|
const wasm = keys(atx.wasm).map((w) => seedleOptionsNormalize(w, cwd, verbose));
|
package/dist/keys.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export type WithKey<T> = T & {
|
|
2
2
|
__key: string;
|
|
3
3
|
};
|
|
4
|
+
export type FlattenWithKey<Type> = Type extends Array<infer Item> ? Array<WithKey<Item>> : Array<WithKey<Type>>;
|
|
4
5
|
export declare function keys<T>(map: {
|
|
5
6
|
[key: string]: T;
|
|
6
|
-
}):
|
|
7
|
+
}): FlattenWithKey<T>;
|
package/dist/keys.js
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
export function keys(map) {
|
|
2
|
-
|
|
2
|
+
let ret = [];
|
|
3
|
+
Object.keys(map)
|
|
3
4
|
.filter((key) => key !== '__key')
|
|
4
|
-
.
|
|
5
|
+
.forEach((key) => {
|
|
6
|
+
if (Array.isArray(map[key])) {
|
|
7
|
+
map[key].forEach((item) => ret.push({ ...item, __key: key }));
|
|
8
|
+
}
|
|
9
|
+
else {
|
|
10
|
+
ret.push({ ...map[key], __key: key });
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
return ret;
|
|
5
14
|
}
|
package/package.json
CHANGED
package/dist/app.d.ts
DELETED
package/dist/app.js
DELETED
package/dist/cli.d.ts
DELETED
package/dist/cli.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { render } from 'ink';
|
|
4
|
-
import meow from 'meow';
|
|
5
|
-
import App from './app.js';
|
|
6
|
-
const cli = meow(`
|
|
7
|
-
Usage
|
|
8
|
-
$ cli
|
|
9
|
-
|
|
10
|
-
Options
|
|
11
|
-
--name Your name
|
|
12
|
-
|
|
13
|
-
Examples
|
|
14
|
-
$ cli --name=Jane
|
|
15
|
-
Hello, Jane
|
|
16
|
-
`, {
|
|
17
|
-
importMeta: import.meta,
|
|
18
|
-
flags: {
|
|
19
|
-
name: {
|
|
20
|
-
type: 'string',
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
});
|
|
24
|
-
render(React.createElement(App, { name: cli.flags.name }));
|
package/dist/stress.ui.d.ts
DELETED
package/dist/stress.ui.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import React, { useLayoutEffect, useState } from 'react';
|
|
2
|
-
import { Observable, scan } from 'rxjs';
|
|
3
|
-
import { Box, render, Text } from 'ink';
|
|
4
|
-
export default function () {
|
|
5
|
-
return (obs$) => new Observable((subscriber) => {
|
|
6
|
-
const renderer = render(React.createElement(View, { "response$": obs$, onComplete: () => {
|
|
7
|
-
renderer.unmount();
|
|
8
|
-
subscriber.next();
|
|
9
|
-
subscriber.complete();
|
|
10
|
-
} }));
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
function View({ response$, onComplete }) {
|
|
14
|
-
const responses = useResponses(response$, onComplete);
|
|
15
|
-
return (React.createElement(Box, null,
|
|
16
|
-
React.createElement(Text, null, "Response count:"),
|
|
17
|
-
React.createElement(Text, null, responses.length)));
|
|
18
|
-
}
|
|
19
|
-
function useResponses(obs$, onComplete) {
|
|
20
|
-
const [responses, setResponses] = useState([]);
|
|
21
|
-
useLayoutEffect(() => {
|
|
22
|
-
const s = obs$
|
|
23
|
-
.pipe(scan((acc, next) => [...acc, next], responses))
|
|
24
|
-
.subscribe({
|
|
25
|
-
next: (responses) => setResponses(responses),
|
|
26
|
-
complete: onComplete
|
|
27
|
-
});
|
|
28
|
-
return () => s.unsubscribe();
|
|
29
|
-
}, [obs$]);
|
|
30
|
-
return responses;
|
|
31
|
-
}
|