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": {
|
"dependencies": {
|
||||||
"@astrojs/node": "^9.3.0",
|
"@astrojs/node": "^9.3.0",
|
||||||
"astro": "^5.12.0",
|
"astro": "^5.12.3",
|
||||||
"cookie": "^0.6.0",
|
"cookie": "^1.0.2",
|
||||||
"dotenv": "^16.4.5",
|
"dotenv": "^16.4.5",
|
||||||
"jose": "^5.2.0",
|
"jose": "^5.2.0",
|
||||||
"js-yaml": "^4.1.0",
|
"js-yaml": "^4.1.0",
|
||||||
@ -20,7 +20,6 @@
|
|||||||
"zod": "^3.25.76"
|
"zod": "^3.25.76"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/cookie": "^0.6.0",
|
|
||||||
"@types/js-yaml": "^4.0.9"
|
"@types/js-yaml": "^4.0.9"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
|
@ -153,17 +153,11 @@ const title = isEdit ? `Edit ${editTool?.name}` : 'Beitrag erstellen';
|
|||||||
</label>
|
</label>
|
||||||
<select id="tool-phases" name="phases" multiple size="4">
|
<select id="tool-phases" name="phases" multiple size="4">
|
||||||
{phases.map(phase => (
|
{phases.map(phase => (
|
||||||
<option value={phase.id}
|
<option value={phase.id}
|
||||||
selected={editTool?.phases?.includes(phase.id)}>
|
selected={editTool?.phases?.includes(phase.id)}>
|
||||||
{phase.name}
|
{phase.name}
|
||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
{domainAgnosticSoftware.map(section => (
|
|
||||||
<option value={section.id}
|
|
||||||
selected={editTool?.phases?.includes(section.id)}>
|
|
||||||
{section.name}
|
|
||||||
</option>
|
|
||||||
))}
|
|
||||||
</select>
|
</select>
|
||||||
<div class="field-help">Zutreffende auswählen</div>
|
<div class="field-help">Zutreffende auswählen</div>
|
||||||
</div>
|
</div>
|
||||||
@ -231,6 +225,22 @@ const title = isEdit ? `Edit ${editTool?.name}` : 'Beitrag erstellen';
|
|||||||
<option value="service" selected={editTool?.accessType === 'service'}>Service</option>
|
<option value="service" selected={editTool?.accessType === 'service'}>Service</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</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>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -423,7 +433,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
|
|
||||||
// Field groups
|
// Field groups
|
||||||
const softwareFields = document.getElementById('software-fields');
|
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');
|
const relatedConceptsField = document.getElementById('related-concepts-field');
|
||||||
|
|
||||||
// Required indicators
|
// Required indicators
|
||||||
@ -459,10 +469,6 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
if (softwareFields) softwareFields.style.display = 'none';
|
if (softwareFields) softwareFields.style.display = 'none';
|
||||||
if (relatedConceptsField) relatedConceptsField.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
|
// Handle required fields
|
||||||
const platformsCheckboxes = document.querySelectorAll('input[name="platforms"]');
|
const platformsCheckboxes = document.querySelectorAll('input[name="platforms"]');
|
||||||
@ -476,8 +482,13 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
// Make platforms and license required
|
// Make platforms and license required
|
||||||
if (platformsRequired) platformsRequired.style.display = 'inline';
|
if (platformsRequired) platformsRequired.style.display = 'inline';
|
||||||
if (licenseRequired) licenseRequired.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 (licenseSelect) licenseSelect.setAttribute('required', 'required');
|
||||||
|
|
||||||
|
if (domainAgnosticField) domainAgnosticField.style.display = 'block';
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Hide required indicators and remove requirements
|
// Hide required indicators and remove requirements
|
||||||
@ -485,7 +496,9 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
if (licenseRequired) licenseRequired.style.display = 'none';
|
if (licenseRequired) licenseRequired.style.display = 'none';
|
||||||
platformsCheckboxes.forEach(cb => cb.removeAttribute('required'));
|
platformsCheckboxes.forEach(cb => cb.removeAttribute('required'));
|
||||||
if (licenseSelect) licenseSelect.removeAttribute('required');
|
if (licenseSelect) licenseSelect.removeAttribute('required');
|
||||||
|
|
||||||
|
if (domainAgnosticField) domainAgnosticField.style.display = 'none';
|
||||||
|
|
||||||
// Show related concepts for methods
|
// Show related concepts for methods
|
||||||
if (selectedType === 'method' && relatedConceptsField) {
|
if (selectedType === 'method' && relatedConceptsField) {
|
||||||
relatedConceptsField.style.display = 'block';
|
relatedConceptsField.style.display = 'block';
|
||||||
@ -520,7 +533,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
toolData.platforms = formData.getAll('platforms') || [];
|
toolData.platforms = formData.getAll('platforms') || [];
|
||||||
toolData.license = formData.get('license')?.trim() || null;
|
toolData.license = formData.get('license')?.trim() || null;
|
||||||
toolData.accessType = formData.get('accessType') || null;
|
toolData.accessType = formData.get('accessType') || null;
|
||||||
toolData.projectUrl = formData.get('projectUrl') || null;
|
toolData['domain-agnostic-software'] = formData.getAll('domainAgnostic') || [];
|
||||||
} else {
|
} else {
|
||||||
toolData.platforms = [];
|
toolData.platforms = [];
|
||||||
toolData.license = null;
|
toolData.license = null;
|
||||||
@ -551,8 +564,8 @@ skillLevel: ${toolData.skillLevel}
|
|||||||
url: "${toolData.url}"${toolData.platforms.length > 0 ? `
|
url: "${toolData.url}"${toolData.platforms.length > 0 ? `
|
||||||
platforms: [${toolData.platforms.map(p => `"${p}"`).join(', ')}]` : ''}${toolData.license ? `
|
platforms: [${toolData.platforms.map(p => `"${p}"`).join(', ')}]` : ''}${toolData.license ? `
|
||||||
license: "${toolData.license}"` : ''}${toolData.accessType ? `
|
license: "${toolData.license}"` : ''}${toolData.accessType ? `
|
||||||
accessType: ${toolData.accessType}` : ''}${toolData.projectUrl ? `
|
accessType: ${toolData.accessType}` : ''}${toolData['domain-agnostic-software'] && toolData['domain-agnostic-software'].length > 0 ? `
|
||||||
projectUrl: "${toolData.projectUrl}"` : ''}${toolData.knowledgebase ? `
|
domain-agnostic-software: [${toolData['domain-agnostic-software'].map(c => `"${c}"`).join(', ')}]` : ''}${toolData.knowledgebase ? `
|
||||||
knowledgebase: true` : ''}${toolData.tags.length > 0 ? `
|
knowledgebase: true` : ''}${toolData.tags.length > 0 ? `
|
||||||
tags: [${toolData.tags.map(t => `"${t}"`).join(', ')}]` : ''}${toolData.related_concepts ? `
|
tags: [${toolData.tags.map(t => `"${t}"`).join(', ')}]` : ''}${toolData.related_concepts ? `
|
||||||
related_concepts: [${toolData.related_concepts.map(c => `"${c}"`).join(', ')}]` : ''}`;
|
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.platforms = formData.getAll('platforms');
|
||||||
submissionData.tool.license = formData.get('license')?.trim() || null;
|
submissionData.tool.license = formData.get('license')?.trim() || null;
|
||||||
submissionData.tool.accessType = formData.get('accessType') || 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
|
// Add optional fields
|
||||||
|
@ -320,47 +320,40 @@ private generateToolYAML(tool: any): string {
|
|||||||
|
|
||||||
async submitContribution(data: ContributionData): Promise<GitOperationResult> {
|
async submitContribution(data: ContributionData): Promise<GitOperationResult> {
|
||||||
const branchName = `tool-${data.type}-${Date.now()}`;
|
const branchName = `tool-${data.type}-${Date.now()}`;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Create branch
|
|
||||||
await this.createBranch(branchName);
|
await this.createBranch(branchName);
|
||||||
|
|
||||||
// FIXED: Don't modify tools.yaml at all - just create the tool data file
|
const toolsPath = 'src/data/tools.yaml';
|
||||||
const toolYaml = this.generateToolYAML(data.tool);
|
const originalYaml = await this.readFile(toolsPath);
|
||||||
const contributionFileName = `contribution-${data.type}-${data.tool.name.toLowerCase().replace(/[^a-z0-9]/g, '-')}.yaml`;
|
const yamlData: any = load(originalYaml);
|
||||||
|
|
||||||
// Create contributions directory if it doesn't exist and write the tool data
|
if (!yamlData.tools || !Array.isArray(yamlData.tools)) {
|
||||||
try {
|
throw new Error('Invalid tools.yaml format');
|
||||||
await this.readFile('contributions/.gitkeep');
|
|
||||||
} catch {
|
|
||||||
// Directory doesn't exist, create it
|
|
||||||
await this.writeFile('contributions/.gitkeep', '# Contribution files directory\n');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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}
|
if (data.type === 'edit') {
|
||||||
Type: ${data.tool.type}
|
yamlData.tools = yamlData.tools.filter((t: any) => (t.name || '').toLowerCase() !== data.tool.name.toLowerCase());
|
||||||
${data.metadata.reason ? `Reason: ${data.metadata.reason}` : ''}
|
}
|
||||||
|
|
||||||
|
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);
|
await this.commitChanges(commitMessage);
|
||||||
|
|
||||||
// Push branch
|
|
||||||
await this.pushBranch(branchName);
|
await this.pushBranch(branchName);
|
||||||
|
|
||||||
// Create pull request with enhanced description
|
|
||||||
const prUrl = await this.createPullRequest(
|
const prUrl = await this.createPullRequest(
|
||||||
branchName,
|
branchName,
|
||||||
`${data.type === 'add' ? 'Add' : 'Update'} tool: ${data.tool.name}`,
|
`${data.type === 'add' ? 'Add' : 'Update'} tool: ${data.tool.name}`,
|
||||||
this.generateEnhancedPRDescription(data, toolYaml)
|
`Automated contribution for ${data.tool.name}`
|
||||||
);
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
message: `Tool contribution submitted successfully`,
|
message: `Tool contribution submitted successfully`,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user