@automattic/vip 2.35.1 → 2.36.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  ## Changelog
2
2
 
3
+ ### 2.35.1
4
+
5
+ - #1523 SQL Import Status: Ensure we pull site type ID from server for validation
6
+ - #1515 refactor: remove flow
7
+ - #1521 Fix link in CONTRIBUTING.md
8
+
3
9
  ### 2.35.0
4
10
 
5
11
  - #1506 Allow imports for all sites with databases by @chriszarate in https://github.com/Automattic/vip-cli/pull/1507
@@ -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 _command = _interopRequireDefault(require("../lib/cli/command"));
13
+ var _tracker = require("../lib/tracker");
14
+ var _phpmyadmin = require("../commands/phpmyadmin");
15
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
+ const examples = [{
17
+ usage: 'vip phpmyadmin @mysite.develop',
18
+ description: 'Open PhpMyAdmin for 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 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
+ });
package/dist/bin/vip.js CHANGED
@@ -29,7 +29,7 @@ if (_config.default && _config.default.environment !== 'production') {
29
29
  const tokenURL = 'https://dashboard.wpvip.com/me/cli/token';
30
30
  const runCmd = async function () {
31
31
  const cmd = (0, _command.default)();
32
- 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');
32
+ 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('phpmyadmin', 'Open PHPMyAdmin console for 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');
33
33
  cmd.argv(process.argv);
34
34
  };
35
35
 
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.PhpMyAdminCommand = exports.GENERATE_PHP_MY_ADMIN_URL_MUTATION = void 0;
7
+ var _graphqlTag = _interopRequireDefault(require("graphql-tag"));
8
+ var _opn = _interopRequireDefault(require("opn"));
9
+ var _api = _interopRequireWildcard(require("../lib/api"));
10
+ var exit = _interopRequireWildcard(require("../lib/cli/exit"));
11
+ 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); }
12
+ 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; }
13
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
+ /**
15
+ * External dependencies
16
+ */
17
+
18
+ /**
19
+ * Internal dependencies
20
+ */
21
+
22
+ const GENERATE_PHP_MY_ADMIN_URL_MUTATION = (0, _graphqlTag.default)`
23
+ mutation GeneratePhpMyAdminAccess($input: GeneratePhpMyAdminAccessInput) {
24
+ generatePHPMyAdminAccess(input: $input) {
25
+ expiresAt
26
+ url
27
+ }
28
+ }
29
+ `;
30
+ exports.GENERATE_PHP_MY_ADMIN_URL_MUTATION = GENERATE_PHP_MY_ADMIN_URL_MUTATION;
31
+ async function generatePhpMyAdminAccess(envId) {
32
+ var _resp$data;
33
+ // Disable global error handling so that we can handle errors ourselves
34
+ (0, _api.disableGlobalGraphQLErrorHandling)();
35
+ const api = await (0, _api.default)();
36
+ const resp = await api.mutate({
37
+ mutation: GENERATE_PHP_MY_ADMIN_URL_MUTATION,
38
+ variables: {
39
+ input: {
40
+ environmentId: envId
41
+ }
42
+ }
43
+ });
44
+
45
+ // Re-enable global error handling
46
+ (0, _api.enableGlobalGraphQLErrorHandling)();
47
+
48
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
49
+ return resp === null || resp === void 0 || (_resp$data = resp.data) === null || _resp$data === void 0 || (_resp$data = _resp$data.generatePHPMyAdminAccess) === null || _resp$data === void 0 ? void 0 : _resp$data.url;
50
+ }
51
+ class PhpMyAdminCommand {
52
+ app;
53
+ env;
54
+ silent;
55
+ track;
56
+ constructor(app, env, trackerFn = async () => {}) {
57
+ this.app = app;
58
+ this.env = env;
59
+ this.track = trackerFn;
60
+ }
61
+ log(msg) {
62
+ if (this.silent) {
63
+ return;
64
+ }
65
+ console.log(msg);
66
+ }
67
+ async run(silent = false) {
68
+ this.silent = silent;
69
+ if (!this.env.id) {
70
+ exit.withError('No environment was specified');
71
+ }
72
+ this.log('Generating PhpMyAdmin URL...');
73
+ let url;
74
+ try {
75
+ url = await generatePhpMyAdminAccess(this.env.id);
76
+ } catch (err) {
77
+ const error = err;
78
+ void this.track('error', {
79
+ error_type: 'generate_pma_url',
80
+ error_message: error.message,
81
+ stack: error.stack
82
+ });
83
+ exit.withError(`Failed to generate PhpMyAdmin URL: ${error.message}`);
84
+ }
85
+ void (0, _opn.default)(url, {
86
+ wait: false
87
+ });
88
+ this.log('PhpMyAdmin is opened in your default browser.');
89
+ }
90
+ }
91
+ exports.PhpMyAdminCommand = PhpMyAdminCommand;
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@automattic/vip",
3
- "version": "2.35.1",
3
+ "version": "2.36.0-dev.0",
4
4
  "lockfileVersion": 2,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@automattic/vip",
9
- "version": "2.35.1",
9
+ "version": "2.36.0-dev.0",
10
10
  "hasInstallScript": true,
11
11
  "license": "MIT",
12
12
  "dependencies": {
@@ -92,6 +92,7 @@
92
92
  "vip-import-validate-sql": "dist/bin/vip-import-validate-sql.js",
93
93
  "vip-logout": "dist/bin/vip-logout.js",
94
94
  "vip-logs": "dist/bin/vip-logs.js",
95
+ "vip-phpmyadmin": "dist/bin/vip-phpmyadmin.js",
95
96
  "vip-search-replace": "dist/bin/vip-search-replace.js",
96
97
  "vip-slowlogs": "dist/bin/vip-slowlogs.js",
97
98
  "vip-sync": "dist/bin/vip-sync.js",
@@ -118,6 +119,7 @@
118
119
  "@types/js-yaml": "^4.0.6",
119
120
  "@types/json2csv": "^5.0.4",
120
121
  "@types/node-fetch": "^2.6.5",
122
+ "@types/opn": "5.1.0",
121
123
  "@types/proxy-from-env": "^1.0.1",
122
124
  "@types/semver": "^7.5.1",
123
125
  "@types/shelljs": "^0.8.12",
@@ -3529,6 +3531,15 @@
3529
3531
  "form-data": "^4.0.0"
3530
3532
  }
3531
3533
  },
3534
+ "node_modules/@types/opn": {
3535
+ "version": "5.1.0",
3536
+ "resolved": "https://registry.npmjs.org/@types/opn/-/opn-5.1.0.tgz",
3537
+ "integrity": "sha512-TNPrB7Y1xl06zDI0aGyqkgxjhIev3oJ+cdqlZ52MTAHauWpEL/gIUdHebIfRHFZk9IqSBpE2ci1DT48iZH81yg==",
3538
+ "dev": true,
3539
+ "dependencies": {
3540
+ "@types/node": "*"
3541
+ }
3542
+ },
3532
3543
  "node_modules/@types/proxy-from-env": {
3533
3544
  "version": "1.0.2",
3534
3545
  "resolved": "https://registry.npmjs.org/@types/proxy-from-env/-/proxy-from-env-1.0.2.tgz",
@@ -16091,6 +16102,15 @@
16091
16102
  "form-data": "^4.0.0"
16092
16103
  }
16093
16104
  },
16105
+ "@types/opn": {
16106
+ "version": "5.1.0",
16107
+ "resolved": "https://registry.npmjs.org/@types/opn/-/opn-5.1.0.tgz",
16108
+ "integrity": "sha512-TNPrB7Y1xl06zDI0aGyqkgxjhIev3oJ+cdqlZ52MTAHauWpEL/gIUdHebIfRHFZk9IqSBpE2ci1DT48iZH81yg==",
16109
+ "dev": true,
16110
+ "requires": {
16111
+ "@types/node": "*"
16112
+ }
16113
+ },
16094
16114
  "@types/proxy-from-env": {
16095
16115
  "version": "1.0.2",
16096
16116
  "resolved": "https://registry.npmjs.org/@types/proxy-from-env/-/proxy-from-env-1.0.2.tgz",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automattic/vip",
3
- "version": "2.35.1",
3
+ "version": "2.36.0-dev.0",
4
4
  "description": "The VIP Javascript library & CLI",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -37,6 +37,7 @@
37
37
  "vip-dev-env-logs": "dist/bin/vip-dev-env-logs.js",
38
38
  "vip-export": "dist/bin/vip-export.js",
39
39
  "vip-export-sql": "dist/bin/vip-export-sql.js",
40
+ "vip-phpmyadmin": "dist/bin/vip-phpmyadmin.js",
40
41
  "vip-dev-env-sync": "dist/bin/vip-dev-env-sync.js",
41
42
  "vip-dev-env-sync-sql": "dist/bin/vip-dev-env-sync-sql.js",
42
43
  "vip-import": "dist/bin/vip-import.js",
@@ -119,6 +120,7 @@
119
120
  "@types/js-yaml": "^4.0.6",
120
121
  "@types/json2csv": "^5.0.4",
121
122
  "@types/node-fetch": "^2.6.5",
123
+ "@types/opn": "5.1.0",
122
124
  "@types/proxy-from-env": "^1.0.1",
123
125
  "@types/semver": "^7.5.1",
124
126
  "@types/shelljs": "^0.8.12",