version-from-git 1.1.1-0 → 1.1.2-main.320b9e4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 William Wong
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # version-from-git
2
2
 
3
- [![npm version](https://badge.fury.io/js/version-from-git.svg)](https://badge.fury.io/js/version-from-git) [![Build Status](https://travis-ci.org/compulim/version-from-git.svg?branch=master)](https://travis-ci.org/compulim/version-from-git)
3
+ [![npm version](https://badge.fury.io/js/version-from-git.svg)](https://badge.fury.io/js/version-from-git)
4
4
 
5
5
  # Background
6
6
 
@@ -12,17 +12,18 @@ And use Travis CI to automatically publish the pre-release version to NPM, tagge
12
12
 
13
13
  # How to use
14
14
 
15
- Run `npx version-from-git`, it will run `npm version 1.0.0-master.1a2b3c4`.
15
+ Run `npx version-from-git`, it will run `npm version 1.0.0-main.1a2b3c4`.
16
16
 
17
17
  ```
18
18
  Usage: version-from-git [options]
19
19
 
20
- Bump package.json version to pre-release tagged with Git branch and short commit hash, 1.0.0-master.1a2b3c4
20
+ Bump package.json version to pre-release tagged with Git branch and short commit hash, 1.0.0-main.1a2b3c4
21
21
 
22
22
  Options:
23
23
 
24
24
  -V, --version output the version number
25
25
  -p, --path <path> path to package.json, default to current directory (default: C:\Users\Compulim\Source\Repos\version-from-git)
26
+ --template <template> pre-release version template (default: branch.short)
26
27
  -t, --travis run in Travis CI: skip when TRAVIS_TAG present
27
28
  -f, --force run "npm version" with --force
28
29
  -m, --message <message> run "npm version" with --message
@@ -41,15 +42,15 @@ Run `npx version-from-git -t`, it will detect whether `TRAVIS_TAG` environment v
41
42
 
42
43
  ## Customizing pre-release version pattern
43
44
 
44
- You can customize the version pattern when tagging for pre-release versions.
45
+ You can customize the version pattern when tagging for pre-release versions by running with argument `--template branch.short`.
45
46
 
46
47
  | Pattern name | Description | Sample |
47
- |--------------|------------------------------------------------------------------|--------------------------------------------|
48
- | `branch` | Branch name<br />In Travis, will use `process.env.TRAVIS_BRANCH` | `master` |
48
+ | ------------ | ---------------------------------------------------------------- | ------------------------------------------ |
49
+ | `branch` | Branch name<br />In Travis, will use `process.env.TRAVIS_BRANCH` | `main` |
49
50
  | `long` | Git commit in long form | `3807f9004867438c57a3e26f2073c33c458d4ef9` |
50
51
  | `short` | Git commit in short form | `3807f90` |
51
52
 
52
- Default pattern is `branch.short`, which would produce `master.1a2b3c4`.
53
+ Default pattern is `branch.short`, which would produce `main.1a2b3c4`.
53
54
 
54
55
  # Contributions
55
56
 
package/package.json CHANGED
@@ -1,26 +1,33 @@
1
1
  {
2
2
  "name": "version-from-git",
3
- "version": "1.1.1-0",
4
- "description": "Bump package.json version to pre-release tagged with Git branch and short commit hash, 1.0.0-master.1a2b3c4",
5
- "main": "src/index.js",
3
+ "version": "1.1.2-main.320b9e4",
4
+ "description": "Bump package.json version to pre-release tagged with Git branch and short commit hash, 1.0.0-main.1a2b3c4",
5
+ "files": [
6
+ "./src/**/*.cjs",
7
+ "./src/**/*.js",
8
+ "./src/**/*.mjs"
9
+ ],
10
+ "main": "./src/index.js",
6
11
  "bin": {
7
12
  "version-from-git": "./src/index.js"
8
13
  },
9
14
  "scripts": {
15
+ "bump": "npm run bump:prod && npm run bump:dev && npm run bump:auditfix",
16
+ "bump:auditfix": "npm audit fix || exit 0",
17
+ "bump:dev": "PACKAGES_TO_BUMP=$(cat package.json | jq -r '(.localPeerDependencies // {}) as $L | (.devDependencies // {}) | to_entries | map(select(.key as $K | $L | has($K) | not)) | map(.key + \"@latest\") | join(\" \")') && [ ! -z \"$PACKAGES_TO_BUMP\" ] && npm install $PACKAGES_TO_BUMP || true",
18
+ "bump:prod": "PACKAGES_TO_BUMP=$(cat package.json | jq -r '(.localPeerDependencies // {}) as $L | (.dependencies // {}) | to_entries | map(select(.key as $K | $L | has($K) | not)) | map(.key + \"@latest\") | join(\" \")') && [ ! -z \"$PACKAGES_TO_BUMP\" ] && npm install $PACKAGES_TO_BUMP || true",
19
+ "-precommit": "npm run precommit:eslint && npm run precommit:typescript:production && npm run precommit:typescript:test",
20
+ "precommit:eslint": "eslint ./src/",
21
+ "precommit:typescript:production": "tsc --noEmit --project ./src/tsconfig.precommit.production.json",
22
+ "precommit:typescript:test": "tsc --noEmit --project ./src/tsconfig.precommit.test.json",
23
+ "prepack": "cp ../../CHANGELOG.md . && cp ../../LICENSE . && cp ../../README.md .",
24
+ "switch": "cat package.json | jq --arg SWITCH_NAME $SWITCH_NAME -r '(.[\"switch:\" + $SWITCH_NAME] // {}) as $TEMPLATE | .devDependencies += ($TEMPLATE.devDependencies // {}) | .dependencies += ($TEMPLATE.dependencies // {})' | tee ./package.json.tmp && mv ./package.json.tmp ./package.json",
10
25
  "test": "echo \"TODO: Add tests\""
11
26
  },
12
- "author": "William Wong <compulim@hotmail.com> (http://compulim.info/)",
13
- "files": [
14
- "src/**/*"
15
- ],
16
27
  "repository": {
17
28
  "type": "git",
18
29
  "url": "git+https://github.com/compulim/version-from-git.git"
19
30
  },
20
- "bugs": {
21
- "url": "https://github.com/compulim/version-from-git/issues"
22
- },
23
- "homepage": "https://github.com/compulim/version-from-git#readme",
24
31
  "keywords": [
25
32
  "branch",
26
33
  "bump",
@@ -30,13 +37,22 @@
30
37
  "travis",
31
38
  "version"
32
39
  ],
40
+ "author": "William Wong (https://github.com/compulim)",
33
41
  "license": "MIT",
42
+ "bugs": {
43
+ "url": "https://github.com/compulim/version-from-git/issues"
44
+ },
45
+ "homepage": "https://github.com/compulim/version-from-git#readme",
34
46
  "dependencies": {
35
47
  "chalk": "^2.4.1",
36
48
  "commander": "^2.15.1",
37
49
  "cross-spawn": "^6.0.5",
38
- "git-rev-sync": "^1.12.0",
50
+ "git-rev-sync": "^3.0.2",
39
51
  "on-error-resume-next": "^1.0.0",
40
- "semver": "^5.5.0"
52
+ "semver": "^5.5.0",
53
+ "version-from-git": "^1.1.2-main.320b9e4"
54
+ },
55
+ "devDependencies": {
56
+ "@tsconfig/strictest": "^2.0.5"
41
57
  }
42
58
  }
package/src/index.js CHANGED
@@ -28,12 +28,12 @@ program
28
28
  .parse(process.argv);
29
29
 
30
30
  function main() {
31
- log(`Running ${ green(`${ ourPackageJSON.name }@${ ourPackageJSON.version }`) }`);
31
+ log(`Running ${green(`${ourPackageJSON.name}@${ourPackageJSON.version}`)}`);
32
32
 
33
33
  let branch, long, short;
34
34
 
35
35
  if (program.travis) {
36
- log(`Travis mode ${ magenta('enabled') }`);
36
+ log(`Travis mode ${magenta('enabled')}`);
37
37
 
38
38
  if (process.env.TRAVIS_TAG) {
39
39
  return log(yellow('Environment variable TRAVIS_TAG is present, we will not generate a new version, exiting'));
@@ -59,7 +59,7 @@ function main() {
59
59
 
60
60
  const packageJSONPath = resolve('package.json');
61
61
 
62
- log(`Reading from ${ magenta(packageJSONPath) }`);
62
+ log(`Reading from ${magenta(packageJSONPath)}`);
63
63
 
64
64
  const packageJSON = onErrorResumeNext(() => require(packageJSONPath));
65
65
 
@@ -71,34 +71,38 @@ function main() {
71
71
  const { version } = packageJSON;
72
72
  const preRelease = (program.template || DEFAULT_TEMPLATE).replace(/\w+/giu, name => {
73
73
  switch (name) {
74
- case 'branch': return branch;
75
- case 'short': return short;
76
- case 'long': return long;
77
-
78
- default: return name;
74
+ case 'branch':
75
+ return branch;
76
+ case 'short':
77
+ return short;
78
+ case 'long':
79
+ return long;
80
+
81
+ default:
82
+ return name;
79
83
  }
80
84
  });
81
85
 
82
- const nextVersion = `${ major(version) }.${ minor(version) }.${ patch(version) }-${ preRelease }`;
86
+ const nextVersion = `${major(version)}.${minor(version)}.${patch(version)}-${preRelease}`;
83
87
 
84
- log(`Bumping from ${ green(version) } to ${ green(nextVersion) }`);
88
+ log(`Bumping from ${green(version)} to ${green(nextVersion)}`);
85
89
 
86
90
  const args = [
87
91
  'version',
88
- ...program.allowSameVersion ? ['--allow-same-version'] : [],
89
- ...program.commitHooks ? [] : ['--no-commit-hooks'],
90
- ...program.force ? ['--force'] : [],
91
- ...program.gitTagVersion ? [] : ['--no-git-tag-version'],
92
- ...program.message ? ['--message', program.message] : [],
93
- ...program.signGitTag ? ['--sign-git-tag'] : [],
92
+ ...(program.allowSameVersion ? ['--allow-same-version'] : []),
93
+ ...(program.commitHooks ? [] : ['--no-commit-hooks']),
94
+ ...(program.force ? ['--force'] : []),
95
+ ...(program.gitTagVersion ? [] : ['--no-git-tag-version']),
96
+ ...(program.message ? ['--message', program.message] : []),
97
+ ...(program.signGitTag ? ['--sign-git-tag'] : []),
94
98
  nextVersion
95
99
  ];
96
100
 
97
- log(`Running ${ magenta(`npm ${ args.join(' ') }`) }`);
101
+ log(`Running ${magenta(`npm ${args.join(' ')}`)}`);
98
102
 
99
- // const result = spawn.sync('npm', args, { cwd, stdio: 'inherit' });
103
+ const result = spawn.sync('npm', args, { cwd, stdio: 'inherit' });
100
104
 
101
- // process.exit(result);
105
+ process.exit(result.status);
102
106
  }
103
107
 
104
108
  main();
package/CHANGELOG.md DELETED
@@ -1,15 +0,0 @@
1
- # Changelog
2
- All notable changes to this project will be documented in this file.
3
-
4
- The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5
- and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6
-
7
- ## [Unreleased]
8
-
9
- ## [1.1.0] - 2019-08-12
10
- ### Added
11
- - Fix [#2](https://github.com/compulim/version-from-git/issues/2). Supports customizing pre-release thru `--template`, in [PR #3](https://github.com/compulim/version-from-git/pulls/3)
12
-
13
- ## [1.0.0] - 2018-05-18
14
- ### Added
15
- - Initial commit