Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature/982: added option to execute after deploy #986

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ yargs
},
})
.command({
command: 'deploy [BU] [TYPE] [KEY] [--fromRetrieve] [--refresh]',
command: 'deploy [BU] [TYPE] [KEY] [--fromRetrieve] [--refresh] [--execute]',
aliases: ['d'],
desc: 'deploys local metadata to a business unit',
builder: (yargs) => {
Expand Down Expand Up @@ -75,6 +75,10 @@ yargs
type: 'boolean',
describe:
'optional for asset-message: runs refresh command for related triggeredSends after deploy',
})
.option('execute', {
type: 'boolean',
describe: 'optional for query: runs execute after deploy',
});
},
handler: (argv) => {
Expand Down
1 change: 1 addition & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class Mcdev {
'fromRetrieve',
'json',
'refresh',
'execute',
'skipInteraction',
'noLogFile',
];
Expand Down
10 changes: 10 additions & 0 deletions lib/metadataTypes/Query.js
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,16 @@ class Query extends MetadataType {
// delete local copy: retrieve/cred/bu/.../...-meta.sql
await super.postDeleteTasks(customerKey, [`${this.definition.type}-meta.sql`]);
}
/**
* Gets executed after deployment of metadata type
*
* @param metadata metadata mapped by their keyField
*/
static async postDeployTasks(metadata) {
if (Util.OPTIONS.execute) {
this.execute(Object.keys(metadata));
}
}
}

// Assign definition & cache to static attributes
Expand Down
12 changes: 12 additions & 0 deletions test/type.query.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,18 @@ describe('type: query', () => {
return;
});
it('Should change the key during update with --changeKeyValue');
it('Should deploy and execute with --execute', async () => {
handler.setOptions({ execute: true });
// WHEN
await handler.deploy('testInstance/testBU', ['query'], ['testNew_query']);
// THEN
assert.equal(
process.exitCode,
false,
'deploy with --execute should not have thrown an error'
);
return;
});
});
describe('Templating ================', () => {
it('Should create a query template via retrieveAsTemplate and build it', async () => {
Expand Down