summit-marker 2.0.0 → 3.0.2
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/README.md +425 -210
- package/package.json +2 -2
- package/src/backgrounds.js +16 -0
- package/src/box.js +73 -0
- package/src/colors.js +1 -1
- package/src/errors.js +34 -0
- package/src/gradients.js +84 -0
- package/src/index.js +73 -12
- package/src/logger.js +65 -0
- package/src/messages.js +39 -4
- package/src/progress.js +67 -0
- package/src/rgbGradient.js +48 -0
- package/src/spinner.js +83 -0
- package/src/table.js +57 -0
- package/src/text.js +16 -0
- package/src/themes.js +25 -0
- package/LICENSE +0 -47
package/src/table.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
function getColumnWidths(rows) {
|
|
2
|
+
const widths = [];
|
|
3
|
+
|
|
4
|
+
for (const row of rows) {
|
|
5
|
+
row.forEach((cell, index) => {
|
|
6
|
+
const length = String(cell).length;
|
|
7
|
+
|
|
8
|
+
if (!widths[index] || length > widths[index]) {
|
|
9
|
+
widths[index] = length;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return widths;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function border(widths) {
|
|
18
|
+
return (
|
|
19
|
+
"+" +
|
|
20
|
+
widths
|
|
21
|
+
.map(width => "-".repeat(width + 2))
|
|
22
|
+
.join("+") +
|
|
23
|
+
"+"
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function createRow(row, widths) {
|
|
28
|
+
return (
|
|
29
|
+
"|" +
|
|
30
|
+
row
|
|
31
|
+
.map(
|
|
32
|
+
(cell, index) =>
|
|
33
|
+
` ${String(cell).padEnd(widths[index])} `
|
|
34
|
+
)
|
|
35
|
+
.join("|") +
|
|
36
|
+
"|"
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export default function table(rows = []) {
|
|
41
|
+
if (!Array.isArray(rows) || rows.length === 0) {
|
|
42
|
+
return "";
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const widths = getColumnWidths(rows);
|
|
46
|
+
|
|
47
|
+
const lines = [];
|
|
48
|
+
|
|
49
|
+
lines.push(border(widths));
|
|
50
|
+
|
|
51
|
+
for (const row of rows) {
|
|
52
|
+
lines.push(createRow(row, widths));
|
|
53
|
+
lines.push(border(widths));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return lines.join("\n");
|
|
57
|
+
}
|
package/src/text.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const text = {
|
|
2
|
+
caps(value) {
|
|
3
|
+
return String(value).toUpperCase();
|
|
4
|
+
},
|
|
5
|
+
|
|
6
|
+
lower(value) {
|
|
7
|
+
return String(value).toLowerCase();
|
|
8
|
+
},
|
|
9
|
+
|
|
10
|
+
title(value) {
|
|
11
|
+
return String(value)
|
|
12
|
+
.split(" ")
|
|
13
|
+
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
|
|
14
|
+
.join(" ");
|
|
15
|
+
}
|
|
16
|
+
};
|
package/src/themes.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// src/themes.js
|
|
2
|
+
|
|
3
|
+
export function createThemes(marker) {
|
|
4
|
+
return {
|
|
5
|
+
success(text) {
|
|
6
|
+
return marker.green(`✔ ${text}`);
|
|
7
|
+
},
|
|
8
|
+
|
|
9
|
+
error(text) {
|
|
10
|
+
return marker.red(`✖ ${text}`);
|
|
11
|
+
},
|
|
12
|
+
|
|
13
|
+
warning(text) {
|
|
14
|
+
return marker.yellow(`⚠ ${text}`);
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
info(text) {
|
|
18
|
+
return marker.blue(`ℹ ${text}`);
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
summit(text) {
|
|
22
|
+
return marker.gradients.rainbow(`★ ${text}`);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}
|
package/LICENSE
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
SUMMIT MARKER LICENSE NOTICE
|
|
2
|
-
|
|
3
|
-
This software package is UNLICENSED.
|
|
4
|
-
|
|
5
|
-
Copyright (c) Summit. All rights reserved.
|
|
6
|
-
|
|
7
|
-
This package and all associated source code, documentation,
|
|
8
|
-
examples, assets, and related materials are protected by
|
|
9
|
-
copyright and remain the exclusive property of the author.
|
|
10
|
-
|
|
11
|
-
No permission is granted to use, copy, modify, merge, publish,
|
|
12
|
-
distribute, sublicense, sell, or create derivative works based
|
|
13
|
-
on this software unless explicit written permission has been
|
|
14
|
-
provided by the copyright holder.
|
|
15
|
-
|
|
16
|
-
Installing or downloading this package does not grant any
|
|
17
|
-
ownership rights, intellectual property rights, redistribution
|
|
18
|
-
rights, or authorization to create modified versions of this
|
|
19
|
-
software.
|
|
20
|
-
|
|
21
|
-
You may use this package only in ways explicitly allowed by the
|
|
22
|
-
author. Any use outside of those permissions is prohibited.
|
|
23
|
-
|
|
24
|
-
Redistribution of this package, whether in original or modified
|
|
25
|
-
form, is not permitted without prior authorization.
|
|
26
|
-
|
|
27
|
-
Modification of the source code, removal of copyright notices,
|
|
28
|
-
rebranding, republishing under another package name, or claiming
|
|
29
|
-
this software as your own is not permitted.
|
|
30
|
-
|
|
31
|
-
The author reserves all rights to this software and may change,
|
|
32
|
-
update, restrict, or discontinue access to this package at any
|
|
33
|
-
time.
|
|
34
|
-
|
|
35
|
-
This software is provided without any express or implied
|
|
36
|
-
permission beyond what has been specifically granted by the
|
|
37
|
-
author. The author is not required to provide support,
|
|
38
|
-
maintenance, updates, or future versions of this software.
|
|
39
|
-
|
|
40
|
-
By installing or accessing this package, you acknowledge that
|
|
41
|
-
the software remains the property of Summit and that no license
|
|
42
|
-
or ownership rights are transferred to you.
|
|
43
|
-
|
|
44
|
-
For licensing requests, commercial use, redistribution requests,
|
|
45
|
-
or other permissions, contact the copyright holder directly.
|
|
46
|
-
|
|
47
|
-
All rights reserved.
|