From 6e0015b17bbbc617f30bebd9c97f1820ef3e6ec7 Mon Sep 17 00:00:00 2001 From: Rui Alves Personal Date: Wed, 24 Jul 2024 21:05:24 +0100 Subject: [PATCH] Added .npmignore. Updated README.md (install + usage) --- .npmignore | 8 ++++++++ README.md | 18 ++++++++++++++++++ package.json | 9 ++++++++- test/gen3/main.ts | 5 ++--- tsconfig.json | 10 ++++------ 5 files changed, 40 insertions(+), 10 deletions(-) create mode 100644 .npmignore diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..ea7523e --- /dev/null +++ b/.npmignore @@ -0,0 +1,8 @@ +src +test +.eslintrc.js +.prettierrc +tsup.config.ts +tsconfig.json +node_modules +scripts diff --git a/README.md b/README.md index 2a2b5af..7d3bf45 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,21 @@ # Shelly API Typescript Strongly typed Shelly API client written in Typescript + +## Install + +You can install it in a Typescript/Javascript project by doing the following: + +```bash +npm i @intruder-detection/shelly-api-typescript +``` + +## Usage + +```ts +import { ShellyGen2PlusHTTPAPI, ShellyMethods } from '@intruder-detection/shelly-api-typescript'; + +const gen2Device = new ShellyGen2PlusHTTPAPI('192.168.1.10'); +const status = await gen2Device.post(ShellyMethods.GetStatus); +console.log(status); +``` diff --git a/package.json b/package.json index 37a0d8b..b1591f8 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,14 @@ "main": "dist/index.js", "module": "dist/index.mjs", "types": "dist/index.d.ts", - "keywords": ["Shelly", "Shelly HTTP/RPC API", "Shelly Typescript", "Shelly NodeJS"], + "keywords": [ + "Shelly", + "Shelly API", + "Shelly HTTP/RPC API", + "Shelly Typescript", + "Shelly Javascript", + "Shelly NodeJS" + ], "repository": { "url": "https://github.com/intruder-detection/shelly-api-typescript" }, diff --git a/test/gen3/main.ts b/test/gen3/main.ts index ba30ef4..fb3a7a5 100644 --- a/test/gen3/main.ts +++ b/test/gen3/main.ts @@ -1,5 +1,4 @@ -import { ShellyGen2PlusHTTPAPI } from '@common/shelly-gen-2-plus-http-api'; -import { BTHomeDeviceMethods, BTHomeMethods, VirtualMethods } from '@gen3/methods.enum'; +import { BTHomeDeviceMethods, BTHomeMethods, ShellyGen2PlusHTTPAPI } from '../../src'; async function virtual() { // await gen3Device.post(VirtualMethods.Add, { @@ -119,4 +118,4 @@ async function main() { await bthomeSensor() } -void main(); +await main(); diff --git a/tsconfig.json b/tsconfig.json index 4658f1e..169ac5a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,17 +1,17 @@ { "compilerOptions": { - "module": "commonjs", + "module": "es2022", + "moduleResolution": "Bundler", "declaration": true, "removeComments": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, "allowSyntheticDefaultImports": true, - "target": "es2023", + "target": "es2022", "sourceMap": true, "outDir": "./dist", "skipLibCheck": true, "strictNullChecks": false, - "noEmit": true, "noImplicitAny": false, "strictBindCallApply": false, "forceConsistentCasingInFileNames": false, @@ -25,7 +25,5 @@ "@utils/*": ["./src/utils/*"], "@common/*": ["./src/common/*"] } - }, - "include": ["src"], - "exclude": ["node_modules"] + } }