git-semver-tags 5.0.1 → 7.0.0
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/README.md +5 -5
- package/{cli.js → cli.mjs} +13 -13
- package/index.js +48 -45
- package/package.json +6 -9
package/README.md
CHANGED
|
@@ -16,12 +16,12 @@ $ npm install --save git-semver-tags
|
|
|
16
16
|
```js
|
|
17
17
|
var gitSemverTags = require('git-semver-tags');
|
|
18
18
|
|
|
19
|
-
// gitSemverTags([options
|
|
19
|
+
// gitSemverTags([options])
|
|
20
20
|
|
|
21
|
-
gitSemverTags(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
const tags = await gitSemverTags();
|
|
22
|
+
|
|
23
|
+
console.log(tags);
|
|
24
|
+
//=> [ 'v2.0.0', 'v1.0.0' ]
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
```sh
|
package/{cli.js → cli.mjs}
RENAMED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const gitSemverTags = require('./')
|
|
2
|
+
import meow from 'meow'
|
|
3
|
+
import gitSemverTags from './index.js'
|
|
5
4
|
|
|
6
5
|
const args = meow(`
|
|
7
6
|
Usage
|
|
@@ -10,8 +9,10 @@ const args = meow(`
|
|
|
10
9
|
--cwd path to git repository to be searched
|
|
11
10
|
--lerna parse lerna style git tags
|
|
12
11
|
--package <name> when listing lerna style tags, filter by a package
|
|
13
|
-
--tag-prefix <prefix> prefix to remove from the tags during their processing
|
|
12
|
+
--tag-prefix <prefix> prefix to remove from the tags during their processing
|
|
13
|
+
--skip-unstable if given, unstable tags will be skipped, e.g., x.x.x-alpha.1, x.x.x-rc.2`,
|
|
14
14
|
{
|
|
15
|
+
importMeta: import.meta,
|
|
15
16
|
booleanDefault: undefined,
|
|
16
17
|
flags: {
|
|
17
18
|
cwd: {
|
|
@@ -25,19 +26,18 @@ const args = meow(`
|
|
|
25
26
|
},
|
|
26
27
|
tagPrefix: {
|
|
27
28
|
type: 'string'
|
|
29
|
+
},
|
|
30
|
+
skipUnstable: {
|
|
31
|
+
type: 'boolean'
|
|
28
32
|
}
|
|
29
33
|
}
|
|
30
34
|
})
|
|
31
35
|
|
|
32
|
-
gitSemverTags({
|
|
36
|
+
const tags = await gitSemverTags({
|
|
33
37
|
lernaTags: args.flags.lerna,
|
|
34
38
|
package: args.flags.package,
|
|
35
|
-
tagPrefix: args.flags.tagPrefix
|
|
36
|
-
|
|
37
|
-
if (err) {
|
|
38
|
-
console.error(err.toString())
|
|
39
|
-
process.exit(1)
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
console.log(tags.join('\n'))
|
|
39
|
+
tagPrefix: args.flags.tagPrefix,
|
|
40
|
+
skipUnstable: args.flags.skipUnstable
|
|
43
41
|
})
|
|
42
|
+
|
|
43
|
+
console.log(tags.join('\n'))
|
package/index.js
CHANGED
|
@@ -1,68 +1,71 @@
|
|
|
1
|
-
|
|
1
|
+
const { exec } = require('child_process')
|
|
2
|
+
const { valid: semverValid } = require('semver')
|
|
2
3
|
|
|
3
|
-
const proc = require('process')
|
|
4
|
-
const exec = require('child_process').exec
|
|
5
|
-
const semverValid = require('semver').valid
|
|
6
4
|
const regex = /tag:\s*(.+?)[,)]/gi
|
|
7
5
|
const cmd = 'git log --decorate --no-color'
|
|
8
6
|
const unstableTagTest = /.+-\w+\.\d+$/
|
|
9
7
|
|
|
10
8
|
function lernaTag (tag, pkg) {
|
|
11
|
-
if (pkg && !(
|
|
9
|
+
if (pkg && !tag.startsWith(`${pkg}@`)) {
|
|
12
10
|
return false
|
|
13
|
-
} else {
|
|
14
|
-
return /^.+@[0-9]+\.[0-9]+\.[0-9]+(-.+)?$/.test(tag)
|
|
15
11
|
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
module.exports = function gitSemverTags (opts, callback) {
|
|
19
|
-
if (typeof opts === 'function') {
|
|
20
|
-
callback = opts
|
|
21
|
-
opts = {}
|
|
22
|
-
}
|
|
23
|
-
const options = Object.assign({ maxBuffer: Infinity, cwd: proc.cwd() }, opts)
|
|
24
12
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return
|
|
28
|
-
}
|
|
13
|
+
return /^.+@[0-9]+\.[0-9]+\.[0-9]+(-.+)?$/.test(tag)
|
|
14
|
+
}
|
|
29
15
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
16
|
+
function gitSemverTags (opts = {}) {
|
|
17
|
+
return new Promise((resolve, reject) => {
|
|
18
|
+
const options = {
|
|
19
|
+
maxBuffer: Infinity,
|
|
20
|
+
cwd: process.cwd(),
|
|
21
|
+
...opts
|
|
34
22
|
}
|
|
35
23
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
if (options.tagPrefix) {
|
|
39
|
-
tagPrefixRegexp = new RegExp('^' + options.tagPrefix + '(.*)')
|
|
24
|
+
if (options.package && !options.lernaTags) {
|
|
25
|
+
throw new Error('opts.package should only be used when running in lerna mode')
|
|
40
26
|
}
|
|
41
|
-
|
|
27
|
+
|
|
28
|
+
exec(cmd, options, (err, data) => {
|
|
29
|
+
if (err) {
|
|
30
|
+
reject(err)
|
|
31
|
+
return
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const tags = []
|
|
42
35
|
let match
|
|
43
|
-
|
|
44
|
-
|
|
36
|
+
let tag
|
|
37
|
+
let unprefixedTag
|
|
45
38
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
39
|
+
data.split('\n').forEach((decorations) => {
|
|
40
|
+
while ((match = regex.exec(decorations))) {
|
|
41
|
+
tag = match[1]
|
|
50
42
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
43
|
+
if (options.skipUnstable && unstableTagTest.test(tag)) {
|
|
44
|
+
// skip unstable tag
|
|
45
|
+
continue
|
|
54
46
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
47
|
+
|
|
48
|
+
if (options.lernaTags) {
|
|
49
|
+
if (lernaTag(tag, options.package)) {
|
|
50
|
+
tags.push(tag)
|
|
51
|
+
}
|
|
52
|
+
} else if (options.tagPrefix) {
|
|
53
|
+
if (tag.startsWith(options.tagPrefix)) {
|
|
54
|
+
unprefixedTag = tag.replace(options.tagPrefix, '')
|
|
55
|
+
|
|
56
|
+
if (semverValid(unprefixedTag)) {
|
|
57
|
+
tags.push(tag)
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
} else if (semverValid(tag)) {
|
|
58
61
|
tags.push(tag)
|
|
59
62
|
}
|
|
60
|
-
} else if (semverValid(tag)) {
|
|
61
|
-
tags.push(tag)
|
|
62
63
|
}
|
|
63
|
-
}
|
|
64
|
-
})
|
|
64
|
+
})
|
|
65
65
|
|
|
66
|
-
|
|
66
|
+
resolve(tags)
|
|
67
|
+
})
|
|
67
68
|
})
|
|
68
69
|
}
|
|
70
|
+
|
|
71
|
+
module.exports = gitSemverTags
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "git-semver-tags",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"description": "Get all git semver tags of your repository in reverse chronological order",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/conventional-changelog/conventional-changelog/issues"
|
|
@@ -17,11 +17,11 @@
|
|
|
17
17
|
},
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"engines": {
|
|
20
|
-
"node": ">=
|
|
20
|
+
"node": ">=16"
|
|
21
21
|
},
|
|
22
22
|
"files": [
|
|
23
23
|
"index.js",
|
|
24
|
-
"cli.
|
|
24
|
+
"cli.mjs"
|
|
25
25
|
],
|
|
26
26
|
"keywords": [
|
|
27
27
|
"git-semver-tags",
|
|
@@ -32,13 +32,10 @@
|
|
|
32
32
|
"git"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"meow": "^
|
|
36
|
-
"semver": "^7.
|
|
35
|
+
"meow": "^12.0.1",
|
|
36
|
+
"semver": "^7.5.2"
|
|
37
37
|
},
|
|
38
38
|
"bin": {
|
|
39
|
-
"git-semver-tags": "cli.
|
|
40
|
-
},
|
|
41
|
-
"scripts": {
|
|
42
|
-
"test-windows": "mocha --timeout 30000"
|
|
39
|
+
"git-semver-tags": "cli.mjs"
|
|
43
40
|
}
|
|
44
41
|
}
|