This repository contains an Octokit script that will automatically add JSON Schema to cgmanifest.json
files.
NOTE: This script requires Node.js 18+.
- Create a GitHub Personal Access Token with the
repo
scope - Rename the
.env.sample
file to.env
- Put your GitHub Personal Access Token in the
GITHUB_TOKEN
environment variable
We receive a lot of support request about cgmanifest.json
files.
By providing a JSON Schema, it allows users to make sure that their cgmanifest.json
file is valid, without asking us.
It also enables intellisense in Visual Studio Code and Visual Studio.
- Search for any repositories that contain a
cgmanifest.json
file - For each repository:
- Check if the repository is archived or private
- If yes, skip to next repository
- Check if the repository has already been forked to the Octokit user
- If yes, fetch the fork
- If no, create a fork
- Check if there is already a pull request for updating
cgmanifest.json
- If yes, skip to next repository
- Fetch the
cgmanifest.json
file from the current repository - Add the
$schema
property to thecgmanifest.json
file - Format the
cgmanifest.json
file usingprettier
- Check if the
cgmanifest-schema
branch exists in the fork- If yes, delete the existing
cgmanifest-schema
branch
- If yes, delete the existing
- Create the
cgmanifest-schema
branch in the fork - Update the
cgmanifest-schema
branch in the fork with the formattedcgmanifest.json
file - Create a pull request for the
cgmanifest-schema
branch from the fork
- Check if the repository is archived or private
Currently, the script opens pull requests against the fork. To create pull requests against the original repository you need to change this line from:
fork.data.owner.login
to:
result.repository.owner.login
There's another script called track-progress.ts
that allows you to track the status of pull requests created by this script.
You can run it by running npm run track-progress
.
Check that the user:
parameter in the search query used in track-progress.ts
is the same as the organization you're opening pull requests for.