# @censujiang/vite-plugin-version-mark

> Automatically insert the version or git_commit_sha in your Vite/Nuxt project.

Latest version **0.0.13** (published 2023-11-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install @censujiang/vite-plugin-version-mark
pnpm add @censujiang/vite-plugin-version-mark
yarn add @censujiang/vite-plugin-version-mark
bun add @censujiang/vite-plugin-version-mark
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.13 |
| Published | 2023-11-11 |
| First published | 2023-07-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 44.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | ZhongxuYang |
| Maintainers | censujiang_self |
| Keywords | git, commit, log, version, plugin, vite, nuxt |

## Links

- npm: https://www.npmjs.com/package/@censujiang/vite-plugin-version-mark
- Repository: https://github.com/censujiang/vite-plugin-version-mark
- Homepage: https://github.com/censujiang/vite-plugin-version-mark.git
- Issues: https://github.com/censujiang/vite-plugin-version-mark/issues
- npm.io page: https://npm.io/package/@censujiang/vite-plugin-version-mark

## Dependencies (1)

- [vite-plugin-global-const](https://npm.io/package/vite-plugin-global-const.md) ^0.0.5

## Alternatives

- [cli-color](https://npm.io/package/cli-color.md) — 3.4M weekly downloads
- [log](https://npm.io/package/log.md) — 1.3M weekly downloads
- [logstash-client](https://npm.io/package/logstash-client.md) — 4.5K weekly downloads
- [@nocobase/plugin-logger](https://npm.io/package/@nocobase/plugin-logger.md) — 2.0K weekly downloads
- [child-process-debug](https://npm.io/package/child-process-debug.md) — 695 weekly downloads

## Recent versions

- 0.0.13 (latest) — 2023-11-11
- 0.0.12 — 2023-07-29
- 0.0.11 — 2023-07-29

## README

# @censujiang/vite-plugin-version-mark

> Automatically insert the version or git_commit_sha in your Vite/Nuxt project.

> This release is a separate branch maintained by @censujiang. The original author is @ZhongxuYang. This version is suitable for my own company's work environment, if you want to use this plugin, please consider @ZhongxuYang's master version first.

<div align="center">
  <a href="https://github.com/ZhongxuYang/@censujiang/vite-plugin-version-mark/tree/main">
    <img src="./docs/static/logo.svg" width="200px" />
  </a>
</div>

<div align="center">

[![npm version][npm-version-src]][npm-version-href]
[![npm downloads][npm-downloads-src]][npm-downloads-href]
[![types][types-src]][types-href]
[![License][license-src]][license-href]

[![Vite][vite-src]][vite-href]
[![Nuxt][nuxt-src]][nuxt-href]

[![Awesome][awesome-src]][awesome-href]

</div>

## Demo
![demo screen shot](./docs/static/iShot.png)

## Install
```sh
yarn add -D @censujiang/vite-plugin-version-mark
# OR npm install -D @censujiang/vite-plugin-version-mark
```

## Usage
### Vite
```ts
// vite.config.ts
import {defineConfig} from 'vite'
import {vitePluginVersionMark} from '@censujiang/vite-plugin-version-mark'

export default defineConfig({
  plugins: [
    vitePluginVersionMark({
      // name: 'test-app',
      // version: '0.0.1',
      // command: 'git describe --tags',
      ifGitSHA: true,
      ifShortSHA: true,
      ifMeta: true,
      ifLog: true,
      ifGlobal: true,
      ifImportMeta: true,
    })
  ],
})
```

### Nuxt3+
```ts
// nuxt.config.ts
export default defineNuxtConfig({
  modules: [
    ['@censujiang/vite-plugin-version-mark/nuxt', {
      // name: 'test-app',
      // version: '0.0.1',
      // command: 'git describe --tags',
      ifGitSHA: true, 
      ifShortSHA: true, 
      ifMeta: true, 
      ifLog: true, 
      ifGlobal: true,
      ifImportMeta: true,
    }]
  ],
})
```

Then you can use `@censujiang/vite-plugin-version-mark` ! 🎉

## Config

`@censujiang/vite-plugin-version-mark` can be print application version in the `Console` or add `<meta>` in HTML element. 

| name | description | type | default | supported |
| --- | --- | --- | --- | --- |
| name | application name | `string` | `name` in package.json | `0.0.1+` |
| version | application version | `string` | `version` in package.json | `0.0.1+` |
| ifGitSHA | use git commit SHA as the version | `boolean` | false | `0.0.1+` |
| ifShortSHA | use git commit short SHA as the version | `boolean` | true | `0.0.1+` |
| ifLog | print info in the Console | `boolean` | true | `0.0.1+` |
| ifGlobal | set a variable named *\`\_\_${APPNAME}\_VERSION\_\_\`* in the window | `boolean` | true | `0.0.4+` |
| ifMeta | add \<meta name="application-name" content="{APPNAME_VERSION}: {version}"> in the \<head> | `boolean` | true | `0.0.1+` |
| ifImportMeta | add `import.meta.env.__${APPNAME}_VERSION__` in the App | `boolean` | true | `0.0.9+` |
| command | provide a custom command to retrieve the version <br/>For example: `git describe --tags` | `string` | git rev-parse --short HEAD | `0.0.8+` |


<!-- - `name` - application name (`name in package.json` by default)
- `version` - application version (`version in package.json` by default)
- `ifGitSHA` - use git commit SHA as the version (`false` by default)
- `ifShortSHA` - use git commit short SHA (`true` by default)
- `ifMeta` - add \<meta name="application-name" content="{APPNAME_VERSION}: {version}"> in the \<head> (`true` by default)
- `ifLog` - print info in the Console (`true` by default)
- `ifGlobal` - set a variable named *\`\_\_${APPNAME}\_VERSION\_\_\`* in the window. (`true` by default)
- `command` - provide a custom command to retrieve the version. For example: `git describe --tags` (`git rev-parse --short HEAD` by default) -->

View [CHANGELOG](./CHANGELOG.md)


<!-- Badges -->
[npm-version-src]: https://img.shields.io/npm/v/@censujiang/vite-plugin-version-mark/latest.svg?style=flat&colorA=18181B
[npm-version-href]: https://npmjs.com/package/@censujiang/vite-plugin-version-mark

[npm-downloads-src]: https://img.shields.io/npm/dm/@censujiang/vite-plugin-version-mark.svg?style=flat&colorA=18181B
[npm-downloads-href]: https://npmjs.com/package/@censujiang/vite-plugin-version-mark

[types-src]: https://img.shields.io/npm/types/@censujiang/vite-plugin-version-mark.svg?style=flat&colorA=18181B
[types-href]: https://npmjs.com/package/@censujiang/vite-plugin-version-mark

[license-src]: https://img.shields.io/npm/l/@censujiang/vite-plugin-version-mark.svg?style=flat&colorA=18181B
[license-href]: https://npmjs.com/package/@censujiang/vite-plugin-version-mark

[nuxt-src]: https://img.shields.io/badge/Nuxt-18181B?&logo=nuxt.js
[nuxt-href]: https://nuxt.com

[vite-src]: https://img.shields.io/badge/Vite-18181B?&logo=vite
[vite-href]: https://vitejs.dev

[awesome-src]: https://awesome.re/mentioned-badge.svg
[awesome-href]: https://github.com/vitejs/awesome-vite#transformers

---
_Source: https://npm.io/package/@censujiang/vite-plugin-version-mark · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
