Code Monkey home page Code Monkey logo

package-version-git-tag's Introduction

package-version-git-tag

Go to the latest release page on npm License: MIT Supported Node.js version: ^14.14.0 || 16.x || >=18.x Minified Bundle Size Details Install Size Details Dependencies Status Build Status Maintainability Status

Add Git tag corresponding to the version field of package.json.

Install

npm install --save-dev package-version-git-tag

Usage

$ package-version-git-tag --help
package-version-git-tag v3.0.0

Add Git tag corresponding to the version field of package.json

Usage:
  $ package-version-git-tag [options]

Options:
  -V, -v, --version  Display version number 
  -h, --help         Display this message 
  --push             `git push` the added tag to the remote repository 
  --verbose          show details of executed git commands 
  -n, --dry-run      perform a trial run with no changes made 

For example, suppose that package.json exists in the current directory, and version is 1.2.3:

{
    "name": "my-awesome-package",
    "version": "1.2.3",
    ...
}

In this case, this command is:

package-version-git-tag

Equivalent to this operation:

$ git tag v1.2.3 -m 1.2.3

If you add the --push flag, it will also run git push. That is, this command is:

package-version-git-tag --push

Equivalent to this operation:

$ git tag v1.2.3 -m 1.2.3
$ git push origin v1.2.3

Customize tag name format

If you want to change the tag name, you can customize it in the same way as the npm/yarn/pnpm version command:

npm / pnpm

If you want to run this command in npm or pnpm, you can change the prefix of the git tag by using tag-version-prefix. You can change the configurations using the following commands:

# Set the tag prefix to "foo-bar-"
npm config set --location=project tag-version-prefix foo-bar-
# Or, if you are using pnpm, run the following command:
pnpm config set --location=project tag-version-prefix foo-bar-

Note: Forgetting the --location option will change the user configuration. If you want to change the prefix only within your project, do not forget the --location option.

If you are using npm v7.19 or earlier, or pnpm v7.20 or earlier, you need to edit the .npmrc file directly, because it does not support the --location option.

Alternatively, you can directly edit the .npmrc file:

.npmrc

; Set the tag prefix to "foo-bar-"
tag-version-prefix = "foo-bar-"

After editing the .npmrc file, check the value using the npm config get tag-version-prefix command (or the pnpm config get tag-version-prefix command).

Yarn

Note: Currently, Yarn 2 and Yarn 3 is not supported.

If you want to run this command in yarn, you can change the prefix of the git tag by using version-tag-prefix. You can change the configuration by editing the .yarnrc file:

.yarnrc

# Set the tag prefix to "foo-bar-"
version-tag-prefix foo-bar-

After editing the .yarnrc file, check the value using the yarn config get version-tag-prefix command.

Alternatively, you can use the yarn config set command.

Note: The yarn config set command updates the .yarnrc file in the home directory. If you want to change the prefix only within your project, you need to edit the .yarnrc file directly.

# Set the tag prefix to "foo-bar-"
yarn config set version-tag-prefix foo-bar-

Tests

To run the test suite, first install the dependencies, then run npm test:

npm install
npm test

Change Log

see CHANGELOG.md

Contributing

see CONTRIBUTING.md

Related

package-version-git-tag's People

Contributors

dependabot[bot] avatar johnschult avatar renovate-bot avatar renovate[bot] avatar sounisi5011 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

package-version-git-tag's Issues

Add --format option

Assuming standard GitHub, the format of the version tag is v{version}.
However, some people may want to change this format.
Perhaps it is an edge case, but better than the current situation where there is no choice.

Add --remote option

There may be multiple remote repositories configured in Git.
The name of the remote repository is often "origin", but this is not the default built in Git.

If remote repositories other than "origin" are set, the option to select them is required.

Add --dry-run option

This command is very simple, but I may still want to know what happens.
It is useful to have the --dry-run option.

Missing Node.js 15 support

I'm using Node.js 15.8.0 and the installation fails with:

error [email protected]: The engine "node" is incompatible with this module. Expected version "10.x || 12.x || 14.x". Got "15.8.0"
error Found incompatible module.

I can hardly imagine that a new Node.js version could break the functionality of this package. Is it really necessary to limit the maximum Node.js version?

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Warning

These dependencies are deprecated:

Datasource Name Replacement PR?
npm npm-run-all Available

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • ⬆️ Update dependency @sounisi5011/readme-generator to v0.0.6
  • ⬆️ Update dependency @types/cross-spawn to v6.0.6
  • ⬆️ Update dependency @types/mock-fs to v4.13.4
  • ⬆️ Update dependency @types/which-pm-runs to v1.0.2
  • ⬆️ Update dependencies: npm-scripts packages (del-cli, npm-run-all)
  • ⬆️ Update dependency @go-task/cli to v3.38.0
  • ⬆️ Update actions/cache action to v4
  • ⬆️ Update actions/checkout action to v4
  • ⬆️ Update actions/github-script action to v7
  • ⬆️ Update actions/setup-node action to v4
  • ⬆️ Update dependencies: test packages (major) (execa, vitest)
  • ⬆️ Update dependency @tsconfig/node14 to v14
  • ⬆️ Update dependency prettier to v3
  • ⬆️ Update dependency which-pm to v3
  • 🔐 Create all rate-limited PRs at once 🔐

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/check-if-changelog-is-updated.yaml
  • actions/checkout v3
.github/workflows/ci.yaml
  • actions/checkout v3
  • actions/github-script v6
  • actions/checkout v3
  • actions/setup-node v3
  • actions/cache v3
  • actions/checkout v3
  • actions/setup-node v3
  • actions/cache v3
.github/workflows/pr-auto-approve.yaml
  • hmarr/auto-approve-action v3
.github/workflows/update-license-year.yaml
  • actions/checkout v3
  • FantasticFiasco/action-update-license-year v2
npm
package.json
  • command-join ^3.0.0
  • cross-spawn ^7.0.2
  • mri ^1.2.0
  • which-pm ^2.0.0
  • which-pm-runs ^1.1.0
  • @go-task/cli 3.27.1
  • @sindresorhus/slugify 2.2.0
  • @sounisi5011/readme-generator 0.0.2
  • @tsconfig/node14 1.0.3
  • @types/cross-spawn 6.0.2
  • @types/mock-fs 4.13.1
  • @types/node 14.18.37
  • @types/semver 7.3.13
  • @types/which-pm-runs 1.0.0
  • @typescript-eslint/eslint-plugin 5.54.1
  • @typescript-eslint/parser 5.54.1
  • can-npm-publish 1.3.6
  • del-cli 5.0.0
  • eslint 8.36.0
  • eslint-config-prettier 8.7.0
  • eslint-config-standard 17.0.0
  • eslint-plugin-import 2.27.5
  • eslint-plugin-n 15.6.1
  • eslint-plugin-prettier 4.2.1
  • eslint-plugin-promise 6.1.1
  • eslint-plugin-simple-import-sort 10.0.0
  • eslint-plugin-vitest 0.0.54
  • execa 7.1.1
  • git-branch-is 4.0.0
  • is-git-status-clean 1.0.0
  • is-promise 4.0.0
  • lefthook 1.3.3
  • mock-fs 5.2.0
  • node-git-server 1.0.0
  • npm-run-all 4.1.5
  • prettier 2.8.4
  • prettier-package-json 2.8.0
  • semver 7.3.8
  • sort-package-json 2.4.1
  • ts-node 10.9.1
  • typescript 4.9.5
  • vite 4.1.4
  • vitest 0.29.2
  • vitest-mock-process 1.0.4
  • node ^14.14.0 || 16.x || >=18.x
  • pnpm 7.30.5

  • Check this box to trigger a request for Renovate to run again on this repository

What we want to do before we release 4.0.0

Add `--help` option

This CLI tool has no help document to browse on the console.
If we follow the standard other commands and use the --help option, the documentation will not be displayed, and Git tags will be added silently.

Replace lightweight tags to annotated tags

There are two types of Git tags: lightweight and annotated.
The lightweight tag is only an alias for commit. Annotated tags, on the other hand, contain information such as the tagger name and date.
Because of this feature, documents on Web state that annotated tags are recommended over lightweight tags.

A lightweight tag is very much like a branch that doesn’t change — it’s just a pointer to a specific commit.

Annotated tags, however, are stored as full objects in the Git database. They’re checksummed; contain the tagger name, email, and date; have a tagging message; and can be signed and verified with GNU Privacy Guard (GPG). It’s generally recommended that you create annotated tags so you can have all this information

https://git-scm.com/book/en/v2/Git-Basics-Tagging#_creating_tags

It is useful to have the feature to detect duplicate tags and replace them with annotated tags if they are lightweight.

Here is the answer to help you detect the type of tag:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.