diff --git a/src/cli.ts b/src/cli.ts index 322392b..21e949e 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -1,6 +1,4 @@ #!/usr/bin/env node -import { lstat, pathExists, readdir, readJson, writeFile } from "fs-extra"; -import { join } from "path"; import { Clockify, Goodreads, @@ -13,7 +11,6 @@ import { Twitter, Wakatime, } from "./"; -import { sortObject, zero } from "./common"; const INTEGRATIONS = [ Clockify, @@ -52,37 +49,6 @@ const cli = async () => { integrationObject.summary(); } }); - - const createdIntegrationData = await readdir(join(".", "data")); - for (const dir of createdIntegrationData) { - const summary: Record = {}; - if ( - (await pathExists(join(".", "data", dir, "summary", "days"))) && - (await lstat(join(".", "data", dir, "summary", "days"))).isDirectory() - ) { - const years = await readdir(join(".", "data", dir, "summary", "days")); - for (const year of years) { - if ( - (await pathExists(join(".", "data", dir, "summary", "days", year))) && - (await lstat(join(".", "data", dir, "summary", "days", year))).isDirectory() - ) { - const months = await readdir(join(".", "data", dir, "summary", "days", year)); - for (const month of months) { - const file = join(".", "data", dir, "summary", "days", year, month); - const data = (await readJson(file)) as Record; - Object.entries(data).forEach(([day, value]) => { - summary[`${zero(year)}-${zero(month.replace(".json", ""))}-${zero(day)}`] = value; - }); - } - } - } - } - if (Object.keys(summary).length) - await writeFile( - join(".", "data", dir, "summary", "days.json"), - JSON.stringify(sortObject(summary), null, 2) + "\n" - ); - } } else { throw new Error(`CLI command '${command}' not recognized`); } diff --git a/src/index.ts b/src/index.ts index fdff0ea..c4f6475 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,12 +1,27 @@ -import Spotify from "./api/spotify"; -import Rescuetime from "./api/rescuetime"; -import LastFm from "./api/last-fm"; -import PocketCasts from "./api/pocket-casts"; -import Wakatime from "./api/wakatime"; import Clockify from "./api/clockify"; +import Goodreads from "./api/goodreads"; import GoogleFit from "./api/google-fit"; +import LastFm from "./api/last-fm"; import OuraRing from "./api/oura-ring"; -import Goodreads from "./api/goodreads"; +import PocketCasts from "./api/pocket-casts"; +import Rescuetime from "./api/rescuetime"; +import Spotify from "./api/spotify"; import Twitter from "./api/twitter"; +import Wakatime from "./api/wakatime"; + +export * from "./common"; +export { + Spotify, + Rescuetime, + LastFm, + PocketCasts, + Wakatime, + Clockify, + GoogleFit, + OuraRing, + Goodreads, + Twitter, +}; +export { fs }; -export { Spotify, Rescuetime, LastFm, PocketCasts, Wakatime, Clockify, GoogleFit, OuraRing, Goodreads, Twitter }; +import fs from "fs-extra";