UNPKG

tfd-test

Version:

Developer task manager. No more TODO or FIXME comments. A simple wrapper function to create tasks.

136 lines (132 loc) 4.68 kB
"use strict"; var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/index.ts var src_exports = {}; __export(src_exports, { TaskListDisplay: () => TaskDisplay_default, logTask: () => logTask }); module.exports = __toCommonJS(src_exports); // src/functions.ts var import_fs = require("fs"); var import_path = __toESM(require("path")); var filePath = import_path.default.join(process.cwd(), "tasks.json"); async function readTasksFromFile(filePath2) { try { const data = await import_fs.promises.readFile(filePath2, "utf8"); return JSON.parse(data); } catch (error) { if (error.code === "ENOENT") { await import_fs.promises.writeFile(filePath2, JSON.stringify([]), "utf8"); return []; } else { console.error("Error reading tasks file:", error); throw error; } } } async function writeTasksToFile(filePath2, tasks) { try { const data = JSON.stringify(tasks, null, 2); await import_fs.promises.writeFile(filePath2, data, "utf8"); } catch (error) { console.error("Error writing tasks file:", error); } } function parseStackTrace(stackLine) { const match = /at (.+):(\d+):(\d+)/.exec(stackLine || ""); return { file: match ? match[1] : "unknown", line: match ? parseInt(match[2], 10) : -1 }; } async function logTask(details) { const error = new Error(); const stackLine = error.stack?.split("\n")[2]; const { file, line } = parseStackTrace(stackLine); const extendedDetails = { ...details, file, line }; const tasks = await readTasksFromFile(filePath); tasks.push(extendedDetails); await writeTasksToFile(filePath, tasks); } // src/components/TaskDisplay.tsx var import_react = __toESM(require("react")); var TaskListDisplay = ({ tasks }) => { return /* @__PURE__ */ import_react.default.createElement("aside", { style: asideStyle }, /* @__PURE__ */ import_react.default.createElement("h2", { style: headingStyle }, "Tasks"), /* @__PURE__ */ import_react.default.createElement("hr", { style: separatorStyle }), /* @__PURE__ */ import_react.default.createElement("ul", { style: listStyle }, tasks.map((task, index) => /* @__PURE__ */ import_react.default.createElement("li", { key: index }, task.description)))); }; var asideStyle = { backgroundColor: "white", // White background borderRadius: "8px", // Medium-rounded corners border: "1px solid #ddd", // Greyish border boxShadow: "0 2px 4px rgba(0,0,0,0.1)", // Slight shadow position: "fixed", // Fixed positioning bottom: "20px", // Positioned 20px from the bottom right: "20px", // Positioned 20px from the right width: "250px", // Width of the component height: "400px", // Height based on content padding: "10px", // Padding inside the component overflowY: "hidden" // Scrollable if content is too long }; var headingStyle = { textAlign: "center", // Center align text fontWeight: "bold", // Bold text fontSize: "16px" // Larger font size }; var separatorStyle = { border: "0", borderTop: "1px solid #ccc", margin: "10px 0", width: "100%" }; var listStyle = { maxHeight: "100%", // Max height to fit the container overflowY: "auto" // Scrollable list }; var TaskDisplay_default = TaskListDisplay; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { TaskListDisplay, logTask });