Skip to content

Commit

Permalink
refactor!: update repo
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Nov 17, 2023
1 parent 7834861 commit e7d217c
Show file tree
Hide file tree
Showing 31 changed files with 5,161 additions and 5,035 deletions.
8 changes: 5 additions & 3 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"extends": [
"@nuxtjs/eslint-config-typescript"
]
"extends": ["eslint-config-unjs"],
"rules": {
"unicorn/prevent-abbreviations": 0,
"unicorn/no-null": 0
}
}
20 changes: 11 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@ on:
jobs:
ci:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v2
- uses: actions/checkout@v4
- run: corepack enable
- uses: actions/setup-node@v4
with:
node-version: '16'
cache: yarn
- run: yarn install
- run: yarn prepack
- run: yarn lint
- run: npx node ./node_modules/.bin/mocha ./test/*.test.*
node-version: 18
cache: "pnpm"
- run: pnpm install
- run: pnpm lint
- run: pnpm build
- run: pnpm test:types
- run: pnpm mocha ./test/*.test.*
# - uses: codecov/codecov-action@v3
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/node_modules
/dist
test/**/dist
pnpm-lock.yaml
Empty file added .prettierrc
Empty file.
389 changes: 144 additions & 245 deletions CHANGELOG.md

Large diffs are not rendered by default.

35 changes: 18 additions & 17 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
Copyright JS Foundation and other contributors
MIT License

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:
Copyright (c) Pooya Parsa <pooya@pi0.io>

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
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 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.
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.
49 changes: 20 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
[![Standard JS][standard-js-src]][standard-js-href]
[![npm version][npm-version-src]][npm-version-href]
[![npm downloads][npm-downloads-src]][npm-downloads-href]
[![package phobia][package-phobia-src]][package-phobia-href]
[![github actions][checks-src]][checks-href]


<div align="center">
<!-- replace with accurate logo e.g from https://worldvectorlogo.com/ -->
<img width="200" height="200" hspace="25" src="./assets/logo.svg">
Expand Down Expand Up @@ -61,49 +59,50 @@ Then add the reporter as a plugin to your webpack config.
**webpack.config.js**

```js
const webpack = require('webpack');
const WebpackBar = require('webpackbar');
const webpack = require("webpack");
const WebpackBar = require("webpackbar");

module.exports = {
context: path.resolve(__dirname),
devtool: 'source-map',
entry: './entry.js',
devtool: "source-map",
entry: "./entry.js",
output: {
filename: './output.js',
path: path.resolve(__dirname)
filename: "./output.js",
path: path.resolve(__dirname),
},
plugins: [
new WebpackBar()
]
plugins: [new WebpackBar()],
};
```

<h2 align="center">Options</h2>

### `name`
- Default: `webpack`

- Default: `webpack`

Name.

### `color`
- Default: `green`

- Default: `green`

Primary color (can be HEX like `#xxyyzz` or a web color like `green`).

### `profile`
- Default: `false`

- Default: `false`

Enable profiler.

### `fancy`

- Default: `true` when not in CI or testing mode.
- Default: `true` when not in CI or testing mode.

Enable bars reporter.

### `basic`

- Default: `true` when running in minimal environments.
- Default: `true` when running in minimal environments.

Enable a simple log reporter (only start and end).

Expand All @@ -112,7 +111,8 @@ Enable a simple log reporter (only start and end).
Register a custom reporter.

### `reporters`
- Default: `[]`

- Default: `[]`

Register an Array of your custom reporters. (Same as `reporter` but array)

Expand Down Expand Up @@ -158,36 +158,27 @@ A reporter should be instance of a class or plain object and functions for speci

`context` is the reference to the plugin. You can use `context.state` to access status.


**Schema of `context.state`:**

```js
{
start,
progress,
message,
details,
request,
hasErrors
start, progress, message, details, request, hasErrors;
}
```

<h2 align="center">License</h2>

MIT - Made with 💖 By Nuxt.js team!
[MIT](./LICENSE)

<!-- Refs -->

[standard-js-src]: https://flat.badgen.net/badge/code%20style/standard/green
[standard-js-href]: https://standardjs.com

[npm-version-src]: https://flat.badgen.net/npm/v/webpackbar/latest
[npm-version-href]: https://npmjs.com/package/webpackbar

[npm-downloads-src]: https://flat.badgen.net/npm/dm/webpackbar
[npm-downloads-href]: https://npmjs.com/package/webpackbar

[package-phobia-src]: https://flat.badgen.net/packagephobia/install/webpackbar
[package-phobia-href]: https://packagephobia.now.sh/result?p=webpackbar

[checks-src]: https://flat.badgen.net/github/checks/nuxt-contrib/webpackbar/master
[checks-href]: https://github.com/nuxt-contrib/webpackbar/actions
18 changes: 8 additions & 10 deletions build.config.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { defineBuildConfig } from 'unbuild'
import { defineBuildConfig } from "unbuild";

export default defineBuildConfig({
declaration: true,
emitCJS: true,
inlineDependencies: true,
entries: [
'src/index'
],
externals: [
'webpack'
]
})
rollup: {
emitCJS: true,
inlineDependencies: true,
},
entries: ["src/index"],
externals: ["webpack"],
});
46 changes: 24 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,36 +15,38 @@
"dist"
],
"scripts": {
"build": "unbuild",
"dev": "webpack --config ./playground/webpack.config.cjs",
"lint": "eslint --ext .ts,.mjs",
"lint": "eslint --ext .ts,.mjs . && prettier -c .",
"lint:fix": "eslint --fix --ext .ts,.mjs . && prettier -w .",
"prepack": "unbuild",
"release": "yarn test && standard-version && npm publish && git push --follow-tags",
"test": "yarn lint && mocha ./test/*.test.*"
"release": "pnpm test && changelogen --release && npm publish && git push --follow-tags",
"test": "pnpm lint && mocha ./test/*.test.*"
},
"dependencies": {
"chalk": "^4.1.2",
"ansi-escapes": "^6.2.0",
"chalk": "^5.3.0",
"consola": "^3.2.3",
"figures": "^6.0.1",
"markdown-table": "^3.0.3",
"pretty-time": "^1.1.0",
"std-env": "^3.3.3"
"std-env": "^3.5.0",
"wrap-ansi": "^9.0.0"
},
"devDependencies": {
"markdown-table": "^3.0.3",
"figures": "^4.0.1",
"ansi-escapes": "^5.0.0",
"wrap-ansi": "^8.1.0",
"@nuxtjs/eslint-config-typescript": "latest",
"@types/mocha": "^9.1.1",
"@types/node": "latest",
"codecov": "latest",
"eslint": "latest",
"jiti": "latest",
"memory-fs": "latest",
"mocha": "latest",
"standard-version": "latest",
"typescript": "latest",
"unbuild": "latest",
"webpack": "latest",
"webpack-cli": "latest"
"@types/mocha": "^10.0.4",
"@types/node": "^20.9.1",
"changelogen": "^0.5.5",
"eslint": "^8.53.0",
"eslint-config-unjs": "^0.2.1",
"jiti": "^1.21.0",
"memory-fs": "^0.5.0",
"mocha": "^10.2.0",
"prettier": "^3.1.0",
"typescript": "^5.2.2",
"unbuild": "^2.0.0",
"webpack": "^5.89.0",
"webpack-cli": "^5.1.4"
},
"peerDependencies": {
"webpack": "3 || 4 || 5"
Expand Down
9 changes: 4 additions & 5 deletions playground/index.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* eslint-disable */

import 'chalk';
import 'eslint';
import 'standard-version';
// eslint-disable-next-line unicorn/import-style
import "chalk";
import "eslint";
import "standard-version";
26 changes: 13 additions & 13 deletions playground/webpack.config.cjs
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
const path = require('path')
const WebpackBar = require('webpackbar')
const path = require("node:path");
const WebpackBar = require("webpackbar");

// let lastProgress;

const config = (name, color) => ({
mode: 'production',
mode: "production",
context: __dirname,
devtool: false,
target: 'node',
entry: './index.mjs',
target: "node",
entry: "./index.mjs",
stats: false,
output: {
filename: './output.cjs',
path: path.join(__dirname, '/dist')
filename: "./output.cjs",
path: path.join(__dirname, "/dist"),
},
module: {
rules: [{ test: /\.js$/, use: path.resolve(__dirname, 'test-loader.cjs') }]
rules: [{ test: /\.js$/, use: path.resolve(__dirname, "test-loader.cjs") }],
},
plugins: [
new WebpackBar({
color,
name,
reporters: ['fancy']
reporters: ["fancy"],
// reporter: {
// progress ({ state }) {
// if (lastProgress !== state.progress && state.progress % 5 === 0) {
Expand All @@ -30,8 +30,8 @@ const config = (name, color) => ({
// }
// }
// }
})
]
})
}),
],
});

module.exports = [config('OrangeBar', 'orange'), config('GreenBar', 'green')]
module.exports = [config("OrangeBar", "orange"), config("GreenBar", "green")];
Loading

0 comments on commit e7d217c

Please sign in to comment.