Skip to content

Commit

Permalink
Add maintainers
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanblock committed Sep 18, 2023
1 parent 4fa319c commit c5018de
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 7 deletions.
6 changes: 6 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ await aws({
(Coming soon!)


### Official `@aws-lite/*` plugins

<!-- plugins_start -->
<!-- plugins_end -->


## Contributing

AWS has (as of this writing) nearly 300 service APIs – `aws-lite` would love your help in authoring and maintaining official (and unofficial) plugins!
Expand Down
2 changes: 1 addition & 1 deletion scripts/generate-plugins/_package-tmpl.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"engines": {
"node": ">=16"
},
"author": "@YOUR_GITHUB",
"author": "<filled in by the plugin generator>",
"license": "Apache-2.0",
"files": [
"src"
Expand Down
2 changes: 1 addition & 1 deletion scripts/generate-plugins/_plugin-tmpl.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const service = '$NAME'
const required = true

/**
* Plugin maintained by: @YOUR_GITHUB
* Plugin maintained by: $MAINTAINERS
*/
module.exports = {
service,
Expand Down
2 changes: 2 additions & 0 deletions scripts/generate-plugins/_readme-tmpl.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

> $DESC
> Maintained by: $MAINTAINERS

## Install

Expand Down
33 changes: 28 additions & 5 deletions scripts/generate-plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,54 @@ let { existsSync, mkdirSync, readFileSync, writeFileSync } = require('fs')
const cwd = process.cwd()

// Break this into a separate file if it becomes too big / unwieldy!
// - name: the official service name; example: `cloudformation`
// - service: the commonly recognized, more formal version (including casing); example: `CloudFormation`
// - maintainers: array of GitHub handles of the individual(s) or org(s) responsible for maintaining the plugin
const plugins = [
{ name: 'dynamodb', service: 'DynamoDB' },
]
{ name: 'dynamodb', service: 'DynamoDB', maintainers: [ '@architect' ] },
].sort()
const pluginTmpl = readFileSync(join(__dirname, '_plugin-tmpl.js')).toString()
const readmeTmpl = readFileSync(join(__dirname, '_readme-tmpl.md')).toString()
const packageTmpl = readFileSync(join(__dirname, '_package-tmpl.json'))

plugins.forEach(plugin => {
if (!plugin.name || typeof plugin.name !== 'string' ||
!plugin.service || typeof plugin.service !== 'string' ||
!plugin.maintainers || !Array.isArray(plugin.maintainers)) {
throw ReferenceError(`Specified plugin must have 'name' (string), 'service' (string), and 'maintainers' (array)`)
}

let pluginDir = join(cwd, 'plugins', plugin.name)
let maintainers = plugin.maintainers.join(', ')
if (!existsSync(pluginDir)) {
let pluginSrc = join(pluginDir, 'src')
mkdirSync(pluginSrc, { recursive: true })

let name = `@aws-lite/${plugin.name}`
let desc = `Official \`aws-lite\` plugin for ${plugin.service}`

// src/index.js
// Plugin: src/index.js
let src = pluginTmpl
.replace(/\$NAME/g, plugin.name)
.replace(/\$MAINTAINERS/g, maintainers)
writeFileSync(join(pluginSrc, 'index.js'), src)

// package.json
// Plugin: package.json
let pkg = JSON.parse(packageTmpl)
pkg.name = name
pkg.description = desc
pkg.author = maintainers
writeFileSync(join(pluginDir, 'package.json'), JSON.stringify(pkg, null, 2))

// readme.md
// Plugin: readme.md
let maintainerLinks = plugin.maintainers.map(p => `[${p}](https://github.com/${p.replace('@', '')})`).join(', ')
let readme = readmeTmpl
.replace(/\$NAME/g, name)
.replace(/\$DESC/g, desc)
.replace(/\$MAINTAINERS/g, maintainerLinks)
writeFileSync(join(pluginDir, 'readme.md'), readme)

// Project: package.json
let projectPkgFile = join(cwd, 'package.json')
let projectPkg = JSON.parse(readFileSync(projectPkgFile))
let workspace = `plugins/${plugin.name}`
Expand All @@ -47,3 +62,11 @@ plugins.forEach(plugin => {
}
}
})

// Project readme.md
let projectReadmeFile = join(cwd, 'readme.md')
let projectReadme = readFileSync(projectReadmeFile).toString()
let pluginListRegex = /(?<=(<!-- plugins_start -->\n))[\s\S]*?(?=(<!-- plugins_end -->))/g
let pluginList = plugins.map(({ name, service }) => `- [${service}](https://www.npmjs.com/package/@aws-lite/${name})`)
projectReadme = projectReadme.replace(pluginListRegex, pluginList.join('\n') + '\n')
writeFileSync(projectReadmeFile, projectReadme)

0 comments on commit c5018de

Please sign in to comment.