.github/ISSUE_TEMPLATE: added sync script for common fields

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2025-04-19 18:05:32 +02:00
parent 8b63921787
commit 4276a64116
4 changed files with 129 additions and 1 deletions
+71
View File
@@ -0,0 +1,71 @@
# This file contains common fields for all issue templates
# Each field is identified by its ID, and are synced with the `sync.js` script
#
# WARNING: After updating this file, run `yarn sync-issue-templates`
#
- id: issue-labels
type: checkboxes
attributes:
label: '📜 Issue Labels'
options:
- label: 'Please familiarize yourself with the issue labels used in this project: [LABELS.md](https://github.com/backstage/backstage/blob/master/LABELS.md)'
required: true
- id: search-terms
type: textarea
attributes:
label: '🔎 Search Terms'
render: plain
description: |
What search terms did you use when trying to find an existing feature proposal?
placeholder: |
List of keywords you searched for before creating this issue. Write them down here so that others can find this bug more easily and help provide feedback.
e.g. "catalog github rate limited", "http root service configurer", "scaffolder template include", "entity card title"
validations:
required: true
- id: project-area
type: dropdown
attributes:
label: '🗃️ Project Area'
description: What area of the project would this feature be related to? This will help find an owner for the issue faster.
options:
- Unknown
- Auditor
- Catalog
- CLI Tooling
- Core Framework
- Design System
- Documentation
- Events System
- Home
- Kubernetes Plugin
- Microsite
- Notifications
- OpenAPI Tooling
- Permission Framework
- Software Templates
- Search
- TechDocs
validations:
required: true
- id: read-code-of-conduct
type: checkboxes
attributes:
label: 'Have you read the Code of Conduct?'
options:
- label: 'I have read the [Code of Conduct](https://github.com/backstage/backstage/blob/master/CODE_OF_CONDUCT.md)'
required: true
- id: willing-to-submit-pr
type: dropdown
attributes:
label: Are you willing to submit PR?
description: This is absolutely not required, but we are happy to guide you in the contribution process.
options:
- Undecided
- Yes, and I have enough information to get started
- Yes, but I would like some more guidance
- No, but I'm happy to collaborate on a PR with someone else
- No, I don't have time to work on this right now
validations:
required: true
+54
View File
@@ -0,0 +1,54 @@
#!/usr/bin/env node
const fs = require('node:fs');
const path = require('node:path');
const yaml = require('yaml');
const TEMPLATES_DIR = path.join(__dirname);
const COMMON_FILE = path.join(TEMPLATES_DIR, '.common.yaml');
// Read the common fields from .common.yaml
const commonDoc = yaml.parseDocument(fs.readFileSync(COMMON_FILE, 'utf8'));
const commonFields = new Map(
commonDoc.contents.items.map(field => {
field.commentBefore = ' This field is managed by .common.yaml';
return [field.get('id'), field];
}),
);
// Get all YAML files in the templates directory except .common.yaml
const templateFiles = fs
.readdirSync(TEMPLATES_DIR)
.filter(file => file.endsWith('.yaml') && file !== '.common.yaml');
// Process each template file
for (const templateFile of templateFiles) {
const templatePath = path.join(TEMPLATES_DIR, templateFile);
const templateDoc = yaml.parseDocument(fs.readFileSync(templatePath, 'utf8'));
if (templateDoc.get('body')) {
const body = templateDoc.get('body');
for (let i = 0; i < body.items.length; i++) {
const field = body.items[i];
const commonField = commonFields.get(field.get('id'));
if (commonField) {
body.items[i] = commonField;
}
}
// Write the updated template back to file with matching style
fs.writeFileSync(
templatePath,
templateDoc.toString({
indent: 2,
lineWidth: 0,
minContentWidth: 0,
singleQuote: true,
}),
);
console.log(`Updated ${templateFile}`);
}
}
console.log('Sync complete!');
+3 -1
View File
@@ -55,6 +55,7 @@
"start:microsite": "cd microsite/ && yarn start",
"start:next": "yarn start example-app-next example-backend",
"storybook": "yarn ./storybook run storybook",
"sync-issue-templates": "node ./.github/ISSUE_TEMPLATE/sync.js",
"techdocs-cli": "node scripts/techdocs-cli.js",
"techdocs-cli:dev": "cross-env TECHDOCS_CLI_DEV_MODE=true node scripts/techdocs-cli.js",
"test": "NODE_OPTIONS='--no-node-snapshot --experimental-vm-modules' backstage-cli repo test",
@@ -112,7 +113,8 @@
"@backstage/errors": "workspace:^",
"@manypkg/get-packages": "^1.1.3",
"@types/global-agent": "^2.1.3",
"@useoptic/optic": "^1.0.0"
"@useoptic/optic": "^1.0.0",
"yaml": "^2.7.0"
},
"devDependencies": {
"@backstage/cli": "workspace:*",
+1
View File
@@ -42682,6 +42682,7 @@ __metadata:
sort-package-json: "npm:^2.8.0"
typedoc: "npm:^0.27.6"
typescript: "npm:~5.6.0"
yaml: "npm:^2.7.0"
languageName: unknown
linkType: soft