Skip to content

Commit

Permalink
#38: retrieve, change key deploy and cache dependent DRAFT
Browse files Browse the repository at this point in the history
  • Loading branch information
phjulia committed Jun 28, 2023
1 parent b4ebec4 commit df7301c
Showing 1 changed file with 61 additions and 7 deletions.
68 changes: 61 additions & 7 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,7 @@ class Mcdev {
static async _fixKeysBU(cred, bu, type, keyArr) {
const properties = await config.getProperties();
let counter_failed = 0;
const toDeploy = [];
const buObject = await Cli.getCredentialObject(
properties,
cred === null ? null : cred + '/' + bu,
Expand All @@ -940,15 +941,68 @@ class Mcdev {
Util.logger.error(ex.message);
return;
}
Util.logger.info('First retrieve');
await this._retrieveBU(cred, bu, type, keyArr);
Util.logger.info(`First retrieve ${type}`);
const retriever = new Retriever(properties, buObject);
const retrieved = await retriever.retrieve(type, keyArr, null, false);
Object.keys(retrieved).forEach((key) => {
//console.log(Object.values(retrieved[key][0])[0]);
//console.log(Object.values(retrieved[key][0]));
for (const item of Object.values(retrieved[key][0])) {
// console.log(item);
if (item != null) {
// console.log('name: ', item.name);
// console.log('key: ', item.key);
if (item.name != item.key) {
// console.log(item.key);
toDeploy.push(item.key);
// console.log('item.key', item.key);
Util.logger.info(`Updating key for query ${item.key}`);
} else {
Util.logger.info(
` ☇ skipping query ${item.key} - key does not need to be updated`
);
}
} else {
Util.logger.error(`${item.key} not found on server.`);
}
}
});

//console.log(Object.values(Object.values(retrieved)[0]));
// console.log(Object.values(retrieved)[0]);
// console.log(Array.isArray(Object.values(retrieved)[0]));
// console.log(Object.values(retrieved));
// console.log(Object.values(retrieved));
// let i = 0;
// for (const item of Object.keys(retrieved)) {
// console.log(Object.values(retrieved[key][0])[0])

// if (Object.values(item)[0] != null) {
// console.log('name: ', Object.values(item)[0].name);
// console.log('key: ', Object.values(item)[0].key);
// if (Object.values(item)[0].name != Object.values(item)[0].key) {
// console.log(Object.values(item)[0].key);
// // toDeploy.push(Object.values(item)[0].key);
// console.log('Object.values(item)[0].key', Object.values(item)[0].key);
// Util.logger.info(`Updating key for query ${Object.values(item)[0].key}`);
// } else {
// Util.logger.info(
// ` ☇ skipping query ${
// Object.values(item)[0].key
// } - key does not need to be updated`
// );
// }
// } else {
// Util.logger.error(`${Object.values(item)[0].key} not found on server.`);
// }
// }

console.log('******************************************', toDeploy);
Util.OPTIONS.changeKeyField = MetadataTypeDefinitions[type].nameField;
const properties = await config.getProperties();
if (!(await config.checkProperties(properties))) {
return null;
}
properties.directories.deploy = properties.directories.retrieve;
return await Deployer._deployBU(cred, bu, properties, type, keyArr, true);
await Deployer._deployBU(cred, bu, properties, type, toDeploy, true);
console.log(MetadataTypeDefinitions[type].dependencies);
this._retrieveBU(cred, bu, MetadataTypeDefinitions[type].dependencies);
} catch (ex) {
Util.logger.errorStack(ex, 'mcdev.fixKeys failed');
}
Expand Down

0 comments on commit df7301c

Please sign in to comment.