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.
feat: add repository image updater (#45)
- Loading branch information
Showing
12 changed files
with
281 additions
and
166 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,81 @@ | ||
/* eslint-disable no-param-reassign */ | ||
import { camelCase } from 'change-case'; | ||
import yargs from 'yargs'; | ||
|
||
import { pipelines } from './pipelines'; | ||
|
||
export const options = { | ||
cpu: { | ||
type: 'string', | ||
}, | ||
memory: { | ||
type: 'string', | ||
}, | ||
pipelines: { | ||
choices: pipelines, | ||
coerce: (values: string[]) => values.map((value) => camelCase(value)), | ||
default: [], | ||
description: 'Pipelines that will be implemented with the CICD stack.', | ||
type: 'array', | ||
}, | ||
'update-repository': { | ||
alias: ['ur'], | ||
description: 'Determine if the repository image will be updated.', | ||
default: true, | ||
type: 'boolean', | ||
}, | ||
'ssh-key': { | ||
demandOption: true, | ||
type: 'string', | ||
}, | ||
'ssh-url': { | ||
demandOption: true, | ||
type: 'string', | ||
}, | ||
'slack-webhook-url': { | ||
type: 'string', | ||
}, | ||
/** | ||
* This option has the format: | ||
* | ||
* ```ts | ||
* Array<{ | ||
* name: string, | ||
* value: string, | ||
* }> | ||
* ``` | ||
*/ | ||
'task-environment': { | ||
alias: ['te'], | ||
default: [], | ||
describe: | ||
'A list of environment variables that will be passed to the ECS container task.', | ||
type: 'array', | ||
}, | ||
} as const; | ||
|
||
export type CicdCommandOptions = Partial<{ | ||
[key in keyof typeof options]: any; | ||
}>; | ||
|
||
export const getCicdConfig = () => { | ||
const { parsed } = yargs.config(); | ||
|
||
if (!parsed) { | ||
return false; | ||
} | ||
|
||
const { argv } = parsed; | ||
|
||
const config: CicdCommandOptions = Object.keys(options).reduce((acc, key) => { | ||
const value = argv[key]; | ||
|
||
if (value) { | ||
acc[key] = value; | ||
} | ||
|
||
return acc; | ||
}, {} as any); | ||
|
||
return config; | ||
}; |
Oops, something went wrong.