@switchbot/homebridge-switchbot 2.9.1-beta.3 → 2.9.1
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/.eslintrc +47 -14
- package/.vscode/settings.json +7 -1
- package/CHANGELOG.md +79 -70
- package/SECURITY.md +2 -2
- package/config.schema.json +348 -114
- package/dist/device/blindtilt.d.ts +0 -3
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +13 -62
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts +0 -3
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +49 -116
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts +0 -3
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +17 -60
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts +0 -3
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +13 -56
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts +0 -3
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +19 -69
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts +0 -3
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +16 -66
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/hub.d.ts +1 -4
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +16 -69
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts +0 -3
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +16 -63
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts +0 -3
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +16 -65
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts +0 -3
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +13 -56
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts +0 -3
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +22 -68
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts +0 -3
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +16 -68
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts +1 -4
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +16 -69
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts +0 -3
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +12 -62
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts +0 -3
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +6 -53
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts +0 -3
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +18 -65
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts +0 -1
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +9 -47
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts +0 -1
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +9 -47
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts +0 -1
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +9 -47
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts +0 -1
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +9 -47
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/light.d.ts +0 -1
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +9 -47
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts +0 -1
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +44 -77
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts +0 -1
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +18 -56
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts +0 -1
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +9 -47
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts +0 -1
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +9 -47
- package/dist/irdevice/waterheater.js.map +1 -1
- package/nodemon.json +4 -2
- package/package.json +9 -14
- package/src/device/blindtilt.ts +14 -62
- package/src/device/bot.ts +51 -108
- package/src/device/ceilinglight.ts +17 -61
- package/src/device/colorbulb.ts +13 -56
- package/src/device/contact.ts +20 -69
- package/src/device/curtain.ts +17 -66
- package/src/device/hub.ts +16 -70
- package/src/device/humidifier.ts +16 -64
- package/src/device/iosensor.ts +17 -66
- package/src/device/lightstrip.ts +13 -56
- package/src/device/lock.ts +22 -69
- package/src/device/meter.ts +18 -69
- package/src/device/meterplus.ts +17 -70
- package/src/device/motion.ts +13 -62
- package/src/device/plug.ts +6 -52
- package/src/device/robotvacuumcleaner.ts +18 -65
- package/src/irdevice/airconditioner.ts +9 -46
- package/src/irdevice/airpurifier.ts +9 -48
- package/src/irdevice/camera.ts +9 -48
- package/src/irdevice/fan.ts +9 -48
- package/src/irdevice/light.ts +9 -48
- package/src/irdevice/other.ts +44 -78
- package/src/irdevice/tv.ts +18 -57
- package/src/irdevice/vacuumcleaner.ts +9 -48
- package/src/irdevice/waterheater.ts +9 -48
- package/tsconfig.json +16 -4
- package/.github/npm-version-script.js +0 -81
- package/.prettierrc +0 -9
package/src/irdevice/other.ts
CHANGED
|
@@ -49,20 +49,8 @@ export class Others {
|
|
|
49
49
|
.getService(this.platform.Service.AccessoryInformation)!
|
|
50
50
|
.setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
|
|
51
51
|
.setCharacteristic(this.platform.Characteristic.Model, device.remoteType)
|
|
52
|
-
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId
|
|
53
|
-
|
|
54
|
-
if (accessory.context.FirmwareRevision) {
|
|
55
|
-
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
56
|
-
+ ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
|
|
57
|
-
accessory
|
|
58
|
-
.getService(this.platform.Service.AccessoryInformation)!
|
|
59
|
-
.setCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
|
|
60
|
-
.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
|
|
61
|
-
.getCharacteristic(this.platform.Characteristic.FirmwareRevision)
|
|
62
|
-
.updateValue(accessory.context.FirmwareRevision);
|
|
63
|
-
} else {
|
|
64
|
-
this.setFirmwareRevision(accessory, device);
|
|
65
|
-
}
|
|
52
|
+
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId)
|
|
53
|
+
.setCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision);
|
|
66
54
|
|
|
67
55
|
// deviceType
|
|
68
56
|
if (this.otherDeviceType === 'switch') {
|
|
@@ -77,8 +65,9 @@ export class Others {
|
|
|
77
65
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
78
66
|
|
|
79
67
|
// Add switchService
|
|
80
|
-
|
|
81
|
-
|
|
68
|
+
const switchService = `${accessory.displayName} Switch`;
|
|
69
|
+
(this.switchService = accessory.getService(this.platform.Service.Switch)
|
|
70
|
+
|| accessory.addService(this.platform.Service.Switch)), switchService;
|
|
82
71
|
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Switch`);
|
|
83
72
|
|
|
84
73
|
this.switchService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
@@ -97,10 +86,10 @@ export class Others {
|
|
|
97
86
|
this.removeWindowCoveringService(accessory);
|
|
98
87
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
99
88
|
|
|
100
|
-
// Add
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
89
|
+
// Add garageDoorService
|
|
90
|
+
const garageDoorService = `${accessory.displayName} Garage Door Opener`;
|
|
91
|
+
(this.garageDoorService = accessory.getService(this.platform.Service.GarageDoorOpener)
|
|
92
|
+
|| accessory.addService(this.platform.Service.GarageDoorOpener)), garageDoorService;
|
|
104
93
|
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Garage Door Opener`);
|
|
105
94
|
|
|
106
95
|
this.garageDoorService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
@@ -120,9 +109,10 @@ export class Others {
|
|
|
120
109
|
this.removeWindowCoveringService(accessory);
|
|
121
110
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
122
111
|
|
|
123
|
-
// Add
|
|
124
|
-
|
|
125
|
-
|
|
112
|
+
// Add doorService
|
|
113
|
+
const doorService = `${accessory.displayName} Door`;
|
|
114
|
+
(this.doorService = accessory.getService(this.platform.Service.Door)
|
|
115
|
+
|| accessory.addService(this.platform.Service.Door)), doorService;
|
|
126
116
|
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Door`);
|
|
127
117
|
|
|
128
118
|
this.doorService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
@@ -150,9 +140,10 @@ export class Others {
|
|
|
150
140
|
this.removeWindowCoveringService(accessory);
|
|
151
141
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
152
142
|
|
|
153
|
-
// Add
|
|
154
|
-
|
|
155
|
-
|
|
143
|
+
// Add windowService
|
|
144
|
+
const windowService = `${accessory.displayName} Window`;
|
|
145
|
+
(this.windowService = accessory.getService(this.platform.Service.Window)
|
|
146
|
+
|| accessory.addService(this.platform.Service.Window)), windowService;
|
|
156
147
|
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Window`);
|
|
157
148
|
|
|
158
149
|
this.windowService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
@@ -180,10 +171,10 @@ export class Others {
|
|
|
180
171
|
this.removeGarageDoorService(accessory);
|
|
181
172
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
182
173
|
|
|
183
|
-
// Add
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
174
|
+
// Add windowCoveringService
|
|
175
|
+
const windowCoveringService = `${accessory.displayName} Window Covering`;
|
|
176
|
+
(this.windowCoveringService = accessory.getService(this.platform.Service.WindowCovering)
|
|
177
|
+
|| accessory.addService(this.platform.Service.WindowCovering)), windowCoveringService;
|
|
187
178
|
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Window Covering`);
|
|
188
179
|
|
|
189
180
|
this.windowCoveringService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
@@ -211,9 +202,10 @@ export class Others {
|
|
|
211
202
|
this.removeWindowCoveringService(accessory);
|
|
212
203
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
213
204
|
|
|
214
|
-
// Add
|
|
215
|
-
|
|
216
|
-
|
|
205
|
+
// Add lockService
|
|
206
|
+
const lockService = `${accessory.displayName} Lock`;
|
|
207
|
+
(this.lockService = accessory.getService(this.platform.Service.LockMechanism)
|
|
208
|
+
|| accessory.addService(this.platform.Service.LockMechanism)), lockService;
|
|
217
209
|
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Lock`);
|
|
218
210
|
|
|
219
211
|
this.lockService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
@@ -232,9 +224,10 @@ export class Others {
|
|
|
232
224
|
this.removeWindowCoveringService(accessory);
|
|
233
225
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
234
226
|
|
|
235
|
-
// Add
|
|
236
|
-
|
|
237
|
-
|
|
227
|
+
// Add faucetService
|
|
228
|
+
const faucetService = `${accessory.displayName} Faucet`;
|
|
229
|
+
(this.faucetService = accessory.getService(this.platform.Service.Faucet)
|
|
230
|
+
|| accessory.addService(this.platform.Service.Faucet)), faucetService;
|
|
238
231
|
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Faucet`);
|
|
239
232
|
|
|
240
233
|
this.faucetService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
@@ -253,9 +246,10 @@ export class Others {
|
|
|
253
246
|
this.removeWindowCoveringService(accessory);
|
|
254
247
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
255
248
|
|
|
256
|
-
// Add
|
|
257
|
-
|
|
258
|
-
|
|
249
|
+
// Add fanService
|
|
250
|
+
const fanService = `${accessory.displayName} Fan`;
|
|
251
|
+
(this.fanService = accessory.getService(this.platform.Service.Fan)
|
|
252
|
+
|| accessory.addService(this.platform.Service.Fan)), fanService;
|
|
259
253
|
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Fan`);
|
|
260
254
|
|
|
261
255
|
this.fanService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
@@ -274,11 +268,10 @@ export class Others {
|
|
|
274
268
|
this.removeGarageDoorService(accessory);
|
|
275
269
|
this.removeWindowCoveringService(accessory);
|
|
276
270
|
|
|
277
|
-
// Add
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
`${accessory.displayName} Stateful Programmable Switch`;
|
|
271
|
+
// Add statefulProgrammableSwitchService
|
|
272
|
+
const statefulProgrammableSwitchService = `${accessory.displayName} Stateful Programmable Switch`;
|
|
273
|
+
(this.statefulProgrammableSwitchService = accessory.getService(this.platform.Service.StatefulProgrammableSwitch)
|
|
274
|
+
|| accessory.addService(this.platform.Service.StatefulProgrammableSwitch)), statefulProgrammableSwitchService;
|
|
282
275
|
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Stateful Programmable Switch`);
|
|
283
276
|
|
|
284
277
|
this.statefulProgrammableSwitchService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
@@ -300,8 +293,9 @@ export class Others {
|
|
|
300
293
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
301
294
|
|
|
302
295
|
// Add outletService
|
|
303
|
-
|
|
304
|
-
|
|
296
|
+
const outletService = `${accessory.displayName} Outlet`;
|
|
297
|
+
(this.outletService = accessory.getService(this.platform.Service.Outlet)
|
|
298
|
+
|| accessory.addService(this.platform.Service.Outlet)), outletService;
|
|
305
299
|
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Outlet`);
|
|
306
300
|
|
|
307
301
|
this.outletService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
@@ -646,16 +640,6 @@ export class Others {
|
|
|
646
640
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
|
|
647
641
|
}
|
|
648
642
|
}
|
|
649
|
-
// FirmwareRevision
|
|
650
|
-
if (this.FirmwareRevision === undefined) {
|
|
651
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} FirmwareRevision: ${this.FirmwareRevision}`);
|
|
652
|
-
} else {
|
|
653
|
-
this.accessory.context.FirmwareRevision = this.FirmwareRevision;
|
|
654
|
-
this.accessory.getService(this.platform.Service.AccessoryInformation)!
|
|
655
|
-
.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
|
|
656
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} `
|
|
657
|
-
+ `updateCharacteristic FirmwareRevision: ${this.FirmwareRevision}`);
|
|
658
|
-
}
|
|
659
643
|
}
|
|
660
644
|
|
|
661
645
|
async disablePushOnChanges(device: irdevice & irDevicesConfig): Promise<void> {
|
|
@@ -885,34 +869,16 @@ export class Others {
|
|
|
885
869
|
}
|
|
886
870
|
}
|
|
887
871
|
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
async setFirmwareRevision(accessory: PlatformAccessory, device: irdevice & irDevicesConfig) {
|
|
891
|
-
if (device.firmware) {
|
|
892
|
-
this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
|
|
893
|
-
accessory.context.FirmwareRevision = device.firmware;
|
|
894
|
-
this.FirmwareRevision = accessory.context.FirmwareRevision;
|
|
895
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} device.firmware, FirmwareRevision: ${this.FirmwareRevision}`);
|
|
896
|
-
} else {
|
|
897
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
|
|
898
|
-
accessory.context.FirmwareRevision = this.platform.version;
|
|
899
|
-
this.FirmwareRevision = accessory.context.FirmwareRevision;
|
|
900
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} this.platform.version, FirmwareRevision: ${this.FirmwareRevision}`);
|
|
901
|
-
}
|
|
902
|
-
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} setFirmwareRevision: ${this.FirmwareRevision}`);
|
|
903
|
-
accessory
|
|
904
|
-
.getService(this.platform.Service.AccessoryInformation)!
|
|
905
|
-
.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
|
|
906
|
-
.getCharacteristic(this.platform.Characteristic.FirmwareRevision)
|
|
907
|
-
.updateValue(this.FirmwareRevision);
|
|
908
|
-
}
|
|
909
|
-
|
|
910
872
|
async context() {
|
|
911
873
|
if (this.On === undefined) {
|
|
912
874
|
this.On = true;
|
|
913
875
|
} else {
|
|
914
876
|
this.On = this.accessory.context.On;
|
|
915
877
|
}
|
|
878
|
+
if (this.FirmwareRevision === undefined) {
|
|
879
|
+
this.FirmwareRevision = this.platform.version;
|
|
880
|
+
this.accessory.context.FirmwareRevision = this.FirmwareRevision;
|
|
881
|
+
}
|
|
916
882
|
}
|
|
917
883
|
|
|
918
884
|
async config(device: irdevice & irDevicesConfig): Promise<void> {
|
package/src/irdevice/tv.ts
CHANGED
|
@@ -43,50 +43,39 @@ export class TV {
|
|
|
43
43
|
.setCharacteristic(this.platform.Characteristic.Name, `${device.deviceName} ${device.remoteType}`)
|
|
44
44
|
.setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
|
|
45
45
|
.setCharacteristic(this.platform.Characteristic.Model, device.remoteType)
|
|
46
|
-
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId
|
|
47
|
-
|
|
48
|
-
if (accessory.context.FirmwareRevision) {
|
|
49
|
-
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
50
|
-
+ ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
|
|
51
|
-
accessory
|
|
52
|
-
.getService(this.platform.Service.AccessoryInformation)!
|
|
53
|
-
.setCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
|
|
54
|
-
.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
|
|
55
|
-
.getCharacteristic(this.platform.Characteristic.FirmwareRevision)
|
|
56
|
-
.updateValue(accessory.context.FirmwareRevision);
|
|
57
|
-
} else {
|
|
58
|
-
this.setFirmwareRevision(accessory, device);
|
|
59
|
-
}
|
|
46
|
+
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId)
|
|
47
|
+
.setCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision);
|
|
60
48
|
|
|
61
49
|
// set the accessory category
|
|
50
|
+
const tvServiceCategory = `${accessory.displayName} ${device.remoteType}`;
|
|
62
51
|
switch (device.remoteType) {
|
|
63
52
|
case 'Speaker':
|
|
64
53
|
case 'DIY Speaker':
|
|
65
54
|
accessory.category = this.platform.api.hap.Categories.SPEAKER;
|
|
66
|
-
(this.tvService = accessory.getService(this.platform.Service.Television)
|
|
67
|
-
|
|
55
|
+
(this.tvService = accessory.getService(this.platform.Service.Television)
|
|
56
|
+
|| accessory.addService(this.platform.Service.Television)), tvServiceCategory;
|
|
68
57
|
break;
|
|
69
58
|
case 'IPTV':
|
|
70
59
|
case 'DIY IPTV':
|
|
71
60
|
accessory.category = this.platform.api.hap.Categories.TV_STREAMING_STICK;
|
|
72
|
-
(this.tvService = accessory.getService(this.platform.Service.Television)
|
|
73
|
-
|
|
61
|
+
(this.tvService = accessory.getService(this.platform.Service.Television)
|
|
62
|
+
|| accessory.addService(this.platform.Service.Television)), tvServiceCategory;
|
|
74
63
|
break;
|
|
75
64
|
case 'DVD':
|
|
76
65
|
case 'DIY DVD':
|
|
77
66
|
case 'Set Top Box':
|
|
78
67
|
case 'DIY Set Top Box':
|
|
79
68
|
accessory.category = this.platform.api.hap.Categories.TV_SET_TOP_BOX;
|
|
80
|
-
(this.tvService = accessory.getService(this.platform.Service.Television)
|
|
81
|
-
|
|
69
|
+
(this.tvService = accessory.getService(this.platform.Service.Television)
|
|
70
|
+
|| accessory.addService(this.platform.Service.Television)), tvServiceCategory;
|
|
82
71
|
break;
|
|
83
72
|
default:
|
|
84
73
|
accessory.category = this.platform.api.hap.Categories.TELEVISION;
|
|
85
74
|
|
|
86
75
|
// get the Television service if it exists, otherwise create a new Television service
|
|
87
76
|
// you can create multiple services for each accessory
|
|
88
|
-
(this.tvService = accessory.getService(this.platform.Service.Television)
|
|
89
|
-
|
|
77
|
+
(this.tvService = accessory.getService(this.platform.Service.Television)
|
|
78
|
+
|| accessory.addService(this.platform.Service.Television)), tvServiceCategory;
|
|
90
79
|
}
|
|
91
80
|
|
|
92
81
|
this.tvService.getCharacteristic(this.platform.Characteristic.ConfiguredName);
|
|
@@ -112,9 +101,9 @@ export class TV {
|
|
|
112
101
|
* Create a speaker service to allow volume control
|
|
113
102
|
*/
|
|
114
103
|
// create a new Television Speaker service
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
104
|
+
const speakerService = `${accessory.displayName} Speaker`;
|
|
105
|
+
(this.speakerService = accessory.getService(this.platform.Service.TelevisionSpeaker)
|
|
106
|
+
|| accessory.addService(this.platform.Service.TelevisionSpeaker)), speakerService;
|
|
118
107
|
|
|
119
108
|
this.speakerService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Speaker`);
|
|
120
109
|
if (!this.speakerService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
@@ -424,16 +413,6 @@ export class TV {
|
|
|
424
413
|
this.tvService?.updateCharacteristic(this.platform.Characteristic.ActiveIdentifier, this.ActiveIdentifier);
|
|
425
414
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}` + ` updateCharacteristic ActiveIdentifier: ${this.ActiveIdentifier}`);
|
|
426
415
|
}
|
|
427
|
-
// FirmwareRevision
|
|
428
|
-
if (this.FirmwareRevision === undefined) {
|
|
429
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} FirmwareRevision: ${this.FirmwareRevision}`);
|
|
430
|
-
} else {
|
|
431
|
-
this.accessory.context.FirmwareRevision = this.FirmwareRevision;
|
|
432
|
-
this.accessory.getService(this.platform.Service.AccessoryInformation)!
|
|
433
|
-
.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
|
|
434
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} `
|
|
435
|
-
+ `updateCharacteristic FirmwareRevision: ${this.FirmwareRevision}`);
|
|
436
|
-
}
|
|
437
416
|
}
|
|
438
417
|
|
|
439
418
|
async disablePushOnChanges(device: irdevice & irDevicesConfig): Promise<void> {
|
|
@@ -535,28 +514,6 @@ export class TV {
|
|
|
535
514
|
this.tvService.updateCharacteristic(this.platform.Characteristic.ActiveIdentifier, e);
|
|
536
515
|
}
|
|
537
516
|
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
async setFirmwareRevision(accessory: PlatformAccessory, device: irdevice & irDevicesConfig) {
|
|
541
|
-
if (device.firmware) {
|
|
542
|
-
this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
|
|
543
|
-
accessory.context.FirmwareRevision = device.firmware;
|
|
544
|
-
this.FirmwareRevision = accessory.context.FirmwareRevision;
|
|
545
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} device.firmware, FirmwareRevision: ${this.FirmwareRevision}`);
|
|
546
|
-
} else {
|
|
547
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
|
|
548
|
-
accessory.context.FirmwareRevision = this.platform.version;
|
|
549
|
-
this.FirmwareRevision = accessory.context.FirmwareRevision;
|
|
550
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} this.platform.version, FirmwareRevision: ${this.FirmwareRevision}`);
|
|
551
|
-
}
|
|
552
|
-
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} setFirmwareRevision: ${this.FirmwareRevision}`);
|
|
553
|
-
accessory
|
|
554
|
-
.getService(this.platform.Service.AccessoryInformation)!
|
|
555
|
-
.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
|
|
556
|
-
.getCharacteristic(this.platform.Characteristic.FirmwareRevision)
|
|
557
|
-
.updateValue(this.FirmwareRevision);
|
|
558
|
-
}
|
|
559
|
-
|
|
560
517
|
async context() {
|
|
561
518
|
if (this.Active === undefined) {
|
|
562
519
|
this.Active = this.platform.Characteristic.Active.INACTIVE;
|
|
@@ -568,6 +525,10 @@ export class TV {
|
|
|
568
525
|
} else {
|
|
569
526
|
this.ActiveIdentifier = this.accessory.context.ActiveIdentifier;
|
|
570
527
|
}
|
|
528
|
+
if (this.FirmwareRevision === undefined) {
|
|
529
|
+
this.FirmwareRevision = this.platform.version;
|
|
530
|
+
this.accessory.context.FirmwareRevision = this.FirmwareRevision;
|
|
531
|
+
}
|
|
571
532
|
}
|
|
572
533
|
|
|
573
534
|
async config(device: irdevice & irDevicesConfig): Promise<void> {
|
|
@@ -38,25 +38,14 @@ export class VacuumCleaner {
|
|
|
38
38
|
.getService(this.platform.Service.AccessoryInformation)!
|
|
39
39
|
.setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
|
|
40
40
|
.setCharacteristic(this.platform.Characteristic.Model, device.remoteType)
|
|
41
|
-
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId
|
|
42
|
-
|
|
43
|
-
if (accessory.context.FirmwareRevision) {
|
|
44
|
-
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
45
|
-
+ ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
|
|
46
|
-
accessory
|
|
47
|
-
.getService(this.platform.Service.AccessoryInformation)!
|
|
48
|
-
.setCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
|
|
49
|
-
.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
|
|
50
|
-
.getCharacteristic(this.platform.Characteristic.FirmwareRevision)
|
|
51
|
-
.updateValue(accessory.context.FirmwareRevision);
|
|
52
|
-
} else {
|
|
53
|
-
this.setFirmwareRevision(accessory, device);
|
|
54
|
-
}
|
|
41
|
+
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId)
|
|
42
|
+
.setCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision);
|
|
55
43
|
|
|
56
44
|
// get the Television service if it exists, otherwise create a new Television service
|
|
57
45
|
// you can create multiple services for each accessory
|
|
58
|
-
|
|
59
|
-
|
|
46
|
+
const switchService = `${accessory.displayName} ${device.remoteType}`;
|
|
47
|
+
(this.switchService = accessory.getService(this.platform.Service.Switch)
|
|
48
|
+
|| accessory.addService(this.platform.Service.Switch)), switchService;
|
|
60
49
|
|
|
61
50
|
this.switchService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
62
51
|
if (!this.switchService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
@@ -163,16 +152,6 @@ export class VacuumCleaner {
|
|
|
163
152
|
this.switchService?.updateCharacteristic(this.platform.Characteristic.On, this.On);
|
|
164
153
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
|
|
165
154
|
}
|
|
166
|
-
// FirmwareRevision
|
|
167
|
-
if (this.FirmwareRevision === undefined) {
|
|
168
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} FirmwareRevision: ${this.FirmwareRevision}`);
|
|
169
|
-
} else {
|
|
170
|
-
this.accessory.context.FirmwareRevision = this.FirmwareRevision;
|
|
171
|
-
this.accessory.getService(this.platform.Service.AccessoryInformation)!
|
|
172
|
-
.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
|
|
173
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} `
|
|
174
|
-
+ `updateCharacteristic FirmwareRevision: ${this.FirmwareRevision}`);
|
|
175
|
-
}
|
|
176
155
|
}
|
|
177
156
|
|
|
178
157
|
async disablePushOnChanges(device: irdevice & irDevicesConfig): Promise<void> {
|
|
@@ -265,34 +244,16 @@ export class VacuumCleaner {
|
|
|
265
244
|
this.switchService.updateCharacteristic(this.platform.Characteristic.On, e);
|
|
266
245
|
}
|
|
267
246
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
async setFirmwareRevision(accessory: PlatformAccessory, device: irdevice & irDevicesConfig) {
|
|
271
|
-
if (device.firmware) {
|
|
272
|
-
this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
|
|
273
|
-
accessory.context.FirmwareRevision = device.firmware;
|
|
274
|
-
this.FirmwareRevision = accessory.context.FirmwareRevision;
|
|
275
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} device.firmware, FirmwareRevision: ${this.FirmwareRevision}`);
|
|
276
|
-
} else {
|
|
277
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
|
|
278
|
-
accessory.context.FirmwareRevision = this.platform.version;
|
|
279
|
-
this.FirmwareRevision = accessory.context.FirmwareRevision;
|
|
280
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} this.platform.version, FirmwareRevision: ${this.FirmwareRevision}`);
|
|
281
|
-
}
|
|
282
|
-
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} setFirmwareRevision: ${this.FirmwareRevision}`);
|
|
283
|
-
accessory
|
|
284
|
-
.getService(this.platform.Service.AccessoryInformation)!
|
|
285
|
-
.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
|
|
286
|
-
.getCharacteristic(this.platform.Characteristic.FirmwareRevision)
|
|
287
|
-
.updateValue(this.FirmwareRevision);
|
|
288
|
-
}
|
|
289
|
-
|
|
290
247
|
async context() {
|
|
291
248
|
if (this.On === undefined) {
|
|
292
249
|
this.On = false;
|
|
293
250
|
} else {
|
|
294
251
|
this.On = this.accessory.context.On;
|
|
295
252
|
}
|
|
253
|
+
if (this.FirmwareRevision === undefined) {
|
|
254
|
+
this.FirmwareRevision = this.platform.version;
|
|
255
|
+
this.accessory.context.FirmwareRevision = this.FirmwareRevision;
|
|
256
|
+
}
|
|
296
257
|
}
|
|
297
258
|
|
|
298
259
|
async config(device: irdevice & irDevicesConfig): Promise<void> {
|
|
@@ -38,25 +38,14 @@ export class WaterHeater {
|
|
|
38
38
|
.getService(this.platform.Service.AccessoryInformation)!
|
|
39
39
|
.setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
|
|
40
40
|
.setCharacteristic(this.platform.Characteristic.Model, device.remoteType)
|
|
41
|
-
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId
|
|
42
|
-
|
|
43
|
-
if (accessory.context.FirmwareRevision) {
|
|
44
|
-
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
45
|
-
+ ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
|
|
46
|
-
accessory
|
|
47
|
-
.getService(this.platform.Service.AccessoryInformation)!
|
|
48
|
-
.setCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
|
|
49
|
-
.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
|
|
50
|
-
.getCharacteristic(this.platform.Characteristic.FirmwareRevision)
|
|
51
|
-
.updateValue(accessory.context.FirmwareRevision);
|
|
52
|
-
} else {
|
|
53
|
-
this.setFirmwareRevision(accessory, device);
|
|
54
|
-
}
|
|
41
|
+
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId)
|
|
42
|
+
.setCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision);
|
|
55
43
|
|
|
56
44
|
// get the Television service if it exists, otherwise create a new Television service
|
|
57
45
|
// you can create multiple services for each accessory
|
|
58
|
-
|
|
59
|
-
|
|
46
|
+
const valveService = `${accessory.displayName} ${device.remoteType}`;
|
|
47
|
+
(this.valveService = accessory.getService(this.platform.Service.Valve)
|
|
48
|
+
|| accessory.addService(this.platform.Service.Valve)), valveService;
|
|
60
49
|
|
|
61
50
|
this.valveService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
62
51
|
if (!this.valveService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
@@ -172,16 +161,6 @@ export class WaterHeater {
|
|
|
172
161
|
this.valveService?.updateCharacteristic(this.platform.Characteristic.Active, this.Active);
|
|
173
162
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`);
|
|
174
163
|
}
|
|
175
|
-
// FirmwareRevision
|
|
176
|
-
if (this.FirmwareRevision === undefined) {
|
|
177
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} FirmwareRevision: ${this.FirmwareRevision}`);
|
|
178
|
-
} else {
|
|
179
|
-
this.accessory.context.FirmwareRevision = this.FirmwareRevision;
|
|
180
|
-
this.accessory.getService(this.platform.Service.AccessoryInformation)!
|
|
181
|
-
.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
|
|
182
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} `
|
|
183
|
-
+ `updateCharacteristic FirmwareRevision: ${this.FirmwareRevision}`);
|
|
184
|
-
}
|
|
185
164
|
}
|
|
186
165
|
|
|
187
166
|
async disablePushOnChanges(device: irdevice & irDevicesConfig): Promise<void> {
|
|
@@ -274,34 +253,16 @@ export class WaterHeater {
|
|
|
274
253
|
this.valveService.updateCharacteristic(this.platform.Characteristic.Active, e);
|
|
275
254
|
}
|
|
276
255
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
async setFirmwareRevision(accessory: PlatformAccessory, device: irdevice & irDevicesConfig) {
|
|
280
|
-
if (device.firmware) {
|
|
281
|
-
this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
|
|
282
|
-
accessory.context.FirmwareRevision = device.firmware;
|
|
283
|
-
this.FirmwareRevision = accessory.context.FirmwareRevision;
|
|
284
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} device.firmware, FirmwareRevision: ${this.FirmwareRevision}`);
|
|
285
|
-
} else {
|
|
286
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
|
|
287
|
-
accessory.context.FirmwareRevision = this.platform.version;
|
|
288
|
-
this.FirmwareRevision = accessory.context.FirmwareRevision;
|
|
289
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} this.platform.version, FirmwareRevision: ${this.FirmwareRevision}`);
|
|
290
|
-
}
|
|
291
|
-
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} setFirmwareRevision: ${this.FirmwareRevision}`);
|
|
292
|
-
accessory
|
|
293
|
-
.getService(this.platform.Service.AccessoryInformation)!
|
|
294
|
-
.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
|
|
295
|
-
.getCharacteristic(this.platform.Characteristic.FirmwareRevision)
|
|
296
|
-
.updateValue(this.FirmwareRevision);
|
|
297
|
-
}
|
|
298
|
-
|
|
299
256
|
async context(): Promise<void> {
|
|
300
257
|
if (this.Active === undefined) {
|
|
301
258
|
this.Active = this.platform.Characteristic.Active.INACTIVE;
|
|
302
259
|
} else {
|
|
303
260
|
this.Active = this.accessory.context.Active;
|
|
304
261
|
}
|
|
262
|
+
if (this.FirmwareRevision === undefined) {
|
|
263
|
+
this.FirmwareRevision = this.platform.version;
|
|
264
|
+
this.accessory.context.FirmwareRevision = this.FirmwareRevision;
|
|
265
|
+
}
|
|
305
266
|
}
|
|
306
267
|
|
|
307
268
|
async config(device: irdevice & irDevicesConfig): Promise<void> {
|
package/tsconfig.json
CHANGED
|
@@ -2,7 +2,15 @@
|
|
|
2
2
|
"compilerOptions": {
|
|
3
3
|
"target": "ES2021",
|
|
4
4
|
"module": "commonjs",
|
|
5
|
-
"lib": [
|
|
5
|
+
"lib": [
|
|
6
|
+
"ES2015",
|
|
7
|
+
"ES2016",
|
|
8
|
+
"ES2017",
|
|
9
|
+
"ES2018",
|
|
10
|
+
"ES2019",
|
|
11
|
+
"ES2020",
|
|
12
|
+
"ES2021"
|
|
13
|
+
],
|
|
6
14
|
"declaration": true,
|
|
7
15
|
"declarationMap": true,
|
|
8
16
|
"sourceMap": true,
|
|
@@ -12,6 +20,10 @@
|
|
|
12
20
|
"esModuleInterop": true,
|
|
13
21
|
"noImplicitAny": false
|
|
14
22
|
},
|
|
15
|
-
"include": [
|
|
16
|
-
|
|
17
|
-
|
|
23
|
+
"include": [
|
|
24
|
+
"src/"
|
|
25
|
+
],
|
|
26
|
+
"exclude": [
|
|
27
|
+
"**/*.spec.ts"
|
|
28
|
+
]
|
|
29
|
+
}
|
|
@@ -1,81 +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
|
-
const fs = require("fs");
|
|
8
|
-
const semver = require("semver");
|
|
9
|
-
const child_process = require("child_process");
|
|
10
|
-
const assert = require("assert");
|
|
11
|
-
|
|
12
|
-
const BRANCH_VERSION_PATTERN = /^([A-Za-z]*)-(\d+.\d+.\d+)$/
|
|
13
|
-
|
|
14
|
-
// Load the contents of the package.json file
|
|
15
|
-
const packageJSON = JSON.parse(fs.readFileSync("package.json", "utf8"));
|
|
16
|
-
|
|
17
|
-
let refArgument = process.argv[2];
|
|
18
|
-
let tagArgument = process.argv[3] || "latest";
|
|
19
|
-
|
|
20
|
-
if (refArgument == null) {
|
|
21
|
-
console.error("ref argument is missing");
|
|
22
|
-
console.error("Usage: npm-version-script.js <ref> [tag]");
|
|
23
|
-
process.exit(1);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Queries the NPM registry for the latest version for the provided tag.
|
|
28
|
-
* @param tag The tag to query for.
|
|
29
|
-
* @returns {string} Returns the version.
|
|
30
|
-
*/
|
|
31
|
-
function getTagVersionFromNpm(tag) {
|
|
32
|
-
try {
|
|
33
|
-
return child_process.execSync(`npm info ${packageJSON.name} version --tag="${tag}"`).toString("utf8").trim();
|
|
34
|
-
} catch (e) {
|
|
35
|
-
throw e;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function desiredTargetVersion(ref) {
|
|
40
|
-
// ref is a GitHub action ref string
|
|
41
|
-
if (ref.startsWith("refs/pull/")) {
|
|
42
|
-
throw Error("The version script was executed inside a PR!");
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
assert(ref.startsWith("refs/heads/"))
|
|
46
|
-
let branchName = ref.slice("refs/heads/".length);
|
|
47
|
-
|
|
48
|
-
let results = branchName.match(BRANCH_VERSION_PATTERN);
|
|
49
|
-
if (results != null) {
|
|
50
|
-
if (results[1] !== tagArgument) {
|
|
51
|
-
console.warn(`The base branch name (${results[1]}) differs from the tag name ${tagArgument}`);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return results[2];
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// legacy mode were we use the `betaVersion` property in the package.json
|
|
58
|
-
if (branchName === "beta" && packageJSON.betaVersion) {
|
|
59
|
-
return packageJSON.betaVersion
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
throw new Error("Malformed branch name for ref: " + ref + ". Can't derive the base version. Use a branch name like: beta-x.x.x!");
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// derive the base version from the branch ref
|
|
66
|
-
const baseVersion = desiredTargetVersion(refArgument);
|
|
67
|
-
|
|
68
|
-
// query the npm registry for the latest version of the provided tag name
|
|
69
|
-
const latestReleasedVersion = getTagVersionFromNpm(tagArgument); // e.g. 0.7.0-beta.12
|
|
70
|
-
const latestReleaseBase = semver.inc(latestReleasedVersion, "patch"); // will produce 0.7.0 (removing the preid, needed for the equality check below)
|
|
71
|
-
|
|
72
|
-
let publishTag;
|
|
73
|
-
if (semver.eq(baseVersion, latestReleaseBase)) { // check if we are releasing another version for the latest beta
|
|
74
|
-
publishTag = latestReleasedVersion; // set the current latest beta to be incremented
|
|
75
|
-
} else {
|
|
76
|
-
publishTag = baseVersion; // start of with a new beta version
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// save the package.json
|
|
80
|
-
packageJSON.version = publishTag;
|
|
81
|
-
fs.writeFileSync("package.json", JSON.stringify(packageJSON, null, 2));
|