@homebridge-plugins/homebridge-smarthq 0.1.0-beta.5 → 0.1.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/CHANGELOG.md
CHANGED
|
@@ -6,7 +6,7 @@ All notable changes to this project will be documented in this file. This projec
|
|
|
6
6
|
|
|
7
7
|
### What's Changes
|
|
8
8
|
|
|
9
|
-
- Release of [@homebridge-plugins/homebridge-smarthq](https://github.com/homebridge-plugins/homebridge-smarthq) which allows
|
|
9
|
+
- Release of [@homebridge-plugins/homebridge-smarthq](https://github.com/homebridge-plugins/homebridge-smarthq) which allows to interact with SmartHQ API.
|
|
10
10
|
|
|
11
11
|
**Full Changelog**: https://github.com/homebridge-plugins/homebridge-smarthq/compare/v0.1.0...v1.0.0
|
|
12
12
|
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@homebridge-plugins/homebridge-smarthq",
|
|
3
3
|
"displayName": "SmartHQ",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "0.1.0
|
|
5
|
+
"version": "0.1.0",
|
|
6
6
|
"description": "The SmartHQ plugin allows you to interact with SmartHQ Devices in HomeKit and with Siri.",
|
|
7
7
|
"author": {
|
|
8
8
|
"name": "donavanbecker",
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
#!/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* This scripts queries the npm registry to pull out the latest version for a given tag.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import assert from 'node:assert'
|
|
8
|
-
import child_process from 'node:child_process'
|
|
9
|
-
import fs from 'node:fs'
|
|
10
|
-
import process from 'node:process'
|
|
11
|
-
|
|
12
|
-
import semver from 'semver'
|
|
13
|
-
|
|
14
|
-
const BRANCH_VERSION_PATTERN = /^([A-Z]+)-(\d+\.\d+\.\d+)$/i
|
|
15
|
-
|
|
16
|
-
// Load the contents of the package.json file
|
|
17
|
-
const packageJSON = JSON.parse(fs.readFileSync('package.json', 'utf8'))
|
|
18
|
-
|
|
19
|
-
const refArgument = process.argv[2]
|
|
20
|
-
const tagArgument = process.argv[3] || 'latest'
|
|
21
|
-
|
|
22
|
-
if (refArgument === null) {
|
|
23
|
-
console.error('ref argument is missing')
|
|
24
|
-
console.error('Usage: npm-version-script-esm.js <ref> [tag]')
|
|
25
|
-
process.exit(1)
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Queries the NPM registry for the latest version for the provided tag.
|
|
30
|
-
* @param tag The tag to query for.
|
|
31
|
-
* @returns {string} Returns the version.
|
|
32
|
-
*/
|
|
33
|
-
function getTagVersionFromNpm(tag) {
|
|
34
|
-
try {
|
|
35
|
-
return child_process.execSync(`npm info ${packageJSON.name} version --tag="${tag}"`).toString('utf8').trim()
|
|
36
|
-
} catch (e) {
|
|
37
|
-
console.error(`Failed to query the npm registry for the latest version for tag: ${tag}`)
|
|
38
|
-
// throw e;
|
|
39
|
-
return '0.0.0'
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function desiredTargetVersion(ref) {
|
|
44
|
-
// ref is a GitHub action ref string
|
|
45
|
-
if (ref.startsWith('refs/pull/')) {
|
|
46
|
-
throw new Error('The version script was executed inside a PR!')
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
assert(ref.startsWith('refs/heads/'))
|
|
50
|
-
const branchName = ref.slice('refs/heads/'.length)
|
|
51
|
-
|
|
52
|
-
const results = branchName.match(BRANCH_VERSION_PATTERN)
|
|
53
|
-
if (results !== null) {
|
|
54
|
-
if (results[1] !== tagArgument) {
|
|
55
|
-
console.warn(`The base branch name (${results[1]}) differs from the tag name ${tagArgument}`)
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return results[2]
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
throw new Error(`Malformed branch name for ref: ${ref}. Can't derive the base version. Use a branch name like: beta-x.x.x or alpha-x.x.x`)
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// derive the base version from the branch ref
|
|
65
|
-
const baseVersion = desiredTargetVersion(refArgument)
|
|
66
|
-
|
|
67
|
-
// query the npm registry for the latest version of the provided tag name
|
|
68
|
-
const latestReleasedVersion = getTagVersionFromNpm(tagArgument) // e.g. 0.7.0-beta.12
|
|
69
|
-
const latestReleaseBase = semver.inc(latestReleasedVersion, 'patch') // will produce 0.7.0 (removing the preid, needed for the equality check below)
|
|
70
|
-
|
|
71
|
-
let publishTag
|
|
72
|
-
if (semver.eq(baseVersion, latestReleaseBase)) { // check if we are releasing another version for the latest beta or alpha
|
|
73
|
-
publishTag = latestReleasedVersion // set the current latest beta or alpha to be incremented
|
|
74
|
-
} else {
|
|
75
|
-
publishTag = baseVersion // start of with a new beta or alpha version
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// save the package.json
|
|
79
|
-
packageJSON.version = publishTag
|
|
80
|
-
fs.writeFileSync('package.json', JSON.stringify(packageJSON, null, 2))
|
|
81
|
-
|
|
82
|
-
// perform the same change to the package-lock.json
|
|
83
|
-
const packageLockJSON = JSON.parse(fs.readFileSync('package-lock.json', 'utf8'))
|
|
84
|
-
packageLockJSON.version = publishTag
|
|
85
|
-
fs.writeFileSync('package-lock.json', JSON.stringify(packageLockJSON, null, 2))
|