# @theorchard/generator-lambda

Yeoman project generator for new node and typescript lambda instances.

## Installing the generator

```bash
# install yeoman and generator
yarn global add yo @theorchard/generator-lambda
```

## Basic Usage

There are two ways you can use this generator:

-   Creating a new project + lambda
-   Creating a new lambda within an existing project

### Creating a new project + lambda

Create a new project folder:

```bash
mkdir lambda-test
cd lambda-test
```

Then run the generator and follow the prompts:

```bash
yo @theorchard/lambda
```

The project directory should now be setup with a README, .gitignore, and a lambda directory with a new lambda.

### Creating a new lambda within an existing project

Go the projects root or lambda directory.

Then run the subgenerator and follow the prompts:

```bash
yo @theorchard/lambda:lambda
```

The lambda folder in the project directory should have a new lambda generated.

### Updating an existing lambda

Go the projects root or lambda directory.

Then run the subgenerator:

```bash
yo @theorchard/lambda:lambda
```

Upon entering the existing lambdas name you will see the following prompt:

-   'This lambda already exists, are you trying to update the node version?'

If you're only trying to update the node version hit 'Y'. This will create or update a few files:

-   Dockerfile
-   Dockerfile.dockerignore
-   Dockerfile.tests
-   docker-compose.yaml
-   .nvmrc
-   package.json
-   scripts/setup.sh

Else hit 'N' and it will carry out the normal lambda creation process while asking if you want to overwrite/edit existing files.
