@automattic/vip 2.36.0-dev.0 → 2.36.1

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 (129) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/bin/vip-app-list.js +1 -8
  3. package/dist/bin/vip-app.js +3 -10
  4. package/dist/bin/vip-backup-db.js +1 -9
  5. package/dist/bin/vip-backup.js +0 -8
  6. package/dist/bin/vip-cache-purge-url.js +6 -16
  7. package/dist/bin/vip-cache.js +0 -8
  8. package/dist/bin/vip-config-envvar-delete.js +2 -11
  9. package/dist/bin/vip-config-envvar-get-all.js +1 -10
  10. package/dist/bin/vip-config-envvar-get.js +1 -10
  11. package/dist/bin/vip-config-envvar-list.js +1 -10
  12. package/dist/bin/vip-config-envvar-set.js +3 -12
  13. package/dist/bin/vip-config-envvar.js +0 -8
  14. package/dist/bin/vip-config-software-get.js +3 -12
  15. package/dist/bin/vip-config-software-update.js +6 -13
  16. package/dist/bin/vip-config-software.js +0 -8
  17. package/dist/bin/vip-config.js +0 -8
  18. package/dist/bin/vip-dev-env-create.js +6 -13
  19. package/dist/bin/vip-dev-env-destroy.js +3 -10
  20. package/dist/bin/vip-dev-env-exec.js +2 -6
  21. package/dist/bin/vip-dev-env-import-media.js +2 -10
  22. package/dist/bin/vip-dev-env-import-sql.js +3 -11
  23. package/dist/bin/vip-dev-env-import.js +0 -8
  24. package/dist/bin/vip-dev-env-info.js +4 -11
  25. package/dist/bin/vip-dev-env-list.js +3 -11
  26. package/dist/bin/vip-dev-env-logs.js +3 -10
  27. package/dist/bin/vip-dev-env-shell.js +3 -10
  28. package/dist/bin/vip-dev-env-start.js +6 -13
  29. package/dist/bin/vip-dev-env-stop.js +4 -11
  30. package/dist/bin/vip-dev-env-sync-sql.js +4 -12
  31. package/dist/bin/vip-dev-env-sync.js +0 -8
  32. package/dist/bin/vip-dev-env-update.js +5 -12
  33. package/dist/bin/vip-dev-env.js +0 -8
  34. package/dist/bin/vip-export-sql.js +1 -9
  35. package/dist/bin/vip-export.js +0 -8
  36. package/dist/bin/vip-import-media-abort.js +7 -13
  37. package/dist/bin/vip-import-media-status.js +4 -11
  38. package/dist/bin/vip-import-media.js +5 -11
  39. package/dist/bin/vip-import-sql-status.js +5 -12
  40. package/dist/bin/vip-import-sql.js +46 -48
  41. package/dist/bin/vip-import-validate-files.js +3 -10
  42. package/dist/bin/vip-import-validate-sql.js +2 -10
  43. package/dist/bin/vip-import.js +0 -8
  44. package/dist/bin/vip-logout.js +0 -8
  45. package/dist/bin/vip-logs.js +10 -22
  46. package/dist/bin/vip-search-replace.js +2 -9
  47. package/dist/bin/vip-slowlogs.js +6 -16
  48. package/dist/bin/vip-sync.js +0 -7
  49. package/dist/bin/vip-validate-preflight.js +13 -24
  50. package/dist/bin/vip-validate.js +0 -8
  51. package/dist/bin/vip-whoami.js +4 -14
  52. package/dist/bin/vip-wp.js +8 -17
  53. package/dist/bin/vip.js +11 -19
  54. package/dist/commands/backup-db.js +15 -31
  55. package/dist/commands/dev-env-import-sql.js +23 -12
  56. package/dist/commands/dev-env-sync-sql.js +34 -35
  57. package/dist/commands/export-sql.js +27 -39
  58. package/dist/lib/analytics/clients/pendo.js +1 -11
  59. package/dist/lib/analytics/clients/tracks.js +2 -12
  60. package/dist/lib/analytics/index.js +1 -11
  61. package/dist/lib/api/app.js +3 -14
  62. package/dist/lib/api/cache-purge.js +3 -17
  63. package/dist/lib/api/feature-flags.js +1 -11
  64. package/dist/lib/api/http.js +4 -14
  65. package/dist/lib/api/user.js +1 -13
  66. package/dist/lib/api.js +8 -23
  67. package/dist/lib/app-logs/app-logs.js +4 -18
  68. package/dist/lib/app-slowlogs/app-slowlogs.js +4 -18
  69. package/dist/lib/app.js +1 -11
  70. package/dist/lib/backup-storage-availability/backup-storage-availability.js +8 -11
  71. package/dist/lib/backup-storage-availability/docker-machine-not-found-error.js +1 -3
  72. package/dist/lib/cli/apiConfig.js +6 -20
  73. package/dist/lib/cli/command.js +26 -33
  74. package/dist/lib/cli/config.js +4 -11
  75. package/dist/lib/cli/envAlias.js +1 -7
  76. package/dist/lib/cli/exit.js +1 -13
  77. package/dist/lib/cli/format.js +6 -15
  78. package/dist/lib/cli/progress.js +2 -13
  79. package/dist/lib/cli/prompt.js +1 -11
  80. package/dist/lib/client-file-uploader.js +22 -24
  81. package/dist/lib/config/software.js +11 -25
  82. package/dist/lib/constants/dev-environment.js +35 -33
  83. package/dist/lib/constants/file-size.js +5 -11
  84. package/dist/lib/constants/vipgo.js +10 -21
  85. package/dist/lib/dev-environment/dev-environment-cli.js +46 -49
  86. package/dist/lib/dev-environment/dev-environment-configuration-file.js +14 -26
  87. package/dist/lib/dev-environment/dev-environment-core.js +30 -43
  88. package/dist/lib/dev-environment/dev-environment-lando.js +19 -30
  89. package/dist/lib/dev-environment/docker-utils.js +1 -6
  90. package/dist/lib/env.js +2 -13
  91. package/dist/lib/envvar/api-delete.js +1 -11
  92. package/dist/lib/envvar/api-get-all.js +2 -13
  93. package/dist/lib/envvar/api-get.js +2 -12
  94. package/dist/lib/envvar/api-list.js +3 -14
  95. package/dist/lib/envvar/api-set.js +1 -11
  96. package/dist/lib/envvar/api.js +8 -46
  97. package/dist/lib/envvar/input.js +2 -14
  98. package/dist/lib/envvar/logging.js +3 -13
  99. package/dist/lib/envvar/read-file.js +1 -13
  100. package/dist/lib/http/proxy-agent.js +3 -12
  101. package/dist/lib/keychain/insecure.js +1 -11
  102. package/dist/lib/keychain/secure.js +1 -11
  103. package/dist/lib/keychain.js +3 -14
  104. package/dist/lib/logout.js +2 -7
  105. package/dist/lib/media-import/media-file-import.js +4 -12
  106. package/dist/lib/media-import/progress.js +2 -12
  107. package/dist/lib/media-import/status.js +15 -30
  108. package/dist/lib/read-file.js +3 -15
  109. package/dist/lib/search-and-replace.js +9 -21
  110. package/dist/lib/site-import/db-file-import.js +6 -18
  111. package/dist/lib/site-import/status.js +19 -36
  112. package/dist/lib/token.js +5 -16
  113. package/dist/lib/tracker.js +5 -15
  114. package/dist/lib/user-error.js +1 -3
  115. package/dist/lib/utils.js +4 -15
  116. package/dist/lib/validations/is-multi-site-sql-dump.js +1 -3
  117. package/dist/lib/validations/is-multi-site.js +6 -17
  118. package/dist/lib/validations/is-multisite-domain-mapped.js +9 -21
  119. package/dist/lib/validations/line-by-line.js +5 -15
  120. package/dist/lib/validations/site-type.js +4 -15
  121. package/dist/lib/validations/sql.js +33 -15
  122. package/dist/lib/validations/utils.js +1 -3
  123. package/dist/lib/vip-import-validate-files.js +2 -9
  124. package/helpers/check-version.js +1 -0
  125. package/helpers/prepublishOnly.js +2 -1
  126. package/npm-shrinkwrap.json +2716 -3116
  127. package/package.json +31 -35
  128. package/dist/bin/vip-phpmyadmin.js +0 -53
  129. package/dist/commands/phpmyadmin.js +0 -91
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
2
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
3
+ exports.__esModule = true;
6
4
  exports.createEnvironment = createEnvironment;
7
5
  exports.destroyEnvironment = destroyEnvironment;
8
6
  exports.doesEnvironmentExist = doesEnvironmentExist;
@@ -24,35 +22,27 @@ exports.startEnvironment = startEnvironment;
24
22
  exports.stopEnvironment = stopEnvironment;
25
23
  exports.updateEnvironment = updateEnvironment;
26
24
  exports.writeEnvironmentData = writeEnvironmentData;
27
- var _nodeOs = _interopRequireDefault(require("node:os"));
28
- var _nodeFs = _interopRequireDefault(require("node:fs"));
29
- var _nodePath = _interopRequireDefault(require("node:path"));
25
+ var _chalk = _interopRequireDefault(require("chalk"));
26
+ var _copyDir = _interopRequireDefault(require("copy-dir"));
30
27
  var _debug = _interopRequireDefault(require("debug"));
31
- var _xdgBasedir = _interopRequireDefault(require("xdg-basedir"));
32
- var _nodeFetch = _interopRequireDefault(require("node-fetch"));
33
28
  var _ejs = _interopRequireDefault(require("ejs"));
34
- var _chalk = _interopRequireDefault(require("chalk"));
35
29
  var _enquirer = require("enquirer");
36
- var _copyDir = _interopRequireDefault(require("copy-dir"));
37
- var _uuid = require("uuid");
30
+ var _nodeFetch = _interopRequireDefault(require("node-fetch"));
31
+ var _nodeFs = _interopRequireDefault(require("node:fs"));
32
+ var _nodeOs = _interopRequireDefault(require("node:os"));
33
+ var _nodePath = _interopRequireDefault(require("node:path"));
38
34
  var _semver = _interopRequireDefault(require("semver"));
39
- var _devEnvironmentLando = require("./dev-environment-lando");
40
- var _searchAndReplace = require("../search-and-replace");
35
+ var _uuid = require("uuid");
36
+ var _xdgBasedir = _interopRequireDefault(require("xdg-basedir"));
41
37
  var _devEnvironmentCli = require("./dev-environment-cli");
38
+ var _devEnvironmentLando = require("./dev-environment-lando");
42
39
  var _app = _interopRequireDefault(require("../api/app"));
43
- var _devEnvironment = require("../constants/dev-environment");
44
40
  var _software = require("../config/software");
45
- var _userError = _interopRequireDefault(require("../user-error"));
41
+ var _devEnvironment = require("../constants/dev-environment");
46
42
  var _proxyAgent = require("../http/proxy-agent");
43
+ var _searchAndReplace = require("../search-and-replace");
44
+ var _userError = _interopRequireDefault(require("../user-error"));
47
45
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
48
- /**
49
- * External dependencies
50
- */
51
-
52
- /**
53
- * Internal dependencies
54
- */
55
-
56
46
  const debug = (0, _debug.default)('@automattic/vip:bin:dev-environment');
57
47
  const landoFileTemplatePath = _nodePath.default.join(__dirname, '..', '..', '..', 'assets', 'dev-env.lando.template.yml.ejs');
58
48
  const nginxFileTemplatePath = _nodePath.default.join(__dirname, '..', '..', '..', 'assets', 'dev-env.nginx.template.conf.ejs');
@@ -63,8 +53,7 @@ const instanceDataFileName = 'instance_data.json';
63
53
  const uploadPathString = 'uploads';
64
54
  const nginxPathString = 'nginx';
65
55
  function xdgDataDirectory() {
66
- var _xdgBasedir$data;
67
- return (_xdgBasedir$data = _xdgBasedir.default.data) !== null && _xdgBasedir$data !== void 0 && _xdgBasedir$data.length ? _xdgBasedir.default.data : _nodeOs.default.tmpdir();
56
+ return _xdgBasedir.default.data?.length ? _xdgBasedir.default.data : _nodeOs.default.tmpdir();
68
57
  }
69
58
  async function startEnvironment(lando, slug, options) {
70
59
  debug('Will start an environment', slug);
@@ -136,7 +125,7 @@ function preProcessInstanceData(instanceData) {
136
125
  // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
137
126
  newInstanceData.elasticsearch = instanceData.elasticsearch || false; // NOSONAR
138
127
 
139
- newInstanceData.php = instanceData.php || _devEnvironment.DEV_ENVIRONMENT_PHP_VERSIONS[Object.keys(_devEnvironment.DEV_ENVIRONMENT_PHP_VERSIONS)[0]];
128
+ newInstanceData.php = instanceData.php || _devEnvironment.DEV_ENVIRONMENT_PHP_VERSIONS[Object.keys(_devEnvironment.DEV_ENVIRONMENT_PHP_VERSIONS)[0]].image;
140
129
  if (newInstanceData.php.startsWith('image:')) {
141
130
  newInstanceData.php = newInstanceData.php.slice('image:'.length);
142
131
  }
@@ -241,12 +230,12 @@ async function printEnvironmentInfo(lando, slug, options) {
241
230
  }
242
231
  const environmentData = readEnvironmentData(slug);
243
232
  const appInfo = await (0, _devEnvironmentLando.landoInfo)(lando, instancePath, {
244
- suppressWarnings: !!options.suppressWarnings,
233
+ suppressWarnings: Boolean(options.suppressWarnings),
245
234
  autologinKey: environmentData.autologinKey
246
235
  });
247
236
  if (options.extended) {
248
237
  appInfo.title = environmentData.wpTitle;
249
- appInfo.multisite = !!environmentData.multisite;
238
+ appInfo.multisite = Boolean(environmentData.multisite);
250
239
  appInfo.php = environmentData.php.split(':')[1];
251
240
  appInfo.wordpress = parseComponentForInfo(environmentData.wordpress);
252
241
  appInfo['Mu plugins'] = parseComponentForInfo(environmentData.muPlugins);
@@ -374,7 +363,7 @@ function getEnvironmentPath(name) {
374
363
  throw new Error('Name was not provided');
375
364
  }
376
365
  const mainEnvironmentPath = xdgDataDirectory();
377
- return _nodePath.default.join(mainEnvironmentPath, 'vip', 'dev-environment', name + '');
366
+ return _nodePath.default.join(mainEnvironmentPath, 'vip', 'dev-environment', String(name));
378
367
  }
379
368
  async function getApplicationInformation(appId, envType) {
380
369
  // $FlowFixMe: gql template is not supported by flow
@@ -406,10 +395,9 @@ async function getApplicationInformation(appId, envType) {
406
395
  const queryResult = await (0, _app.default)(appId, fieldsQuery, _software.appQueryFragments);
407
396
  const appData = {};
408
397
  if (queryResult.id) {
409
- var _queryResult$reposito;
410
398
  appData.id = queryResult.id;
411
399
  appData.name = queryResult.name;
412
- appData.repository = (_queryResult$reposito = queryResult.repository) === null || _queryResult$reposito === void 0 ? void 0 : _queryResult$reposito.htmlUrl;
400
+ appData.repository = queryResult.repository?.htmlUrl;
413
401
 
414
402
  // 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.
415
403
  const environments = queryResult.environments ?? [];
@@ -431,15 +419,14 @@ async function getApplicationInformation(appId, envType) {
431
419
  envData = environments.find(candidateEnv => candidateEnv.type === env);
432
420
  }
433
421
  if (envData) {
434
- var _envData$primaryDomai, _envData$softwareSett, _envData$softwareSett2;
435
422
  appData.environment = {
436
423
  name: envData.name,
437
424
  branch: envData.branch,
438
425
  type: envData.type,
439
426
  isMultisite: envData.isMultisite,
440
- primaryDomain: ((_envData$primaryDomai = envData.primaryDomain) === null || _envData$primaryDomai === void 0 ? void 0 : _envData$primaryDomai.name) ?? '',
441
- php: ((_envData$softwareSett = envData.softwareSettings) === null || _envData$softwareSett === void 0 || (_envData$softwareSett = _envData$softwareSett.php) === null || _envData$softwareSett === void 0 ? void 0 : _envData$softwareSett.current.version) ?? '',
442
- wordpress: ((_envData$softwareSett2 = envData.softwareSettings) === null || _envData$softwareSett2 === void 0 || (_envData$softwareSett2 = _envData$softwareSett2.wordpress) === null || _envData$softwareSett2 === void 0 ? void 0 : _envData$softwareSett2.current.version) ?? ''
427
+ primaryDomain: envData.primaryDomain?.name ?? '',
428
+ php: envData.softwareSettings?.php?.current.version ?? '',
429
+ wordpress: envData.softwareSettings?.wordpress?.current.version ?? ''
443
430
  };
444
431
  }
445
432
  }
@@ -457,7 +444,7 @@ async function resolveImportPath(slug, fileName, searchReplace, inPlace) {
457
444
  }
458
445
 
459
446
  // Run Search and Replace if the --search-replace flag was provided
460
- if (searchReplace !== null && searchReplace !== void 0 && searchReplace.length) {
447
+ if (searchReplace?.length) {
461
448
  const {
462
449
  outputFileName
463
450
  } = await (0, _searchAndReplace.searchAndReplace)(resolvedPath, searchReplace, {
@@ -543,10 +530,10 @@ async function maybeUpdateWordPressImage(slug) {
543
530
  const newestWordPressImage = versions.find(({
544
531
  tag
545
532
  }) => tag !== 'trunk');
546
- console.log('The most recent WordPress version available is: ' + _chalk.default.green(newestWordPressImage === null || newestWordPressImage === void 0 ? void 0 : newestWordPressImage.tag));
533
+ console.log('The most recent WordPress version available is: ' + _chalk.default.green(newestWordPressImage?.tag));
547
534
 
548
535
  // If the currently used version is the most up to date: exit.
549
- if (currentWordPressTag === (newestWordPressImage === null || newestWordPressImage === void 0 ? void 0 : newestWordPressImage.tag)) {
536
+ if (currentWordPressTag === newestWordPressImage?.tag) {
550
537
  console.log('Environment WordPress version is: ' + _chalk.default.green(currentWordPressTag) + ' ... 😎 nice! ');
551
538
  return false;
552
539
  }
@@ -571,8 +558,8 @@ async function maybeUpdateWordPressImage(slug) {
571
558
  const confirm = await (0, _enquirer.prompt)({
572
559
  type: 'select',
573
560
  name: 'upgrade',
574
- message: 'Would You like to change the WordPress version? ',
575
- choices: ['yes', 'no', "no (don't ask anymore)"]
561
+ message: 'Would you like to upgrade WordPress? ',
562
+ choices: ['no', 'yes', "no (don't ask anymore)"]
576
563
  });
577
564
 
578
565
  // If the user takes the new WP version path
@@ -587,8 +574,8 @@ async function maybeUpdateWordPressImage(slug) {
587
574
 
588
575
  // Write new data and stage for rebuild
589
576
  // FIXME: version?.tag is possibly null. Should we throw if we can't find a version somehow?
590
- envData.wordpress.tag = (version === null || version === void 0 ? void 0 : version.tag) ?? '';
591
- envData.wordpress.ref = version === null || version === void 0 ? void 0 : version.ref;
577
+ envData.wordpress.tag = version?.tag ?? '';
578
+ envData.wordpress.ref = version?.ref;
592
579
  await updateEnvironment(envData);
593
580
  return true;
594
581
  }
@@ -637,7 +624,7 @@ async function isVersionListExpired(cacheFile, ttl) {
637
624
  mtime: expire
638
625
  } = await _nodeFs.default.promises.stat(cacheFile);
639
626
  expire.setSeconds(expire.getSeconds() + ttl);
640
- return +new Date() > +expire;
627
+ return Number(new Date()) > Number(expire);
641
628
  } catch (err) {
642
629
  return true;
643
630
  }
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
2
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
3
+ exports.__esModule = true;
6
4
  exports.bootstrapLando = bootstrapLando;
7
5
  exports.checkEnvHealth = checkEnvHealth;
8
6
  exports.isEnvUp = isEnvUp;
@@ -16,30 +14,22 @@ exports.landoStart = landoStart;
16
14
  exports.landoStop = landoStop;
17
15
  exports.validateDockerAccess = validateDockerAccess;
18
16
  exports.validateDockerInstalled = validateDockerInstalled;
19
- var _nodeOs = require("node:os");
20
- var _promises = require("node:fs/promises");
21
- var _promises2 = require("node:dns/promises");
22
- var _nodePath = _interopRequireDefault(require("node:path"));
17
+ var _chalk = _interopRequireDefault(require("chalk"));
23
18
  var _debug = _interopRequireDefault(require("debug"));
24
- var _lando = _interopRequireDefault(require("lando/lib/lando"));
25
19
  var _bootstrap = require("lando/lib/bootstrap");
20
+ var _lando = _interopRequireDefault(require("lando/lib/lando"));
26
21
  var _utils = _interopRequireDefault(require("lando/plugins/lando-core/lib/utils"));
27
22
  var _build = _interopRequireDefault(require("lando/plugins/lando-tooling/lib/build"));
28
- var _chalk = _interopRequireDefault(require("chalk"));
23
+ var _promises = require("node:dns/promises");
24
+ var _promises2 = require("node:fs/promises");
25
+ var _nodeOs = require("node:os");
26
+ var _nodePath = _interopRequireDefault(require("node:path"));
29
27
  var _xdgBasedir = _interopRequireDefault(require("xdg-basedir"));
30
28
  var _devEnvironmentCore = require("./dev-environment-core");
31
- var _devEnvironment = require("../constants/dev-environment");
32
29
  var _dockerUtils = require("./docker-utils");
30
+ var _devEnvironment = require("../constants/dev-environment");
33
31
  var _userError = _interopRequireDefault(require("../user-error"));
34
32
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
35
- /**
36
- * External dependencies
37
- */
38
-
39
- /**
40
- * Internal dependencies
41
- */
42
-
43
33
  /**
44
34
  * This file will hold all the interactions with lando library
45
35
  */
@@ -70,7 +60,7 @@ async function getLandoConfig() {
70
60
  const landoDir = _nodePath.default.join(vipDir, 'lando');
71
61
  const fakeHomeDir = _nodePath.default.join(landoDir, 'home');
72
62
  try {
73
- await (0, _promises.mkdir)(fakeHomeDir, {
63
+ await (0, _promises2.mkdir)(fakeHomeDir, {
74
64
  recursive: true
75
65
  });
76
66
  } catch (err) {
@@ -118,7 +108,7 @@ async function regenerateLandofile(instancePath) {
118
108
  try {
119
109
  const now = new Date().toISOString().replace(/[^\d]/g, '').slice(0, -3);
120
110
  const backup = `${landoFile}.${now}`;
121
- await (0, _promises.rename)(landoFile, backup);
111
+ await (0, _promises2.rename)(landoFile, backup);
122
112
  console.warn(_chalk.default.yellow('Backed up %s to %s'), landoFile, backup);
123
113
  } catch (err) {
124
114
  // Rename failed - possibly the file does not exist. Silently ignoring.
@@ -180,7 +170,7 @@ async function bootstrapLando() {
180
170
  const instanceData = (0, _devEnvironmentCore.readEnvironmentData)(data.name);
181
171
  let registryResolvable = false;
182
172
  try {
183
- registryResolvable = (await (0, _promises2.lookup)('ghcr.io')).address.length > 0 || false;
173
+ registryResolvable = (await (0, _promises.lookup)('ghcr.io')).address.length > 0 || false;
184
174
  debug('Registry ghcr.io is resolvable');
185
175
  } catch (err) {
186
176
  debug('Registry ghcr.io is not resolvable, image pull might be broken.');
@@ -222,12 +212,12 @@ async function landoLogs(lando, instancePath, options) {
222
212
  debug('Will show lando logs on path:', instancePath, ' with options: ', options);
223
213
  const app = await getLandoApplication(lando, instancePath);
224
214
  const logTask = lando.tasks.find(task => task.command === 'logs');
225
- await (logTask === null || logTask === void 0 ? void 0 : logTask.run({
215
+ await logTask?.run({
226
216
  follow: options.follow,
227
217
  service: options.service,
228
218
  timestamps: options.timestamps,
229
219
  _app: app
230
- }));
220
+ });
231
221
  } finally {
232
222
  const duration = new Date().getTime() - started.getTime();
233
223
  debug('landoLogs() took %d ms', duration);
@@ -257,7 +247,7 @@ async function getBridgeNetwork(lando) {
257
247
  }
258
248
  async function cleanUpLandoProxy(lando) {
259
249
  const network = await getBridgeNetwork(lando);
260
- if (network !== null && network !== void 0 && network.Containers && !Object.keys(network.Containers).length) {
250
+ if (network?.Containers && !Object.keys(network.Containers).length) {
261
251
  const proxy = lando.engine.docker.getContainer(lando.config.proxyContainer);
262
252
  try {
263
253
  await proxy.remove({
@@ -295,13 +285,12 @@ async function landoDestroy(lando, instancePath) {
295
285
  async function landoInfo(lando, instancePath, options = {}) {
296
286
  const started = new Date();
297
287
  try {
298
- var _app$info$find;
299
288
  const app = await getLandoApplication(lando, instancePath);
300
289
  const info = _utils.default.startTable(app);
301
290
  const reachableServices = app.info.filter(service => service.urls.length);
302
291
  reachableServices.forEach(service => info[`${service.service} urls`] = service.urls);
303
292
  const health = await checkEnvHealth(lando, instancePath);
304
- const frontEndUrl = ((_app$info$find = app.info.find(service => 'nginx' === service.service)) === null || _app$info$find === void 0 ? void 0 : _app$info$find.urls[0]) ?? '';
293
+ const frontEndUrl = app.info.find(service => 'nginx' === service.service)?.urls[0] ?? '';
305
294
  const extraService = await getExtraServicesConnections(lando, app);
306
295
  const appInfo = {
307
296
  slug: info.name.replace(/^vipdev/, ''),
@@ -380,8 +369,8 @@ async function getExtraServicesConnections(lando, app) {
380
369
 
381
370
  // eslint-disable-next-line no-await-in-loop
382
371
  const containerScan = service.id ? await lando.engine.docker.scan(service.id) : null;
383
- if (containerScan !== null && containerScan !== void 0 && containerScan.NetworkSettings.Ports) {
384
- const mappings = Object.keys(containerScan.NetworkSettings.Ports).map(internalPort => containerScan.NetworkSettings.Ports[internalPort]).filter(externalMapping => externalMapping === null || externalMapping === void 0 ? void 0 : externalMapping.length);
372
+ if (containerScan?.NetworkSettings.Ports) {
373
+ const mappings = Object.keys(containerScan.NetworkSettings.Ports).map(internalPort => containerScan.NetworkSettings.Ports[internalPort]).filter(externalMapping => externalMapping?.length);
385
374
  if (mappings.length) {
386
375
  const {
387
376
  HostIp: host,
@@ -475,12 +464,12 @@ async function landoShell(lando, instancePath, service, user, command) {
475
464
  command = ['/bin/sh', '-c', `if [ -x /bin/bash ]; then /bin/bash ${interactive}; else /bin/sh ${interactive}; fi; exit 0`];
476
465
  }
477
466
  debug('Running command "%o" in service "%s" as user "%s"', command, service, user);
478
- await (shellTask === null || shellTask === void 0 ? void 0 : shellTask.run({
467
+ await shellTask?.run({
479
468
  command,
480
469
  service,
481
470
  user,
482
471
  _app: app
483
- }));
472
+ });
484
473
  }
485
474
 
486
475
  /**
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
2
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
3
+ exports.__esModule = true;
6
4
  exports.getDockerSocket = getDockerSocket;
7
5
  exports.getEngineConfig = getEngineConfig;
8
6
  exports.splitca = splitca;
@@ -11,9 +9,6 @@ var _promises = require("node:fs/promises");
11
9
  var _nodeOs = require("node:os");
12
10
  var _nodePath = require("node:path");
13
11
  /* eslint-disable no-await-in-loop */
14
- /**
15
- * External dependencies
16
- */
17
12
 
18
13
  /**
19
14
  * Reads a Certificate Authority file and returns it as an array of certificates
package/dist/lib/env.js CHANGED
@@ -1,20 +1,10 @@
1
1
  "use strict";
2
2
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
3
+ exports.__esModule = true;
6
4
  exports.default = void 0;
7
5
  var _nodeOs = require("node:os");
8
6
  var _package = _interopRequireDefault(require("../../package.json"));
9
7
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
- /**
11
- * External dependencies
12
- */
13
-
14
- /**
15
- * Internal dependencies
16
- */
17
-
18
8
  const app = {
19
9
  name: _package.default.name,
20
10
  version: _package.default.version
@@ -32,5 +22,4 @@ const env = {
32
22
  node,
33
23
  userAgent: `vip-cli/${app.version} (node/${node.version}; ${os.name}/${os.version}; +https://wpvip.com)`
34
24
  };
35
- var _default = env;
36
- exports.default = _default;
25
+ var _default = exports.default = env;
@@ -1,20 +1,10 @@
1
1
  "use strict";
2
2
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
3
+ exports.__esModule = true;
6
4
  exports.default = deleteEnvVar;
7
5
  var _graphqlTag = _interopRequireDefault(require("graphql-tag"));
8
6
  var _api = _interopRequireDefault(require("../../lib/api"));
9
7
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
- /**
11
- * External dependencies
12
- */
13
-
14
- /**
15
- * Internal dependencies
16
- */
17
-
18
8
  const mutation = (0, _graphqlTag.default)`
19
9
  mutation DeleteEnvironmentVariable($appId: Int!, $envId: Int!, $name: String!) {
20
10
  deleteEnvironmentVariable(
@@ -1,20 +1,10 @@
1
1
  "use strict";
2
2
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
3
+ exports.__esModule = true;
6
4
  exports.default = getEnvVars;
7
5
  var _graphqlTag = _interopRequireDefault(require("graphql-tag"));
8
6
  var _api = _interopRequireDefault(require("../../lib/api"));
9
7
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
- /**
11
- * External dependencies
12
- */
13
-
14
- /**
15
- * Internal dependencies
16
- */
17
-
18
8
  const query = (0, _graphqlTag.default)`
19
9
  query GetEnvironmentVariablesWithValues($appId: Int!, $envId: Int!) {
20
10
  app(id: $appId) {
@@ -33,7 +23,6 @@ const query = (0, _graphqlTag.default)`
33
23
  }
34
24
  `;
35
25
  async function getEnvVars(appId, envId) {
36
- var _data$app;
37
26
  const api = await (0, _api.default)();
38
27
  const variables = {
39
28
  appId,
@@ -45,5 +34,5 @@ async function getEnvVars(appId, envId) {
45
34
  query,
46
35
  variables
47
36
  });
48
- return ((_data$app = data.app) === null || _data$app === void 0 || (_data$app = _data$app.environments) === null || _data$app === void 0 || (_data$app = _data$app[0]) === null || _data$app === void 0 || (_data$app = _data$app.environmentVariables) === null || _data$app === void 0 ? void 0 : _data$app.nodes) ?? null;
37
+ return data.app?.environments?.[0]?.environmentVariables?.nodes ?? null;
49
38
  }
@@ -1,22 +1,12 @@
1
1
  "use strict";
2
2
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
3
+ exports.__esModule = true;
6
4
  exports.default = getEnvVar;
7
5
  var _apiGetAll = _interopRequireDefault(require("../../lib/envvar/api-get-all"));
8
6
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
- /**
10
- * External dependencies
11
- */
12
-
13
- /**
14
- * Internal dependencies
15
- */
16
-
17
7
  async function getEnvVar(appId, envId, name) {
18
8
  const envvars = await (0, _apiGetAll.default)(appId, envId);
19
- return envvars === null || envvars === void 0 ? void 0 : envvars.find(({
9
+ return envvars?.find(({
20
10
  name: foundName
21
11
  }) => name === foundName);
22
12
  }
@@ -1,20 +1,10 @@
1
1
  "use strict";
2
2
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
3
+ exports.__esModule = true;
6
4
  exports.default = listEnvVars;
7
5
  var _graphqlTag = _interopRequireDefault(require("graphql-tag"));
8
6
  var _api = _interopRequireDefault(require("../../lib/api"));
9
7
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
- /**
11
- * External dependencies
12
- */
13
-
14
- /**
15
- * Internal dependencies
16
- */
17
-
18
8
  const query = (0, _graphqlTag.default)`
19
9
  query GetEnvironmentVariables($appId: Int!, $envId: Int!) {
20
10
  app(id: $appId) {
@@ -34,7 +24,6 @@ const query = (0, _graphqlTag.default)`
34
24
 
35
25
  // List the names (but not values) of environment variables.
36
26
  async function listEnvVars(appId, envId) {
37
- var _data$app;
38
27
  const api = await (0, _api.default)();
39
28
  const variables = {
40
29
  appId,
@@ -46,6 +35,6 @@ async function listEnvVars(appId, envId) {
46
35
  query,
47
36
  variables
48
37
  });
49
- const nodes = ((_data$app = data.app) === null || _data$app === void 0 || (_data$app = _data$app.environments) === null || _data$app === void 0 || (_data$app = _data$app[0]) === null || _data$app === void 0 || (_data$app = _data$app.environmentVariables) === null || _data$app === void 0 ? void 0 : _data$app.nodes) ?? [];
50
- return nodes.map(entry => (entry === null || entry === void 0 ? void 0 : entry.name) ?? '');
38
+ const nodes = data.app?.environments?.[0]?.environmentVariables?.nodes ?? [];
39
+ return nodes.map(entry => entry?.name ?? '');
51
40
  }
@@ -1,20 +1,10 @@
1
1
  "use strict";
2
2
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
3
+ exports.__esModule = true;
6
4
  exports.default = setEnvVar;
7
5
  var _graphqlTag = _interopRequireDefault(require("graphql-tag"));
8
6
  var _api = _interopRequireDefault(require("../../lib/api"));
9
7
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
- /**
11
- * External dependencies
12
- */
13
-
14
- /**
15
- * Internal dependencies
16
- */
17
-
18
8
  const mutation = (0, _graphqlTag.default)`
19
9
  mutation AddEnvironmentVariable($appId: Int!, $envId: Int!, $name: String!, $value: String!) {
20
10
  addEnvironmentVariable(
@@ -1,63 +1,26 @@
1
1
  "use strict";
2
2
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
3
+ exports.__esModule = true;
6
4
  exports.appQuery = void 0;
7
- Object.defineProperty(exports, "deleteEnvVar", {
8
- enumerable: true,
9
- get: function () {
10
- return _apiDelete.default;
11
- }
12
- });
13
- Object.defineProperty(exports, "getEnvVar", {
14
- enumerable: true,
15
- get: function () {
16
- return _apiGet.default;
17
- }
18
- });
19
- Object.defineProperty(exports, "getEnvVars", {
20
- enumerable: true,
21
- get: function () {
22
- return _apiGetAll.default;
23
- }
24
- });
25
- Object.defineProperty(exports, "listEnvVars", {
26
- enumerable: true,
27
- get: function () {
28
- return _apiList.default;
29
- }
30
- });
31
- Object.defineProperty(exports, "setEnvVar", {
32
- enumerable: true,
33
- get: function () {
34
- return _apiSet.default;
35
- }
36
- });
37
5
  exports.validateName = validateName;
38
6
  exports.validateNameWithMessage = validateNameWithMessage;
39
7
  var _chalk = _interopRequireDefault(require("chalk"));
40
- var _logging = require("../../lib/envvar/logging");
41
8
  var _apiDelete = _interopRequireDefault(require("./api-delete"));
9
+ exports.deleteEnvVar = _apiDelete.default;
42
10
  var _apiGet = _interopRequireDefault(require("./api-get"));
11
+ exports.getEnvVar = _apiGet.default;
43
12
  var _apiGetAll = _interopRequireDefault(require("./api-get-all"));
13
+ exports.getEnvVars = _apiGetAll.default;
44
14
  var _apiList = _interopRequireDefault(require("./api-list"));
15
+ exports.listEnvVars = _apiList.default;
45
16
  var _apiSet = _interopRequireDefault(require("./api-set"));
17
+ exports.setEnvVar = _apiSet.default;
18
+ var _logging = require("../../lib/envvar/logging");
46
19
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
47
- // @format
48
-
49
- /**
50
- * External dependencies
51
- */
52
-
53
- /**
54
- * Internal dependencies
55
- */
56
-
57
20
  // Reexport for convenience
58
21
 
59
22
  // The subquery for environments lets users choose any environment, including production.
60
- const appQuery = `
23
+ const appQuery = exports.appQuery = `
61
24
  id
62
25
  name
63
26
  environments {
@@ -74,7 +37,6 @@ const appQuery = `
74
37
  name
75
38
  }
76
39
  `;
77
- exports.appQuery = appQuery;
78
40
  function validateName(name) {
79
41
  const sanitizedName = name.trim().toUpperCase().replace(/[^A-Z0-9_]/g, '');
80
42
  return name === sanitizedName && /^[A-Z]/.test(sanitizedName);
@@ -1,24 +1,12 @@
1
1
  "use strict";
2
2
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
3
+ exports.__esModule = true;
6
4
  exports.cancel = cancel;
7
5
  exports.confirm = confirm;
8
6
  exports.promptForValue = promptForValue;
9
7
  var _chalk = _interopRequireDefault(require("chalk"));
10
8
  var _enquirer = require("enquirer");
11
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
- // @format
13
-
14
- /**
15
- * External dependencies
16
- */
17
-
18
- /**
19
- * Internal dependencies
20
- */
21
-
22
10
  function cancel() {
23
11
  console.log(_chalk.default.yellow('Command cancelled by user.'));
24
12
  process.exit();
@@ -42,5 +30,5 @@ async function promptForValue(message, mustMatch) {
42
30
  return true;
43
31
  }
44
32
  });
45
- return (str === null || str === void 0 ? void 0 : str.trim()) ?? '';
33
+ return str?.trim() ?? '';
46
34
  }
@@ -1,26 +1,16 @@
1
1
  "use strict";
2
2
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
3
+ exports.__esModule = true;
6
4
  exports.debug = void 0;
7
5
  exports.getEnvContext = getEnvContext;
8
6
  var _debug = _interopRequireDefault(require("debug"));
9
7
  var _command = require("../../lib/cli/command");
10
8
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
- /**
12
- * External dependencies
13
- */
14
-
15
- /**
16
- * Internal dependencies
17
- */
18
-
19
9
  // Shared debugger.
20
- const debug = (0, _debug.default)('@automattic/vip:bin:config:envvar');
10
+ const debug = exports.debug = (0, _debug.default)('@automattic/vip:bin:config:envvar');
21
11
 
22
12
  // FIXME: Replace with a proper type
23
- exports.debug = debug;
13
+
24
14
  function getEnvContext(app, env) {
25
15
  return `@${app.id}.${(0, _command.getEnvIdentifier)(env)}`;
26
16
  }