Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add proper wrapping for esm and Deno by updating dependencies #143

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,8 @@ jobs:
- run: npm install
env:
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true
- run: npm test
- run: npm run test
- run: npm run coverage
esm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 14
- run: npm install
- run: npm run test:esm
deno:
runs-on: ubuntu-latest
steps:
Expand Down
8 changes: 4 additions & 4 deletions deno.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Bootstrap cliui with CommonJS dependencies:
import { cliui, UI } from './build/lib/index.js'
import type { UIOptions } from './build/lib/index.d.ts'
import { wrap, stripAnsi } from './build/lib/string-utils.js'
import wrap from 'wrap-ansi'
import stripAnsi from 'strip-ansi'
import stringWidth from 'string-width'

export default function ui (opts: UIOptions): UI {
return cliui(opts, {
stringWidth: (str: string) => {
return [...str].length
},
stringWidth,
stripAnsi,
wrap
})
Expand Down
8 changes: 4 additions & 4 deletions index.mjs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// Bootstrap cliui with CommonJS dependencies:
import { cliui } from './build/lib/index.js'
import { wrap, stripAnsi } from './build/lib/string-utils.js'
import wrap from 'wrap-ansi'
import stripAnsi from 'strip-ansi'
import stringWidth from 'string-width'

export default function ui (opts) {
return cliui(opts, {
stringWidth: (str) => {
return [...str].length
},
stringWidth,
stripAnsi,
wrap
})
Expand Down
7 changes: 4 additions & 3 deletions lib/cjs.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// Bootstrap cliui with CommonJS dependencies:
import { cliui, UIOptions } from './index.js'
const stringWidth = require('string-width')
const stripAnsi = require('strip-ansi')
const wrap = require('wrap-ansi')
import stringWidth from 'string-width'
import wrap from 'wrap-ansi'
import stripAnsi from 'strip-ansi'

export default function ui (opts: UIOptions) {
return cliui(opts, {
stringWidth,
Expand Down
30 changes: 0 additions & 30 deletions lib/string-utils.ts

This file was deleted.

21 changes: 11 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@
"check": "standardx '**/*.ts' && standardx '**/*.js' && standardx '**/*.cjs'",
"fix": "standardx --fix '**/*.ts' && standardx --fix '**/*.js' && standardx --fix '**/*.cjs'",
"pretest": "rimraf build && tsc -p tsconfig.test.json && cross-env NODE_ENV=test npm run build:cjs",
"test": "c8 mocha ./test/*.cjs",
"test:esm": "c8 mocha ./test/esm/cliui-test.mjs",
"test": "c8 --exclude-after-remap mocha ./test/cjs/*.cjs ./test/esm/*.mjs",
"postest": "check",
"coverage": "c8 report --check-coverage",
"coverage": "c8 --exclude-after-remap report --check-coverage",
"precompile": "rimraf build",
"compile": "tsc",
"postcompile": "npm run build:cjs",
Expand Down Expand Up @@ -49,11 +48,13 @@
"author": "Ben Coe <[email protected]>",
"license": "ISC",
"dependencies": {
"string-width": "^4.2.0",
"strip-ansi": "^6.0.1",
"wrap-ansi": "^7.0.0"
"string-width": "^5.1.2",
"strip-ansi": "^7.0.1",
"wrap-ansi": "^8.1.0"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^22.0.2",
"@rollup/plugin-node-resolve": "^14.1.0",
"@types/node": "^14.0.27",
"@typescript-eslint/eslint-plugin": "^4.0.0",
"@typescript-eslint/parser": "^4.0.0",
Expand All @@ -65,12 +66,12 @@
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-node": "^11.1.0",
"gts": "^3.0.0",
"mocha": "^10.0.0",
"mocha": "^9.2.2",
"rimraf": "^3.0.2",
"rollup": "^2.23.1",
"rollup-plugin-ts": "^3.0.2",
"rollup": "^2.79.1",
"rollup-plugin-ts": "^2.0.7",
"standardx": "^7.0.0",
"typescript": "^4.0.0"
"typescript": "4.6.4"
},
"files": [
"build",
Expand Down
10 changes: 9 additions & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import ts from 'rollup-plugin-ts'
import nodeResolve from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'

// These two transient dependencies are still CommonJS:
// 'node_modules/emoji-regex/index.js',
// 'node_modules/eastasianwidth/eastasianwidth.js'

const output = {
format: 'cjs',
Expand All @@ -12,6 +18,8 @@ export default {
input: './lib/cjs.ts',
output,
plugins: [
ts({ /* options */ })
ts({ /* options */ }),
nodeResolve(),
commonjs()
]
}
4 changes: 4 additions & 0 deletions test/cjs/cliui-test.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const { runTests } = require('../shared-tests.cjs')
const cliui = require('../../build/index.cjs')

runTests(cliui, 'CJS')
Loading
Loading