UNPKG

metacoding

Version:

Guided Development Workflow for GitHub Copilot - Transform your coding experience with AI-guided standards, structured workflows, and quality practices

146 lines (139 loc) 4.35 kB
"use strict"; 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.GitIgnoreManager = void 0; const fs = __importStar(require("fs-extra")); const path = __importStar(require("path")); class GitIgnoreManager { static getAIAssistantPatterns() { return [ '# metacoding: AI coding assistant exclusions', '.github/copilot-instructions.md', '.github/instructions/', '.vscode/copilot-instructions.md', '.idea/copilot-instructions.md', ]; } async updateGitIgnore(projectPath) { const gitignorePath = path.join(projectPath, '.gitignore'); const patterns = GitIgnoreManager.getAIAssistantPatterns(); try { let existingContent = ''; let hasExistingFile = false; if (await fs.pathExists(gitignorePath)) { existingContent = await fs.readFile(gitignorePath, 'utf8'); hasExistingFile = true; } const hasMetacodingSection = existingContent.includes('# metacoding:'); if (hasMetacodingSection) { return; } let contentToAppend = ''; if (hasExistingFile && existingContent.length > 0 && !existingContent.endsWith('\n')) { contentToAppend = '\n\n'; } else if (hasExistingFile && existingContent.length > 0) { contentToAppend = '\n'; } contentToAppend += patterns.join('\n') + '\n'; if (hasExistingFile) { await fs.appendFile(gitignorePath, contentToAppend); } else { await fs.writeFile(gitignorePath, contentToAppend); } } catch (error) { throw new Error(`Failed to update .gitignore: ${error instanceof Error ? error.message : 'Unknown error'}`); } } async hasMetacodingPatterns(projectPath) { const gitignorePath = path.join(projectPath, '.gitignore'); try { if (!(await fs.pathExists(gitignorePath))) { return false; } const content = await fs.readFile(gitignorePath, 'utf8'); return content.includes('# metacoding:'); } catch { return false; } } static createTemplateContent() { const patterns = GitIgnoreManager.getAIAssistantPatterns(); return `# Dependencies node_modules/ *.tgz # Build outputs lib/ dist/ build/ coverage/ # Environment files .env .env.local .env.*.local # IDE and Editor files .vscode/ .idea/ *.swp *.swo *~ # OS generated files .DS_Store .DS_Store? ._* .Spotlight-V100 .Trashes ehthumbs.db Thumbs.db # Logs *.log npm-debug.log* yarn-debug.log* yarn-error.log* # Temporary files tmp/ temp/ tmp-* ${patterns.join('\n')} `; } } exports.GitIgnoreManager = GitIgnoreManager; //# sourceMappingURL=gitignore-manager.js.map