fix gitignore again

This commit is contained in:
olcxja 2026-05-10 16:36:35 +02:00
commit 5da5c2afe2
3329 changed files with 364540 additions and 3 deletions

View file

@ -0,0 +1,19 @@
/**
* ANSI escape codes (WIP)
*
* @see https://en.wikipedia.org/wiki/ANSI_escape_code
*/
export declare class EscapeCode {
static readonly cursorLeft: () => string;
static readonly cursorUp: (count?: number) => string;
static readonly cursorDown: (count?: number) => string;
static readonly cursorForward: (count?: number) => string;
static readonly cursorBackward: (count?: number) => string;
static readonly cursorHide: () => string;
static readonly cursorShow: () => string;
static readonly eraseLine: () => string;
static readonly eraseLines: (count: number) => string;
static readonly eraseUp: () => string;
static readonly eraseDown: () => string;
static readonly eraseScreen: () => string;
}

View file

@ -0,0 +1,33 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.EscapeCode = void 0;
const ESC = '\u001B[';
/**
* ANSI escape codes (WIP)
*
* @see https://en.wikipedia.org/wiki/ANSI_escape_code
*/
class EscapeCode {
}
exports.EscapeCode = EscapeCode;
EscapeCode.cursorLeft = () => `${ESC}G`;
EscapeCode.cursorUp = (count = 1) => `${ESC}${count}A`;
EscapeCode.cursorDown = (count = 1) => `${ESC}${count}B`;
EscapeCode.cursorForward = (count = 1) => `${ESC}${count}C`;
EscapeCode.cursorBackward = (count = 1) => `${ESC}${count}D`;
EscapeCode.cursorHide = () => `${ESC}?25l`;
EscapeCode.cursorShow = () => `${ESC}?25h`;
EscapeCode.eraseLine = () => `${ESC}2K`;
EscapeCode.eraseLines = (count) => {
let seq = '';
for (let i = 0; i < count; i++) {
seq += EscapeCode.eraseLine();
if (i < count - 1) {
seq += EscapeCode.cursorUp();
}
}
return `${seq}${EscapeCode.cursorLeft()}`;
};
EscapeCode.eraseUp = () => `${ESC}1J`;
EscapeCode.eraseDown = () => `${ESC}J`;
EscapeCode.eraseScreen = () => `${ESC}2J`;

View file

@ -0,0 +1,9 @@
/// <reference types="node" />
export declare class Cursor {
static stream: NodeJS.WriteStream;
private static _isVisible;
private static _listenerAttached;
static show(): void;
static hide(): void;
static toggle(): void;
}

View file

@ -0,0 +1,38 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Cursor = void 0;
const tslib_1 = require("tslib");
const signal_exit_1 = tslib_1.__importDefault(require("signal-exit"));
const ansi_1 = require("./ansi");
class Cursor {
static show() {
if (Cursor.stream.isTTY) {
Cursor._isVisible = true;
Cursor.stream.write(ansi_1.EscapeCode.cursorShow());
}
}
static hide() {
if (Cursor.stream.isTTY) {
if (!Cursor._listenerAttached) {
(0, signal_exit_1.default)(() => {
Cursor.show();
});
Cursor._listenerAttached = true;
}
Cursor._isVisible = false;
Cursor.stream.write(ansi_1.EscapeCode.cursorHide());
}
}
static toggle() {
if (Cursor._isVisible) {
Cursor.hide();
}
else {
Cursor.show();
}
}
}
exports.Cursor = Cursor;
Cursor.stream = process.stderr;
Cursor._isVisible = true;
Cursor._listenerAttached = false;

View file

@ -0,0 +1,35 @@
import sliceAnsi = require('slice-ansi');
import stringWidth = require('string-width');
import stripAnsi = require('strip-ansi');
export { sliceAnsi, stringWidth, stripAnsi };
export declare const TTY_WIDTH: number;
export declare function indent(n?: number): string;
export interface WordWrapOptions {
width?: number;
indentation?: number;
append?: string;
}
export declare function wordWrap(msg: string, { width, indentation, append }: WordWrapOptions): string;
export declare function prettyPath(p: string): string;
export declare function expandPath(p: string): string;
export declare function generateFillSpaceStringList(list: string[], optimalLength?: number, fillCharacter?: string): string[];
export interface ColumnarOptions {
hsep?: string;
vsep?: string;
headers?: string[];
}
/**
* Basic CLI table generator with support for ANSI colors.
*
* @param rows 2-dimensional matrix containing cells. An array of columns,
* which are arrays of cells.
* @param options.vsep The vertical separator character, default is
* `chalk.dim('|')`. Supply an empty string to hide
* the separator altogether.
* @param options.hsep The horizontal separator character, default is
* `chalk.dim('-')`. This is used under the headers,
* if supplied. Supply an empty string to hide the
* separator altogether.
* @param options.headers An array of header cells.
*/
export declare function columnar(rows: string[][], { hsep, vsep, headers }: ColumnarOptions): string;

View file

@ -0,0 +1,123 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.columnar = exports.generateFillSpaceStringList = exports.expandPath = exports.prettyPath = exports.wordWrap = exports.indent = exports.TTY_WIDTH = exports.stripAnsi = exports.stringWidth = exports.sliceAnsi = void 0;
const tslib_1 = require("tslib");
const os = tslib_1.__importStar(require("os"));
const path = tslib_1.__importStar(require("path"));
const sliceAnsi = require("slice-ansi");
exports.sliceAnsi = sliceAnsi;
const stringWidth = require("string-width");
exports.stringWidth = stringWidth;
const stripAnsi = require("strip-ansi");
exports.stripAnsi = stripAnsi;
const wrapAnsi = require("wrap-ansi");
const untildify = require("untildify");
const MIN_TTY_WIDTH = 80;
const MAX_TTY_WIDTH = 120;
exports.TTY_WIDTH = process.stdout.columns ? Math.max(MIN_TTY_WIDTH, Math.min(process.stdout.columns, MAX_TTY_WIDTH)) : Infinity;
function indent(n = 4) {
return ' '.repeat(n);
}
exports.indent = indent;
function wordWrap(msg, { width = exports.TTY_WIDTH, indentation = 0, append = '' }) {
return wrapAnsi(msg, width - indentation - append.length, { trim: true }).split('\n').join(`${append}\n${indent(indentation)}`);
}
exports.wordWrap = wordWrap;
function prettyPath(p) {
p = expandPath(p);
const cwd = process.cwd();
const d = path.dirname(p);
const h = os.homedir();
const distanceFromCwd = Math.abs(d.split(path.sep).length - cwd.split(path.sep).length);
if (cwd === d) {
return '.' + path.sep + path.basename(p);
}
else if (d.startsWith(cwd)) {
return '.' + path.sep + p.substring(cwd.length + 1);
}
else if (distanceFromCwd <= 2) {
const rel = path.relative(cwd, p);
return rel ? rel : '.';
}
else if (p === h) {
return '~';
}
else if (p.indexOf(h) === 0) {
return '~' + path.sep + p.substring(h.length + 1);
}
return p;
}
exports.prettyPath = prettyPath;
function expandPath(p) {
return path.resolve(untildify(p));
}
exports.expandPath = expandPath;
function generateFillSpaceStringList(list, optimalLength = 1, fillCharacter = ' ') {
if (optimalLength < 2) {
optimalLength = 2;
}
const longestItem = Math.max(...list.map(item => stringWidth(item)));
const fullLength = longestItem > optimalLength ? longestItem + 1 : optimalLength;
const fullLengthString = fillCharacter.repeat(fullLength);
return list.map(item => sliceAnsi(fullLengthString, 0, fullLength - stringWidth(item)));
}
exports.generateFillSpaceStringList = generateFillSpaceStringList;
/**
* Basic CLI table generator with support for ANSI colors.
*
* @param rows 2-dimensional matrix containing cells. An array of columns,
* which are arrays of cells.
* @param options.vsep The vertical separator character, default is
* `chalk.dim('|')`. Supply an empty string to hide
* the separator altogether.
* @param options.hsep The horizontal separator character, default is
* `chalk.dim('-')`. This is used under the headers,
* if supplied. Supply an empty string to hide the
* separator altogether.
* @param options.headers An array of header cells.
*/
function columnar(rows, { hsep = '-', vsep = '|', headers }) {
const includeHeaders = headers ? true : false;
if (!rows[0]) {
return '';
}
const columnCount = headers ? headers.length : rows[0].length;
const columns = headers ?
headers.map(header => [header]) :
rows[0].map(() => []);
for (const row of rows) {
let highestLineCount = 0;
const splitRows = row.map(cell => {
const lines = cell.split('\n');
highestLineCount = Math.max(highestLineCount, lines.length);
return lines;
});
for (const rowIndex in row) {
if (columns[rowIndex]) {
columns[rowIndex].push(...splitRows[rowIndex], ...Array(highestLineCount - splitRows[rowIndex].length).fill(''));
}
}
}
const paddedColumns = columns.map((col, columnIndex) => {
if (columnIndex < columnCount - 1) {
const spaceCol = generateFillSpaceStringList(col);
return col.map((cell, cellIndex) => `${cell}${spaceCol[cellIndex]}${vsep === '' ? '' : `${vsep} `}`);
}
else {
return col;
}
});
let longestRowLength = 0;
const singleColumn = paddedColumns.reduce((a, b) => {
return a.map((_, i) => {
const r = a[i] + b[i];
longestRowLength = Math.max(longestRowLength, stringWidth(r));
return r;
});
});
if (includeHeaders && hsep !== '') {
singleColumn.splice(1, 0, hsep.repeat(longestRowLength));
}
return singleColumn.join('\n');
}
exports.columnar = columnar;

View file

@ -0,0 +1,4 @@
export * from './ansi';
export * from './cursor';
export * from './format';
export * from './info';

View file

@ -0,0 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./ansi"), exports);
tslib_1.__exportStar(require("./cursor"), exports);
tslib_1.__exportStar(require("./format"), exports);
tslib_1.__exportStar(require("./info"), exports);

View file

@ -0,0 +1,26 @@
/**
* These environment variables work for: GitHub Actions, Travis CI, CircleCI,
* Gitlab CI, AppVeyor, CodeShip, Jenkins, TeamCity, Bitbucket Pipelines, AWS
* CodeBuild
*/
export declare const CI_ENVIRONMENT_VARIABLES: readonly string[];
export declare const CI_ENVIRONMENT_VARIABLES_DETECTED: string[];
export interface TerminalInfo {
/**
* Whether this is in CI or not.
*/
readonly ci: boolean;
/**
* Path to the user's shell program.
*/
readonly shell: string;
/**
* Whether the terminal is an interactive TTY or not.
*/
readonly tty: boolean;
/**
* Whether this is a Windows shell or not.
*/
readonly windows: boolean;
}
export declare const TERMINAL_INFO: TerminalInfo;

View file

@ -0,0 +1,40 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TERMINAL_INFO = exports.CI_ENVIRONMENT_VARIABLES_DETECTED = exports.CI_ENVIRONMENT_VARIABLES = void 0;
const tslib_1 = require("tslib");
const debug_1 = require("debug");
const os = tslib_1.__importStar(require("os"));
const debug = (0, debug_1.debug)('ionic:utils-terminal:info');
/**
* These environment variables work for: GitHub Actions, Travis CI, CircleCI,
* Gitlab CI, AppVeyor, CodeShip, Jenkins, TeamCity, Bitbucket Pipelines, AWS
* CodeBuild
*/
exports.CI_ENVIRONMENT_VARIABLES = ['CI', 'BUILD_ID', 'BUILD_NUMBER', 'BITBUCKET_COMMIT', 'CODEBUILD_BUILD_ARN', 'GITHUB_ACTIONS'];
exports.CI_ENVIRONMENT_VARIABLES_DETECTED = exports.CI_ENVIRONMENT_VARIABLES.filter(v => !!process.env[v]);
function getShell() {
const { shell } = os.userInfo();
if (shell) {
return shell;
}
if (process.env.SHELL) {
return process.env.SHELL;
}
if (process.platform === 'darwin') {
return '/bin/bash';
}
if (process.platform === 'win32') {
return process.env.COMSPEC ? process.env.COMSPEC : 'cmd.exe';
}
return '/bin/sh';
}
if (exports.CI_ENVIRONMENT_VARIABLES_DETECTED.length > 0) {
debug(`Environment variables for CI detected: ${exports.CI_ENVIRONMENT_VARIABLES_DETECTED.join(', ')}`);
}
exports.TERMINAL_INFO = Object.freeze({
ci: exports.CI_ENVIRONMENT_VARIABLES_DETECTED.length > 0,
shell: getShell(),
tty: Boolean(process.stdin.isTTY && process.stdout.isTTY && process.stderr.isTTY),
windows: process.platform === 'win32' || !!(process.env.OSTYPE && /^(msys|cygwin)$/.test(process.env.OSTYPE) ||
process.env.MSYSTEM && /^MINGW(32|64)$/.test(process.env.MSYSTEM)),
});