geomcli 0.5.16 → 0.5.18
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/index.d.ts +3 -0
- package/dist/index.js +137 -59
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,9 @@ import { tGeomFunc, tParamVal, EFormat, tAllPageDef, tPackage } from 'geometrix'
|
|
|
2
2
|
|
|
3
3
|
declare function geom_write(iPartName: string, fgeom: tGeomFunc, simTime: number, iParam: tParamVal, iFormat: EFormat, iFace?: string, iDir?: string, iFname?: string): Promise<string>;
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Docs for `geom_cli` function.
|
|
7
|
+
*/
|
|
5
8
|
declare function geom_cli(iArgs: string[], dList: tAllPageDef, appPackage: tPackage, outDir?: string): Promise<void>;
|
|
6
9
|
|
|
7
10
|
export { geom_cli, geom_write };
|
package/dist/index.js
CHANGED
|
@@ -114,7 +114,15 @@ async function geom_write(iPartName, fgeom, simTime, iParam, iFormat, iFace = ""
|
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
// src/geom_cli.ts
|
|
117
|
-
import {
|
|
117
|
+
import {
|
|
118
|
+
PType,
|
|
119
|
+
EFormat as EFormat2,
|
|
120
|
+
designParam,
|
|
121
|
+
prefixLog,
|
|
122
|
+
paramListToVal,
|
|
123
|
+
version_details,
|
|
124
|
+
checkImpPages
|
|
125
|
+
} from "geometrix";
|
|
118
126
|
import yargs from "yargs";
|
|
119
127
|
import { hideBin } from "yargs/helpers";
|
|
120
128
|
function print_version_details(appPackage) {
|
|
@@ -298,24 +306,53 @@ function decompose_outopt(outopt) {
|
|
|
298
306
|
const eFormat = { eWrite: rWrite, eFormat: rFormat, eFace: rFace, eSubdesign: rSubD };
|
|
299
307
|
return eFormat;
|
|
300
308
|
}
|
|
301
|
-
function
|
|
309
|
+
async function addDynamicPath(dList, iPath) {
|
|
310
|
+
const rList = dList;
|
|
311
|
+
if (iPath !== "") {
|
|
312
|
+
if (!iPath.endsWith(".js")) {
|
|
313
|
+
console.log(`err729: ${iPath} has an unexpected file extension`);
|
|
314
|
+
process.exit(1);
|
|
315
|
+
}
|
|
316
|
+
try {
|
|
317
|
+
console.log(`addDynamicPath: ${iPath}`);
|
|
318
|
+
const pages = await import(iPath);
|
|
319
|
+
const [cErr, cMsg] = checkImpPages(pages);
|
|
320
|
+
console.log(cMsg);
|
|
321
|
+
if (cErr) {
|
|
322
|
+
throw "err337: unexpected export type";
|
|
323
|
+
}
|
|
324
|
+
const pagK = Object.keys(pages);
|
|
325
|
+
for (const pagN of pagK) {
|
|
326
|
+
rList[`import/${pagN}`] = pages[pagN];
|
|
327
|
+
}
|
|
328
|
+
} catch (err) {
|
|
329
|
+
console.log(`err229: Error by importing ${iPath}`);
|
|
330
|
+
console.log(err);
|
|
331
|
+
process.exit(1);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
return rList;
|
|
335
|
+
}
|
|
336
|
+
async function list_designs(dList, iPath, detail) {
|
|
302
337
|
let rlog = "List of available designs:\n";
|
|
303
|
-
|
|
338
|
+
const dList2 = await addDynamicPath(dList, iPath);
|
|
339
|
+
for (const [idx, dname] of get_design_array(dList2).entries()) {
|
|
304
340
|
rlog += `${(idx + 1).toString().padStart(4, " ")} : ${dname}
|
|
305
341
|
`;
|
|
306
342
|
if (detail) {
|
|
307
|
-
rlog += ` ${
|
|
343
|
+
rlog += ` ${dList2[dname].pDef.partName}
|
|
308
344
|
`;
|
|
309
|
-
rlog += ` ${
|
|
345
|
+
rlog += ` ${dList2[dname].pTitle}
|
|
310
346
|
`;
|
|
311
|
-
rlog += ` ${
|
|
347
|
+
rlog += ` ${dList2[dname].pDescription}
|
|
312
348
|
`;
|
|
313
349
|
}
|
|
314
350
|
}
|
|
315
351
|
console.log(rlog);
|
|
316
352
|
}
|
|
317
|
-
function list_parameters(dList, selD, paramPath, modif) {
|
|
318
|
-
const
|
|
353
|
+
async function list_parameters(dList, iPath, selD, paramPath, modif) {
|
|
354
|
+
const dList2 = await addDynamicPath(dList, iPath);
|
|
355
|
+
const theD = selectDesign(dList2, selD);
|
|
319
356
|
let rlog = `List of parameters of the design ${selD} (${theD.pDef.partName}):
|
|
320
357
|
`;
|
|
321
358
|
const dParam = designParam(theD.pDef);
|
|
@@ -360,9 +397,10 @@ function list_parameters(dList, selD, paramPath, modif) {
|
|
|
360
397
|
}
|
|
361
398
|
console.log(rlog);
|
|
362
399
|
}
|
|
363
|
-
function list_figures(dList, selD, paramPath, modif) {
|
|
364
|
-
const
|
|
365
|
-
const
|
|
400
|
+
async function list_figures(dList, iPath, selD, paramPath, modif) {
|
|
401
|
+
const dList2 = await addDynamicPath(dList, iPath);
|
|
402
|
+
const dPartName = selectDesignN(dList2, selD);
|
|
403
|
+
const figN = get_figure_array(dList2, selD, paramPath, modif);
|
|
366
404
|
let rlog = `List of figures of the design ${selD} (${dPartName}):
|
|
367
405
|
`;
|
|
368
406
|
for (const [idx, figNi] of figN.entries()) {
|
|
@@ -372,9 +410,10 @@ function list_figures(dList, selD, paramPath, modif) {
|
|
|
372
410
|
}
|
|
373
411
|
console.log(rlog);
|
|
374
412
|
}
|
|
375
|
-
function list_subdesigns(dList, selD, paramPath, modif) {
|
|
376
|
-
const
|
|
377
|
-
const
|
|
413
|
+
async function list_subdesigns(dList, iPath, selD, paramPath, modif) {
|
|
414
|
+
const dList2 = await addDynamicPath(dList, iPath);
|
|
415
|
+
const dPartName = selectDesignN(dList2, selD);
|
|
416
|
+
const subdA = get_subdesign_array(dList2, selD, paramPath, modif);
|
|
378
417
|
const subdN = Object.keys(subdA);
|
|
379
418
|
let rlog = `List of sub-designs of the design ${selD} (${dPartName}):
|
|
380
419
|
`;
|
|
@@ -390,8 +429,9 @@ function list_subdesigns(dList, selD, paramPath, modif) {
|
|
|
390
429
|
}
|
|
391
430
|
console.log(rlog);
|
|
392
431
|
}
|
|
393
|
-
function list_subd_parameters(dList, selD, subdN, paramPath, modif) {
|
|
394
|
-
const
|
|
432
|
+
async function list_subd_parameters(dList, iPath, selD, subdN, paramPath, modif) {
|
|
433
|
+
const dList2 = await addDynamicPath(dList, iPath);
|
|
434
|
+
const subdParam = get_subd(dList2, selD, subdN, paramPath, modif, true).dparam;
|
|
395
435
|
const nameLength = 20;
|
|
396
436
|
const nameLabel = "name".padEnd(nameLength, " ");
|
|
397
437
|
let rlog = ` # : ${nameLabel} value init changed
|
|
@@ -407,11 +447,16 @@ function list_subd_parameters(dList, selD, subdN, paramPath, modif) {
|
|
|
407
447
|
}
|
|
408
448
|
console.log(rlog);
|
|
409
449
|
}
|
|
410
|
-
function
|
|
411
|
-
const
|
|
450
|
+
async function computeGeom2(dList, iPath, selD, paramPath, modif, printLog) {
|
|
451
|
+
const dList2 = await addDynamicPath(dList, iPath);
|
|
452
|
+
return computeGeom(dList2, selD, paramPath, modif, printLog);
|
|
453
|
+
}
|
|
454
|
+
async function list_outopt(dList, iPath, selD, paramPath, modif) {
|
|
455
|
+
const dList2 = await addDynamicPath(dList, iPath);
|
|
456
|
+
const dPartName = selectDesignN(dList2, selD);
|
|
412
457
|
let rlog = `List of outputs of the design ${selD} (${dPartName}):
|
|
413
458
|
`;
|
|
414
|
-
const outOpt = get_outopt_array(
|
|
459
|
+
const outOpt = get_outopt_array(dList2, selD, paramPath, modif);
|
|
415
460
|
for (const [idx, oneOpt] of outOpt.entries()) {
|
|
416
461
|
const idx2 = (idx + 1).toString().padStart(4, " ");
|
|
417
462
|
rlog += `${idx2} : ${oneOpt}
|
|
@@ -421,13 +466,18 @@ function list_outopt(dList, selD, paramPath, modif) {
|
|
|
421
466
|
}
|
|
422
467
|
var cmd_write = false;
|
|
423
468
|
async function geom_cli(iArgs, dList, appPackage, outDir = "output") {
|
|
424
|
-
const argv = yargs(hideBin(iArgs)).scriptName("geom_cli").version(appPackage.version).usage("Usage: $0 <global-options> command <command-argument>").example([
|
|
469
|
+
const argv = await yargs(hideBin(iArgs)).scriptName("geom_cli").version(appPackage.version).usage("Usage: $0 <global-options> command <command-argument>").example([
|
|
425
470
|
["$0 list-designs", "list the available designs"],
|
|
426
471
|
["$0 list-designs-detailed", "list the available designs with detailed information"],
|
|
427
472
|
["$0 -d heliostat/rake compute-log", "compute and print the log"],
|
|
428
473
|
["$0 -d heliostat/swing list-outopt", "list possible output-format-options"],
|
|
429
474
|
["$0 -d heliostat/rod write zip_all", "write a zip file"]
|
|
430
|
-
]).option("
|
|
475
|
+
]).option("import", {
|
|
476
|
+
alias: "i",
|
|
477
|
+
type: "string",
|
|
478
|
+
description: "path to a javascript-geometrix-design-library",
|
|
479
|
+
default: ""
|
|
480
|
+
}).option("design", {
|
|
431
481
|
alias: "d",
|
|
432
482
|
type: "string",
|
|
433
483
|
description: "design to be used by the command",
|
|
@@ -455,59 +505,85 @@ async function geom_cli(iArgs, dList, appPackage, outDir = "output") {
|
|
|
455
505
|
default: ""
|
|
456
506
|
}).command("versions", "print details about the app version and its dependencies", {}, () => {
|
|
457
507
|
print_version_details(appPackage);
|
|
458
|
-
}).command(["list-designs", "list"], "list the available designs", {}, () => {
|
|
459
|
-
list_designs(dList, false);
|
|
460
|
-
}).command(
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
argv2.
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
508
|
+
}).command(["list-designs", "list"], "list the available designs", {}, async (argv2) => {
|
|
509
|
+
await list_designs(dList, argv2.import, false);
|
|
510
|
+
}).command(
|
|
511
|
+
"list-designs-detailed",
|
|
512
|
+
"list the available designs with details",
|
|
513
|
+
{},
|
|
514
|
+
async (argv2) => {
|
|
515
|
+
await list_designs(dList, argv2.import, true);
|
|
516
|
+
}
|
|
517
|
+
).command(
|
|
518
|
+
"list-parameters",
|
|
519
|
+
"list the parameters of the selected design",
|
|
520
|
+
{},
|
|
521
|
+
async (argv2) => {
|
|
522
|
+
await list_parameters(
|
|
523
|
+
dList,
|
|
524
|
+
argv2.import,
|
|
525
|
+
argv2.design,
|
|
526
|
+
argv2.param,
|
|
527
|
+
argv2.modif
|
|
528
|
+
);
|
|
529
|
+
}
|
|
530
|
+
).command("list-figures", "list the figures of the selected design", {}, async (argv2) => {
|
|
531
|
+
await list_figures(
|
|
478
532
|
dList,
|
|
533
|
+
argv2.import,
|
|
479
534
|
argv2.design,
|
|
480
535
|
argv2.param,
|
|
481
536
|
argv2.modif
|
|
482
537
|
);
|
|
483
538
|
}).command(
|
|
539
|
+
"list-subdesigns",
|
|
540
|
+
"list the subdesigns of the selected design",
|
|
541
|
+
{},
|
|
542
|
+
async (argv2) => {
|
|
543
|
+
await list_subdesigns(
|
|
544
|
+
dList,
|
|
545
|
+
argv2.import,
|
|
546
|
+
argv2.design,
|
|
547
|
+
argv2.param,
|
|
548
|
+
argv2.modif
|
|
549
|
+
);
|
|
550
|
+
}
|
|
551
|
+
).command(
|
|
484
552
|
"list-subd-parameters <subdN>",
|
|
485
553
|
"list the parameters of subdesigns",
|
|
486
554
|
{},
|
|
487
|
-
(argv2) => {
|
|
488
|
-
list_subd_parameters(
|
|
555
|
+
async (argv2) => {
|
|
556
|
+
await list_subd_parameters(
|
|
489
557
|
dList,
|
|
558
|
+
argv2.import,
|
|
490
559
|
argv2.design,
|
|
491
560
|
argv2.subdN,
|
|
492
561
|
argv2.param,
|
|
493
562
|
argv2.modif
|
|
494
563
|
);
|
|
495
564
|
}
|
|
496
|
-
).command(
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
565
|
+
).command(
|
|
566
|
+
"compute-log",
|
|
567
|
+
"Compute and print the log without writing file",
|
|
568
|
+
{},
|
|
569
|
+
async (argv2) => {
|
|
570
|
+
await computeGeom2(
|
|
571
|
+
dList,
|
|
572
|
+
argv2.import,
|
|
573
|
+
argv2.design,
|
|
574
|
+
argv2.param,
|
|
575
|
+
argv2.modif,
|
|
576
|
+
true
|
|
577
|
+
);
|
|
578
|
+
}
|
|
579
|
+
).command(
|
|
505
580
|
"list-outopt",
|
|
506
581
|
"list the possible output format options of the selected design",
|
|
507
582
|
{},
|
|
508
|
-
(argv2) => {
|
|
509
|
-
list_outopt(
|
|
583
|
+
async (argv2) => {
|
|
584
|
+
await list_outopt(
|
|
510
585
|
dList,
|
|
586
|
+
argv2.import,
|
|
511
587
|
argv2.design,
|
|
512
588
|
argv2.param,
|
|
513
589
|
argv2.modif
|
|
@@ -515,19 +591,21 @@ async function geom_cli(iArgs, dList, appPackage, outDir = "output") {
|
|
|
515
591
|
}
|
|
516
592
|
).command("write <outopt>", "write the output format file", {}, () => {
|
|
517
593
|
cmd_write = true;
|
|
518
|
-
}).demandCommand(1).help().strict().
|
|
594
|
+
}).demandCommand(1).help().strict().parseAsync();
|
|
519
595
|
if (cmd_write) {
|
|
520
596
|
const iOutDir = argv.outDir;
|
|
521
597
|
if (iOutDir === "") {
|
|
522
598
|
console.log("err638: option 'outDir' is set to empty string. Nothing written!");
|
|
523
599
|
process.exit(1);
|
|
524
600
|
}
|
|
601
|
+
const iPath = argv.import;
|
|
602
|
+
const dList2 = await addDynamicPath(dList, iPath);
|
|
525
603
|
const selD = argv.design;
|
|
526
604
|
const outopt = argv.outopt;
|
|
527
605
|
const paramPath = argv.param;
|
|
528
606
|
const paramModif = argv.modif;
|
|
529
|
-
const theD = selectDesign(
|
|
530
|
-
const outOpt = get_outopt_array(
|
|
607
|
+
const theD = selectDesign(dList2, selD);
|
|
608
|
+
const outOpt = get_outopt_array(dList2, selD, paramPath, paramModif);
|
|
531
609
|
if (!outOpt.includes(outopt)) {
|
|
532
610
|
console.log(`err639: outopt ${outopt} is not a valid option`);
|
|
533
611
|
process.exit(1);
|
|
@@ -543,7 +621,7 @@ async function geom_cli(iArgs, dList, appPackage, outDir = "output") {
|
|
|
543
621
|
console.log(emsg);
|
|
544
622
|
process.exit(1);
|
|
545
623
|
}
|
|
546
|
-
computeGeom(
|
|
624
|
+
computeGeom(dList2, selD, paramPath, paramModif, true);
|
|
547
625
|
try {
|
|
548
626
|
if (oOpt.eWrite === 0 /* eEGOPARAMS */) {
|
|
549
627
|
rlog += writeParams(
|
|
@@ -553,7 +631,7 @@ async function geom_cli(iArgs, dList, appPackage, outDir = "output") {
|
|
|
553
631
|
argv.outFileName
|
|
554
632
|
);
|
|
555
633
|
} else if (oOpt.eWrite === 1 /* eSUBDPARAMS */) {
|
|
556
|
-
const subD = get_subd(
|
|
634
|
+
const subD = get_subd(dList2, selD, oOpt.eSubdesign, paramPath, paramModif, false);
|
|
557
635
|
rlog += writeParams(
|
|
558
636
|
subD.partName,
|
|
559
637
|
paramListToVal(subD.dparam),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "geomcli",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.18",
|
|
4
4
|
"description": "the nodejs companion library of geometrix",
|
|
5
5
|
"private": false,
|
|
6
6
|
"repository": {
|
|
@@ -41,21 +41,21 @@
|
|
|
41
41
|
"clean": "shx rm -fr build dist node_modules"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"geometrix": "^0.5.
|
|
44
|
+
"geometrix": "^0.5.14",
|
|
45
45
|
"yargs": "^17.7.2"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@types/yargs": "^17.0.32",
|
|
49
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
50
|
-
"@typescript-eslint/parser": "^6.
|
|
49
|
+
"@typescript-eslint/eslint-plugin": "^6.20.0",
|
|
50
|
+
"@typescript-eslint/parser": "^6.20.0",
|
|
51
51
|
"eslint": "^8.56.0",
|
|
52
52
|
"eslint-config-prettier": "^9.1.0",
|
|
53
53
|
"npm-run-all": "^4.1.5",
|
|
54
|
-
"prettier": "^3.
|
|
54
|
+
"prettier": "^3.2.5",
|
|
55
55
|
"shx": "^0.3.4",
|
|
56
56
|
"tsup": "^8.0.1",
|
|
57
57
|
"typescript": "^5.3.3",
|
|
58
|
-
"vitest": "^1.
|
|
58
|
+
"vitest": "^1.2.2"
|
|
59
59
|
},
|
|
60
60
|
"exports": {
|
|
61
61
|
".": {
|