From afdcc482b23f64e96066a7229ae59780aa7870f3 Mon Sep 17 00:00:00 2001 From: Krasimir Gruychev Date: Sat, 23 Nov 2024 04:49:39 +0200 Subject: [PATCH 1/3] * code lints * README.md: todo --- README.md | 8 +++++--- cli.js | 9 +++++---- tests/helpers.mjs | 1 + tests/suite.js | 1 + 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 1d0ffdf..83b0d2c 100644 --- a/README.md +++ b/README.md @@ -83,11 +83,13 @@ node cli control --rgb 90,30,115 # RGB something ``` -## TODO +## TODO ![Direction](https://img.shields.io/badge/read-backwards-blue) -- ✅ port and optimize [tuya-smartlife-api-node](https://github.com/shellcatt/tuya-smartlife-api-node) -- ✅ port unit tests +- ❌ migrate to TypeScript +- ❌ add JSDoc - ✅ port pipelines +- ✅ port unit tests +- ✅ port and optimize [tuya-smartlife-api-node](https://github.com/shellcatt/tuya-smartlife-api-node) ## Credits ![License](https://img.shields.io/badge/license-MIT-73901d) diff --git a/cli.js b/cli.js index c0a48cb..aa9a097 100755 --- a/cli.js +++ b/cli.js @@ -13,6 +13,7 @@ import { delay as sleep } from "@std/async/delay"; import colors from '@colors/colors'; colors.enable(); +import process from "node:process"; import { log } from "node:console"; import initDebug from 'debug'; const debug = initDebug('cli'); @@ -60,7 +61,7 @@ async function init() { if (!authConfigStore.has('auth')) { await auth(); } else if (!sessionStore.has('session.accessToken')) { - let auth = authConfigStore.get('auth'); + const auth = authConfigStore.get('auth'); await client.init(auth.HA_EMAIL, auth.HA_PASS, auth.HA_CC, auth.HA_REGION); } else { await client.load(sessionStore.get('session')); @@ -108,7 +109,7 @@ function renderTable({ head, rows, widths }) { program .command('auth') .description('login with SmartLife') - .action(async (opts) => { + .action(async () => { if (authConfigStore.has('auth')) { const answer = await select({ message: 'Re-enter existing credentitals?', @@ -194,7 +195,7 @@ program } else if (tDevice.deviceType() == 'light') { - let devName = client.getDeviceById(tDevice.objectId()).name(); + const devName = client.getDeviceById(tDevice.objectId()).name(); log(`Get device by Name (${devName})...`); tBulb = client.getDeviceByName( devName ); log({ tBulb }); @@ -205,7 +206,7 @@ program await sleep(500); log('Test Light Bulb controls...'); - let response = await client.deviceControl(tBulb.objectId(), 'turnOnOff', { value: '1' }); + const response = await client.deviceControl(tBulb.objectId(), 'turnOnOff', { value: '1' }); console.dir(response, { depth: null }); await sleep(500); diff --git a/tests/helpers.mjs b/tests/helpers.mjs index 43145bc..f38df53 100644 --- a/tests/helpers.mjs +++ b/tests/helpers.mjs @@ -1,4 +1,5 @@ import { existsSync, readFileSync, writeFileSync, unlinkSync } from 'node:fs'; +import process from "node:process"; import 'dotenv/config'; diff --git a/tests/suite.js b/tests/suite.js index 4d62bf5..e93d86c 100644 --- a/tests/suite.js +++ b/tests/suite.js @@ -1,6 +1,7 @@ import Mocha from 'mocha'; import { readdirSync } from 'node:fs'; import { join } from 'node:path'; +import process from "node:process"; const mocha = new Mocha({ reporter: 'spec', From 1c9c6080c9cf3ea91f8aee0c87fcb987f3dbfd58 Mon Sep 17 00:00:00 2001 From: Krasimir Gruychev Date: Sat, 23 Nov 2024 05:30:33 +0200 Subject: [PATCH 2/3] * GH Actions: updated main events --- .github/workflows/main.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fdbd4a8..04f7b55 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -12,7 +12,8 @@ on: - '**/*.mjs' pull_request: - branches: + types: [ opened ] + branches: - main paths: - 'package.json' From 852d59f897b0c3d37da50db42a02350ccb847923 Mon Sep 17 00:00:00 2001 From: Krasimir Gruychev Date: Sat, 23 Nov 2024 05:51:52 +0200 Subject: [PATCH 3/3] * README.md: workflow badges --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 83b0d2c..4bb3abf 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Tuya Smart Life API + CLI +![Unit Tests](https://github.com/shellcatt/tuya-smartlife-api-deno/actions/workflows/main.yml/badge.svg?branch=main) ![Releases](https://github.com/shellcatt/tuya-smartlife-api-deno/actions/workflows/release.yml/badge.svg) + ## Usage [![requirements]( https://img.shields.io/badge/requires-deno-blue?logo=deno)](https://docs.deno.com/runtime/getting_started/installation/)