Skip to content

Commit

Permalink
4.39.0
Browse files Browse the repository at this point in the history
  • Loading branch information
oznu committed Feb 15, 2021
1 parent 487f89c commit e671507
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 24 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,4 @@
"smart home",
"hb-service"
]
}
}
4 changes: 2 additions & 2 deletions src/modules/config-editor/config-editor.module.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { forwardRef, Module } from '@nestjs/common';
import { Module } from '@nestjs/common';
import { PassportModule } from '@nestjs/passport';
import { ConfigEditorService } from './config-editor.service';
import { ConfigEditorController } from './config-editor.controller';
Expand All @@ -13,7 +13,7 @@ import { PluginsModule } from '../plugins/plugins.module';
LoggerModule,
ConfigModule,
SchedulerModule,
forwardRef(() => PluginsModule),
PluginsModule,
],
providers: [
ConfigEditorService,
Expand Down
3 changes: 1 addition & 2 deletions src/modules/config-editor/config-editor.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as fs from 'fs-extra';
import * as path from 'path';
import * as dayjs from 'dayjs';
import { BadRequestException, forwardRef, Inject, Injectable, NotFoundException } from '@nestjs/common';
import { BadRequestException, Injectable, NotFoundException } from '@nestjs/common';
import { Logger } from '../../core/logger/logger.service';
import { ConfigService, HomebridgeConfig } from '../../core/config/config.service';
import { SchedulerService } from '../../core/scheduler/scheduler.service';
Expand All @@ -13,7 +13,6 @@ export class ConfigEditorService {
private readonly logger: Logger,
private readonly configService: ConfigService,
private readonly schedulerService: SchedulerService,
@Inject(forwardRef(() => PluginsService))
private readonly pluginsService: PluginsService,
) {
this.start();
Expand Down
4 changes: 1 addition & 3 deletions src/modules/plugins/plugins.module.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as https from 'https';
import { Module, HttpModule, forwardRef } from '@nestjs/common';
import { Module, HttpModule } from '@nestjs/common';
import { PassportModule } from '@nestjs/passport';

import { PluginsService } from './plugins.service';
Expand All @@ -8,7 +8,6 @@ import { PluginsController } from './plugins.controller';
import { PluginsGateway } from './plugins.gateway';
import { ConfigModule } from '../../core/config/config.module';
import { NodePtyModule } from '../../core/node-pty/node-pty.module';
import { ConfigEditorModule } from '../config-editor/config-editor.module';

@Module({
imports: [
Expand All @@ -23,7 +22,6 @@ import { ConfigEditorModule } from '../config-editor/config-editor.module';
NodePtyModule,
ConfigModule,
LoggerModule,
forwardRef(() => ConfigEditorModule),
],
providers: [
PluginsService,
Expand Down
16 changes: 8 additions & 8 deletions src/modules/plugins/plugins.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EventEmitter } from 'events';
import { Injectable, NotFoundException, InternalServerErrorException, HttpService, BadRequestException, Inject, forwardRef } from '@nestjs/common';
import { Injectable, NotFoundException, InternalServerErrorException, HttpService, BadRequestException } from '@nestjs/common';
import { HomebridgePlugin, IPackageJson, INpmSearchResults, INpmRegistryModule } from './types';
import { HomebridgePluginVersions, HomebridgePluginUiMetadata, PluginAlias } from './types';
import axios from 'axios';
Expand All @@ -16,7 +16,6 @@ import * as pLimit from 'p-limit';
import { Logger } from '../../core/logger/logger.service';
import { ConfigService, HomebridgeConfig } from '../../core/config/config.service';
import { NodePtyService } from '../../core/node-pty/node-pty.service';
import { ConfigEditorService } from '../config-editor/config-editor.service';

@Injectable()
export class PluginsService {
Expand Down Expand Up @@ -63,8 +62,6 @@ export class PluginsService {
private nodePtyService: NodePtyService,
private logger: Logger,
private configService: ConfigService,
@Inject(forwardRef(() => ConfigEditorService))
private configEditorService: ConfigEditorService,
) {

/**
Expand Down Expand Up @@ -550,10 +547,13 @@ export class PluginsService {
const installedVersion = semver.parse(homebridge.installedVersion);
const targetVersion = semver.parse(version);
if (installedVersion.minor === 2 && targetVersion.minor > 2) {
const config = await this.configEditorService.getConfigFile();
config.bridge.advertiser = 'ciao';
delete config.mdns;
await this.configEditorService.updateConfigFile(config);
try {
const config: HomebridgeConfig = await fs.readJson(this.configService.configPath);
config.bridge.advertiser = 'ciao';
await fs.writeJsonSync(this.configService.configPath, config);
} catch (e) {
this.logger.warn('Could not update config.json', e.message);
}
}
}
// end 1.2.x -> 1.3.0 upgrade
Expand Down
11 changes: 4 additions & 7 deletions test/e2e/plugins.gateway.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { PluginsModule } from '../../src/modules/plugins/plugins.module';
import { PluginsService } from '../../src/modules/plugins/plugins.service';
import { PluginsGateway } from '../../src/modules/plugins/plugins.gateway';
import { NodePtyService } from '../../src/core/node-pty/node-pty.service';
import { ConfigEditorService } from '../../src/modules/config-editor/config-editor.service';

describe('PluginsGateway (e2e)', () => {
let app: NestFastifyApplication;
Expand All @@ -22,7 +21,6 @@ describe('PluginsGateway (e2e)', () => {
let configService: ConfigService;
let pluginsService: PluginsService;
let pluginsGateway: PluginsGateway;
let configEditorService: ConfigEditorService;
let client: EventEmitter;

let win32NpmPath: string;
Expand Down Expand Up @@ -63,7 +61,6 @@ describe('PluginsGateway (e2e)', () => {
configService = app.get(ConfigService);
pluginsService = app.get(PluginsService);
pluginsGateway = app.get(PluginsGateway);
configEditorService = app.get(ConfigEditorService);

win32NpmPath = (pluginsService as any).getNpmPath()[0];
});
Expand Down Expand Up @@ -378,14 +375,14 @@ describe('PluginsGateway (e2e)', () => {
return term;
});

const getConfigFileMock = jest.spyOn(configEditorService, 'getConfigFile');
const writeJsonMock = jest.spyOn(fs, 'writeJsonSync');

try {
await pluginsGateway.homebridgeUpdate(client, { version: 'latest' });
} catch (e) { }

// the save config method should have been called
expect(getConfigFileMock).toHaveBeenCalled();
expect(writeJsonMock).toHaveBeenCalled();
});

it('ON /plugins/homebridge-update (1.1.x -> 1.3.x)', async () => {
Expand All @@ -410,14 +407,14 @@ describe('PluginsGateway (e2e)', () => {
return term;
});

const getConfigFileMock = jest.spyOn(configEditorService, 'getConfigFile');
const writeJsonMock = jest.spyOn(fs, 'writeJsonSync');

try {
await pluginsGateway.homebridgeUpdate(client, { version: 'latest' });
} catch (e) { }

// the save config method should not have been called
expect(getConfigFileMock).not.toHaveBeenCalled();
expect(writeJsonMock).not.toHaveBeenCalled();
});

afterAll(async () => {
Expand Down

0 comments on commit e671507

Please sign in to comment.