Skip to content

Commit

Permalink
Use tsup for builds (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
PondWader authored Nov 3, 2024
1 parent a536de0 commit 501669c
Show file tree
Hide file tree
Showing 12 changed files with 1,252 additions and 34 deletions.
1,231 changes: 1,222 additions & 9 deletions package-lock.json

Large diffs are not rendered by default.

19 changes: 12 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
{
"name": "picospinner",
"version": "1.0.1",
"main": "./dist/index.js",
"type": "commonjs",
"type": "module",
"exports": {
"import": "./dist/index.js",
"require": "./dist/index.cjs"
},
"types": "./dist/index.d.ts",
"author": "PondWader",
"description": "A lightweight, no dependency, pluggable CLI spinner library.",
"scripts": {
"build": "tsc",
"build": "tsup ./src/index.ts --format cjs,esm --dts --minify",
"format": "prettier --write src",
"test": "tsc && npm run build && c8 --exclude-after-remap node --test",
"test": "tsc && c8 --exclude-after-remap node --test",
"lint": "npm run lint:format && eslint src",
"lint:format": "prettier --check src",
"bench": "tsc && node ./bench/string-width.mjs"
},
"files": [
"dist",
"!dist/test",
"!**/*.map"
"./dist/index.js",
"./dist/index.cjs",
"./dist/index.d.ts",
"./dist/index.d.cts"
],
"keywords": [
"spinner",
Expand All @@ -41,6 +45,7 @@
"prettier": "^3.3.2",
"string-width": "^7.2.0",
"tinybench": "^2.8.0",
"tsup": "^8.3.5",
"typescript": "^5.5.2",
"typescript-eslint": "^7.14.1"
}
Expand Down
2 changes: 1 addition & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Symbols} from '.';
import {Symbols} from './index.js';

export const DEFAULT_FRAMES = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
export const DEFAULT_TICK_MS = 50;
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as constants from './constants';
import {Renderer, TextComponent} from './renderer';
import * as constants from './constants.js';
import {Renderer, TextComponent} from './renderer.js';

export type Formatter = (input: string) => string;

Expand Down
4 changes: 2 additions & 2 deletions src/renderer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as constants from './constants';
import {countLines} from './string-lines';
import * as constants from './constants.js';
import {countLines} from './string-lines.js';

export class TextComponent {
onChange?: () => void;
Expand Down
2 changes: 1 addition & 1 deletion src/string-lines.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {getStringWidth} from './string-width';
import {getStringWidth} from './string-width.js';

export function countLines(str: string, maxWidth: number) {
const lines = str.split('\n');
Expand Down
2 changes: 1 addition & 1 deletion src/string-width.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// A javascript port of wcswidth based on https://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c with modification for emojis and not returning -1 for control characters

import {Intervals, nonSpacing} from './string-chars';
import {Intervals, nonSpacing} from './string-chars.js';

const EMOJI_REGEX = /(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F)(?:\u200d(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F))*/uy;
const ANSI_REGEX = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y;
Expand Down
6 changes: 3 additions & 3 deletions src/test/renderer-test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {test} from 'node:test';
import {Renderer, TextComponent} from '../renderer';
import {Renderer, TextComponent} from '../renderer.js';
import * as assert from 'node:assert/strict';
import {interceptStdout, suppressStdout} from './utils';
import * as constants from '../constants';
import {interceptStdout, suppressStdout} from './utils.js';
import * as constants from '../constants.js';

test('TextComponent', async (t) => {
const component = new TextComponent('lorem ipsum dolor');
Expand Down
4 changes: 2 additions & 2 deletions src/test/spinner-test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as assert from 'node:assert/strict';
import {test} from 'node:test';
import {Spinner, Symbols, renderer} from '..';
import {Spinner, Symbols, renderer} from '../index.js';
import {createFinishingRenderedLine, createRenderedLine, createRenderedOutput, interceptStdout, TickMeasuredSpinner} from './utils.js';
import * as constants from '../constants';
import * as constants from '../constants.js';

async function testEndMethod(method: keyof Symbols, type: 'str' | 'obj', customSymbol?: string) {
renderer._reset();
Expand Down
4 changes: 2 additions & 2 deletions src/test/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import capcon from 'capture-console';
import * as constants from '../constants';
import * as constants from '../constants.js';
import {isAbsolute} from 'path';
import {DisplayOptions, Spinner, Symbols} from '..';
import {DisplayOptions, Spinner, Symbols} from '../index.js';

export function createRenderedOutput(components: {symbol: string; text: string}[], firstLine = false, prevLines = -1) {
let out = (!firstLine ? (constants.CLEAR_LINE + constants.UP_LINE).repeat(prevLines === -1 ? components.length : prevLines) : '') + constants.CLEAR_LINE + constants.HIDE_CURSOR;
Expand Down
4 changes: 2 additions & 2 deletions src/test/width-test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as assert from 'node:assert/strict';
import test from 'node:test';
import {getStringWidth} from '../string-width';
import {countLines} from '../string-lines';
import {getStringWidth} from '../string-width.js';
import {countLines} from '../string-lines.js';

// Test cases taken from https://github.com/fabiospampinato/fast-string-truncated-width/blob/master/test/index.js

Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
/* Visit https://aka.ms/tsconfig.json to read more about this file */
/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "es2022" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2021', or 'ESNEXT'. */,
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */,
"target": "ES2022" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2021', or 'ESNEXT'. */,
"module": "ES2022" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */,
// "lib": [], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
Expand Down

0 comments on commit 501669c

Please sign in to comment.