-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
135 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "<filled in by the plugin generator>", | ||
"version": "0.0.0", | ||
"description": "<filled in by the plugin generator>", | ||
"homepage": "https://github.com/architect/aws-lite", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/architect/aws-lite" | ||
}, | ||
"bugs": "https://github.com/architect/aws-lite/issues", | ||
"main": "src/index.js", | ||
"engines": { | ||
"node": ">=16" | ||
}, | ||
"author": "@YOUR_GITHUB", | ||
"license": "Apache-2.0", | ||
"files": [ | ||
"src" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
const service = '$NAME' | ||
const required = true | ||
|
||
/** | ||
* Plugin maintained by: @YOUR_GITHUB | ||
*/ | ||
module.exports = { | ||
service, | ||
methods: { | ||
// TODO: include a reference link with each method, example: | ||
// https://docs.aws.amazon.com/lambda/latest/dg/API_GetFunctionConfiguration.html | ||
$ReplaceMe: { | ||
validate: { | ||
name: { type: 'string', required }, | ||
}, | ||
request: async ({ name }) => { | ||
return { | ||
endpoint: `/$API_VER/${name}/etc` | ||
} | ||
}, | ||
error: async (error) => { | ||
if (error.statusCode === 400 && | ||
error?.error?.message?.match(/validation error/)) { | ||
error.metadata.type = 'Validation error' | ||
} | ||
return error | ||
} | ||
}, | ||
|
||
// TODO: add API link | ||
$ReplaceMeToo: { | ||
validate: { | ||
name: { type: 'string', required }, | ||
}, | ||
request: async ({ name }) => { | ||
return { | ||
endpoint: `/$API_VER/${name}/etc` | ||
} | ||
}, | ||
// error: async (error) => error | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# `$NAME` | ||
|
||
> $DESC | ||
|
||
## Install | ||
|
||
```sh | ||
npm i $NAME | ||
``` | ||
|
||
|
||
## Learn more | ||
|
||
Please see the [main `aws-lite` readme](https://github.com/architect/aws-lite) for more information about `aws-lite` plugins. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#! /usr/bin/env node | ||
let { join } = require('path') | ||
let { existsSync, mkdirSync, readFileSync, writeFileSync } = require('fs') | ||
const cwd = process.cwd() | ||
|
||
// Break this into a separate file if it becomes too big / unwieldy! | ||
const plugins = [ | ||
{ name: 'dynamodb', service: 'DynamoDB' }, | ||
] | ||
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 => { | ||
let pluginDir = join(cwd, 'plugins', plugin.name) | ||
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 | ||
let src = pluginTmpl | ||
.replace(/\$NAME/g, plugin.name) | ||
writeFileSync(join(pluginSrc, 'index.js'), src) | ||
|
||
// package.json | ||
let pkg = JSON.parse(packageTmpl) | ||
pkg.name = name | ||
pkg.description = desc | ||
writeFileSync(join(pluginDir, 'package.json'), JSON.stringify(pkg, null, 2)) | ||
|
||
// readme.md | ||
let readme = readmeTmpl | ||
.replace(/\$NAME/g, name) | ||
.replace(/\$DESC/g, desc) | ||
writeFileSync(join(pluginDir, 'readme.md'), readme) | ||
|
||
let projectPkgFile = join(cwd, 'package.json') | ||
let projectPkg = JSON.parse(readFileSync(projectPkgFile)) | ||
let workspace = `plugins/${plugin.name}` | ||
if (!projectPkg.workspaces.includes(workspace)) { | ||
projectPkg.workspaces.push(workspace) | ||
projectPkg.workspaces = projectPkg.workspaces.sort() | ||
writeFileSync(projectPkgFile, JSON.stringify(projectPkg, null, 2)) | ||
} | ||
} | ||
}) |