Skip to content
This repository has been archived by the owner on Jul 4, 2022. It is now read-only.
/ Codename Public archive

🔖 Parsing your semantic version numbers into awesome version names!

License

Notifications You must be signed in to change notification settings

khaosdoctor/Codename

Repository files navigation

Codename

JavaScript Style Guide npm version GitHub license Codename Codacy Badge codecov Build Status

Parsing your semantic version numbers into awesome version names!

Summary

What is it?

This is a fun project to transform your boring Semantic Version numbers like 1.2.3 into awesome badass codenames.

This means you can give your project version an alias so you can call it by name, for instance, let's give Pokémon™ names to our versions. So 1.2.3 would be turned into the pokédex number:

  • major is 1, which translates to Bulbasaur
  • minor is 2, which translates to Ivysaur
  • patch is 3, which translates to Venusaur

Your full project codename would be: V1.2.3 - Bulbasaur (or V Bulbasaur.Ivysaur.Venusaur but this is not pretty).

Usage

First, install the package by issuing:

npm i @khaosdoctor/codename --save

Or, if you like yarn:

yarn add @khaosdoctor/codename

Then, in your project require it as const codename = require('@khaosdoctor/codename')

Parsers

Codename uses parsers to parse your version name. A parser is a simple object that follows the structure:

module.exports = {
  major: [
    'codename0',
    'codename1',
    'codename2',
    'codename3',
    'codename4',
    ...
  ],
  minor: [
    'codename0',
    'codename1',
    'codename2',
    'codename3',
    'codename4',
    ...
  ],
  patch: [
    'codename0',
    'codename1',
    'codename2',
    'codename3',
    'codename4',
    ...
  ]
}

Or also:

module.exports = {
  major: {
    'majorNumber': 'name',
    'majorNumber': 'name',
    'majorNumber': 'name',
    'majorNumber': 'name',
    'majorNumber': 'name',
    ...
  },
  minor: {
    'minorNumber': 'name',
    'minorNumber': 'name',
    'minorNumber': 'name',
    'minorNumber': 'name',
    'minorNumber': 'name',
    ...
  },
  patch: {
    'patchNumber': 'name',
    'patchNumber': 'name',
    'patchNumber': 'name',
    'patchNumber': 'name',
    'patchNumber': 'name',
    ...
  }
}

Note: If one of the indexes (major, minor or patch) is omitted, the original version number will be used

Another note: Using arrays will start the count on index 0 (as every array), if you wish to specify version numbers for specific names, use objects instead

After that you can simply instantiate with a parser and have fun!

Let's use Pokémon™ again:

const codename = require('khaosdoctor/codename')(yourParser) // This is a Pokémon™ parser
const myVersion = require('./package.json').version // 1.2.3

console.log(codename.parse(myVersion).major) // Would output 'Bulbasaur'

console.log(codename.parse(myVersion).minor) // Would output 'Ivysaur'

console.log(codename.parse(myVersion).patch) // Would output 'Venusaur'

console.log(codename.parse(myVersion).codename) // Would output 'Bulbasaur.Ivysaur.Venusaur'

console.log(codename.parse(myVersion).codenameText) // Would output 'V1.2.3 - Bulbasaur'

That's it.

Some examples and parsers

  • codename-zodiac: Outputs Zodiac Signs for each version number (starting on 1, major only)
  • codename-greek: Outputs greek letters for version numbers
  • codename-greek-gods: Outputs greek god names for major version numbers, demigod names for minor version numbers and hero names for patches (start on 1)
  • codename-titans: Outputs greek titan names for version numbers (start on 1, major only)
  • codename-nordic: Outputs nordic gods names for version numbers (starting on 1, major only)
  • codename-zodiac-warriors: Outputs zodiac warriors names for version numbers (starting on 1, major only)
  • codename-universe: Outputs star names for major version numbers (start on 0), constellation names for minor numbers and moon names for patch numbers

Add yours here by submiting a PR! 😄

About

🔖 Parsing your semantic version numbers into awesome version names!

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published