Skip to content

Commit

Permalink
Merge pull request #520 from mit-27/update-connectorUpdate
Browse files Browse the repository at this point in the history
Update connectorUpdate script
  • Loading branch information
naelob authored Jun 20, 2024
2 parents d1c271f + fc03f21 commit 692b938
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions packages/api/scripts/connectorUpdate.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ function updateInitSQLFile(initSQLFile, newServiceDirs, vertical) {
let newLines = newServiceDirs
.map((serviceName) => {
const columnName = `${vertical.toLowerCase()}_${serviceName.toLowerCase()}`;
return ` ${columnName} boolean NOT NULL,\n`;
return ` ${columnName} boolean,\n`;
})
.join('');

Expand Down Expand Up @@ -376,10 +376,13 @@ function updateSeedSQLFile(seedSQLFile, newServiceDirs, vertical) {
fileContent = fileContent.replace(lastMatch[1], newColumnsSection);

// Update each VALUES section
fileContent = fileContent.replace(/VALUES(.*?);/gs, (match) => {
fileContent = fileContent.replace(/INSERT INTO connector_sets \(([^)]+)\) VALUES(.*?);/gs, (match) => {
return match
.replace(/\),\s*\(/g, '),\n (') // Fix line formatting
.replace(/\([^\)]+\)/g, (values) => {
.replace(/\([^\)]+\)/g, (values, index) => {
if (values.startsWith('(id_connector_set')) {
return values
}
let newValues = newColumns.map(() => 'TRUE').join(', ');
return values.slice(0, -1) + ', ' + newValues + ')';
});
Expand Down Expand Up @@ -439,13 +442,13 @@ function updateObjectTypes(baseDir, objectType, vertical) {
updateModuleFile(moduleFile, newServiceDirs, servicesDir);

// Path to the mappings file
const mappingsFile = path.join(
__dirname,
`../src/${vertical}/${objectType.toLowerCase()}/types/mappingsTypes.ts`,
);
// const mappingsFile = path.join(
// __dirname,
// `../src/${vertical}/${objectType.toLowerCase()}/types/mappingsTypes.ts`,
// );

// Call updateMappingsFile to update the mappings file with new services
updateMappingsFile(mappingsFile, newServiceDirs, objectType, vertical);
// // Call updateMappingsFile to update the mappings file with new services
// updateMappingsFile(mappingsFile, newServiceDirs, objectType, vertical);

const possibleProviderForImportStatements = getProvidersForImportStatements(
targetFile,
Expand Down

0 comments on commit 692b938

Please sign in to comment.