Skip to content

Commit

Permalink
Fork to @KineticCafe and Typescript
Browse files Browse the repository at this point in the history
Convert to Typescript. The previous version produces TS2349 even though
the created type declaration file and the generated type declaration
file are more or less the same.

Signed-off-by: Austin Ziegler <[email protected]>
  • Loading branch information
halostatue committed Nov 29, 2023
1 parent 7e5a72c commit eeaacdc
Show file tree
Hide file tree
Showing 28 changed files with 3,639 additions and 5,597 deletions.
5 changes: 0 additions & 5 deletions .babelrc.js

This file was deleted.

4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
/dist
/lib
pnpm-lock.yaml
7 changes: 7 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
root: true,
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier'],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
rules: {},
}
11 changes: 0 additions & 11 deletions .eslintrc.js

This file was deleted.

11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 2
updates:
- package-ecosystem: npm
directory: /
schedule:
interval: monthly

- package-ecosystem: github-actions
directory: /
schedule:
interval: monthly
14 changes: 14 additions & 0 deletions .github/workflows/dco-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Check DCO

on:
pull_request:

jobs:
check-dco:
runs-on: ubuntu-latest
steps:
- uses: KineticCafe/[email protected]
with:
exempt-authors: |
@kineticcommerce.com
@kineticcafe.com
17 changes: 17 additions & 0 deletions .github/workflows/dependabot-automerge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Dependabot auto-merge

on:
pull_request:

permissions:
contents: write
pull-requests: write

jobs:
dependabot-automerge:
runs-on: ubuntu-latest

steps:
- uses: KineticCafe/actions/[email protected]
with:
update-type: minor
27 changes: 27 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Node.js Package

on:
push:
tags:
- v*

jobs:
package:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
with:
version: 8
# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v4
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
- run: pnpm install --frozen-lockfile --ignore-scripts
- run: pnpm run build
- run: pnpm exec publint
- run: pnpm test
- run: pnpm publish --ignore-scripts
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
35 changes: 35 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Node.js CI

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.x]
pnpm-version: [7, 8]

steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
with:
version: ${{ matrix.pnpm-version }}
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm run build
- run: pnpm run test
- run: |
pnpm run format:check || {
pnpm run format
git diff --exit-code
}
- run: pnpm run lint
- run: pnpm exec publint
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
node_modules
coverage
dist
/dist
/lib
3 changes: 3 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
auto-install-peers=true
dedupe-peer-dependents=true
use-lockfile-v6=true
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pnpm-lock.yaml
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"trailingComma": "es5",
"printWidth": 90,
"singleQuote": true,
"semi": false,
"useTabs": false
}
7 changes: 0 additions & 7 deletions .travis.yml

This file was deleted.

126 changes: 126 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
# @kineticcafe/rollup-plugin-delete

Delete files and folders using Rollup. This is a fork of the excellent
[rollup-plugin-delete][]. The changes are mostly:

- Convert to Typescript. The previous version produces TS2349 even though the
created type declaration file and the generated type declaration file are
more or less the same.

## About

This plugin is useful when you want to clean `dist` or other folders and files
before bundling. It's using [del][] internally, check it for pattern examples.

## Installation

```bash
# pnpm
pnpm install -D @kineticcafe/rollup-plugin-delete

# yarn
yarn add -D @kineticcafe/rollup-plugin-delete

# npm
npm install -D @kineticcafe/rollup-plugin-delete
```

## Usage

```js
// rollup.config.js
import { del } from '@kineticcafe/rollup-plugin-delete'

export default {
input: 'src/index.js',
output: {
file: 'dist/app.js',
format: 'cjs',
},
plugins: [del({ targets: 'dist/*' })],
}
```

You can also remove files after the bundle has been written:

```typescript
// vite.config.ts
import * as path from 'node:path'
import { defineConfig } from 'vite'
import { del } from '@kineticcafe/rollup-plugin-delete'

const deleteIndexHtml = () =>
del({
targets: path.resolve(__dirname, 'dist/index.html'),
hook: 'writeBundle',
})

export default defineConfig({
plugins: [deleteIndexHtml()],
})
```

### Configuration

There are some useful options:

#### `targets`

A string or an array of patterns of files and folders to be deleted. Default is
`[]`.

```js
del({ targets: 'dist/*' })

del({
targets: ['dist/*', 'build/*'],
})
```

#### `verbose`

Output removed files and folders to console. Default is `false`.

```js
del({
targets: 'dist/*',
verbose: true,
})
```

> Note: use \* (wildcard character) in pattern to show removed files
#### `hook`

The [Rollup hook](https://rollupjs.org/guide/en/#build-hooks) the plugin should
use. Default is `buildStart`.

```js
del({
targets: 'dist/*',
hook: 'buildEnd',
})
```

#### `runOnce`

Type: `boolean` | Default: `false`

Delete items once. Useful in watch mode.

```js
del({
targets: 'dist/*',
runOnce: true,
})
```

All other options are passed to [del
package](https://github.com/sindresorhus/del) which is used inside.

## License

MIT

[rollup-plugin-delete]: https://github.com/vladshcherbin/rollup-plugin-delete
[del]: https://github.com/sindresorhus/del
30 changes: 0 additions & 30 deletions index.d.ts

This file was deleted.

10 changes: 0 additions & 10 deletions jest.config.js

This file was deleted.

Loading

0 comments on commit eeaacdc

Please sign in to comment.