updates for PR creation
This commit is contained in:
		
							parent
							
								
									bb26d9a80d
								
							
						
					
					
						commit
						f21d5b33e3
					
				
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							@ -11,8 +11,8 @@
 | 
			
		||||
  },
 | 
			
		||||
  "dependencies": {
 | 
			
		||||
    "@astrojs/node": "^9.3.0",
 | 
			
		||||
    "astro": "^5.12.0",
 | 
			
		||||
    "cookie": "^0.6.0",
 | 
			
		||||
    "astro": "^5.12.3",
 | 
			
		||||
    "cookie": "^1.0.2",
 | 
			
		||||
    "dotenv": "^16.4.5",
 | 
			
		||||
    "jose": "^5.2.0",
 | 
			
		||||
    "js-yaml": "^4.1.0",
 | 
			
		||||
@ -20,7 +20,6 @@
 | 
			
		||||
    "zod": "^3.25.76"
 | 
			
		||||
  },
 | 
			
		||||
  "devDependencies": {
 | 
			
		||||
    "@types/cookie": "^0.6.0",
 | 
			
		||||
    "@types/js-yaml": "^4.0.9"
 | 
			
		||||
  },
 | 
			
		||||
  "engines": {
 | 
			
		||||
 | 
			
		||||
@ -153,17 +153,11 @@ const title = isEdit ? `Edit ${editTool?.name}` : 'Beitrag erstellen';
 | 
			
		||||
              </label>
 | 
			
		||||
              <select id="tool-phases" name="phases" multiple size="4">
 | 
			
		||||
                {phases.map(phase => (
 | 
			
		||||
                  <option value={phase.id} 
 | 
			
		||||
                  <option value={phase.id}
 | 
			
		||||
                          selected={editTool?.phases?.includes(phase.id)}>
 | 
			
		||||
                    {phase.name}
 | 
			
		||||
                  </option>
 | 
			
		||||
                ))}
 | 
			
		||||
                {domainAgnosticSoftware.map(section => (
 | 
			
		||||
                  <option value={section.id} 
 | 
			
		||||
                          selected={editTool?.phases?.includes(section.id)}>
 | 
			
		||||
                    {section.name}
 | 
			
		||||
                  </option>
 | 
			
		||||
                ))}
 | 
			
		||||
              </select>
 | 
			
		||||
              <div class="field-help">Zutreffende auswählen</div>
 | 
			
		||||
            </div>
 | 
			
		||||
@ -231,6 +225,22 @@ const title = isEdit ? `Edit ${editTool?.name}` : 'Beitrag erstellen';
 | 
			
		||||
                  <option value="service" selected={editTool?.accessType === 'service'}>Service</option>
 | 
			
		||||
                </select>
 | 
			
		||||
              </div>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
              <!-- Domain-Agnostic Categories -->
 | 
			
		||||
              <div style="grid-column: 1 / -1;" id="domain-agnostic-field">
 | 
			
		||||
                <label style="display: block; margin-bottom: 0.5rem; font-weight: 600;">
 | 
			
		||||
                  Domain-Agnostic Categories
 | 
			
		||||
                </label>
 | 
			
		||||
                <div id="domain-agnostic-checkboxes" style="display: grid; gap: 0.25rem; font-size: 0.875rem;">
 | 
			
		||||
                  {domainAgnosticSoftware.map(cat => (
 | 
			
		||||
                    <label class="checkbox-wrapper" style="margin-bottom: 0.25rem;">
 | 
			
		||||
                      <input type="checkbox" name="domainAgnostic" value={cat.id} checked={editTool?.['domain-agnostic-software']?.includes(cat.id)} />
 | 
			
		||||
                      <span>{cat.name}</span>
 | 
			
		||||
                    </label>
 | 
			
		||||
                  ))}
 | 
			
		||||
                </div>
 | 
			
		||||
              </div>
 | 
			
		||||
            </div>
 | 
			
		||||
          </div>
 | 
			
		||||
 | 
			
		||||
@ -423,7 +433,7 @@ document.addEventListener('DOMContentLoaded', () => {
 | 
			
		||||
  
 | 
			
		||||
  // Field groups
 | 
			
		||||
  const softwareFields = document.getElementById('software-fields');
 | 
			
		||||
  const projectUrlField = document.getElementById('project-url-field');
 | 
			
		||||
  const domainAgnosticField = document.getElementById('domain-agnostic-field');
 | 
			
		||||
  const relatedConceptsField = document.getElementById('related-concepts-field');
 | 
			
		||||
  
 | 
			
		||||
  // Required indicators
 | 
			
		||||
@ -459,10 +469,6 @@ document.addEventListener('DOMContentLoaded', () => {
 | 
			
		||||
    if (softwareFields) softwareFields.style.display = 'none';
 | 
			
		||||
    if (relatedConceptsField) relatedConceptsField.style.display = 'none';
 | 
			
		||||
    
 | 
			
		||||
    // Show project URL for software only
 | 
			
		||||
    if (projectUrlField) {
 | 
			
		||||
      projectUrlField.style.display = selectedType === 'software' ? 'block' : 'none';
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    // Handle required fields
 | 
			
		||||
    const platformsCheckboxes = document.querySelectorAll('input[name="platforms"]');
 | 
			
		||||
@ -476,8 +482,13 @@ document.addEventListener('DOMContentLoaded', () => {
 | 
			
		||||
      // Make platforms and license required
 | 
			
		||||
      if (platformsRequired) platformsRequired.style.display = 'inline';
 | 
			
		||||
      if (licenseRequired) licenseRequired.style.display = 'inline';
 | 
			
		||||
      platformsCheckboxes.forEach(cb => cb.setAttribute('required', 'required'));
 | 
			
		||||
      if (platformsCheckboxes.length > 0) {
 | 
			
		||||
        platformsCheckboxes.forEach(cb => cb.removeAttribute('required'));
 | 
			
		||||
        platformsCheckboxes[0].setAttribute('required', 'required');
 | 
			
		||||
      }
 | 
			
		||||
      if (licenseSelect) licenseSelect.setAttribute('required', 'required');
 | 
			
		||||
 | 
			
		||||
      if (domainAgnosticField) domainAgnosticField.style.display = 'block';
 | 
			
		||||
      
 | 
			
		||||
    } else {
 | 
			
		||||
      // Hide required indicators and remove requirements
 | 
			
		||||
@ -485,7 +496,9 @@ document.addEventListener('DOMContentLoaded', () => {
 | 
			
		||||
      if (licenseRequired) licenseRequired.style.display = 'none';
 | 
			
		||||
      platformsCheckboxes.forEach(cb => cb.removeAttribute('required'));
 | 
			
		||||
      if (licenseSelect) licenseSelect.removeAttribute('required');
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      if (domainAgnosticField) domainAgnosticField.style.display = 'none';
 | 
			
		||||
 | 
			
		||||
      // Show related concepts for methods
 | 
			
		||||
      if (selectedType === 'method' && relatedConceptsField) {
 | 
			
		||||
        relatedConceptsField.style.display = 'block';
 | 
			
		||||
@ -520,7 +533,7 @@ document.addEventListener('DOMContentLoaded', () => {
 | 
			
		||||
        toolData.platforms = formData.getAll('platforms') || [];
 | 
			
		||||
        toolData.license = formData.get('license')?.trim() || null;
 | 
			
		||||
        toolData.accessType = formData.get('accessType') || null;
 | 
			
		||||
        toolData.projectUrl = formData.get('projectUrl') || null;
 | 
			
		||||
        toolData['domain-agnostic-software'] = formData.getAll('domainAgnostic') || [];
 | 
			
		||||
      } else {
 | 
			
		||||
        toolData.platforms = [];
 | 
			
		||||
        toolData.license = null;
 | 
			
		||||
@ -551,8 +564,8 @@ skillLevel: ${toolData.skillLevel}
 | 
			
		||||
url: "${toolData.url}"${toolData.platforms.length > 0 ? `
 | 
			
		||||
platforms: [${toolData.platforms.map(p => `"${p}"`).join(', ')}]` : ''}${toolData.license ? `
 | 
			
		||||
license: "${toolData.license}"` : ''}${toolData.accessType ? `
 | 
			
		||||
accessType: ${toolData.accessType}` : ''}${toolData.projectUrl ? `
 | 
			
		||||
projectUrl: "${toolData.projectUrl}"` : ''}${toolData.knowledgebase ? `
 | 
			
		||||
accessType: ${toolData.accessType}` : ''}${toolData['domain-agnostic-software'] && toolData['domain-agnostic-software'].length > 0 ? `
 | 
			
		||||
domain-agnostic-software: [${toolData['domain-agnostic-software'].map(c => `"${c}"`).join(', ')}]` : ''}${toolData.knowledgebase ? `
 | 
			
		||||
knowledgebase: true` : ''}${toolData.tags.length > 0 ? `
 | 
			
		||||
tags: [${toolData.tags.map(t => `"${t}"`).join(', ')}]` : ''}${toolData.related_concepts ? `
 | 
			
		||||
related_concepts: [${toolData.related_concepts.map(c => `"${c}"`).join(', ')}]` : ''}`;
 | 
			
		||||
@ -660,7 +673,8 @@ related_concepts: [${toolData.related_concepts.map(c => `"${c}"`).join(', ')}]`
 | 
			
		||||
          submissionData.tool.platforms = formData.getAll('platforms');
 | 
			
		||||
          submissionData.tool.license = formData.get('license')?.trim() || null;
 | 
			
		||||
          submissionData.tool.accessType = formData.get('accessType') || null;
 | 
			
		||||
          submissionData.tool.projectUrl = formData.get('projectUrl')?.trim() || null;
 | 
			
		||||
          const da = formData.getAll('domainAgnostic');
 | 
			
		||||
          if (da.length > 0) submissionData.tool['domain-agnostic-software'] = da;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Add optional fields
 | 
			
		||||
 | 
			
		||||
@ -320,47 +320,40 @@ private generateToolYAML(tool: any): string {
 | 
			
		||||
 | 
			
		||||
async submitContribution(data: ContributionData): Promise<GitOperationResult> {
 | 
			
		||||
  const branchName = `tool-${data.type}-${Date.now()}`;
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  try {
 | 
			
		||||
    // Create branch
 | 
			
		||||
    await this.createBranch(branchName);
 | 
			
		||||
    
 | 
			
		||||
    // FIXED: Don't modify tools.yaml at all - just create the tool data file
 | 
			
		||||
    const toolYaml = this.generateToolYAML(data.tool);
 | 
			
		||||
    const contributionFileName = `contribution-${data.type}-${data.tool.name.toLowerCase().replace(/[^a-z0-9]/g, '-')}.yaml`;
 | 
			
		||||
    
 | 
			
		||||
    // Create contributions directory if it doesn't exist and write the tool data
 | 
			
		||||
    try {
 | 
			
		||||
      await this.readFile('contributions/.gitkeep');
 | 
			
		||||
    } catch {
 | 
			
		||||
      // Directory doesn't exist, create it
 | 
			
		||||
      await this.writeFile('contributions/.gitkeep', '# Contribution files directory\n');
 | 
			
		||||
 | 
			
		||||
    const toolsPath = 'src/data/tools.yaml';
 | 
			
		||||
    const originalYaml = await this.readFile(toolsPath);
 | 
			
		||||
    const yamlData: any = load(originalYaml);
 | 
			
		||||
 | 
			
		||||
    if (!yamlData.tools || !Array.isArray(yamlData.tools)) {
 | 
			
		||||
      throw new Error('Invalid tools.yaml format');
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    // Write the tool data as a separate file for maintainers to review
 | 
			
		||||
    await this.writeFile(`contributions/${contributionFileName}`, toolYaml);
 | 
			
		||||
    
 | 
			
		||||
    // Commit changes
 | 
			
		||||
    const commitMessage = `${data.type === 'add' ? 'Add' : 'Update'} tool: ${data.tool.name}
 | 
			
		||||
 | 
			
		||||
Contributed by: ${data.metadata.submitter}
 | 
			
		||||
Type: ${data.tool.type}
 | 
			
		||||
${data.metadata.reason ? `Reason: ${data.metadata.reason}` : ''}
 | 
			
		||||
    if (data.type === 'edit') {
 | 
			
		||||
      yamlData.tools = yamlData.tools.filter((t: any) => (t.name || '').toLowerCase() !== data.tool.name.toLowerCase());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    yamlData.tools.push(data.tool);
 | 
			
		||||
 | 
			
		||||
    const newYaml = dump(yamlData, { lineWidth: -1, noRefs: true, quotingType: '"', forceQuotes: false, indent: 2 });
 | 
			
		||||
 | 
			
		||||
    await this.writeFile(toolsPath, newYaml);
 | 
			
		||||
 | 
			
		||||
    const commitMessage = `${data.type === 'add' ? 'Add' : 'Update'} tool: ${data.tool.name}`;
 | 
			
		||||
 | 
			
		||||
This contribution contains the raw tool data for manual review and integration.`;
 | 
			
		||||
    
 | 
			
		||||
    await this.commitChanges(commitMessage);
 | 
			
		||||
    
 | 
			
		||||
    // Push branch
 | 
			
		||||
 | 
			
		||||
    await this.pushBranch(branchName);
 | 
			
		||||
    
 | 
			
		||||
    // Create pull request with enhanced description
 | 
			
		||||
 | 
			
		||||
    const prUrl = await this.createPullRequest(
 | 
			
		||||
      branchName,
 | 
			
		||||
      `${data.type === 'add' ? 'Add' : 'Update'} tool: ${data.tool.name}`,
 | 
			
		||||
      this.generateEnhancedPRDescription(data, toolYaml)
 | 
			
		||||
      `Automated contribution for ${data.tool.name}`
 | 
			
		||||
    );
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    return {
 | 
			
		||||
      success: true,
 | 
			
		||||
      message: `Tool contribution submitted successfully`,
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user