Skip to content

Commit

Permalink
Release 1.1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Luligu committed Mar 10, 2024
1 parent 70e7c38 commit 1525a83
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 10 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

All notable changes to this project will be documented in this file.

## [1.1.4] - 2024-03-10

### Changed

- [cli]: Updated the loading from cli.


## [1.1.3] - 2024-03-10

### Added
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ To install i.e. https://github.com/Luligu/matterbridge-example-accessory-platfor
git clone https://github.com/Luligu/matterbridge-example-accessory-platform
cd matterbridge-example-accessory-platform
npm install
npm link matterbridge
npm run build
```
Then add the plugin to Matterbridge
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "matterbridge",
"version": "1.1.3",
"version": "1.1.4",
"description": "Matterbridge",
"author": "https://github.com/Luligu",
"license": "Apache-2.0",
Expand All @@ -21,7 +21,7 @@
"matter.js"
],
"bin": {
"matterbridge": "./dist/index.js"
"matterbridge": "./dist/cli.js"
},
"engines": {
"node": "^18.19.0 || ^20.11.0"
Expand Down
16 changes: 16 additions & 0 deletions src/cli.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env node

import { Matterbridge } from './matterbridge.js';

async function main() {
// eslint-disable-next-line no-console
console.log('Loading Matterbridge from cli');
await Matterbridge.loadInstance(true);
}

process.title = 'matterbridge';

main().catch((error) => {
// eslint-disable-next-line no-console
console.error(`Failed to initialize Matterbridge from cli: ${error}`);
});
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env node
/**
* This file contains the entry point of Matterbridge.
*
Expand Down Expand Up @@ -41,6 +40,8 @@ export * from './ColorControlServer.js';
export * from './TvocCluster.js';

async function main() {
// eslint-disable-next-line no-console
console.log('Loading Matterbridge instance');
await Matterbridge.loadInstance();
}

Expand Down
13 changes: 7 additions & 6 deletions src/matterBridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,17 +158,18 @@ export class Matterbridge {
* Loads an instance of the Matterbridge class.
* If an instance already exists, an error will be thrown.
* @returns The loaded instance of the Matterbridge class.
* @throws Error if an instance of Matterbridge already exists.
*/
static async loadInstance() {
static async loadInstance(cli = false) {
// eslint-disable-next-line no-console
console.error('loadInstance cli:', cli);
if (!Matterbridge.instance) {
// eslint-disable-next-line no-console
console.error('Matterbridge instance does not exists');
Matterbridge.instance = new Matterbridge();
await Matterbridge.instance.initialize();
if (cli) await Matterbridge.instance.initialize();
} else {
// eslint-disable-next-line no-console
console.error('Matterbridge instance already exists');
console.error('Matterbridge instance already exists');
console.error('Matterbridge instance already exists');
//throw new Error('Matterbridge instance already exists');
}
return Matterbridge.instance;
}
Expand Down

0 comments on commit 1525a83

Please sign in to comment.