@automattic/vip 3.22.6 → 3.23.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.
@@ -138,6 +138,8 @@ services:
138
138
  <% if ( phpmyadmin ) { %>
139
139
  phpmyadmin:
140
140
  type: compose
141
+ ssl: true
142
+ sslExpose: false
141
143
  services:
142
144
  image: phpmyadmin:5
143
145
  command: /docker-entrypoint.sh apache2-foreground
@@ -248,6 +250,8 @@ services:
248
250
 
249
251
  <% if ( mailpit ) { %>
250
252
  mailpit:
253
+ ssl: true
254
+ sslExpose: false
251
255
  type: compose
252
256
  services:
253
257
  image: axllent/mailpit:latest
@@ -2,6 +2,7 @@
2
2
  "use strict";
3
3
 
4
4
  exports.__esModule = true;
5
+ exports.confirmSkipBackup = void 0;
5
6
  exports.gates = gates;
6
7
  exports.parseHeaders = parseHeaders;
7
8
  exports.promptToContinue = void 0;
@@ -309,9 +310,69 @@ const promptToContinue = async ({
309
310
  };
310
311
 
311
312
  /**
312
- * @returns {Promise<string[]>}
313
+ * Show a huge warning and prompt the user to confirm twice when skipping backup
314
+ *
315
+ * @param {Function} track - Tracking function
316
+ * @returns {Promise<boolean>} True if user confirmed both times, false otherwise
313
317
  */
314
318
  exports.promptToContinue = promptToContinue;
319
+ const confirmSkipBackup = async track => {
320
+ console.log(_chalk.default.bold.red('⚠️ WARNING ⚠️'));
321
+ console.log(_chalk.default.red(_chalk.default.bold.red('YOU ARE ABOUT TO SKIP CREATING A BACKUP BEFORE IMPORTING SQL!\n')));
322
+ console.log(_chalk.default.bold.yellow('This action is EXTREMELY DANGEROUS and can result in:'));
323
+ console.log(_chalk.default.bold.yellow('• Permanent data loss'));
324
+ console.log(_chalk.default.bold.yellow('• Inability to automatically restore your database'));
325
+ console.log(_chalk.default.bold.yellow('• Complete site failure'));
326
+ console.log(_chalk.default.bold.red('There is NO way to undo this action once the import begins!\n'));
327
+ const importAbortedMsg = _chalk.default.red('✗ Import aborted.');
328
+ try {
329
+ // First confirmation: y/n prompt
330
+ const firstConfirm = await (0, _enquirer.prompt)({
331
+ type: 'confirm',
332
+ name: 'firstConfirm',
333
+ message: 'Are you absolutely certain you want to skip the backup?'
334
+ }).catch(() => {
335
+ return {
336
+ firstConfirm: false
337
+ };
338
+ });
339
+ if (!firstConfirm.firstConfirm) {
340
+ await track('import_sql_skip_backup_cancelled');
341
+ console.log(importAbortedMsg);
342
+ return false;
343
+ }
344
+
345
+ // Second confirmation: requires typing "yes"
346
+ const secondConfirm = await (0, _enquirer.prompt)({
347
+ type: 'input',
348
+ name: 'secondConfirm',
349
+ message: `Type '${_chalk.default.yellow('yes')}' (without quotes) to proceed WITHOUT creating a backup (this cannot be undone):\n`
350
+ }).catch(() => {
351
+ return {
352
+ secondConfirm: ''
353
+ };
354
+ });
355
+ if (secondConfirm.secondConfirm?.toLowerCase() !== 'yes') {
356
+ await track('import_sql_skip_backup_cancelled');
357
+ console.error('Failed to confirm!');
358
+ console.log(importAbortedMsg);
359
+ return false;
360
+ }
361
+ } catch (error) {
362
+ await track('import_sql_skip_backup_cancelled');
363
+ console.log(importAbortedMsg);
364
+ console.error(error);
365
+ return false;
366
+ }
367
+ await track('import_sql_skip_backup_confirmed');
368
+ console.log(_chalk.default.red('⚠️ Backup will be skipped. Proceeding with import...'));
369
+ return true;
370
+ };
371
+
372
+ /**
373
+ * @returns {Promise<string[]>}
374
+ */
375
+ exports.confirmSkipBackup = confirmSkipBackup;
315
376
  async function validateAndGetTableNames({
316
377
  skipValidate,
317
378
  appId,
@@ -413,7 +474,7 @@ const displayPlaybook = ({
413
474
  requiredArgs: 1,
414
475
  module: 'import-sql',
415
476
  usage
416
- }).command('status', 'Check the status of a SQL database import currently in progress.').option('skip-validate', 'Do not perform file validation prior to import. If the file contains unsupported entries, the import is likely to fail.').option('search-replace', 'Search for a string in a local or remote SQL database file and replace it with a new string. Separate the values by a comma only; no spaces (e.g. --search-replace="from,to"). Can be passed more than once.').option('in-place', 'Overwrite a local SQL database file with the results of a search and replace operation prior to import.').option('output', 'Save the results of a --search-replace operation that is run against a local SQL database file to a copy of that file. Accepts a local file path. Ignored when used with the --in-place option.').option('skip-maintenance-mode', 'Prevent an unlaunched environment from going into maintenance mode during the import of a local or remote SQL database file. Skipping maintenance mode can cause site instability during import.').option('md5', 'Verify the integrity of a remote SQL database file. Accepts an MD5 hash value.').option('header', 'Pass a header name and value (Formatted as "Name: Value") in a request for a remote SQL database file. Can be passed more than once for multiple headers and values.').examples(examples)
477
+ }).command('status', 'Check the status of a SQL database import currently in progress.').option('skip-validate', 'Do not perform file validation prior to import. If the file contains unsupported entries, the import is likely to fail.').option('search-replace', 'Search for a string in a local or remote SQL database file and replace it with a new string. Separate the values by a comma only; no spaces (e.g. --search-replace="from,to"). Can be passed more than once.').option('in-place', 'Overwrite a local SQL database file with the results of a search and replace operation prior to import.').option('output', 'Save the results of a --search-replace operation that is run against a local SQL database file to a copy of that file. Accepts a local file path. Ignored when used with the --in-place option.').option('skip-maintenance-mode', 'Prevent an unlaunched environment from going into maintenance mode during the import of a local or remote SQL database file. Skipping maintenance mode can cause site instability during import.').option('md5', 'Verify the integrity of a remote SQL database file. Accepts an MD5 hash value.').option('header', 'Pass a header name and value (Formatted as "Name: Value") in a request for a remote SQL database file. Can be passed more than once for multiple headers and values.').option(['B', 'skip-backup'], 'Skip creating a backup before importing the SQL file. WARNING: This is extremely dangerous and can result in permanent data loss.').examples(examples)
417
478
  // eslint-disable-next-line complexity
418
479
  .argv(process.argv, async (arg, opts) => {
419
480
  const {
@@ -425,7 +486,8 @@ const displayPlaybook = ({
425
486
  searchReplace,
426
487
  skipMaintenanceMode,
427
488
  md5,
428
- header
489
+ header,
490
+ skipBackup
429
491
  } = opts;
430
492
  const {
431
493
  id: envId,
@@ -498,6 +560,12 @@ const displayPlaybook = ({
498
560
  isMultiSite,
499
561
  tableNames
500
562
  });
563
+ if (skipBackup) {
564
+ const confirmed = await confirmSkipBackup(track);
565
+ if (!confirmed) {
566
+ process.exit(0);
567
+ }
568
+ }
501
569
  if (!isUrl && opts.inPlace) {
502
570
  const approved = await (0, _prompt.confirm)([], 'Are you sure you want to run search and replace on your input file? This operation is not reversible.');
503
571
  if (!approved) {
@@ -564,7 +632,10 @@ Processing the SQL import for your environment...
564
632
  input: {
565
633
  id: app.id,
566
634
  environmentId: env.id,
567
- skipMaintenanceMode
635
+ skipMaintenanceMode,
636
+ ...(skipBackup && {
637
+ skipBackup: true
638
+ })
568
639
  }
569
640
  };
570
641
  if (isUrl) {
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@automattic/vip",
3
- "version": "3.22.6",
3
+ "version": "3.23.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@automattic/vip",
9
- "version": "3.22.6",
9
+ "version": "3.23.0",
10
10
  "hasInstallScript": true,
11
11
  "license": "MIT",
12
12
  "dependencies": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automattic/vip",
3
- "version": "3.22.6",
3
+ "version": "3.23.0",
4
4
  "description": "The VIP Javascript library & CLI",
5
5
  "main": "index.js",
6
6
  "bin": {