Skip to content

Add CLI to add/edit/view/delete items#26

Open
willfeldman wants to merge 2 commits intomainfrom
easy-add
Open

Add CLI to add/edit/view/delete items#26
willfeldman wants to merge 2 commits intomainfrom
easy-add

Conversation

@willfeldman
Copy link
Copy Markdown
Owner

This pull request introduces a new data management CLI for portfolio static data and documents its features and usage. The most significant changes are the addition of several new npm scripts to run the CLI and the inclusion of a comprehensive README describing the CLI's capabilities, usage, and technical details.

CLI Integration and Documentation:

  • Added new npm scripts to package.json for running, viewing, and validating data via the CLI (data, data:view, data:validate).
  • Added a detailed scripts/README.md that documents the Portfolio Data Manager CLI, including quick start instructions, feature overview, supported data types, usage examples, validation rules, best practices, troubleshooting, and future enhancements.

Adds advanced browsing, detailed entry viewing, and field-level editing for all data types. Introduces HTML formatting for rich text fields, external editor integration, and improved array and tag management. Updates the main menu UI and refactors editing workflows for a more user-friendly experience.
@vercel
Copy link
Copy Markdown

vercel Bot commented Aug 8, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
portfolio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 8, 2025 8:53pm

@netlify
Copy link
Copy Markdown

netlify Bot commented Aug 8, 2025

Deploy Preview for venerable-sherbet-c490a5 failed.

Name Link
🔨 Latest commit e15ea8e
🔍 Latest deploy log https://app.netlify.com/projects/venerable-sherbet-c490a5/deploys/689663dba287360008740956

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request introduces a comprehensive Portfolio Data Manager CLI that provides an interactive interface for managing portfolio static data files including experiences, projects, organizations, and awards. The CLI offers full CRUD operations, data validation, export capabilities, and detailed viewing options while maintaining data integrity and safety through confirmation prompts and automatic validation.

  • Adds a complete data management CLI with interactive menus for browsing, adding, editing, and deleting portfolio entries
  • Implements comprehensive data validation with schema checking, duplicate ID detection, and field validation
  • Provides export functionality for JSON and CSV formats with timestamped backups

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.

File Description
scripts/data-manager.js Main CLI application implementing the complete data management interface with validation, CRUD operations, and export features
scripts/README.md Comprehensive documentation covering CLI features, usage examples, validation rules, best practices, and troubleshooting
package.json Adds three new npm scripts for running the CLI in different modes (interactive, view-only, validate-only)

Comment thread scripts/data-manager.js
optional: ['github', 'url', 'code', 'tags', 'images', 'additionalInformation'],
nested: {
tags: {
required: ['name', 'color', 'background'],
Copy link

Copilot AI Aug 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tags schema requires 'name', 'color', and 'background' fields, but the processTags method at line 798 only sets default values for 'color' and 'background'. This creates inconsistency where manually created tags might not match the schema requirements.

Copilot uses AI. Check for mistakes.
Comment thread scripts/data-manager.js
loadAllData() {
for (const [type, filePath] of Object.entries(DATA_FILES)) {
try {
delete require.cache[require.resolve(path.resolve(filePath))];
Copy link

Copilot AI Aug 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The require.cache deletion could fail if the file doesn't exist or has never been required before, causing an error. The deletion should be wrapped in a try-catch or check if the resolved path exists in the cache first.

Copilot uses AI. Check for mistakes.
Comment thread scripts/data-manager.js

// Get next ID
const existingIds = this.currentData[type].map(item => item.id);
const nextId = existingIds.length > 0 ? Math.max(...existingIds) + 1 : 0;
Copy link

Copilot AI Aug 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using Math.max(...existingIds) will throw an error if existingIds contains non-numeric values. The code should validate that all IDs are numbers or handle mixed types appropriately.

Suggested change
const nextId = existingIds.length > 0 ? Math.max(...existingIds) + 1 : 0;
const numericIds = existingIds.filter(id => typeof id === 'number' && !isNaN(id));
const nextId = numericIds.length > 0 ? Math.max(...numericIds) + 1 : 0;

Copilot uses AI. Check for mistakes.
Comment thread scripts/data-manager.js
console.log(`\nOpening ${tempFile} in external editor...`);
console.log('Save and close the file when done editing.');

const editor = process.env.EDITOR || 'nano';
Copy link

Copilot AI Aug 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fallback to 'nano' may not work on all systems (e.g., Windows). Consider using a cross-platform approach or checking for available editors like 'notepad' on Windows.

Suggested change
const editor = process.env.EDITOR || 'nano';
let editor = process.env.EDITOR;
if (!editor) {
if (process.platform === 'win32') {
editor = 'notepad';
} else {
editor = 'nano';
}
}

Copilot uses AI. Check for mistakes.
Comment thread scripts/data-manager.js
// Special handling for projects to include projectTags
if (type === 'projects') {
// Read existing file to preserve projectTags
const existingContent = fs.readFileSync(filePath, 'utf8');
Copy link

Copilot AI Aug 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reading the file synchronously without error handling could cause the application to crash if the file doesn't exist or is inaccessible. This should be wrapped in a try-catch block.

Suggested change
const existingContent = fs.readFileSync(filePath, 'utf8');
let existingContent = '';
try {
existingContent = fs.readFileSync(filePath, 'utf8');
} catch (error) {
// If the file doesn't exist or can't be read, skip preserving projectTags
existingContent = '';
}

Copilot uses AI. Check for mistakes.
Comment thread scripts/data-manager.js

// Type-specific validations
if (type === 'experiences' && item.url && Array.isArray(item.url)) {
item.url.forEach((url, urlIndex) => {
Copy link

Copilot AI Aug 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code assumes item.url is an array when it's checked with Array.isArray(item.url), but then directly calls forEach without verifying the array isn't empty or that each element exists.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants