@automattic/vip 2.36.2 → 2.37.0-dev.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.
@@ -17,7 +17,7 @@ services:
17
17
  type: compose
18
18
  services:
19
19
  image: ghcr.io/automattic/vip-container-images/dev-tools:0.9
20
- command: exit 0
20
+ command: /bin/true
21
21
  volumes:
22
22
  - devtools:/dev-tools
23
23
  - scripts:/scripts
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * External dependencies
5
+ */
6
+
7
+ /**
8
+ * Internal dependencies
9
+ */
10
+ "use strict";
11
+
12
+ var _phpmyadmin = require("../commands/phpmyadmin");
13
+ var _command = _interopRequireDefault(require("../lib/cli/command"));
14
+ var _tracker = require("../lib/tracker");
15
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
+ const examples = [{
17
+ usage: 'vip db phpmyadmin @mysite.develop',
18
+ description: 'Open PhpMyAdmin console for the database of the @mysite.develop environment'
19
+ }];
20
+ const appQuery = `
21
+ id,
22
+ name,
23
+ type,
24
+ organization { id, name },
25
+ environments{
26
+ id
27
+ appId
28
+ type
29
+ name
30
+ primaryDomain { name }
31
+ uniqueLabel
32
+ }
33
+ `;
34
+ void (0, _command.default)({
35
+ appContext: true,
36
+ appQuery,
37
+ envContext: true,
38
+ module: 'phpmyadmin',
39
+ requiredArgs: 0,
40
+ usage: 'vip db phpmyadmin'
41
+ }).examples(examples).argv(process.argv, async (arg, {
42
+ app,
43
+ env
44
+ }) => {
45
+ const trackerFn = (0, _tracker.makeCommandTracker)('phpmyadmin', {
46
+ app: app.id,
47
+ env: env.uniqueLabel
48
+ });
49
+ await trackerFn('execute');
50
+ const cmd = new _phpmyadmin.PhpMyAdminCommand(app, env, trackerFn);
51
+ await cmd.run();
52
+ await trackerFn('success');
53
+ });
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * External dependencies
5
+ */
6
+
7
+ /**
8
+ * Internal dependencies
9
+ */
10
+ "use strict";
11
+
12
+ var _command = _interopRequireDefault(require("../lib/cli/command"));
13
+ var _tracker = require("../lib/tracker");
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+ void (0, _command.default)({
16
+ usage: 'vip db'
17
+ }).command('phpmyadmin', 'Open PhpMyAdmin console for your application database').example('vip db phpmyadmin @mysite.develop', 'Open PhpMyAdmin console for your database of the @mysite.develop environment').argv(process.argv, async () => {
18
+ await (0, _tracker.trackEvent)('vip_db_command_execute');
19
+ });
@@ -415,7 +415,6 @@ Processing the SQL import for your environment...
415
415
  `;
416
416
  progressTracker.suffix = `\n${(0, _format.getGlyphForStatus)(status, progressTracker.runningSprite)} ${status === 'running' ? 'Loading remaining steps' : ''}`; // TODO: maybe use progress tracker status
417
417
  };
418
-
419
418
  const failWithError = failureError => {
420
419
  status = 'failed';
421
420
  setProgressTrackerPrefixAndSuffix();
package/dist/bin/vip.js CHANGED
@@ -21,7 +21,7 @@ if (_config.default && _config.default.environment !== 'production') {
21
21
  const tokenURL = 'https://dashboard.wpvip.com/me/cli/token';
22
22
  const runCmd = async function () {
23
23
  const cmd = (0, _command.default)();
24
- cmd.command('logout', 'Logout from your current session').command('app', 'List and modify your VIP applications').command('backup', 'Generate a backup for VIP applications').command('cache', 'Manage page cache for your VIP applications').command('config', 'Set configuration for your VIP applications').command('dev-env', 'Use local dev-environment').command('export', 'Export data from your VIP application').command('import', 'Import media or SQL files into your VIP applications').command('logs', 'Get logs from your VIP applications').command('search-replace', 'Perform search and replace tasks on files').command('slowlogs', 'Get slowlogs from your VIP applications').command('sync', 'Sync production to a development environment').command('whoami', 'Display details about the currently logged-in user').command('validate', 'Validate your VIP application and environment').command('wp', 'Run WP CLI commands against an environment');
24
+ cmd.command('logout', 'Logout from your current session').command('app', 'List and modify your VIP applications').command('backup', 'Generate a backup for VIP applications').command('cache', 'Manage page cache for your VIP applications').command('config', 'Set configuration for your VIP applications').command('dev-env', 'Use local dev-environment').command('export', 'Export data from your VIP application').command('import', 'Import media or SQL files into your VIP applications').command('logs', 'Get logs from your VIP applications').command('search-replace', 'Perform search and replace tasks on files').command('slowlogs', 'Get slowlogs from your VIP applications').command('db', 'Run operations on your VIP application database').command('sync', 'Sync production to a development environment').command('whoami', 'Display details about the currently logged-in user').command('validate', 'Validate your VIP application and environment').command('wp', 'Run WP CLI commands against an environment');
25
25
  cmd.argv(process.argv);
26
26
  };
27
27
 
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.PhpMyAdminCommand = exports.GENERATE_PHP_MY_ADMIN_URL_MUTATION = void 0;
5
+ var _chalk = _interopRequireDefault(require("chalk"));
6
+ var _graphqlTag = _interopRequireDefault(require("graphql-tag"));
7
+ var _api = _interopRequireWildcard(require("../lib/api"));
8
+ var exit = _interopRequireWildcard(require("../lib/cli/exit"));
9
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
10
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+ /**
13
+ * External dependencies
14
+ */
15
+
16
+ /**
17
+ * Internal dependencies
18
+ */
19
+
20
+ const GENERATE_PHP_MY_ADMIN_URL_MUTATION = exports.GENERATE_PHP_MY_ADMIN_URL_MUTATION = (0, _graphqlTag.default)`
21
+ mutation GeneratePhpMyAdminAccess($input: GeneratePhpMyAdminAccessInput) {
22
+ generatePHPMyAdminAccess(input: $input) {
23
+ expiresAt
24
+ url
25
+ }
26
+ }
27
+ `;
28
+ async function generatePhpMyAdminAccess(envId) {
29
+ // Disable global error handling so that we can handle errors ourselves
30
+ (0, _api.disableGlobalGraphQLErrorHandling)();
31
+ const api = await (0, _api.default)();
32
+ const resp = await api.mutate({
33
+ mutation: GENERATE_PHP_MY_ADMIN_URL_MUTATION,
34
+ variables: {
35
+ input: {
36
+ environmentId: envId
37
+ }
38
+ }
39
+ });
40
+
41
+ // Re-enable global error handling
42
+ (0, _api.enableGlobalGraphQLErrorHandling)();
43
+
44
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
45
+ return resp?.data?.generatePHPMyAdminAccess?.url;
46
+ }
47
+ class PhpMyAdminCommand {
48
+ app;
49
+ env;
50
+ silent;
51
+ track;
52
+ constructor(app, env, trackerFn = async () => {}) {
53
+ this.app = app;
54
+ this.env = env;
55
+ this.track = trackerFn;
56
+ }
57
+ log(msg) {
58
+ if (this.silent) {
59
+ return;
60
+ }
61
+ console.log(msg);
62
+ }
63
+ async openUrl(url) {
64
+ const {
65
+ default: open
66
+ } = await import('open');
67
+ void open(url, {
68
+ wait: false
69
+ });
70
+ }
71
+ async run(silent = false) {
72
+ this.silent = silent;
73
+ if (!this.env.id) {
74
+ exit.withError('No environment was specified');
75
+ }
76
+ const message = 'Note: PHPMyAdmin sessions are read-only. If you run a query that writes to DB, it will fail.';
77
+ console.log(_chalk.default.yellow(message));
78
+ this.log('Generating PhpMyAdmin URL...');
79
+ let url;
80
+ try {
81
+ url = await generatePhpMyAdminAccess(this.env.id);
82
+ } catch (err) {
83
+ const error = err;
84
+ void this.track('error', {
85
+ error_type: 'generate_pma_url',
86
+ error_message: error.message,
87
+ stack: error.stack
88
+ });
89
+ exit.withError(`Failed to generate PhpMyAdmin URL: ${error.message}`);
90
+ }
91
+ void this.openUrl(url);
92
+ this.log('PhpMyAdmin is opened in your default browser.');
93
+ }
94
+ }
95
+ exports.PhpMyAdminCommand = PhpMyAdminCommand;
@@ -88,7 +88,6 @@ _args.default.argv = async function (argv, cb) {
88
88
  options.app = parsedAlias.app;
89
89
  options.env = parsedAlias.env; // Can be undefined
90
90
  }
91
-
92
91
  const validationError = validateOpts(options);
93
92
  if (validationError) {
94
93
  const error = validationError.toString();
@@ -38,7 +38,6 @@ require('fetch-retry')(_nodeFetch.default, {
38
38
  return Math.pow(2, attempt) * 1000; // 1000, 2000, 4000
39
39
  }
40
40
  });
41
-
42
41
  const debug = (0, _debug.default)('vip:lib/client-file-uploader');
43
42
 
44
43
  // Files smaller than COMPRESS_THRESHOLD will not be compressed before upload
@@ -198,7 +197,6 @@ async function uploadUsingPutObject({
198
197
  ...fetchOptions.headers,
199
198
  'Content-Length': `${fileSize}` // This has to be a string
200
199
  };
201
-
202
200
  let readBytes = 0;
203
201
  const progressPassThrough = new _stream.PassThrough();
204
202
  progressPassThrough.on('data', data => {
@@ -484,7 +482,6 @@ async function uploadPart({
484
482
  * ...so it may not be feasible to include with presigned requests.
485
483
  */
486
484
  };
487
-
488
485
  fetchOptions.body = (0, _fs.createReadStream)(fileName, {
489
486
  start,
490
487
  end
@@ -40,4 +40,4 @@ const DEV_ENVIRONMENT_PHP_VERSIONS = exports.DEV_ENVIRONMENT_PHP_VERSIONS = {
40
40
  label: '7.4 (EOL; not supported)'
41
41
  }
42
42
  };
43
- const DEV_ENVIRONMENT_VERSION = exports.DEV_ENVIRONMENT_VERSION = '2.0.0';
43
+ const DEV_ENVIRONMENT_VERSION = exports.DEV_ENVIRONMENT_VERSION = '2.0.1';
@@ -189,7 +189,6 @@ async function getEnvironmentName(options) {
189
189
  }
190
190
  return DEFAULT_SLUG; // Fall back to the default slug if we don't have any, e.g. during the env creation purpose
191
191
  }
192
-
193
192
  function getEnvironmentStartCommand(slug, configurationFileOptions) {
194
193
  const isUsingConfigurationFileSlug = Object.keys(configurationFileOptions).length > 0 && configurationFileOptions.slug === slug;
195
194
  if (!slug || isUsingConfigurationFileSlug) {
@@ -606,7 +605,6 @@ function processBooleanOption(value) {
606
605
  // eslint-disable-next-line @typescript-eslint/no-base-to-string
607
606
  return !FALSE_OPTIONS.includes(value.toString().toLowerCase()); // NOSONAR
608
607
  }
609
-
610
608
  function processStringOrBooleanOption(value) {
611
609
  if (typeof value === 'boolean') {
612
610
  return value;
@@ -342,7 +342,6 @@ ${maybeExitPrompt}
342
342
  overallStatus = results.progress?.status ?? 'unknown';
343
343
  // This shouldn't be 'unknown'...what should we do here?
344
344
  }
345
-
346
345
  progressTracker.stopPrinting();
347
346
  setProgressTrackerSuffix();
348
347
 
package/docs/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  ## Changelog
2
2
 
3
+ ### 2.36.3
4
+
5
+ - build(deps): bump @json2csv/plainjs from 7.0.3 to 7.0.4
6
+ - build(deps-dev): bump nock from 13.3.8 to 13.4.0
7
+ - build(deps-dev): bump the babel group with 2 updates
8
+ - build(deps-dev): bump @automattic/eslint-plugin-wpvip from 0.9.0 to 0.9.1
9
+ - fix(dev-env): `/lando-entrypoint.sh: exec: line 83: exit: not found`
10
+ - build(deps-dev): bump eslint from 8.54.0 to 8.55.0
11
+ - build(deps-dev): bump typescript from 5.3.2 to 5.3.3
12
+ - build(deps-dev): bump the testing group with 1 update
13
+ - chore(deps): update lando to 25fcd83
14
+ - build(deps): bump Automattic/vip-actions from 0.1.2 to 0.2.0
15
+
3
16
  ### 2.36.2
4
17
 
5
18
  - #1558 fix(dev-env): Fix typo on suggested start command after updating env