@automattic/vip 2.22.0 → 2.24.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/CHANGELOG.md +38 -13
- package/assets/dev-env.lando.template.yml.ejs +6 -1
- package/dist/bin/vip-app-list.js +0 -12
- package/dist/bin/vip-app.js +6 -13
- package/dist/bin/vip-cache-purge-url.js +4 -19
- package/dist/bin/vip-cache.js +0 -2
- package/dist/bin/vip-config-envvar-delete.js +4 -19
- package/dist/bin/vip-config-envvar-get-all.js +6 -19
- package/dist/bin/vip-config-envvar-get.js +4 -15
- package/dist/bin/vip-config-envvar-list.js +8 -20
- package/dist/bin/vip-config-envvar-set.js +4 -23
- package/dist/bin/vip-config-envvar.js +0 -2
- package/dist/bin/vip-config-software-get.js +0 -17
- package/dist/bin/vip-config-software-update.js +6 -22
- package/dist/bin/vip-config-software.js +0 -2
- package/dist/bin/vip-config.js +0 -2
- package/dist/bin/vip-dev-env-create.js +8 -21
- package/dist/bin/vip-dev-env-destroy.js +4 -11
- package/dist/bin/vip-dev-env-exec.js +4 -14
- package/dist/bin/vip-dev-env-import-media.js +3 -8
- package/dist/bin/vip-dev-env-import-sql.js +10 -23
- package/dist/bin/vip-dev-env-import.js +0 -3
- package/dist/bin/vip-dev-env-info.js +5 -13
- package/dist/bin/vip-dev-env-list.js +4 -9
- package/dist/bin/vip-dev-env-start.js +9 -17
- package/dist/bin/vip-dev-env-stop.js +4 -11
- package/dist/bin/vip-dev-env-update.js +4 -12
- package/dist/bin/vip-dev-env.js +0 -2
- package/dist/bin/vip-import-media-abort.js +0 -18
- package/dist/bin/vip-import-media-status.js +0 -12
- package/dist/bin/vip-import-media.js +6 -23
- package/dist/bin/vip-import-sql-status.js +0 -12
- package/dist/bin/vip-import-sql.js +33 -99
- package/dist/bin/vip-import-validate-files.js +21 -42
- package/dist/bin/vip-import-validate-sql.js +0 -8
- package/dist/bin/vip-import.js +0 -3
- package/dist/bin/vip-logs.js +20 -50
- package/dist/bin/vip-search-replace.js +8 -14
- package/dist/bin/vip-sync.js +2 -25
- package/dist/bin/vip-validate-preflight.js +467 -0
- package/dist/bin/vip-validate.js +19 -0
- package/dist/bin/vip-whoami.js +2 -14
- package/dist/bin/vip-wp.js +39 -89
- package/dist/bin/vip.js +14 -40
- package/dist/lib/analytics/clients/pendo.js +9 -18
- package/dist/lib/analytics/clients/stub.js +1 -3
- package/dist/lib/analytics/clients/tracks.js +11 -20
- package/dist/lib/analytics/index.js +4 -11
- package/dist/lib/api/app.js +1 -11
- package/dist/lib/api/cache-purge.js +4 -7
- package/dist/lib/api/feature-flags.js +1 -4
- package/dist/lib/api/http.js +9 -15
- package/dist/lib/api/user.js +1 -7
- package/dist/lib/api.js +7 -18
- package/dist/lib/app-logs/app-logs.js +2 -9
- package/dist/lib/app.js +2 -5
- package/dist/lib/cli/apiConfig.js +4 -19
- package/dist/lib/cli/command.js +43 -133
- package/dist/lib/cli/config.js +1 -5
- package/dist/lib/cli/envAlias.js +14 -15
- package/dist/lib/cli/exit.js +4 -6
- package/dist/lib/cli/format.js +8 -50
- package/dist/lib/cli/progress.js +13 -42
- package/dist/lib/cli/prompt.js +1 -5
- package/dist/lib/cli/repo.js +7 -20
- package/dist/lib/client-file-uploader.js +44 -97
- package/dist/lib/config/software.js +2 -52
- package/dist/lib/constants/dev-environment.js +1 -2
- package/dist/lib/constants/file-size.js +1 -1
- package/dist/lib/constants/vipgo.js +1 -1
- package/dist/lib/dev-environment/dev-environment-cli.js +140 -195
- package/dist/lib/dev-environment/dev-environment-core.js +91 -186
- package/dist/lib/dev-environment/dev-environment-lando.js +32 -96
- package/dist/lib/env.js +1 -4
- package/dist/lib/envvar/api-delete.js +1 -4
- package/dist/lib/envvar/api-get-all.js +1 -4
- package/dist/lib/envvar/api-get.js +1 -2
- package/dist/lib/envvar/api-list.js +3 -4
- package/dist/lib/envvar/api-set.js +1 -4
- package/dist/lib/envvar/api.js +5 -16
- package/dist/lib/envvar/input.js +1 -8
- package/dist/lib/envvar/logging.js +2 -6
- package/dist/lib/envvar/read-file.js +1 -3
- package/dist/lib/http/proxy-agent.js +17 -22
- package/dist/lib/keychain/browser.js +1 -4
- package/dist/lib/keychain/insecure.js +1 -10
- package/dist/lib/keychain/secure.js +1 -8
- package/dist/lib/keychain.js +4 -8
- package/dist/lib/logout.js +0 -6
- package/dist/lib/media-import/media-file-import.js +3 -7
- package/dist/lib/media-import/progress.js +6 -17
- package/dist/lib/media-import/status.js +14 -65
- package/dist/lib/read-file.js +1 -6
- package/dist/lib/rollbar.js +1 -7
- package/dist/lib/search-and-replace.js +9 -41
- package/dist/lib/site-import/db-file-import.js +3 -9
- package/dist/lib/site-import/status.js +17 -74
- package/dist/lib/token.js +1 -33
- package/dist/lib/tracker.js +4 -20
- package/dist/lib/user-error.js +0 -2
- package/dist/lib/validations/is-multi-site-sql-dump.js +4 -12
- package/dist/lib/validations/is-multi-site.js +5 -21
- package/dist/lib/validations/is-multisite-domain-mapped.js +5 -31
- package/dist/lib/validations/line-by-line.js +4 -16
- package/dist/lib/validations/site-type.js +10 -19
- package/dist/lib/validations/sql.js +11 -76
- package/dist/lib/validations/utils.js +1 -6
- package/dist/lib/vip-import-validate-files.js +82 -109
- package/npm-shrinkwrap.json +894 -357
- package/package.json +5 -2
|
@@ -4,23 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.validate = exports.staticSqlValidations = exports.getTableNames = void 0;
|
|
7
|
-
|
|
8
7
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
9
|
-
|
|
10
8
|
var _singleLineLog = require("single-line-log");
|
|
11
|
-
|
|
12
9
|
var exit = _interopRequireWildcard(require("../cli/exit"));
|
|
13
|
-
|
|
14
10
|
var _tracker = require("../tracker");
|
|
15
|
-
|
|
16
11
|
var _lineByLine = require("./line-by-line");
|
|
17
|
-
|
|
18
12
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
19
|
-
|
|
20
13
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
21
|
-
|
|
22
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
|
-
|
|
24
15
|
/**
|
|
25
16
|
*
|
|
26
17
|
* @format
|
|
@@ -33,35 +24,29 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
33
24
|
/**
|
|
34
25
|
* Internal dependencies
|
|
35
26
|
*/
|
|
27
|
+
|
|
36
28
|
let problemsFound = 0;
|
|
37
29
|
let lineNum = 1;
|
|
38
30
|
const tableNames = [];
|
|
39
|
-
|
|
40
31
|
function formatError(message) {
|
|
41
32
|
return `${_chalk.default.red('SQL Error:')} ${message}`;
|
|
42
33
|
}
|
|
43
|
-
|
|
44
34
|
function formatWarning(message) {
|
|
45
35
|
return `${_chalk.default.yellow('Warning:')} ${message}`;
|
|
46
36
|
}
|
|
47
|
-
|
|
48
37
|
function formatRecommendation(message) {
|
|
49
38
|
return `${_chalk.default.yellow('Recommendation:')} ${message}`;
|
|
50
39
|
}
|
|
51
|
-
|
|
52
40
|
const generalCheckFormatter = check => {
|
|
53
41
|
const errors = [];
|
|
54
42
|
const infos = [];
|
|
55
43
|
const validProblems = check.results.filter(result => !result.falsePositive);
|
|
56
|
-
|
|
57
44
|
if (validProblems.length > 0) {
|
|
58
45
|
if (validProblems.some(result => !result.warning)) {
|
|
59
46
|
problemsFound += 1;
|
|
60
47
|
}
|
|
61
|
-
|
|
62
48
|
for (const problem of validProblems) {
|
|
63
49
|
const text = `${problem.text || check.message} on line ${problem.lineNumber || ''}.`;
|
|
64
|
-
|
|
65
50
|
if (problem.warning) {
|
|
66
51
|
errors.push({
|
|
67
52
|
warning: formatWarning(text),
|
|
@@ -77,17 +62,14 @@ const generalCheckFormatter = check => {
|
|
|
77
62
|
} else {
|
|
78
63
|
infos.push(`✅ ${check.message} was found 0 times.`);
|
|
79
64
|
}
|
|
80
|
-
|
|
81
65
|
return {
|
|
82
66
|
errors,
|
|
83
67
|
infos
|
|
84
68
|
};
|
|
85
69
|
};
|
|
86
|
-
|
|
87
70
|
const lineNumberCheckFormatter = check => {
|
|
88
71
|
const errors = [];
|
|
89
72
|
const infos = [];
|
|
90
|
-
|
|
91
73
|
if (check.results.length > 0) {
|
|
92
74
|
problemsFound += 1;
|
|
93
75
|
const lineNumbers = check.results.map(result => result.lineNumber);
|
|
@@ -98,20 +80,16 @@ const lineNumberCheckFormatter = check => {
|
|
|
98
80
|
} else {
|
|
99
81
|
infos.push(`✅ ${check.message} was found 0 times.`);
|
|
100
82
|
}
|
|
101
|
-
|
|
102
83
|
return {
|
|
103
84
|
errors,
|
|
104
85
|
infos
|
|
105
86
|
};
|
|
106
87
|
};
|
|
107
|
-
|
|
108
88
|
const requiredCheckFormatter = (check, type, isImport) => {
|
|
109
89
|
const errors = [];
|
|
110
90
|
const infos = [];
|
|
111
|
-
|
|
112
91
|
if (check.results.length > 0) {
|
|
113
92
|
infos.push(`✅ ${check.message} was found ${check.results.length} times.`);
|
|
114
|
-
|
|
115
93
|
if (type === 'createTable') {
|
|
116
94
|
if (!isImport) {
|
|
117
95
|
checkTablePrefixes(check.results, errors, infos);
|
|
@@ -124,13 +102,11 @@ const requiredCheckFormatter = (check, type, isImport) => {
|
|
|
124
102
|
recommendation: formatRecommendation(check.recommendation)
|
|
125
103
|
});
|
|
126
104
|
}
|
|
127
|
-
|
|
128
105
|
return {
|
|
129
106
|
errors,
|
|
130
107
|
infos
|
|
131
108
|
};
|
|
132
109
|
};
|
|
133
|
-
|
|
134
110
|
const infoCheckFormatter = check => {
|
|
135
111
|
const infos = [];
|
|
136
112
|
check.results.forEach(item => {
|
|
@@ -141,14 +117,12 @@ const infoCheckFormatter = check => {
|
|
|
141
117
|
infos
|
|
142
118
|
};
|
|
143
119
|
};
|
|
144
|
-
|
|
145
120
|
function checkTablePrefixes(results, errors, infos) {
|
|
146
121
|
const wpTables = [],
|
|
147
|
-
|
|
148
|
-
|
|
122
|
+
notWPTables = [],
|
|
123
|
+
wpMultisiteTables = [];
|
|
149
124
|
results.forEach(result => {
|
|
150
125
|
const tableName = result.text || '';
|
|
151
|
-
|
|
152
126
|
if (tableName.match(/^wp_(\d+_)/)) {
|
|
153
127
|
wpMultisiteTables.push(tableName);
|
|
154
128
|
} else if (tableName.match(/^wp_/)) {
|
|
@@ -157,11 +131,9 @@ function checkTablePrefixes(results, errors, infos) {
|
|
|
157
131
|
notWPTables.push(tableName);
|
|
158
132
|
}
|
|
159
133
|
});
|
|
160
|
-
|
|
161
134
|
if (wpTables.length > 0) {
|
|
162
135
|
infos.push(` - wp_ prefix tables found: ${wpTables.length} `);
|
|
163
136
|
}
|
|
164
|
-
|
|
165
137
|
if (notWPTables.length > 0) {
|
|
166
138
|
problemsFound += 1;
|
|
167
139
|
errors.push({
|
|
@@ -169,12 +141,10 @@ function checkTablePrefixes(results, errors, infos) {
|
|
|
169
141
|
recommendation: formatRecommendation('Please make sure all table names are prefixed with `wp_`')
|
|
170
142
|
});
|
|
171
143
|
}
|
|
172
|
-
|
|
173
144
|
if (wpMultisiteTables.length > 0) {
|
|
174
145
|
infos.push(` - wp_n_ prefix tables found: ${wpMultisiteTables.length} `);
|
|
175
146
|
}
|
|
176
147
|
}
|
|
177
|
-
|
|
178
148
|
const checks = {
|
|
179
149
|
binaryLogging: {
|
|
180
150
|
matcher: /SET @@SESSION.sql_log_bin/i,
|
|
@@ -291,19 +261,16 @@ const checks = {
|
|
|
291
261
|
matcher: "'(siteurl|home)',\\s?'(.*?)'",
|
|
292
262
|
matchHandler: (lineNumber, results, expectedDomain) => {
|
|
293
263
|
const foundDomain = results[2].replace(/https?:\/\//, '');
|
|
294
|
-
|
|
295
264
|
if (!foundDomain.trim()) {
|
|
296
265
|
return {
|
|
297
266
|
falsePositive: true
|
|
298
267
|
};
|
|
299
268
|
}
|
|
300
|
-
|
|
301
269
|
if (foundDomain.includes(expectedDomain)) {
|
|
302
270
|
return {
|
|
303
271
|
falsePositive: true
|
|
304
272
|
};
|
|
305
273
|
}
|
|
306
|
-
|
|
307
274
|
return {
|
|
308
275
|
warning: true,
|
|
309
276
|
lineNumber,
|
|
@@ -329,26 +296,21 @@ const checks = {
|
|
|
329
296
|
}
|
|
330
297
|
};
|
|
331
298
|
const DEV_ENV_SPECIFIC_CHECKS = ['useStatement', 'siteHomeUrlLando'];
|
|
332
|
-
|
|
333
299
|
const postValidation = async options => {
|
|
334
300
|
await (0, _tracker.trackEvent)('import_validate_sql_command_execute', {
|
|
335
301
|
is_import: options.isImport
|
|
336
302
|
});
|
|
337
|
-
|
|
338
303
|
if (!options.isImport) {
|
|
339
304
|
(0, _singleLineLog.stdout)(`Finished processing ${lineNum} lines.`);
|
|
340
305
|
console.log('\n');
|
|
341
306
|
}
|
|
342
|
-
|
|
343
307
|
const errorSummary = {};
|
|
344
308
|
const checkEntries = Object.entries(checks).filter(([type]) => !options.skipChecks.includes(type));
|
|
345
309
|
const formattedWarnings = [];
|
|
346
310
|
let formattedErrors = [];
|
|
347
311
|
let formattedInfos = [];
|
|
348
|
-
|
|
349
312
|
for (const [type, check] of checkEntries) {
|
|
350
313
|
const formattedOutput = check.outputFormatter(check, type, options.isImport);
|
|
351
|
-
|
|
352
314
|
for (const error of formattedOutput.errors) {
|
|
353
315
|
if (error.warning) {
|
|
354
316
|
formattedWarnings.push(error);
|
|
@@ -356,19 +318,15 @@ const postValidation = async options => {
|
|
|
356
318
|
formattedErrors.push(error);
|
|
357
319
|
}
|
|
358
320
|
}
|
|
359
|
-
|
|
360
321
|
formattedInfos = formattedInfos.concat(formattedOutput.infos);
|
|
361
322
|
errorSummary[type] = check.results.length;
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
|
|
323
|
+
}
|
|
324
|
+
// eslint-disable-next-line camelcase
|
|
365
325
|
errorSummary.problems_found = problemsFound;
|
|
366
326
|
const tableNamesSet = new Set(tableNames);
|
|
367
|
-
|
|
368
327
|
if (tableNames.length > tableNamesSet.size) {
|
|
369
328
|
// there was a duplciate table
|
|
370
329
|
problemsFound++;
|
|
371
|
-
|
|
372
330
|
function findDuplicates(arr) {
|
|
373
331
|
const filtered = arr.filter(item => {
|
|
374
332
|
if (tableNamesSet.has(item)) {
|
|
@@ -379,7 +337,6 @@ const postValidation = async options => {
|
|
|
379
337
|
});
|
|
380
338
|
return [...new Set(filtered)];
|
|
381
339
|
}
|
|
382
|
-
|
|
383
340
|
const duplicates = findDuplicates(tableNames);
|
|
384
341
|
const errorObject = {
|
|
385
342
|
error: formatError('Duplicate table names were found: ' + duplicates.join(',')),
|
|
@@ -387,22 +344,18 @@ const postValidation = async options => {
|
|
|
387
344
|
};
|
|
388
345
|
formattedErrors = formattedErrors.concat(errorObject);
|
|
389
346
|
}
|
|
390
|
-
|
|
391
347
|
if (formattedWarnings.length) {
|
|
392
348
|
const warningOutput = [];
|
|
393
349
|
formattedWarnings.forEach(warning => {
|
|
394
350
|
warningOutput.push(warning.warning);
|
|
395
|
-
|
|
396
351
|
if (warning.recommendation) {
|
|
397
352
|
warningOutput.push(warning.recommendation);
|
|
398
353
|
}
|
|
399
|
-
|
|
400
354
|
warningOutput.push('');
|
|
401
355
|
});
|
|
402
356
|
console.log(warningOutput.join('\n'));
|
|
403
357
|
console.log('');
|
|
404
358
|
}
|
|
405
|
-
|
|
406
359
|
if (problemsFound > 0) {
|
|
407
360
|
await (0, _tracker.trackEvent)('import_validate_sql_command_failure', {
|
|
408
361
|
is_import: options.isImport,
|
|
@@ -411,75 +364,58 @@ const postValidation = async options => {
|
|
|
411
364
|
const errorOutput = [];
|
|
412
365
|
formattedErrors.forEach(error => {
|
|
413
366
|
errorOutput.push(error.error);
|
|
414
|
-
|
|
415
367
|
if (error.recommendation) {
|
|
416
368
|
errorOutput.push(error.recommendation);
|
|
417
369
|
}
|
|
418
|
-
|
|
419
370
|
errorOutput.push('');
|
|
420
371
|
});
|
|
421
372
|
errorOutput.push(_chalk.default.bold.red(`SQL validation failed due to ${problemsFound} error(s)`));
|
|
422
|
-
|
|
423
373
|
if (options.isImport) {
|
|
424
374
|
throw new Error(errorOutput.join('\n'));
|
|
425
375
|
}
|
|
426
|
-
|
|
427
376
|
exit.withError(errorOutput.join('\n'));
|
|
428
377
|
}
|
|
429
|
-
|
|
430
378
|
if (!options.isImport) {
|
|
431
379
|
console.log(formattedInfos.join('\n'));
|
|
432
380
|
console.log('');
|
|
433
381
|
}
|
|
434
|
-
|
|
435
382
|
await (0, _tracker.trackEvent)('import_validate_sql_command_success', {
|
|
436
383
|
is_import: options.isImport
|
|
437
384
|
});
|
|
438
385
|
};
|
|
439
|
-
|
|
440
386
|
const getTableNames = () => {
|
|
441
387
|
return tableNames;
|
|
442
388
|
};
|
|
443
|
-
|
|
444
389
|
exports.getTableNames = getTableNames;
|
|
445
|
-
|
|
446
390
|
const checkForTableName = line => {
|
|
447
391
|
const matches = line.match(/(?<=^CREATE\sTABLE\s)`?(?:(wp_[\d+_]?\w+))`?/);
|
|
448
|
-
|
|
449
392
|
if (matches) {
|
|
450
|
-
const tableName = matches[1];
|
|
451
|
-
|
|
393
|
+
const tableName = matches[1];
|
|
394
|
+
// we should only have one match if we have any since we're looking at the start of the string
|
|
452
395
|
tableNames.push(tableName);
|
|
453
396
|
}
|
|
454
397
|
};
|
|
455
|
-
|
|
456
398
|
const DEFAULT_VALIDATION_OPTIONS = {
|
|
457
399
|
isImport: true,
|
|
458
400
|
skipChecks: DEV_ENV_SPECIFIC_CHECKS,
|
|
459
401
|
extraCheckParams: {}
|
|
460
402
|
};
|
|
461
|
-
|
|
462
403
|
const perLineValidations = (line, options = DEFAULT_VALIDATION_OPTIONS) => {
|
|
463
404
|
if (lineNum % 500 === 0) {
|
|
464
405
|
options.isImport ? '' : (0, _singleLineLog.stdout)(`Reading line ${lineNum} `);
|
|
465
406
|
}
|
|
466
|
-
|
|
467
407
|
checkForTableName(line);
|
|
468
408
|
const checkKeys = Object.keys(checks).filter(checkItem => !options.skipChecks.includes(checkItem));
|
|
469
|
-
|
|
470
409
|
for (const checkKey of checkKeys) {
|
|
471
410
|
const check = checks[checkKey];
|
|
472
411
|
const results = line.match(check.matcher);
|
|
473
412
|
const extraCheckParams = options.extraCheckParams[checkKey];
|
|
474
|
-
|
|
475
413
|
if (results) {
|
|
476
414
|
check.results.push(check.matchHandler(lineNum, results, extraCheckParams));
|
|
477
415
|
}
|
|
478
416
|
}
|
|
479
|
-
|
|
480
417
|
lineNum += 1;
|
|
481
418
|
};
|
|
482
|
-
|
|
483
419
|
const postLineExecutionProcessing = async ({
|
|
484
420
|
isImport,
|
|
485
421
|
skipChecks
|
|
@@ -490,21 +426,21 @@ const postLineExecutionProcessing = async ({
|
|
|
490
426
|
extraCheckParams: {}
|
|
491
427
|
});
|
|
492
428
|
};
|
|
493
|
-
|
|
494
429
|
const staticSqlValidations = {
|
|
495
430
|
execute: perLineValidations,
|
|
496
431
|
postLineExecutionProcessing
|
|
497
|
-
};
|
|
432
|
+
};
|
|
498
433
|
|
|
434
|
+
// For standalone SQL validations
|
|
499
435
|
exports.staticSqlValidations = staticSqlValidations;
|
|
500
|
-
|
|
501
436
|
const validate = async (filename, options = DEFAULT_VALIDATION_OPTIONS) => {
|
|
502
437
|
const readInterface = await (0, _lineByLine.getReadInterface)(filename);
|
|
503
438
|
options.isImport = false;
|
|
504
439
|
readInterface.on('line', line => {
|
|
505
440
|
perLineValidations(line, options);
|
|
506
|
-
});
|
|
441
|
+
});
|
|
507
442
|
|
|
443
|
+
// Block until the processing completes
|
|
508
444
|
await new Promise(resolve => readInterface.on('close', resolve));
|
|
509
445
|
readInterface.close();
|
|
510
446
|
await postLineExecutionProcessing({
|
|
@@ -512,5 +448,4 @@ const validate = async (filename, options = DEFAULT_VALIDATION_OPTIONS) => {
|
|
|
512
448
|
skipChecks: options.skipChecks
|
|
513
449
|
});
|
|
514
450
|
};
|
|
515
|
-
|
|
516
451
|
exports.validate = validate;
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getMultilineStatement = getMultilineStatement;
|
|
7
|
-
|
|
8
7
|
/**
|
|
9
8
|
* Get SQL statements matching a supplied pattern from a file stream
|
|
10
9
|
*
|
|
@@ -15,31 +14,27 @@ function getMultilineStatement(statementRegex) {
|
|
|
15
14
|
const matchingStatements = [];
|
|
16
15
|
let isCapturing = false;
|
|
17
16
|
let index = 0;
|
|
17
|
+
|
|
18
18
|
/**
|
|
19
19
|
* Processes each line of the file stream and builds an array of statements which start with the supplied pattern
|
|
20
20
|
*
|
|
21
21
|
* @param {string} line A line from the file stream
|
|
22
22
|
* @returns {array} An array of matching statements where each statement is presented as an array of lines
|
|
23
23
|
*/
|
|
24
|
-
|
|
25
24
|
return line => {
|
|
26
25
|
const shouldStartCapture = statementRegex.test(line);
|
|
27
26
|
const shouldEndCapture = (shouldStartCapture || isCapturing) && /;$/.test(line);
|
|
28
|
-
|
|
29
27
|
if (shouldStartCapture) {
|
|
30
28
|
isCapturing = true;
|
|
31
29
|
matchingStatements[index] = [];
|
|
32
30
|
}
|
|
33
|
-
|
|
34
31
|
if (isCapturing) {
|
|
35
32
|
matchingStatements[index].push(line);
|
|
36
33
|
}
|
|
37
|
-
|
|
38
34
|
if (shouldEndCapture) {
|
|
39
35
|
isCapturing = false;
|
|
40
36
|
index++;
|
|
41
37
|
}
|
|
42
|
-
|
|
43
38
|
return matchingStatements;
|
|
44
39
|
};
|
|
45
40
|
}
|