Skip to content

Commit

Permalink
#1470: improve folder loading - part 2
Browse files Browse the repository at this point in the history
  • Loading branch information
JoernBerkefeld committed Jul 22, 2024
1 parent a445f46 commit f5a0f22
Show file tree
Hide file tree
Showing 17 changed files with 1,013 additions and 55 deletions.
2 changes: 1 addition & 1 deletion @types/lib/Deployer.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 9 additions & 7 deletions lib/Deployer.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,13 +298,6 @@ class Deployer {
}
}

if (!Util.OPTIONS.fromRetrieve) {
await Deployer.createFolderDefinitions(
this.deployDir,
this.metadata,
Object.keys(this.metadata)
);
}
const foundDeployTypes = Object.keys(this.metadata)
// remove empty types
.filter((type) => Object.keys(this.metadata[type]).length)
Expand All @@ -318,6 +311,15 @@ class Deployer {
throw new Error('No metadata found for deployment');
}
const deployOrder = Util.getMetadataHierachy(foundDeployTypes);

if (!Util.OPTIONS.fromRetrieve) {
// run this AFTER identifying deployOrder or else ALL folders will be cached
await Deployer.createFolderDefinitions(
this.deployDir,
this.metadata,
Object.keys(this.metadata)
);
}
// build cache, including all metadata types which will be deployed (Avoids retrieve later)
for (const metadataType in deployOrder) {
const type = metadataType;
Expand Down
1 change: 0 additions & 1 deletion lib/metadataTypes/definitions/Folder.definition.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ export default {
folderTypesFromParent: [
'asset-shared',
'asset',
'hidden',
'shared_content',
'shared_data',
'shared_dataextension',
Expand Down
24 changes: 12 additions & 12 deletions test/general.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe('GENERAL', () => {

assert.equal(
testUtils.getAPIHistoryLength(),
38,
36,
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
);
return;
Expand Down Expand Up @@ -110,7 +110,7 @@ describe('GENERAL', () => {

assert.equal(
testUtils.getAPIHistoryLength(),
38,
36,
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
);
return;
Expand Down Expand Up @@ -159,7 +159,7 @@ describe('GENERAL', () => {

assert.equal(
testUtils.getAPIHistoryLength(),
38,
36,
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
);
return;
Expand Down Expand Up @@ -226,7 +226,7 @@ describe('GENERAL', () => {

assert.equal(
testUtils.getAPIHistoryLength(),
88,
83,
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
);
return;
Expand Down Expand Up @@ -287,7 +287,7 @@ describe('GENERAL', () => {

assert.equal(
testUtils.getAPIHistoryLength(),
88,
83,
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
);
return;
Expand Down Expand Up @@ -348,7 +348,7 @@ describe('GENERAL', () => {

assert.equal(
testUtils.getAPIHistoryLength(),
88,
83,
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
);
return;
Expand Down Expand Up @@ -695,7 +695,7 @@ describe('GENERAL', () => {
// download first before we test buildTemplate
await handler.retrieve('testInstance/testBU', ['automation', 'query']);

const expectedApiCallsRetrieve = 25;
const expectedApiCallsRetrieve = 24;
assert.equal(
testUtils.getAPIHistoryLength(),
expectedApiCallsRetrieve,
Expand Down Expand Up @@ -800,7 +800,7 @@ describe('GENERAL', () => {
});

it('buildTemplate + buildDefinition for multiple types with keys and --retrieve', async () => {
const expectedApiCallsRetrieve = 28;
const expectedApiCallsRetrieve = 27;

// preparation
const argvMetadata = [
Expand Down Expand Up @@ -1158,7 +1158,7 @@ describe('GENERAL', () => {
// download first before we test buildTemplate
await handler.retrieve('testInstance/testBU', ['automation', 'query']);

const expectedApiCallsRetrieve = 25;
const expectedApiCallsRetrieve = 24;
assert.equal(
testUtils.getAPIHistoryLength(),
expectedApiCallsRetrieve,
Expand Down Expand Up @@ -1350,7 +1350,7 @@ describe('GENERAL', () => {
// download first before we test buildTemplate
await handler.retrieve('testInstance/testBU', ['automation', 'query']);

const expectedApiCallsRetrieve = 25;
const expectedApiCallsRetrieve = 24;
assert.equal(
testUtils.getAPIHistoryLength(),
expectedApiCallsRetrieve,
Expand Down Expand Up @@ -1658,7 +1658,7 @@ describe('GENERAL', () => {
// download first before we test buildTemplate
await handler.retrieve('testInstance/testBU', ['automation', 'query']);

const expectedApiCallsRetrieve = 25;
const expectedApiCallsRetrieve = 24;
assert.equal(
testUtils.getAPIHistoryLength(),
expectedApiCallsRetrieve,
Expand Down Expand Up @@ -2284,7 +2284,7 @@ describe('GENERAL', () => {
);
assert.equal(
testUtils.getAPIHistoryLength(),
9,
8,
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,29 +293,6 @@
<IsEditable>false</IsEditable>
<AllowChildren>false</AllowChildren>
</Results>
<Results xsi:type="DataFolder">
<Client>
<ID>1111111</ID>
</Client>
<PartnerKey xsi:nil="true" />
<CreatedDate>2021-02-07T10:44:01.413</CreatedDate>
<ModifiedDate>2021-12-16T03:43:33.38</ModifiedDate>
<ID>639967</ID>
<ObjectID xsi:nil="true" />
<CustomerKey />
<ParentFolder>
<PartnerKey xsi:nil="true" />
<ID>89355</ID>
<ObjectID xsi:nil="true" />
<CustomerKey>dataextension_default</CustomerKey>
</ParentFolder>
<Name>TestAudiences</Name>
<Description />
<ContentType>dataextension</ContentType>
<IsActive>true</IsActive>
<IsEditable>true</IsEditable>
<AllowChildren>true</AllowChildren>
</Results>
<Results xsi:type="DataFolder">
<Client>
<ID>1111111</ID>
Expand Down
Loading

0 comments on commit f5a0f22

Please sign in to comment.