@itentialopensource/adapter-f5_bigiq 0.5.7 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/.eslintrc.js +1 -0
  2. package/AUTH.md +4 -4
  3. package/BROKER.md +4 -4
  4. package/CALLS.md +621 -9
  5. package/ENHANCE.md +3 -3
  6. package/PROPERTIES.md +24 -9
  7. package/README.md +24 -23
  8. package/SUMMARY.md +2 -2
  9. package/SYSTEMINFO.md +1 -1
  10. package/TAB1.md +2 -2
  11. package/TAB2.md +9 -5
  12. package/TROUBLESHOOT.md +10 -1
  13. package/UTILITIES.md +473 -0
  14. package/adapter.js +11315 -5
  15. package/adapterBase.js +52 -16
  16. package/entities/BIGIPAuthentication/action.json +106 -0
  17. package/entities/BIGIPAuthentication/schema.json +23 -0
  18. package/entities/BIGIPConfigurationManagement/action.json +310 -0
  19. package/entities/BIGIPConfigurationManagement/schema.json +33 -0
  20. package/entities/BIGIPLocalTrafficManager/action.json +1042 -0
  21. package/entities/BIGIPLocalTrafficManager/schema.json +69 -0
  22. package/entities/BIGIPNetwork/action.json +432 -0
  23. package/entities/BIGIPNetwork/schema.json +39 -0
  24. package/entities/BIGIPSystem/action.json +209 -0
  25. package/entities/BIGIPSystem/schema.json +28 -0
  26. package/package.json +24 -28
  27. package/pronghorn.json +5973 -13
  28. package/propertiesSchema.json +68 -7
  29. package/report/adapterInfo.json +8 -8
  30. package/report/auto-adapter-openapi.json +20632 -0
  31. package/report/updateReport1748555375038.json +120 -0
  32. package/sampleProperties.json +4 -0
  33. package/test/integration/adapterTestBasicGet.js +88 -54
  34. package/test/integration/adapterTestConnectivity.js +15 -16
  35. package/test/integration/adapterTestIntegration.js +2597 -38
  36. package/test/unit/adapterBaseTestUnit.js +641 -39
  37. package/test/unit/adapterTestUnit.js +4822 -61
  38. package/utils/adapterInfo.js +114 -164
  39. package/utils/argParser.js +44 -0
  40. package/utils/checkMigrate.js +77 -38
  41. package/utils/entitiesToDB.js +53 -42
  42. package/utils/logger.js +26 -0
  43. package/utils/modify.js +56 -55
  44. package/utils/mongoDbConnection.js +79 -0
  45. package/utils/mongoUtils.js +162 -0
  46. package/utils/taskMover.js +31 -32
  47. package/utils/tbScript.js +36 -172
  48. package/utils/tbUtils.js +84 -226
  49. package/utils/troubleshootingAdapter.js +68 -84
  50. package/utils/updateAdapterConfig.js +158 -0
  51. package/utils/addAuth.js +0 -94
  52. package/utils/artifactize.js +0 -146
  53. package/utils/basicGet.js +0 -50
  54. package/utils/packModificationScript.js +0 -35
  55. package/utils/patches2bundledDeps.js +0 -90
package/utils/modify.js CHANGED
@@ -1,29 +1,7 @@
1
1
  const { execSync } = require('child_process');
2
2
  const fs = require('fs-extra');
3
- const Ajv = require('ajv');
4
3
  const rls = require('readline-sync');
5
4
  const { existsSync } = require('fs-extra');
6
- const { getAdapterConfig } = require('./tbUtils');
7
- const { name } = require('../package.json');
8
- const propertiesSchema = require('../propertiesSchema.json');
9
-
10
- const flags = process.argv[2];
11
-
12
- /**
13
- * @summary Updates database instance with new adapter properties
14
- *
15
- * @function updateServiceItem
16
- */
17
- async function updateServiceItem() {
18
- const { database, serviceItem } = await getAdapterConfig();
19
- const currentProps = serviceItem.properties.properties;
20
- const ajv = new Ajv({ allErrors: true, useDefaults: true });
21
- const validate = ajv.compile(propertiesSchema);
22
- validate(currentProps);
23
- console.log('Updating Properties...');
24
- await database.collection('service_configs').updateOne({ model: name }, { $set: serviceItem });
25
- console.log('Properties Updated');
26
- }
27
5
 
28
6
  /**
29
7
  * @summary Creates a backup zip file of current adapter
@@ -70,21 +48,20 @@ function revertMod() {
70
48
  fs.removeSync(file);
71
49
  }
72
50
  });
73
- // // unzip previousVersion, reinstall dependencies and delete zipfile
51
+ // unzip previousVersion, reinstall dependencies and delete zipfile
74
52
  execSync('unzip -o previousVersion.zip && rm -rf node_modules && rm package-lock.json && npm install', { maxBuffer: 1024 * 1024 * 2 });
75
53
  execSync('rm previousVersion.zip');
76
54
  console.log('Changes have been reverted');
77
55
  }
78
56
 
79
- // Main Script
80
-
81
- // Migrate
82
- if (flags === '-m') {
83
- if (!fs.existsSync('migrationPackage.zip')) {
84
- console.log('Migration Package not found. Download and place migrationPackage in the adapter root directory');
85
- process.exit();
57
+ /**
58
+ * @summary Handle migration logic
59
+ */
60
+ function handleMigration() {
61
+ if (!existsSync('migrationPackage.zip')) {
62
+ throw new Error('Migration Package not found. Download and place migrationPackage in the adapter root directory');
86
63
  }
87
- // Backup current adapter
64
+
88
65
  backup();
89
66
  console.log('Migrating adapter and running tests...');
90
67
  const migrateCmd = 'unzip -o migrationPackage.zip'
@@ -92,61 +69,85 @@ if (flags === '-m') {
92
69
  + ' && node migrate';
93
70
  const migrateOutput = execSync(migrateCmd, { encoding: 'utf-8' });
94
71
  console.log(migrateOutput);
95
- if (migrateOutput.indexOf('Lint exited with code 1') >= 0
96
- || migrateOutput.indexOf('Tests exited with code 1') >= 0) {
72
+
73
+ if (migrateOutput.includes('Lint exited with code 1') || migrateOutput.includes('Tests exited with code 1')) {
97
74
  if (rls.keyInYN('Adapter failed tests or lint after migrating. Would you like to revert the changes?')) {
98
75
  console.log('Reverting changes...');
99
76
  revertMod();
100
- process.exit();
77
+ throw new Error('Adapter failed tests or lint after migrating. Changes reverted');
101
78
  }
102
79
  console.log('Adapter Migration will continue. If you want to revert the changes, run the command npm run adapter:revert');
103
80
  }
81
+
104
82
  console.log('Installing new dependencies..');
105
83
  const updatePackageCmd = 'rm -rf node_modules && rm package-lock.json && npm install';
106
84
  const updatePackageOutput = execSync(updatePackageCmd, { encoding: 'utf-8' });
107
85
  console.log(updatePackageOutput);
108
86
  console.log('New dependencies installed');
109
- console.log('Updating adapter properties..');
110
- updateServiceItem().then(() => {
111
- console.log('Adapter Successfully Migrated. Restart adapter in IAP to apply the changes');
112
- archiveMod('MIG');
113
- process.exit();
114
- });
87
+ archiveMod('MIG');
115
88
  }
116
89
 
117
- // Update
118
- if (flags === '-u') {
119
- if (!fs.existsSync('updatePackage.zip')) {
120
- console.log('Update Package not found. Download and place updateAdapter.zip in the adapter root directory');
121
- process.exit();
90
+ /**
91
+ * @summary Handle update logic
92
+ */
93
+ function handleUpdate() {
94
+ if (!existsSync('updatePackage.zip')) {
95
+ throw new Error('Update Package not found. Download and place updateAdapter.zip in the adapter root directory');
122
96
  }
123
- // Backup current adapter
97
+
124
98
  backup();
125
99
  const updateCmd = 'unzip -o updatePackage.zip'
126
100
  + ' && cd adapter_modifications'
127
101
  + ' && node update.js updateFiles';
128
102
  execSync(updateCmd, { encoding: 'utf-8' });
129
103
  const updateOutput = execSync(updateCmd, { encoding: 'utf-8' });
130
- if (updateOutput.indexOf('Lint exited with code 1') >= 0
131
- || updateOutput.indexOf('Tests exited with code 1') >= 0) {
104
+
105
+ if (updateOutput.includes('Lint exited with code 1') || updateOutput.includes('Tests exited with code 1')) {
132
106
  if (rls.keyInYN('Adapter failed tests or lint after updating. Would you like to revert the changes?')) {
133
107
  console.log('Reverting changes...');
134
108
  revertMod();
135
- process.exit();
109
+ throw new Error('Adapter failed tests or lint after updating. Changes reverted');
136
110
  }
137
111
  console.log('Adapter Update will continue. If you want to revert the changes, run the command npm run adapter:revert');
138
112
  }
113
+
139
114
  console.log(updateOutput);
140
115
  console.log('Adapter Successfully Updated. Restart adapter in IAP to apply the changes');
141
116
  archiveMod('UPD');
142
- process.exit();
143
117
  }
144
118
 
145
- // Revert
146
- if (flags === '-r') {
147
- if (!fs.existsSync('previousVersion.zip')) {
148
- console.log('Previous adapter version not found. There are no changes to revert');
149
- process.exit();
119
+ /**
120
+ * @summary Handle revert logic
121
+ */
122
+ function handleRevert() {
123
+ if (!existsSync('previousVersion.zip')) {
124
+ throw new Error('Previous adapter version not found. There are no changes to revert');
150
125
  }
151
126
  revertMod();
152
127
  }
128
+
129
+ /**
130
+ * @summary Entrypoint for the script
131
+ */
132
+ function main() {
133
+ const flags = process.argv[2];
134
+
135
+ switch (flags) {
136
+ case '-m':
137
+ return handleMigration();
138
+ case '-u':
139
+ return handleUpdate();
140
+ case '-r':
141
+ return handleRevert();
142
+ default:
143
+ throw new Error('Invalid flag. Use -m for migrate, -u for update, or -r for revert.');
144
+ }
145
+ }
146
+
147
+ try {
148
+ main();
149
+ process.exit(0);
150
+ } catch (error) {
151
+ console.error(error.message || error);
152
+ process.exit(1);
153
+ }
@@ -0,0 +1,79 @@
1
+ // Set globals
2
+ /* global log */
3
+
4
+ const { MongoClient } = require('mongodb');
5
+ const MongoUtils = require('./mongoUtils');
6
+
7
+ class MongoDBConnection {
8
+ constructor(properties) {
9
+ this.properties = properties;
10
+ this.initialize(properties);
11
+ }
12
+
13
+ initialize(properties) {
14
+ const {
15
+ url, database, maxPoolSize, appname
16
+ } = properties;
17
+
18
+ // Handle URL first - if provided, it takes precedence
19
+ if (url) {
20
+ const urlObj = new URL(url);
21
+ const urlDbName = urlObj.pathname.slice(1);
22
+ this.dbName = database || urlDbName;
23
+
24
+ // Update URL if database name is different
25
+ if (this.dbName !== urlDbName) {
26
+ urlObj.pathname = `${this.dbName}`;
27
+ }
28
+
29
+ this.url = urlObj.toString();
30
+ } else {
31
+ const connectionObj = MongoUtils.generateConnectionObj(properties);
32
+ this.url = MongoUtils.generateConnectionString(connectionObj);
33
+ this.dbName = database;
34
+ }
35
+
36
+ // Set options using generateTlsSettings
37
+ this.options = MongoUtils.generateTlsSettings(properties);
38
+
39
+ // Add maxPoolSize if configured
40
+ if (maxPoolSize > 0 && maxPoolSize <= 65535) {
41
+ this.options.maxPoolSize = maxPoolSize;
42
+ }
43
+
44
+ // Add application name if provided
45
+ if (appname) {
46
+ this.options.appname = appname;
47
+ }
48
+ }
49
+
50
+ async closeConnection() {
51
+ if (this.connection && this.connection.close) {
52
+ try {
53
+ await this.connection.close();
54
+ } catch (err) {
55
+ log.error(`Failed to close MongoDB connection - ${err.message}`);
56
+ }
57
+ }
58
+ }
59
+
60
+ async connect() {
61
+ const client = new MongoClient(this.url, this.options);
62
+
63
+ client.on('serverHeartbeatSucceeded', (msg) => log.info(`Connection established and heartbeat succeeded - ${JSON.stringify(msg)}`));
64
+ client.on('connectionClosed', (msg) => log.info(`Connection closed - ${JSON.stringify(msg)}`));
65
+ client.on('error', (msg) => log.error(`Connection error - ${JSON.stringify(msg)}`));
66
+ client.on('commandFailed', (msg) => log.error(`Command failed - ${JSON.stringify(msg)}`));
67
+ client.on('serverHeartbeatFailed', (msg) => log.error(`Connection timeout - ${JSON.stringify(msg)}`));
68
+
69
+ await client.connect().catch((error) => {
70
+ throw new Error(MongoUtils.resolveMongoError(error));
71
+ });
72
+
73
+ this.db = client.db(this.dbName);
74
+ this.connection = client;
75
+ return this;
76
+ }
77
+ }
78
+
79
+ module.exports = MongoDBConnection;
@@ -0,0 +1,162 @@
1
+ const fs = require('fs-extra');
2
+
3
+ class MongoUtils {
4
+ /**
5
+ * Parses a MongoDB connection string and extracts its components.
6
+ * @param {string} connectionString - The MongoDB connection string.
7
+ * @returns {object} Parsed connection details.
8
+ */
9
+ static parseConnectionString(connectionString) {
10
+ try {
11
+ const url = new URL(connectionString);
12
+ return {
13
+ protocol: url.protocol.replace(':', ''),
14
+ host: url.hostname,
15
+ port: url.port || '27017',
16
+ database: url.pathname.replace('/', ''),
17
+ username: url.username || null,
18
+ password: url.password || null,
19
+ options: Object.fromEntries(url.searchParams.entries())
20
+ };
21
+ } catch (error) {
22
+ throw new Error(`Invalid MongoDB URI: ${error.message}`);
23
+ }
24
+ }
25
+
26
+ /**
27
+ * Generates a MongoDB connection string from given properties.
28
+ * @param {object} config - MongoDB connection properties.
29
+ * @returns {string} A valid MongoDB connection string.
30
+ */
31
+ static generateConnectionString(config) {
32
+ // Determine protocol based on addSrv flag
33
+ const protocol = config.addSrv ? 'mongodb+srv' : 'mongodb';
34
+
35
+ // Build authentication part if credentials are provided and dbAuth is true
36
+ const authPart = (config.dbAuth && config.username && config.password)
37
+ ? `${encodeURIComponent(config.username)}:${encodeURIComponent(config.password)}@`
38
+ : '';
39
+
40
+ // Build host and port part
41
+ const hostPart = config.host;
42
+ const portPart = !config.addSrv && config.port ? `:${config.port}` : '';
43
+
44
+ // Build options part
45
+ let optionsPart = '';
46
+ if (config.options && Object.keys(config.options).length) {
47
+ optionsPart = `?${new URLSearchParams(config.options).toString()}`;
48
+ }
49
+
50
+ // Build database part
51
+ const dbPart = config.database ? `/${config.database}` : '';
52
+
53
+ return `${protocol}://${authPart}${hostPart}${portPart}${dbPart}${optionsPart}`;
54
+ }
55
+
56
+ /**
57
+ * Generates TLS settings for MongoDB connection
58
+ * @param {object} properties - Connection properties containing TLS configuration
59
+ * @returns {object} TLS settings object
60
+ */
61
+ static generateTlsSettings(properties) {
62
+ // Handle TLS properties
63
+ if (properties.tls) {
64
+ return {
65
+ tls: properties.tls.enabled,
66
+ tlsAllowInvalidCertificates: properties.tls.tlsAllowInvalidCertificates || false,
67
+ tlsCAFile: properties.tls.tlsCAFile
68
+ };
69
+ }
70
+
71
+ // Handle db_ssl properties (standard adapter format)
72
+ if (!properties.db_ssl) {
73
+ return { tls: false };
74
+ }
75
+
76
+ const tlsProperties = {
77
+ tls: properties.db_ssl.enabled || false,
78
+ tlsAllowInvalidCertificates: properties.db_ssl.accept_invalid_cert || false
79
+ };
80
+
81
+ const hasValidCaFile = properties.db_ssl.enabled && properties.db_ssl.ca_file && fs.existsSync(properties.db_ssl.ca_file);
82
+
83
+ if (hasValidCaFile) {
84
+ tlsProperties.tlsCAFile = properties.db_ssl.ca_file;
85
+ }
86
+
87
+ return tlsProperties;
88
+ }
89
+
90
+ /**
91
+ * Generates a connection object from properties
92
+ * @param {object} properties - Connection properties
93
+ * @returns {object} Connection object with host, port, database, and credentials
94
+ */
95
+ static generateConnectionObj(properties) {
96
+ try {
97
+ const connectionObj = {
98
+ host: properties.host,
99
+ port: properties.port,
100
+ database: properties.database,
101
+ addSrv: properties.addSrv || false,
102
+ dbAuth: properties.dbAuth || false,
103
+ options: properties.replSet && !properties.addSrv ? { replicaSet: properties.replSet } : undefined
104
+ };
105
+
106
+ // Only include credentials if dbAuth is true
107
+ if (properties.dbAuth) {
108
+ // Validate that both username and password are provided when dbAuth is true
109
+ if (!properties.username || !properties.password) {
110
+ throw new Error('Both username and password are required when dbAuth is enabled');
111
+ }
112
+ connectionObj.username = properties.username;
113
+ connectionObj.password = properties.password;
114
+ }
115
+
116
+ return connectionObj;
117
+ } catch (error) {
118
+ throw new Error(`Invalid MongoDB configuration: ${error.message}`);
119
+ }
120
+ }
121
+
122
+ /**
123
+ * Resolves MongoDB error messages to user-friendly format
124
+ * @param {object} mongoError - The MongoDB error object
125
+ * @returns {string} User-friendly error message
126
+ */
127
+ static resolveMongoError(mongoError) {
128
+ if (mongoError && mongoError.code === 13) {
129
+ return 'User unauthorized to perform the requested action: ';
130
+ }
131
+ if (mongoError && mongoError.code === 18) {
132
+ return `User Authentication failed. Username/Password combination is incorrect ${mongoError}`;
133
+ }
134
+ return mongoError;
135
+ }
136
+
137
+ /**
138
+ * Helper function to validate and process MongoDB connection properties
139
+ * @param {Object} mongoProps - MongoDB connection properties to validate
140
+ * @returns {Object|undefined} - Validated and processed MongoDB properties or undefined if invalid
141
+ */
142
+ static getAndValidateMongoProps(mongoProps) {
143
+ if (!mongoProps) return undefined;
144
+
145
+ // Handle URL-based connection
146
+ const url = mongoProps.url && mongoProps.url.trim();
147
+ if (!url) {
148
+ // Handle host-based connection
149
+ const hasHost = mongoProps.hostname || mongoProps.host;
150
+ const hasDatabase = mongoProps.database;
151
+ return (hasHost && hasDatabase) ? mongoProps : undefined;
152
+ }
153
+
154
+ // Process URL-based connection
155
+ const props = { ...mongoProps };
156
+ const { database } = props;
157
+ const urlHasDatabase = database && url.includes(`/${database}`);
158
+ return urlHasDatabase ? props : { ...props, url: `${url}/${database}` };
159
+ }
160
+ }
161
+
162
+ module.exports = MongoUtils;
@@ -9,30 +9,32 @@ const blacklistTasks = [
9
9
  ];
10
10
 
11
11
  const adapterBaseTasks = [
12
- 'getDevicesFiltered',
13
- 'isAlive',
14
- 'getConfig',
15
- 'getDevice',
16
- 'iapUpdateAdapterConfiguration',
17
- 'iapFindAdapterPath',
18
- 'iapSuspendAdapter',
19
- 'iapUnsuspendAdapter',
20
- 'iapGetAdapterQueue',
21
- 'iapTroubleshootAdapter',
22
- 'iapRunAdapterHealthcheck',
23
- 'iapRunAdapterConnectivity',
24
- 'iapRunAdapterBasicGet',
25
- 'iapMoveAdapterEntitiesToDB',
26
- 'getDevice',
27
- 'getDevicesFiltered',
28
- 'isAlive',
29
- 'getConfig',
30
- 'iapGetDeviceCount',
31
- 'iapRunAdapterLint',
32
- 'iapRunAdapterTests',
33
- 'iapGetAdapterInventory'
12
+ 'getDevicesFiltered',
13
+ 'isAlive',
14
+ 'getConfig',
15
+ 'getDevice',
16
+ 'iapUpdateAdapterConfiguration',
17
+ 'iapFindAdapterPath',
18
+ 'iapSuspendAdapter',
19
+ 'iapUnsuspendAdapter',
20
+ 'iapGetAdapterQueue',
21
+ 'iapTroubleshootAdapter',
22
+ 'iapRunAdapterHealthcheck',
23
+ 'iapRunAdapterConnectivity',
24
+ 'iapRunAdapterBasicGet',
25
+ 'iapMoveAdapterEntitiesToDB',
26
+ 'getDevice',
27
+ 'getDevicesFiltered',
28
+ 'isAlive',
29
+ 'getConfig',
30
+ 'iapGetDeviceCount',
31
+ 'iapRunAdapterLint',
32
+ 'iapRunAdapterTests',
33
+ 'iapGetAdapterInventory'
34
34
  ];
35
35
 
36
+ let shouldExitWithFailure = false;
37
+
36
38
  function updatePronghorn(tasks, original, updated) {
37
39
  const originalFile = require(original);
38
40
  const unusedMethods = [];
@@ -57,15 +59,13 @@ function updatePronghorn(tasks, original, updated) {
57
59
  return 'Done';
58
60
  }
59
61
 
60
- function flipTaskFlag(task, pronghornPath, value)
61
- {
62
+ function flipTaskFlag(task, pronghornPath, value) {
62
63
  const pronghorn = require(pronghornPath);
63
64
  const index = pronghorn.methods.findIndex((method) => method.name === task);
64
65
  pronghorn.methods[index] = { ...pronghorn.methods[index], task: value };
65
66
  fs.writeFileSync(pronghornPath, JSON.stringify(pronghorn, null, 2));
66
67
  }
67
68
 
68
- //Return array of relevant paths given adapter directory
69
69
  function createPaths(currentAdapter) {
70
70
  const paths = [];
71
71
  const filePaths = [
@@ -86,12 +86,8 @@ function insert(str, index, value) {
86
86
  return str.substr(0, index) + value + str.substr(index);
87
87
  }
88
88
 
89
- //modify adapter js
90
- //original - path to file containing tasks we want to remove
91
- // updated - path to file we want to move the tasks to
92
89
  function updateAdapterJs(tasks, original, updated, adapterDir) {
93
90
  if (!fs.existsSync(original)) {
94
- //could do this or just let the error ocurr lower down and catch in warpper
95
91
  throw new Error(`Original file ${original} does not exist.`);
96
92
  }
97
93
  let originalFile = fs.readFileSync(original, 'utf8');
@@ -99,7 +95,6 @@ function updateAdapterJs(tasks, original, updated, adapterDir) {
99
95
  if (!fs.existsSync(updated)) {
100
96
  const adapterExport = require(`${adapterDir}/pronghorn.json`).export;
101
97
  updatedFile = `/* @copyright Itential, LLC 2019 */\n\n/* eslint import/no-dynamic-require: warn */\n/* eslint no-unused-vars: warn */\n/* global log */\n\nconst path = require('path');\n\nconst AdapterBaseCl = require(path.join(__dirname, 'adapterBase.js'));\n\nclass ${adapterExport}Inactive extends AdapterBaseCl {}\n`;
102
- //To do handles backup files where og doesn't exist
103
98
  } else {
104
99
  updatedFile = fs.readFileSync(updated, 'utf8');
105
100
  }
@@ -223,6 +218,7 @@ function activateTasks(adapterDir, tasks) {
223
218
  return 'success';
224
219
  } catch (e) {
225
220
  console.log(`Error: ${e} ocurred during execution. Rolling back changes.`);
221
+ shouldExitWithFailure = true;
226
222
  for (let i = 0; i < backupFiles.length; i++) {
227
223
  const file = fs.readFileSync(backupFiles[i], 'utf8');
228
224
  fs.writeFileSync(filePaths[i], file, 'utf8');
@@ -233,7 +229,6 @@ function activateTasks(adapterDir, tasks) {
233
229
  }
234
230
  });
235
231
  deleteBackups(adapterDir);
236
- process.exit(1);
237
232
  }
238
233
  }
239
234
 
@@ -290,6 +285,7 @@ function deactivateTasks(adapterDir, tasks) {
290
285
  return 'success';
291
286
  } catch (e) {
292
287
  console.log(`Error: ${e} ocurred during execution. Rolling back changes.`);
288
+ shouldExitWithFailure = true;
293
289
  for (let i = 0; i < backupFiles.length; i++) {
294
290
  const file = fs.readFileSync(backupFiles[i], 'utf8');
295
291
  fs.writeFileSync(filePaths[i], file, 'utf8');
@@ -300,10 +296,13 @@ function deactivateTasks(adapterDir, tasks) {
300
296
  }
301
297
  });
302
298
  deleteBackups(adapterDir);
303
- process.exit(1);
304
299
  }
305
300
  }
306
301
 
302
+ if (shouldExitWithFailure) {
303
+ process.exit(1);
304
+ }
305
+
307
306
  module.exports = {
308
307
  activateTasks, deactivateTasks, rollbackChanges, deleteBackups
309
308
  };