@tangelo/tangelo-configuration-toolkit 1.13.0 → 1.14.1

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.
@@ -2,7 +2,10 @@ const {execSync, spawn} = require('child_process');
2
2
  const {chdir} = require('process');
3
3
  const inquirer = require('inquirer');
4
4
  const path = require('path');
5
+ const fs = require('fs-extra');
5
6
 
7
+ const execGitCommand = require('../../lib/exec-git-command');
8
+ const getTdiBranch = require('../../lib/get-tdi-branch');
6
9
 
7
10
  const cmdExec = commands => new Promise(resolve => {
8
11
  let promise = new Promise(resolve => resolve());
@@ -21,7 +24,7 @@ const cmdExec = commands => new Promise(resolve => {
21
24
  cp.stdout.on('data', log);
22
25
  cp.stderr.setEncoding('utf8');
23
26
  cp.stderr.on('data', log);
24
- cp.on('close', code => {
27
+ cp.on('close', () => {
25
28
  if (!a[i+1] || a[i+1][1]) _write();
26
29
  resolve();
27
30
  });
@@ -33,6 +36,8 @@ const cmdExec = commands => new Promise(resolve => {
33
36
  });
34
37
  });
35
38
 
39
+ const tdiMigrationFilePath = path.join(_paths.repo, _paths.tdi, 'tct/git/tdiCommitsRequiringMigration.js');
40
+
36
41
  module.exports = function git (argv) {
37
42
 
38
43
  if (argv.init) {
@@ -112,4 +117,94 @@ module.exports = function git (argv) {
112
117
  throw e;
113
118
  });
114
119
  }
120
+
121
+ if (argv.update) {
122
+ const [update, tdiFromDateCustom, tdiToDateCustom] = `${argv.update}`.split(/\s/);
123
+
124
+ if (update === `tdi`) {
125
+
126
+ const tdiBranch = getTdiBranch(argv.branch);
127
+ const tdiBranchUpgrade = tdiBranch.from ? (tdiBranch.from.name < tdiBranch.name) : false;
128
+
129
+ if (tdiBranchUpgrade) _info(`Current branch '${tdiBranch.from.name}' will be updated to '${tdiBranch.name}'\nCommon ancestor will be used in selecting TDI commits requiring migration: ${_formatDate(tdiBranch.commonAncestor.date)}`);
130
+ _info(`Branch ${tdiBranch.name} is ${tdiBranch.commitsBehind} commits behind.`);
131
+
132
+ // Set branch in .gitmodules file; This ensures submodule update will follow this branch to the latest commit
133
+ const setBranch = execGitCommand(`submodule set-branch -b ${tdiBranch.name} tangelo-default-implementation`, _paths.repo);
134
+ if (setBranch.error) _error(`Set branch failed: ${setBranch.error}`);
135
+
136
+ if (tdiBranch.commitsBehind > 0 || tdiFromDateCustom) {
137
+ // update submodule
138
+ const updateSubmoduleMsg = execGitCommand(`submodule update --remote`, _paths.repo);
139
+ if (updateSubmoduleMsg.error && !tdiFromDateCustom) _error(`Update submodule failed\n${updateSubmoduleMsg.error}`);
140
+
141
+ if (!tdiFromDateCustom) _info(`TDI submodule updated:\n${updateSubmoduleMsg}`);
142
+
143
+ // tdiMigrationFilePath should exist in latest commits of releases 5.3+; As we updated to the latest version this should work
144
+ if (fs.existsSync(tdiMigrationFilePath)) {
145
+ const migrations = require(tdiMigrationFilePath);
146
+ const fromTdiDate = tdiFromDateCustom ? new Date(tdiFromDateCustom) : (tdiBranch.commonAncestor) ? tdiBranch.commonAncestor.date: _git.commitTdi.local().date;
147
+ const toTdiDate = tdiToDateCustom ? new Date(tdiToDateCustom) : new Date(execGitCommand(`log -1 --format=%cd --date=iso-strict`, path.join(_paths.repo, _paths.tdi), ['date']).date);
148
+
149
+ _info(`TDI commits requiring migration between ${_formatDate(fromTdiDate)} and ${_formatDate(toTdiDate)}`);
150
+ // Filter the migrations that should be applied/considered; Also display older releases migrations
151
+ const migrationsFiltered = migrations
152
+ .filter((m) => m.releases.find((r) => {
153
+ const time = new Date(r.date).getTime();
154
+ return ((tdiBranchUpgrade)
155
+ ? `release/${r.release}` == tdiBranch.name || (tdiBranch.from.name <= `release/${r.release}` && `release/${r.release}` < tdiBranch.name && (fromTdiDate.getTime() < time && time < toTdiDate.getTime()))
156
+ : `release/${r.release}` == tdiBranch.name && (fromTdiDate.getTime() < time && time < toTdiDate.getTime())
157
+ );
158
+ })
159
+ );
160
+
161
+ let relevantMigrationCount = 0;
162
+ // Apply callback for migrations
163
+ migrationsFiltered
164
+ .forEach((m) => {
165
+ const date = _formatDate(new Date(m.releases.filter((r) => tdiBranch.name >= `release/${r.release}`)[0].date));
166
+ relevantMigrationCount += (m.callback(date, relevantMigrationCount+1)) === 1 ? 1 : 0;
167
+ });
168
+
169
+ // Output message based on whether or not migrations are required
170
+ if (migrationsFiltered.length === 0) {
171
+ _write(`-- No commits require migrations --`);
172
+ } else {
173
+ _info(`\n${relevantMigrationCount} relevant migration(s) out of ${migrationsFiltered.length} migration(s) are shown.`);
174
+ _info(`See confluence page 'TDI commits requiring migration' for more detailed information`);
175
+ }
176
+
177
+ } else {
178
+ _error(`Cannot find required files in TDI submodule.`);
179
+ }
180
+ } else {
181
+ _info(`Your TDI submodule is already up to date`);
182
+ }
183
+ } else {
184
+ if (argv.branch) _warn(`Branch argument '${argv.branch}' is ignored for a repository update.`);
185
+
186
+ // Fetch all
187
+ _info(`Fetch all`);
188
+ const cmdFetch = execGitCommand('fetch -pf --all', path.join(_paths.repo));
189
+ if (cmdFetch.error) _warn(`Fetch failed\n${cmdFetch.error}`);
190
+
191
+ // pull repo
192
+ _info(`Pull repository`);
193
+ const cmdPull = execGitCommand(`pull`, _paths.repo);
194
+ if (cmdPull.error) _warn(`Pull failed\n${cmdPull.error}`);
195
+
196
+ _info(`Checked out at commit:`);
197
+ const repoLog = execGitCommand(`log -1 --format=%D;%H;%cd --date=iso-strict`, _paths.repo, ['tags', 'hash', 'date']);
198
+ _write(`${_formatDate(repoLog.date)} - ${repoLog.tags} - ${repoLog.hash}`);
199
+
200
+ _info(`Retrieve submodules that belong to this repo-commit`); // update submodule recursively (set to version that belongs to repo)
201
+ _write(execGitCommand(`submodule update --recursive`, path.join(_paths.repo)));
202
+ _info(`Submodule checked out at commit:`);
203
+ const tdiLog = execGitCommand(`log -1 --format=%D;%H;%cd --date=iso-strict`, path.join(_paths.repo, _paths.tdi), ['tags', 'hash', 'date']);
204
+ _write(`${_formatDate(tdiLog.date)} - ${tdiLog.tags} - ${tdiLog.hash}`);
205
+ const tdiBranch = getTdiBranch();
206
+
207
+ _info(`\nTDI branch ${tdiBranch.name} is ${tdiBranch.commitsBehind} commits behind.\nUpdate TDI to latest version with 'tct g -u tdi'`);
208
+ }
209
+ }
115
210
  };
@@ -1,202 +1,201 @@
1
- const fs = require('fs-extra');
2
- const globby = require('globby');
3
- const path = require('path');
4
- const {Table} = require('console-table-printer');
5
-
6
- const execGitCommand = require('../../lib/exec-git-command');
7
- const c = require('../deploy/config');
8
- const {remote} = require('../deploy/execute');
9
-
10
-
11
- const getGitInfo = () => {
12
- // Version info TDI submodule
13
- const gitSubmoduleInfo = new Table({
14
- columns: [
15
- {name: 'property', title: 'TDI - submodule', alignment: 'left'},
16
- {name: 'value', alignment: 'left'}
17
- ],
18
- });
19
-
20
- // Fetch all
21
- execGitCommand('fetch -pf --all', path.join(_paths.repo, _paths.tdi));
22
-
23
- // Get branches containing TDI HEAD commit
24
- const releaseBranches = execGitCommand(`branch --all --contains ${_git.commitTdi.local().hash}`, path.join(_paths.repo, _paths.tdi)).match(/release\/[^\s]+/gsm);
25
- if (!releaseBranches) _error('Could not retrieve TDI release branches');
26
- // Get the first possible branch; prefer release/5.1 over release/5.2:
27
- releaseBranches.sort((a, b) => a.name > b.name ? 1 : -1);
28
- const firstBranch = {name: releaseBranches[0]};
29
- // Get number of commits behind
30
- firstBranch.commitsBehind = execGitCommand(`rev-list HEAD...origin/${firstBranch.name} --count`, path.join(_paths.repo, _paths.tdi));
31
-
32
- // Create table rows for TDI submodule info
33
- gitSubmoduleInfo.addRow({
34
- property: 'Commit date',
35
- value: _git.commitTdi.local().date.toLocaleDateString('en-gb', {day: 'numeric', month: 'short', year: 'numeric', hour: '2-digit', minute: '2-digit'})
36
- });
37
- if (firstBranch) {
38
- gitSubmoduleInfo.addRow({
39
- property: 'Branch',
40
- value: firstBranch.name
41
- });
42
- gitSubmoduleInfo.addRow({
43
- property: 'Commits behind',
44
- value: firstBranch.commitsBehind
45
- });
46
- } else {
47
- gitSubmoduleInfo.addRow({
48
- property: 'Branch could not be determined',
49
- value: ''
50
- });
51
- }
52
-
53
- // Print TDI submodule info
54
- gitSubmoduleInfo.printTable();
55
- };
56
-
57
- const getFileExtractInfo = (sorting) => {
58
- // version info miscellaneous
59
- const projects = new Set;
60
- const types = new Set;
61
- const versionInfoConfigPath = path.join(_paths.repo, _paths.tdi, 'tct/version/versionInfo.js');
62
- const versionInfo = new Table({
63
- columns: [
64
- {name: 'path', alignment: 'left'},
65
- {name: 'type', alignment: 'left'},
66
- {name: 'version', alignment: 'left'},
67
- {name: 'sort'}
68
- ],
69
- disabledColumns: ['sort'],
70
- sort: (a, b) => a.sort.toLowerCase() > b.sort.toLowerCase() ? 1 : -1
71
- });
72
-
73
- if (fs.existsSync(versionInfoConfigPath)) {
74
- const config = require(versionInfoConfigPath);
75
-
76
- config.forEach(v => {
77
- const location = path.join(_paths.repo, v.glob);
78
-
79
- globby
80
- .sync(location)
81
- .forEach(f => {
82
- const filePathExtract = f.match(/.*(?<path>(cmscustom|site-stylesheets)\/(?<customer>[^/]*)\/(?<project>[^/]*)\/.*)/);
83
- const path = filePathExtract.groups.path || '';
84
- const project = filePathExtract.groups.project || '';
85
-
86
- const fileContent = fs.readFileSync(f).toString();
87
- v.extracts.forEach(e => {
88
- const extract = fileContent.match(e.regex);
89
- if (extract) {
90
- projects.add(project); // Store the projects where versioninfo is found
91
- types.add(e.type); // Store the types for which versioninfo is found
92
- versionInfo.addRow({ // Create row with version information to output
93
- path,
94
- sort: `${sorting=='project' ? project : e.type}_2${sorting=='project' ? e.type : extract.groups.version}`, // Output is sorted on project or type: '_2' ensures it is rendered after the empty row and the row with the project name
95
- type: e.type,
96
- version: extract.groups.version
97
- });
98
- }
99
- });
100
- });
101
- });
102
-
103
- if (sorting=='project') {
104
- // For projects containing version information
105
- projects.forEach(p => {
106
- versionInfo.addRow({ // Add empty row after project
107
- path: '',
108
- sort: `${p}_3`,
109
- type: '',
110
- version: ''
111
- });
112
- versionInfo.addRow({ // Add row with project name
113
- path: `-- ${p}:`,
114
- sort: `${p}_1`,
115
- type: '',
116
- version: ''
117
- }, {
118
- color: 'yellow'
119
- });
120
- });
121
- }
122
- else if (sorting=='type') {
123
- types.forEach(t => {
124
- versionInfo.addRow({ // Add empty row after type
125
- path: '',
126
- sort: `${t}_3`,
127
- type: '',
128
- version: ''
129
- });
130
- });
131
- }
132
- versionInfo.printTable();
133
- }
134
- else {
135
- _warn('Version info of miscellaneous items cannot be extracted:\nCannot find required files in TDI submodule. Try updating TDI submodule.');
136
- }
137
- };
138
-
139
- const getServerInfo = (server) => {
140
- // Remote server info
141
- // common setup
142
- _write();
143
- c.setServer(server);
144
-
145
- if (!c.envDev) {
146
- _info(`Remote version info for '${c.server.ftpConfig.host}':\n`);
147
- remote.add('sudo ~root/scripts/version.sh', '').process();
148
- }
149
- else {
150
- _info('For development environments no server version information is available. Check rancher / database for this information.\nAdd the --server option with a non-dev environment to see version information for that server.');
151
- }
152
- };
153
-
154
-
155
- module.exports = function info (argv) {
156
-
157
- if (argv.doctypes) {
158
- _info('Document type information for this git repository\n');
159
-
160
- const doctypesInfo = new Table({
161
- columns: [
162
- {name: 'id', alignment: 'right'},
163
- {name: 'name', alignment: 'left'},
164
- {name: 'paths', alignment: 'left'}
165
- ],
166
- });
167
-
168
- globby
169
- .sync(_paths.repo + '/database/config/**/txd_document_types.sql')
170
- .forEach((p, i, a) => {
171
- fs.readFileSync(p).toString().match(/select([\s\S]+?)from\s+dual/gmi)
172
- .forEach((dtRow, i, a) => {
173
- const ntSqlInsert = fs.readFileSync(p.replace('txd_document_types', 'txd_node_types')).toString().match(/select(.*?)from\s+dual/s)[1];
174
- const id = dtRow.match(/(\d+) id/)?.[1];
175
- const name = dtRow.match(/'([^']+)' display_name/)?.[1];
176
- const dbPath = p.match(/(database\/config\/(:?.*)\/)txd_document_types.sql/i)?.[1];
177
- const prPath = ntSqlInsert.match(/'([^']+)' xsl_prep_inc/)[1].replace('prepare_xincludes.xsl','');
178
-
179
- doctypesInfo.addRows([
180
- {id, name, paths: 'config/cmscustom/'+ prPath},
181
- {paths: dbPath}
182
- ]);
183
-
184
- if (i!==a.length-1) doctypesInfo.addRow({});
185
- });
186
-
187
- if (i!==a.length-1) doctypesInfo.addRow({});
188
- });
189
-
190
-
191
- doctypesInfo.printTable();
192
- }
193
-
194
- if (argv.versions) {
195
- _info('Version information for this git repository\n');
196
-
197
- getGitInfo();
198
- getFileExtractInfo(argv.versions);
199
- getServerInfo(argv.server);
200
- }
201
-
202
- };
1
+ const fs = require('fs-extra');
2
+ const globby = require('globby');
3
+ const path = require('path');
4
+ const {Table} = require('console-table-printer');
5
+
6
+ const execGitCommand = require('../../lib/exec-git-command');
7
+ const getTdiBranch = require('../../lib/get-tdi-branch');
8
+ const c = require('../deploy/config');
9
+ const {remote} = require('../deploy/execute');
10
+
11
+
12
+ const getGitInfo = () => {
13
+ // Version info TDI submodule
14
+ const gitSubmoduleInfo = new Table({
15
+ columns: [
16
+ {name: 'property', title: 'TDI - submodule', alignment: 'left'},
17
+ {name: 'value', alignment: 'left'}
18
+ ],
19
+ });
20
+
21
+ // Fetch all
22
+ const cmdFetch = execGitCommand('fetch -pf --all', path.join(_paths.repo, _paths.tdi));
23
+ if (cmdFetch.error) _warn(`Fetch failed\n${cmdFetch.error}`);
24
+
25
+ // Set branch name of firstBranch without 'remotes/origin/'
26
+ const tdiBranch = getTdiBranch();
27
+
28
+ // Get number of commits behind
29
+ tdiBranch.commitsBehind = execGitCommand(`rev-list HEAD...origin/${tdiBranch.name} --count`, path.join(_paths.repo, _paths.tdi));
30
+
31
+ // Create table rows for TDI submodule info
32
+ gitSubmoduleInfo.addRow({
33
+ property: 'Commit date',
34
+ value: _formatDate(_git.commitTdi.local().date)
35
+ });
36
+ if (tdiBranch) {
37
+ gitSubmoduleInfo.addRow({
38
+ property: 'Branch',
39
+ value: tdiBranch.name
40
+ });
41
+ gitSubmoduleInfo.addRow({
42
+ property: 'Commits behind',
43
+ value: tdiBranch.commitsBehind
44
+ });
45
+ } else {
46
+ gitSubmoduleInfo.addRow({
47
+ property: 'Branch could not be determined',
48
+ value: ''
49
+ });
50
+ }
51
+
52
+ // Print TDI submodule info
53
+ gitSubmoduleInfo.printTable();
54
+ };
55
+
56
+ const getFileExtractInfo = (sorting) => {
57
+ // version info miscellaneous
58
+ const projects = new Set;
59
+ const types = new Set;
60
+ const versionInfoConfigPath = path.join(_paths.repo, _paths.tdi, 'tct/version/versionInfo.js');
61
+ const versionInfo = new Table({
62
+ columns: [
63
+ {name: 'path', alignment: 'left'},
64
+ {name: 'type', alignment: 'left'},
65
+ {name: 'version', alignment: 'left'},
66
+ {name: 'sort'}
67
+ ],
68
+ disabledColumns: ['sort'],
69
+ sort: (a, b) => a.sort.toLowerCase() > b.sort.toLowerCase() ? 1 : -1
70
+ });
71
+
72
+ if (fs.existsSync(versionInfoConfigPath)) {
73
+ const config = require(versionInfoConfigPath);
74
+
75
+ config.forEach(v => {
76
+ const location = path.join(_paths.repo, v.glob);
77
+
78
+ globby
79
+ .sync(location)
80
+ .forEach(f => {
81
+ const filePathExtract = f.match(/.*(?<path>(cmscustom|site-stylesheets)\/(?<customer>[^/]*)\/(?<project>[^/]*)\/.*)/);
82
+ const path = filePathExtract.groups.path || '';
83
+ const project = filePathExtract.groups.project || '';
84
+
85
+ const fileContent = fs.readFileSync(f).toString();
86
+ v.extracts.forEach(e => {
87
+ const extract = fileContent.match(e.regex);
88
+ if (extract) {
89
+ projects.add(project); // Store the projects where versioninfo is found
90
+ types.add(e.type); // Store the types for which versioninfo is found
91
+ versionInfo.addRow({ // Create row with version information to output
92
+ path,
93
+ sort: `${sorting=='project' ? project : e.type}_2${sorting=='project' ? e.type : extract.groups.version}`, // Output is sorted on project or type: '_2' ensures it is rendered after the empty row and the row with the project name
94
+ type: e.type,
95
+ version: extract.groups.version
96
+ });
97
+ }
98
+ });
99
+ });
100
+ });
101
+
102
+ if (sorting=='project') {
103
+ // For projects containing version information
104
+ projects.forEach(p => {
105
+ versionInfo.addRow({ // Add empty row after project
106
+ path: '',
107
+ sort: `${p}_3`,
108
+ type: '',
109
+ version: ''
110
+ });
111
+ versionInfo.addRow({ // Add row with project name
112
+ path: `-- ${p}:`,
113
+ sort: `${p}_1`,
114
+ type: '',
115
+ version: ''
116
+ }, {
117
+ color: 'yellow'
118
+ });
119
+ });
120
+ }
121
+ else if (sorting=='type') {
122
+ types.forEach(t => {
123
+ versionInfo.addRow({ // Add empty row after type
124
+ path: '',
125
+ sort: `${t}_3`,
126
+ type: '',
127
+ version: ''
128
+ });
129
+ });
130
+ }
131
+ versionInfo.printTable();
132
+ }
133
+ else {
134
+ _warn('Version info of miscellaneous items cannot be extracted:\nCannot find required files in TDI submodule. Try updating TDI submodule.');
135
+ }
136
+ };
137
+
138
+ const getServerInfo = (server) => {
139
+ // Remote server info
140
+ // common setup
141
+ _write();
142
+ c.setServer(server);
143
+
144
+ if (!c.envDev) {
145
+ _info(`Remote version info for '${c.server.ftpConfig.host}':\n`);
146
+ remote.add('sudo ~root/scripts/version.sh', '').process();
147
+ }
148
+ else {
149
+ _info('For development environments no server version information is available. Check rancher / database for this information.\nAdd the --server option with a non-dev environment to see version information for that server.');
150
+ }
151
+ };
152
+
153
+
154
+ module.exports = function info (argv) {
155
+
156
+ if (argv.doctypes) {
157
+ _info('Document type information for this git repository\n');
158
+
159
+ const doctypesInfo = new Table({
160
+ columns: [
161
+ {name: 'id', alignment: 'right'},
162
+ {name: 'name', alignment: 'left'},
163
+ {name: 'paths', alignment: 'left'}
164
+ ],
165
+ });
166
+
167
+ globby
168
+ .sync(_paths.repo + '/database/config/**/txd_document_types.sql')
169
+ .forEach((p, i, a) => {
170
+ fs.readFileSync(p).toString().match(/select([\s\S]+?)from\s+dual/gmi)
171
+ .forEach((dtRow, i, a) => {
172
+ const ntSqlInsert = fs.readFileSync(p.replace('txd_document_types', 'txd_node_types')).toString().match(/select(.*?)from\s+dual/s)[1];
173
+ const id = dtRow.match(/(\d+) id/)?.[1];
174
+ const name = dtRow.match(/'([^']+)' display_name/)?.[1];
175
+ const dbPath = p.match(/(database\/config\/(:?.*)\/)txd_document_types.sql/i)?.[1];
176
+ const prPath = ntSqlInsert.match(/'([^']+)' xsl_prep_inc/)[1].replace('prepare_xincludes.xsl', '');
177
+
178
+ doctypesInfo.addRows([
179
+ {id, name, paths: 'config/cmscustom/'+ prPath},
180
+ {paths: dbPath}
181
+ ]);
182
+
183
+ if (i!==a.length-1) doctypesInfo.addRow({});
184
+ });
185
+
186
+ if (i!==a.length-1) doctypesInfo.addRow({});
187
+ });
188
+
189
+
190
+ doctypesInfo.printTable();
191
+ }
192
+
193
+ if (argv.versions) {
194
+ _info('Version information for this git repository\n');
195
+
196
+ getGitInfo();
197
+ getFileExtractInfo(argv.versions);
198
+ getServerInfo(argv.server);
199
+ }
200
+
201
+ };
@@ -62,7 +62,7 @@ module.exports = function migrate (argv) {
62
62
  if (p.path_dbconfig.join('/') != p.path_cmscustom.join('/')) projectFolders.push(p.path_cmscustom.join('/'));
63
63
  });
64
64
  // Set filter to chosen active documents
65
- filter = projectFolders.length == 1 ? `**/${projectFolders}/**` : `**/{${projectFolders.join(',')}}/**`;
65
+ filter = projectFolders.length === 1 ? `**/${projectFolders}/**` : `**/{${projectFolders.join(',')}}/**`;
66
66
  }
67
67
 
68
68
  _info(`Filter applied: ${filter}`);
@@ -52,9 +52,11 @@ module.exports = function steps (step, dry, filter) {
52
52
  }
53
53
 
54
54
  let filesModCount = 0;
55
- for (let i=0; i<20 && r.files[0]; i++) { // execute repeatedly for modified files only (with safety limit of 20)
55
+ let maxRepeat = 20;
56
+ for (let i=0; i<maxRepeat && r.files[0]; i++) { // execute repeatedly for modified files only (with safety limit of 20)
56
57
  r.files = rif.sync(r).filter(f => f.hasChanged).map(f => f.file);
57
- if (i==0) filesModCount = r.files.length; // save count only after first run (after this only subsets are processed)
58
+ if (i===0) filesModCount = r.files.length; // save count only after first run (after this only subsets are processed)
59
+ if (i===maxRepeat-1 && r.files[0]) _warn(`Repeated replacement stopped by safety limit - check file changes for too many content occurrences`);
58
60
  if (dry) break;
59
61
  }
60
62
 
@@ -18,9 +18,9 @@ const checkLog = (logFilePath, remove=true) => {
18
18
  if (fs.existsSync(logFilePath)) {
19
19
  const logFile = fs.readFileSync(logFilePath).toString();
20
20
  // Check for ORA- error messages
21
- if (logFile.match(RegExp(`ORA-`, 'gm'))) {
21
+ if (logFile.match(/ORA-/g)) {
22
22
  // Select each ORA- error message and up to 6 lines before (the lines before may not contain ORA- themselves)
23
- const errors = logFile.match(RegExp(`((?![^\n]*ORA-)[^\n]*\n){0,6}ORA-[^\n\r]*`, `gms`));
23
+ const errors = logFile.match(/(?:(?![^\n]*ORA-)[^\n]*\n){0,6}ORA-[^\n\r]*/gms);
24
24
  _info(`${errors.length} error(s) during SQL script:\n`);
25
25
  // Print each error + lines before:
26
26
  errors.forEach((e, i) => {