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

@dyn-temp/version-build

v1.0.4

Published

This repository houses various code utilities involved in the overall CICD workflow - semantic versioning, linting ,etc.

Downloads

2

Readme

#utilities This repository houses various code utilities involved in the overall CICD workflow - semantic versioning, linting ,etc.

versioning tool

Using git commands it will work with the target project's repository to create tags and release branchces. For the first iteration it will generate only minor and patch versions. The major verion flow is yet to be decided.

Every application will implement it's own flow using the functions exposed by the node-version-build tool.

Every application will commit using the Conventional Commits specification. This is important because the node-version-tool will look in the commit message for the structural elements defined by the Conventional Commits specification.

Dependency

Semver

Simple-git

Installation

npm install {path_to_repo}

Usage

The module exposes a gitCommands object.

const gitCommands = new GitCommands();

Functions

getTags() Returns the tags list as present in the target repo. Useful to return the last tag. Usually the first step in the repo-specific implementation.

| Sample call | Sample response | | --- | --- | | await gitCommands.getTags() | TagList { all: [ '0.0.1', '0.0.1-beta.0.1' ], latest: '0.0.1-beta.0.1' } |


getCommitsSinceTag(from) Retruns the list of commits starting with the 'from' parameter. It will disregard the merge commits as they are not important for the versioning process. This function is called by the shouldAdvanceVersion() function to determine what part of the version should be updates.

Sample call: await gitCommands.getCommitsSinceTag(lastTag.latest)

Sample response Commits [ { hash: '279bfbcb3298b7ffb45b210c15aa38897871a313', date: '2023-10-18T14:10:50+03:00', message: 'wip: commit #2', refs: 'HEAD -> main, tag: 0.0.1-beta.0.1, 0.0.1-beta.0.1', body: '', author_name: 'Author One', author_email: '[email protected]' }, { hash: 'e8d7506348d221d5549b9337333f7e68c3924df6', date: '2023-10-18T13:56:34+03:00', message: 'wip: new commit', refs: '', body: '', author_name: 'Author two', author_email: '[email protected]' } ]


getHead()

Returns the current GIT head hash excluding the merge commits. Used by the getCommitsSinceTag() function.


incremenVersion(tag, part) Returns an increment of the part parameter based on the tag parameter.

Sample Call - major version: gitCommands.incremenVersion('1.0.0', 'major')

Sample response - major version: 2.0.0

Sample Call - minor version: gitCommands.incremenVersion('1.0.0', 'minor')

Sample response - minor version: 1.1.0

Sample Call - patch version: gitCommands.incremenVersion('1.0.0', 'patch')

Sample response - patch version: 1.0.1


createReleaseBranch(branch) Acts on the repository and creates a new branch on the current head, using the naming convention v{branch}. This branch will act as the release candidate. Returns void.


createTag(name) Acts on the repository and creates a new tag on the current head. Returns void.


Sample Usage

import gitCommands from "@version-build/version-build";

const lastTag = await gitCommands.getTags(); // .latest
const commits = await gitCommands.getCommitsSinceTag(lastTag.latest);
// get the needed version update
const shouldAdvanceMajor = await gitCommands.shouldAdvanceVersion(lastTag.latest, 'breaking');
const shouldAdvanceMinor = await gitCommands.shouldAdvanceVersion(lastTag.latest, 'feat');
const shouldAdvancePatch = await gitCommands.shouldAdvanceVersion(lastTag.latest, 'fix');


const result = {
    "advenceMajor": false, 
    "advanceMinor": false,
    "advancePatch": false,
    "newVersion": null
};

if (shouldAdvanceMajor) {
    throw new Error("Major version update! Please contact the system administrator.");
}

if (shouldAdvanceMinor) {
    const newVersion = gitCommands.incremenVersion(lastTag.latest, 'minor');
    gitCommands.createReleaseBranch(newVersion);
    gitCommands.createTag(newVersion);  
    result.advanceMinor =  shouldAdvanceMinor;
    result.newVersion = newVersion
}

if (shouldAdvancePatch) {
    const newVersion = gitCommands.incremenVersion(lastTag.latest, 'patch');
    gitCommands.createReleaseBranch(newVersion);
    gitCommands.createTag(newVersion);  
    result.advancePatch =  shouldAdvanceMinor;
    result.newVersion = newVersion
}

console.log(result);

8b1e7f3 (versioning and build tool initial commit)