Skip to content

Commit

Permalink
✨ Export helper methods
Browse files Browse the repository at this point in the history
  • Loading branch information
AnandChowdhary committed Nov 15, 2022
1 parent f0afde4 commit f631afa
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 41 deletions.
34 changes: 0 additions & 34 deletions src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/usr/bin/env node
import { lstat, pathExists, readdir, readJson, writeFile } from "fs-extra";
import { join } from "path";
import {
Clockify,
Goodreads,
Expand All @@ -13,7 +11,6 @@ import {
Twitter,
Wakatime,
} from "./";
import { sortObject, zero } from "./common";

const INTEGRATIONS = [
Clockify,
Expand Down Expand Up @@ -52,37 +49,6 @@ const cli = async () => {
integrationObject.summary();
}
});

const createdIntegrationData = await readdir(join(".", "data"));
for (const dir of createdIntegrationData) {
const summary: Record<string, any> = {};
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<string, any>;
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`);
}
Expand Down
29 changes: 22 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -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";

0 comments on commit f631afa

Please sign in to comment.