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

git-info-plugin

v1.1.2

Published

it's a webpack4 plugin to help developers get git info in current build

Downloads

3

Readme

GitInfoPlugin

Build Status npm version

一个非常简单的 webpack4 插件,用于快速查看本地build的git信息,用于快速定位当前build是基于哪次提交。

A very simple webpack4 plugin which is used to check git info of local build. it helps developers know which commit the current build is based on.

使用(Usage)

npm install --save-dev git-info-plugin

然后在webpack.config中按照如下配置:

var GitInfoPlugin = require('git-info-plugin')

module.exports = {
  plugins: [
    new GitInfoPlugin()
  ]
}

构建完成后,打开网页,输入快捷键(默认ctrl + shift + Enter),打开浏览器开发者工具,在console中可以看到当前build的最新一次git commit id.

open webpage and input default shortcut (ctrl + shift + enter), then open develper tools (chrome, firefox etc..). you could see newest commit id in console:

c698cec1c6c22641692c716535dfcb21492c41ed

branch

dev

detail

c698cec1 - lq007, 2 days ago : Fix some bugs

配置 (Config)

插件有默认配置,用户可不必自行填写。 默认配置如下:

Default config is below:

module.exports = {
  plugins: [
    new GitInfoPlugin({
        hotKey: 'ctrl+shift+13',
        hotKeyDelimiter: '+',
        info: 'detail',
        show: 'console',
        command: '',
        filename: 'gitInfo'
    }
  ]
}

hotKeyDelimiter: '+'

快捷键分隔符,默认为'+',用户可自行设置为‘~’,‘¥’ 等等。

user could add custom hotkey delimiter like '#','%' etc..

hotKey: 'ctrl+shift+13'

通过设置hotKey用户可自定义快捷键以免与项目已有快捷键冲突。目前支持的快捷方式是Ctrl或Shift或Alt任意组合再加键盘的keyCode, 比如回车键(Enter)的keyCode是13.

Currently, legal hot keys are 'Ctrl' or 'Shift' or 'Alt' associated with keyCode. for example: ctrl+shift+13 (13 is Enter keyCode) or ctrl+13

:warning: 注意: 1. hotKey中的分隔符应和hotKeyDelimiter中的配置保持一致。 2. hotKey之间不允许出现空格

:warning: Note: 1. the delimiter in config hotKey should be consistent with that in config hotKeyDelimiter. 2. there should be no space between hotkeys.

info: 'id' || 'branch' || 'detail'

通过info配置,用户可选择项目中展示的info信息。目前支持id, branch以及detail三种形式。

Currently, it supports 3 types of info: id, branch and detail.

show: 'console' || 'file' || 'both'

默认为console, 即git信息只有用快捷键通过开发者工具中的console显示。

console is default value. it means we could only get git info from console through hotkey.

如果设置为file,git信息将会导出到文件gitInfo.md并且无法通过使用快捷键在console中显示。

file means git info will only show in exported file.

如果设置为both,即console模式和file模式同时开启。

both means 'console' mode and 'file' mode are both available.

command: ''

默认不赋值,仅仅使用插件提供的info option当中的选项。用户可以通过command配置自定义git command. 自定义后,info配置项将失效。

user could set custom git command through the option. Note that info options will be inactive if user set custom command.

例子(example) : { command: 'git status' }

:warning:警告: 请不要使用操作性command,比如'pull','add','delete','revert','merge'等,否则编译过程将会抛错。

:warning:Warning: Please don't use operational git commands which may change current project like 'pull', 'add', 'delete', 'revert', 'merge' etc.. or webpack will throw compile error.

filename: 'gitInfo'

用户可自定义导出git信息的文件名,默认值为'gitInfo',导出文件即为'gitInfo.md'。

user could set custom file name for exported file. by default the name is 'gitInfo.md'.

版本支持 (Webpack version)

该插件支持webpack4及以上。

it supports webpack4 or above.

依赖 (Dependency)

在成功运行GitInfoPlugin之前,在webpack.config中需要有关于HtmlWebpackPlugin配置。

The plugin runs based on webpack HtmlWebpackPlugin.

const GitInfoPlugin = require('git-info-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
  plugins: [
    new HtmlWebpackPlugin({
            template: './src/index.html'
    }),
    new GitInfoPlugin()
  ]
}

浏览器兼容性 (browser compatibility)

Chrome >= 45

FireFox >= 34

Safari >= 9

Edge

Not support IE <= 10

这是个方便开发人员的插件,所以并不需要兼容很多浏览器对吧?我觉得有chrome就足够了 :sunglasses:

It's just a plugin for developer, so we don't have to support old browsers, right ? actually Chrome is enough :yum:

TODO

  1. 移除对HtmlWebpackPlugin的依赖(当前插件需要用到html-webpack-plugin的hook,将一段script插入到生成的template html当中,这样其实不太好)。

remove dependent on HtmlWebpackPlugin (hook in HtmlWebpackPlugin is needed in GitInfoPlugin).