This repository was archived by the owner on Jun 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
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
11 changed files
with
142 additions
and
27 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
module.exports = require('../../config/jest.config.base')(__dirname); | ||
const config = require('../../config/jest.config.base')(__dirname); | ||
|
||
module.exports = { ...config, collectCoverage: false }; |
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,56 @@ | ||
/* eslint-disable import/first */ | ||
import * as faker from 'faker'; | ||
|
||
const optionsFromConfigFiles = { | ||
option: faker.random.word(), | ||
optionEnv: faker.random.word(), | ||
environments: { | ||
Production: { | ||
optionEnv: faker.random.word(), | ||
}, | ||
}, | ||
}; | ||
|
||
jest.mock('deepmerge', () => ({ | ||
all: jest.fn().mockReturnValue(optionsFromConfigFiles), | ||
})); | ||
|
||
import cli from './cli'; | ||
|
||
describe('handle options correctly', () => { | ||
test('argv must have the options passed to CLI', () => { | ||
const options = { | ||
region: faker.random.word(), | ||
}; | ||
cli.parse('print-args', options, (_err, argv) => { | ||
expect(argv).toMatchObject(options); | ||
expect(argv).toMatchObject(options); | ||
}); | ||
}); | ||
|
||
test('argv must have the environment option', () => { | ||
cli.parse( | ||
'print-args', | ||
{ environment: 'Production' }, | ||
(_err: any, argv: any) => { | ||
expect(argv.optionEnv).toEqual( | ||
optionsFromConfigFiles.environments.Production.optionEnv, | ||
); | ||
}, | ||
); | ||
}); | ||
|
||
test('argv must have the CLI optionEnv', () => { | ||
const newOptionEnv = faker.random.word(); | ||
cli.parse( | ||
'print-args', | ||
{ | ||
environment: 'Production', | ||
optionEnv: newOptionEnv, | ||
}, | ||
(_err: any, argv: any) => { | ||
expect(argv.optionEnv).toEqual(newOptionEnv); | ||
}, | ||
); | ||
}); | ||
}); |
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,32 @@ | ||
--- | ||
title: CLI | ||
--- | ||
|
||
## Environments | ||
|
||
**carlin** was projected to work with environments. As we've been building a lot of Apps, we realized that we commonly have some environments, like production and staging. The difference between these environments was some options values that we passed to the deploy command. To handle these options, we've created the `environments` option. It receives an object whose keys are the environment name and the values are an object containing the command options. | ||
|
||
Besides `environments`, if we provide the option `-e`, `--env` or `--environment`, **carlin** searches if such environment exists inside `environments` object and assign the values to the command. For instance, suppose that we have the `carlin.yml` below. | ||
|
||
```yaml title="carlin.yml" | ||
region: us-east-1 | ||
environments: | ||
Production: | ||
region: ap-south-1 | ||
``` | ||
The `region` value will be, for each command: | ||
|
||
| Command | `region` | | ||
| ------------------------------------------------ | -------------- | | ||
| `carlin deploy` | **us-east-1** | | ||
| `carlin deploy --region eu-west-1` | **eu-west-1** | | ||
| `carlin deploy -e production`\* | **us-east-1** | | ||
| `carlin deploy -e Production` | **ap-south-1** | | ||
| `carlin deploy -e Production --region eu-west-1` | **eu-west-1** | | ||
|
||
:::note | ||
|
||
\* `environment` is case sensitive. | ||
|
||
::: |
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,11 @@ | ||
--- | ||
title: Installation | ||
--- | ||
|
||
You can install **carlin** with NPM or Yarn. | ||
|
||
```bash | ||
npm install -g carlin | ||
# or | ||
yarn global add carlin | ||
``` |
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,8 @@ | ||
--- | ||
title: Overview | ||
slug: / | ||
--- | ||
|
||
**carlin** has been built for the last years as helpers scripts that support deploying AWS cloud resources. The first scripts were used to deploy CloudFormation templates as we've started performing numerous deployments along with staging, production, development... environments. | ||
|
||
As the scripts grew, it was very useful put them all in a CLI and create an [NPM package](https://www.npmjs.com/package/carlin), this way it can be used by all team in all projects. |
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
module.exports = { | ||
someSidebar: { | ||
'Getting Started': ['overview', 'installation', 'CLI'], | ||
Commands: ['deploy'], | ||
}, | ||
}; |