UNPKG

copyright-updater

Version:

A lightweight CLI tool that automatically updates copyright years in your project files โ€” with support for custom formats and ranges.

140 lines (90 loc) โ€ข 3.58 kB
# ๐Ÿ“… copyright-updater A lightweight and customizable utility to auto-generate or update copyright years in your projects. Supports multiple formats, including custom ranges โ€” perfect for open-source projects, websites, and professional applications. --- ## โœจ Features - โœ… Auto-generates dynamic copyright year ranges - ๐Ÿง  Smart format selection (`minimal`, `ranged`, `full`, etc.) - ๐Ÿ“† `ranged` & `copyright-ranged` now accept **optional end year** - ๐Ÿงฉ `modified` format enforces manual range - โš™๏ธ Lightweight and dependency-free - ๐Ÿ› ๏ธ Works in both JavaScript and Node.js environments --- ## ๐Ÿ“ฆ Installation ```bash npm install copyright-updater ``` Or for testing locally with symlink: ```bash npm link ``` --- ## ๐Ÿš€ Usage ### 1. Minimal Format ```js import cpUpdate from "copyright-updater"; console.log(cpUpdate("minimal", 2020)); // Output: ยฉ 2020 - 2025 (or current year) ``` --- ### 2. Ranged Format ```js console.log(cpUpdate("ranged", 2018)); // Output: ยฉ 2018 - 2025 console.log(cpUpdate("ranged", 2018, 2030)); // Output: ยฉ 2018 - 2030 ``` --- ### 3. Copyright-Ranged ```js console.log(cpUpdate("copyright-ranged", 2019)); // Output: Copyright 2019 - 2025 console.log(cpUpdate("copyright-ranged", 2019, 2029)); // Output: Copyright 2019 - 2029 ``` --- ### 4. Modified Format (Strict) ```js console.log(cpUpdate("modified", 2015, 2022)); // Output: Copyright 2015 - 2022 ``` > โš ๏ธ This format **requires both** `startYear` and `endYear`. If either is missing, an error is thrown. --- ### 5. Full Format (Default fallback) ```js console.log(cpUpdate("full", 2025)); // Output: Copyright 2025 ``` --- ## ๐Ÿ”ค Available Formats | Format | Description | Example Output | |-------------------|----------------------------------------------------|-----------------------------------| | `minimal` | Symbol + smart range (`ยฉ`) | `ยฉ 2020 - 2025` | | `ranged` | Accepts optional end year | `ยฉ 2018 - 2030` or `ยฉ 2018 - 2025`| | `copyright-ranged` | Same as `ranged`, but with `"Copyright"` label | `Copyright 2018 - 2025` | | `full` *(default)* | Smart single or ranged year with `"Copyright"` | `Copyright 2025` or `2020 - 2025` | | `modified` | Manual range, **requires both** start & end years | `Copyright 2018 - 2030` | --- ## ๐Ÿง  API ### `cpUpdate(format, startYear, endYear?)` | Param | Type | Required | Description | |-------------|--------|----------|-----------------------------------------| | `format` | string | โœ… | One of the predefined format types | | `startYear` | number | โœ… | Start year of the copyright | | `endYear` | number | โŒ | Used only in `ranged`, `copyright-ranged`, and `modified` | --- ## ๐Ÿ›‘ Error Handling If `modified` format is used without `endYear`, you'll get: ```bash Error: Both startYear and endYear are required for 'modified' format. ``` --- ## ๐Ÿงช Coming Soon * [ ] CLI Support (e.g. `npx copyright-updater`) * [ ] Auto-update license headers across files * [ ] Config-based year override --- ## ๐Ÿ‘จโ€๐Ÿ’ป Author Created with โค๏ธ by [Harpreet Singh](https://github.com/HarpreetSingh792) --- ## ๐Ÿ“„ License [ISC](./LICENSE)