@automattic/vip 2.31.1-dev → 2.31.1-dev3

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.
Files changed (37) hide show
  1. package/.editorconfig +11 -0
  2. package/.prettierignore +6 -0
  3. package/CONTRIBUTING.md +20 -19
  4. package/dist/bin/vip-app-list.js +12 -10
  5. package/dist/bin/vip-dev-env-start.js +4 -1
  6. package/dist/bin/vip-dev-env-sync-sql.js +1 -1
  7. package/dist/bin/vip-export-sql.js +3 -2
  8. package/dist/bin/vip-import-media-abort.js +3 -3
  9. package/dist/bin/vip-import-media.js +3 -3
  10. package/dist/bin/vip-import-sql.js +2 -1
  11. package/dist/bin/vip-sync.js +27 -13
  12. package/dist/bin/vip-validate-preflight.js +16 -14
  13. package/dist/bin/vip-wp.js +9 -9
  14. package/dist/commands/backup-db.js +30 -26
  15. package/dist/commands/export-sql.js +2 -3
  16. package/dist/lib/api/cache-purge.js +2 -10
  17. package/dist/lib/app-logs/app-logs.js +10 -4
  18. package/dist/lib/cli/format.js +2 -2
  19. package/dist/lib/config/software.js +10 -9
  20. package/dist/lib/constants/dev-environment.js +3 -6
  21. package/dist/lib/dev-environment/dev-environment-cli.js +3 -3
  22. package/dist/lib/dev-environment/dev-environment-core.js +52 -41
  23. package/dist/lib/dev-environment/dev-environment-lando.js +3 -1
  24. package/dist/lib/envvar/api-delete.js +2 -11
  25. package/dist/lib/envvar/api-get-all.js +3 -10
  26. package/dist/lib/envvar/api-list.js +3 -10
  27. package/dist/lib/envvar/api-set.js +2 -12
  28. package/dist/lib/media-import/status.js +18 -18
  29. package/dist/lib/validations/site-type.js +1 -1
  30. package/dist/lib/validations/sql.js +2 -1
  31. package/dist/lib/vip-import-validate-files.js +1 -0
  32. package/helpers/check-version.js +7 -5
  33. package/helpers/prepublishOnly.js +90 -0
  34. package/npm-shrinkwrap.json +238 -3936
  35. package/package.json +12 -12
  36. package/tsconfig.json +5 -9
  37. package/automattic-vip-2.31.1-dev.tgz +0 -0
@@ -91,16 +91,16 @@ const updateSoftwareMutation = (0, _graphqlTag.default)`
91
91
  }
92
92
  ) {
93
93
  php {
94
- ...Software
94
+ ...Software
95
95
  }
96
96
  wordpress {
97
- ...Software
97
+ ...Software
98
98
  }
99
99
  muplugins {
100
- ...Software
100
+ ...Software
101
101
  }
102
102
  nodejs {
103
- ...Software
103
+ ...Software
104
104
  }
105
105
  }
106
106
  }
@@ -108,9 +108,9 @@ const updateSoftwareMutation = (0, _graphqlTag.default)`
108
108
  `;
109
109
  const updateJobQuery = (0, _graphqlTag.default)`
110
110
  query UpdateJob($appId: Int!, $envId: Int!) {
111
- app(id: $appId ) {
111
+ app(id: $appId) {
112
112
  environments(id: $envId) {
113
- jobs (types:["upgrade_php", "upgrade_wordpress", "upgrade_muplugins", "upgrade_nodejs"]) {
113
+ jobs(types: ["upgrade_php", "upgrade_wordpress", "upgrade_muplugins", "upgrade_nodejs"]) {
114
114
  type
115
115
  completedAt
116
116
  createdAt
@@ -126,7 +126,8 @@ const updateJobQuery = (0, _graphqlTag.default)`
126
126
  }
127
127
  }
128
128
  }
129
- }`;
129
+ }
130
+ `;
130
131
  const COMPONENT_NAMES = {
131
132
  wordpress: 'WordPress',
132
133
  php: 'PHP',
@@ -236,9 +237,9 @@ const _processComponentVersion = (softwareSettings, component, userProvidedVersi
236
237
  const promptForUpdate = async (appTypeId, opts, softwareSettings) => {
237
238
  const component = await _processComponent(appTypeId, opts.component);
238
239
  const version = await _processComponentVersion(softwareSettings, component, opts.version);
239
-
240
+ const confirm =
240
241
  // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
241
- const confirm = opts.force || (await new _enquirer.Confirm({
242
+ opts.force || (await new _enquirer.Confirm({
242
243
  // NOSONAR
243
244
  message: `Are you sure you want to upgrade ${COMPONENT_NAMES[component]} to ${version}?`
244
245
  }).run().catch(() => {
@@ -30,11 +30,8 @@ const DEV_ENVIRONMENT_WORDPRESS_VERSION_TTL = 86400; // once per day
30
30
  exports.DEV_ENVIRONMENT_WORDPRESS_VERSION_TTL = DEV_ENVIRONMENT_WORDPRESS_VERSION_TTL;
31
31
  const DEV_ENVIRONMENT_PHP_VERSIONS = {
32
32
  '8.0': 'ghcr.io/automattic/vip-container-images/php-fpm:8.0',
33
- // eslint-disable-next-line quote-props
34
- '8.2': 'ghcr.io/automattic/vip-container-images/php-fpm:8.2',
35
- // eslint-disable-next-line quote-props
36
- '8.1': 'ghcr.io/automattic/vip-container-images/php-fpm:8.1',
37
- // eslint-disable-next-line quote-props -- flow does not support non-string keys
38
- '7.4': 'ghcr.io/automattic/vip-container-images/php-fpm:7.4'
33
+ 8.2: 'ghcr.io/automattic/vip-container-images/php-fpm:8.2',
34
+ 8.1: 'ghcr.io/automattic/vip-container-images/php-fpm:8.1',
35
+ 7.4: 'ghcr.io/automattic/vip-container-images/php-fpm:7.4'
39
36
  };
40
37
  exports.DEV_ENVIRONMENT_PHP_VERSIONS = DEV_ENVIRONMENT_PHP_VERSIONS;
@@ -712,10 +712,10 @@ async function postStart(slug, options) {
712
712
  const launchVSCode = slug => {
713
713
  const workspacePath = (0, _devEnvironmentCore.getVSCodeWorkspacePath)(slug);
714
714
  if (_fs.default.existsSync(workspacePath)) {
715
- console.log('VSCode workspace already exists, skipping creation.');
715
+ console.log('VS Code workspace already exists, skipping creation.');
716
716
  } else {
717
717
  (0, _devEnvironmentCore.generateVSCodeWorkspace)(slug);
718
- console.log('VSCode workspace generated');
718
+ console.log('VS Code workspace generated');
719
719
  }
720
720
  const vsCodeExecutable = getVSCodeExecutable();
721
721
  if (vsCodeExecutable) {
@@ -723,7 +723,7 @@ const launchVSCode = slug => {
723
723
  shell: process.platform === 'win32'
724
724
  });
725
725
  } else {
726
- console.log(`VSCode not detected in path, please open ${workspacePath} with VSCode`);
726
+ console.log(`VS Code was not detected in the expected path. VS Code Workspace file location:\n${workspacePath}`);
727
727
  }
728
728
  };
729
729
  const getVSCodeExecutable = () => {
@@ -43,11 +43,6 @@ var _devEnvironment = require("../constants/dev-environment");
43
43
  var _software = require("../config/software");
44
44
  var _userError = _interopRequireDefault(require("../user-error"));
45
45
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
46
- /**
47
- *
48
- * @format
49
- */
50
-
51
46
  /**
52
47
  * External dependencies
53
48
  */
@@ -64,6 +59,10 @@ const nginxFileName = 'extra.conf';
64
59
  const instanceDataFileName = 'instance_data.json';
65
60
  const uploadPathString = 'uploads';
66
61
  const nginxPathString = 'nginx';
62
+ function xdgDataDirectory() {
63
+ var _xdgBasedir$data;
64
+ return (_xdgBasedir$data = _xdgBasedir.default.data) !== null && _xdgBasedir$data !== void 0 && _xdgBasedir$data.length ? _xdgBasedir.default.data : _os.default.tmpdir();
65
+ }
67
66
  async function startEnvironment(lando, slug, options) {
68
67
  debug('Will start an environment', slug);
69
68
  const instancePath = getEnvironmentPath(slug);
@@ -115,7 +114,7 @@ async function updateEnvironment(instanceData) {
115
114
  debug('Instance path for', slug, 'is:', instancePath);
116
115
  const alreadyExists = _fs.default.existsSync(instancePath);
117
116
  if (!alreadyExists) {
118
- throw new Error('Environment doesn\'t exist.');
117
+ throw new Error("Environment doesn't exist.");
119
118
  }
120
119
  const preProcessedInstanceData = preProcessInstanceData(instanceData);
121
120
  debug('Will create an environment', slug, 'with instanceData: ', preProcessedInstanceData);
@@ -125,15 +124,20 @@ function preProcessInstanceData(instanceData) {
125
124
  const newInstanceData = {
126
125
  ...instanceData
127
126
  };
128
- if (instanceData.mediaRedirectDomain && !instanceData.mediaRedirectDomain.match(/^http/)) {
127
+ if (instanceData.mediaRedirectDomain && !/^http/.exec(instanceData.mediaRedirectDomain)) {
129
128
  // We need to make sure the redirect is an absolute path
130
129
  newInstanceData.mediaRedirectDomain = `https://${instanceData.mediaRedirectDomain}`;
131
130
  }
132
- newInstanceData.elasticsearch = instanceData.elasticsearch || false;
131
+
132
+ // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
133
+ newInstanceData.elasticsearch = instanceData.elasticsearch || false; // NOSONAR
134
+
133
135
  newInstanceData.php = instanceData.php || _devEnvironment.DEV_ENVIRONMENT_PHP_VERSIONS[Object.keys(_devEnvironment.DEV_ENVIRONMENT_PHP_VERSIONS)[0]];
134
136
  if (newInstanceData.php.startsWith('image:')) {
135
137
  newInstanceData.php = newInstanceData.php.slice('image:'.length);
136
138
  }
139
+
140
+ // FIXME: isNaN supports only number in TypeScript, actually, because isNaN('123') returns false despite being a string
137
141
  if (isNaN(instanceData.wordpress.tag)) {
138
142
  newInstanceData.wordpress.tag = 'trunk';
139
143
  }
@@ -206,10 +210,12 @@ async function printAllEnvironmentsInfo(lando, options) {
206
210
  }
207
211
  }
208
212
  function parseComponentForInfo(component) {
213
+ var _component$tag;
209
214
  if (component.mode === 'local') {
210
- return component.dir || '';
215
+ var _component$dir;
216
+ return (_component$dir = component.dir) !== null && _component$dir !== void 0 ? _component$dir : '';
211
217
  }
212
- return component.tag || '[demo-image]';
218
+ return (_component$tag = component.tag) !== null && _component$tag !== void 0 ? _component$tag : '[demo-image]';
213
219
  }
214
220
  async function showLogs(lando, slug, options = {}) {
215
221
  debug('Will display logs command on env', slug, 'with options', options);
@@ -274,12 +280,14 @@ function readEnvironmentData(slug) {
274
280
  let instanceData;
275
281
  try {
276
282
  instanceDataString = _fs.default.readFileSync(instanceDataTargetPath, 'utf8');
277
- } catch (err) {
283
+ } catch (error) {
284
+ const err = error;
278
285
  throw new _userError.default(`There was an error reading file "${instanceDataTargetPath}": ${err.message}.`);
279
286
  }
280
287
  try {
281
288
  instanceData = JSON.parse(instanceDataString);
282
- } catch (err) {
289
+ } catch (error) {
290
+ const err = error;
283
291
  throw new _userError.default(`There was an error parsing file "${instanceDataTargetPath}": ${err.message}. You may need to recreate the environment.`);
284
292
  }
285
293
 
@@ -312,7 +320,7 @@ function readEnvironmentData(slug) {
312
320
  *
313
321
  * @param {string} slug Env slug
314
322
  * @param {InstanceData} data instance data
315
- * @return {Promise} Promise
323
+ * @return {Promise<void>} Promise
316
324
  */
317
325
  function writeEnvironmentData(slug, data) {
318
326
  debug('Will try to write instance data for environment', slug);
@@ -340,7 +348,7 @@ async function prepareLandoEnv(instanceData, instancePath) {
340
348
  debug(`Instance data file created in ${instanceDataTargetPath}`);
341
349
  }
342
350
  function getAllEnvironmentNames() {
343
- const mainEnvironmentPath = _xdgBasedir.default.data || _os.default.tmpdir();
351
+ const mainEnvironmentPath = xdgDataDirectory();
344
352
  const baseDir = _path.default.join(mainEnvironmentPath, 'vip', 'dev-environment');
345
353
  const doWeHaveAnyEnvironment = _fs.default.existsSync(baseDir);
346
354
  let envNames = [];
@@ -357,7 +365,7 @@ function getEnvironmentPath(name) {
357
365
  if (!name) {
358
366
  throw new Error('Name was not provided');
359
367
  }
360
- const mainEnvironmentPath = _xdgBasedir.default.data || _os.default.tmpdir();
368
+ const mainEnvironmentPath = xdgDataDirectory();
361
369
  return _path.default.join(mainEnvironmentPath, 'vip', 'dev-environment', name + '');
362
370
  }
363
371
  async function getApplicationInformation(appId, envType) {
@@ -389,12 +397,14 @@ async function getApplicationInformation(appId, envType) {
389
397
  }`;
390
398
  const queryResult = await (0, _app.default)(appId, fieldsQuery, _software.appQueryFragments);
391
399
  const appData = {};
392
- if (queryResult) {
393
- var _queryResult$reposito;
400
+ if (queryResult.id) {
401
+ var _queryResult$reposito, _queryResult$environm;
394
402
  appData.id = queryResult.id;
395
403
  appData.name = queryResult.name;
396
404
  appData.repository = (_queryResult$reposito = queryResult.repository) === null || _queryResult$reposito === void 0 ? void 0 : _queryResult$reposito.htmlUrl;
397
- const environments = queryResult.environments || [];
405
+
406
+ // FIXME: This is casted as AppEnvironment[] but pedantically, Parker's schema made it so that the array may contain nullable. Code-wise though, that doesn't actually happen.
407
+ const environments = (_queryResult$environm = queryResult.environments) !== null && _queryResult$environm !== void 0 ? _queryResult$environm : [];
398
408
  let envData;
399
409
  if (envType) {
400
410
  envData = environments.find(candidateEnv => candidateEnv.type === envType);
@@ -413,15 +423,15 @@ async function getApplicationInformation(appId, envType) {
413
423
  envData = environments.find(candidateEnv => candidateEnv.type === env);
414
424
  }
415
425
  if (envData) {
416
- var _envData$primaryDomai, _envData$softwareSett, _envData$softwareSett2, _envData$softwareSett3, _envData$softwareSett4, _envData$softwareSett5, _envData$softwareSett6;
426
+ var _envData$primaryDomai, _envData$primaryDomai2, _envData$softwareSett, _envData$softwareSett2, _envData$softwareSett3, _envData$softwareSett4, _envData$softwareSett5, _envData$softwareSett6;
417
427
  appData.environment = {
418
428
  name: envData.name,
419
429
  branch: envData.branch,
420
430
  type: envData.type,
421
431
  isMultisite: envData.isMultisite,
422
- primaryDomain: ((_envData$primaryDomai = envData.primaryDomain) === null || _envData$primaryDomai === void 0 ? void 0 : _envData$primaryDomai.name) || '',
423
- php: ((_envData$softwareSett = envData.softwareSettings) === null || _envData$softwareSett === void 0 ? void 0 : (_envData$softwareSett2 = _envData$softwareSett.php) === null || _envData$softwareSett2 === void 0 ? void 0 : (_envData$softwareSett3 = _envData$softwareSett2.current) === null || _envData$softwareSett3 === void 0 ? void 0 : _envData$softwareSett3.version) || '',
424
- wordpress: ((_envData$softwareSett4 = envData.softwareSettings) === null || _envData$softwareSett4 === void 0 ? void 0 : (_envData$softwareSett5 = _envData$softwareSett4.wordpress) === null || _envData$softwareSett5 === void 0 ? void 0 : (_envData$softwareSett6 = _envData$softwareSett5.current) === null || _envData$softwareSett6 === void 0 ? void 0 : _envData$softwareSett6.version) || ''
432
+ primaryDomain: (_envData$primaryDomai = (_envData$primaryDomai2 = envData.primaryDomain) === null || _envData$primaryDomai2 === void 0 ? void 0 : _envData$primaryDomai2.name) !== null && _envData$primaryDomai !== void 0 ? _envData$primaryDomai : '',
433
+ php: (_envData$softwareSett = (_envData$softwareSett2 = envData.softwareSettings) === null || _envData$softwareSett2 === void 0 ? void 0 : (_envData$softwareSett3 = _envData$softwareSett2.php) === null || _envData$softwareSett3 === void 0 ? void 0 : _envData$softwareSett3.current.version) !== null && _envData$softwareSett !== void 0 ? _envData$softwareSett : '',
434
+ wordpress: (_envData$softwareSett4 = (_envData$softwareSett5 = envData.softwareSettings) === null || _envData$softwareSett5 === void 0 ? void 0 : (_envData$softwareSett6 = _envData$softwareSett5.wordpress) === null || _envData$softwareSett6 === void 0 ? void 0 : _envData$softwareSett6.current.version) !== null && _envData$softwareSett4 !== void 0 ? _envData$softwareSett4 : ''
425
435
  };
426
436
  }
427
437
  }
@@ -439,7 +449,7 @@ async function resolveImportPath(slug, fileName, searchReplace, inPlace) {
439
449
  }
440
450
 
441
451
  // Run Search and Replace if the --search-replace flag was provided
442
- if (searchReplace && searchReplace.length) {
452
+ if (searchReplace !== null && searchReplace !== void 0 && searchReplace.length) {
443
453
  const {
444
454
  outputFileName
445
455
  } = await (0, _searchAndReplace.searchAndReplace)(resolvedPath, searchReplace, {
@@ -464,7 +474,7 @@ async function importMediaPath(slug, filePath) {
464
474
  throw new Error(_devEnvironment.DEV_ENVIRONMENT_NOT_FOUND);
465
475
  }
466
476
  const files = _fs.default.readdirSync(resolvedPath);
467
- if (files.indexOf(uploadPathString) > -1) {
477
+ if (files.includes(uploadPathString)) {
468
478
  const confirm = await (0, _enquirer.prompt)({
469
479
  type: 'confirm',
470
480
  name: 'continue',
@@ -506,13 +516,14 @@ async function updateWordPressImage(slug) {
506
516
  if (currentWordPressTag === 'trunk') {
507
517
  return false;
508
518
  }
509
- } catch (error) {
519
+ } catch (err) {
520
+ const error = err;
510
521
  // This can throw an exception if the env is build with older vip version
511
522
  if ('ENOENT' === error.code) {
512
523
  message = 'Environment was created before update was supported.\n\n';
513
524
  message += 'To update environment please destroy it and create a new one.';
514
525
  } else {
515
- message = `An error prevented reading the configuration of: ${slug}\n\n ${error}`;
526
+ message = `An error prevented reading the configuration of: ${slug}\n\n ${error.message}`;
516
527
  }
517
528
  await (0, _devEnvironmentCli.handleCLIException)(new Error(message));
518
529
  return false;
@@ -520,15 +531,14 @@ async function updateWordPressImage(slug) {
520
531
 
521
532
  // sort
522
533
  versions.sort((before, after) => before.tag < after.tag ? 1 : -1);
523
-
524
534
  // Newest WordPress Image but that is not trunk
525
535
  const newestWordPressImage = versions.find(({
526
536
  tag
527
537
  }) => tag !== 'trunk');
528
- console.log('The most recent WordPress version available is: ' + _chalk.default.green(newestWordPressImage.tag));
538
+ console.log('The most recent WordPress version available is: ' + _chalk.default.green(newestWordPressImage === null || newestWordPressImage === void 0 ? void 0 : newestWordPressImage.tag));
529
539
 
530
540
  // If the currently used version is the most up to date: exit.
531
- if (currentWordPressTag === newestWordPressImage.tag) {
541
+ if (currentWordPressTag === (newestWordPressImage === null || newestWordPressImage === void 0 ? void 0 : newestWordPressImage.tag)) {
532
542
  console.log('Environment WordPress version is: ' + _chalk.default.green(currentWordPressTag) + ' ... 😎 nice! ');
533
543
  return false;
534
544
  }
@@ -559,6 +569,7 @@ async function updateWordPressImage(slug) {
559
569
 
560
570
  // If the user takes the new WP version path
561
571
  if (confirm.upgrade === 'yes') {
572
+ var _version$tag;
562
573
  console.log('Upgrading from: ' + _chalk.default.yellow(currentWordPressTag) + ' to:');
563
574
 
564
575
  // Select a new image
@@ -568,15 +579,17 @@ async function updateWordPressImage(slug) {
568
579
  }) => tag.trim() === choice.tag.trim());
569
580
 
570
581
  // Write new data and stage for rebuild
571
- envData.wordpress.tag = version.tag;
572
- envData.wordpress.ref = version.ref;
582
+ // FIXME: version?.tag is possibly null. Should we throw if we can't find a version somehow?
583
+ envData.wordpress.tag = (_version$tag = version === null || version === void 0 ? void 0 : version.tag) !== null && _version$tag !== void 0 ? _version$tag : '';
584
+ envData.wordpress.ref = version === null || version === void 0 ? void 0 : version.ref;
573
585
  await updateEnvironment(envData);
574
586
  return true;
575
587
  }
576
588
  if (confirm.upgrade === "no (don't ask anymore)") {
589
+ const updateCommand = `vip dev-env update --slug=${slug}`;
577
590
  envData.wordpress.doNotUpgrade = true;
578
591
  console.log("We won't ask about upgrading this environment anymore.");
579
- console.log('To manually upgrade please run:' + `${_chalk.default.yellow(`vip dev-env update --slug=${slug}`)}`);
592
+ console.log(`To manually upgrade please run: ${_chalk.default.yellow(updateCommand)}`);
580
593
  await updateEnvironment(envData);
581
594
  }
582
595
  return false;
@@ -603,7 +616,7 @@ async function isVersionListExpired(cacheFile, ttl) {
603
616
  mtime: expire
604
617
  } = await _fs.default.promises.stat(cacheFile);
605
618
  expire.setSeconds(expire.getSeconds() + ttl);
606
- return +new Date() > expire;
619
+ return +new Date() > +expire;
607
620
  } catch (err) {
608
621
  return true;
609
622
  }
@@ -614,7 +627,7 @@ async function isVersionListExpired(cacheFile, ttl) {
614
627
  */
615
628
  async function getVersionList() {
616
629
  let res;
617
- const mainEnvironmentPath = _xdgBasedir.default.data || _os.default.tmpdir();
630
+ const mainEnvironmentPath = xdgDataDirectory();
618
631
  const cacheFilePath = _path.default.join(mainEnvironmentPath, 'vip');
619
632
  const cacheFile = _path.default.join(cacheFilePath, _devEnvironment.DEV_ENVIRONMENT_WORDPRESS_CACHE_KEY);
620
633
  // Handle from cache
@@ -660,8 +673,7 @@ async function getVersionList() {
660
673
  * @return {string} Workspace path
661
674
  */
662
675
  function generateVSCodeWorkspace(slug) {
663
- var _instanceData$muPlugi, _instanceData$appCode;
664
- debug('Generating VSCode Workspace');
676
+ debug('Generating VS Code Workspace');
665
677
  const location = getEnvironmentPath(slug);
666
678
  const workspacePath = getVSCodeWorkspacePath(slug);
667
679
  const instanceData = readEnvironmentData(slug);
@@ -669,12 +681,12 @@ function generateVSCodeWorkspace(slug) {
669
681
  const folders = [{
670
682
  path: location
671
683
  }];
672
- if ((_instanceData$muPlugi = instanceData.muPlugins) !== null && _instanceData$muPlugi !== void 0 && _instanceData$muPlugi.dir) {
684
+ if (instanceData.muPlugins.dir) {
673
685
  folders.push({
674
686
  path: instanceData.muPlugins.dir
675
687
  });
676
688
  }
677
- if ((_instanceData$appCode = instanceData.appCode) !== null && _instanceData$appCode !== void 0 && _instanceData$appCode.dir) {
689
+ if (instanceData.appCode.dir) {
678
690
  folders.push({
679
691
  path: instanceData.appCode.dir
680
692
  });
@@ -696,12 +708,11 @@ function generateVSCodeWorkspace(slug) {
696
708
  return workspacePath;
697
709
  }
698
710
  const generatePathMappings = (location, instanceData) => {
699
- var _instanceData$muPlugi2, _instanceData$appCode2;
700
711
  const pathMappings = {};
701
- if ((_instanceData$muPlugi2 = instanceData.muPlugins) !== null && _instanceData$muPlugi2 !== void 0 && _instanceData$muPlugi2.dir) {
712
+ if (instanceData.muPlugins.dir) {
702
713
  pathMappings['/wp/wp-content/mu-plugins'] = instanceData.muPlugins.dir;
703
714
  }
704
- if ((_instanceData$appCode2 = instanceData.appCode) !== null && _instanceData$appCode2 !== void 0 && _instanceData$appCode2.dir) {
715
+ if (instanceData.appCode.dir) {
705
716
  pathMappings['/wp/wp-content/client-mu-plugins'] = _path.default.resolve(instanceData.appCode.dir, 'client-mu-plugins');
706
717
  pathMappings['/wp/wp-content/images'] = _path.default.resolve(instanceData.appCode.dir, 'images');
707
718
  pathMappings['/wp/wp-content/languages'] = _path.default.resolve(instanceData.appCode.dir, 'languages');
@@ -470,7 +470,9 @@ async function landoShell(lando, instancePath, service, user, command) {
470
470
  async function removeDevToolsVolumes(lando, app) {
471
471
  debug('Attempting to removing dev-tools volumes');
472
472
  const scanResult = await lando.engine.docker.listVolumes();
473
- const devToolsVolumeNames = ((scanResult === null || scanResult === void 0 ? void 0 : scanResult.Volumes) || []).map(volume => volume.Name).filter(volumeName => new RegExp(`${app.project}.*devtools`).test(volumeName));
473
+ const devToolsVolumeNames = ((scanResult === null || scanResult === void 0 ? void 0 : scanResult.Volumes) || []).map(volume => volume.Name)
474
+ // eslint-disable-next-line security/detect-non-literal-regexp
475
+ .filter(volumeName => new RegExp(`${app.project}.*devtools`).test(volumeName));
474
476
  debug('Will remove', devToolsVolumeNames);
475
477
  const removalPromises = devToolsVolumeNames.map(volumeName => removeVolume(lando, volumeName));
476
478
  await Promise.all(removalPromises);
@@ -16,18 +16,9 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
16
16
  */
17
17
 
18
18
  const mutation = (0, _graphqlTag.default)`
19
- mutation DeleteEnvironmentVariable(
20
- $appId: Int!
21
- $envId: Int!
22
- $name: String!
23
- ) {
19
+ mutation DeleteEnvironmentVariable($appId: Int!, $envId: Int!, $name: String!) {
24
20
  deleteEnvironmentVariable(
25
- input: {
26
- applicationId: $appId
27
- environmentId: $envId
28
- name: $name
29
- value: ""
30
- }
21
+ input: { applicationId: $appId, environmentId: $envId, name: $name, value: "" }
31
22
  ) {
32
23
  environmentVariables {
33
24
  total
@@ -16,17 +16,10 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
16
16
  */
17
17
 
18
18
  const query = (0, _graphqlTag.default)`
19
- query GetEnvironmentVariablesWithValues(
20
- $appId: Int!
21
- $envId: Int!
22
- ) {
23
- app(
24
- id: $appId
25
- ) {
19
+ query GetEnvironmentVariablesWithValues($appId: Int!, $envId: Int!) {
20
+ app(id: $appId) {
26
21
  id
27
- environments(
28
- id: $envId
29
- ) {
22
+ environments(id: $envId) {
30
23
  id
31
24
  environmentVariables {
32
25
  total
@@ -16,17 +16,10 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
16
16
  */
17
17
 
18
18
  const query = (0, _graphqlTag.default)`
19
- query GetEnvironmentVariables(
20
- $appId: Int!
21
- $envId: Int!
22
- ) {
23
- app(
24
- id: $appId
25
- ) {
19
+ query GetEnvironmentVariables($appId: Int!, $envId: Int!) {
20
+ app(id: $appId) {
26
21
  id
27
- environments(
28
- id: $envId
29
- ) {
22
+ environments(id: $envId) {
30
23
  id
31
24
  environmentVariables {
32
25
  total
@@ -16,19 +16,9 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
16
16
  */
17
17
 
18
18
  const mutation = (0, _graphqlTag.default)`
19
- mutation AddEnvironmentVariable(
20
- $appId: Int!
21
- $envId: Int!
22
- $name: String!
23
- $value: String!
24
- ) {
19
+ mutation AddEnvironmentVariable($appId: Int!, $envId: Int!, $name: String!, $value: String!) {
25
20
  addEnvironmentVariable(
26
- input: {
27
- applicationId: $appId
28
- environmentId: $envId
29
- name: $name
30
- value: $value
31
- }
21
+ input: { applicationId: $appId, environmentId: $envId, name: $name, value: $value }
32
22
  ) {
33
23
  environmentVariables {
34
24
  total
@@ -35,31 +35,31 @@ const IMPORT_MEDIA_PROGRESS_POLL_INTERVAL = 1000;
35
35
  const ONE_MINUTE_IN_MILLISECONDS = 1000 * 60;
36
36
  const TWO_MINUTES_IN_MILLISECONDS = 2 * ONE_MINUTE_IN_MILLISECONDS;
37
37
  const IMPORT_MEDIA_PROGRESS_QUERY = (0, _graphqlTag.default)`
38
- query App( $appId: Int, $envId: Int ) {
39
- app( id: $appId ) {
40
- environments( id: $envId ) {
41
- id
42
- name
43
- type
44
- repo
45
- mediaImportStatus {
46
- importId
47
- siteId
48
- status
49
- filesTotal
50
- filesProcessed
51
- failureDetails {
52
- previousStatus
53
- globalErrors
54
- fileErrors {
38
+ query App($appId: Int, $envId: Int) {
39
+ app(id: $appId) {
40
+ environments(id: $envId) {
41
+ id
42
+ name
43
+ type
44
+ repo
45
+ mediaImportStatus {
46
+ importId
47
+ siteId
48
+ status
49
+ filesTotal
50
+ filesProcessed
51
+ failureDetails {
52
+ previousStatus
53
+ globalErrors
54
+ fileErrors {
55
55
  fileName
56
56
  errors
57
+ }
57
58
  }
58
59
  }
59
60
  }
60
61
  }
61
62
  }
62
- }
63
63
  `;
64
64
  async function getStatus(api, appId, envId) {
65
65
  const response = await api.query({
@@ -75,7 +75,7 @@ const siteTypeValidations = {
75
75
  await track('import_sql_command_error', {
76
76
  error_type: 'multisite-import-where-primary-domain-unmapped'
77
77
  });
78
- throw new Error('This import would set the network\'s main site domain to ' + primaryDomainFromSQL + ', however this domain is not mapped to the target environment. Please replace this domain in your ' + 'import file, or map it to the environment.');
78
+ throw new Error("This import would set the network's main site domain to " + primaryDomainFromSQL + ', however this domain is not mapped to the target environment. Please replace this domain in your ' + 'import file, or map it to the environment.');
79
79
  }
80
80
  }
81
81
  }
@@ -161,6 +161,7 @@ const checks = {
161
161
  },
162
162
  trigger: {
163
163
  // Match `CREATE (DEFINER=`root`@`host`) TRIGGER`
164
+ // eslint-disable-next-line security/detect-unsafe-regex
164
165
  matcher: /^CREATE (\(?DEFINER=`?(\w*)(`@`)?(\w*\.*%?)*`?\)?)?(| )TRIGGER/i,
165
166
  matchHandler: lineNumber => ({
166
167
  lineNumber
@@ -283,7 +284,7 @@ const checks = {
283
284
  results: [],
284
285
  message: 'Siteurl/home options not pointing to lando domain',
285
286
  excerpt: 'Siteurl/home options not pointing to lando domain',
286
- recommendation: 'Use search-replace to change environment\'s domain'
287
+ recommendation: "Use search-replace to change environment's domain"
287
288
  },
288
289
  engineInnoDB: {
289
290
  matcher: / ENGINE=(?!(InnoDB))/i,
@@ -419,6 +419,7 @@ const isFileSanitized = file => {
419
419
  */
420
420
  exports.isFileSanitized = isFileSanitized;
421
421
  const identifyIntermediateImage = filename => {
422
+ // eslint-disable-next-line security/detect-unsafe-regex
422
423
  const regex = /([_-])?(\d+x\d+)(@\d+\w)?(\.\w{3,4})$/;
423
424
  return filename.match(regex); // NOSONAR
424
425
  };
@@ -4,10 +4,12 @@ const { name, engines } = require( '../package.json' );
4
4
  const version = engines.node;
5
5
 
6
6
  if ( ! semver.satisfies( process.version, version ) ) {
7
- console.log( [
8
- `The current version of Node (${ process.version }) does not meet the minimum requirements;`,
9
- `${ name } requires Node version ${ version }.`,
10
- 'Please follow the installation instructions at https://nodejs.org/en/download/ to upgrade before continuing.`',
11
- ].join( ' ' ) );
7
+ console.log(
8
+ [
9
+ `The current version of Node (${ process.version }) does not meet the minimum requirements;`,
10
+ `${ name } requires Node version ${ version }.`,
11
+ 'Please follow the installation instructions at https://nodejs.org/en/download/ to upgrade before continuing.`',
12
+ ].join( ' ' )
13
+ );
12
14
  process.exit( 1 );
13
15
  }