Skip to content

Commit

Permalink
Issue #136 Add ES Module exports
Browse files Browse the repository at this point in the history
- Update documentation
- Fix analyze scripts
  • Loading branch information
kernwig committed Jan 29, 2025
1 parent d195403 commit 5fab62e
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 91 deletions.
39 changes: 25 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ we found certain patterns being used repeatedly, and code being copied from one
These commonalities have been extracted, matured, and gathered into a reusable collection.

Sailplane is the result: a collection of useful packages for use in developing code that runs in AWS.
They are primarily used in Lambda functions, but most are useful in other services that use the Node.js 18+
runtime as well.
They are primarily designed for use in Lambda functions, but most are useful in other environments
that use the Node.js 20+ runtime as well. `ExpiringValue` is even useful in web browsers.

The Typescript source is compiled to ES6 Javascript for portability, along with Typescript type
definition files. While the typing provides the expected benefit, these utilities may be used in plain
The Typescript source is compiled to ES2020 Javascript and distributed with both ESModule and CommonJS
modules for portability, along with Typescript type definition files and map files.
While the typing provides the expected benefit, these utilities may be used in plain
Javascript as well.

Every tool is the genesis of real world needs, and they continue to evolve.
Expand Down Expand Up @@ -45,16 +46,26 @@ as a sailplane is to flight without the complexities of an airplane.

And that's it. Also, the NPM scope was available.

![](docs/sailplane.png)

## Development

Use the `make.sh` script to build all of the projects in an order that resolves the dependencies between them.
This is a monorepo with shared development tools at the root level. Each subdirectory is a
project. Use the `npm run` scripts in each package, or from the root workspace to run the
script on all packages.

### Making Changes

1. Create an [issue in Github](https://github.com/rackspace/sailplane/issues). Get approval from the community.
2. Create a branch off of `main`. The branch name should be like `issue/<num>-brief-summary`
3. Make your change and test it thoroughly with unit tests and a project using it.
4. Run `npm run analyze` from the root workspace and resolve all errors.
5. Commit to your git branch and open a [pull request](https://github.com/rackspace/sailplane/pulls).
- Do not change the version in `package.json`.

### Publish a Release

This is managed from each library package, as they are individually released to NPM.

```
$ ./make.sh clean # delete all node_modules directories
$ ./make.sh build # npm install, test, and build all packages
$ ./make.sh check # check what packages need to be published
$ ./make.sh publish # npm publish packages with new version numbers (must have bump versions first and have permission)
$ ./make.sh all # do clean, build, & publish
```
1. Run `npm run clean && npm run analyze` to confirm that all code builds and tests pass.
2. Use `npm version <major | minor | patch>` to bump the version and tag it in git. ([docs](https://docs.npmjs.com/cli/v10/commands/npm-version))
3. Use `npm publish` to publish the change to NPM. You must have credentials. ([docs](https://docs.npmjs.com/cli/v10/commands/npm-publish))
4. Commit & Push updates to git.
2 changes: 1 addition & 1 deletion aws-https/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"typescript"
],
"scripts": {
"analyze": "npm run build && npm run lint && npm test && npm run prettier",
"analyze": "npm run build && npm run lint && npm test",
"clean": "rm -rf coverage dist",
"build": "tsup",
"dev": "tsup --watch",
Expand Down
2 changes: 1 addition & 1 deletion docs/injector.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ As of v3, Injector also supports a Typescript decorator for registering classes.
## Install

```shell
npm install @sailplane/injector @sailplane/logger bottlejs@1.7
npm install @sailplane/injector @sailplane/logger bottlejs@2
```

## Configuration
Expand Down
23 changes: 14 additions & 9 deletions docs/lambda_utils.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,39 +44,44 @@ or use it as an example to write your own, to add more middleware!

## Install

**To use LambdaUtils v6.x with Middy v4.x.x (latest):**
### LambdaUtils v7.x with Middy v6.x.x (latest)

**Works best with ES Modules, not CommonJS.** See [Middy Upgrade Notes](https://middy.js.org/docs/upgrade/5-6).

```shell
npm install @sailplane/lambda-utils@6 @sailplane/logger @middy/core@4 @middy/http-cors@4 @middy/http-event-normalizer@4 @middy/http-header-normalizer@4 @middy/http-json-body-parser@4
npm install @sailplane/lambda-utils@7 @sailplane/logger @middy/core@6 @middy/http-cors@6 @middy/http-event-normalizer@6 @middy/http-header-normalizer@6 @middy/http-json-body-parser@6
```

The extra `@middy/` middleware packages are optional if you write your own wrapper function that does not use them.
See below.

**To use LambdaUtils v4.x or v5.x with Middy v2.x.x:**
### LambdaUtils v6.x with Middy v4.x.x

```shell
npm install @sailplane/lambda-utils@4 @sailplane/logger @middy/core@2 @middy/http-cors@2 @middy/http-event-normalizer@2 @middy/http-header-normalizer@2 @middy/http-json-body-parser@2
npm install @sailplane/lambda-utils@6 @sailplane/logger @middy/core@4 @middy/http-cors@4 @middy/http-event-normalizer@4 @middy/http-header-normalizer@4 @middy/http-json-body-parser@4
```

The extra @middy/ middleware packages are optional if you write your own wrapper function that does not use them.
The extra `@middy/` middleware packages are optional if you write your own wrapper function that does not use them.
See below.

**To use LambdaUtils v3.x with Middy v1.x.x:**
### LambdaUtils v4.x or v5.x with Middy v2.x.x

```shell
npm install @sailplane/lambda-utils@3 @sailplane/logger @middy/core@1 @middy/http-cors@1 @middy/http-event-normalizer@1 @middy/http-header-normalizer@1 @middy/http-json-body-parser@1
npm install @sailplane/lambda-utils@4 @sailplane/logger @middy/core@2 @middy/http-cors@2 @middy/http-event-normalizer@2 @middy/http-header-normalizer@2 @middy/http-json-body-parser@2
```

The extra @middy/ middleware packages are optional if you write your own wrapper function that does not use them.
See below.

**To use LambdaUtils v2.x with Middy v0.x.x:**
### LambdaUtils v3.x with Middy v1.x.x

```shell
npm install @sailplane/lambda-utils@2 @sailplane/logger middy@0
npm install @sailplane/lambda-utils@3 @sailplane/logger @middy/core@1 @middy/http-cors@1 @middy/http-event-normalizer@1 @middy/http-header-normalizer@1 @middy/http-json-body-parser@1
```

The extra @middy/ middleware packages are optional if you write your own wrapper function that does not use them.
See below.

## Upgrading

To upgrade from older versions of lambda-utils, remove the old lambda-utils and middy dependencies
Expand Down
2 changes: 1 addition & 1 deletion elasticsearch-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"typescript"
],
"scripts": {
"analyze": "npm run build && npm run lint && npm test && npm run prettier",
"analyze": "npm run build && npm run lint && npm test",
"clean": "rm -rf coverage dist",
"build": "tsup",
"dev": "tsup --watch",
Expand Down
2 changes: 1 addition & 1 deletion expiring-value/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"typescript"
],
"scripts": {
"analyze": "npm run build && npm run lint && npm test && npm run prettier",
"analyze": "npm run build && npm run lint && npm test",
"clean": "rm -rf coverage dist",
"build": "tsup",
"dev": "tsup --watch",
Expand Down
2 changes: 1 addition & 1 deletion injector/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"typescript"
],
"scripts": {
"analyze": "npm run build && npm run lint && npm test && npm run prettier",
"analyze": "npm run build && npm run lint && npm test",
"clean": "rm -rf coverage dist",
"build": "tsup",
"dev": "tsup --watch",
Expand Down
2 changes: 1 addition & 1 deletion lambda-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"middy"
],
"scripts": {
"analyze": "npm run build && npm run lint && npm test && npm run prettier",
"analyze": "npm run build && npm run lint && npm test",
"clean": "rm -rf coverage dist",
"build": "tsup",
"dev": "tsup --watch",
Expand Down
2 changes: 1 addition & 1 deletion logger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"typescript"
],
"scripts": {
"analyze": "npm run build && npm run lint && npm test && npm run prettier",
"analyze": "npm run build && npm run lint && npm test",
"clean": "rm -rf coverage dist",
"build": "tsup",
"dev": "tsup --watch",
Expand Down
59 changes: 0 additions & 59 deletions make.sh

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"npm": ">=10.3.0 <11"
},
"scripts": {
"analyze": "npm run analyze -ws",
"analyze": "npm run analyze -ws && npm run prettier",
"build": "npm run build -ws",
"clean": "npm run clean -ws && rm -rf tsconfig.tsbuildinfo",
"clean:all": "npm run clean && find . -name node_modules -maxdepth 2 -type d -exec rm -rf {} +",
Expand Down
2 changes: 1 addition & 1 deletion state-storage/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"typescript"
],
"scripts": {
"analyze": "npm run build && npm run lint && npm test && npm run prettier",
"analyze": "npm run build && npm run lint && npm test",
"clean": "rm -rf coverage dist",
"build": "tsup",
"dev": "tsup --watch",
Expand Down

0 comments on commit 5fab62e

Please sign in to comment.