@fnndsc/chili 3.4.0 → 3.6.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.
Files changed (36) hide show
  1. package/dist/chefs/chefs.js +12 -11
  2. package/dist/commands/fs/download.js +4 -3
  3. package/dist/commands/fs/upload.js +4 -3
  4. package/dist/commands/man/doc.js +3 -2
  5. package/dist/commands/plugins/add.js +35 -34
  6. package/dist/config/colorConfig.js +2 -1
  7. package/dist/connect/connectHandler.js +7 -6
  8. package/dist/context/contextCommand.js +3 -2
  9. package/dist/controllers/fileController.js +4 -3
  10. package/dist/controllers/pluginController.js +2 -1
  11. package/dist/feeds/feedHandler.js +19 -18
  12. package/dist/filesystem/fileGroupHandler.d.ts +18 -5
  13. package/dist/filesystem/fileGroupHandler.js +68 -46
  14. package/dist/filesystem/filesystemHandler.js +13 -11
  15. package/dist/filesystem/inodeCommand.js +3 -2
  16. package/dist/handlers/baseGroupHandler.d.ts +8 -2
  17. package/dist/handlers/baseGroupHandler.js +30 -18
  18. package/dist/index.js +3 -2
  19. package/dist/lfs/lfs.js +6 -4
  20. package/dist/man/man.js +4 -3
  21. package/dist/man/renderer.js +3 -2
  22. package/dist/pacs/pacsQueryHandler.js +14 -13
  23. package/dist/pacs/pacsRetrieveHandler.js +13 -12
  24. package/dist/path/pathCommand.js +23 -22
  25. package/dist/plugins/pluginGroupHandler.d.ts +17 -6
  26. package/dist/plugins/pluginGroupHandler.js +58 -37
  27. package/dist/plugins/pluginHandler.js +23 -22
  28. package/dist/run.d.ts +22 -0
  29. package/dist/run.js +42 -46
  30. package/dist/screen/output.d.ts +88 -0
  31. package/dist/screen/output.js +95 -0
  32. package/dist/screen/screen.js +9 -8
  33. package/dist/utils/admin_prompt.js +10 -9
  34. package/dist/utils/docker.js +10 -9
  35. package/dist/views/pluginParameters.js +2 -1
  36. package/package.json +1 -1
@@ -5,6 +5,7 @@
5
5
  */
6
6
  import { table, getBorderCharacters } from "table";
7
7
  import chalk from "chalk";
8
+ import { chiliLog, chiliErrLog } from "./output.js";
8
9
  /**
9
10
  * Processes raw table input data and headers into a standardized format.
10
11
  *
@@ -60,7 +61,7 @@ function tableContent_pack(tableData, selectedFields) {
60
61
  body = tableData.map((row) => headers.map((field) => (row[field] !== undefined ? row[field] : "")));
61
62
  }
62
63
  else {
63
- console.error("Invalid table data");
64
+ chiliErrLog("Invalid table data");
64
65
  return null;
65
66
  }
66
67
  return { headers, body };
@@ -188,10 +189,10 @@ export function table_display(tableData, headers, options = {}) {
188
189
  },
189
190
  };
190
191
  const result = screen.table_output(processedTableData, tableOptions);
191
- console.log(result);
192
+ chiliLog(result);
192
193
  if (options.pagination && options.pagination.shown < options.pagination.total) {
193
194
  const { shown, total } = options.pagination;
194
- console.log(chalk.dim(` ↓ showing ${shown} of ${total} · --all to fetch all · --limit <n> for page size`));
195
+ chiliLog(chalk.dim(` ↓ showing ${shown} of ${total} · --all to fetch all · --limit <n> for page size`));
195
196
  }
196
197
  return tableObj;
197
198
  }
@@ -200,16 +201,16 @@ export function table_display(tableData, headers, options = {}) {
200
201
  */
201
202
  export class Screen {
202
203
  log(...args) {
203
- console.log(...args);
204
+ chiliLog(...args);
204
205
  }
205
206
  error(...args) {
206
- console.error(chalk.red(...args));
207
+ chiliErrLog(chalk.red(...args));
207
208
  }
208
209
  warn(...args) {
209
- console.warn(chalk.yellow(...args));
210
+ chiliErrLog(chalk.yellow(...args));
210
211
  }
211
212
  info(...args) {
212
- console.info(chalk.blue(...args));
213
+ chiliLog(chalk.blue(...args));
213
214
  }
214
215
  /**
215
216
  * Generates a formatted table output string.
@@ -242,7 +243,7 @@ export class Screen {
242
243
  : output;
243
244
  }
244
245
  catch (error) {
245
- console.error("Error in table_output method:", error);
246
+ chiliErrLog("Error in table_output method:", error);
246
247
  return "Error generating table";
247
248
  }
248
249
  }
@@ -9,6 +9,7 @@
9
9
  */
10
10
  import * as readline from 'readline';
11
11
  import { Writable } from 'stream';
12
+ import { chiliLog, chiliWrite } from "../screen/output.js";
12
13
  /** Injected by the host (chell) so prompts route through the active readline. */
13
14
  let _askFn = null;
14
15
  let _askHiddenFn = null;
@@ -35,24 +36,24 @@ export function adminPrompt_register(askFn, askHiddenFn) {
35
36
  */
36
37
  export async function adminCredentials_prompt(attempt = 1, maxAttempts = 3) {
37
38
  if (attempt === 1) {
38
- console.log('\nAdmin credentials required to register plugins.');
39
- console.log('You can provide these via --adminUser and --adminPassword flags.');
40
- console.log('');
39
+ chiliLog('\nAdmin credentials required to register plugins.');
40
+ chiliLog('You can provide these via --adminUser and --adminPassword flags.');
41
+ chiliLog('');
41
42
  }
42
43
  else {
43
- console.log(`\nAuthentication failed. Attempt ${attempt} of ${maxAttempts}.`);
44
- console.log('');
44
+ chiliLog(`\nAuthentication failed. Attempt ${attempt} of ${maxAttempts}.`);
45
+ chiliLog('');
45
46
  }
46
47
  const askFn = _askFn ?? ask_fallback;
47
48
  const askHiddenFn = _askHiddenFn ?? askHidden_fallback;
48
49
  const username = await askFn('Username: ');
49
50
  if (!username) {
50
- console.log('Username cannot be empty.');
51
+ chiliLog('Username cannot be empty.');
51
52
  return null;
52
53
  }
53
54
  const password = await askHiddenFn('Password: ');
54
55
  if (!password) {
55
- console.log('Password cannot be empty.');
56
+ chiliLog('Password cannot be empty.');
56
57
  return null;
57
58
  }
58
59
  return { username, password };
@@ -82,9 +83,9 @@ function askHidden_fallback(prompt) {
82
83
  output: muted,
83
84
  terminal: true,
84
85
  });
85
- process.stdout.write(prompt);
86
+ chiliWrite(prompt);
86
87
  rl.question('', (answer) => {
87
- process.stdout.write('\n');
88
+ chiliWrite('\n');
88
89
  rl.close();
89
90
  resolve(answer.trim());
90
91
  });
@@ -7,6 +7,7 @@
7
7
  * @module
8
8
  */
9
9
  import { exec } from "child_process";
10
+ import { chiliErrLog, chiliLog } from "../screen/output.js";
10
11
  /**
11
12
  * Promisified version of child_process.exec.
12
13
  * @param command - The command string to execute.
@@ -33,13 +34,13 @@ export async function shellCommand_run(command) {
33
34
  try {
34
35
  const { stdout, stderr } = await childProcess_exec(command);
35
36
  if (stderr) {
36
- // console.warn(`Command stderr: ${stderr.trim()}`); // Log stderr as warning, not necessarily an error
37
+ // chiliErrLog(`Command stderr: ${stderr.trim()}`); // Log stderr as warning, not necessarily an error
37
38
  }
38
39
  return stdout.trim();
39
40
  }
40
41
  catch (error) {
41
- // console.error(`Command failed: ${command}`);
42
- // console.error(`Error: ${error.message}`);
42
+ // chiliErrLog(`Command failed: ${command}`);
43
+ // chiliErrLog(`Error: ${error.message}`);
43
44
  return null;
44
45
  }
45
46
  }
@@ -77,8 +78,8 @@ export async function docker_checkAvailability() {
77
78
  if (result === "OK") {
78
79
  return true;
79
80
  }
80
- console.error("Error: Docker is not installed or not running.");
81
- console.error("Please ensure Docker is properly set up on your system to add plugins.");
81
+ chiliErrLog("Error: Docker is not installed or not running.");
82
+ chiliErrLog("Please ensure Docker is properly set up on your system to add plugins.");
82
83
  return false;
83
84
  }
84
85
  /**
@@ -112,17 +113,17 @@ export async function docker_imageExistsLocally(image) {
112
113
  export async function docker_pullImage(image, quiet = true) {
113
114
  const existsLocally = await docker_imageExistsLocally(image);
114
115
  if (existsLocally) {
115
- console.log(`Docker image ${image} already exists locally.`);
116
+ chiliLog(`Docker image ${image} already exists locally.`);
116
117
  return true;
117
118
  }
118
- console.log(`Pulling Docker image: ${image}...`);
119
+ chiliLog(`Pulling Docker image: ${image}...`);
119
120
  const quietFlag = quiet ? '--quiet' : '';
120
121
  const result = await shellCommand_run(`docker pull ${quietFlag} ${image}`);
121
122
  if (result !== null) {
122
- console.log(`Successfully pulled ${image}`);
123
+ chiliLog(`Successfully pulled ${image}`);
123
124
  return true;
124
125
  }
125
- console.error(`Failed to pull Docker image: ${image}`);
126
+ chiliErrLog(`Failed to pull Docker image: ${image}`);
126
127
  return false;
127
128
  }
128
129
  /**
@@ -4,6 +4,7 @@
4
4
  * @module
5
5
  */
6
6
  import chalk from 'chalk';
7
+ import { chiliLog } from "../screen/output.js";
7
8
  /**
8
9
  * Renders plugin parameters in a "man page" style format.
9
10
  *
@@ -15,7 +16,7 @@ import chalk from 'chalk';
15
16
  * @param data - The filtered resource data containing plugin parameters.
16
17
  */
17
18
  export function pluginParameters_renderMan(data) {
18
- console.log(pluginParameters_manRender(data));
19
+ chiliLog(pluginParameters_manRender(data));
19
20
  }
20
21
  /**
21
22
  * Builds the "man page" style rendering of plugin parameters as a string.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fnndsc/chili",
3
- "version": "3.4.0",
3
+ "version": "3.6.0",
4
4
  "description": "ChILI handles Intelligent Line Interactions: A CLI and library for ChRIS, acting as the controller layer for business logic and user presentation.",
5
5
  "repository": {
6
6
  "type": "git",