{"library":"resin-cli-visuals","title":"Resin CLI Visuals","description":"resin-cli-visuals is a JavaScript/TypeScript library providing a collection of command-line interface (CLI) widgets designed primarily for the Balena ecosystem's CLI tools. It offers components such as spinners, progress bars, interactive tables (horizontal and vertical), and a drive scanner to dynamically detect storage device changes. The current stable version is 4.0.4, released in March 2026, indicating an active development cadence with several minor and major releases in the last year. Key differentiators include its focus on CLI UX within the Balena context, offering ready-to-use visual components for common CLI interactions, and its recent migration to TypeScript and ESM, ensuring modern JavaScript practices. The library is built to enhance user interaction in console applications, making operations like long-running tasks or data display more visually intuitive.","language":"javascript","status":"active","last_verified":"Wed Apr 22","install":{"commands":["npm install resin-cli-visuals"],"cli":null},"imports":["import { visuals } from 'resin-cli-visuals';","import { DriveScanner } from 'resin-cli-visuals';","import { visuals } from 'resin-cli-visuals';\nconst spinner = new visuals.Spinner('Loading...');"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { visuals, DriveScanner } from 'resin-cli-visuals';\n\nasync function runCliDemo() {\n  // Simulate a long-running operation with a spinner\n  const spinner = new visuals.Spinner('Processing task...');\n  spinner.start();\n  await new Promise(resolve => setTimeout(resolve, 3000));\n  spinner.stop();\n  console.log('Task completed.');\n\n  // Display data in a horizontal table\n  const tableData = [\n    { label: 'Name', value: 'John Doe' },\n    { label: 'Email', value: 'john.doe@example.com' },\n    { label: 'Role', value: 'Developer' }\n  ];\n  const tableOrdering = ['label', 'value'];\n  console.log('\\nUser Details:');\n  console.log(visuals.table.horizontal(tableData, tableOrdering));\n\n  // Example of a DriveScanner (requires a driveFinder function)\n  // In a real scenario, driveFinder would be an async function\n  // that returns an array of drive objects.\n  const mockDriveFinder = async () => [\n    { device: '/dev/sda', size: '10GB', description: 'USB Drive' },\n    { device: '/dev/sdb', size: '500GB', description: 'Internal HDD' }\n  ];\n  const scanner = new DriveScanner(mockDriveFinder, { interval: 2000 });\n  scanner.on('change', (drives) => {\n    console.log('\\nDrive change detected:', drives);\n  });\n  console.log('\\nDrive scanner started. Waiting for changes (runs for 5s)...');\n  await new Promise(resolve => setTimeout(resolve, 5000));\n  scanner.stop();\n  console.log('Drive scanner stopped.');\n}\n\nrunCliDemo().catch(console.error);","lang":"typescript","description":"This quickstart demonstrates creating a spinner, displaying data in a horizontal table, and using the DriveScanner to detect drive changes.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}