Skip to content

Commit

Permalink
Add fetch-files command to deployer
Browse files Browse the repository at this point in the history
  • Loading branch information
amarthadan committed Jan 9, 2023
1 parent c93ab8e commit a29bed4
Show file tree
Hide file tree
Showing 6 changed files with 435 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .changeset/quiet-goats-laugh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@api3/airnode-deployer': minor
---

Add fetch-files command to deployer
2 changes: 2 additions & 0 deletions packages/airnode-deployer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"@api3/airnode-validator": "^0.9.0",
"@api3/promise-utils": "^0.3.0",
"@google-cloud/storage": "^6.9.0",
"adm-zip": "^0.5.10",
"aws-sdk": "^2.1290.0",
"chalk": "^4.1.2",
"cli-table3": "^0.6.3",
Expand All @@ -45,6 +46,7 @@
},
"devDependencies": {
"@google-cloud/functions-framework": "^3.1.2",
"@types/adm-zip": "^0.5.0",
"@types/aws-lambda": "^8.10.108",
"@types/lodash": "^4.14.186",
"@types/node": "^17.0.18",
Expand Down
39 changes: 36 additions & 3 deletions packages/airnode-deployer/src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { deploy, removeWithReceipt } from './commands';
import * as logger from '../utils/logger';
import { longArguments } from '../utils/cli';
import { MultiMessageError } from '../utils/infrastructure';
import { deploymentInfo, listAirnodes, removeAirnode } from '../infrastructure';
import { deploymentInfo, fetchFiles, listAirnodes, removeAirnode } from '../infrastructure';

function drawHeader() {
loggerUtils.log(
Expand Down Expand Up @@ -49,6 +49,7 @@ const cliExamples = [
'deploy -c config/config.json -s config/secrets.env -r config/receipt.json',
'list --cloud-providers gcp',
'info aws808e2a22',
'fetch-files aws808e2a22',
'remove-with-receipt -r config/receipt.json',
'remove aws808e2a22',
];
Expand Down Expand Up @@ -124,7 +125,6 @@ yargs(hideBin(process.argv))
yargs.positional('deployment-id', {
description: `ID of the deployment (from 'list' command)`,
type: 'string',
demandOption: true,
});
},
async (args) => {
Expand Down Expand Up @@ -167,7 +167,6 @@ yargs(hideBin(process.argv))
yargs.positional('deployment-id', {
description: `ID of the deployment (from 'list' command)`,
type: 'string',
demandOption: true,
});
},
async (args) => {
Expand All @@ -183,6 +182,40 @@ yargs(hideBin(process.argv))
}
}
)
.command(
'fetch-files <deployment-id> [version-id]',
'Fetch deployment files for the deployed Airnode',
(yargs) => {
yargs.positional('deployment-id', {
description: `ID of the deployment (from 'list' command)`,
type: 'string',
});
yargs.positional('version-id', {
description: `ID of the deployment version (from 'info' command)`,
type: 'string',
});
yargs.option('output-dir', {
alias: 'o',
description: 'Where to store fetched files',
default: 'config/',
type: 'string',
});
},
async (args) => {
logger.debugMode(args.debug as boolean);
logger.debug(`Running command ${args._[0]} with arguments ${longArguments(args)}`);

// Looks like due to the bug in yargs (https://github.com/yargs/yargs/issues/1649) we need to specify the types explicitely
const goFetchFiles = await go(() =>
fetchFiles(args.deploymentId as string, args.outputDir as string, args.versionId as string | undefined)
);
if (!goFetchFiles.success) {
logger.fail(goFetchFiles.error.message);
// eslint-disable-next-line functional/immutable-data
process.exitCode = 1;
}
}
)
.example(cliExamples.map((line) => [`$0 ${line}\n`]))
.help()
.demandCommand(1)
Expand Down
Loading

0 comments on commit a29bed4

Please sign in to comment.