You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've recently been working on a project where I programmatically generate the codeowners file based on some configuration. So far, I've written a fairly simple class that gives an API to describe a codeowners file (rules, comments, and newlines), and I'm wondering if you'd like this contributed back?
I'm thinking more along the lines of parsing a CODEOWNERS file to a simple AST (see below), and then set of methods to work with that AST and a means to convert the AST to a CODEOWNERS file.
Example AST:
{
type: 'rule' | 'comment' | 'newline'
// For type == comment
message?: string
// For type == rule
pattern: string
owners: string[]
}
The Codeowners function would then change to:
// If options.read == true, then call Codeowners.prototype.readSync() followed by Codeowners.prototype.parse()
// options.read will default to true, as this closest resembles the existing behaviour
new Codeowners(currentPath, fileName = 'CODEOWNERS', options?: { read: true })
Codeowners.prototype.getOwner(filepath: string);
Codeowners.prototype.parse() // called by constructor
Codeowners.prototype.addComment(message?: string)
Codeowners.prototype.addRule(pattern: string, owners: string[])
Codeowners.prototype.addNewline()
Codeowners.prototype.toString() // output the current AST as a CODEOWNERS file
async Codeowners.prototype.read()
async Codeowners.prototype.write()
Codeowners.prototype.readSync()
Codeowners.prototype.writeSync()
Thoughts? This would allow programmatic management of CODEOWNERS files, we could also optionally do a breaking API change of:
Hi!
I've recently been working on a project where I programmatically generate the codeowners file based on some configuration. So far, I've written a fairly simple class that gives an API to describe a codeowners file (rules, comments, and newlines), and I'm wondering if you'd like this contributed back?
I'm thinking more along the lines of parsing a CODEOWNERS file to a simple AST (see below), and then set of methods to work with that AST and a means to convert the AST to a CODEOWNERS file.
Example AST:
The
Codeowners
function would then change to:Thoughts? This would allow programmatic management of CODEOWNERS files, we could also optionally do a breaking API change of:
Such that existing code using the API would be:
The text was updated successfully, but these errors were encountered: