Skip to content

Commit

Permalink
version 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
stagas committed Jul 30, 2022
1 parent 87040a1 commit 154d67f
Show file tree
Hide file tree
Showing 18 changed files with 319 additions and 165 deletions.
3 changes: 3 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,18 @@ module.exports = {
ignorePatterns: ['dist', 'node_modules'],
plugins: ['import'],
rules: {
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-empty-interface': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-extra-semi': 'off',
'@typescript-eslint/no-inferrable-types': 'warn',
'@typescript-eslint/no-namespace': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-this-alias': 'off',
'@typescript-eslint/no-unused-vars': ['error', { args: 'all', argsIgnorePattern: '^_' }],
'@typescript-eslint/no-var-requires': 'off',
'no-cond-assign': 'off',
'no-empty': 'off',
},
}
8 changes: 7 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
* -linguist-detectable
bench/** linguist-detectable
src/** linguist-detectable
example/** linguist-detectable
test/** linguist-detectable
types/** linguist-detectable
*.ts linguist-language=TypeScript

*.html -linguist-detectable
2 changes: 0 additions & 2 deletions .prettierignore

This file was deleted.

9 changes: 0 additions & 9 deletions .prettierrc

This file was deleted.

44 changes: 41 additions & 3 deletions .pull-configs.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const fs = require('fs')
const { pullConfigs } = require('pull-configs')

const local = __dirname + '/'
Expand All @@ -6,14 +7,51 @@ const remote = 'https://github.com/stagas/typescript-minimal-template/raw/main/'
const { assign, omit, sort, merge, replace } = pullConfigs(remote, local)

merge('package.json', (prev, next) => {
assign(prev.scripts, omit(next.scripts, ['test']))
prev.trustedDependencies ??= []
prev.trustedDependencies = [
...new Set([...prev.trustedDependencies, ...(next.trustedDependencies ?? [])]),
].sort()
prev.types = next.types
prev.scripts = next.scripts
prev.files = next.files
sort(assign(prev.devDependencies, next.devDependencies))

// deprecated
delete prev.devDependencies['@stagas/documentation-fork']
delete prev.devDependencies['@rollup/plugin-commonjs']
delete prev.devDependencies['@stagas/sucrase-jest-plugin']
delete prev.devDependencies['@web/dev-server-esbuild']
delete prev.devDependencies['@web/dev-server-rollup']
delete prev.devDependencies['esbuild']
delete prev.devDependencies['esbuild-register']
delete prev.devDependencies['prettier']
delete prev.devDependencies['terser']
delete prev.devDependencies['vite-web-test-runner-plugin']
})
replace('.gitattributes')
replace('.gitignore')
replace('.npmrc')
replace('.eslintrc.js')
replace('.prettierrc')
replace('.pull-configs.js')
replace('.swcrc')
replace('dprint.json')
replace('jest.config.js')
replace('tsconfig.json')
replace('tsconfig.dist.json')
replace('web-test-runner.config.js')
merge('.vscode/settings.json')
replace('LICENSE')

const deprecated = [
'.vscode/extensions.json',
'.vscode',
'.prettierrc',
'.prettierignore',
'example/tsconfig.json',
'vite.config.js',
]
deprecated.forEach(x => {
try {
fs.rmSync(x, { recursive: true })
console.log('removed', x)
} catch {}
})
25 changes: 25 additions & 0 deletions .swcrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"jsc": {
"target": "es2022",
"parser": {
"syntax": "typescript",
"tsx": true,
"decorators": true,
"dynamicImport": true
},
"transform": {
"legacyDecorator": true,
"decoratorMetadata": true,
"useDefineForClassFields": true,
"react": {
"runtime": "automatic"
},
"hidden": {
"jest": true
}
},
"keepClassNames": true
},
"sourceMaps": true,
"inlineSourcesContent": true
}
13 changes: 0 additions & 13 deletions .vscode/extensions.json

This file was deleted.

12 changes: 0 additions & 12 deletions .vscode/settings.json

This file was deleted.

7 changes: 7 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright 2022 stagas

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
71 changes: 35 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,58 +1,57 @@
<h1 align="center">puppeteer-pretty-console</h1>
<h1>
puppeteer-pretty-console <a href="https://npmjs.org/package/puppeteer-pretty-console"><img src="https://img.shields.io/badge/npm-v1.0.0-F00.svg?colorA=000"/></a> <a href="src"><img src="https://img.shields.io/badge/loc-104-FFF.svg?colorA=000"/></a> <a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-F0B.svg?colorA=000"/></a>
</h1>

<p align="center">
helper that setups console output for puppeteer
</p>

<p align="center">
<a href="#install"> 🔧 <strong>Install</strong></a>
· <a href="#example"> 🧩 <strong>Example</strong></a>
· <a href="#api"> 📜 <strong>API docs</strong></a>
· <a href="https://github.com/stagas/puppeteer-pretty-console/releases"> 🔥 <strong>Releases</strong></a>
· <a href="#contribute"> 💪🏼 <strong>Contribute</strong></a>
· <a href="https://github.com/stagas/puppeteer-pretty-console/issues"> 🖐️ <strong>Help</strong></a>
</p>

***
<p></p>

## Install
helper that setups console output for puppeteer

```sh
$ npm i puppeteer-pretty-console
```
<h4>
<table><tr><td title="Triple click to select and copy paste">
<code>npm i puppeteer-pretty-console </code>
</td><td title="Triple click to select and copy paste">
<code>pnpm add puppeteer-pretty-console </code>
</td><td title="Triple click to select and copy paste">
<code>yarn add puppeteer-pretty-console</code>
</td></tr></table>
</h4>

## API

<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

#### Table of Contents

* [puppeteerPrettyConsole](#puppeteerprettyconsole)
* [Parameters](#parameters)
<p> <details id="puppeteerPrettyConsole$1" title="Function" ><summary><span><a href="#puppeteerPrettyConsole$1">#</a></span> <code><strong>puppeteerPrettyConsole</strong></code><em>(page, filter)</em> &ndash; Setups console output for a puppeteer page.</summary> <a href="src/index.ts#L31">src/index.ts#L31</a> <ul> <p> <p>

### puppeteerPrettyConsole

[src/index.ts:16-70](https://github.com/stagas/puppeteer-pretty-console/blob/78c2d042d7f76a39488abf73bf7e542437abdc75/src/index.ts#L16-L70 "Source code on GitHub")
```ts
const page = await browser.newPage()
puppeteerPrettyConsole(page)
```

Setups console output for a puppeteer page.
</p>
<details id="page$3" title="Parameter" ><summary><span><a href="#page$3">#</a></span> <code><strong>page</strong></code> &ndash; A puppeteer page instance created by browser.newPage()
</summary> <ul><p><span>Page</span></p> </ul></details><details id="filter$4" title="Function" ><summary><span><a href="#filter$4">#</a></span> <code><strong>filter</strong></code><em>(args)</em> </summary> <ul> <p> <details id="args$7" title="Parameter" ><summary><span><a href="#args$7">#</a></span> <code><strong>args</strong></code> </summary> <ul><p>any []</p> </ul></details> <p><strong>filter</strong><em>(args)</em> &nbsp;=&gt; <ul>any []</ul></p></p> </ul></details> <p><strong>puppeteerPrettyConsole</strong><em>(page, filter)</em> &nbsp;=&gt; <ul>void</ul></p></p> </ul></details><details id="print$8" title="Variable" ><summary><span><a href="#print$8">#</a></span> <code><strong>print</strong></code> <span><span>&nbsp;=&nbsp;</span> <code>...</code></span> </summary> <a href="src/index.ts#L17">src/index.ts#L17</a> <ul><p>any</p> </ul></details><details id="puppeteerPrettyConsole$1" title="Function" ><summary><span><a href="#puppeteerPrettyConsole$1">#</a></span> <code><strong>puppeteerPrettyConsole</strong></code><em>(page, filter)</em> &ndash; Setups console output for a puppeteer page.</summary> <a href="src/index.ts#L31">src/index.ts#L31</a> <ul> <p> <p>

```ts
const page = await browser.newPage()
puppeteerPrettyConsole(page)
```

#### Parameters
</p>
<details id="page$3" title="Parameter" ><summary><span><a href="#page$3">#</a></span> <code><strong>page</strong></code> &ndash; A puppeteer page instance created by browser.newPage()
</summary> <ul><p><span>Page</span></p> </ul></details><details id="filter$4" title="Function" ><summary><span><a href="#filter$4">#</a></span> <code><strong>filter</strong></code><em>(args)</em> </summary> <ul> <p> <details id="args$7" title="Parameter" ><summary><span><a href="#args$7">#</a></span> <code><strong>args</strong></code> </summary> <ul><p>any []</p> </ul></details> <p><strong>filter</strong><em>(args)</em> &nbsp;=&gt; <ul>any []</ul></p></p> </ul></details> <p><strong>puppeteerPrettyConsole</strong><em>(page, filter)</em> &nbsp;=&gt; <ul>void</ul></p></p> </ul></details></p>

## Credits

* `page` **Page** A puppeteer page instance created by browser.newPage()
- [@stagas/chalk](https://npmjs.org/package/@stagas/chalk) by [stagas](https://github.com/stagas) &ndash; Terminal string styling done right (+ CommonJS build)
- [apply-sourcemaps](https://npmjs.org/package/apply-sourcemaps) by [stagas](https://github.com/stagas) &ndash; Fetch and apply sourcemaps in logs and stack traces originating from the browser or puppeteer.
- [event-toolkit](https://npmjs.org/package/event-toolkit) by [stagas](https://github.com/stagas) &ndash; Toolkit for DOM events.
- [everyday-utils](https://npmjs.org/package/everyday-utils) by [stagas](https://github.com/stagas) &ndash; Everyday utilities
- [puppeteer](https://npmjs.org/package/puppeteer) by [The Chromium Authors](https://github.com/puppeteer) &ndash; A high-level API to control headless Chrome over the DevTools Protocol

## Contribute
## Contributing

[Fork](https://github.com/stagas/puppeteer-pretty-console/fork) or
[edit](https://github.dev/stagas/puppeteer-pretty-console) and submit a PR.
[Fork](https://github.com/stagas/puppeteer-pretty-console/fork) or [edit](https://github.dev/stagas/puppeteer-pretty-console) and submit a PR.

All contributions are welcome!

## License

MIT © 2021
[stagas](https://github.com/stagas)
<a href="LICENSE">MIT</a> &copy; 2022 [stagas](https://github.com/stagas)
31 changes: 31 additions & 0 deletions dprint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"indentWidth": 2,
"incremental": true,
"typescript": {
"arguments.trailingCommas": "never",
"arrowFunction.useParentheses": "preferNone",
"commentLine.forceSpaceAfterSlashes": false,
"jsx.quoteStyle": "preferDouble",
"quoteProps": "asNeeded",
"quoteStyle": "alwaysSingle",
"semiColons": "asi",
"useBraces": "maintain"
},
"json": {},
"markdown": {},
"includes": [
"**/*.{ts,tsx,js,jsx,cjs,mjs,json,md}"
],
"excludes": [
"node_modules/**/*",
"coverage/**/*",
"dist/**/*",
".swc/**/*",
".vscode/**/*"
],
"plugins": [
"https://unpkg.com/@stagas/dprint-plugin-typescript-binary/dprint_plugin_typescript.wasm@8114f452af5a7244132b68b7a04371467ff508c4d1b7d3cb9e3613921e333a7e",
"https://plugins.dprint.dev/json-0.15.3.wasm",
"https://plugins.dprint.dev/markdown-0.13.3.wasm"
]
}
51 changes: 25 additions & 26 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,40 @@
module.exports = {
testEnvironment: 'jsdom', // or node
testEnvironment: 'jsdom', // 'node'
rootDir: '.',
roots: ['<rootDir>/test/', '<rootDir>/src'],
testMatch: ['**/*.spec.{js,jsx,ts,tsx}'],
testPathIgnorePatterns: ['<rootDir>/node_modules/', '<rootDir>/test/web/'],
collectCoverageFrom: ['src/**/*.{ts,tsx}'],
coverageDirectory: '<rootDir>/coverage',
coveragePathIgnorePatterns: ['types'],
collectCoverageFrom: ['src/**/*.{ts,tsx}'],
coverageProvider: 'v8',

// enable this for real typescript builds (slow but accurate)
resolver: require.resolve('@stagas/jest-node-exports-resolver'),
// preset: 'ts-jest',

// enable this for fast, correct sourcemaps but not all features supported
// transform: {
// '\\.(js|jsx|ts|tsx)$': [
// '@stagas/sucrase-jest-plugin',
// {
// jsxPragma: 'h',
// jsxFragmentPragma: 'Fragment',
// production: true,
// disableESTransforms: true,
// },
// ],
// },

// enable this for fast, incorrect sourcemaps but more features supported

transform: {
'\\.(js|jsx|ts|tsx)$': [
'@swc-node/jest',
{
experimentalDecorators: true,
emitDecoratorMetadata: true,
react: {
pragma: 'h',
pragmaFrag: 'Fragment',
swc: {
jsc: {
target: 'es2022',
parser: {
syntax: 'typescript',
tsx: true,
decorators: true,
dynamicImport: true,
},
transform: {
legacyDecorator: true,
decoratorMetadata: true,
useDefineForClassFields: true,
react: {
runtime: 'automatic',
},
hidden: {
jest: true,
},
},
keepClassNames: true,
},
},
},
],
Expand Down
Loading

0 comments on commit 154d67f

Please sign in to comment.