From e942fc2911252ec5535e0ac271f3b87637860f04 Mon Sep 17 00:00:00 2001 From: kaustubh285 Date: Sun, 1 Mar 2026 17:29:27 +0000 Subject: [PATCH] Add Biome config and format code Add biome.json and enable Biome formatting/linting. Add @biomejs/biome, commander, and fuse.js to package files and add a format script. Apply consistent styling (double quotes, semicolons, import ordering, and minor type fixes) across the codebase. --- biome.json | 34 +++++++++ bun.lock | 25 +++++++ package.json | 104 +++++++++++++------------- src/commands/config.command.ts | 25 +++++-- src/commands/dump.command.ts | 75 ++++++++++++------- src/commands/flux.option.ts | 2 +- src/commands/init.command.ts | 131 +++++++++++++++++---------------- src/commands/search.command.ts | 46 +++++++----- src/index.ts | 95 ++++++++++++++---------- src/types/index.ts | 17 ++--- src/utils/constants.ts | 8 +- src/utils/fuse.instance.ts | 6 +- src/utils/helper.ts | 82 ++++++++++++++------- src/utils/index.ts | 8 +- src/utils/lib.ts | 68 ++++++++++------- src/utils/privacy.ts | 37 +++++----- tsconfig.json | 48 ++++++------ 17 files changed, 490 insertions(+), 321 deletions(-) create mode 100644 biome.json diff --git a/biome.json b/biome.json new file mode 100644 index 0000000..b9b52b1 --- /dev/null +++ b/biome.json @@ -0,0 +1,34 @@ +{ + "$schema": "https://biomejs.dev/schemas/2.4.4/schema.json", + "vcs": { + "enabled": true, + "clientKind": "git", + "useIgnoreFile": true + }, + "files": { + "includes": ["**", "!!**/dist"] + }, + "formatter": { + "enabled": true, + "indentStyle": "tab" + }, + "linter": { + "enabled": true, + "rules": { + "recommended": true + } + }, + "javascript": { + "formatter": { + "quoteStyle": "double" + } + }, + "assist": { + "enabled": true, + "actions": { + "source": { + "organizeImports": "on" + } + } + } +} diff --git a/bun.lock b/bun.lock index 362b809..7aed80e 100644 --- a/bun.lock +++ b/bun.lock @@ -5,9 +5,12 @@ "": { "name": "flux-cap", "dependencies": { + "commander": "^14.0.3", + "fuse.js": "^7.1.0", "inquirer": "^13.2.5", }, "devDependencies": { + "@biomejs/biome": "2.4.4", "@changesets/cli": "^2.29.8", "@types/inquirer": "^9.0.9", }, @@ -16,6 +19,24 @@ "packages": { "@babel/runtime": ["@babel/runtime@7.28.6", "", {}, "sha512-05WQkdpL9COIMz4LjTxGpPNCdlpyimKppYNoJ5Di5EUObifl8t4tuLuUBBZEpoLYOmfvIWrsp9fCl0HoPRVTdA=="], + "@biomejs/biome": ["@biomejs/biome@2.4.4", "", { "optionalDependencies": { "@biomejs/cli-darwin-arm64": "2.4.4", "@biomejs/cli-darwin-x64": "2.4.4", "@biomejs/cli-linux-arm64": "2.4.4", "@biomejs/cli-linux-arm64-musl": "2.4.4", "@biomejs/cli-linux-x64": "2.4.4", "@biomejs/cli-linux-x64-musl": "2.4.4", "@biomejs/cli-win32-arm64": "2.4.4", "@biomejs/cli-win32-x64": "2.4.4" }, "bin": { "biome": "bin/biome" } }, "sha512-tigwWS5KfJf0cABVd52NVaXyAVv4qpUXOWJ1rxFL8xF1RVoeS2q/LK+FHgYoKMclJCuRoCWAPy1IXaN9/mS61Q=="], + + "@biomejs/cli-darwin-arm64": ["@biomejs/cli-darwin-arm64@2.4.4", "", { "os": "darwin", "cpu": "arm64" }, "sha512-jZ+Xc6qvD6tTH5jM6eKX44dcbyNqJHssfl2nnwT6vma6B1sj7ZLTGIk6N5QwVBs5xGN52r3trk5fgd3sQ9We9A=="], + + "@biomejs/cli-darwin-x64": ["@biomejs/cli-darwin-x64@2.4.4", "", { "os": "darwin", "cpu": "x64" }, "sha512-Dh1a/+W+SUCXhEdL7TiX3ArPTFCQKJTI1mGncZNWfO+6suk+gYA4lNyJcBB+pwvF49uw0pEbUS49BgYOY4hzUg=="], + + "@biomejs/cli-linux-arm64": ["@biomejs/cli-linux-arm64@2.4.4", "", { "os": "linux", "cpu": "arm64" }, "sha512-V/NFfbWhsUU6w+m5WYbBenlEAz8eYnSqRMDMAW3K+3v0tYVkNyZn8VU0XPxk/lOqNXLSCCrV7FmV/u3SjCBShg=="], + + "@biomejs/cli-linux-arm64-musl": ["@biomejs/cli-linux-arm64-musl@2.4.4", "", { "os": "linux", "cpu": "arm64" }, "sha512-+sPAXq3bxmFwhVFJnSwkSF5Rw2ZAJMH3MF6C9IveAEOdSpgajPhoQhbbAK12SehN9j2QrHpk4J/cHsa/HqWaYQ=="], + + "@biomejs/cli-linux-x64": ["@biomejs/cli-linux-x64@2.4.4", "", { "os": "linux", "cpu": "x64" }, "sha512-R4+ZCDtG9kHArasyBO+UBD6jr/FcFCTH8QkNTOCu0pRJzCWyWC4EtZa2AmUZB5h3e0jD7bRV2KvrENcf8rndBg=="], + + "@biomejs/cli-linux-x64-musl": ["@biomejs/cli-linux-x64-musl@2.4.4", "", { "os": "linux", "cpu": "x64" }, "sha512-gGvFTGpOIQDb5CQ2VC0n9Z2UEqlP46c4aNgHmAMytYieTGEcfqhfCFnhs6xjt0S3igE6q5GLuIXtdQt3Izok+g=="], + + "@biomejs/cli-win32-arm64": ["@biomejs/cli-win32-arm64@2.4.4", "", { "os": "win32", "cpu": "arm64" }, "sha512-trzCqM7x+Gn832zZHgr28JoYagQNX4CZkUZhMUac2YxvvyDRLJDrb5m9IA7CaZLlX6lTQmADVfLEKP1et1Ma4Q=="], + + "@biomejs/cli-win32-x64": ["@biomejs/cli-win32-x64@2.4.4", "", { "os": "win32", "cpu": "x64" }, "sha512-gnOHKVPFAAPrpoPt2t+Q6FZ7RPry/FDV3GcpU53P3PtLNnQjBmKyN2Vh/JtqXet+H4pme8CC76rScwdjDcT1/A=="], + "@changesets/apply-release-plan": ["@changesets/apply-release-plan@7.0.14", "", { "dependencies": { "@changesets/config": "^3.1.2", "@changesets/get-version-range-type": "^0.4.0", "@changesets/git": "^3.0.4", "@changesets/should-skip-package": "^0.1.2", "@changesets/types": "^6.1.0", "@manypkg/get-packages": "^1.1.3", "detect-indent": "^6.0.0", "fs-extra": "^7.0.1", "lodash.startcase": "^4.4.0", "outdent": "^0.5.0", "prettier": "^2.7.1", "resolve-from": "^5.0.0", "semver": "^7.5.3" } }, "sha512-ddBvf9PHdy2YY0OUiEl3TV78mH9sckndJR14QAt87KLEbIov81XO0q0QAmvooBxXlqRRP8I9B7XOzZwQG7JkWA=="], "@changesets/assemble-release-plan": ["@changesets/assemble-release-plan@6.0.9", "", { "dependencies": { "@changesets/errors": "^0.2.0", "@changesets/get-dependents-graph": "^2.1.3", "@changesets/should-skip-package": "^0.1.2", "@changesets/types": "^6.1.0", "@manypkg/get-packages": "^1.1.3", "semver": "^7.5.3" } }, "sha512-tPgeeqCHIwNo8sypKlS3gOPmsS3wP0zHt67JDuL20P4QcXiw/O4Hl7oXiuLnP9yg+rXLQ2sScdV1Kkzde61iSQ=="], @@ -116,6 +137,8 @@ "cli-width": ["cli-width@4.1.0", "", {}, "sha512-ouuZd4/dm2Sw5Gmqy6bGyNNNe1qt9RpmxveLSO7KcgsTnU7RXfsw+/bukWGo1abgBiMAic068rclZsO4IWmmxQ=="], + "commander": ["commander@14.0.3", "", {}, "sha512-H+y0Jo/T1RZ9qPP4Eh1pkcQcLRglraJaSLoyOtHxu6AapkjWVCy2Sit1QQ4x3Dng8qDlSsZEet7g5Pq06MvTgw=="], + "cross-spawn": ["cross-spawn@7.0.6", "", { "dependencies": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", "which": "^2.0.1" } }, "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA=="], "detect-indent": ["detect-indent@6.1.0", "", {}, "sha512-reYkTUJAZb9gUuZ2RvVCNhVHdg62RHnJ7WJl8ftMi4diZ6NWlciOzQN88pUhSELEwflJht4oQDv0F0BMlwaYtA=="], @@ -144,6 +167,8 @@ "fs-extra": ["fs-extra@7.0.1", "", { "dependencies": { "graceful-fs": "^4.1.2", "jsonfile": "^4.0.0", "universalify": "^0.1.0" } }, "sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw=="], + "fuse.js": ["fuse.js@7.1.0", "", {}, "sha512-trLf4SzuuUxfusZADLINj+dE8clK1frKdmqiJNb1Es75fmI5oY6X2mxLVUciLLjxqw/xr72Dhy+lER6dGd02FQ=="], + "glob-parent": ["glob-parent@5.1.2", "", { "dependencies": { "is-glob": "^4.0.1" } }, "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow=="], "globby": ["globby@11.1.0", "", { "dependencies": { "array-union": "^2.1.0", "dir-glob": "^3.0.1", "fast-glob": "^3.2.9", "ignore": "^5.2.0", "merge2": "^1.4.1", "slash": "^3.0.0" } }, "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g=="], diff --git a/package.json b/package.json index 0000b89..ddf2b9e 100644 --- a/package.json +++ b/package.json @@ -1,52 +1,56 @@ { - "name": "@dev_desh/flux-cap", - "type": "module", - "version": "0.7.0", - "description": "Git-aware CLI context manager for ADHD developers", - "bin": { - "flux": "./dist/index.js" - }, - "files": [ - "dist/**/*", - "README.md", - "LICENSE" - ], - "scripts": { - "build": "bun build src/index.ts --outdir dist --target node --format esm", - "dev": "bun run src/index.ts", - "prepublishOnly": "bun run build", - "publish": "npm publish --access=public", - "local-install": "bun run build && npm link", - "local-uninstall": "npm unlink -g flux-cap", - "local-reinstall": "bun run local-uninstall && bun run local-install", - "changeset": "changeset", - "changeset:add": "changeset add", - "changeset:status": "changeset status", - "changeset:version": "changeset version", - "changeset:publish": "changeset publish" - }, - "engines": { - "node": ">=18.0.0" - }, - "keywords": [ - "cli", - "productivity", - "adhd", - "git", - "context-switching", - "brain-dump", - "developer-tools" - ], - "dependencies": { - "inquirer": "^13.2.5" - }, - "devDependencies": { - "@changesets/cli": "^2.29.8", - "@types/inquirer": "^9.0.9" - }, - "repository": { - "type": "git", - "url": "https://github.com/kaustubh285/flux-cap" - }, - "license": "MIT" + "name": "@dev_desh/flux-cap", + "type": "module", + "version": "0.7.0", + "description": "Git-aware CLI context manager for ADHD developers", + "bin": { + "flux": "./dist/index.js" + }, + "files": [ + "dist/**/*", + "README.md", + "LICENSE" + ], + "scripts": { + "build": "bun build src/index.ts --outdir dist --target node --format esm", + "dev": "bun run src/index.ts", + "prepublishOnly": "bun run build", + "publish": "npm publish --access=public", + "local-install": "bun run build && npm link", + "local-uninstall": "npm unlink -g flux-cap", + "local-reinstall": "bun run local-uninstall && bun run local-install", + "changeset": "changeset", + "changeset:add": "changeset add", + "changeset:status": "changeset status", + "changeset:version": "changeset version", + "changeset:publish": "changeset publish", + "format": "bunx --bun @biomejs/biome check --write" + }, + "engines": { + "node": ">=18.0.0" + }, + "keywords": [ + "cli", + "productivity", + "adhd", + "git", + "context-switching", + "brain-dump", + "developer-tools" + ], + "dependencies": { + "commander": "^14.0.3", + "fuse.js": "^7.1.0", + "inquirer": "^13.2.5" + }, + "devDependencies": { + "@biomejs/biome": "2.4.4", + "@changesets/cli": "^2.29.8", + "@types/inquirer": "^9.0.9" + }, + "repository": { + "type": "git", + "url": "https://github.com/kaustubh285/flux-cap" + }, + "license": "MIT" } diff --git a/src/commands/config.command.ts b/src/commands/config.command.ts index 648324e..d78c1f0 100644 --- a/src/commands/config.command.ts +++ b/src/commands/config.command.ts @@ -3,16 +3,18 @@ import { getConfigFile, getFluxPath } from "../utils/lib"; export async function configCommand(data: string[]) { console.log(`Updating key: ${data[0]} to ${data[1]}`); - const fluxPath = await getFluxPath() + const fluxPath = await getFluxPath(); const fs = await import("fs"); const config = await getConfigFile(fluxPath); if (data.length < 2) { - console.log("Please provide a key and value to update the config. Example: flux config --add-tags notes ideas tasks"); + console.log( + "Please provide a key and value to update the config. Example: flux config --add-tags notes ideas tasks", + ); return; } const key = data[0]; - const value = data.slice(1).join(' '); + const value = data.slice(1).join(" "); const editableKeys = [ "hideWorkingDir", "hideBranchName", @@ -20,11 +22,13 @@ export async function configCommand(data: string[]) { "resultLimit", "threshold", "includeScore", - "defaultFocusDuration" - ] + "defaultFocusDuration", + ]; if (!editableKeys.includes(key)) { - console.log(`Invalid config key.\nEditable keys are: ${editableKeys.join(', ')}`); + console.log( + `Invalid config key.\nEditable keys are: ${editableKeys.join(", ")}`, + ); return; } @@ -72,12 +76,17 @@ export async function configCommand(data: string[]) { if (!isNaN(duration)) { config.defaultFocusDuration = duration; } else { - console.log("Invalid value for defaultFocusDuration. Please provide a number."); + console.log( + "Invalid value for defaultFocusDuration. Please provide a number.", + ); return; } } - fs.writeFileSync(fluxPath + FLUX_CONFIG_PATH, JSON.stringify(config, null, 4)); + fs.writeFileSync( + fluxPath + FLUX_CONFIG_PATH, + JSON.stringify(config, null, 4), + ); console.log("Config updated successfully."); } diff --git a/src/commands/dump.command.ts b/src/commands/dump.command.ts index 62b108b..b49aa8f 100644 --- a/src/commands/dump.command.ts +++ b/src/commands/dump.command.ts @@ -1,26 +1,37 @@ +import { editor } from "@inquirer/prompts"; import { randomUUID } from "crypto"; import type { BrainDump, BrainDumpOptions, FluxConfig } from "../types"; +import { + createBrainDumpFileIfNotExists, + getConfigFile, + getCurrentBranch, + getFluxPath, + getGitUncommittedChanges, + getMonthString, + getTags, + getWorkingDir, +} from "../utils/"; import { FLUX_BRAIN_DUMP_PATH, FLUX_CONFIG_PATH } from "../utils/constants"; -import { createBrainDumpFileIfNotExists, getConfigFile, getCurrentBranch, getFluxPath, getGitUncommittedChanges, getMonthString, getTags, getWorkingDir } from "../utils/"; -import { editor } from '@inquirer/prompts'; - -export async function handleBrainDump(message: string[], options: BrainDumpOptions) { +export async function handleBrainDump( + message: string[], + options: BrainDumpOptions, +) { try { let finalMessage: string; if (options.multiline) { - console.log('Opening editor for multiline input...'); - const initialText = message ? message.join(' ') : ''; + console.log("Opening editor for multiline input..."); + const initialText = message ? message.join(" ") : ""; const multilineInput = await editor({ - message: 'Enter your brain dump (save & exit when done):', + message: "Enter your brain dump (save & exit when done):", default: initialText, - waitForUserInput: false + waitForUserInput: false, }); if (!multilineInput.trim()) { - console.log('Brain dump cancelled - no content provided'); + console.log("Brain dump cancelled - no content provided"); return; } @@ -30,36 +41,37 @@ export async function handleBrainDump(message: string[], options: BrainDumpOptio console.log('Please provide a message: flux dump "your message"'); return; } - finalMessage = message.join(' '); + finalMessage = message.join(" "); } await brainDumpAddCommand(finalMessage, options); - } catch (error) { - console.error('Error creating brain dump:', error instanceof Error ? error.message : 'Unknown error'); + console.error( + "Error creating brain dump:", + error instanceof Error ? error.message : "Unknown error", + ); process.exit(1); } } - -export async function brainDumpAddCommand(message: string, options: BrainDumpOptions = {}) { - const fluxPath = await getFluxPath() +export async function brainDumpAddCommand( + message: string, + options: BrainDumpOptions = {}, +) { + const fluxPath = await getFluxPath(); const fs = await import("fs"); - - console.log("Creating brain dump..."); const monthString = getMonthString(); await createBrainDumpFileIfNotExists(monthString, fluxPath); const config = await getConfigFile(fluxPath); - const workingDir = await getWorkingDir(config) - const branch = getCurrentBranch(config) + const workingDir = await getWorkingDir(config); + const branch = getCurrentBranch(config); const hasUncommittedChanges = getGitUncommittedChanges(config); const tags = getTags(options, config); - const newDump: BrainDump = { id: randomUUID(), timestamp: new Date().toISOString(), @@ -67,21 +79,28 @@ export async function brainDumpAddCommand(message: string, options: BrainDumpOpt workingDir, branch, hasUncommittedChanges, - tags + tags, }; - const data: { dumps: BrainDump[] } = JSON.parse(fs.readFileSync(`${fluxPath}${FLUX_BRAIN_DUMP_PATH}/${monthString}.json`, 'utf8')); + const data: { dumps: BrainDump[] } = JSON.parse( + fs.readFileSync( + `${fluxPath}${FLUX_BRAIN_DUMP_PATH}/${monthString}.json`, + "utf8", + ), + ); config.sorted ? data.dumps.unshift(newDump) : data.dumps.push(newDump); - fs.writeFileSync(`${fluxPath}${FLUX_BRAIN_DUMP_PATH}/${monthString}.json`, JSON.stringify(data, null, 2)); + fs.writeFileSync( + `${fluxPath}${FLUX_BRAIN_DUMP_PATH}/${monthString}.json`, + JSON.stringify(data, null, 2), + ); - const displayMessage = message.length > 50 - ? message.substring(0, 47) + "..." - : message; + const displayMessage = + message.length > 50 ? message.substring(0, 47) + "..." : message; - const preview = message.includes('\n') - ? `${message.split('\n')[0]}... (multiline)` + const preview = message.includes("\n") + ? `${message.split("\n")[0]}... (multiline)` : displayMessage; console.log(`✅ Brain dump saved: "${preview}"`); diff --git a/src/commands/flux.option.ts b/src/commands/flux.option.ts index 21af4ed..38fe23f 100644 --- a/src/commands/flux.option.ts +++ b/src/commands/flux.option.ts @@ -2,7 +2,7 @@ import { getConfigFile } from "../utils"; export async function versionOption() { const config = await getConfigFile(); - console.log(`flux-cap version: ${config?.fluxVersion || 'unknown'}`); + console.log(`flux-cap version: ${config?.fluxVersion || "unknown"}`); } export function helpOption() { diff --git a/src/commands/init.command.ts b/src/commands/init.command.ts index 891a829..b966563 100644 --- a/src/commands/init.command.ts +++ b/src/commands/init.command.ts @@ -1,7 +1,13 @@ import fs from "fs"; -import { FLUX_BRAIN_DUMP_PATH, FLUX_CONFIG_PATH, FLUX_DEFAULT_CONFIG, FLUX_FOLDER_PATH, FLUX_SESSION_PATH } from "../utils/constants"; -import { createIfNotExists, getFluxPath } from "../utils/"; import inquirer from "inquirer"; +import { createIfNotExists, getFluxPath } from "../utils/"; +import { + FLUX_BRAIN_DUMP_PATH, + FLUX_CONFIG_PATH, + FLUX_DEFAULT_CONFIG, + FLUX_FOLDER_PATH, + FLUX_SESSION_PATH, +} from "../utils/constants"; export async function initFluxCommand(options: { yes?: boolean }) { console.log("Initializing Flux Capacitor..."); @@ -9,46 +15,44 @@ export async function initFluxCommand(options: { yes?: boolean }) { // CRITICAL SECTION try { // Check if .flux folder exists - await createIfNotExists(FLUX_FOLDER_PATH, 'directory'); - await createIfNotExists(FLUX_BRAIN_DUMP_PATH, 'directory'); - await createIfNotExists(FLUX_SESSION_PATH, 'directory'); - + await createIfNotExists(FLUX_FOLDER_PATH, "directory"); + await createIfNotExists(FLUX_BRAIN_DUMP_PATH, "directory"); + await createIfNotExists(FLUX_SESSION_PATH, "directory"); // Check if config.json exists - const config = FLUX_DEFAULT_CONFIG + const config = FLUX_DEFAULT_CONFIG; let answers: { includeWorkingDir: any; includeBranch: any; includeUncommitted: any; - } + }; if (options.yes) { console.log("Accepting all default options for initialization..."); answers = { includeWorkingDir: true, includeBranch: true, - includeUncommitted: true - } - } - else { + includeUncommitted: true, + }; + } else { answers = await inquirer.prompt([ { - type: 'confirm', - name: 'includeWorkingDir', - message: 'Include your current working directory in logs?', - default: true + type: "confirm", + name: "includeWorkingDir", + message: "Include your current working directory in logs?", + default: true, }, { - type: 'confirm', - name: 'includeBranch', - message: 'Include your git branch name in logs?', - default: true + type: "confirm", + name: "includeBranch", + message: "Include your git branch name in logs?", + default: true, }, { - type: 'confirm', - name: 'includeUncommitted', - message: 'Include uncommitted git changes in logs?', - default: true - } + type: "confirm", + name: "includeUncommitted", + message: "Include uncommitted git changes in logs?", + default: true, + }, ]); } @@ -56,62 +60,67 @@ export async function initFluxCommand(options: { yes?: boolean }) { config.privacy.hideBranchName = !answers.includeBranch; config.privacy.hideUncommittedChanges = !answers.includeUncommitted; + await createIfNotExists( + FLUX_CONFIG_PATH, + "file", + JSON.stringify(config, null, 4), + ); - - await createIfNotExists(FLUX_CONFIG_PATH, 'file', JSON.stringify(config, null, 4)); - - console.log("If you want to customize your configuration, you can edit the config.json file located in the .flux directory."); - } - catch (error) { + console.log( + "If you want to customize your configuration, you can edit the config.json file located in the .flux directory.", + ); + } catch (error) { console.error("Error during initialization:", error); - process.exit(1) + process.exit(1); } try { // NON-CRITICAL SECTION // If a git repo, add it to gitignore - if (fs.existsSync('.git/')) { + if (fs.existsSync(".git/")) { console.log("Git repository detected."); - } - else { + } else { console.log("Not a git repository. Skipping git integration."); } - if (fs.existsSync('.gitignore')) { + if (fs.existsSync(".gitignore")) { console.log("Gitignore file exists"); - const gitignoreContent = fs.readFileSync('.gitignore', 'utf8') + const gitignoreContent = fs.readFileSync(".gitignore", "utf8"); if (gitignoreContent.includes(FLUX_FOLDER_PATH)) { console.log(".flux is already in .gitignore"); + } else { + fs.appendFileSync(".gitignore", `\n${FLUX_FOLDER_PATH}`); } - else { - fs.appendFileSync('.gitignore', `\n${FLUX_FOLDER_PATH}`); - } - } - else { - fs.writeFileSync('.gitignore', '.flux'); + } else { + fs.writeFileSync(".gitignore", ".flux"); console.log("Created .gitignore file."); } - } - catch (error) { - console.error(`Error during git setup: ${error}. \n You may need to manually add .flux/ to your .gitignore file.`); + } catch (error) { + console.error( + `Error during git setup: ${error}. \n You may need to manually add .flux/ to your .gitignore file.`, + ); } - console.log(`Flux Cap folder structure created at ${FLUX_FOLDER_PATH}, with cwd as ${process.cwd()}`); + console.log( + `Flux Cap folder structure created at ${FLUX_FOLDER_PATH}, with cwd as ${process.cwd()}`, + ); console.log("Flux Capacitor initialized successfully!"); } - export const resetFluxCommand = async () => { console.log("Resetting Flux Capacitor..."); - const fluxPath = await getFluxPath() + FLUX_FOLDER_PATH - - const { confirmed } = await inquirer.prompt([{ - type: 'confirm', - name: 'confirmed', - message: 'Are you sure? This will delete all your brain dumps and sessions.', - default: false - }]); + const fluxPath = (await getFluxPath()) + FLUX_FOLDER_PATH; + + const { confirmed } = await inquirer.prompt([ + { + type: "confirm", + name: "confirmed", + message: + "Are you sure? This will delete all your brain dumps and sessions.", + default: false, + }, + ]); if (!confirmed) { console.log("Reset cancelled."); @@ -122,15 +131,13 @@ export const resetFluxCommand = async () => { if (fs.existsSync(fluxPath)) { fs.rmSync(fluxPath, { recursive: true, force: true }); console.log("Removed .flux directory and all its contents."); - } - else { + } else { console.log("Flux Capacitor is not initialized in this repository."); } - } - catch (error) { + } catch (error) { console.error("Error during reset:", error); - process.exit(1) + process.exit(1); } console.log("Flux Capacitor reset successfully!"); -} +}; diff --git a/src/commands/search.command.ts b/src/commands/search.command.ts index e8c569c..57722b9 100644 --- a/src/commands/search.command.ts +++ b/src/commands/search.command.ts @@ -1,37 +1,48 @@ -import Fuse from "fuse.js" -import { displaySearchResults, FLUX_BRAIN_DUMP_PATH, getAllBrainDumpFilePaths, getConfigFile, getFluxPath, getMonthString, searchResultFormat } from "../utils"; -import { createFuseInstance } from "../utils/fuse.instance"; -import type { BrainDump } from "../types"; import fs from "fs"; +import Fuse from "fuse.js"; +import type { BrainDump } from "../types"; +import { + displaySearchResults, + FLUX_BRAIN_DUMP_PATH, + getAllBrainDumpFilePaths, + getConfigFile, + getFluxPath, + getMonthString, + searchResultFormat, +} from "../utils"; +import { createFuseInstance } from "../utils/fuse.instance"; export async function searchBrainDumpCommand(query: string[]) { console.log("Searching all brain dumps..."); - const fluxPath = await getFluxPath() + const fluxPath = await getFluxPath(); const config = await getConfigFile(fluxPath); - const combinedQuery = query.join(' ').trim(); + const combinedQuery = query.join(" ").trim(); - let searchResults: Array<{ item: BrainDump, score?: number }> = []; + const searchResults: Array<{ item: BrainDump; score?: number }> = []; const allFilePaths = await getAllBrainDumpFilePaths(fluxPath); if (combinedQuery) { for (const searchQuery of query) { for await (const filePath of allFilePaths) { - const fileData: { dumps: BrainDump[] } = JSON.parse(fs.readFileSync(filePath, 'utf8')); + const fileData: { dumps: BrainDump[] } = JSON.parse( + fs.readFileSync(filePath, "utf8"), + ); const fuse = createFuseInstance(fileData.dumps, config); const results = fuse.search(searchQuery); searchResults.push(...results); } } - } - else { + } else { for await (const filePath of allFilePaths) { - const fileData: { dumps: BrainDump[] } = JSON.parse(fs.readFileSync(filePath, 'utf8')); + const fileData: { dumps: BrainDump[] } = JSON.parse( + fs.readFileSync(filePath, "utf8"), + ); const recentDumps = fileData.dumps - .filter(dump => dump && dump.message && dump.message.trim() !== '') - .map(dump => ({ + .filter((dump) => dump && dump.message && dump.message.trim() !== "") + .map((dump) => ({ item: dump, score: 0, - timestamp: new Date(dump.timestamp).getTime() + timestamp: new Date(dump.timestamp).getTime(), })); searchResults.push(...recentDumps); } @@ -46,15 +57,14 @@ export async function searchBrainDumpCommand(query: string[]) { }); } - - const resultLimit = config?.search?.resultLimit || (combinedQuery ? 10 : 5); const limitedResults = searchResults.slice(0, resultLimit); if (searchResults.length > limitedResults.length) { - console.log(`\n(Showing ${limitedResults.length} of ${searchResults.length} results)`); + console.log( + `\n(Showing ${limitedResults.length} of ${searchResults.length} results)`, + ); } displaySearchResults(limitedResults, combinedQuery || undefined); - } diff --git a/src/index.ts b/src/index.ts index da275b4..e47e6bc 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,49 +1,64 @@ #!/usr/bin/env node import { Command } from "commander"; -import { initFluxCommand, resetFluxCommand } from "./commands/init.command"; -import { brainDumpAddCommand, handleBrainDump } from "./commands/dump.command"; -import { searchBrainDumpCommand } from "./commands/search.command"; +import packageJson from "../package.json"; import { configCommand } from "./commands/config.command"; +import { brainDumpAddCommand, handleBrainDump } from "./commands/dump.command"; import { helpOption } from "./commands/flux.option"; -import packageJson from "../package.json" +import { initFluxCommand, resetFluxCommand } from "./commands/init.command"; +import { searchBrainDumpCommand } from "./commands/search.command"; import { getFluxPath } from "./utils"; -const program = new Command() - -program.name(`flux`).description('Git-aware CLI context manager for ADHD developers').version(packageJson.version); - -program.command('init') - .option("-y, --yes", "Accept all default options for initialization") - .description('Initialize flux in the current repository') - .action(initFluxCommand) - -program.command('reset') - .description('Resets flux in the current repository') - .action(resetFluxCommand) - -program.command('dump [message...]') - .option('-m, --multiline', 'Enable multiline input mode') - .option('-n, --notes', 'Jot down a note') - .option('-i, --important', 'Jot down a link') - .option('-d, --ideas', 'Jot down an idea') - .option('-t, --tasks', 'Jot down a task') - .option('-b, --bugs', 'Jot down a bug') - .option('-l, --links', 'Jot down a link') - .option('--tag [custom]', 'Jot down a custom tagged') - .description('Add a brain dump with a message. Use --multiline for multi-line input.') - .action(async (message, options) => { - await handleBrainDump(message, options); - }) - -program.command('search [query...]') - .description('Search brain dumps with a query. If no query is provided, lists all brain dumps for the current month.') - .action((query?: string[]) => { - searchBrainDumpCommand(query ? query : [""]); - }) -// .alias("cfg") -program.command('config [data...]') - .description('Update configuration fields. Example: flux config search.limit 10') - .action(configCommand) +const program = new Command(); +program + .name(`flux`) + .description("Git-aware CLI context manager for ADHD developers") + .version(packageJson.version); + +program + .command("init") + .option("-y, --yes", "Accept all default options for initialization") + .description("Initialize flux in the current repository") + .action(initFluxCommand); + +program + .command("reset") + .description("Resets flux in the current repository") + .action(resetFluxCommand); + +program + .command("dump [message...]") + .option("-m, --multiline", "Enable multiline input mode") + .option("-n, --notes", "Jot down a note") + .option("-i, --important", "Jot down a link") + .option("-d, --ideas", "Jot down an idea") + .option("-t, --tasks", "Jot down a task") + .option("-b, --bugs", "Jot down a bug") + .option("-l, --links", "Jot down a link") + .option("--tag [custom]", "Jot down a custom tagged") + .description( + "Add a brain dump with a message. Use --multiline for multi-line input.", + ) + .action(async (message, options) => { + await handleBrainDump(message, options); + }); + +program + .command("search [query...]") + .description( + "Search brain dumps with a query. If no query is provided, lists all brain dumps for the current month.", + ) + .action((query?: string[]) => { + searchBrainDumpCommand(query ? query : [""]); + }); + + +// .alias("cfg") +program + .command("config [data...]") + .description( + "Update configuration fields. Example: flux config search.limit 10", + ) + .action(configCommand); program.parse(process.argv); diff --git a/src/types/index.ts b/src/types/index.ts index f70b292..9c33424 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -9,15 +9,15 @@ export type FluxConfig = { hideWorkingDir: boolean; hideBranchName: boolean; hideUncommittedChanges: boolean; - }, + }; search: { searchFields: ("message" | "workingDir" | "branch" | "tags" | "id")[]; resultLimit: number | null; fuseOptions?: { - threshold: number, - includeScore: boolean - } - }, + threshold: number; + includeScore: boolean; + }; + }; // ALL optional fields below this line - 24/02/26 - v0.3.0 tags?: string[]; }; @@ -28,10 +28,9 @@ export type BrainDump = { message: string; workingDir?: string; branch?: string | null; - tags?: string[], + tags?: string[]; hasUncommittedChanges?: boolean; -} - +}; export type BrainDumpOptions = { multiline?: boolean; @@ -39,4 +38,4 @@ export type BrainDumpOptions = { ideas?: boolean; tasks?: boolean; tag?: string; -} +}; diff --git a/src/utils/constants.ts b/src/utils/constants.ts index 5538852..0617021 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -1,4 +1,4 @@ -import packageJson from "../../package.json" +import packageJson from "../../package.json"; import type { FluxConfig } from "../types"; @@ -27,12 +27,12 @@ export const FLUX_DEFAULT_CONFIG: FluxConfig = { resultLimit: 10, fuseOptions: { threshold: 0.3, - includeScore: true - } + includeScore: true, + }, }, tags: ["notes", "ideas", "tasks", "bugs", "links", "imporatant"], }; export const FLUX_DEFAULT_BRAIN_DUMP_CONTENT = { fluxVersion: "0.0.1", -} +}; diff --git a/src/utils/fuse.instance.ts b/src/utils/fuse.instance.ts index 83b50de..dc188e7 100644 --- a/src/utils/fuse.instance.ts +++ b/src/utils/fuse.instance.ts @@ -1,10 +1,10 @@ -import Fuse from "fuse.js" -import type { FluxConfig } from "../types" +import Fuse from "fuse.js"; +import type { FluxConfig } from "../types"; export function createFuseInstance(data: any[], config: FluxConfig) { return new Fuse(data, { keys: config.search.searchFields, includeScore: config.search.fuseOptions?.includeScore || true, threshold: config.search.fuseOptions?.threshold || 0.5, - }) + }); } diff --git a/src/utils/helper.ts b/src/utils/helper.ts index 3f9332d..8401377 100644 --- a/src/utils/helper.ts +++ b/src/utils/helper.ts @@ -4,15 +4,24 @@ import type { BrainDump } from "../types"; export function getMonthString(): string { const currentDate = new Date(); const year = currentDate.getFullYear(); - const month = String(currentDate.getMonth() + 1).padStart(2, '0'); + const month = String(currentDate.getMonth() + 1).padStart(2, "0"); return `${year}-${month}`; } - -export function searchResultFormat({ message, timestamp, score, index }: { message: string, timestamp: string, score?: string, index?: number }): string { +export function searchResultFormat({ + message, + timestamp, + score, + index, +}: { + message: string; + timestamp: string; + score?: string; + index?: number; +}): string { const formattedTimestamp = new Date(timestamp).toLocaleString(); - const indexStr = index !== undefined ? `${index + 1}.` : ''; - const scoreStr = `[${score || '0.00'}]`; + const indexStr = index !== undefined ? `${index + 1}.` : ""; + const scoreStr = `[${score || "0.00"}]`; const timeStr = `[${formattedTimestamp}]`; const formattedMessage = formatMessageForDisplay(message); @@ -21,32 +30,45 @@ export function searchResultFormat({ message, timestamp, score, index }: { messa } function formatMessageForDisplay(message: string): string { - const lines = message.split('\n').map(line => line.trim()).filter(line => line.length > 0); + const lines = message + .split("\n") + .map((line) => line.trim()) + .filter((line) => line.length > 0); if (lines.length <= 1) { const singleLine = lines[0] || message; - return singleLine.length > 80 ? singleLine.substring(0, 77) + '...' : singleLine; + return singleLine.length > 80 + ? singleLine.substring(0, 77) + "..." + : singleLine; } const firstLine = lines[0]; - const truncatedFirst = firstLine?.length > 60 ? firstLine?.substring(0, 57) + '...' : firstLine; + const truncatedFirst = + firstLine?.length > 60 ? firstLine?.substring(0, 57) + "..." : firstLine; const remainingCount = lines.length - 1; - return `${truncatedFirst} (+${remainingCount} more line${remainingCount === 1 ? '' : 's'})`; + return `${truncatedFirst} (+${remainingCount} more line${remainingCount === 1 ? "" : "s"})`; } -export function displaySearchResults(results: Array<{ item: BrainDump, score?: number }>, query?: string) { +export function displaySearchResults( + results: Array<{ item: BrainDump; score?: number }>, + query?: string, +) { if (results.length === 0) { if (query) { console.log(`\n No brain dumps found matching "${query}"\n`); } else { - console.log("\nNo brain dumps found. Try 'flux dump' to create your first one!\n"); + console.log( + "\nNo brain dumps found. Try 'flux dump' to create your first one!\n", + ); } return; } - const queryText = query ? ` matching "${query}"` : ''; - console.log(`\n Found ${results.length} brain dump${results.length === 1 ? '' : 's'}${queryText}\n`); + const queryText = query ? ` matching "${query}"` : ""; + console.log( + `\n Found ${results.length} brain dump${results.length === 1 ? "" : "s"}${queryText}\n`, + ); const terminalWidth = process.stdout.columns || 100; const indexWidth = results.length.toString().length + 2; @@ -54,14 +76,15 @@ export function displaySearchResults(results: Array<{ item: BrainDump, score?: n const scoreWidth = 8; const timeWidth = 12; - - const header = `${'#'.padEnd(indexWidth)}${'ID'.padEnd(idWidth)}${'SCORE'.padEnd(scoreWidth)}${'TIME'.padEnd(timeWidth)}MESSAGE`; + const header = `${"#".padEnd(indexWidth)}${"ID".padEnd(idWidth)}${"SCORE".padEnd(scoreWidth)}${"TIME".padEnd(timeWidth)}MESSAGE`; console.log(`\x1b[90m${header}\x1b[0m`); - console.log(`\x1b[36m${'─'.repeat(Math.min(terminalWidth - 5, header.length))}\x1b[0m`); + console.log( + `\x1b[36m${"─".repeat(Math.min(terminalWidth - 5, header.length))}\x1b[0m`, + ); results.forEach((result, index) => { const dump = result.item; - const score = result.score?.toFixed(2) || '0.00'; + const score = result.score?.toFixed(2) || "0.00"; const shortId = dump.id.substring(0, 8); const timeAgo = getTimeAgo(new Date(dump.timestamp)); @@ -70,34 +93,39 @@ export function displaySearchResults(results: Array<{ item: BrainDump, score?: n const scoreStr = `\x1b[90m[${score}]\x1b[0m`.padEnd(scoreWidth + 9); const timeStr = `\x1b[90m${timeAgo}\x1b[0m`.padEnd(timeWidth + 9); - const lines = dump.message.split('\n').map(l => l.trim()).filter(l => l.length > 0); - const firstLine = lines[0] || '(empty)'; + const lines = dump.message + .split("\n") + .map((l) => l.trim()) + .filter((l) => l.length > 0); + const firstLine = lines[0] || "(empty)"; console.log(`\n${indexStr}${idStr}${scoreStr}${timeStr}${firstLine}`); - const messageIndent = ' '.repeat(indexWidth + idWidth + scoreWidth + timeWidth); + const messageIndent = " ".repeat( + indexWidth + idWidth + scoreWidth + timeWidth, + ); if (lines.length > 1) { - lines.slice(1).forEach(line => { + lines.slice(1).forEach((line) => { console.log(`${messageIndent}${line}`); }); } if (dump?.tags?.length) { - const tagsLine = `[${dump.tags.join(', ')}]`; + const tagsLine = `[${dump.tags.join(", ")}]`; console.log(`${messageIndent}\x1b[36m${tagsLine}\x1b[0m`); // Cyan for tags } - - if (dump.branch && dump.branch !== 'main') { - const gitInfo = `${dump.branch}${dump.hasUncommittedChanges ? ' (uncommitted)' : ''}`; + if (dump.branch && dump.branch !== "main") { + const gitInfo = `${dump.branch}${dump.hasUncommittedChanges ? " (uncommitted)" : ""}`; console.log(`${messageIndent}\x1b[33m${gitInfo}\x1b[0m`); } }); - console.log(`\n\x1b[90m Tip: Use the 8-character ID to reference dumps (e.g., flux edit ${results[0]?.item.id.substring(0, 8)})\x1b[0m\n`); + console.log( + `\n\x1b[90m Tip: Use the 8-character ID to reference dumps (e.g., flux edit ${results[0]?.item.id.substring(0, 8)})\x1b[0m\n`, + ); } - function getTimeAgo(date: Date): string { const now = new Date(); const diffMs = now.getTime() - date.getTime(); diff --git a/src/utils/index.ts b/src/utils/index.ts index afc6d81..82cb163 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -1,4 +1,4 @@ -export * from "./constants" -export * from "./privacy" -export * from "./lib" -export * from "./helper" +export * from "./constants"; +export * from "./helper"; +export * from "./lib"; +export * from "./privacy"; diff --git a/src/utils/lib.ts b/src/utils/lib.ts index b360adf..85110fa 100644 --- a/src/utils/lib.ts +++ b/src/utils/lib.ts @@ -1,18 +1,17 @@ -import type { FluxConfig } from "../types"; -import { FLUX_BRAIN_DUMP_PATH, FLUX_CONFIG_PATH } from "./constants"; -import { execSync } from 'child_process'; +import { execSync } from "child_process"; import fs from "fs"; import path from "path"; +import type { FluxConfig } from "../types"; +import { FLUX_BRAIN_DUMP_PATH, FLUX_CONFIG_PATH } from "./constants"; export async function getFluxPath() { - const cwd = process.cwd(); - let fullPath = cwd.split(path.sep); + const fullPath = cwd.split(path.sep); while (true) { - let parentPath = fullPath.join(path.sep) + "/.flux" + const parentPath = fullPath.join(path.sep) + "/.flux"; if (fs.existsSync(parentPath)) { - return parentPath.split(".flux")[0] + return parentPath.split(".flux")[0]; break; } fullPath.pop(); @@ -20,23 +19,29 @@ export async function getFluxPath() { break; } } - console.error("No .flux directory found in the current or parent directories. Please run 'flux init' to initialize."); + console.error( + "No .flux directory found in the current or parent directories. Please run 'flux init' to initialize.", + ); process.exit(1); } -export async function createIfNotExists(folderPath: string, type: 'file' | 'directory', data?: any): Promise { +export async function createIfNotExists( + folderPath: string, + type: "file" | "directory", + data?: any, +): Promise { try { const fs = await import("fs"); if (!fs.existsSync(folderPath)) { - if (type === 'file') { - fs.writeFileSync(folderPath, data || ''); + if (type === "file") { + fs.writeFileSync(folderPath, data || ""); // console.log(`Created file: ${folderPath}`); return; } fs.mkdirSync(folderPath, { recursive: true }); // console.log(`Created directory: ${folderPath}`); } else { - if (type === 'file') { + if (type === "file") { try { const stats = fs.statSync(folderPath); if (stats.size === 0 && data) { @@ -44,7 +49,7 @@ export async function createIfNotExists(folderPath: string, type: 'file' | 'dire fs.writeFileSync(folderPath, data); } } catch (writeError: any) { - if (writeError.code === 'EACCES' || writeError.code === 'EPERM') { + if (writeError.code === "EACCES" || writeError.code === "EPERM") { throw new Error(`No write permissions for file: ${folderPath}`); } throw writeError; @@ -53,8 +58,10 @@ export async function createIfNotExists(folderPath: string, type: 'file' | 'dire try { fs.accessSync(folderPath, fs.constants.W_OK); } catch (accessError: any) { - if (accessError.code === 'EACCES' || accessError.code === 'EPERM') { - throw new Error(`No write permissions for directory: ${folderPath}`); + if (accessError.code === "EACCES" || accessError.code === "EPERM") { + throw new Error( + `No write permissions for directory: ${folderPath}`, + ); } } } @@ -66,26 +73,35 @@ export async function createIfNotExists(folderPath: string, type: 'file' | 'dire } } -export async function createBrainDumpFileIfNotExists(dateString: string, fluxPath?: string) { - - await createIfNotExists(`${fluxPath}${FLUX_BRAIN_DUMP_PATH}${dateString}.json`, 'file', JSON.stringify({ - fluxVersion: "0.0.1", - month: dateString, - dumps: [] - })); +export async function createBrainDumpFileIfNotExists( + dateString: string, + fluxPath?: string, +) { + await createIfNotExists( + `${fluxPath}${FLUX_BRAIN_DUMP_PATH}${dateString}.json`, + "file", + JSON.stringify({ + fluxVersion: "0.0.1", + month: dateString, + dumps: [], + }), + ); } - export async function getConfigFile(fluxPath?: string): Promise { const fs = await import("fs"); const configPath = `${fluxPath}${FLUX_CONFIG_PATH}`; - let config: FluxConfig = JSON.parse(fs.readFileSync(configPath, 'utf8')); + const config: FluxConfig = JSON.parse(fs.readFileSync(configPath, "utf8")); return config; } -export async function getAllBrainDumpFilePaths(fluxPath?: string): Promise { +export async function getAllBrainDumpFilePaths( + fluxPath?: string, +): Promise { const fs = await import("fs"); const path = await import("path"); const files = fs.readdirSync(fluxPath + FLUX_BRAIN_DUMP_PATH); - return files.filter(file => file.endsWith(".json")).map(file => path.join(fluxPath + FLUX_BRAIN_DUMP_PATH, file)); + return files + .filter((file) => file.endsWith(".json")) + .map((file) => path.join(fluxPath + FLUX_BRAIN_DUMP_PATH, file)); } diff --git a/src/utils/privacy.ts b/src/utils/privacy.ts index 5fdc180..ecb4f95 100644 --- a/src/utils/privacy.ts +++ b/src/utils/privacy.ts @@ -1,14 +1,16 @@ +import { execSync } from "child_process"; import type { BrainDumpOptions, FluxConfig } from "../types"; -import { execSync } from 'child_process'; export function getGitUncommittedChanges(config: FluxConfig): boolean { if (config.privacy.hideUncommittedChanges) { - return false + return false; } try { - const status = execSync('git status --porcelain', - { encoding: 'utf8', cwd: process.cwd(), timeout: 1000 } - ).trim(); + const status = execSync("git status --porcelain", { + encoding: "utf8", + cwd: process.cwd(), + timeout: 1000, + }).trim(); return status.length > 0; } catch (error) { return false; @@ -16,18 +18,19 @@ export function getGitUncommittedChanges(config: FluxConfig): boolean { } export async function getWorkingDir(config: FluxConfig): Promise { - return config.privacy.hideWorkingDir ? "" : process.cwd(); } export function getCurrentBranch(config: FluxConfig): string | null { if (config.privacy.hideBranchName) { - return "" + return ""; } try { - const branch = execSync('git rev-parse --abbrev-ref HEAD', - { encoding: 'utf8', cwd: process.cwd(), timeout: 1000 } - ).trim(); + const branch = execSync("git rev-parse --abbrev-ref HEAD", { + encoding: "utf8", + cwd: process.cwd(), + timeout: 1000, + }).trim(); return branch; } catch (error) { return ""; @@ -35,17 +38,19 @@ export function getCurrentBranch(config: FluxConfig): string | null { } export function getTags(options: BrainDumpOptions, config: FluxConfig) { - - let tags: string[] = []; + const tags: string[] = []; if (options.tag) { tags.push(options.tag); } - let optionTags = Object.keys(options).filter(key => options[key as keyof BrainDumpOptions] === true); + const optionTags = Object.keys(options).filter( + (key) => options[key as keyof BrainDumpOptions] === true, + ); if (!config.tags) { - console.log("You do not have any tags configured. You can add tags to your config to use this feature. or run `flux config --add-tags notes ideas tasks` to add default tags. or update the config file"); + console.log( + "You do not have any tags configured. You can add tags to your config to use this feature. or run `flux config --add-tags notes ideas tasks` to add default tags. or update the config file", + ); } else { - for (const tag of optionTags) { if (config.tags && config.tags.includes(tag)) { tags.push(tag); @@ -54,6 +59,4 @@ export function getTags(options: BrainDumpOptions, config: FluxConfig) { } return tags; - - } diff --git a/tsconfig.json b/tsconfig.json index bfa0fea..146fe4e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,29 +1,29 @@ { - "compilerOptions": { - // Environment setup & latest features - "lib": ["ESNext"], - "target": "ESNext", - "module": "Preserve", - "moduleDetection": "force", - "jsx": "react-jsx", - "allowJs": true, + "compilerOptions": { + // Environment setup & latest features + "lib": ["ESNext"], + "target": "ESNext", + "module": "Preserve", + "moduleDetection": "force", + "jsx": "react-jsx", + "allowJs": true, - // Bundler mode - "moduleResolution": "bundler", - "allowImportingTsExtensions": true, - "verbatimModuleSyntax": true, - "noEmit": true, + // Bundler mode + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "verbatimModuleSyntax": true, + "noEmit": true, - // Best practices - "strict": true, - "skipLibCheck": true, - "noFallthroughCasesInSwitch": true, - "noUncheckedIndexedAccess": true, - "noImplicitOverride": true, + // Best practices + "strict": true, + "skipLibCheck": true, + "noFallthroughCasesInSwitch": true, + "noUncheckedIndexedAccess": true, + "noImplicitOverride": true, - // Some stricter flags (disabled by default) - "noUnusedLocals": false, - "noUnusedParameters": false, - "noPropertyAccessFromIndexSignature": false - } + // Some stricter flags (disabled by default) + "noUnusedLocals": false, + "noUnusedParameters": false, + "noPropertyAccessFromIndexSignature": false + } }