@sequencemedia/minimserver 1.2.2 → 1.2.3
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/.husky/post-commit +4 -0
- package/build/gulp/post-commit.mjs +48 -0
- package/build/gulp/pre-commit.mjs +39 -8
- package/gulpfile.mjs +4 -0
- package/package.json +2 -1
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import debug from 'debug'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
readFile
|
|
5
|
+
} from 'fs/promises'
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
exec
|
|
9
|
+
} from 'child_process'
|
|
10
|
+
|
|
11
|
+
const OPTIONS = {
|
|
12
|
+
maxBuffer: 1024 * 500
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const log = debug('@sequencemedia/minimserver:build:gulp:post-commit')
|
|
16
|
+
const error = debug('@sequencemedia/minimserver:build:gulp:post-commit:error')
|
|
17
|
+
|
|
18
|
+
log('`@sequencemedia/minimserver` is awake')
|
|
19
|
+
|
|
20
|
+
export async function getPackageVersion () {
|
|
21
|
+
log('getPackageVersion')
|
|
22
|
+
|
|
23
|
+
const {
|
|
24
|
+
version = '0.0.0'
|
|
25
|
+
} = JSON.parse(await readFile('./package.json', 'utf8'))
|
|
26
|
+
|
|
27
|
+
return version
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function gitTag (a = '0.0.0', m = `v${a}`) {
|
|
31
|
+
log('gitTag')
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
new Promise((resolve, reject) => {
|
|
35
|
+
exec(`git tag -a v${a} -m "${m}"`, OPTIONS, (e, v) => (!e) ? resolve(v) : reject(e))
|
|
36
|
+
})
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export default async function postCommit () {
|
|
41
|
+
log('post-commit')
|
|
42
|
+
|
|
43
|
+
try {
|
|
44
|
+
await gitTag(await getPackageVersion())
|
|
45
|
+
} catch ({ code = 'NONE', message = 'No error message defined' }) {
|
|
46
|
+
error({ code, message })
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
} from 'child_process'
|
|
6
6
|
|
|
7
7
|
const log = debug('@sequencemedia/minimserver:build:gulp:pre-commit')
|
|
8
|
+
const error = debug('@sequencemedia/minimserver:build:gulp:pre-commit:error')
|
|
8
9
|
|
|
9
10
|
log('`@sequencemedia/minimserver` is awake')
|
|
10
11
|
|
|
@@ -18,22 +19,52 @@ const OPTIONS = {
|
|
|
18
19
|
maxBuffer: 1024 * 500
|
|
19
20
|
}
|
|
20
21
|
|
|
21
|
-
|
|
22
|
+
const BRANCH = 'master'
|
|
23
|
+
|
|
24
|
+
const trim = (v) => v.split('\n').map((v) => v.trimEnd()).join('\n').trim()
|
|
25
|
+
|
|
26
|
+
function use (key) {
|
|
27
|
+
const log = debug(`@sequencemedia/minimserver:${key}`)
|
|
28
|
+
|
|
29
|
+
return function use (v) {
|
|
30
|
+
log(trim(v))
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function getGitRemoteShowOriginHeadBranch () {
|
|
35
|
+
log('getGitRemoteShowOriginHeadBranch')
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
new Promise((resolve, reject) => {
|
|
39
|
+
const command = 'git remote show origin | awk \'/HEAD branch/ {print $NF}\''
|
|
40
|
+
|
|
41
|
+
const {
|
|
42
|
+
stdout,
|
|
43
|
+
stderr
|
|
44
|
+
} = exec(command, OPTIONS, (e, v = '') => (!e) ? resolve(trim(v)) : reject(e))
|
|
45
|
+
|
|
46
|
+
stdout.on('data', use('git-remote-show-origin-head-branch'))
|
|
47
|
+
stderr.on('data', use('git-remote-show-origin-head-branch'))
|
|
48
|
+
})
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function hasPackageVersionChanges (branch = BRANCH) {
|
|
22
53
|
log('hasPackageVersionChanges')
|
|
23
54
|
|
|
24
55
|
return (
|
|
25
56
|
new Promise((resolve, reject) => {
|
|
26
|
-
exec(
|
|
57
|
+
exec(`git diff HEAD origin/${branch} package.json`, OPTIONS, (e, v) => (!e) ? resolve(PACKAGE_VERSION_CHANGES.test(v)) : reject(e))
|
|
27
58
|
})
|
|
28
59
|
)
|
|
29
60
|
}
|
|
30
61
|
|
|
31
|
-
export function notPackageVersionChanges () {
|
|
62
|
+
export function notPackageVersionChanges (branch = BRANCH) {
|
|
32
63
|
log('notPackageVersionChanges')
|
|
33
64
|
|
|
34
65
|
return (
|
|
35
66
|
new Promise((resolve, reject) => {
|
|
36
|
-
exec(
|
|
67
|
+
exec(`git diff HEAD origin/${branch} package.json`, OPTIONS, (e, v) => (!e) ? resolve(PACKAGE_VERSION_CHANGES.test(v) !== true) : reject(e))
|
|
37
68
|
})
|
|
38
69
|
)
|
|
39
70
|
}
|
|
@@ -58,12 +89,12 @@ export function notStagedChanges () {
|
|
|
58
89
|
)
|
|
59
90
|
}
|
|
60
91
|
|
|
61
|
-
export function notPushedChanges () {
|
|
92
|
+
export function notPushedChanges (branch = BRANCH) {
|
|
62
93
|
log('notPushedChanges')
|
|
63
94
|
|
|
64
95
|
return (
|
|
65
96
|
new Promise((resolve, reject) => {
|
|
66
|
-
exec(
|
|
97
|
+
exec(`git log origin/${branch}..HEAD`, OPTIONS, (e, v) => (!e) ? resolve(!!v) : reject(e))
|
|
67
98
|
})
|
|
68
99
|
)
|
|
69
100
|
}
|
|
@@ -103,12 +134,12 @@ export default async function preCommit () {
|
|
|
103
134
|
/**
|
|
104
135
|
* Not package version changes, continue
|
|
105
136
|
*/
|
|
106
|
-
if (await notPackageVersionChanges()) {
|
|
137
|
+
if (await notPackageVersionChanges(await getGitRemoteShowOriginHeadBranch())) {
|
|
107
138
|
await patchPackageVersion()
|
|
108
139
|
await addPackageVersionChanges()
|
|
109
140
|
}
|
|
110
141
|
}
|
|
111
142
|
} catch ({ code = 'NONE', message = 'No error message defined' }) {
|
|
112
|
-
|
|
143
|
+
error({ code, message })
|
|
113
144
|
}
|
|
114
145
|
}
|
package/gulpfile.mjs
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import gulp from 'gulp'
|
|
2
2
|
|
|
3
3
|
import preCommit from '#build/gulp/pre-commit'
|
|
4
|
+
import postCommit from '#build/gulp/post-commit'
|
|
4
5
|
|
|
5
6
|
gulp
|
|
6
7
|
.task('pre-commit', preCommit)
|
|
7
8
|
|
|
9
|
+
gulp
|
|
10
|
+
.task('post-commit', postCommit)
|
|
11
|
+
|
|
8
12
|
gulp
|
|
9
13
|
.task('default', gulp.series('pre-commit'))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sequencemedia/minimserver",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.3",
|
|
4
4
|
"description": "Watch for changes to M3Us and rescan MinimServer",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"minimserver",
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"dev": "cross-env DEBUG=@sequencemedia/minimserver* NODE_ENV=development node .",
|
|
36
36
|
"gulp": "gulp --color",
|
|
37
37
|
"pre-commit": "npm run lint && cross-env DEBUG=@sequencemedia/minimserver,@sequencemedia/minimserver:* npm run gulp -- pre-commit",
|
|
38
|
+
"post-commit": "cross-env DEBUG=@sequencemedia/minimserver,@sequencemedia/minimserver:* npm run gulp -- post-commit",
|
|
38
39
|
"prepare": "husky install"
|
|
39
40
|
},
|
|
40
41
|
"dependencies": {
|