version-me

some cheap dev-only lib to avoid manual updates of the version in multiple files (f.e. `version.json`/`version.xml` besides `package.json`)

Usage no npm install needed!

<script type="module">
  import versionMe from 'https://cdn.skypack.dev/version-me';
</script>

README

GitHub package.json version

version-me

some cheap dev-only lib to avoid manual updates of the version in multiple files (f.e. version.json/version.xml besides package.json)

where to use it?

the bundler config / somewhen else before any further pipelines

how to use

import { versionMe, xml } from 'versionMe'

versionMe()
// or
versionMe({ file: './dist/build-version.json' })
// or
versionMe({ customContent: ({ version }) => JSON.stringify({ CUSTOM_VERSION_KEY: version }) })
// or
versionMe({ file: './version.xml', customContent: (param) => xml(param) })
// or or or

environment variables it looks for

you must either provide the npm_package_version (provided by default if using a package manager to start the script) or VERSION by hand
=> VERSION whatever.js or yarn whatever (script in package.json which runs whatever.js somehow)

configurations

key default value   description
file './version.json' sets the file path & name
customContent ({ version }) => JSON.stringify({ version }) adds the ability for custom file contents

provided formatters

  • json ({"version": "..."}) (default)
  • xml (<version>...</version>)