@altronix/cli 0.7.13 → 0.7.14

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 CHANGED
@@ -379,13 +379,11 @@ function extraBootConfs(board, extraConfs) {
379
379
  function copy() {
380
380
  return (obs$) => obs$.pipe(mergeMap((opts) => {
381
381
  const { src, dst } = opts;
382
- return new Observable((subscriber) => {
383
- fs.promises
384
- .copyFile(src, dst)
385
- .then(() => subscriber.next(opts))
386
- .catch(() => subscriber.next({ ...opts, err: dst }))
387
- .finally(() => subscriber.complete());
388
- });
382
+ const promise = fs.promises
383
+ .copyFile(src, dst)
384
+ .then(() => opts)
385
+ .catch(() => ({ ...opts, err: dst }));
386
+ return from(promise);
389
387
  }));
390
388
  }
391
389
  function concatFiles(src, dest) {
@@ -18,10 +18,10 @@ export interface BuildProgress<K extends string = string> {
18
18
  export interface Options {
19
19
  items: BuildItem[];
20
20
  progress$: Observable<BuildProgress>;
21
- onComplete: UseCompleteEffectCallback;
21
+ onComplete: BuildEffectCallback;
22
22
  }
23
23
  export default function ({ items, progress$, onComplete }: Options): React.JSX.Element;
24
- interface UseCompleteEffectCallback<E extends Error = Error> {
24
+ interface BuildEffectCallback<E extends Error = Error> {
25
25
  (e?: E): void;
26
26
  }
27
27
  export {};
package/dist/build.ui.js CHANGED
@@ -21,8 +21,7 @@ export class BuildError extends Error {
21
21
  export default function ({ items, progress$, onComplete }) {
22
22
  const [col, _rows] = useStdoutDimensions();
23
23
  const [width, setWidth] = useState(0);
24
- const progress = useBuildEffect(progress$, items.map(({ item: i }) => i));
25
- useCompleteEffect(progress$, onComplete);
24
+ const progress = useBuildEffect(progress$, items.map(({ item: i }) => i), onComplete);
26
25
  useLayoutEffect(() => {
27
26
  const width = items.map(({ item }) => item).reduce(calculateItemWidth, 0);
28
27
  setWidth(width);
@@ -81,17 +80,13 @@ function progressReducer(acc, next) {
81
80
  : progressInc(acc[next.item]);
82
81
  return acc;
83
82
  }
84
- function useCompleteEffect(obs$, cb) {
85
- useLayoutEffect(() => {
86
- const s = obs$.subscribe({ complete: cb, error: cb });
87
- return s.unsubscribe();
88
- });
89
- }
90
- function useBuildEffect(obs$, items) {
83
+ function useBuildEffect(obs$, items, cb) {
91
84
  const [progress, setProgress] = useState(initProgress(items));
92
85
  useLayoutEffect(() => {
93
86
  const s = obs$.pipe(scan(progressReducer, progress)).subscribe({
94
- next: (progress) => setProgress({ ...progress })
87
+ next: (progress) => setProgress({ ...progress }),
88
+ complete: cb,
89
+ error: cb
95
90
  });
96
91
  return () => s.unsubscribe();
97
92
  }, [obs$]);
package/dist/index.js CHANGED
@@ -7,45 +7,38 @@ import { build } from './build.js';
7
7
  import { fileURLToPath } from 'url';
8
8
  // https://stackoverflow.com/questions/8817423/why-is-dirname-not-defined-in-node-repl
9
9
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
10
- (async function main() {
11
- // Parse package.json to get version
12
- const pkg = path.resolve(__dirname, '..', 'package.json');
13
- const ver = JSON.parse(await fs.promises.readFile(pkg, 'ascii')).version;
14
- // const cwd = path.resolve('./');
10
+ // Parse package.json to get version
11
+ const pkg = path.resolve(__dirname, '..', 'package.json');
12
+ const ver = JSON.parse(fs.readFileSync(pkg, 'ascii')).version;
13
+ // const cwd = path.resolve('./');
14
+ program
15
+ .name('atx')
16
+ .description('build atx zdk projects')
17
+ .version(ver)
18
+ .option('-VV, --verbose', 'extra logging');
19
+ // Scan command
20
+ /*
21
+ const ignore = 'node_modules;target;build;.git';
15
22
  program
16
- .name('atx')
17
- .description('build atx zdk projects')
18
- .version(ver)
19
- .option('-VV, --verbose', 'extra logging');
20
- // Scan command
21
- /*
22
- const ignore = 'node_modules;target;build;.git';
23
- program
24
- .command('scan')
25
- .description('scan for *.cddl files')
26
- .option('-p, --path <PATH>', 'root directory to start scan', cwd)
27
- .option('-m, --matches <REGEX>', 'match expression', '.*cddl$')
28
- .option('-i, --ignores <REGEX>', 'ignore directories', ignore)
29
- .action(seedle.scan);
30
- */
31
- // Build command
32
- // TODO - detect if west is available and fail early
33
- program
34
- .command('build')
35
- .description('build atx zdk application')
36
- .option('-c, --config <CONFIG>', 'workspace config file')
37
- .option('-C, --concurrent <NUMBER>', 'how many builds to run concurrently')
38
- .option('-A, --application', 'build applications')
39
- .option('-B, --bootloader', 'build bootloaders')
40
- .option('-W, --wasm', 'build wasm')
41
- .option('-y, --yes', 'answer yes automatically')
42
- .action(build);
43
- // Load plugins
44
- // (await plugins()).forEach(({ plugin: _, path: __, description: ___ }) => {});
45
- try {
46
- await program.parseAsync();
47
- }
48
- catch (e) {
49
- console.error(e);
50
- }
51
- })();
23
+ .command('scan')
24
+ .description('scan for *.cddl files')
25
+ .option('-p, --path <PATH>', 'root directory to start scan', cwd)
26
+ .option('-m, --matches <REGEX>', 'match expression', '.*cddl$')
27
+ .option('-i, --ignores <REGEX>', 'ignore directories', ignore)
28
+ .action(seedle.scan);
29
+ */
30
+ // Build command
31
+ // TODO - detect if west is available and fail early
32
+ program
33
+ .command('build')
34
+ .description('build atx zdk application')
35
+ .option('-c, --config <CONFIG>', 'workspace config file')
36
+ .option('-C, --concurrent <NUMBER>', 'how many builds to run concurrently')
37
+ .option('-A, --application', 'build applications')
38
+ .option('-B, --bootloader', 'build bootloaders')
39
+ .option('-W, --wasm', 'build wasm')
40
+ .option('-y, --yes', 'answer yes automatically')
41
+ .action(build);
42
+ // Load plugins
43
+ // (await plugins()).forEach(({ plugin: _, path: __, description: ___ }) => {});
44
+ program.parseAsync().catch((e) => console.error(e));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@altronix/cli",
3
- "version": "0.7.13",
3
+ "version": "0.7.14",
4
4
  "license": "MIT",
5
5
  "bin": {
6
6
  "atx": "./dist/index.js"