claudes-office
Version:
CLI tool to initialize Claude's office in your project
168 lines • 6.7 kB
JavaScript
;
/**
* Update notifier utility for the update command
* Appends update information to the user's CLAUDE.md file
*/
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.appendUpdateNotification = appendUpdateNotification;
exports.getVersionNotification = getVersionNotification;
const fs = __importStar(require("fs-extra"));
/**
* Append update information to user's CLAUDE.md file
*
* @param claudeMdPath - Path to the user's CLAUDE.md file
* @param notification - Update notification to append
* @returns Whether the notification was successfully appended
*/
async function appendUpdateNotification(claudeMdPath, notification) {
try {
// Check if CLAUDE.md exists
if (!await fs.pathExists(claudeMdPath)) {
console.error(`CLAUDE.md not found at ${claudeMdPath}`);
return false;
}
// Format the notification
const updateText = formatUpdateNotification(notification);
// Read existing content
const existingContent = await fs.readFile(claudeMdPath, 'utf8');
// Check if notification already exists (based on version)
if (existingContent.includes(`# Update Notification - Version ${notification.version}`)) {
// Notification already exists, don't append again
return false;
}
// Append the notification
const newContent = `${existingContent}\n\n${updateText}`;
// Write back to file
await fs.writeFile(claudeMdPath, newContent, 'utf8');
return true;
}
catch (error) {
console.error('Error appending update notification:', error.message);
return false;
}
}
/**
* Format update notification as markdown
*
* @param notification - Update notification to format
* @returns Formatted markdown string
*/
function formatUpdateNotification(notification) {
const { version, newFeatures = [], breakingChanges = [], otherChanges = [], } = notification;
const markdown = [
'<!-- --------------------------------------------- -->',
`# Update Notification - Version ${version}`,
'',
'> **Note:** The claudes-office package has been updated to a new version.',
'> Please review the changes below and delete this section once you have',
'> incorporated these changes into your workflow.',
''
];
if (newFeatures.length > 0) {
markdown.push('## New Features');
markdown.push('');
newFeatures.forEach(feature => {
markdown.push(`- ${feature}`);
});
markdown.push('');
}
if (breakingChanges.length > 0) {
markdown.push('## Breaking Changes');
markdown.push('');
breakingChanges.forEach(change => {
markdown.push(`- ⚠️ ${change}`);
});
markdown.push('');
}
if (otherChanges.length > 0) {
markdown.push('## Other Changes');
markdown.push('');
otherChanges.forEach(change => {
markdown.push(`- ${change}`);
});
markdown.push('');
}
markdown.push('<!-- Delete this section after reading -->');
markdown.push('<!-- --------------------------------------------- -->');
return markdown.join('\n');
}
/**
* Get notification for a specific version
*
* @param version - Version to get notification for
* @returns Update notification for the specified version
*/
function getVersionNotification(version) {
// Define notifications for each version
const notifications = {
'0.4.0': {
version: '0.4.0',
newFeatures: [
'TypeScript Migration: The codebase has been migrated to TypeScript for improved type safety and developer experience.',
'Update Notifications: Update information is now appended to your CLAUDE.md file after updates.',
'Backup System: The update command now creates backups before making changes.',
'File Comparison: Improved file comparison utilities for the update command.'
],
breakingChanges: [],
otherChanges: [
'Code quality improvements across the codebase.',
'Enhanced error handling and detailed logging.',
'Better type definitions for all commands and options.'
]
},
'0.5.0': {
version: '0.5.0',
newFeatures: [
'Meeting Generation: AI-powered meeting generation with support for different meeting types.',
'Multi-Project Support: Automatically detect and configure for various tech stacks.',
'Complete TypeScript Refinement: Enhanced type safety throughout the codebase.'
],
breakingChanges: [],
otherChanges: [
'Improved update command with better conflict resolution.',
'Enhanced meeting templates for various scenarios.'
]
}
};
// Return notification for the specified version, or a generic one if not found
return notifications[version] || {
version,
newFeatures: ['This version includes various improvements and bug fixes.'],
breakingChanges: [],
otherChanges: []
};
}
//# sourceMappingURL=updateNotifier.js.map