@kibibit/announce-it
TypeScript icon, indicating that this package has built-in type declarations

3.0.1 • Public • Published

@kibibit/announce-it

Announcing your application releases on social media


How to install

Install this package as a dev dependency:

npm install --save-dev @kibibit/announce-it

How to use

Intended to run after a new release in your continues integration

Twitter Setup

You have to create a Developer Account on Twitter.

  • Create an App
  • From your apps list go to your app Details
  • Select the Keys and tokens tab
  • You'll need all 4 variables available in that page:
    • API key
    • API secret key
    • Access token
    • Access token secret

As a command line tool

  • You need to pass the following parameters by either ENV parameters or calling the cli with these as cli params:

    • TWITTER_CONSUMER_KEY = API key
    • TWITTER_CONSUMER_SECRET = API secret key
    • TWITTER_ACCESS_TOKEN_KEY = Access token
    • TWITTER_ACCESS_TOKEN_SECRET = Access token secret
    • branch = the current branch

    As CLI params:

    ./node_modules/.bin/announce-it --CONSUMER_KEY <key> --CONSUMER_SECRET <secret> --ACCESS_TOKEN_KEY <key> --ACCESS_TOKEN_SECRET <secret> --branch <branchName>

    Both ENV parameters and the CLI arguments have the same names. If a parameter is found in both places, the CLI argument will be used.

  • You can add a dedicated script in your package.json file:

    // ...
    "scripts": {
      // ...
      "announce": "announce-it"
    }
    // ...
  • If executed with @semanic-release/exec:

    because of a current issue with @semantic-release/exec, you need to pass the current branch directly

    "release": {
      "branches": [ /* ... */ ]
      // ...
      "success": [
        "@semantic-release/github",
        [
          "@semantic-release/exec",
          {
            "successCmd": "npm start -- --branch $TRAVIS_BRANCH"
          }
        ]
      ],
    }
      // ...
    // ...
  • If installed as a project dependency, you can run with npx:

    # should be ran inside your project
    # npx
    npx announce-it
    
    # directly 
    ./node_modules/.bin/announce-it
  • If installed globally, you can run it from within any node package with the correct setup

As a node module

import { KbAnnounceIt, PackageDetails } from '@kibibit/announce-it';

const announceIt = new KbAnnounceIt({
  accessTokenKey: 'TWITTER_ACCESS_KEY',
  accessTokenSecret: 'TWITTER_ACCESS_SECRET',
  consumerKey: 'TWITTER_CONSUMER_KEY',
  consumerSecret: 'TWITTER_CONSUMER_SECRET',
  branch: 'CURRENT_BRANCH'
});

const myPackage: PackageDetails = require('./package');

// get generated tweet
const tweet: string = announceIt.generateTweet(myPackage);

console.log('going to tweet: ', tweet);

// publish tweet to twitter
announceIt.announceRelease(myPackage);

Defining your Templates

Inside your package.json file, add an announcements object with tweet property.

You can then create your own tweet message template that will be posted to twitter.

{
  "name": "my-package",
  "version": "2.4.3",
  // ...
  "announcements": {
    "tweet": "Version <%= version %> of <%= package %> is live! <%= npmpage %>"
  },
}

The tweet template is generated with Lodash template.

You can use these variables:

  • Package name: <%= package %>
  • Version number: <%= version %>
  • Package description: <%= description %>
  • Package author: <%= author %>
  • Homepage link: <%= homepage %>
  • Package page on npm: <%= npmpage %>

Contributing

If you have suggestions for how announce-it could be improved, or want to report a bug, open an issue! We'd love all and any contributions.

For more, check out the Contributing Guide.

Contributors

Thanks goes to our contributors! (emoji key):

Gil Tichon
Gil Tichon

🚇 💻 📆
Neil Kalman
Neil Kalman

🚇 🤔

Library logo is made by Freepik from www.flaticon.com and licensed by CC 3.0 BY

License

MIT © 2019 Gil Tichon ZimGil@kibibit.io

Readme

Keywords

none

Package Sidebar

Install

npm i @kibibit/announce-it

Weekly Downloads

0

Version

3.0.1

License

MIT

Unpacked Size

42 kB

Total Files

31

Last publish

Collaborators

  • k1b1b0t
  • thatkookooguy
  • zimgil
  • or.tichon