Skip to content

Commit 8d0b999

Browse files
johnpcKamil Sobol
andauthored
add --config-out-dir arg to pipeline-deploy (#854)
* add --out-dir arg to pipeline-deploy * fix lint * use --config-out-dir * Update .changeset/moody-grapes-move.md Co-authored-by: Kamil Sobol <[email protected]> * Update packages/cli/src/commands/pipeline-deploy/pipeline_deploy_command.test.ts Co-authored-by: Kamil Sobol <[email protected]> --------- Co-authored-by: Kamil Sobol <[email protected]>
1 parent 6a2f9aa commit 8d0b999

File tree

3 files changed

+47
-1
lines changed

3 files changed

+47
-1
lines changed

.changeset/moody-grapes-move.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@aws-amplify/backend-cli': patch
3+
---
4+
5+
add --config-out-dir to pipeline-deploy command

packages/cli/src/commands/pipeline-deploy/pipeline_deploy_command.test.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,35 @@ void describe('deploy command', () => {
8484
]);
8585
assert.equal(generateClientConfigMock.mock.callCount(), 1);
8686
});
87+
88+
void it('allows --config-out-dir argument', async () => {
89+
const mockDeploy = mock.method(
90+
BackendDeployerFactory.getInstance(),
91+
'deploy',
92+
() => Promise.resolve()
93+
);
94+
await getCommandRunner(true).runCommand(
95+
'pipeline-deploy --app-id abc --branch test-branch --config-out-dir src'
96+
);
97+
assert.strictEqual(mockDeploy.mock.callCount(), 1);
98+
assert.deepStrictEqual(mockDeploy.mock.calls[0].arguments, [
99+
{
100+
name: 'test-branch',
101+
namespace: 'abc',
102+
type: 'branch',
103+
},
104+
{
105+
validateAppSources: true,
106+
},
107+
]);
108+
assert.equal(generateClientConfigMock.mock.callCount(), 1);
109+
assert.deepStrictEqual(generateClientConfigMock.mock.calls[0].arguments, [
110+
{
111+
name: 'test-branch',
112+
namespace: 'abc',
113+
type: 'branch',
114+
},
115+
'src',
116+
]);
117+
});
87118
});

packages/cli/src/commands/pipeline-deploy/pipeline_deploy_command.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export type PipelineDeployCommandOptions =
1212
type PipelineDeployCommandOptionsCamelCase = {
1313
branch: string;
1414
appId: string;
15+
configOutDir?: string;
1516
};
1617

1718
/**
@@ -61,7 +62,10 @@ export class PipelineDeployCommand
6162
await this.backendDeployer.deploy(backendId, {
6263
validateAppSources: true,
6364
});
64-
await this.clientConfigGenerator.generateClientConfigToFile(backendId);
65+
await this.clientConfigGenerator.generateClientConfigToFile(
66+
backendId,
67+
args['config-out-dir']
68+
);
6569
};
6670

6771
builder = (yargs: Argv): Argv<PipelineDeployCommandOptions> => {
@@ -79,6 +83,12 @@ export class PipelineDeployCommand
7983
type: 'string',
8084
array: false,
8185
})
86+
.option('config-out-dir', {
87+
describe:
88+
'A path to directory where config is written. If not provided defaults to current process working directory.',
89+
type: 'string',
90+
array: false,
91+
})
8292
.fail((msg, err) => {
8393
handleCommandFailure(msg, err, yargs);
8494
yargs.exit(1, err);

0 commit comments

Comments
 (0)