dev-stamp
TypeScript icon, indicating that this package has built-in type declarations

1.2.0ย โ€ขย Publicย โ€ขย Published
Dev Stamp logo

Dev Stamp

โœจ Stamp your dev footprint into HTML


npm version npm downloads MIT License
SonarQube Quality Gate Mutation testing badge

๐Ÿ“œ Table of Contents


๐Ÿ’ฎ What is Dev Stamp?

Dev Stamp is a tiny โšก๏ธ zero-config tool that lets you inject custom content (like build time, version, commit hash, or even a fun signature) right into the HTML of your project, anywhere.

๐Ÿ‘‰ Choose your injection mode: a comment in the body tag or a meta tag in the head section.

Whether you're building apps, sites, or web widgets โ€“ Dev Stamp leaves your dev mark with style ๐Ÿ’ฎ.


๐ŸŽฏ Use Cases

  • โœ๏ธ Add your personal touch to your projects
  • ๐Ÿงช Debug production issues faster with visible build info
  • ๐Ÿชช Watermark internal tools or preprod environments
  • ๐Ÿ› ๏ธ Keep track of your builds in a fun way

๐Ÿ”ฅ Why You'll Love It

  • ๐Ÿชถ Ultra-lightweight โ€“ less than 5KB, no dependencies
  • โš™๏ธ Zero-config โ€“ works out of the box, but easily customizable
  • ๐Ÿ’ฌ Inject anything, anywhere โ€“ version, build date, Git SHA, or your custom message anywhere in the HTML
  • ๐Ÿ› ๏ธ Tool-agnostic โ€“ fits into any build process, no matter the stack
  • ๐Ÿง™โ€โ™‚๏ธ Magical simplicity โ€“ one function, one job, done right

๐Ÿš€ Quick Examples

๐Ÿ’ฌ Inject a Comment

import { stampInHtml } from 'dev-stamp';

stampInHtml("๐Ÿ’ฎ Made with love by [Your Name]");

โฌ‡๏ธ This adds a comment at the end of the body tag in your HTML.

<html lang="en">
  <head>
    <title>My Project</title>
  </head>
  <body>
    <h1>Hello, World!</h1>
    <!--๐Ÿ’ฎ Made with love by [Your Name]-->
  </body>
</html>

For more options, please refer to the Advanced Usage section.

๐Ÿช„ Inject a Meta Tag

import { stampInHtml } from 'dev-stamp';

stampInHtml("๐Ÿš€ Project version 1.0.0", {
  mode: "meta-tag",
});

โฌ‡๏ธ This adds a meta-tag at the end of the head tag in your HTML.

<html lang="en">
  <head>
    <title>My Project</title>
    <meta name="dev-stamp" content="๐Ÿš€ Project version 1.0.0">
  </head>
  <body>
    <h1>Hello, World!</h1>
  </body>
</html>

For more options, please refer to the Advanced Usage section.


๐Ÿ“ฆ Installation

If you're using npm, yarn, or pnpm, you can install Dev Stamp with the following command:

npm i dev-stamp --save-dev
# or
yarn add -D dev-stamp
# or
pnpm add -D dev-stamp

If you want to use Dev Stamp in a browser environment, you can include it via a <script type="module"> tag, which is supported by all modern browsers:

<script type="module">
  import { stampInHtml } from "https://cdn.jsdelivr.net/npm/dev-stamp/dist/index.js";

  stampInHtml("Hello from CDN ๐Ÿชด");
</script>

๐Ÿ”ง Advanced Usage

You can customize the stamp with various options, which can be passed as a second argument to the stampInHtml function.

import { stampInHtml, StampOptions } from 'dev-stamp';

const options: StampOptions = {
  targetSelector: '.my-custom-selector', // CSS selector to find the target element, comment will be injected at the end of this element
};

stampInHtml("๐Ÿ’ฎ Made with love by [Your Name]", options);

๐Ÿ’ก Modes of Injection

Dev Stamp supports two modes of injection:

  1. Comment: Injects a comment at the end of the body tag (by default).
  2. Meta Tag: Injects a meta tag in the head section of the HTML.

You can choose the mode by setting the mode option in the StampOptions described below.

๐Ÿฆ‹ Options

Field Type Description Default
targetSelector string CSS selector to find the target element to inject the stamp. Only used if mode is set to comment "body"
mode "comment"
"meta-tag"
Mode of HTML injection "comment"
comment StampCommentOptions Options related to the comment injection. Only used if mode is set to comment Refer to Comment Options for details
metaTag StampMetaTagOptions Options related to the meta-tag injection. Only used if mode is set to meta-tag Refer to Meta Tag Options for details

Comment Options

Field Type Description Default
innerDisplay "inline"
"spaced-inline"
"block"
How the comment should be displayed in the HTML. "inline" is the default, "spaced-inline" adds spaces around the comment, and "block" displays it as a block comment (with newlines before and after). "inline"

Meta Tag Options

Field Type Description Default
name string Name of the meta tag to be injected "dev-stamp"
strictValidation boolean Whether to validate the meta tag name against HTML standards true
overwrite boolean Whether to overwrite an existing meta tag with the same name true

๐Ÿงช Robustness

๐Ÿ’ฏ Unit Testing

Dev Stamp is designed to be robust and handle various scenarios.

To achieve this, it is 100% unit tested with Vitest and has 100% code coverage.

๐Ÿ‹ SonarCloud

The code quality is continuously monitored using SonarCloud.

You can check the code quality by clicking on the badge below:

SonarCloud Quality Gate

๐Ÿ‘ฝ Mutation Testing

StrykerJS is used to ensure the code is resilient to mutations.

You can check the mutation testing results by clicking on the badges below:

Mutation testing badge


๐Ÿ“ƒ License

Licensed under the MIT License ๐Ÿ“„ โ€“ free as in freedom.


๐Ÿ‘ฉโ€๐Ÿ’ป Contributing

We welcome contributions! If you have ideas, suggestions, or issues, please open an issue or a pull request.

Thanks to Jessica Garrido for the fantastic idea โค๏ธ

Readme

Keywords

Package Sidebar

Install

npm i dev-stamp

Weekly Downloads

116

Version

1.2.0

License

MIT

Unpacked Size

37 kB

Total Files

9

Last publish

Collaborators

  • antoinezanardi