npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@dictools/notifier

v1.0.2

Published

Dictools Notifier help the team to know when the dictionary keys have changed by Slack notification

Downloads

7

Readme

Getting started

Dictools Notifier is a tool used to notifies development/content team using a slack webhook based on a JSON file. Usually, it is used when the development team has the autonomy to create i18n dictionary keys directly in the code using a fallback file, this way it's not necessary to await the content team create the keys before writing the code.

Installation

Dictools Notifier can be installed using npm or yarn:

# npm
npm install @dictools/notifier --save-dev

# yarn
yarn add @dictools/notifier --dev

Usage

Prerequisites:

Script Initializer

Create a configuration file to start using dictools/notifier. The message can be formatted using the attachment format provided by slack, to know more details please check out the documentation.

// notification.js
const Notifier = require("@dictools/notifier");

const notification = new Notifier({
  path: "dictionary.json", // JSON file only
  hookUri: "https://hooks.slack.com/services/<api_token>",
  channel: "#acme-keys", // Optional
  username: "Acme", // Optional
  project: {
    name: "Acme App",
    boardUrl: "https://jira.acme.com/browse",
    key: "ACM" // (e.g. Task number ACM-0234)
  }
  /** 
   * Optional Configuration: ( Slack message replacement )
   * Text has available replacement keys that is used to get information from the project or git diff
   * and it can be customized as you need.
   */
  messages: {
    /** 
     * Check out the available text keys
     * @param {string} #{project} - Project name
     * @param {string} #{key} - Dictionary key name
     * @param {string} #{type} - Git change type (e.g. Added, Changed, Removed)
     * @param {string} #{username} - Git committer name (Global or locally git username)
     * @param {string} #{task} - Task link for the board (e.g. https://jira.acme.com/browse/ACM-0234)
     * @param {string} #{value} - Current content key value
     * @param {string} #{oldValue} - Previous content key value
     */
    title: "Changes to #{project} dictionary key(s):",
    added: {
      description: "Dictionary key #{key} has been #{type}",
      body: "Text: #{value}",
      footer: "#{type} by: #{username} | Task: #{task}"
    },
    changed: {
      description: "Dictionary key *#{key}* has been #{type}",
      body: "From: #{oldValue} To: #{value}",
      footer: "#{type} by: #{username} | Task: #{task}"
    },
    removed: {
      description: "Dictionary key *#{key}* has been #{type}",
      body: "Text: #{value}",
      footer: "#{type} by: #{username} | Task: #{task}"
    }
  }
});

notification.init();

Options

Options | Description | Types -------------------------------|---------------------------------------------------------------------------------------------------|----------- path | Defines the project's key map path | String hookUri | Slack Webhooks API url | String channel (Optional) | Slack channel where will be posted the notification | String username (Optional) | Slack username that will be used to post the notification | String project.name | Project name | String project.boardUrl | It is used to link the notification with your project board (e.g. https://jira.acme.com/browse) | String project.key | Key is the project identifier used to find a task number in a commit message e.g. feat(blog): ACM-0234 :: add comment section | String: "ACM"/ Array: ["ACM", "AMC"] / Regex: /(ACM)-[0-9]+/g messages.title | Slack message title e.g. Changes to Acme dictionary key(s): | String messages.added.description | Slack message description to added keys e.g. Dictionary key ticket_0234 has been added | String messages.added.body | Slack message body to added keys e.g. Text: Hello World | String messages.added.footer | Slack message footer to added keys e.g. Added by John Doe - Task: ACM-0234 | String messages.changed.description | Slack message description to changed keys e.g. Dictionary key ticket_0234 has been changed | String messages.changed.body | Slack message body to changed keys e.g. From: Hello World - To: Hi everyone! | String messages.changed.footer | Slack message footer to changed keys e.g. Changed by John Doe - Task: ACM-0234 | String messages.removed.description | Slack message description to removed keys e.g. Dictionary key ticket_0234 has been removed | String messages.removed.body | Slack message body to removed keys e.g. Text: Hi everyone! | String messages.removed.footer | Slack message footer to removed keys e.g. Removed by John Doe - Task: ACM-0234 | String

Configure Git Hooks

Let's see an example using Husky.

// package.json
{
  "husky": {
    "hooks": {
      "post-commit": "node ./notification.js"
    }
  }
}

After setting up the hook start to commit normally and as soon as you have new changes to the dictionary you will receive a notification on the configured slack channel.

Slack message preview

Contributing

Thanks for being interested in helping us to improve the experience for who use this library, we are all ears to listen, if you want to collaborate reporting an issue, feature or something else please use the issues section using the proper labels to your request, we will answer as soon as we can, thank you!

License

Dictools Notifier is MIT licensed.