Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@korabo/genversion-plus

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@korabo/genversion-plus - npm Package Compare versions

Comparing version 0.9.1 to 1.0.0

bin/genversion-plus.js

4

index.js
var gv = require('./lib/genversion');
var gv = require('./lib/genversion-plus');
var v = require('./lib/version');

@@ -7,2 +7,2 @@

exports.generate = gv.generate;
exports.version = v;
exports.version = v.version;
// generated by genversion-plus
exports.version = '0.9.1'
exports.buildTime = '2021-02-08T11:43:32.651Z'
exports.version = '1.0.0'
exports.buildTime = '2021-02-08T12:56:30.128Z'
exports.comment = ''
exports.author = 'TAKEUCHI Shinichi'
{
"name": "@korabo/genversion-plus",
"version": "0.9.1",
"version": "1.0.0",
"description": "A command line utility to read version from package.json and attach it into your module as a property",

@@ -23,3 +23,3 @@ "keywords": [

"bin": {
"genversion-plus": "bin/genversion.js"
"genversion-plus": "bin/genversion-plus.js"
},

@@ -54,6 +54,6 @@ "author": {

"lintfix": "standard --fix 'bin/*.js' 'lib/**/*.js' 'test/**/*.js'",
"gv": "pnpx ./bin/genversion.js lib/version.js",
"release": "pnpm version patch && pnpm run gv && pnpm run test",
"gvp": "pnpx ./bin/genversion-plus.js",
"release": "pnpm run gvp -- lib/version.js && pnpm run test",
"public-publish": "pnpm publish --access public"
}
}

@@ -1,8 +0,8 @@

# genversion
# genversion-plus
[![npm version](https://badge.fury.io/js/genversion.svg)](https://www.npmjs.com/package/genversion)
[![npm version](https://badge.fury.io/js/%40korabo%2Fgenversion-plus.svg)](https://badge.fury.io/js/%40korabo%2Fgenversion-plus)
![Logo](doc/logo.png?raw=true "Abracadabra...and behold!")
So you want `yourmodule.version` to follow the version in package.json but are tired of updating it manually every time the version changes? On server side, you could just `require('package.json').version` but on client side however, that would expose the versions of your dependencies and possibly other sensitive data too, so [it is usually a naughty thing to do](https://stackoverflow.com/a/10855054/638546)! How to import only the version? Genversion to the rescue!
So you want `yourmodule.version+` to follow the version in package.json but are tired of updating it manually every time the version changes? On server side, you could just `require('package.json').version` but on client side and/or build deployments from typescript however, that would expose the versions of your dependencies and possibly other sensitive data too, so [it is usually a naughty thing to do](https://stackoverflow.com/a/10855054/638546)! How to import only the version+? Genversion-plus to the rescue!

@@ -14,30 +14,37 @@ ## Try it out

$ cd yourmodule
$ npm install -g genversion
$ genversion lib/version.js
$ npm install -g @korabo/genversion-plus
$ genversion-plus lib/version.js
Voilà! The new lib/version.js:
module.exports = '1.2.3'
exports.version = '0.9.1'
exports.buildTime = '2021-02-08T11:43:32.651Z'
exports.comment = ''
exports.author = 'TAKEUCHI Shinichi'
Use flags to match your coding style. `$ genversion --es6 --semi lib/version.js` creates:
Use flags to match your coding style. `$ genversion-plus --gen es6 --semi lib/version.js` creates:
export const version = '1.2.3';
export const version = '0.9.1';
export const buildTime = '2021-02-08T11:43:32.651Z';
export const comment = '';
export const author = 'TAKEUCHI Shinichi';
By default, genversion reads the version from the `package.json` nearest to the target `version.js`. In case your project contains multiple `package.json` files along the target path you can specify the one with `--source <path>` parameter.
By default, genversion-plus reads the version from the `package.json` nearest to the target `version.js`. In case your project contains multiple `package.json` files along the target path you can specify the one with `--source <path>` parameter. An custom template can be used to generate `version.js` or `version.ts`
## Integrate to your build
First install via [npm](https://www.npmjs.com/package/genversion).
First install via [npm](https://www.npmjs.com/package/@korabo/genversion-plus).
$ npm install genversion --save-dev
$ npm install @korabo/genversion-plus --save-dev
Genversion works by first reading the current version from package.json and then generating a simple CommonJS module file that exports the version string. For safety, the version file begins with a signature that tells genversion that the file can be overwritten.
Genversion-plus works by first reading the current version from package.json and then generating a simple CommonJS module file that exports the version string. For safety, the version file begins with a signature that tells genversion-plus that the file can be overwritten.
// generated by genversion
// generated by genversion-plus
module.exports = '1.2.3'
Now, your job is to 1) choose a path for the version file, 2) require() the new file into your module, and 3) add genversion as a part of your build or release pipeline. For example, let us choose the path 'lib/version.js' and require it in yourmodule/index.js:
Now, your job is to 1) choose a path for the version file, 2) require() the new file into your module, and 3) add genversion-plus as a part of your build or release pipeline. For example, let us choose the path 'lib/version.js' and require it in yourmodule/index.js:
...
exports.version = require('./lib/version')
var myversion = require('./lib/version')
exports.version = myversion.version
...

@@ -52,9 +59,9 @@

Then, let us integrate genversion into your build task.
Then, let us integrate genversion-plus into your build task.
"scripts": {
"build": "genversion lib/version.js && other build stuff"
"build": "genversion-plus lib/version.js && other build stuff"
}
The target path is given as the first argument. If the file already exists and has been previously created by genversion, it is replaced with the new one.
The target path is given as the first argument. If the file already exists and has been previously created by genversion-plus, it is replaced with the new one.

@@ -72,24 +79,24 @@ Finished! Now your module has a version property that matches with package.json and is updated every time you build the project.

Directly from `$ genversion --help`:
Directly from `$ genversion-plus --help`:
Usage: genversion [options] <target>
Usage: genversion-plus [options] <target>
Generates a version module at the target filepath.
Options:
-V, --version output the version number
-v, --verbose output the new version
-s, --semi use semicolons in generated code
-g, --gen <cjs|es6> use cjs or es6 ,,, syntax in generating code
-p, --source <path> search for package.json along a custom path
-t, --template <filepath> use given file as generation template
-m, --message <comment> build comment to be generated
-a, --author <author> author name to be generated
-h, --help output usage information
-V, --version output the version number
-v, --verbose output the new version
-s, --semi use semicolons in generated code
-e, --es6 use es6 syntax in generated code
-p, --source <path> search for package.json along a custom path
-h, --help output usage information
## Node API
You can also use genversion within your code:
You can also use genversion-plus within your code:
var gv = require('genversion');
var gv = require('genversion-plus');

@@ -99,3 +106,3 @@ The available properties and functions are listed below.

### genversion.check(targetPath, callback)
### genversion-plus.check(targetPath, callback)

@@ -107,3 +114,3 @@ Check if it is possible to generate the version module into `targetPath`.

- *targetPath:* string. An absolute or relative file path. Relative to `process.cwd()`.
- *callback:* function (err, doesExist, isByGenversion). Parameter *doesExist* is a boolean that is true if a file at targetPath already exists. Parameter *isByGenversion* is a boolean that is true if the existing file seems like it has been generated by genversion.
- *callback:* function (err, doesExist, isByGenversion). Parameter *doesExist* is a boolean that is true if a file at targetPath already exists. Parameter *isByGenversion* is a boolean that is true if the existing file seems like it has been generated by genversion-plus.

@@ -124,3 +131,3 @@ **Example:**

### genversion.generate(targetPath, opts, callback)
### genversion-plus.generate(targetPath, opts, callback)

@@ -135,3 +142,4 @@ Read the version property from the nearest `package.json` along the `targetPath` and then generate a version module file at `targetPath`. A custom path to `package.json` can be specified with `opts.source`.

- *useSemicolon:* optional boolean. Defaults to `false`.
- *useEs6Syntax:* optional boolean. Defaults to `false`.
- *genSyntax:* optional string <cjs|es6>. Defaults to `cjs`.
- *template:* optional string. An absolute or relative path to a template-file. Defaults to the value of `module-source:lib/template.txt`.
- *callback:* function (err, version). Parameter *version* is the version string read from `package.json`. Parameter *err* is non-null if `package.json` cannot be found, its version is not a string, or writing the module fails.

@@ -155,18 +163,16 @@

### genversion.version
### genversion-plus.version
The version string of genversion module in [semantic versioning](http://semver.org/) format. Generated with genversion itself, of course.
The version string of genversion-plus module in [semantic versioning](http://semver.org/) format. Generated with genversion-plus itself, of course.
## Projects using genversion
## Projects using genversion-plus
- [genversion](https://www.npmjs.com/package/genversion)
- [poisson-process](https://www.npmjs.com/package/poisson-process)
- [taaspace](https://www.npmjs.com/package/taaspace)
- [taach](https://www.npmjs.com/package/taach)
- [genversion-plus](https://www.npmjs.com/package/@korabo/genversion-plus)
Do you use genversion in your project? We are happy to mention it in the list. Just hit us with an issue or a pull request.
Do you use genversion-plus in your project? We are happy to mention it in the list. Just hit us with an issue or a pull request.
## Related projects
- [genversion](https://www.npmjs.com/package/genversion)
- [versiony](https://github.com/ciena-blueplanet/versiony) for version increments

@@ -180,7 +186,7 @@ - [package-json-versionify](https://github.com/nolanlawson/package-json-versionify) for browserify builds

$ npm run test
$ pnpm run test
To make release, bump the version in `package.json` and run:
$ npm run release
$ pnpm run release && npm public-publish

@@ -187,0 +193,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc