Skip to content

Commit

Permalink
Merge pull request #91 from mfucci/fix-build
Browse files Browse the repository at this point in the history
node-matter@0.0.9 broken: fix command line file references
  • Loading branch information
mfucci authored Oct 28, 2022
2 parents 67a18aa + 20b43eb commit 41dd111
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 9 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
},
"scripts": {
"clean": "rm -rf build",
"build": "tsc",
"build": "npm run clean; tsc",
"test": "TZ=utc mocha"
},
"devDependencies": {
Expand All @@ -43,10 +43,10 @@
"files": [
"build/**/*"
],
"main": "build/Main.js",
"types": "build/Main.d.ts",
"main": "build/Device.js",
"types": "build/Device.d.ts",
"bin": {
"matter": "./build/Main.js",
"matter": "./build/Device.js",
"matter-controller": "./build/Controller.js"
}
}
10 changes: 8 additions & 2 deletions src/Controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,18 @@ import { singleton } from "./util/Singleton";
import { MdnsScanner } from "./matter/mdns/MdnsScanner";
import { Time } from "./time/Time";
import { TimeNode } from "./time/TimeNode";
import { Logger } from "./log/Logger";
import packageJson from "../package.json";

Network.get = singleton(() => new NetworkNode());
Time.get = singleton(() => new TimeNode());

class Main {
const logger = Logger.get("Controller");

class Controller {
async start() {
logger.info(`node-matter@${packageJson.version}`);

const ip = getParameter("ip");
if (ip === undefined) throw new Error("Please specify the IP of the device to commission with -ip");
const port = getIntParameter("port") ?? 5540;
Expand All @@ -35,4 +41,4 @@ class Main {
}
}

new Main().start();
new Controller().start();
12 changes: 10 additions & 2 deletions src/Device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import { OperationalCredentialsClusterHandler } from "./matter/cluster/server/Op
import { MdnsScanner } from "./matter/mdns/MdnsScanner";
import { Time } from "./time/Time";
import { TimeNode } from "./time/TimeNode";
import packageJson from "../package.json";
import { Logger } from "./log/Logger";

// From Chip-Test-DAC-FFF1-8000-0007-Key.der
const DevicePrivateKey = Buffer.from("727F1005CBA47ED7822A9D930943621617CFD3B79D9AF528B801ECF9F1992204", "hex");
Expand All @@ -44,8 +46,12 @@ const CertificateDeclaration = Buffer.from("3082021906092a864886f70d010702a08202
Network.get = singleton(() => new NetworkNode());
Time.get = singleton(() => new TimeNode());

class Main {
const logger = Logger.get("Device");

class Device {
async start() {
logger.info(`node-matter@${packageJson.version}`);

const deviceName = "Matter test device";
const deviceType = 257 /* Dimmable bulb */;
const vendorName = "node-matter";
Expand Down Expand Up @@ -124,7 +130,9 @@ class Main {
.addEndpoint(0x01, DEVICE.ON_OFF_LIGHT, [ onOffClusterServer ])
)
.start()

logger.info("Listening");
}
}

new Main().start();
new Device().start();
12 changes: 12 additions & 0 deletions src/dts/package.json.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* @license
* Copyright 2022 The node-matter Authors
* SPDX-License-Identifier: Apache-2.0
*/

declare module "*package.json" {
const npmPackage: {
version: string
};
export default npmPackage;
}
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
"declaration": true,
"strict": true
},
"include": ["src/**/*.ts"],
"include": ["src/**/*.ts", "dts/*.d.ts"],
}

0 comments on commit 41dd111

Please sign in to comment.