Skip to content

Commit 4a45d06

Browse files
committed
Initial commit
0 parents  commit 4a45d06

File tree

17 files changed

+2942
-0
lines changed

17 files changed

+2942
-0
lines changed

.denolint.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"files": {
3+
"exclude": [
4+
"test/fixtures",
5+
"test/snapshots"
6+
]
7+
},
8+
"rules": {
9+
"tags": ["recommended"]
10+
}
11+
}

.editorconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true

.github/workflows/ci.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Test or Release
2+
3+
on:
4+
- push
5+
- pull_request
6+
7+
jobs:
8+
test-or-release:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout Sources
12+
uses: actions/checkout@v3
13+
- name: Install Node
14+
uses: actions/setup-node@v3
15+
with:
16+
node-version: 'lts/*'
17+
registry-url: 'https://registry.npmjs.org'
18+
- name: Install PNPM
19+
uses: pnpm/action-setup@v2
20+
with:
21+
version: latest
22+
run_install: |
23+
- args: [--frozen-lockfile, --no-verify-store-integrity]
24+
- name: Test
25+
run: npm test
26+
- name: Coverage
27+
uses: codecov/codecov-action@v3
28+
- name: Publish
29+
uses: cycjimmy/semantic-release-action@v3
30+
with:
31+
semantic_version: 19
32+
branches: master
33+
env:
34+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.DS_Store
2+
*.log
3+
*.map
4+
/lib/index.cjs
5+
node_modules

.vscode/launch.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"type": "node",
9+
"request": "launch",
10+
"name": "tests",
11+
"program": "${workspaceFolder}/test/index.js",
12+
"skipFiles": [
13+
"<node_internals>/**"
14+
]
15+
},
16+
17+
]
18+
}

.vscode/settings.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"files.exclude": {
3+
"**/.git": true,
4+
"**/.DS_Store": true
5+
},
6+
"search.exclude": {
7+
"**/node_modules": true,
8+
"pnpm-lock.yaml": true
9+
}
10+
}

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# 1.0.0 (2023-05-04)
2+
3+
Initial release

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 Ferdinand Prantl
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# rollup-plugin-write-only-changes
2+
3+
[![Latest version](https://img.shields.io/npm/v/rollup-plugin-write-only-changes)
4+
![Dependency status](https://img.shields.io/librariesio/release/npm/rollup-plugin-write-only-changes)
5+
](https://www.npmjs.com/package/rollup-plugin-write-only-changes)
6+
7+
A [Rollup] Rollup plugin for writing files to the output directoriy only if their contents actually changed.
8+
9+
## Requirements
10+
11+
This plugin requires [Node.js] [LTS] (currently 18, at least 14.8) and Rollup 1.20 or newer.
12+
13+
## Installation
14+
15+
Using npm:
16+
17+
npm i -D rollup-plugin-write-only-changes
18+
19+
## Usage
20+
21+
Create a `rollup.config.js` [configuration file] and import the plugin:
22+
23+
```js
24+
import { writeOnlyChanges } from 'rollup-plugin-write-only-changes';
25+
26+
export default {
27+
input: 'src/index.js',
28+
output: {
29+
dir: 'output',
30+
format: 'cjs'
31+
},
32+
plugins: [writeOnlyChanges()]
33+
}
34+
```
35+
36+
Then call `rollup` either via the [command-line] or the [programmatically].
37+
38+
## Options
39+
40+
The plugin can be customised by the following options, which can be passed as an object with the properties below.
41+
42+
### `verbose`
43+
44+
Type: `boolean` | `{ missing, failing, existed, created, changed, intact }`<br>
45+
Default: `{ failing: true }`
46+
47+
Logging configuration. All cases can be enabled by `true` and disabled
48+
by `false`. ingle cases are selectable by specifying an object with
49+
the following boolean properties, which are `false` by default,
50+
except for `failing`, which `true` by default:
51+
52+
* `missing`: Log files, which were missing in the output directory.
53+
* `failing`: Log files, which failed when they tried to be read from the output directory.
54+
* `existed`: Log files, which already existed in the output directory and were read.
55+
* `created`: Log files, which had to be created in the output directory,
56+
because they did not exist there.
57+
* `changed`: Log files, which had to be rewritten in the output directory,
58+
because their content was different.
59+
* `intact`: Log files, which did not have to be rewritten in the output directory,
60+
because their content remained the same.
61+
62+
### `rebuild`
63+
64+
Type: `boolean`<br>
65+
Default: `false`
66+
67+
If the output files should be forcibly written at least once, when rollup
68+
starts and the project is built at first, before the watcher starts.
69+
70+
## Contributing
71+
72+
In lieu of a formal styleguide, take care to maintain the existing coding style. Lint and test your code.
73+
74+
## License
75+
76+
Copyright (C) 2023 Ferdinand Prantl
77+
78+
Licensed under the [MIT License].
79+
80+
[MIT License]: http://en.wikipedia.org/wiki/MIT_License
81+
[Rollup]: https://rollupjs.org/
82+
[Node.js]: https://nodejs.org/
83+
[LTS]: https://github.com/nodejs/Release
84+
[configuration file]: https://www.rollupjs.org/guide/en/#configuration-files
85+
[command-line]: https://www.rollupjs.org/guide/en/#command-line-reference
86+
[programmatically]: https://www.rollupjs.org/guide/en/#javascript-api

lib/index.d.ts

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import { Plugin } from 'rollup'
2+
3+
export interface WriteOnlyChangesLogOptions {
4+
/**
5+
* Log files, which were missing in the output directory.
6+
* @default false
7+
*/
8+
missing?: boolean
9+
10+
/**
11+
* Log files, which failed when they tried to be read from the output directory.
12+
* @default true
13+
*/
14+
failing?: boolean
15+
16+
/**
17+
* Log files, which already existed in the output directory and were read.
18+
* @default false
19+
*/
20+
existed?: boolean
21+
22+
/**
23+
* Log files, which had to be created in the output directory,
24+
* because they did not exist there.
25+
* @default false
26+
*/
27+
created?: boolean
28+
29+
/**
30+
* Log files, which had to be rewritten in the output directory,
31+
* because their content was different.
32+
* @default false
33+
*/
34+
changed?: boolean
35+
36+
/**
37+
* Log files, which did not have to be rewritten in the output directory,
38+
* because their content remained the same.
39+
* @default false
40+
*/
41+
intact?: boolean
42+
}
43+
44+
export interface PluginWriteOnlyChangesOptions {
45+
/**
46+
* Logging configuration. All cases can be enabled by `true` and disabled
47+
* by `false`. ingle cases are selectable by specifying an object
48+
* with `PluginWriteOnlyChangesLogOptions`.
49+
* @default { failing: true }
50+
*/
51+
verbose?: boolean | WriteOnlyChangesLogOptions
52+
53+
/**
54+
* If the output files should be forcibly written at least once, when rollup
55+
* starts and the project is built at first, before the watcher starts.
56+
* @default false
57+
*/
58+
rebuild?: boolean
59+
}
60+
61+
/**
62+
* Converts .json (JSON/CJSON/JSON5) files to ES6 modules.
63+
*/
64+
export function writeOnlyChanges(options?: PluginWriteOnlyChangesOptions): Plugin

0 commit comments

Comments
 (0)