![Introducing Enhanced Alert Actions and Triage Functionality](https://cdn.sanity.io/images/cgdhsj6q/production/fe71306d515f85de6139b46745ea7180362324f0-2530x946.png?w=800&fit=max&auto=format)
Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
add-dist-header
Advanced tools
Readme
<img src=https://centerkey.com/graphics/center-key-logo.svg align=right width=200 alt=logo>
Prepend a one-line banner comment (with license notice) to distribution files
add-dist-header uses the name
, homepage
, and license
from your project's package.json
file to create a header comment and prepend it to a build file.
<img src=https://raw.githubusercontent.com/center-key/add-dist-header/main/screenshot.png width=800 alt=screenshot>
Example header comment for a .js file:
//! my-app v3.1.4 ~~ https://github.com/my-org/my-app ~~ MIT License
Example header comment for a .css file:
/*! my-app v3.1.4 ~~ https://github.com/my-org/my-app ~~ MIT License */
Automatically prepending headers to distribution files is particularly handy when your build
tools are configured to remove comments (such as if "removeComments": true
in set
in tsconfig.json).
For a real-world example, see the files in the dist folder at
w3c-html-validator
Install package for node:
$ npm install --save-dev add-dist-header
Run dist-header
from the "scripts"
section of your package.json file.
Parameters:
"build/*"
)."dist"
).Example package.json script:
"scripts": {
"add-headers": "add-dist-header build dist"
},
You can install add-dist-header globally and then run it anywhere directly from the terminal.
Example terminal commands:
$ npm install --global add-dist-header
$ add-dist-header "build" "dist"
[17:13:50] add-dist-header build/my-app.d.ts --> dist/my-app.d.ts (413.11 KB)
[17:13:51] add-dist-header build/my-app.js --> dist/my-app.js (1,569.70 KB)
The parameters are optional:
$ add-dist-header #same as above since "build/*" "dist" are the default parameter values
[17:13:50] add-dist-header build/my-app.d.ts --> dist/my-app.d.ts (413.11 KB)
[17:13:51] add-dist-header build/my-app.js --> dist/my-app.js (1,569.70 KB)
$ add-dist-header "meta/config.js" #creates "dist/config.js" prepended with header
[17:15:03] add-dist-header meta/config.js --> dist/config.js (3.91 KB)
Command-line flags:
Flag | Description | Values | Default |
---|---|---|---|
--delimiter | Characters separating the parts of the header comment. | string | ~~ |
--keep-first | Do not delete the original first line comment. | N/A | N/A |
--no-version | Do not substitute occurrences of {{pkg.version}} with the package.json version number. | N/A | N/A |
--note | Place to add a comment only for humans. | string | N/A |
--quiet | Suppress informational messages. | N/A | N/A |
--recursive | Include subfolders for the source folder. | N/A | N/A |
In addition to prepending the header comment, add-dist-header also replaces all occurrences of
{{pkg.version}}
in each file with the version number found in package.json.
This enables inserting the current package version number into your distribution files.
The substitution feature is disabled with the --no-version
flag.
Examples:
add-dist-header build/minimized dist
Copy the files in the build/minimized folder to the dist folder and add comment headers.
add-dist-header build dist --no-version --delimiter=🔥
Add comment headers but do not substitute the version number and use "🔥" as the separator in the header comment instead of "~~".
add-dist-header build dist --recursive
Include the subfolders of build.
Even though add-dist-header is primarily intended for build scripts, the package can easily be used programmatically in ESM and TypeScript projects.
Example:
import { addDistHeader } from 'add-dist-header';
const options = {
dist: 'dist',
delimiter: '🚀🚀🚀',
};
const result = addDistHeader.prepend('build/rocket.js', options);
console.log('The size of the new file is:', result.size);
See the TypeScript Declarations at the top of add-dist-header.ts for documentation.
CLI Build Tools
Feel free to submit questions at:
github.com/center-key/add-dist-header/issues
FAQs
Prepend a one-line banner comment (with license notice) to distribution files
The npm package add-dist-header receives a total of 40 weekly downloads. As such, add-dist-header popularity was classified as not popular.
We found that add-dist-header demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.