Comparing version
@@ -1,2 +0,1 @@ | ||
#!/usr/bin/env node | ||
export {}; |
@@ -1,2 +0,1 @@ | ||
#!/usr/bin/env node | ||
import meow from 'meow'; | ||
@@ -3,0 +2,0 @@ import { auth } from './auth.js'; |
@@ -8,2 +8,3 @@ import { getSession } from './auth.js'; | ||
import { Session } from '../lib/index.js'; | ||
import pkg from '../package.json' assert { type: 'json' }; | ||
export class MeteringHandler { | ||
@@ -13,2 +14,3 @@ constructor(flags) { | ||
this.session = getSession({ token: this.flags.token, prm: this.flags.prm }); | ||
this.session.userAgent = `@bokub/linky CLI (v${pkg.version})`; | ||
} | ||
@@ -15,0 +17,0 @@ daily() { |
@@ -59,2 +59,3 @@ import { AxiosError } from 'axios'; | ||
private prms; | ||
userAgent: string; | ||
constructor(token: string, prm?: string | undefined); | ||
@@ -61,0 +62,0 @@ getDailyConsumption(start: string, end: string): Promise<EnergyResponse>; |
@@ -29,2 +29,3 @@ import axios, { AxiosError } from 'axios'; | ||
this.prms = []; | ||
this.userAgent = '@bokub/linky'; | ||
try { | ||
@@ -70,3 +71,3 @@ const decoded = jwt.decode(token); | ||
Accept: 'application/json', | ||
'User-Agent': '@bokub/linky', | ||
'User-Agent': this.userAgent, | ||
}, | ||
@@ -73,0 +74,0 @@ }) |
{ | ||
"name": "linky", | ||
"description": "Easily retrieve your Linky power consumption", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"author": "bokub", | ||
@@ -9,3 +9,3 @@ "license": "GPL-3.0-or-later", | ||
"bin": { | ||
"linky": "dist/bin/cli.js" | ||
"linky": "dist/bin/index.cjs" | ||
}, | ||
@@ -21,9 +21,8 @@ "types": "dist/lib/index.d.ts", | ||
"scripts": { | ||
"coverage": "c8 report --reporter=text-lcov > coverage.lcov", | ||
"test": "NODE_OPTIONS=--experimental-vm-modules c8 jest", | ||
"test": "NODE_NO_WARNINGS=1 NODE_OPTIONS=--experimental-vm-modules jest", | ||
"test:coverage": "c8 npm run test && c8 report --reporter=text-lcov > coverage.lcov", | ||
"generate-fixtures": "RECORDING=1 node --experimental-vm-modules --loader=ts-node/esm test/fixtures/generate.ts", | ||
"prepare": "husky install", | ||
"prepublishOnly": "npm run build", | ||
"build": "rm -fr ./dist && tsc", | ||
"pkg": "rm -fr ./pkg && pkg . --out-path pkg -t node18-linux-x64,node18-macos-x64,node18-win-x64", | ||
"build": "rm -fr ./dist && tsc && cp cli.cjs ./dist/bin/index.cjs", | ||
"lint": "npx prettier --check --ignore-path .gitignore . && npx eslint --ext ts,js ." | ||
@@ -62,3 +61,2 @@ }, | ||
"nock": "^13.3.1", | ||
"pkg": "^5.8.1", | ||
"prettier": "^2.8.8", | ||
@@ -65,0 +63,0 @@ "ts-jest": "^29.1.0", |
{ | ||
"name": "linky", | ||
"description": "Easily retrieve your Linky power consumption", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"author": "bokub", | ||
@@ -9,3 +9,3 @@ "license": "GPL-3.0-or-later", | ||
"bin": { | ||
"linky": "dist/bin/cli.js" | ||
"linky": "dist/bin/index.cjs" | ||
}, | ||
@@ -21,9 +21,8 @@ "types": "dist/lib/index.d.ts", | ||
"scripts": { | ||
"coverage": "c8 report --reporter=text-lcov > coverage.lcov", | ||
"test": "NODE_OPTIONS=--experimental-vm-modules c8 jest", | ||
"test": "NODE_NO_WARNINGS=1 NODE_OPTIONS=--experimental-vm-modules jest", | ||
"test:coverage": "c8 npm run test && c8 report --reporter=text-lcov > coverage.lcov", | ||
"generate-fixtures": "RECORDING=1 node --experimental-vm-modules --loader=ts-node/esm test/fixtures/generate.ts", | ||
"prepare": "husky install", | ||
"prepublishOnly": "npm run build", | ||
"build": "rm -fr ./dist && tsc", | ||
"pkg": "rm -fr ./pkg && pkg . --out-path pkg -t node18-linux-x64,node18-macos-x64,node18-win-x64", | ||
"build": "rm -fr ./dist && tsc && cp cli.cjs ./dist/bin/index.cjs", | ||
"lint": "npx prettier --check --ignore-path .gitignore . && npx eslint --ext ts,js ." | ||
@@ -62,3 +61,2 @@ }, | ||
"nock": "^13.3.1", | ||
"pkg": "^5.8.1", | ||
"prettier": "^2.8.8", | ||
@@ -65,0 +63,0 @@ "ts-jest": "^29.1.0", |
@@ -11,4 +11,2 @@ # Linky | ||
### Attention : Cette documentation est valable uniquement pour la version 2 du module. La documentation pour la version 1 est toujours disponible sur la [branche v1](https://github.com/bokub/linky/tree/v1#readme) | ||
<p align="center"> | ||
@@ -18,2 +16,4 @@ <img src="https://user-images.githubusercontent.com/17952318/93326183-b5ba2400-f818-11ea-85cf-c278a1e32b58.gif" alt="Screenshot"> | ||
### Attention : Cette documentation est valable uniquement pour la version 2 du module. La documentation pour la version 1 est toujours disponible sur la [branche v1](https://github.com/bokub/linky/tree/v1#readme) | ||
Ce module vous permet de récupérer votre consommation et production électrique Linky via les API _"Token V3"_ et _"Metering Data V5"_ d'Enedis | ||
@@ -32,3 +32,4 @@ | ||
Si vous avez Node.js sur votre machine : | ||
1. Installez [Node.js](https://nodejs.org/en/download) sur votre machine | ||
2. Installez `linky` avec npm: | ||
@@ -39,8 +40,2 @@ ```bash | ||
Dans le cas contraire, vous pouvez télécharger le binaire correspondant à votre plateforme dans les [assets de la dernière release](https://github.com/bokub/linky/releases/latest). | ||
> **N.B :** Si vous choisissez d'utiliser un binaire, il faudra adapter les exemples de cette documentation en replaçant la commande `linky` par le nom du binaire. | ||
> | ||
> Par exemple, au lieu de faire `linky --help`, il faudra faire `./linky-win.exe --help` | ||
### Utilisation | ||
@@ -54,3 +49,3 @@ | ||
Puis, créez une connexion à votre compte avec la commande suivante: | ||
Puis, créez une connexion à votre compte avec la commande suivante : | ||
@@ -66,3 +61,3 @@ ```bash | ||
```bash | ||
# Récupère la consommation quotidienne du 1er au 3 mai 2023 inclus | ||
# Récupère la consommation quotidienne du 1er au 3 mai 2023 | ||
linky daily --start 2023-05-01 --end 2023-05-04 | ||
@@ -73,3 +68,3 @@ | ||
# Récupère la puissance maximale de consommation atteinte quotidiennement du 1er au 3 mai 2023 inclus | ||
# Récupère la puissance maximale de consommation atteinte quotidiennement du 1er au 3 mai 2023 | ||
linky maxpower --start 2023-05-01 --end 2023-05-04 | ||
@@ -81,3 +76,3 @@ ``` | ||
```bash | ||
# Récupère la production quotidienne du 1er au 3 mai 2023 inclus | ||
# Récupère la production quotidienne du 1er au 3 mai 2023 | ||
linky dailyprod --start 2023-05-01 --end 2023-05-04 | ||
@@ -186,2 +181,7 @@ | ||
// Si vous prévoyez de rendre votre application/service/module accessible au grand public, | ||
// ajoutez un User-Agent au format string à la session. | ||
// Celui-ci doit permettre d'identifier l'origine des requêtes envoyées à Conso API. | ||
session.userAgent = 'Mon super service'; | ||
// Récupère la consommation quotidienne du 1er au 3 mai 2023 | ||
@@ -188,0 +188,0 @@ session.getDailyConsumption('2023-05-01', '2023-05-04').then((result) => { |
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
65489
0.27%21
-4.55%15
7.14%464
1.53%1
Infinity%