@automattic/vip 2.36.1 → 2.36.2-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.
@@ -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
+ });
@@ -27,11 +27,17 @@ const examples = [{
27
27
  const slug = await (0, _devEnvironmentCli.getEnvironmentName)(opt);
28
28
  const cmd = new _devEnvImportSql.DevEnvImportSQLCommand(fileName, opt, slug);
29
29
  const trackingInfo = (0, _devEnvironmentCli.getEnvTrackingInfo)(cmd.slug);
30
+ const trackerFn = (0, _tracker.makeCommandTracker)('dev_env_import_sql', trackingInfo);
31
+ await trackerFn('execute');
30
32
  try {
31
33
  await cmd.run();
32
- await (0, _tracker.trackEvent)('dev_env_import_sql_command_success', trackingInfo);
34
+ await trackerFn('success');
33
35
  } catch (error) {
34
- await (0, _devEnvironmentCli.handleCLIException)(error, 'dev_env_import_sql_command_error', trackingInfo);
36
+ await (0, _devEnvironmentCli.handleCLIException)(error);
37
+ await trackerFn('error', {
38
+ message: error.message,
39
+ stack: error.stack
40
+ });
35
41
  process.exitCode = 1;
36
42
  }
37
43
  });
@@ -67,7 +67,7 @@ cmd.argv(process.argv, async (arg, opt) => {
67
67
  const instanceData = await (0, _devEnvironmentCli.promptForArguments)(finalPreselectedOptions, defaultOptions, suppressPrompts);
68
68
  instanceData.siteSlug = slug;
69
69
  await (0, _devEnvironmentCore.updateEnvironment)(instanceData);
70
- const message = '\n' + _chalk.default.green('✓') + ' environment updated. Please start environment again for changes to take effect: ' + _chalk.default.bold(`vip dev env --slug ${slug} start`);
70
+ const message = '\n' + _chalk.default.green('✓') + ' environment updated. Please start environment again for changes to take effect: ' + _chalk.default.bold(`vip dev-env --slug ${slug} start`);
71
71
  console.log(message);
72
72
  await (0, _tracker.trackEvent)('dev_env_update_command_success', trackingInfo);
73
73
  } catch (error) {
package/dist/bin/vip.js CHANGED
@@ -22,7 +22,7 @@ if (_config.default && _config.default.environment !== 'production') {
22
22
  const tokenURL = 'https://dashboard.wpvip.com/me/cli/token';
23
23
  const runCmd = async function () {
24
24
  const cmd = (0, _command.default)();
25
- 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');
25
+ 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');
26
26
  cmd.argv(process.argv);
27
27
  };
28
28
 
@@ -19,7 +19,6 @@ class DevEnvImportSQLCommand {
19
19
  fileName;
20
20
  options;
21
21
  slug;
22
- trackingInfo;
23
22
  constructor(fileName, options, slug) {
24
23
  this.fileName = fileName;
25
24
  this.options = options;
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.PhpMyAdminCommand = exports.GENERATE_PHP_MY_ADMIN_URL_MUTATION = void 0;
5
+ var _graphqlTag = _interopRequireDefault(require("graphql-tag"));
6
+ var _opn = _interopRequireDefault(require("opn"));
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 run(silent = false) {
64
+ this.silent = silent;
65
+ if (!this.env.id) {
66
+ exit.withError('No environment was specified');
67
+ }
68
+ this.log('Generating PhpMyAdmin URL...');
69
+ let url;
70
+ try {
71
+ url = await generatePhpMyAdminAccess(this.env.id);
72
+ } catch (err) {
73
+ const error = err;
74
+ void this.track('error', {
75
+ error_type: 'generate_pma_url',
76
+ error_message: error.message,
77
+ stack: error.stack
78
+ });
79
+ exit.withError(`Failed to generate PhpMyAdmin URL: ${error.message}`);
80
+ }
81
+
82
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call
83
+ void (0, _opn.default)(url, {
84
+ wait: false
85
+ });
86
+ this.log('PhpMyAdmin is opened in your default browser.');
87
+ }
88
+ }
89
+ exports.PhpMyAdminCommand = PhpMyAdminCommand;
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@automattic/vip",
3
- "version": "2.36.1",
3
+ "version": "2.36.2-dev.0",
4
4
  "lockfileVersion": 2,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@automattic/vip",
9
- "version": "2.36.1",
9
+ "version": "2.36.2-dev.0",
10
10
  "hasInstallScript": true,
11
11
  "license": "MIT",
12
12
  "dependencies": {
@@ -64,6 +64,8 @@
64
64
  "vip-config-software": "dist/bin/vip-config-software.js",
65
65
  "vip-config-software-get": "dist/bin/vip-config-software-get.js",
66
66
  "vip-config-software-update": "dist/bin/vip-config-software-update.js",
67
+ "vip-db": "dist/bin/vip-db.js",
68
+ "vip-db-phpmyadmin": "dist/bin/vip-db-phpmyadmin.js",
67
69
  "vip-dev-env": "dist/bin/vip-dev-env.js",
68
70
  "vip-dev-env-create": "dist/bin/vip-dev-env-create.js",
69
71
  "vip-dev-env-destroy": "dist/bin/vip-dev-env-destroy.js",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automattic/vip",
3
- "version": "2.36.1",
3
+ "version": "2.36.2-dev.0",
4
4
  "description": "The VIP Javascript library & CLI",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -21,6 +21,8 @@
21
21
  "vip-config-software": "dist/bin/vip-config-software.js",
22
22
  "vip-config-software-get": "dist/bin/vip-config-software-get.js",
23
23
  "vip-config-software-update": "dist/bin/vip-config-software-update.js",
24
+ "vip-db": "dist/bin/vip-db.js",
25
+ "vip-db-phpmyadmin": "dist/bin/vip-db-phpmyadmin.js",
24
26
  "vip-dev-env": "dist/bin/vip-dev-env.js",
25
27
  "vip-dev-env-create": "dist/bin/vip-dev-env-create.js",
26
28
  "vip-dev-env-update": "dist/bin/vip-dev-env-update.js",
@@ -185,7 +187,6 @@
185
187
  }
186
188
  },
187
189
  "publishConfig": {
188
- "access": "public",
189
- "provenance": true
190
+ "access": "public"
190
191
  }
191
192
  }