@automattic/vip 3.10.0 → 3.11.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.
@@ -340,14 +340,15 @@ void (0, _command.default)({
340
340
  requiredArgs: 1,
341
341
  module: 'import-sql',
342
342
  usage
343
- }).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 the SQL file and replace it with a new string. Separate the values by a comma only; no spaces (e.g. --search-replace=“from,to”).').option('in-place', 'Overwrite the local input file with the results of the search and replace operation prior to import.').option('output', 'The local file path to save a copy of the results from the search and replace operation when the --search-replace option is passed. Ignored when used with the --in-place option.').examples(examples).argv(process.argv, async (arg, opts) => {
343
+ }).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 the SQL file and replace it with a new string. Separate the values by a comma only; no spaces (e.g. --search-replace=“from,to”).').option('in-place', 'Overwrite the local input file with the results of the search and replace operation prior to import.').option('output', 'The local file path to save a copy of the results from the search and replace operation when the --search-replace option is passed. Ignored when used with the --in-place option.').option('skip-maintenance-mode', 'Imports data without putting the environment in maintenance mode. Available only for unlaunched environments. Caution: This may cause site instability during import.').examples(examples).argv(process.argv, async (arg, opts) => {
344
344
  const {
345
345
  app,
346
346
  env
347
347
  } = opts;
348
348
  let {
349
349
  skipValidate,
350
- searchReplace
350
+ searchReplace,
351
+ skipMaintenanceMode
351
352
  } = opts;
352
353
  const {
353
354
  id: envId,
@@ -495,7 +496,8 @@ Processing the SQL import for your environment...
495
496
  environmentId: env.id,
496
497
  basename,
497
498
  md5,
498
- searchReplace: []
499
+ searchReplace: [],
500
+ skipMaintenanceMode
499
501
  };
500
502
  if (searchReplace) {
501
503
  let pairs = searchReplace;
@@ -92,6 +92,9 @@ class DevEnvImportSQLCommand {
92
92
  if (searchReplace?.length && !inPlace) {
93
93
  _fs.default.unlinkSync(resolvedPath);
94
94
  }
95
+ if (this.options.postImportSQL) {
96
+ await (0, _devEnvironmentDatabase.executeQuery)(lando, this.slug, this.options.postImportSQL);
97
+ }
95
98
  await (0, _devEnvironmentDatabase.flushCache)(lando, this.slug, this.options.quiet);
96
99
  if (undefined === this.options.skipReindex || !(0, _devEnvironmentCli.processBooleanOption)(this.options.skipReindex)) {
97
100
  try {
@@ -205,15 +205,16 @@ class DevEnvSyncSQLCommand {
205
205
  const importOptions = {
206
206
  inPlace: true,
207
207
  skipValidate: true,
208
- quiet: true
208
+ quiet: true,
209
+ postImportSQL: this.fixBlogsTableQuery()
209
210
  };
210
211
  const importCommand = new _devEnvImportSql.DevEnvImportSQLCommand(this.sqlFile, importOptions, this.slug);
211
212
  await importCommand.run();
212
213
  }
213
- async fixBlogsTable() {
214
+ fixBlogsTableQuery() {
214
215
  const networkSites = this.env.wpSitesSDS?.nodes;
215
216
  if (!networkSites) {
216
- return;
217
+ return '';
217
218
  }
218
219
  const prologue = `
219
220
  DROP PROCEDURE IF EXISTS vip_sync_update_blog_domains;
@@ -240,10 +241,10 @@ DROP PROCEDURE vip_sync_update_blog_domains;
240
241
  const newDomain = primaryDomain !== oldDomain ? `${this.slugifyDomain(oldDomain)}.${this.landoDomain}` : this.landoDomain;
241
242
  queries.push(` UPDATE wp_blogs SET domain = '${newDomain}' WHERE blog_id = ${Number(site.blogId)};`);
242
243
  }
243
- if (queries.length) {
244
- const sql = `${prologue}\n${queries.join('\n')}\n${epilogue}`;
245
- await _fs.default.promises.appendFile(this.sqlFile, sql);
244
+ if (queries.length === 0) {
245
+ return '';
246
246
  }
247
+ return `${prologue}\n${queries.join('\n')}\n${epilogue}`;
247
248
  }
248
249
 
249
250
  /**
@@ -301,7 +302,6 @@ DROP PROCEDURE vip_sync_update_blog_domains;
301
302
  console.log(` ${domain} -> ${landoDomain}`);
302
303
  }
303
304
  await this.runSearchReplace();
304
- await this.fixBlogsTable();
305
305
  console.log(`${_chalk.default.green('✓')} Search-replace operation is complete`);
306
306
  } catch (err) {
307
307
  const error = err;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  exports.__esModule = true;
4
- exports.reIndexSearch = exports.flushCache = exports.dataCleanup = exports.addAdminUser = void 0;
4
+ exports.reIndexSearch = exports.flushCache = exports.executeQuery = exports.dataCleanup = exports.addAdminUser = void 0;
5
5
  var _devEnvironmentCore = require("./dev-environment-core");
6
6
  const addAdminUser = async (lando, slug, quiet) => {
7
7
  const addUserArg = ['wp', 'dev-env-add-admin', '--username=vipgo', '--password=password', '--skip-plugins', '--skip-themes'].concat(quiet ? ['--quiet'] : []);
@@ -29,4 +29,8 @@ const flushCache = async (lando, slug, quiet) => {
29
29
  const cacheArg = ['wp', 'cache', 'flush', '--skip-plugins', '--skip-themes'].concat(quiet ? ['--quiet'] : []);
30
30
  await (0, _devEnvironmentCore.exec)(lando, slug, cacheArg);
31
31
  };
32
- exports.flushCache = flushCache;
32
+ exports.flushCache = flushCache;
33
+ const executeQuery = async (lando, slug, query) => {
34
+ await (0, _devEnvironmentCore.exec)(lando, slug, ['wp', 'db', 'query', query]);
35
+ };
36
+ exports.executeQuery = executeQuery;
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@automattic/vip",
3
- "version": "3.10.0",
3
+ "version": "3.11.0",
4
4
  "lockfileVersion": 2,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@automattic/vip",
9
- "version": "3.10.0",
9
+ "version": "3.11.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.10.0",
3
+ "version": "3.11.0",
4
4
  "description": "The VIP Javascript library & CLI",
5
5
  "main": "index.js",
6
6
  "bin": {