@automattic/vip 2.10.0 → 2.12.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.
Files changed (123) hide show
  1. package/CONTRIBUTING.md +7 -2
  2. package/README.md +27 -0
  3. package/config/{config.json → config.publish.json} +0 -0
  4. package/dist/bin/vip-dev-env-create.js +1 -0
  5. package/dist/bin/vip-dev-env-destroy.js +1 -0
  6. package/dist/bin/vip-dev-env-exec.js +1 -0
  7. package/dist/bin/vip-dev-env-import-media.js +1 -0
  8. package/dist/bin/vip-dev-env-import-sql.js +1 -0
  9. package/dist/bin/vip-dev-env-info.js +1 -0
  10. package/dist/bin/vip-dev-env-list.js +1 -0
  11. package/dist/bin/vip-dev-env-start.js +4 -3
  12. package/dist/bin/vip-dev-env-stop.js +7 -1
  13. package/dist/bin/vip-dev-env-update.js +1 -0
  14. package/dist/bin/vip-import-sql.js +7 -1
  15. package/dist/bin/vip-wp.js +2 -2
  16. package/dist/bin/vip.js +1 -1
  17. package/dist/lib/analytics/clients/pendo.js +92 -0
  18. package/dist/lib/analytics/clients/stub.js +1 -1
  19. package/dist/lib/analytics/clients/tracks.js +0 -5
  20. package/dist/lib/analytics/index.js +21 -4
  21. package/dist/lib/api.js +2 -2
  22. package/dist/lib/cli/config.js +30 -0
  23. package/dist/lib/dev-environment/dev-environment-cli.js +25 -2
  24. package/dist/lib/dev-environment/dev-environment-lando.js +17 -0
  25. package/dist/lib/http/proxy-agent.js +94 -0
  26. package/dist/lib/rollbar.js +1 -1
  27. package/dist/lib/tracker.js +13 -4
  28. package/npm-shrinkwrap.json +319 -133
  29. package/package/dist/bin/vip-app-list.js +73 -0
  30. package/package/dist/bin/vip-app.js +76 -0
  31. package/package/dist/bin/vip-config-envvar-delete.js +97 -0
  32. package/package/dist/bin/vip-config-envvar-get-all.js +94 -0
  33. package/package/dist/bin/vip-config-envvar-get.js +79 -0
  34. package/package/dist/bin/vip-config-envvar-list.js +91 -0
  35. package/package/dist/bin/vip-config-envvar-set.js +123 -0
  36. package/package/dist/bin/vip-config-envvar.js +23 -0
  37. package/package/dist/bin/vip-config.js +20 -0
  38. package/package/dist/bin/vip-dev-env-create.js +105 -0
  39. package/package/dist/bin/vip-dev-env-destroy.js +56 -0
  40. package/package/dist/bin/vip-dev-env-exec.js +67 -0
  41. package/package/dist/bin/vip-dev-env-import-media.js +51 -0
  42. package/package/dist/bin/vip-dev-env-import-sql.js +83 -0
  43. package/package/dist/bin/vip-dev-env-import.js +32 -0
  44. package/package/dist/bin/vip-dev-env-info.js +61 -0
  45. package/package/dist/bin/vip-dev-env-list.js +46 -0
  46. package/package/dist/bin/vip-dev-env-start.js +77 -0
  47. package/package/dist/bin/vip-dev-env-stop.js +52 -0
  48. package/package/dist/bin/vip-dev-env-update.js +89 -0
  49. package/package/dist/bin/vip-dev-env.js +23 -0
  50. package/package/dist/bin/vip-import-media-abort.js +132 -0
  51. package/package/dist/bin/vip-import-media-status.js +84 -0
  52. package/package/dist/bin/vip-import-media.js +168 -0
  53. package/package/dist/bin/vip-import-sql-status.js +83 -0
  54. package/package/dist/bin/vip-import-sql.js +580 -0
  55. package/package/dist/bin/vip-import-validate-files.js +191 -0
  56. package/package/dist/bin/vip-import-validate-sql.js +34 -0
  57. package/package/dist/bin/vip-import.js +20 -0
  58. package/package/dist/bin/vip-logs.js +232 -0
  59. package/package/dist/bin/vip-search-replace.js +71 -0
  60. package/package/dist/bin/vip-sync.js +191 -0
  61. package/package/dist/bin/vip-whoami.js +67 -0
  62. package/package/dist/bin/vip-wp.js +555 -0
  63. package/package/dist/bin/vip.js +149 -0
  64. package/package/dist/lib/analytics/clients/client.js +1 -0
  65. package/package/dist/lib/analytics/clients/pendo.js +92 -0
  66. package/package/dist/lib/analytics/clients/stub.js +19 -0
  67. package/package/dist/lib/analytics/clients/tracks.js +128 -0
  68. package/package/dist/lib/analytics/index.js +45 -0
  69. package/package/dist/lib/api/app.js +70 -0
  70. package/package/dist/lib/api/feature-flags.js +39 -0
  71. package/package/dist/lib/api/user.js +58 -0
  72. package/package/dist/lib/api.js +136 -0
  73. package/package/dist/lib/app-logs/app-logs.js +70 -0
  74. package/package/dist/lib/cli/apiConfig.js +90 -0
  75. package/package/dist/lib/cli/command.js +606 -0
  76. package/package/dist/lib/cli/envAlias.js +60 -0
  77. package/package/dist/lib/cli/exit.js +33 -0
  78. package/package/dist/lib/cli/format.js +213 -0
  79. package/package/dist/lib/cli/pager.js +52 -0
  80. package/package/dist/lib/cli/progress.js +208 -0
  81. package/package/dist/lib/cli/prompt.js +37 -0
  82. package/package/dist/lib/cli/repo.js +77 -0
  83. package/package/dist/lib/client-file-uploader.js +602 -0
  84. package/package/dist/lib/constants/dev-environment.js +42 -0
  85. package/package/dist/lib/constants/file-size.js +14 -0
  86. package/package/dist/lib/dev-environment/dev-environment-cli.js +508 -0
  87. package/package/dist/lib/dev-environment/dev-environment-core.js +620 -0
  88. package/package/dist/lib/dev-environment/dev-environment-lando.js +330 -0
  89. package/package/dist/lib/dev-environment/types.js +1 -0
  90. package/package/dist/lib/env.js +36 -0
  91. package/package/dist/lib/envvar/api-delete.js +56 -0
  92. package/package/dist/lib/envvar/api-get-all.js +59 -0
  93. package/package/dist/lib/envvar/api-get.js +24 -0
  94. package/package/dist/lib/envvar/api-list.js +60 -0
  95. package/package/dist/lib/envvar/api-set.js +58 -0
  96. package/package/dist/lib/envvar/api.js +104 -0
  97. package/package/dist/lib/envvar/input.js +55 -0
  98. package/package/dist/lib/envvar/logging.js +33 -0
  99. package/package/dist/lib/envvar/read-file.js +43 -0
  100. package/{dist → package/dist}/lib/http/socks-proxy-agent.js +0 -0
  101. package/package/dist/lib/keychain/browser.js +35 -0
  102. package/package/dist/lib/keychain/insecure.js +63 -0
  103. package/package/dist/lib/keychain/keychain.js +1 -0
  104. package/package/dist/lib/keychain/secure.js +36 -0
  105. package/package/dist/lib/keychain.js +36 -0
  106. package/package/dist/lib/media-import/media-file-import.js +34 -0
  107. package/package/dist/lib/media-import/progress.js +86 -0
  108. package/package/dist/lib/media-import/status.js +335 -0
  109. package/package/dist/lib/rollbar.js +35 -0
  110. package/package/dist/lib/search-and-replace.js +203 -0
  111. package/package/dist/lib/site-import/db-file-import.js +46 -0
  112. package/package/dist/lib/site-import/status.js +444 -0
  113. package/package/dist/lib/token.js +132 -0
  114. package/package/dist/lib/tracker.js +96 -0
  115. package/package/dist/lib/validations/is-multi-site-sql-dump.js +59 -0
  116. package/package/dist/lib/validations/is-multi-site.js +99 -0
  117. package/package/dist/lib/validations/line-by-line.js +92 -0
  118. package/package/dist/lib/validations/site-type.js +66 -0
  119. package/package/dist/lib/validations/sql.js +371 -0
  120. package/package/dist/lib/vip-import-validate-files.js +548 -0
  121. package/package/vip.iml +11 -0
  122. package/package.json +12 -9
  123. package/helpers/prepare-config.js +0 -19
package/CONTRIBUTING.md CHANGED
@@ -10,6 +10,11 @@ Tests are powered by [Jest](https://jestjs.io).
10
10
 
11
11
  ## Developing
12
12
 
13
+ ### Node version
14
+
15
+ To develop use the minimum supported node version. You can take a look in the `package.json` `engines` configuration
16
+ or, if you use tools like `nvm` you can run `nvm use` to ensure you're running the right one.
17
+
13
18
  ### Local Dev
14
19
 
15
20
  To test against a local instance of Parker, you can use the `API_HOST` env var. You'll also want to nullify the `VIP_PROXY` env var as well.
@@ -91,7 +96,7 @@ Then, let's publish:
91
96
  1. Push the tag to GitHub (`git push --tags`)
92
97
  1. Push the master branch `git push`
93
98
  1. Make sure you're part of the Automattic organization in npm
94
- 1. Publish the release to npm (`npm run publish-please --access public`)
99
+ 1. Publish the release to npm (`npm run publish-please --access public`) the script will do some extra checks (npm version, branch, etc) to ensure everything is correct. If all looks good, proceed.
95
100
  1. Edit [the release on GitHub](https://github.com/Automattic/vip/releases) to include a description of the changes and publish (this can just copy the details from the changelog).
96
101
  1. Push `master` changes (mostly the version bump) to `develop` (`git checkout develop && git merge master` )
97
102
 
@@ -127,4 +132,4 @@ Then, repeat for any additional versions that we need to patch.
127
132
 
128
133
  Some unit tests require some go-search-replace executable binary files to run. Binaries files for several OS architectures can be downloaded from https://github.com/Automattic/go-search-replace/releases/
129
134
 
130
- If, for some reason, you need to compile these binaries yourself, please follow instructions at https://github.com/Automattic/go-search-replace
135
+ If, for some reason, you need to compile these binaries yourself, please follow instructions at https://github.com/Automattic/go-search-replace
package/README.md CHANGED
@@ -26,6 +26,33 @@ By default, we record information about the usage of this tool using an in-house
26
26
 
27
27
  ## Changelog
28
28
 
29
+ ### 2.12.0 (19 May 2022)
30
+
31
+ - #1035 and #1032 Improved publishing checks to publish on npm
32
+ - #1037 [dev-env] only record the php version numbers update/clean_php_version
33
+ - #999 Add Feature to Support HTTPS/HTTP/NO_PROXY Settings
34
+ - #1036 Move DO_NOT_TRACK handling to Analytics lib
35
+ - #1033 [dev-env] Bump lando in order to support node 18
36
+
37
+ #### Special thanks
38
+ frank-cerny for the contribution on #1036
39
+
40
+ ### 2.11.2 (12 May 2022)
41
+
42
+ - Hotfix to use correct production config.json in the NPM published package caused by a different NPM version in the build process.
43
+
44
+ ### 2.11.1 (12 May 2022)
45
+
46
+ - Hotfix to use correct production config.json in the NPM published package
47
+
48
+ ### 2.11.0 (11 May 2022)
49
+
50
+ - #1022 [dev-env] Validate docker installed
51
+ - #1026 [dev-env] adds tracking to stop subcommand
52
+ - #1028 Re-calculate the fileMeta if file gets changed by the searchAndReplace
53
+ - #1029 Adds Pendo analytics client
54
+ - #1030 [dev-env] Fix failure tracking
55
+
29
56
  ### 2.10.0 (4 May 2022)
30
57
 
31
58
  - #1021 [dev-env] Add login info and documentation link to `dev-env info`
File without changes
@@ -60,6 +60,7 @@ const cmd = (0, _command.default)().option('slug', 'Custom name of the dev envir
60
60
  (0, _devEnvironmentCli.addDevEnvConfigurationOptions)(cmd);
61
61
  cmd.examples(examples);
62
62
  cmd.argv(process.argv, async (arg, opt) => {
63
+ await (0, _devEnvironmentCli.validateDependencies)();
63
64
  const slug = (0, _devEnvironmentCli.getEnvironmentName)(opt);
64
65
  debug('Args: ', arg, 'Options: ', opt);
65
66
  const trackingInfo = {
@@ -38,6 +38,7 @@ const examples = [{
38
38
  description: 'Destroys a local dev environment named foo'
39
39
  }];
40
40
  (0, _command.default)().option('slug', 'Custom name of the dev environment').option('soft', 'Keep config files needed to start an environment intact').examples(examples).argv(process.argv, async (arg, opt) => {
41
+ await (0, _devEnvironmentCli.validateDependencies)();
41
42
  const slug = (0, _devEnvironmentCli.getEnvironmentName)(opt);
42
43
  const trackingInfo = (0, _devEnvironmentCli.getEnvTrackingInfo)(slug);
43
44
  await (0, _tracker.trackEvent)('dev_env_destroy_command_execute', trackingInfo);
@@ -39,6 +39,7 @@ const examples = [{
39
39
  (0, _command.default)({
40
40
  wildcardCommand: true
41
41
  }).option('slug', 'Custom name of the dev environment').examples(examples).argv(process.argv, async (unmatchedArgs, opt) => {
42
+ await (0, _devEnvironmentCli.validateDependencies)();
42
43
  const slug = (0, _devEnvironmentCli.getEnvironmentName)(opt);
43
44
  const trackingInfo = (0, _devEnvironmentCli.getEnvTrackingInfo)(slug);
44
45
  await (0, _tracker.trackEvent)('dev_env_exec_command_execute', trackingInfo);
@@ -36,6 +36,7 @@ const examples = [{
36
36
  (0, _command.default)({
37
37
  requiredArgs: 1
38
38
  }).examples(examples).option('slug', 'Custom name of the dev environment').argv(process.argv, async (unmatchedArgs, opt) => {
39
+ await (0, _devEnvironmentCli.validateDependencies)();
39
40
  const [filePath] = unmatchedArgs;
40
41
  const slug = (0, _devEnvironmentCli.getEnvironmentName)(opt);
41
42
  const trackingInfo = (0, _devEnvironmentCli.getEnvTrackingInfo)(slug);
@@ -45,6 +45,7 @@ const examples = [{
45
45
  (0, _command.default)({
46
46
  requiredArgs: 1
47
47
  }).option('slug', 'Custom name of the dev environment').option('search-replace', 'Perform Search and Replace on the specified SQL file').option('in-place', 'Search and Replace explicitly on the given input file').option('skip-validate', 'Do not perform file validation.').examples(examples).argv(process.argv, async (unmatchedArgs, opt) => {
48
+ await (0, _devEnvironmentCli.validateDependencies)();
48
49
  const [fileName] = unmatchedArgs;
49
50
  const {
50
51
  searchReplace,
@@ -39,6 +39,7 @@ const examples = [{
39
39
  description: 'Return information about a local dev environment named "my_site"'
40
40
  }];
41
41
  (0, _command.default)().option('slug', 'Custom name of the dev environment').option('all', 'Show Info for all local dev environments').examples(examples).argv(process.argv, async (arg, opt) => {
42
+ await (0, _devEnvironmentCli.validateDependencies)();
42
43
  const slug = (0, _devEnvironmentCli.getEnvironmentName)(opt);
43
44
  const trackingInfo = opt.all ? {
44
45
  all: true
@@ -31,6 +31,7 @@ const examples = [{
31
31
  description: 'Return information about all local dev environments'
32
32
  }];
33
33
  (0, _command.default)().examples(examples).argv(process.argv, async () => {
34
+ await (0, _devEnvironmentCli.validateDependencies)();
34
35
  const trackingInfo = {
35
36
  all: true
36
37
  };
@@ -22,10 +22,10 @@ var _command = _interopRequireDefault(require("../lib/cli/command"));
22
22
 
23
23
  var _devEnvironmentCore = require("../lib/dev-environment/dev-environment-core");
24
24
 
25
- var _devEnvironmentCli = require("../lib/dev-environment/dev-environment-cli");
26
-
27
25
  var _devEnvironment = require("../lib/constants/dev-environment");
28
26
 
27
+ var _devEnvironmentCli = require("../lib/dev-environment/dev-environment-cli");
28
+
29
29
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
30
30
 
31
31
  /**
@@ -39,6 +39,7 @@ const examples = [{
39
39
  description: 'Starts a local dev environment'
40
40
  }];
41
41
  (0, _command.default)().option('slug', 'Custom name of the dev environment').option('skip-rebuild', 'Only start stopped services').examples(examples).argv(process.argv, async (arg, opt) => {
42
+ await (0, _devEnvironmentCli.validateDependencies)();
42
43
  const startProcessing = new Date();
43
44
  const slug = (0, _devEnvironmentCli.getEnvironmentName)(opt);
44
45
  const trackingInfo = (0, _devEnvironmentCli.getEnvTrackingInfo)(slug);
@@ -67,7 +68,7 @@ const examples = [{
67
68
  await (0, _devEnvironmentCore.startEnvironment)(slug, options);
68
69
  const processingTime = new Date() - startProcessing;
69
70
  const successTrackingInfo = { ...trackingInfo,
70
- processingTime
71
+ processing_time: processingTime
71
72
  };
72
73
  await (0, _tracker.trackEvent)('dev_env_start_command_success', successTrackingInfo);
73
74
  } catch (error) {
@@ -14,6 +14,8 @@ var _debug = _interopRequireDefault(require("debug"));
14
14
 
15
15
  var _chalk = _interopRequireDefault(require("chalk"));
16
16
 
17
+ var _tracker = require("../lib/tracker");
18
+
17
19
  var _command = _interopRequireDefault(require("../lib/cli/command"));
18
20
 
19
21
  var _devEnvironmentCore = require("../lib/dev-environment/dev-environment-core");
@@ -33,14 +35,18 @@ const examples = [{
33
35
  description: 'Stops a local dev environment'
34
36
  }];
35
37
  (0, _command.default)().option('slug', 'Custom name of the dev environment').examples(examples).argv(process.argv, async (arg, opt) => {
38
+ await (0, _devEnvironmentCli.validateDependencies)();
36
39
  const slug = (0, _devEnvironmentCli.getEnvironmentName)(opt);
37
40
  debug('Args: ', arg, 'Options: ', opt);
41
+ const trackingInfo = (0, _devEnvironmentCli.getEnvTrackingInfo)(slug);
42
+ await (0, _tracker.trackEvent)('dev_env_stop_command_execute', trackingInfo);
38
43
 
39
44
  try {
40
45
  await (0, _devEnvironmentCore.stopEnvironment)(slug);
41
46
  const message = _chalk.default.green('✓') + ' environment stopped.\n';
42
47
  console.log(message);
48
+ await (0, _tracker.trackEvent)('dev_env_stop_command_success', trackingInfo);
43
49
  } catch (error) {
44
- (0, _devEnvironmentCli.handleCLIException)(error);
50
+ (0, _devEnvironmentCli.handleCLIException)(error, 'dev_env_stop_command_error', trackingInfo);
45
51
  }
46
52
  });
@@ -38,6 +38,7 @@ const cmd = (0, _command.default)().option('slug', 'Custom name of the dev envir
38
38
  (0, _devEnvironmentCli.addDevEnvConfigurationOptions)(cmd);
39
39
  cmd.examples(examples);
40
40
  cmd.argv(process.argv, async (arg, opt) => {
41
+ await (0, _devEnvironmentCli.validateDependencies)();
41
42
  const slug = (0, _devEnvironmentCli.getEnvironmentName)(opt);
42
43
  const trackingInfo = (0, _devEnvironmentCli.getEnvTrackingInfo)(slug);
43
44
  await (0, _tracker.trackEvent)('dev_env_update_command_execute', trackingInfo);
@@ -54,6 +54,8 @@ var _progress = require("../lib/cli/progress");
54
54
 
55
55
  var _isMultiSite = require("../lib/validations/is-multi-site");
56
56
 
57
+ var _rollbar = require("../lib/rollbar");
58
+
57
59
  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); }
58
60
 
59
61
  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; }
@@ -379,7 +381,7 @@ const displayPlaybook = ({
379
381
  } = env;
380
382
  const [fileName] = arg;
381
383
  const isMultiSite = await (0, _isMultiSite.isMultiSiteInSiteMeta)(appId, envId);
382
- const fileMeta = await (0, _clientFileUploader.getFileMeta)(fileName);
384
+ let fileMeta = await (0, _clientFileUploader.getFileMeta)(fileName);
383
385
 
384
386
  if (fileMeta.isCompressed) {
385
387
  console.log(_chalk.default.yellowBright('You are importing a compressed file. Validation and search-replace operation will be skipped.'));
@@ -453,6 +455,9 @@ Processing the SQL import for your environment...
453
455
  progressTracker.print({
454
456
  clearAfter: true
455
457
  });
458
+
459
+ _rollbar.rollbar.error(failureError);
460
+
456
461
  exit.withError(failureError);
457
462
  };
458
463
 
@@ -474,6 +479,7 @@ Processing the SQL import for your environment...
474
479
  }
475
480
 
476
481
  fileNameToUpload = outputFileName;
482
+ fileMeta = await (0, _clientFileUploader.getFileMeta)(fileNameToUpload);
477
483
  progressTracker.stepSuccess('replace');
478
484
  } else {
479
485
  progressTracker.stepSkipped('replace');
@@ -35,7 +35,7 @@ var _token = _interopRequireDefault(require("../lib/token"));
35
35
 
36
36
  var _rollbar = require("../lib/rollbar");
37
37
 
38
- var _socksProxyAgent = _interopRequireDefault(require("../lib/http/socks-proxy-agent"));
38
+ var _proxyAgent = require("../lib/http/proxy-agent");
39
39
 
40
40
  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); }
41
41
 
@@ -487,7 +487,7 @@ const bindReconnectEvents = ({
487
487
  }
488
488
  }
489
489
  },
490
- agent: (0, _socksProxyAgent.default)()
490
+ agent: (0, _proxyAgent.createProxyAgent)(_api.API_HOST)
491
491
  });
492
492
  currentJob = await launchCommandAndGetStreams({
493
493
  socket,
package/dist/bin/vip.js CHANGED
@@ -13,7 +13,7 @@ var _chalk = _interopRequireDefault(require("chalk"));
13
13
 
14
14
  var _debug = _interopRequireDefault(require("debug"));
15
15
 
16
- var _config = _interopRequireDefault(require("../../config/config.json"));
16
+ var _config = _interopRequireDefault(require("../lib/cli/config"));
17
17
 
18
18
  var _command = _interopRequireWildcard(require("../lib/cli/command"));
19
19
 
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _api = _interopRequireDefault(require("../../api"));
9
+
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+
12
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
13
+
14
+ /**
15
+ * External dependencies
16
+ */
17
+ const debug = require('debug')('@automattic/vip:analytics:clients:pendo');
18
+ /**
19
+ * Internal dependencies
20
+ */
21
+
22
+
23
+ /**
24
+ * Pendo analytics client.
25
+ */
26
+ class Pendo {
27
+ static get ENDPOINT() {
28
+ return '/pendo';
29
+ }
30
+
31
+ constructor({
32
+ userId,
33
+ eventPrefix,
34
+ env
35
+ }) {
36
+ _defineProperty(this, "context", {});
37
+
38
+ this.eventPrefix = eventPrefix;
39
+ this.userAgent = env.userAgent;
40
+ this.userId = userId;
41
+ this.context = { ...env
42
+ };
43
+ }
44
+
45
+ async trackEvent(eventName, eventProps = {}) {
46
+ if (!eventName.startsWith(this.eventPrefix)) {
47
+ eventName = this.eventPrefix + eventName;
48
+ }
49
+
50
+ debug('trackEvent()', eventProps);
51
+ this.context = { ...this.context,
52
+ org_id: eventProps.org_slug,
53
+ org_slug: eventProps.org_slug,
54
+ userAgent: this.userAgent,
55
+ userId: this.userId
56
+ };
57
+
58
+ try {
59
+ return await this.send(eventName, eventProps);
60
+ } catch (error) {
61
+ debug(error);
62
+ } // Resolve to false instead of rejecting
63
+
64
+
65
+ return Promise.resolve(false);
66
+ }
67
+
68
+ async send(eventName, eventProps) {
69
+ const body = {
70
+ context: this.context,
71
+ event: eventName,
72
+ properties: eventProps,
73
+ timestamp: Date.now(),
74
+ type: 'track',
75
+ visitorId: `${this.context.userId}`
76
+ };
77
+ debug('send()', body);
78
+ const {
79
+ apiFetch
80
+ } = await (0, _api.default)();
81
+ const response = await apiFetch(Pendo.ENDPOINT, {
82
+ method: 'POST',
83
+ body
84
+ });
85
+ const responseText = await response.text();
86
+ debug('response', responseText);
87
+ return responseText;
88
+ }
89
+
90
+ }
91
+
92
+ exports.default = Pendo;
@@ -11,7 +11,7 @@ exports.default = void 0;
11
11
  class AnalyticsClientStub {
12
12
  // eslint-disable-next-line no-unused-vars
13
13
  trackEvent(name, props) {
14
- return new Promise(resolve => resolve());
14
+ return new Promise(resolve => resolve(true));
15
15
  }
16
16
 
17
17
  }
@@ -100,11 +100,6 @@ class Tracks {
100
100
  }
101
101
 
102
102
  send(extraParams) {
103
- if (process.env.DO_NOT_TRACK) {
104
- debug('send() => skipping per DO_NOT_TRACK variable');
105
- return Promise.resolve('tracks disabled per DO_NOT_TRACK variable');
106
- }
107
-
108
103
  const params = Object.assign({}, this.baseParams, extraParams);
109
104
  const method = 'POST';
110
105
 
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
+ var _debug = _interopRequireDefault(require("debug"));
9
+
8
10
  var _stub = _interopRequireDefault(require("./clients/stub"));
9
11
 
10
12
  var _env = _interopRequireDefault(require("../env"));
@@ -12,10 +14,15 @@ var _env = _interopRequireDefault(require("../env"));
12
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
15
 
14
16
  /**
15
- * Internal dependencies
17
+ * External dependencies
16
18
  */
17
19
 
20
+ /**
21
+ * Internal dependencies
22
+ */
23
+ const debug = (0, _debug.default)('@automattic/vip:analytics');
18
24
  /* eslint-disable camelcase */
25
+
19
26
  const client_info = {
20
27
  cli_version: _env.default.app.version,
21
28
  os_name: _env.default.os.name,
@@ -26,13 +33,23 @@ const client_info = {
26
33
 
27
34
  class Analytics {
28
35
  constructor({
29
- tracks = new _stub.default()
36
+ clients = new _stub.default()
30
37
  }) {
31
- this.tracks = tracks;
38
+ this.clients = clients;
32
39
  }
33
40
 
34
41
  async trackEvent(name, props = {}) {
35
- return Promise.all([this.tracks.trackEvent(name, Object.assign({}, client_info, props))]);
42
+ if (process.env.DO_NOT_TRACK) {
43
+ debug(`trackEvent() for ${name} => skipping per DO_NOT_TRACK variable`);
44
+ return Promise.resolve(`Skipping trackEvent for ${name} (DO_NOT_TRACK)`);
45
+ }
46
+
47
+ return Promise.all(this.clients.map(client => {
48
+ return client.trackEvent(name, { // eslint-disable-next-line camelcase
49
+ ...client_info,
50
+ ...props
51
+ });
52
+ }));
36
53
  }
37
54
 
38
55
  }
package/dist/lib/api.js CHANGED
@@ -23,7 +23,7 @@ var _token = _interopRequireDefault(require("./token"));
23
23
 
24
24
  var _env = _interopRequireDefault(require("./env"));
25
25
 
26
- var _socksProxyAgent = _interopRequireDefault(require("./http/socks-proxy-agent"));
26
+ var _proxyAgent = require("./http/proxy-agent");
27
27
 
28
28
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
29
29
 
@@ -96,7 +96,7 @@ async function API({
96
96
  });
97
97
  return forward(operation);
98
98
  });
99
- const proxyAgent = (0, _socksProxyAgent.default)();
99
+ const proxyAgent = (0, _proxyAgent.createProxyAgent)(API_URL);
100
100
  const httpLink = new _core.HttpLink({
101
101
  uri: API_URL,
102
102
  headers,
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _debug = _interopRequireDefault(require("debug"));
9
+
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+
12
+ /**
13
+ * External dependencies
14
+ */
15
+ const debug = (0, _debug.default)('@automattic/vip:lib:cli:config');
16
+ let configFromFile = {};
17
+
18
+ try {
19
+ // Get `local` config first; this will only exist in dev as it's npmignore-d.
20
+ configFromFile = require("../../../config/config.local.json");
21
+ debug('Loaded config data from config.local.json');
22
+ } catch {
23
+ // Fall back to `publish` config file.
24
+ configFromFile = require("../../../config/config.publish.json");
25
+ debug('Loaded config data from config.publish.json');
26
+ }
27
+
28
+ const config = Object.assign({}, configFromFile);
29
+ var _default = config;
30
+ exports.default = _default;
@@ -18,6 +18,7 @@ exports.promptForComponent = promptForComponent;
18
18
  exports.addDevEnvConfigurationOptions = addDevEnvConfigurationOptions;
19
19
  exports.getTagChoices = getTagChoices;
20
20
  exports.getEnvTrackingInfo = getEnvTrackingInfo;
21
+ exports.validateDependencies = void 0;
21
22
 
22
23
  var _chalk = _interopRequireDefault(require("chalk"));
23
24
 
@@ -33,12 +34,20 @@ var _path = _interopRequireDefault(require("path"));
33
34
 
34
35
  var _os = _interopRequireDefault(require("os"));
35
36
 
37
+ var exit = _interopRequireWildcard(require("../cli/exit"));
38
+
36
39
  var _tracker = require("../tracker");
37
40
 
38
41
  var _devEnvironment = require("../constants/dev-environment");
39
42
 
40
43
  var _devEnvironmentCore = require("./dev-environment-core");
41
44
 
45
+ var _devEnvironmentLando = require("./dev-environment-lando");
46
+
47
+ 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); }
48
+
49
+ 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; }
50
+
42
51
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
43
52
 
44
53
  /**
@@ -73,7 +82,7 @@ async function handleCLIException(exception, trackKey, trackBaseInfo = {}) {
73
82
  if (trackKey) {
74
83
  try {
75
84
  const errorTrackingInfo = { ...trackBaseInfo,
76
- error: message
85
+ failure: message
77
86
  };
78
87
  await (0, _tracker.trackEvent)(trackKey, errorTrackingInfo);
79
88
  } catch (trackException) {
@@ -91,6 +100,16 @@ async function handleCLIException(exception, trackKey, trackBaseInfo = {}) {
91
100
  }
92
101
  }
93
102
 
103
+ const validateDependencies = async () => {
104
+ try {
105
+ await (0, _devEnvironmentLando.validateDockerInstalled)();
106
+ } catch (exception) {
107
+ exit.withError(exception.message);
108
+ }
109
+ };
110
+
111
+ exports.validateDependencies = validateDependencies;
112
+
94
113
  function getEnvironmentName(options) {
95
114
  if (options.slug) {
96
115
  return options.slug;
@@ -468,6 +487,8 @@ async function getTagChoices() {
468
487
 
469
488
  function getEnvTrackingInfo(slug) {
470
489
  try {
490
+ var _result$php;
491
+
471
492
  const envData = (0, _devEnvironmentCore.readEnvironmentData)(slug);
472
493
  const result = {
473
494
  slug
@@ -476,9 +497,11 @@ function getEnvTrackingInfo(slug) {
476
497
  for (const key of Object.keys(envData)) {
477
498
  // track doesnt like camelCase
478
499
  const snakeCasedKey = key.replace(/[A-Z]/g, letter => `_${letter.toLowerCase()}`);
479
- result[snakeCasedKey] = envData[key];
500
+ const value = _devEnvironment.DEV_ENVIRONMENT_COMPONENTS.includes(key) ? JSON.stringify(envData[key]) : envData[key];
501
+ result[snakeCasedKey] = value;
480
502
  }
481
503
 
504
+ result.php = (_result$php = result.php) === null || _result$php === void 0 ? void 0 : _result$php.replace(/.*:/, '');
482
505
  return result;
483
506
  } catch (err) {
484
507
  return {
@@ -9,6 +9,7 @@ exports.landoStop = landoStop;
9
9
  exports.landoDestroy = landoDestroy;
10
10
  exports.landoInfo = landoInfo;
11
11
  exports.landoExec = landoExec;
12
+ exports.validateDockerInstalled = validateDockerInstalled;
12
13
 
13
14
  var _debug = _interopRequireDefault(require("debug"));
14
15
 
@@ -310,4 +311,20 @@ async function ensureNoOrphantProxyContainer(lando) {
310
311
  }
311
312
 
312
313
  await proxyContainer.remove();
314
+ }
315
+
316
+ async function validateDockerInstalled() {
317
+ const lando = new _lando.default(getLandoConfig());
318
+ await lando.bootstrap();
319
+ lando.log.verbose('docker-engine exists: %s', lando.engine.dockerInstalled);
320
+
321
+ if (lando.engine.dockerInstalled === false) {
322
+ throw Error('docker could not be located! Please follow the following instructions to install it - https://docs.docker.com/engine/install/');
323
+ }
324
+
325
+ lando.log.verbose('docker-compose exists: %s', lando.engine.composeInstalled);
326
+
327
+ if (lando.engine.composeInstalled === false) {
328
+ throw Error('docker-compose could not be located! Please follow the following instructions to install it - https://docs.docker.com/compose/install/');
329
+ }
313
330
  }