@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.
- package/dist/chefs/chefs.js +12 -11
- package/dist/commands/fs/download.js +4 -3
- package/dist/commands/fs/upload.js +4 -3
- package/dist/commands/man/doc.js +3 -2
- package/dist/commands/plugins/add.js +35 -34
- package/dist/config/colorConfig.js +2 -1
- package/dist/connect/connectHandler.js +7 -6
- package/dist/context/contextCommand.js +3 -2
- package/dist/controllers/fileController.js +4 -3
- package/dist/controllers/pluginController.js +2 -1
- package/dist/feeds/feedHandler.js +19 -18
- package/dist/filesystem/fileGroupHandler.d.ts +18 -5
- package/dist/filesystem/fileGroupHandler.js +68 -46
- package/dist/filesystem/filesystemHandler.js +13 -11
- package/dist/filesystem/inodeCommand.js +3 -2
- package/dist/handlers/baseGroupHandler.d.ts +8 -2
- package/dist/handlers/baseGroupHandler.js +30 -18
- package/dist/index.js +3 -2
- package/dist/lfs/lfs.js +6 -4
- package/dist/man/man.js +4 -3
- package/dist/man/renderer.js +3 -2
- package/dist/pacs/pacsQueryHandler.js +14 -13
- package/dist/pacs/pacsRetrieveHandler.js +13 -12
- package/dist/path/pathCommand.js +23 -22
- package/dist/plugins/pluginGroupHandler.d.ts +17 -6
- package/dist/plugins/pluginGroupHandler.js +58 -37
- package/dist/plugins/pluginHandler.js +23 -22
- package/dist/run.d.ts +22 -0
- package/dist/run.js +42 -46
- package/dist/screen/output.d.ts +88 -0
- package/dist/screen/output.js +95 -0
- package/dist/screen/screen.js +9 -8
- package/dist/utils/admin_prompt.js +10 -9
- package/dist/utils/docker.js +10 -9
- package/dist/views/pluginParameters.js +2 -1
- package/package.json +1 -1
package/dist/screen/screen.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
192
|
+
chiliLog(result);
|
|
192
193
|
if (options.pagination && options.pagination.shown < options.pagination.total) {
|
|
193
194
|
const { shown, total } = options.pagination;
|
|
194
|
-
|
|
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
|
-
|
|
204
|
+
chiliLog(...args);
|
|
204
205
|
}
|
|
205
206
|
error(...args) {
|
|
206
|
-
|
|
207
|
+
chiliErrLog(chalk.red(...args));
|
|
207
208
|
}
|
|
208
209
|
warn(...args) {
|
|
209
|
-
|
|
210
|
+
chiliErrLog(chalk.yellow(...args));
|
|
210
211
|
}
|
|
211
212
|
info(...args) {
|
|
212
|
-
|
|
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
|
-
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
-
|
|
44
|
-
|
|
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
|
-
|
|
51
|
+
chiliLog('Username cannot be empty.');
|
|
51
52
|
return null;
|
|
52
53
|
}
|
|
53
54
|
const password = await askHiddenFn('Password: ');
|
|
54
55
|
if (!password) {
|
|
55
|
-
|
|
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
|
-
|
|
86
|
+
chiliWrite(prompt);
|
|
86
87
|
rl.question('', (answer) => {
|
|
87
|
-
|
|
88
|
+
chiliWrite('\n');
|
|
88
89
|
rl.close();
|
|
89
90
|
resolve(answer.trim());
|
|
90
91
|
});
|
package/dist/utils/docker.js
CHANGED
|
@@ -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
|
-
//
|
|
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
|
-
//
|
|
42
|
-
//
|
|
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
|
-
|
|
81
|
-
|
|
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
|
-
|
|
116
|
+
chiliLog(`Docker image ${image} already exists locally.`);
|
|
116
117
|
return true;
|
|
117
118
|
}
|
|
118
|
-
|
|
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
|
-
|
|
123
|
+
chiliLog(`Successfully pulled ${image}`);
|
|
123
124
|
return true;
|
|
124
125
|
}
|
|
125
|
-
|
|
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
|
-
|
|
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.
|
|
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",
|