cdd-cli 3.1.5 → 3.1.6
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/_config.yml +13 -0
- package/dist/components/Header.js +10 -2
- package/dist/components/StatsBar.js +5 -4
- package/dist/helpers/appInfo.js +21 -0
- package/dist/helpers/logger.js +17 -3
- package/docs/_config.yml +13 -0
- package/package.json +1 -1
- package/src/components/Header.jsx +11 -3
- package/src/helpers/appInfo.js +23 -0
package/_config.yml
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Configure GitHub Pages to treat the generated docs as a static site.
|
|
2
|
+
source: docs
|
|
3
|
+
# Disable the default theme so Jekyll does not expect its SCSS assets.
|
|
4
|
+
theme: null
|
|
5
|
+
|
|
6
|
+
# Allow Jekyll to copy across these asset folders untouched.
|
|
7
|
+
include:
|
|
8
|
+
- fonts
|
|
9
|
+
- scripts
|
|
10
|
+
- styles
|
|
11
|
+
|
|
12
|
+
# We do not rely on any Jekyll plugins for this site.
|
|
13
|
+
plugins: []
|
|
@@ -2,6 +2,7 @@ import React from "react";
|
|
|
2
2
|
import { Box, Text } from "ink";
|
|
3
3
|
import chalk from "chalk";
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
|
+
import { getAppVersion } from "../helpers/appInfo.js";
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Header component displayed at the top of the CLI UI.
|
|
@@ -14,17 +15,24 @@ import PropTypes from 'prop-types';
|
|
|
14
15
|
* <Header count={3} />
|
|
15
16
|
*/
|
|
16
17
|
|
|
18
|
+
var VERSION = getAppVersion();
|
|
17
19
|
export default function Header(_ref) {
|
|
18
20
|
var count = _ref.count;
|
|
21
|
+
var formattedVersion = VERSION === "unknown" ? "unknown" : "v".concat(VERSION);
|
|
19
22
|
return /*#__PURE__*/React.createElement(Box, {
|
|
20
23
|
justifyContent: "space-between"
|
|
21
24
|
}, /*#__PURE__*/React.createElement(Text, {
|
|
22
25
|
color: "cyanBright"
|
|
23
26
|
}, "\uD83D\uDC33 ", chalk.bold("CDD"), /*#__PURE__*/React.createElement(Text, {
|
|
24
27
|
color: "gray"
|
|
25
|
-
}, " \u2014 CLI Docker Dashboard")), /*#__PURE__*/React.createElement(
|
|
28
|
+
}, " \u2014 CLI Docker Dashboard")), /*#__PURE__*/React.createElement(Box, {
|
|
29
|
+
flexDirection: "column",
|
|
30
|
+
alignItems: "flex-end"
|
|
31
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
32
|
+
color: "gray"
|
|
33
|
+
}, formattedVersion), /*#__PURE__*/React.createElement(Text, {
|
|
26
34
|
color: "gray"
|
|
27
|
-
}, count, " container", count === 1 ? "" : "s", " found"));
|
|
35
|
+
}, count, " container", count === 1 ? "" : "s", " found")));
|
|
28
36
|
}
|
|
29
37
|
Header.propTypes = {
|
|
30
38
|
count: PropTypes.number.isRequired
|
|
@@ -8,8 +8,8 @@ var BAR_WIDTH = 8;
|
|
|
8
8
|
* Small visual bar that shows CPU and memory usage percentages.
|
|
9
9
|
*
|
|
10
10
|
* @param {Object} props
|
|
11
|
-
* @param {number} props.cpu - CPU percentage (0-100)
|
|
12
|
-
* @param {number} props.mem - Memory percentage (0-100)
|
|
11
|
+
* @param {number} props.cpu - CPU percentage (values outside 0-100 are clamped)
|
|
12
|
+
* @param {number} props.mem - Memory percentage (values outside 0-100 are clamped)
|
|
13
13
|
* @returns {JSX.Element}
|
|
14
14
|
*/
|
|
15
15
|
export default function StatsBar(_ref) {
|
|
@@ -27,7 +27,8 @@ StatsBar.propTypes = {
|
|
|
27
27
|
/**
|
|
28
28
|
* Build a fixed-width bar representation from a numeric percentage.
|
|
29
29
|
*
|
|
30
|
-
* @param {number} value - Percentage value (0-100)
|
|
30
|
+
* @param {number} value - Percentage value (values outside 0-100 are clamped)
|
|
31
|
+
* @param {number} width - Desired bar width in characters
|
|
31
32
|
* @returns {string} Colored bar string
|
|
32
33
|
*/
|
|
33
34
|
function makeBar(value, width) {
|
|
@@ -48,7 +49,7 @@ function formatPercent(value) {
|
|
|
48
49
|
/**
|
|
49
50
|
* Colorize a value or text depending on thresholds.
|
|
50
51
|
*
|
|
51
|
-
* @param {number} value - Numeric value used to pick color
|
|
52
|
+
* @param {number} value - Numeric value used to pick color; receives clamped percentage
|
|
52
53
|
* @param {string} [text] - Text to colorize, defaults to the numeric string
|
|
53
54
|
* @returns {string}
|
|
54
55
|
*/
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { readFileSync } from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { fileURLToPath } from "url";
|
|
4
|
+
var cachedVersion;
|
|
5
|
+
export function getAppVersion() {
|
|
6
|
+
if (cachedVersion) {
|
|
7
|
+
return cachedVersion;
|
|
8
|
+
}
|
|
9
|
+
try {
|
|
10
|
+
var _packageJson$version;
|
|
11
|
+
var __filename = fileURLToPath(import.meta.url);
|
|
12
|
+
var moduleDir = path.dirname(__filename);
|
|
13
|
+
var packageJsonPath = path.resolve(moduleDir, "../../package.json");
|
|
14
|
+
var packageJson = JSON.parse(readFileSync(packageJsonPath, "utf8"));
|
|
15
|
+
cachedVersion = (_packageJson$version = packageJson.version) !== null && _packageJson$version !== void 0 ? _packageJson$version : "unknown";
|
|
16
|
+
return cachedVersion;
|
|
17
|
+
} catch (error) {
|
|
18
|
+
cachedVersion = "unknown";
|
|
19
|
+
return cachedVersion;
|
|
20
|
+
}
|
|
21
|
+
}
|
package/dist/helpers/logger.js
CHANGED
|
@@ -9,6 +9,21 @@ var LOG_LEVELS = {
|
|
|
9
9
|
info: 2,
|
|
10
10
|
debug: 3
|
|
11
11
|
};
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @typedef {Object} LogEntry
|
|
15
|
+
* @property {string} level Severity string (error, warn, info, debug)
|
|
16
|
+
* @property {string} message Primary log message
|
|
17
|
+
* @property {any[]} args Additional payload values forwarded to listeners
|
|
18
|
+
* @property {string} timestamp ISO timestamp when the entry was created
|
|
19
|
+
* @property {string} formatted Preformatted message used for console output
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @callback LogListener
|
|
24
|
+
* @param {LogEntry} entry Log entry data emitted by the logger
|
|
25
|
+
*/
|
|
26
|
+
|
|
12
27
|
function parseLevel(value) {
|
|
13
28
|
if (typeof value !== "string") {
|
|
14
29
|
return null;
|
|
@@ -96,9 +111,8 @@ export var logger = {
|
|
|
96
111
|
/**
|
|
97
112
|
* Subscribe to log events.
|
|
98
113
|
*
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
* @returns {Function} Cleanup function that removes the listener when called.
|
|
114
|
+
* @param {LogListener} listener Listener invoked for every log entry that passes the current level filter.
|
|
115
|
+
* @returns {function(): void} Cleanup function that removes the listener when called.
|
|
102
116
|
*/
|
|
103
117
|
subscribe: function subscribe(listener) {
|
|
104
118
|
if (typeof listener !== "function") {
|
package/docs/_config.yml
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
title: CDD Documentation
|
|
2
|
+
# Disable the default GitHub Pages theme so Jekyll just copies our static output
|
|
3
|
+
# (the static HTML is generated by JSDoc and already styled).
|
|
4
|
+
theme: null
|
|
5
|
+
|
|
6
|
+
# Explicitly include asset folders that Jekyll might otherwise ignore.
|
|
7
|
+
include:
|
|
8
|
+
- fonts
|
|
9
|
+
- scripts
|
|
10
|
+
- styles
|
|
11
|
+
|
|
12
|
+
# No Jekyll plugins are required for this pre-rendered site.
|
|
13
|
+
plugins: []
|
package/package.json
CHANGED
|
@@ -2,6 +2,7 @@ import React from "react";
|
|
|
2
2
|
import { Box, Text } from "ink";
|
|
3
3
|
import chalk from "chalk";
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
|
+
import { getAppVersion } from "../helpers/appInfo.js";
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Header component displayed at the top of the CLI UI.
|
|
@@ -14,16 +15,23 @@ import PropTypes from 'prop-types';
|
|
|
14
15
|
* <Header count={3} />
|
|
15
16
|
*/
|
|
16
17
|
|
|
18
|
+
const VERSION = getAppVersion();
|
|
19
|
+
|
|
17
20
|
export default function Header({ count }) {
|
|
21
|
+
const formattedVersion = VERSION === "unknown" ? "unknown" : `v${VERSION}`;
|
|
22
|
+
|
|
18
23
|
return (
|
|
19
24
|
<Box justifyContent="space-between">
|
|
20
25
|
<Text color="cyanBright">
|
|
21
26
|
🐳 {chalk.bold("CDD")}
|
|
22
27
|
<Text color="gray"> — CLI Docker Dashboard</Text>
|
|
23
28
|
</Text>
|
|
24
|
-
<
|
|
25
|
-
|
|
26
|
-
|
|
29
|
+
<Box flexDirection="column" alignItems="flex-end">
|
|
30
|
+
<Text color="gray">{formattedVersion}</Text>
|
|
31
|
+
<Text color="gray">
|
|
32
|
+
{count} container{count === 1 ? "" : "s"} found
|
|
33
|
+
</Text>
|
|
34
|
+
</Box>
|
|
27
35
|
</Box>
|
|
28
36
|
);
|
|
29
37
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { readFileSync } from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { fileURLToPath } from "url";
|
|
4
|
+
|
|
5
|
+
let cachedVersion;
|
|
6
|
+
|
|
7
|
+
export function getAppVersion() {
|
|
8
|
+
if (cachedVersion) {
|
|
9
|
+
return cachedVersion;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
try {
|
|
13
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
14
|
+
const moduleDir = path.dirname(__filename);
|
|
15
|
+
const packageJsonPath = path.resolve(moduleDir, "../../package.json");
|
|
16
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf8"));
|
|
17
|
+
cachedVersion = packageJson.version ?? "unknown";
|
|
18
|
+
return cachedVersion;
|
|
19
|
+
} catch (error) {
|
|
20
|
+
cachedVersion = "unknown";
|
|
21
|
+
return cachedVersion;
|
|
22
|
+
}
|
|
23
|
+
}
|