homebridge-alexa 0.7.1-beta.2 → 0.7.1-beta.4

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.
@@ -4,23 +4,25 @@
4
4
  * This scripts queries the npm registry to pull out the latest version for a given tag.
5
5
  */
6
6
 
7
- const fs = require("fs");
8
- const semver = require("semver");
9
- const child_process = require("child_process");
10
- const assert = require("assert");
7
+ const assert = require('node:assert')
8
+ const child_process = require('node:child_process')
9
+ const fs = require('node:fs')
10
+ const process = require('node:process')
11
11
 
12
- const BRANCH_VERSION_PATTERN = /^([A-Za-z]*)-(\d+.\d+.\d+)$/
12
+ const semver = require('semver')
13
+
14
+ const BRANCH_VERSION_PATTERN = /^([A-Z]+)-(\d+\.\d+\.\d+)$/i
13
15
 
14
16
  // Load the contents of the package.json file
15
- const packageJSON = JSON.parse(fs.readFileSync("package.json", "utf8"));
17
+ const packageJSON = JSON.parse(fs.readFileSync('package.json', 'utf8'))
16
18
 
17
- let refArgument = process.argv[2];
18
- let tagArgument = process.argv[3] || "latest";
19
+ const refArgument = process.argv[2]
20
+ const tagArgument = process.argv[3] || 'latest'
19
21
 
20
22
  if (refArgument == null) {
21
- console.error("ref argument is missing");
22
- console.error("Usage: npm-version-script.js <ref> [tag]");
23
- process.exit(1);
23
+ console.error('ref argument is missing')
24
+ console.error('Usage: npm-version-script.js <ref> [tag]')
25
+ process.exit(1)
24
26
  }
25
27
 
26
28
  /**
@@ -30,64 +32,54 @@ if (refArgument == null) {
30
32
  */
31
33
  function getTagVersionFromNpm(tag) {
32
34
  try {
33
- return child_process.execSync(`npm info ${packageJSON.name} version --tag="${tag}"`).toString("utf8").trim();
35
+ return child_process.execSync(`npm info ${packageJSON.name} version --tag="${tag}"`).toString('utf8').trim()
34
36
  } catch (e) {
35
- console.error(`Failed to query the npm registry for the latest version for tag: ${tag}`);
37
+ console.error(`Failed to query the npm registry for the latest version for tag: ${tag}`)
36
38
  // throw e;
37
- return "0.0.0";
39
+ return '0.0.0'
38
40
  }
39
41
  }
40
42
 
41
43
  function desiredTargetVersion(ref) {
42
44
  // ref is a GitHub action ref string
43
- if (ref.startsWith("refs/pull/")) {
44
- throw Error("The version script was executed inside a PR!");
45
+ if (ref.startsWith('refs/pull/')) {
46
+ throw new Error('The version script was executed inside a PR!')
45
47
  }
46
48
 
47
- assert(ref.startsWith("refs/heads/"))
48
- let branchName = ref.slice("refs/heads/".length);
49
+ assert(ref.startsWith('refs/heads/'))
50
+ const branchName = ref.slice('refs/heads/'.length)
49
51
 
50
- let results = branchName.match(BRANCH_VERSION_PATTERN);
52
+ const results = branchName.match(BRANCH_VERSION_PATTERN)
51
53
  if (results != null) {
52
54
  if (results[1] !== tagArgument) {
53
- console.warn(`The base branch name (${results[1]}) differs from the tag name ${tagArgument}`);
55
+ console.warn(`The base branch name (${results[1]}) differs from the tag name ${tagArgument}`)
54
56
  }
55
57
 
56
- return results[2];
57
- }
58
-
59
- // legacy mode were we use the `betaVersion` property in the package.json
60
- if (branchName === "beta" && packageJSON.betaVersion) {
61
- return packageJSON.betaVersion
62
- }
63
-
64
- // legacy mode were we use the `alphaVersion` property in the package.json
65
- if (branchName === "alpha" && packageJSON.alphaVersion) {
66
- return packageJSON.alphaVersion
58
+ return results[2]
67
59
  }
68
60
 
69
- 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`);
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`)
70
62
  }
71
63
 
72
64
  // derive the base version from the branch ref
73
- const baseVersion = desiredTargetVersion(refArgument);
65
+ const baseVersion = desiredTargetVersion(refArgument)
74
66
 
75
67
  // query the npm registry for the latest version of the provided tag name
76
- const latestReleasedVersion = getTagVersionFromNpm(tagArgument); // e.g. 0.7.0-beta.12
77
- const latestReleaseBase = semver.inc(latestReleasedVersion, "patch"); // will produce 0.7.0 (removing the preid, needed for the equality check below)
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)
78
70
 
79
- let publishTag;
71
+ let publishTag
80
72
  if (semver.eq(baseVersion, latestReleaseBase)) { // check if we are releasing another version for the latest beta or alpha
81
- publishTag = latestReleasedVersion; // set the current latest beta or alpha to be incremented
73
+ publishTag = latestReleasedVersion // set the current latest beta or alpha to be incremented
82
74
  } else {
83
- publishTag = baseVersion; // start of with a new beta or alpha version
75
+ publishTag = baseVersion // start of with a new beta or alpha version
84
76
  }
85
77
 
86
78
  // save the package.json
87
- packageJSON.version = publishTag;
88
- fs.writeFileSync("package.json", JSON.stringify(packageJSON, null, 2));
79
+ packageJSON.version = publishTag
80
+ fs.writeFileSync('package.json', JSON.stringify(packageJSON, null, 2))
89
81
 
90
82
  // perform the same change to the package-lock.json
91
- const packageLockJSON = JSON.parse(fs.readFileSync("package-lock.json", "utf8"));
92
- packageLockJSON.version = publishTag;
93
- fs.writeFileSync("package-lock.json", JSON.stringify(packageLockJSON, null, 2));
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))
package/CHANGELOG.md CHANGED
@@ -9,6 +9,7 @@ All notable changes to this project will be documented in this file. This projec
9
9
  #### Changes
10
10
 
11
11
  - Update `filter` to accept a list of addresses and ports ie "192.168.1.11:51551, 192.168.1.11:46047"
12
+ - Add config option `enhancedSkip` to allow the wording `Alexa, tv skip` when watching youtube via appletv-enhanced to push the select button on the remote.
12
13
 
13
14
  ## 0.7.0 (2023-05-30)
14
15
 
@@ -220,6 +220,12 @@
220
220
  }
221
221
  }
222
222
  }
223
+ },
224
+ "enhancedSkip": {
225
+ "title": "<b>For 'appletv-enhanced', enable skip</b>",
226
+ "type": "boolean",
227
+ "placeholder": false,
228
+ "description": "This option will change the behaviour of the next or skip command of the 'appletv-enhanced' plugin, from skip to select. This will enable the wording 'Alexa tv skip' to press the select button on the Apple TV remote. This is useful for skipping adds on YouTube."
223
229
  }
224
230
  }
225
231
  },
@@ -251,6 +257,7 @@
251
257
  "routines",
252
258
  "debug",
253
259
  "thermostatTurnOn",
260
+ "enhancedSkip",
254
261
  "deviceListHandling",
255
262
  {
256
263
  "key": "deviceList",
@@ -312,10 +312,15 @@ function _getActions(description, context, devices) {
312
312
  Characteristic.RemoteKey.INFORMATION = 15;
313
313
  */
314
314
  // "Play", "Pause", "Stop", "Next", "Previous"
315
+ // console.log("Remote Key", context);
315
316
  cookie["Pause"] = messages.cookieV(11, context);
316
317
  cookie["Play"] = messages.cookieV(8, context);
317
318
  cookie["Stop"] = messages.cookieV(9, context);
318
- cookie["Next"] = messages.cookieV(7, context);
319
+ if (context.options.enhancedSkip === true && context.info.Manufacturer === 'Apple Inc.') {
320
+ cookie["Next"] = messages.cookieV(8, context);
321
+ } else {
322
+ cookie["Next"] = messages.cookieV(7, context);
323
+ }
319
324
  cookie["Previous"] = messages.cookieV(6, context);
320
325
  break;
321
326
  default:
@@ -22,7 +22,8 @@ function Homebridge(devices, context) {
22
22
  blind: context.blind,
23
23
  door: context.door,
24
24
  mergeServiceName: context.mergeServiceName,
25
- thermostatTurnOn: context.thermostatTurnOn
25
+ thermostatTurnOn: context.thermostatTurnOn,
26
+ enhancedSkip: context.enhancedSkip,
26
27
  };
27
28
  this.playback = {};
28
29
  devices.accessories.accessories.forEach(function (element) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "homebridge-alexa",
3
- "version": "0.7.1-beta.2",
3
+ "version": "0.7.1-beta.4",
4
4
  "description": "Control your Homebridge devices with Amazon Alexa.",
5
5
  "main": "plugin.js",
6
6
  "scripts": {
@@ -50,7 +50,7 @@
50
50
  "dependencies": {
51
51
  "bottleneck": "2.19.5",
52
52
  "debug": "4.3.6",
53
- "hap-node-client": "0.2.8-beta.12",
53
+ "hap-node-client": "^0.2.8",
54
54
  "is-my-json-valid": "2.20.6",
55
55
  "mqtt": "5.9.1"
56
56
  },
@@ -59,5 +59,28 @@
59
59
  "bugs": {
60
60
  "url": "https://github.com/NorthernMan54/homebridge-alexa/issues"
61
61
  },
62
- "homepage": "https://github.com/NorthernMan54/homebridge-alexa#readme"
62
+ "homepage": "https://github.com/NorthernMan54/homebridge-alexa#readme",
63
+ "jest": {
64
+ "moduleFileExtensions": [
65
+ "js",
66
+ "json",
67
+ "ts"
68
+ ],
69
+ "rootDir": "./",
70
+ "testEnvironment": "node",
71
+ "testRegex": ".test.ts$",
72
+ "testTimeout": 10000,
73
+ "transform": {
74
+ "^.+\\.(t)s$": "ts-jest"
75
+ },
76
+ "collectCoverageFrom": [
77
+ "**/*.ts"
78
+ ],
79
+ "coveragePathIgnorePatterns": [
80
+ "/ui/",
81
+ "/test/",
82
+ "/dist/",
83
+ "/scripts/"
84
+ ]
85
+ }
63
86
  }
package/plugin.js CHANGED
@@ -45,6 +45,7 @@ function alexaHome(log, config, api) {
45
45
  this.CloudTransport = config['CloudTransport'] || "mqtts"; // Default to mqtts Transport
46
46
  this.LegacyCloudTransport = config['LegacyCloudTransport'] || false; // Default to new Transport ( Setting from discarded beta )
47
47
  var mqttKeepalive = config['keepalive'] || 5; // MQTT Connection Keepalive
48
+ this.enhancedSkip = config['enhancedSkip'] || false; // Use enhanced skip for appletv-enhanced plugin
48
49
 
49
50
  if (mqttKeepalive < 60) {
50
51
  this.keepalive = mqttKeepalive * 60;
@@ -143,7 +144,8 @@ alexaHome.prototype.didFinishLaunching = function () {
143
144
  door: this.door,
144
145
  mergeServiceName: this.mergeServiceName,
145
146
  // Other Options
146
- events: this.events
147
+ events: this.events,
148
+ enhancedSkip: this.enhancedSkip
147
149
  };
148
150
 
149
151
  // Initialize HAP Connections
package/jest.config.json DELETED
@@ -1,12 +0,0 @@
1
- {
2
- "moduleFileExtensions": ["js", "json", "ts"],
3
- "rootDir": "./",
4
- "testEnvironment": "node",
5
- "testRegex": ".test.ts$",
6
- "testTimeout": 10000,
7
- "transform": {
8
- "^.+\\.(t)s$": "ts-jest"
9
- },
10
- "collectCoverageFrom": ["**/*.ts"],
11
- "coveragePathIgnorePatterns": ["/ui/", "/test/", "/dist/", "/scripts/"]
12
- }