Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

* lints, docs & actions #5

Merged
merged 3 commits into from
Nov 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ on:
- '**/*.mjs'

pull_request:
branches:
types: [ opened ]
branches:
- main
paths:
- 'package.json'
Expand Down
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -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/)


Expand Down Expand Up @@ -83,11 +85,13 @@ node cli control <ID|Name> --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)
Expand Down
9 changes: 5 additions & 4 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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'));
Expand Down Expand Up @@ -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?',
Expand Down Expand Up @@ -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 });
Expand All @@ -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);

Expand Down
1 change: 1 addition & 0 deletions tests/helpers.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { existsSync, readFileSync, writeFileSync, unlinkSync } from 'node:fs';
import process from "node:process";

import 'dotenv/config';

Expand Down
1 change: 1 addition & 0 deletions tests/suite.js
Original file line number Diff line number Diff line change
@@ -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',
Expand Down