subconscious-cli 4.0.3 → 4.0.4
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/bin/branding.js +2 -3
- package/bin/colors.js +9 -0
- package/bin/update-check.js +39 -15
- package/package.json +1 -1
package/bin/branding.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { colorEnabled } from './colors.js';
|
|
1
|
+
import { BRAND_ORANGE, colorEnabled } from './colors.js';
|
|
2
2
|
|
|
3
3
|
// Pre-rendered from assets/imgs/logo.png as portable, 7-bit ASCII art.
|
|
4
4
|
const LOGO = [
|
|
@@ -20,7 +20,6 @@ const LOGO = [
|
|
|
20
20
|
' ###### #####',
|
|
21
21
|
].join('\n');
|
|
22
22
|
|
|
23
|
-
const ORANGE = '\x1b[38;2;255;92;40m';
|
|
24
23
|
const BOLD = '\x1b[1m';
|
|
25
24
|
const RESET = '\x1b[0m';
|
|
26
25
|
|
|
@@ -34,6 +33,6 @@ export function renderBanner(options = {}) {
|
|
|
34
33
|
// still get the same logo without ANSI styling.
|
|
35
34
|
if (!isTTY || term === 'dumb') return ` ${title}`;
|
|
36
35
|
|
|
37
|
-
const logo = color ? `${
|
|
36
|
+
const logo = color ? `${BRAND_ORANGE}${LOGO}${RESET}` : LOGO;
|
|
38
37
|
return `${logo}\n\n ${title}`;
|
|
39
38
|
}
|
package/bin/colors.js
CHANGED
|
@@ -10,6 +10,11 @@ export const colorEnabled =
|
|
|
10
10
|
(forceColor || process.stdout.isTTY === true);
|
|
11
11
|
|
|
12
12
|
const ansi = (code) => (colorEnabled ? `\x1b[${code}m` : '');
|
|
13
|
+
const rgb = (red, green, blue) =>
|
|
14
|
+
colorEnabled ? `\x1b[38;2;${red};${green};${blue}m` : '';
|
|
15
|
+
const bgRgb = (red, green, blue) =>
|
|
16
|
+
colorEnabled ? `\x1b[48;2;${red};${green};${blue}m` : '';
|
|
17
|
+
export const BRAND_ORANGE = '\x1b[38;2;255;92;40m';
|
|
13
18
|
|
|
14
19
|
export const c = {
|
|
15
20
|
reset: ansi(0),
|
|
@@ -20,6 +25,10 @@ export const c = {
|
|
|
20
25
|
red: ansi(31),
|
|
21
26
|
yellow: ansi(33),
|
|
22
27
|
magenta: ansi(35),
|
|
28
|
+
black: ansi(30),
|
|
29
|
+
orange: colorEnabled ? BRAND_ORANGE : '',
|
|
30
|
+
orangeSoft: rgb(255, 145, 105),
|
|
31
|
+
bgOrange: bgRgb(255, 92, 40),
|
|
23
32
|
underline: ansi(4),
|
|
24
33
|
inverse: ansi(7),
|
|
25
34
|
};
|
package/bin/update-check.js
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import fs from 'node:fs/promises';
|
|
2
2
|
import { spawn } from 'node:child_process';
|
|
3
3
|
import readline from 'node:readline';
|
|
4
|
-
import { c } from './colors.js';
|
|
4
|
+
import { c, colorEnabled } from './colors.js';
|
|
5
5
|
|
|
6
6
|
export const PACKAGE_NAME = 'subconscious-cli';
|
|
7
7
|
export const UPDATE_CHECK_TIMEOUT_MS = 1500;
|
|
8
8
|
const UPDATE_ACTIONS = ['Update now', 'Skip for now'];
|
|
9
|
+
const UPDATE_LOGO = [
|
|
10
|
+
' ● ●',
|
|
11
|
+
' ╲ ╱ ',
|
|
12
|
+
'●─── ╳ ───●',
|
|
13
|
+
' ╱ ╲ ',
|
|
14
|
+
' ● ●',
|
|
15
|
+
];
|
|
9
16
|
|
|
10
17
|
function parseVersion(version) {
|
|
11
18
|
const match = String(version)
|
|
@@ -85,18 +92,32 @@ export async function fetchLatestVersion(options = {}) {
|
|
|
85
92
|
}
|
|
86
93
|
|
|
87
94
|
export function renderUpdateNotice(installedVersion, latestVersion) {
|
|
88
|
-
const
|
|
89
|
-
const
|
|
90
|
-
const
|
|
91
|
-
const
|
|
92
|
-
const
|
|
93
|
-
|
|
95
|
+
const logoWidth = Math.max(...UPDATE_LOGO.map((line) => line.length));
|
|
96
|
+
const textWidth = 24;
|
|
97
|
+
const gap = ' ';
|
|
98
|
+
const innerWidth = logoWidth + gap.length + textWidth + 2;
|
|
99
|
+
const border = `${c.orange}╭${'─'.repeat(innerWidth)}╮${c.reset}`;
|
|
100
|
+
const bottom = `${c.orange}╰${'─'.repeat(innerWidth)}╯${c.reset}`;
|
|
101
|
+
const text = [
|
|
102
|
+
{ raw: 'Subconscious CLI', value: `${c.orange}${c.bold}Subconscious CLI${c.reset}` },
|
|
103
|
+
{ raw: 'Update available', value: `${c.bold}Update available${c.reset}` },
|
|
104
|
+
{ raw: '', value: '' },
|
|
105
|
+
{
|
|
106
|
+
raw: `${installedVersion} → ${latestVersion}`,
|
|
107
|
+
value: `${c.dim}${installedVersion}${c.reset} ${c.orange}→${c.reset} ${c.orange}${c.bold}${latestVersion}${c.reset}`,
|
|
108
|
+
},
|
|
109
|
+
{ raw: '', value: '' },
|
|
110
|
+
];
|
|
111
|
+
const row = (logo, copy) => {
|
|
112
|
+
const logoPadding = ' '.repeat(logoWidth - logo.length);
|
|
113
|
+
const textPadding = ' '.repeat(textWidth - copy.raw.length);
|
|
114
|
+
return `${c.orange}│${c.reset} ${c.orange}${logo}${logoPadding}${c.reset}${gap}${copy.value}${textPadding} ${c.orange}│${c.reset}`;
|
|
115
|
+
};
|
|
94
116
|
|
|
95
117
|
return [
|
|
96
|
-
` ${
|
|
97
|
-
` ${row(
|
|
98
|
-
` ${
|
|
99
|
-
` ${c.yellow}${border}${c.reset}`,
|
|
118
|
+
` ${border}`,
|
|
119
|
+
...UPDATE_LOGO.map((logo, index) => ` ${row(logo, text[index])}`),
|
|
120
|
+
` ${bottom}`,
|
|
100
121
|
].join('\n');
|
|
101
122
|
}
|
|
102
123
|
|
|
@@ -110,11 +131,14 @@ export function renderUpdateOptions(selectedIndex = 0, versions = {}) {
|
|
|
110
131
|
|
|
111
132
|
return UPDATE_ACTIONS.map((label, index) => {
|
|
112
133
|
const active = index === selectedIndex;
|
|
113
|
-
const pointer = active ? `${c.
|
|
134
|
+
const pointer = active ? `${c.orange}›${c.reset}` : ' ';
|
|
135
|
+
const activeStyle = colorEnabled
|
|
136
|
+
? `${c.bgOrange}${c.black}`
|
|
137
|
+
: c.inverse;
|
|
114
138
|
const option = active
|
|
115
|
-
? `${
|
|
139
|
+
? `${activeStyle}${c.bold} ${label} ${c.reset}`
|
|
116
140
|
: ` ${label} `;
|
|
117
|
-
const descriptionStyle = active ? c.
|
|
141
|
+
const descriptionStyle = active ? c.orangeSoft : c.dim;
|
|
118
142
|
return ` ${pointer} ${option}\n ${descriptionStyle}${descriptions[index]}${c.reset}`;
|
|
119
143
|
}).join('\n');
|
|
120
144
|
}
|
|
@@ -132,7 +156,7 @@ export async function selectUpdateAction(options = {}) {
|
|
|
132
156
|
const output = options.output || process.stderr;
|
|
133
157
|
const initiallyRaw = input.isRaw === true;
|
|
134
158
|
let selectedIndex = options.selectedIndex ?? 0;
|
|
135
|
-
const instructions = ` ${c.dim}Use
|
|
159
|
+
const instructions = ` ${c.dim}Use ${c.orange}↑/↓${c.reset}${c.dim} to select • ${c.orange}Enter${c.reset}${c.dim} to confirm${c.reset}`;
|
|
136
160
|
const render = () =>
|
|
137
161
|
`${renderUpdateOptions(selectedIndex, {
|
|
138
162
|
installedVersion: options.installedVersion,
|