[READ-ONLY] Mirror of https://github.com/bombshell-dev/clack. Effortlessly build beautiful command-line apps bomb.sh/docs/clack/basics/getting-started/
cli command-line command-line-app node prompt prompts
5

Configure Feed

Select the types of activity you want to include in your feed.

remove unused packages

Nate Moore (Mar 5, 2023, 10:15 AM -0600) e5d4526e 6dee1eac

+60 -64
-1
packages/core/package.json
··· 53 53 "prepack": "pnpm build" 54 54 }, 55 55 "dependencies": { 56 - "eastasianwidth": "^0.2.0", 57 56 "picocolors": "^1.0.0", 58 57 "sisteransi": "^1.0.5" 59 58 },
+58 -60
packages/core/src/utils.ts
··· 3 3 import { stdin, stdout } from 'node:process'; 4 4 import * as readline from 'node:readline'; 5 5 import { cursor } from 'sisteransi'; 6 - // @ts-expect-error no types 7 - import ea from 'eastasianwidth'; 8 6 9 7 export function block({ 10 8 input = stdin, ··· 64 62 return str.replace(ansiRegex(), ''); 65 63 } 66 64 67 - export function width(str: string): number { 68 - return Array.from(graphemes.segment(str)).map(({ segment: c }) => ea.characterLength(c)).reduce((a, b) => a + b, 0); 69 - } 65 + // export function width(str: string): number { 66 + // return Array.from(graphemes.segment(str)).map(({ segment: c }) => ea.characterLength(c)).reduce((a, b) => a + b, 0); 67 + // } 70 68 71 - const words = new Intl.Segmenter([], { granularity: 'word' }); 72 - const graphemes = new Intl.Segmenter([], { granularity: 'grapheme' }); 69 + // const words = new Intl.Segmenter([], { granularity: 'word' }); 70 + // const graphemes = new Intl.Segmenter([], { granularity: 'grapheme' }); 73 71 74 72 // TODO: match behavior with `wrap-ansi` 75 73 // There are currently some bugs here that keep ansi escapes from working properly 76 - export function _wrap(str: string, cols = process.stdout.columns): string { 77 - const parts: string[] = []; 78 - let part = ''; 79 - let i = 0; 80 - const handle = (chunk: string, { prefix = "", suffix = '' } = {}) => { 81 - for (const word of words.segment(chunk)) { 82 - if (word.segment === '\n') { 83 - parts.push(part) 84 - i = 0 85 - part = '' 86 - continue; 87 - } 88 - const len = width(word.segment); 89 - // Gracefully handle trailing punctuation by ensuring it is always joined with the previous word 90 - if (len === 1 && word.segment.trim() && /\W/.test(word.segment)) { 91 - part += word.segment; 92 - i += 1 93 - continue; 94 - } 95 - if ((i + len) > cols - 1) { 96 - parts.push(part.trim()) 97 - i = 0 98 - part = '' 99 - } 100 - part += `${prefix}${word.segment}${suffix}` 101 - i += len; 102 - } 103 - } 74 + // export function _wrap(str: string, cols = process.stdout.columns): string { 75 + // const parts: string[] = []; 76 + // let part = ''; 77 + // let i = 0; 78 + // const handle = (chunk: string, { prefix = "", suffix = '' } = {}) => { 79 + // for (const word of words.segment(chunk)) { 80 + // if (word.segment === '\n') { 81 + // parts.push(part) 82 + // i = 0 83 + // part = '' 84 + // continue; 85 + // } 86 + // const len = width(word.segment); 87 + // // Gracefully handle trailing punctuation by ensuring it is always joined with the previous word 88 + // if (len === 1 && word.segment.trim() && /\W/.test(word.segment)) { 89 + // part += word.segment; 90 + // i += 1 91 + // continue; 92 + // } 93 + // if ((i + len) > cols - 1) { 94 + // parts.push(part.trim()) 95 + // i = 0 96 + // part = '' 97 + // } 98 + // part += `${prefix}${word.segment}${suffix}` 99 + // i += len; 100 + // } 101 + // } 104 102 105 - const re = ansiRegex(); 106 - let lastIndex = 0; 107 - let lastPart = ""; 108 - let m; 109 - while (m = re.exec(str)) { 110 - const chunk = m.input.slice(lastIndex, m.index); 111 - const [prefix, suffix] = [lastPart, m[0]] 112 - if (prefix) { 113 - const [pCode, sCode] = [Number(prefix.slice(2, -1)), Number(suffix.slice(2, -1))] 114 - if (sCode > pCode) { 115 - handle(chunk, { prefix, suffix }); 116 - } else { 117 - handle(chunk) 118 - } 119 - } else { 120 - handle(chunk) 121 - } 122 - lastPart = m[0]; 123 - lastIndex = m.index + m[0].length; 124 - } 125 - const chunk = str.slice(lastIndex); 126 - handle(chunk); 127 - parts.push(part); 103 + // const re = ansiRegex(); 104 + // let lastIndex = 0; 105 + // let lastPart = ""; 106 + // let m; 107 + // while (m = re.exec(str)) { 108 + // const chunk = m.input.slice(lastIndex, m.index); 109 + // const [prefix, suffix] = [lastPart, m[0]] 110 + // if (prefix) { 111 + // const [pCode, sCode] = [Number(prefix.slice(2, -1)), Number(suffix.slice(2, -1))] 112 + // if (sCode > pCode) { 113 + // handle(chunk, { prefix, suffix }); 114 + // } else { 115 + // handle(chunk) 116 + // } 117 + // } else { 118 + // handle(chunk) 119 + // } 120 + // lastPart = m[0]; 121 + // lastIndex = m.index + m[0].length; 122 + // } 123 + // const chunk = str.slice(lastIndex); 124 + // handle(chunk); 125 + // parts.push(part); 128 126 129 - return parts.map(p => /^\s{2,}/.test(p) ? p : p.trimStart()).join('\n'); 130 - } 127 + // return parts.map(p => /^\s{2,}/.test(p) ? p : p.trimStart()).join('\n'); 128 + // } 131 129
+1 -1
packages/prompts/src/index.ts
··· 13 13 import isUnicodeSupported from 'is-unicode-supported'; 14 14 import color from 'picocolors'; 15 15 import { cursor, erase } from 'sisteransi'; 16 + import { strip } from '@clack/core'; 16 17 17 18 export { isCancel } from '@clack/core'; 18 19 ··· 531 532 }).prompt() as Promise<Value[] | symbol>; 532 533 }; 533 534 534 - const strip = (str: string) => str.replace(ansiRegex(), ''); 535 535 export const note = (message = '', title = '') => { 536 536 const lines = `\n${message}\n`.split('\n'); 537 537 const len =
+1 -2
pnpm-lock.yaml
··· 48 48 49 49 packages/core: 50 50 specifiers: 51 - eastasianwidth: ^0.2.0 52 51 picocolors: ^1.0.0 53 52 sisteransi: ^1.0.5 54 53 wrap-ansi: ^8.1.0 55 54 dependencies: 56 - eastasianwidth: 0.2.0 57 55 picocolors: 1.0.0 58 56 sisteransi: 1.0.5 59 57 devDependencies: ··· 1219 1217 1220 1218 /eastasianwidth/0.2.0: 1221 1219 resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==} 1220 + dev: true 1222 1221 1223 1222 /editorconfig/0.15.3: 1224 1223 resolution: {integrity: sha512-M9wIMFx96vq0R4F+gRpY3o2exzb8hEj/n9S8unZtHSvYjibBp/iMufSzvmOcV/laG0ZtuTVGtiJggPOSW2r93g==}