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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@git-lazy/tag

v2.0.3

Published

Create git tags programmatically with support for annotated, signed, and force-overwrite options

Readme

@git-lazy/tag

Create git tags programmatically with support for annotated, signed, and force-overwrite options

Installation

npm install @git-lazy/tag
# or
pnpm add @git-lazy/tag
# or
yarn add @git-lazy/tag

Usage

import { gitTag, gitTagSync, buildCmd } from '@git-lazy/tag';

// 建立基本標籤 / Create a basic tag
await gitTag('v1.0.0');

// 建立附註標籤 / Create an annotated tag
await gitTag('v1.0.0', {
  annotated: true,
  message: 'Release v1.0.0',
  cwd: '/path/to/repo',
});

// 同步建立標籤 / Synchronously create a tag
const result = gitTagSync('v1.0.0');

// 建立強制覆蓋的簽章標籤 / Create a force-overwrite signed tag
gitTagSync('v2.0.0', {
  forceGitTag: true,
  signGitTag: true,
  message: 'Major release v2.0.0',
});

API

gitTag(tag, options, spawnOptions)

非同步執行 git tag 命令 / Asynchronously execute git tag command

使用 cross-spawn 以非同步方式執行 git tag,適合需要等待完成但不阻塞主執行緒的場景 Executes git tag asynchronously using cross-spawn, suitable for scenarios that need to wait for completion without blocking the main thread

Parameters:

  • tag (string) - 標籤名稱 / Tag name
  • options (IOptions) - 標籤選項 / Tag options
    • cwd (string) - 工作目錄路徑 / Working directory path
    • message (string) - 標籤訊息 / Tag message
    • forceGitTag (boolean) - 是否強制覆蓋已存在的標籤 / Whether to force overwrite existing tags
    • signGitTag (boolean) - 是否對標籤進行 GPG 簽章 / Whether to GPG sign the tag
    • annotated (boolean) - 是否建立附註標籤 / Whether to create an annotated tag
    • target (string) - 目標物件(Commit SHA、Branch 等)/ Target object (Commit SHA, Branch, etc.)
  • spawnOptions (ISpawnGitAsyncOptions) - 程序產生選項 / Spawn process options

Returns: Promise - 非同步程序執行結果 / Async process execution result

Example:

import { gitTag } from '@git-lazy/tag';

// 建立基本標籤 / Create a basic tag
await gitTag('v1.0.0');

// 建立附註標籤並指定工作目錄 / Create an annotated tag with working directory
await gitTag('v1.0.0', {
  annotated: true,
  message: 'Release v1.0.0',
  cwd: '/path/to/repo',
});

gitTagSync(tag, options, spawnOptions)

同步執行 git tag 命令 / Synchronously execute git tag command

使用 cross-spawn 以同步方式執行 git tag,適合需要立即確認結果的場景 Executes git tag synchronously using cross-spawn, suitable for scenarios that need immediate result confirmation

Parameters:

  • tag (string) - 標籤名稱 / Tag name
  • options (IOptions) - 標籤選項 / Tag options
    • cwd (string) - 工作目錄路徑 / Working directory path
    • message (string) - 標籤訊息 / Tag message
    • forceGitTag (boolean) - 是否強制覆蓋已存在的標籤 / Whether to force overwrite existing tags
    • signGitTag (boolean) - 是否對標籤進行 GPG 簽章 / Whether to GPG sign the tag
    • annotated (boolean) - 是否建立附註標籤 / Whether to create an annotated tag
    • target (string) - 目標物件(Commit SHA、Branch 等)/ Target object (Commit SHA, Branch, etc.)
  • spawnOptions (ISpawnGitSyncOptions) - 程序產生選項 / Spawn process options

Returns: ISpawnSyncResult - 同步程序執行結果 / Sync process execution result

Example:

import { gitTagSync } from '@git-lazy/tag';

// 同步建立標籤 / Synchronously create a tag
const result = gitTagSync('v1.0.0');
console.log(result.status); // 0 表示成功 / 0 indicates success

// 建立強制覆蓋的簽章標籤 / Create a force-overwrite signed tag
gitTagSync('v2.0.0', {
  forceGitTag: true,
  signGitTag: true,
  message: 'Major release v2.0.0',
});

buildCmd(tag, options)

建立 git tag 命令參數陣列 / Build git tag command arguments array

根據提供的標籤名稱與選項,生成對應的 git tag 命令參數 Generates corresponding git tag command arguments based on the provided tag name and options

Parameters:

  • tag (string) - 標籤名稱 / Tag name
  • options (IOptions) - 標籤選項 / Tag options

Returns: string[] - 過濾後的命令參數陣列 / Filtered command arguments array

Example:

import { buildCmd } from '@git-lazy/tag';

// 建立基本標籤 / Create a basic tag
buildCmd('v1.0.0');
// Returns: ['tag', 'v1.0.0']

// 建立附註標籤並包含訊息 / Create an annotated tag with message
buildCmd('v1.0.0', { annotated: true, message: 'Release v1.0.0' });
// Returns: ['tag', '-a', 'v1.0.0', '-m', 'Release v1.0.0']

// 建立強制覆蓋的簽章標籤 / Create a force-overwrite signed tag
buildCmd('v2.0.0', { forceGitTag: true, signGitTag: true });
// Returns: ['tag', 'v2.0.0', '--force', '--sign']

Types

IOptions

Git Tag 操作選項 / Git Tag operation options

| Property | Type | Description | |----------|------|-------------| | cwd | string | 工作目錄路徑 / Working directory path | | message | string | 標籤訊息 / Tag message | | forceGitTag | boolean | 是否強制覆蓋已存在的標籤 / Whether to force overwrite existing tags | | signGitTag | boolean | 是否對標籤進行 GPG 簽章 / Whether to GPG sign the tag | | annotated | boolean | 是否建立附註標籤 / Whether to create an annotated tag | | target | string | 目標物件(Commit SHA、Branch 等)/ Target object |

License

ISC