Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Mar 24, 2023
1 parent 5e3149a commit 4ec4ebb
Show file tree
Hide file tree
Showing 11 changed files with 99 additions and 107 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
node_version: [14, 16, 18]

node-version:
- 18
- 16
- 14
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
node_modules
yarn.lock
/dist.js
build
dist
Empty file removed package-lock.json
Empty file.
53 changes: 21 additions & 32 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,22 @@
"email": "[email protected]",
"url": "https://sindresorhus.com"
},
"main": "dist.js",
"type": "module",
"exports": {
"types": "./build/index.d.ts",
"default": "./build/index.js"
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"engines": {
"node": ">=14.16"
},
"scripts": {
"build": "tsc",
"test": "xo && ava",
"prepublish": "npm run build",
"pretest": "npm run build",
"test": "xo && ava"
"pretest": "npm run build"
},
"files": [
"build"
"dist"
],
"keywords": [
"ink-component",
Expand All @@ -45,46 +44,36 @@
"command-line"
],
"dependencies": {
"cfonts": "^2.8.6",
"prop-types": "^15.7.2"
"cfonts": "^3.1.1",
"prop-types": "^15.8.1"
},
"devDependencies": {
"@babel/cli": "^7.2.3",
"@babel/core": "^7.3.3",
"@babel/preset-react": "^7.0.0",
"@sindresorhus/tsconfig": "^3.0.1",
"@types/react": "^18.0.28",
"ava": "^5.1.1",
"clear-module": "^3.1.0",
"eslint-config-xo-react": "^0.19.0",
"eslint-plugin-react": "^7.7.0",
"eslint-plugin-react-hooks": "^1.4.0",
"ink": "^4",
"ink-testing-library": "^3",
"react": "^18",
"strip-ansi": "^5.0.0",
"ava": "^5.2.0",
"clear-module": "^4.1.2",
"eslint-config-xo-react": "^0.27.0",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"ink": "^4.0.0",
"ink-testing-library": "^3.0.0",
"react": "^18.2.0",
"strip-ansi": "^7.0.1",
"ts-node": "^10.9.1",
"typescript": "^5.0.2",
"xo": "^0.24.0"
"xo": "^0.53.1"
},
"peerDependencies": {
"ink": ">=2.0.0",
"react": ">=16.8.0"
},
"babel": {
"presets": [
"@ava/stage-4",
"@babel/preset-react"
]
"ink": ">=4",
"react": ">=18"
},
"xo": {
"extends": [
"xo-react"
],
"prettier": true,
"rules": {
"unicorn/no-hex-escape": "off",
"unicorn/filename-case": "off"
"unicorn/filename-case": "off",
"@typescript-eslint/naming-convention": "off"
}
},
"ava": {
Expand Down
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

## Install

```
$ npm install ink-big-text
```sh
npm install ink-big-text
```

## Usage
Expand Down
1 change: 1 addition & 0 deletions source/cfonts.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare module 'cfonts';
55 changes: 55 additions & 0 deletions source/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import React from 'react';
import {Text} from 'ink';
import CFonts from 'cfonts';

export type CFontProps = {
font:
| 'block'
| 'slick'
| 'tiny'
| 'grid'
| 'pallet'
| 'shade'
| 'simple'
| 'simpleBlock'
| '3d'
| 'simple3d'
| 'chrome'
| 'huge';
align: 'left' | 'center' | 'right';
colors: string[];
backgroundColor:
| 'transparent'
| 'black'
| 'red'
| 'green'
| 'yellow'
| 'blue'
| 'magenta'
| 'cyan'
| 'white';
letterSpacing: number;
lineHeight: number;
space: boolean;
maxLength: number;
};

export type BigTextProps = {text: string} & Partial<CFontProps>;

const defaultCFontProps: CFontProps = {
font: 'block',
align: 'left',
colors: ['system'],
backgroundColor: 'transparent',
letterSpacing: 1,
lineHeight: 1,
space: true,
maxLength: 0,
};

const BigText: React.FC<BigTextProps> = ({text, ...props}) => { // eslint-disable-line react/function-component-definition
const cFontProps = {...defaultCFontProps, ...props};
return <Text>{CFonts.render(text, cFontProps).string}</Text>; // eslint-disable-line @typescript-eslint/no-unsafe-call
};

export default BigText;
1 change: 0 additions & 1 deletion src/cfonts.d.ts

This file was deleted.

55 changes: 0 additions & 55 deletions src/index.tsx

This file was deleted.

21 changes: 11 additions & 10 deletions test/test.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import React from "react";
import test from "ava";
import { render } from "ink-testing-library";
import clearModule from "clear-module";
import stripAnsi from "strip-ansi";
import { BigText } from "../src/index.js";
import process from 'node:process';
import React from 'react';
import test from 'ava';
import {render} from 'ink-testing-library';
import clearModule from 'clear-module';
import stripAnsi from 'strip-ansi';
import BigText from '../source/index.js';

test("render", t => {
test('render', t => {
// TODO: Find out why this doesn't work to prevent color
process.env.FORCE_COLOR = "0";
process.env.FORCE_COLOR = '0';
clearModule.all();
// const BigText = require('.');
// Const BigText = require('.');

const { lastFrame } = render(<BigText text="unicorns" />);
const {lastFrame} = render(<BigText text='unicorns'/>);
console.log(lastFrame());
t.snapshot(stripAnsi(lastFrame()));

Expand Down
6 changes: 4 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
{
"extends": "@sindresorhus/tsconfig",
"compilerOptions": {
"outDir": "build",
"outDir": "dist",
"sourceMap": true,
"jsx": "react"
},
"include": ["src"],
"include": [
"source"
],
"ts-node": {
"transpileOnly": true,
"files": true
Expand Down

0 comments on commit 4ec4ebb

Please sign in to comment.