@drakulavich/oura-cli 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -6,6 +6,27 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.1.3] - 2026-05-13
10
+
11
+ ### Fixed
12
+ - `--token <pat>` global flag now uses the value as an inline token instead of
13
+ trying to read it as a file path (#1, item 1).
14
+ - `--no-color` is now wired through to chalk and honors the `NO_COLOR` env
15
+ variable; it was previously advertised in the `describe` manifest but never
16
+ took effect (#1, item 2).
17
+ - `todayDate()` and `dateRange()` now use the configured/system timezone via
18
+ `todayLocal(resolveDefaultTimezone())` instead of UTC-only `.toISOString()`,
19
+ so users in non-UTC timezones get the correct "today" near midnight (#1,
20
+ item 3).
21
+ - Single-day `start == end` API calls verified safe: `oura-cli sleep today`
22
+ (which calls `client.fetch(endpoint, today, today)`) returns data correctly.
23
+ No change needed to `api-command.ts` (#1, item 4).
24
+
25
+ ### Note
26
+ - Several smells covered in the audit issue (#1) remain open for v0.2+:
27
+ closed `ErrorCode` union, manifest documentation, commander chain helper,
28
+ schema-validated test fixtures.
29
+
9
30
  ## [0.1.2] - 2026-05-13
10
31
 
11
32
  ### Fixed
@@ -42,6 +63,7 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
42
63
  - Local SQLite cache at `~/.oura-cli/oura.db`.
43
64
  - Auth via `oura-cli login`, `OURA_TOKEN`, `OURA_TOKEN_PATH`, or `~/.oura-token`.
44
65
 
66
+ [0.1.3]: https://github.com/drakulavich/oura-cli/releases/tag/v0.1.3
45
67
  [0.1.2]: https://github.com/drakulavich/oura-cli/releases/tag/v0.1.2
46
68
  [0.1.1]: https://github.com/drakulavich/oura-cli/releases/tag/v0.1.1
47
69
  [0.1.0]: https://github.com/drakulavich/oura-cli/releases/tag/v0.1.0
package/dist/index.js CHANGED
@@ -2142,11 +2142,6 @@ var {
2142
2142
  Help
2143
2143
  } = import__.default;
2144
2144
 
2145
- // src/api/client.ts
2146
- import { readFileSync } from "fs";
2147
- import { resolve } from "path";
2148
- import { homedir } from "os";
2149
-
2150
2145
  // node_modules/chalk/source/vendor/ansi-styles/index.js
2151
2146
  var ANSI_BACKGROUND_OFFSET = 10;
2152
2147
  var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
@@ -2636,6 +2631,11 @@ var chalk = createChalk();
2636
2631
  var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
2637
2632
  var source_default = chalk;
2638
2633
 
2634
+ // src/api/client.ts
2635
+ import { readFileSync } from "fs";
2636
+ import { resolve } from "path";
2637
+ import { homedir } from "os";
2638
+
2639
2639
  // src/lib/errors.ts
2640
2640
  class CliError extends Error {
2641
2641
  code;
@@ -2717,16 +2717,52 @@ class OuraClient {
2717
2717
  }
2718
2718
  }
2719
2719
 
2720
+ // src/lib/time.ts
2721
+ function nowUtc() {
2722
+ return new Date().toISOString().replace(/\.\d{3}Z$/, "Z");
2723
+ }
2724
+ function formatLocal(utcStr, timezone) {
2725
+ const dt = new Date(utcStr);
2726
+ const parts = new Intl.DateTimeFormat("sv-SE", {
2727
+ timeZone: timezone,
2728
+ year: "numeric",
2729
+ month: "2-digit",
2730
+ day: "2-digit",
2731
+ hour: "2-digit",
2732
+ minute: "2-digit",
2733
+ hour12: false
2734
+ }).formatToParts(dt);
2735
+ const get = (type) => parts.find((p) => p.type === type)?.value ?? "";
2736
+ return `${get("year")}-${get("month")}-${get("day")} ${get("hour")}:${get("minute")}`;
2737
+ }
2738
+ function formatLocalDate(utcStr, timezone) {
2739
+ return formatLocal(utcStr, timezone).split(" ")[0];
2740
+ }
2741
+ function todayLocal(timezone) {
2742
+ return formatLocalDate(nowUtc(), timezone);
2743
+ }
2744
+ function resolveDefaultTimezone() {
2745
+ if (process.env.OURA_TZ)
2746
+ return process.env.OURA_TZ;
2747
+ try {
2748
+ return Intl.DateTimeFormat().resolvedOptions().timeZone || "UTC";
2749
+ } catch {
2750
+ return "UTC";
2751
+ }
2752
+ }
2753
+
2720
2754
  // src/commands/helpers.ts
2721
2755
  function getClient(opts) {
2722
- return new OuraClient(opts.token ? { tokenPath: opts.token } : {});
2756
+ return new OuraClient(opts.token ? { token: opts.token } : {});
2723
2757
  }
2724
- function todayDate() {
2725
- return new Date().toISOString().slice(0, 10);
2758
+ function todayDate(timezone) {
2759
+ return todayLocal(timezone ?? resolveDefaultTimezone());
2726
2760
  }
2727
- function dateRange(days) {
2728
- const end = todayDate();
2729
- const start = new Date(Date.now() - days * 86400000).toISOString().slice(0, 10);
2761
+ function dateRange(days, timezone) {
2762
+ const tz = timezone ?? resolveDefaultTimezone();
2763
+ const end = todayLocal(tz);
2764
+ const startMs = new Date(`${end}T00:00:00Z`).getTime() - (days - 1) * 86400000;
2765
+ const start = new Date(startMs).toISOString().slice(0, 10);
2730
2766
  return { start, end };
2731
2767
  }
2732
2768
 
@@ -3822,9 +3858,12 @@ function describeCommand(version) {
3822
3858
  }
3823
3859
 
3824
3860
  // src/index.ts
3825
- var VERSION = "0.1.2";
3861
+ var VERSION = "0.1.3";
3862
+ if (process.argv.includes("--no-color") || process.env.NO_COLOR) {
3863
+ source_default.level = 0;
3864
+ }
3826
3865
  var program2 = new Command;
3827
- program2.name("oura-cli").description("Oura Ring CLI \u2014 query and analyze Oura Ring health data. Designed for humans and agents.").version(VERSION).option("--format <format>", "Output format: table | json (default auto-detect by TTY)").option("--token <pat>", "Inline access token (prefer env vars or `oura-cli login`)").option("--db <path>", "Path to SQLite database file (env: OURA_DB_PATH)").option("--tz <timezone>", "Display timezone (env: OURA_TZ; default auto-detect)");
3866
+ program2.name("oura-cli").description("Oura Ring CLI \u2014 query and analyze Oura Ring health data. Designed for humans and agents.").version(VERSION).option("--format <format>", "Output format: table | json (default auto-detect by TTY)").option("--token <pat>", "Inline access token (prefer env vars or `oura-cli login`)").option("--db <path>", "Path to SQLite database file (env: OURA_DB_PATH)").option("--tz <timezone>", "Display timezone (env: OURA_TZ; default auto-detect)").option("--no-color", "Disable ANSI colors in human output (also honors NO_COLOR env)");
3828
3867
  program2.addCommand(loginCommand());
3829
3868
  program2.addCommand(describeCommand(VERSION));
3830
3869
  program2.addCommand(createApiCommand("sleep", "Fetch daily sleep scores from Oura API.", "daily_sleep"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drakulavich/oura-cli",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Oura Ring CLI — query and analyze Oura Ring health data from the command line, designed for humans and AI agents.",
5
5
  "keywords": [
6
6
  "oura",