@automattic/vip 2.12.0 → 2.13.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.
- package/README.md +12 -1
- package/dist/bin/vip-cache-purge-url.js +93 -0
- package/{package/dist/bin/vip-config.js → dist/bin/vip-cache.js} +6 -3
- package/dist/bin/vip-dev-env-import-sql.js +8 -1
- package/dist/bin/vip-dev-env-start.js +2 -1
- package/dist/bin/vip-dev-env-update.js +1 -0
- package/dist/bin/vip.js +1 -1
- package/dist/lib/api/cache-purge.js +76 -0
- package/dist/lib/dev-environment/dev-environment-lando.js +31 -3
- package/dist/lib/envvar/read-file.js +2 -18
- package/{package/dist/lib/envvar → dist/lib}/read-file.js +3 -6
- package/dist/lib/validations/sql.js +134 -52
- package/npm-shrinkwrap.json +79 -79
- package/package.json +4 -2
- package/package/dist/bin/vip-app-list.js +0 -73
- package/package/dist/bin/vip-app.js +0 -76
- package/package/dist/bin/vip-config-envvar-delete.js +0 -97
- package/package/dist/bin/vip-config-envvar-get-all.js +0 -94
- package/package/dist/bin/vip-config-envvar-get.js +0 -79
- package/package/dist/bin/vip-config-envvar-list.js +0 -91
- package/package/dist/bin/vip-config-envvar-set.js +0 -123
- package/package/dist/bin/vip-config-envvar.js +0 -23
- package/package/dist/bin/vip-dev-env-create.js +0 -105
- package/package/dist/bin/vip-dev-env-destroy.js +0 -56
- package/package/dist/bin/vip-dev-env-exec.js +0 -67
- package/package/dist/bin/vip-dev-env-import-media.js +0 -51
- package/package/dist/bin/vip-dev-env-import-sql.js +0 -83
- package/package/dist/bin/vip-dev-env-import.js +0 -32
- package/package/dist/bin/vip-dev-env-info.js +0 -61
- package/package/dist/bin/vip-dev-env-list.js +0 -46
- package/package/dist/bin/vip-dev-env-start.js +0 -77
- package/package/dist/bin/vip-dev-env-stop.js +0 -52
- package/package/dist/bin/vip-dev-env-update.js +0 -89
- package/package/dist/bin/vip-dev-env.js +0 -23
- package/package/dist/bin/vip-import-media-abort.js +0 -132
- package/package/dist/bin/vip-import-media-status.js +0 -84
- package/package/dist/bin/vip-import-media.js +0 -168
- package/package/dist/bin/vip-import-sql-status.js +0 -83
- package/package/dist/bin/vip-import-sql.js +0 -580
- package/package/dist/bin/vip-import-validate-files.js +0 -191
- package/package/dist/bin/vip-import-validate-sql.js +0 -34
- package/package/dist/bin/vip-import.js +0 -20
- package/package/dist/bin/vip-logs.js +0 -232
- package/package/dist/bin/vip-search-replace.js +0 -71
- package/package/dist/bin/vip-sync.js +0 -191
- package/package/dist/bin/vip-whoami.js +0 -67
- package/package/dist/bin/vip-wp.js +0 -555
- package/package/dist/bin/vip.js +0 -149
- package/package/dist/lib/analytics/clients/client.js +0 -1
- package/package/dist/lib/analytics/clients/pendo.js +0 -92
- package/package/dist/lib/analytics/clients/stub.js +0 -19
- package/package/dist/lib/analytics/clients/tracks.js +0 -128
- package/package/dist/lib/analytics/index.js +0 -45
- package/package/dist/lib/api/app.js +0 -70
- package/package/dist/lib/api/feature-flags.js +0 -39
- package/package/dist/lib/api/user.js +0 -58
- package/package/dist/lib/api.js +0 -136
- package/package/dist/lib/app-logs/app-logs.js +0 -70
- package/package/dist/lib/cli/apiConfig.js +0 -90
- package/package/dist/lib/cli/command.js +0 -606
- package/package/dist/lib/cli/envAlias.js +0 -60
- package/package/dist/lib/cli/exit.js +0 -33
- package/package/dist/lib/cli/format.js +0 -213
- package/package/dist/lib/cli/pager.js +0 -52
- package/package/dist/lib/cli/progress.js +0 -208
- package/package/dist/lib/cli/prompt.js +0 -37
- package/package/dist/lib/cli/repo.js +0 -77
- package/package/dist/lib/client-file-uploader.js +0 -602
- package/package/dist/lib/constants/dev-environment.js +0 -42
- package/package/dist/lib/constants/file-size.js +0 -14
- package/package/dist/lib/dev-environment/dev-environment-cli.js +0 -508
- package/package/dist/lib/dev-environment/dev-environment-core.js +0 -620
- package/package/dist/lib/dev-environment/dev-environment-lando.js +0 -330
- package/package/dist/lib/dev-environment/types.js +0 -1
- package/package/dist/lib/env.js +0 -36
- package/package/dist/lib/envvar/api-delete.js +0 -56
- package/package/dist/lib/envvar/api-get-all.js +0 -59
- package/package/dist/lib/envvar/api-get.js +0 -24
- package/package/dist/lib/envvar/api-list.js +0 -60
- package/package/dist/lib/envvar/api-set.js +0 -58
- package/package/dist/lib/envvar/api.js +0 -104
- package/package/dist/lib/envvar/input.js +0 -55
- package/package/dist/lib/envvar/logging.js +0 -33
- package/package/dist/lib/http/socks-proxy-agent.js +0 -25
- package/package/dist/lib/keychain/browser.js +0 -35
- package/package/dist/lib/keychain/insecure.js +0 -63
- package/package/dist/lib/keychain/keychain.js +0 -1
- package/package/dist/lib/keychain/secure.js +0 -36
- package/package/dist/lib/keychain.js +0 -36
- package/package/dist/lib/media-import/media-file-import.js +0 -34
- package/package/dist/lib/media-import/progress.js +0 -86
- package/package/dist/lib/media-import/status.js +0 -335
- package/package/dist/lib/rollbar.js +0 -35
- package/package/dist/lib/search-and-replace.js +0 -203
- package/package/dist/lib/site-import/db-file-import.js +0 -46
- package/package/dist/lib/site-import/status.js +0 -444
- package/package/dist/lib/token.js +0 -132
- package/package/dist/lib/tracker.js +0 -96
- package/package/dist/lib/validations/is-multi-site-sql-dump.js +0 -59
- package/package/dist/lib/validations/is-multi-site.js +0 -99
- package/package/dist/lib/validations/line-by-line.js +0 -92
- package/package/dist/lib/validations/site-type.js +0 -66
- package/package/dist/lib/validations/sql.js +0 -371
- package/package/dist/lib/vip-import-validate-files.js +0 -548
- package/package/vip.iml +0 -11
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.validate = exports.staticSqlValidations = exports.getTableNames =
|
|
6
|
+
exports.validate = exports.staticSqlValidations = exports.getTableNames = void 0;
|
|
7
7
|
|
|
8
8
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
9
9
|
|
|
@@ -45,18 +45,43 @@ function formatRecommendation(message) {
|
|
|
45
45
|
return `${_chalk.default.yellow('Recommendation:')} ${message}`;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
const
|
|
48
|
+
const generalCheckFormatter = check => {
|
|
49
|
+
const errors = [];
|
|
50
|
+
const infos = [];
|
|
51
|
+
const validProblems = check.results.filter(result => !result.falsePositive);
|
|
52
|
+
|
|
53
|
+
if (validProblems.length > 0) {
|
|
54
|
+
problemsFound += 1;
|
|
55
|
+
|
|
56
|
+
for (const problem of validProblems) {
|
|
57
|
+
errors.push({
|
|
58
|
+
error: formatError(`${problem.text || check.message} on line ${problem.lineNumber || ''}.`),
|
|
59
|
+
recommendation: formatRecommendation(problem.recomendation || check.recommendation)
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
} else {
|
|
63
|
+
infos.push(`✅ ${check.message} was found 0 times.`);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return {
|
|
67
|
+
errors,
|
|
68
|
+
infos
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const lineNumberCheckFormatter = check => {
|
|
49
73
|
const errors = [];
|
|
50
74
|
const infos = [];
|
|
51
75
|
|
|
52
76
|
if (check.results.length > 0) {
|
|
53
77
|
problemsFound += 1;
|
|
78
|
+
const lineNumbers = check.results.map(result => result.lineNumber);
|
|
54
79
|
errors.push({
|
|
55
|
-
error: formatError(`${check.message} on line(s) ${
|
|
80
|
+
error: formatError(`${check.message} on line(s) ${lineNumbers.join(', ')}.`),
|
|
56
81
|
recommendation: formatRecommendation(check.recommendation)
|
|
57
82
|
});
|
|
58
83
|
} else {
|
|
59
|
-
infos.push(`✅ ${check.message} was found
|
|
84
|
+
infos.push(`✅ ${check.message} was found 0 times.`);
|
|
60
85
|
}
|
|
61
86
|
|
|
62
87
|
return {
|
|
@@ -94,7 +119,7 @@ const requiredCheckFormatter = (check, type, isImport) => {
|
|
|
94
119
|
const infoCheckFormatter = check => {
|
|
95
120
|
const infos = [];
|
|
96
121
|
check.results.forEach(item => {
|
|
97
|
-
infos.push(item);
|
|
122
|
+
infos.push(item.text);
|
|
98
123
|
});
|
|
99
124
|
return {
|
|
100
125
|
errors: [],
|
|
@@ -102,11 +127,13 @@ const infoCheckFormatter = check => {
|
|
|
102
127
|
};
|
|
103
128
|
};
|
|
104
129
|
|
|
105
|
-
function checkTablePrefixes(
|
|
130
|
+
function checkTablePrefixes(results, errors, infos) {
|
|
106
131
|
const wpTables = [],
|
|
107
132
|
notWPTables = [],
|
|
108
133
|
wpMultisiteTables = [];
|
|
109
|
-
|
|
134
|
+
results.forEach(result => {
|
|
135
|
+
const tableName = result.text || '';
|
|
136
|
+
|
|
110
137
|
if (tableName.match(/^wp_(\d+_)/)) {
|
|
111
138
|
wpMultisiteTables.push(tableName);
|
|
112
139
|
} else if (tableName.match(/^wp_/)) {
|
|
@@ -136,8 +163,10 @@ function checkTablePrefixes(tables, errors, infos) {
|
|
|
136
163
|
const checks = {
|
|
137
164
|
binaryLogging: {
|
|
138
165
|
matcher: /SET @@SESSION.sql_log_bin/i,
|
|
139
|
-
matchHandler: lineNumber =>
|
|
140
|
-
|
|
166
|
+
matchHandler: lineNumber => ({
|
|
167
|
+
lineNumber
|
|
168
|
+
}),
|
|
169
|
+
outputFormatter: lineNumberCheckFormatter,
|
|
141
170
|
results: [],
|
|
142
171
|
message: 'SET @@SESSION.sql_log_bin statement',
|
|
143
172
|
excerpt: "'SET @@SESSION.sql_log_bin' statement should not be present (case-insensitive)",
|
|
@@ -146,8 +175,10 @@ const checks = {
|
|
|
146
175
|
trigger: {
|
|
147
176
|
// Match `CREATE (DEFINER=`root`@`host`) TRIGGER`
|
|
148
177
|
matcher: /^CREATE (\(?DEFINER=`?(\w*)(`@`)?(\w*\.*%?)*`?\)?)?(| )TRIGGER/i,
|
|
149
|
-
matchHandler: lineNumber =>
|
|
150
|
-
|
|
178
|
+
matchHandler: lineNumber => ({
|
|
179
|
+
lineNumber
|
|
180
|
+
}),
|
|
181
|
+
outputFormatter: lineNumberCheckFormatter,
|
|
151
182
|
results: [],
|
|
152
183
|
message: 'TRIGGER statement',
|
|
153
184
|
excerpt: "'TRIGGER' statement should not be present (case-sensitive)",
|
|
@@ -155,8 +186,10 @@ const checks = {
|
|
|
155
186
|
},
|
|
156
187
|
dropDB: {
|
|
157
188
|
matcher: /^DROP DATABASE/i,
|
|
158
|
-
matchHandler: lineNumber =>
|
|
159
|
-
|
|
189
|
+
matchHandler: lineNumber => ({
|
|
190
|
+
lineNumber
|
|
191
|
+
}),
|
|
192
|
+
outputFormatter: lineNumberCheckFormatter,
|
|
160
193
|
results: [],
|
|
161
194
|
message: 'DROP DATABASE statement',
|
|
162
195
|
excerpt: "'DROP DATABASE' should not be present (case-insensitive)",
|
|
@@ -164,8 +197,10 @@ const checks = {
|
|
|
164
197
|
},
|
|
165
198
|
useStatement: {
|
|
166
199
|
matcher: /^USE /i,
|
|
167
|
-
matchHandler: lineNumber =>
|
|
168
|
-
|
|
200
|
+
matchHandler: lineNumber => ({
|
|
201
|
+
lineNumber
|
|
202
|
+
}),
|
|
203
|
+
outputFormatter: lineNumberCheckFormatter,
|
|
169
204
|
results: [],
|
|
170
205
|
message: 'USE <DATABASE_NAME> statement',
|
|
171
206
|
excerpt: "'USE <DATABASE_NAME>' should not be present (case-insensitive)",
|
|
@@ -173,8 +208,10 @@ const checks = {
|
|
|
173
208
|
},
|
|
174
209
|
alterUser: {
|
|
175
210
|
matcher: /^(ALTER USER|SET PASSWORD)/i,
|
|
176
|
-
matchHandler: lineNumber =>
|
|
177
|
-
|
|
211
|
+
matchHandler: lineNumber => ({
|
|
212
|
+
lineNumber
|
|
213
|
+
}),
|
|
214
|
+
outputFormatter: lineNumberCheckFormatter,
|
|
178
215
|
results: [],
|
|
179
216
|
message: 'ALTER USER statement',
|
|
180
217
|
excerpt: "'ALTER USER' should not be present (case-insensitive)",
|
|
@@ -182,7 +219,9 @@ const checks = {
|
|
|
182
219
|
},
|
|
183
220
|
dropTable: {
|
|
184
221
|
matcher: /^DROP TABLE IF EXISTS `?([a-z0-9_]*)/i,
|
|
185
|
-
matchHandler: (lineNumber, results) =>
|
|
222
|
+
matchHandler: (lineNumber, results) => ({
|
|
223
|
+
text: results[1]
|
|
224
|
+
}),
|
|
186
225
|
outputFormatter: requiredCheckFormatter,
|
|
187
226
|
results: [],
|
|
188
227
|
message: 'DROP TABLE',
|
|
@@ -191,7 +230,9 @@ const checks = {
|
|
|
191
230
|
},
|
|
192
231
|
createTable: {
|
|
193
232
|
matcher: /^CREATE TABLE (?:IF NOT EXISTS )?`?([a-z0-9_]*)/i,
|
|
194
|
-
matchHandler: (lineNumber, results) =>
|
|
233
|
+
matchHandler: (lineNumber, results) => ({
|
|
234
|
+
text: results[1]
|
|
235
|
+
}),
|
|
195
236
|
outputFormatter: requiredCheckFormatter,
|
|
196
237
|
results: [],
|
|
197
238
|
message: 'CREATE TABLE',
|
|
@@ -200,41 +241,74 @@ const checks = {
|
|
|
200
241
|
},
|
|
201
242
|
siteHomeUrl: {
|
|
202
243
|
matcher: "'(siteurl|home)',\\s?'(.*?)'",
|
|
203
|
-
matchHandler: (lineNumber, results) =>
|
|
244
|
+
matchHandler: (lineNumber, results) => ({
|
|
245
|
+
text: results[1]
|
|
246
|
+
}),
|
|
204
247
|
outputFormatter: infoCheckFormatter,
|
|
205
248
|
results: [],
|
|
206
249
|
message: 'Siteurl/home matches',
|
|
207
250
|
excerpt: 'Siteurl/home options',
|
|
208
251
|
recommendation: ''
|
|
209
252
|
},
|
|
253
|
+
siteHomeUrlLando: {
|
|
254
|
+
matcher: "'(siteurl|home)',\\s?'(.*?)'",
|
|
255
|
+
matchHandler: (lineNumber, results, expectedDomain) => {
|
|
256
|
+
const foundDomain = results[2].replace(/https?:\/\//, '');
|
|
257
|
+
|
|
258
|
+
if (!foundDomain.trim()) {
|
|
259
|
+
return {
|
|
260
|
+
falsePositive: true
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
if (foundDomain.includes(expectedDomain)) {
|
|
265
|
+
return {
|
|
266
|
+
falsePositive: true
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
return {
|
|
271
|
+
lineNumber,
|
|
272
|
+
recomendation: `Use '--search-replace="${foundDomain},${expectedDomain}"' switch to replace the domain`
|
|
273
|
+
};
|
|
274
|
+
},
|
|
275
|
+
outputFormatter: generalCheckFormatter,
|
|
276
|
+
results: [],
|
|
277
|
+
message: 'Siteurl/home options not pointing to lando domain',
|
|
278
|
+
excerpt: 'Siteurl/home options not pointing to lando domain',
|
|
279
|
+
recommendation: 'Use search-replace to change environment\'s domain'
|
|
280
|
+
},
|
|
210
281
|
engineInnoDB: {
|
|
211
282
|
matcher: / ENGINE=(?!(InnoDB))/i,
|
|
212
|
-
matchHandler: lineNumber =>
|
|
213
|
-
|
|
283
|
+
matchHandler: lineNumber => ({
|
|
284
|
+
lineNumber
|
|
285
|
+
}),
|
|
286
|
+
outputFormatter: lineNumberCheckFormatter,
|
|
214
287
|
results: [],
|
|
215
288
|
message: 'ENGINE != InnoDB',
|
|
216
289
|
excerpt: "'ENGINE=InnoDB' should be present (case-insensitive) for all tables",
|
|
217
290
|
recommendation: "Ensure your application works with InnoDB and update your SQL dump to include only 'ENGINE=InnoDB' engine definitions in 'CREATE TABLE' statements. " + "We suggest you search for all 'ENGINE=X' entries and replace them with 'ENGINE=InnoDB'!"
|
|
218
291
|
}
|
|
219
292
|
};
|
|
293
|
+
const DEV_ENV_SPECIFIC_CHECKS = ['useStatement', 'siteHomeUrlLando'];
|
|
220
294
|
|
|
221
|
-
const postValidation = async
|
|
295
|
+
const postValidation = async options => {
|
|
222
296
|
await (0, _tracker.trackEvent)('import_validate_sql_command_execute', {
|
|
223
|
-
is_import: isImport
|
|
297
|
+
is_import: options.isImport
|
|
224
298
|
});
|
|
225
299
|
|
|
226
|
-
if (!isImport) {
|
|
300
|
+
if (!options.isImport) {
|
|
227
301
|
(0, _singleLineLog.stdout)(`Finished processing ${lineNum} lines.`);
|
|
228
302
|
console.log('\n');
|
|
229
303
|
}
|
|
230
304
|
|
|
231
305
|
const errorSummary = {};
|
|
232
|
-
const checkEntries = Object.entries(checks);
|
|
306
|
+
const checkEntries = Object.entries(checks).filter(([type]) => !options.skipChecks.includes(type));
|
|
233
307
|
let formattedErrors = [];
|
|
234
308
|
let formattedInfos = [];
|
|
235
309
|
|
|
236
310
|
for (const [type, check] of checkEntries) {
|
|
237
|
-
const formattedOutput = check.outputFormatter(check, type, isImport);
|
|
311
|
+
const formattedOutput = check.outputFormatter(check, type, options.isImport);
|
|
238
312
|
formattedErrors = formattedErrors.concat(formattedOutput.errors);
|
|
239
313
|
formattedInfos = formattedInfos.concat(formattedOutput.infos);
|
|
240
314
|
errorSummary[type] = check.results.length;
|
|
@@ -269,7 +343,7 @@ const postValidation = async (filename, isImport = false) => {
|
|
|
269
343
|
|
|
270
344
|
if (problemsFound > 0) {
|
|
271
345
|
await (0, _tracker.trackEvent)('import_validate_sql_command_failure', {
|
|
272
|
-
is_import: isImport,
|
|
346
|
+
is_import: options.isImport,
|
|
273
347
|
error: errorSummary
|
|
274
348
|
});
|
|
275
349
|
const errorOutput = [`SQL validation failed due to ${_chalk.default.red(problemsFound)} error(s)`, ''];
|
|
@@ -283,25 +357,23 @@ const postValidation = async (filename, isImport = false) => {
|
|
|
283
357
|
errorOutput.push('');
|
|
284
358
|
});
|
|
285
359
|
|
|
286
|
-
if (isImport) {
|
|
360
|
+
if (options.isImport) {
|
|
287
361
|
throw new Error(errorOutput.join('\n'));
|
|
288
362
|
}
|
|
289
363
|
|
|
290
364
|
exit.withError(errorOutput.join('\n'));
|
|
291
365
|
}
|
|
292
366
|
|
|
293
|
-
if (!isImport) {
|
|
367
|
+
if (!options.isImport) {
|
|
294
368
|
console.log(formattedInfos.join('\n'));
|
|
295
369
|
console.log('');
|
|
296
370
|
}
|
|
297
371
|
|
|
298
372
|
await (0, _tracker.trackEvent)('import_validate_sql_command_success', {
|
|
299
|
-
is_import: isImport
|
|
373
|
+
is_import: options.isImport
|
|
300
374
|
});
|
|
301
375
|
};
|
|
302
376
|
|
|
303
|
-
exports.postValidation = postValidation;
|
|
304
|
-
|
|
305
377
|
const getTableNames = () => {
|
|
306
378
|
return tableNames;
|
|
307
379
|
};
|
|
@@ -318,53 +390,63 @@ const checkForTableName = line => {
|
|
|
318
390
|
}
|
|
319
391
|
};
|
|
320
392
|
|
|
321
|
-
const
|
|
393
|
+
const DEFAULT_VALIDATION_OPTIONS = {
|
|
394
|
+
isImport: true,
|
|
395
|
+
skipChecks: DEV_ENV_SPECIFIC_CHECKS,
|
|
396
|
+
extraCheckParams: {}
|
|
397
|
+
};
|
|
398
|
+
|
|
399
|
+
const perLineValidations = (line, options = DEFAULT_VALIDATION_OPTIONS) => {
|
|
322
400
|
if (lineNum % 500 === 0) {
|
|
323
|
-
|
|
401
|
+
options.isImport ? '' : (0, _singleLineLog.stdout)(`Reading line ${lineNum} `);
|
|
324
402
|
}
|
|
325
403
|
|
|
326
404
|
checkForTableName(line);
|
|
327
|
-
const checkKeys = Object.keys(checks).filter(checkItem => !skipChecks.includes(checkItem));
|
|
328
|
-
|
|
329
|
-
|
|
405
|
+
const checkKeys = Object.keys(checks).filter(checkItem => !options.skipChecks.includes(checkItem));
|
|
406
|
+
|
|
407
|
+
for (const checkKey of checkKeys) {
|
|
408
|
+
const check = checks[checkKey];
|
|
330
409
|
const results = line.match(check.matcher);
|
|
410
|
+
const extraCheckParams = options.extraCheckParams[checkKey];
|
|
331
411
|
|
|
332
412
|
if (results) {
|
|
333
|
-
check.results.push(check.matchHandler(lineNum, results));
|
|
413
|
+
check.results.push(check.matchHandler(lineNum, results, extraCheckParams));
|
|
334
414
|
}
|
|
335
|
-
}
|
|
336
|
-
lineNum += 1;
|
|
337
|
-
};
|
|
415
|
+
}
|
|
338
416
|
|
|
339
|
-
|
|
340
|
-
perLineValidations(line, isImport, skipChecks);
|
|
417
|
+
lineNum += 1;
|
|
341
418
|
};
|
|
342
419
|
|
|
343
420
|
const postLineExecutionProcessing = async ({
|
|
344
|
-
|
|
345
|
-
|
|
421
|
+
isImport,
|
|
422
|
+
skipChecks
|
|
346
423
|
}) => {
|
|
347
|
-
await postValidation(
|
|
424
|
+
await postValidation({
|
|
425
|
+
isImport: isImport || false,
|
|
426
|
+
skipChecks: skipChecks || DEV_ENV_SPECIFIC_CHECKS,
|
|
427
|
+
extraCheckParams: {}
|
|
428
|
+
});
|
|
348
429
|
};
|
|
349
430
|
|
|
350
431
|
const staticSqlValidations = {
|
|
351
|
-
execute,
|
|
432
|
+
execute: perLineValidations,
|
|
352
433
|
postLineExecutionProcessing
|
|
353
434
|
}; // For standalone SQL validations
|
|
354
435
|
|
|
355
436
|
exports.staticSqlValidations = staticSqlValidations;
|
|
356
437
|
|
|
357
|
-
const validate = async (filename,
|
|
438
|
+
const validate = async (filename, options = DEFAULT_VALIDATION_OPTIONS) => {
|
|
358
439
|
const readInterface = await (0, _lineByLine.getReadInterface)(filename);
|
|
440
|
+
options.isImport = false;
|
|
359
441
|
readInterface.on('line', line => {
|
|
360
|
-
|
|
442
|
+
perLineValidations(line, options);
|
|
361
443
|
}); // Block until the processing completes
|
|
362
444
|
|
|
363
445
|
await new Promise(resolve => readInterface.on('close', resolve));
|
|
364
446
|
readInterface.close();
|
|
365
447
|
await postLineExecutionProcessing({
|
|
366
|
-
|
|
367
|
-
|
|
448
|
+
isImport: options.isImport,
|
|
449
|
+
skipChecks: options.skipChecks
|
|
368
450
|
});
|
|
369
451
|
};
|
|
370
452
|
|