-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support plugin definitions with version number.
In order to support https:// urls for plugins we can not simply use names anymore. The https: url does not give insight on what npm package is available at the target url making caching impossible. The implementation is pretty strict, not allowing for anything but https urls and exact version definitions in order to keep the cache fast. BREAKING CHANGE: this changes the input format definition from a set of string-separated plugins to an object structure.
- Loading branch information
1 parent
bfdc496
commit d2b2b4d
Showing
8 changed files
with
290 additions
and
36 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
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,69 @@ | ||
# Serverless Plugin Loading Example | ||
|
||
This folder contains a simple [serverless][] setup that can be deployed to your AWS account. | ||
|
||
[serverless]: https://serverless.com | ||
|
||
## Deploy Process | ||
|
||
1. Run `npm install` in this folder. _(~2 min)_ | ||
2. Run `npx sls deploy` in this folder. _(~3 min)_ | ||
3. Run `npx sls invoke --function=hello` in this folder. | ||
|
||
It will show an output like: | ||
|
||
```json | ||
{ | ||
"statusCode": 200, | ||
"body": { | ||
"names": [], | ||
"plugin": {} | ||
} | ||
} | ||
``` | ||
|
||
4. Go into your AWS console and add the environment variable `PLUGINS` to the new `plugin-example-main-dev-hello` function. You should find it at [this link][sls-fn]. You can specify [npm][] package definitions like `{"@tradle/constants": "2.5.1", "@tradle/errors": "2.0.1"}`. Dont forget to `SAVE`. | ||
|
||
[sls-fn]: https://us-east-1.console.aws.amazon.com/lambda/home?region=us-east-1#/functions/plugin-example-main-dev-hello?tab=configure | ||
[npm]: https://npmjs.com | ||
|
||
5. Run `npx sls invoke --function=hello` again. | ||
|
||
The output should now be something like: | ||
|
||
```js | ||
{ | ||
"statusCode": 200, | ||
"body": { | ||
"names": [ | ||
"@tradle/constants", | ||
"@tradle/errors" | ||
], | ||
"plugin": { | ||
"@tradle/constants": { | ||
"data": { | ||
// ... | ||
}, | ||
"pkg": { | ||
// ... | ||
} | ||
}, | ||
"@tradle/errors": { | ||
"data": { | ||
// ... | ||
}, | ||
"pkg": { | ||
// ... | ||
} | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
|
||
Indicating that the new Plugins are available. | ||
|
||
--- | ||
|
||
Find all the code in [`./handler.ts`](./handler.ts). | ||
|
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
Oops, something went wrong.