@automattic/vip 2.36.2-dev.0 → 2.36.3
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/.eslintrc.js +22 -0
- package/.prettierignore +2 -2
- package/README.md +15 -26
- package/assets/dev-env.lando.template.yml.ejs +1 -1
- package/dist/bin/vip-dev-env-purge.js +67 -0
- package/dist/bin/vip-dev-env.js +1 -1
- package/dist/bin/vip-import-sql.js +0 -1
- package/dist/bin/vip.js +5 -3
- package/dist/commands/export-sql.js +1 -1
- package/dist/lib/cli/command.js +0 -1
- package/dist/lib/client-file-uploader.js +0 -3
- package/dist/lib/constants/dev-environment.js +1 -1
- package/dist/lib/dev-environment/dev-environment-cli.js +0 -2
- package/dist/lib/site-import/status.js +0 -1
- package/docs/ARCHITECTURE.md +95 -0
- package/{CHANGELOG.md → docs/CHANGELOG.md} +37 -0
- package/docs/CONTRIBUTING.md +29 -0
- package/docs/DEBUGGING.md +33 -0
- package/docs/RELEASING.md +163 -0
- package/docs/SETUP.md +151 -0
- package/docs/TESTING.md +67 -0
- package/npm-shrinkwrap.json +2731 -2025
- package/package.json +30 -31
- package/tsconfig.json +4 -16
- package/CONTRIBUTING.md +0 -216
- package/dist/bin/vip-db-phpmyadmin.js +0 -53
- package/dist/bin/vip-db.js +0 -19
- package/dist/commands/phpmyadmin.js +0 -89
- /package/{SECURITY.md → docs/SECURITY.md} +0 -0
package/.eslintrc.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require( '@automattic/eslint-plugin-wpvip/init' );
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
extends: [
|
|
5
|
+
'plugin:@automattic/wpvip/recommended',
|
|
6
|
+
'plugin:@automattic/wpvip/cli',
|
|
7
|
+
'plugin:@automattic/wpvip/weak-testing',
|
|
8
|
+
'plugin:@automattic/wpvip/typescript',
|
|
9
|
+
],
|
|
10
|
+
rules: {
|
|
11
|
+
camelcase: 'warn',
|
|
12
|
+
'jest/no-mocks-import': 'warn',
|
|
13
|
+
'no-await-in-loop': 'warn',
|
|
14
|
+
'no-console': 0,
|
|
15
|
+
'security/detect-object-injection': 0,
|
|
16
|
+
'security/detect-non-literal-fs-filename': 0,
|
|
17
|
+
'promise/no-multiple-resolved': 0,
|
|
18
|
+
'no-unused-vars': 'off',
|
|
19
|
+
'@typescript-eslint/no-unused-vars': 'warn',
|
|
20
|
+
},
|
|
21
|
+
root: true,
|
|
22
|
+
};
|
package/.prettierignore
CHANGED
package/README.md
CHANGED
|
@@ -1,31 +1,20 @@
|
|
|
1
|
-
VIP-CLI
|
|
1
|
+
# VIP-CLI
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
VIP-CLI is a tool for interacting with and managing your [WordPress VIP applications](https://wpvip.com/).
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Further documentation
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
- [SETUP.md](https://github.com/Automattic/vip-cli/blob/trunk/docs/SETUP.md) for installation and setup instructions, basic usage and environmental variables.
|
|
8
|
+
- [ARCHITECTURE.md](https://github.com/Automattic/vip-cli/blob/trunk/docs/ARCHITECTURE.md) for information on architecture, code structure, data storage and security.
|
|
9
|
+
- [CONTRIBUTING.md](https://github.com/Automattic/vip-cli/blob/trunk/docs/CONTRIBUTING.md) for information on how to contribute patches and features, also issue and pull request labels.
|
|
10
|
+
- [DEBUGGING.md](https://github.com/Automattic/vip-cli/blob/trunk/docs/DEBUGGING.md) for information on how to debug the software.
|
|
11
|
+
- [TESTING.md](https://github.com/Automattic/vip-cli/blob/trunk/docs/TESTING.md) for details on testing the software and individual tasks.
|
|
12
|
+
- [RELEASING.md](https://github.com/Automattic/vip-cli/blob/trunk/docs/RELEASING.md) for details on deploying a new release.
|
|
13
|
+
- [SECURITY.md](https://github.com/Automattic/vip-cli/blob/trunk/docs/SECURITY.md) for information if you **found a security issue**.
|
|
10
14
|
|
|
11
|
-
|
|
15
|
+
## Further information
|
|
12
16
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
Then, launch the command and follow the prompts:
|
|
18
|
-
|
|
19
|
-
```
|
|
20
|
-
vip
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
If you need more information, check out our [VIP-CLI documentation](https://docs.wpvip.com/technical-references/vip-cli/).
|
|
24
|
-
|
|
25
|
-
## Contributing
|
|
26
|
-
|
|
27
|
-
For help with contributing to this project, including instructions for local development, please see [CONTRIBUTING](CONTRIBUTING.md) and [SECURITY](SECURITY.md).
|
|
28
|
-
|
|
29
|
-
## Analytics
|
|
30
|
-
|
|
31
|
-
By default, we record information about the usage of this tool using an in-house analytics sytem. If you would prefer to opt-out of this data collection, you can do so via the `DO_NOT_TRACK` environment variable. You may either export it in your shell configuration or specify it on the command line (e.g. `DO_NOT_TRACK=1 vip app list`).
|
|
17
|
+
- In the [WordPress VIP Lobby](https://lobby.vip.wordpress.com/) find announcements related to the [CLI](https://lobby.vip.wordpress.com/?s=vip-cli) and [API](https://lobby.vip.wordpress.com/?s=vip%20go%20api).
|
|
18
|
+
- The [WordPress VIP Documentation](https://docs.wpvip.com/) has instructions related to the [CLI](https://docs.wpvip.com/technical-references/vip-cli/).
|
|
19
|
+
- [Changelog](https://github.com/Automattic/vip-cli/blob/trunk/docs/CHANGELOG.md) file for VIP-CLI is available.
|
|
20
|
+
- [VIP Cloud Changelog](https://wpvipchangelog.wordpress.com/) logs changes to the [CLI](https://wpvipchangelog.wordpress.com/?s=cli) and other aspects of the platform.
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* External dependencies
|
|
5
|
+
*/
|
|
6
|
+
"use strict";
|
|
7
|
+
|
|
8
|
+
var _chalk = _interopRequireDefault(require("chalk"));
|
|
9
|
+
var _debug = _interopRequireDefault(require("debug"));
|
|
10
|
+
var _command = _interopRequireDefault(require("../lib/cli/command"));
|
|
11
|
+
var _devEnvironment = require("../lib/constants/dev-environment");
|
|
12
|
+
var _devEnvironmentCli = require("../lib/dev-environment/dev-environment-cli");
|
|
13
|
+
var _devEnvironmentCore = require("../lib/dev-environment/dev-environment-core");
|
|
14
|
+
var _devEnvironmentLando = require("../lib/dev-environment/dev-environment-lando");
|
|
15
|
+
var _tracker = require("../lib/tracker");
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
+
/**
|
|
18
|
+
* Internal dependencies
|
|
19
|
+
*/
|
|
20
|
+
const debug = (0, _debug.default)('@automattic/vip:bin:dev-environment');
|
|
21
|
+
const examples = [{
|
|
22
|
+
usage: `${_devEnvironment.DEV_ENVIRONMENT_FULL_COMMAND} purge`,
|
|
23
|
+
description: 'Destroys all local dev environments'
|
|
24
|
+
}, {
|
|
25
|
+
usage: `${_devEnvironment.DEV_ENVIRONMENT_FULL_COMMAND} purge --force`,
|
|
26
|
+
description: 'Destroys all local dev environments without prompting'
|
|
27
|
+
}];
|
|
28
|
+
(0, _command.default)().option('soft', 'Keep config files needed to start an environment intact').option('force', 'Removes prompt that verifies if user wants to destroy all environments').examples(examples).argv(process.argv, async (arg, opt) => {
|
|
29
|
+
debug('Args: ', arg, 'Options: ', opt);
|
|
30
|
+
const allEnvNames = (0, _devEnvironmentCore.getAllEnvironmentNames)();
|
|
31
|
+
const lando = await (0, _devEnvironmentLando.bootstrapLando)();
|
|
32
|
+
if (allEnvNames.length === 0) {
|
|
33
|
+
console.log('No environments to purge!');
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (!opt.force) {
|
|
37
|
+
const purge = await (0, _devEnvironmentCli.promptForBoolean)('Are you sure you want to purge ALL existing dev environments?', true);
|
|
38
|
+
if (!purge) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const trackingInfo = {
|
|
43
|
+
all: true
|
|
44
|
+
};
|
|
45
|
+
await (0, _tracker.trackEvent)('dev_env_purge_command_execute', trackingInfo);
|
|
46
|
+
await (0, _devEnvironmentCli.validateDependencies)(lando, '');
|
|
47
|
+
const removeFiles = !(opt.soft || false);
|
|
48
|
+
try {
|
|
49
|
+
for (const slug of allEnvNames) {
|
|
50
|
+
try {
|
|
51
|
+
// eslint-disable-next-line no-await-in-loop
|
|
52
|
+
await (0, _devEnvironmentCore.destroyEnvironment)(lando, slug, removeFiles);
|
|
53
|
+
const message = _chalk.default.green('✓') + ' Environment destroyed.\n';
|
|
54
|
+
console.log(message);
|
|
55
|
+
} catch (error) {
|
|
56
|
+
const trackingInfoChild = (0, _devEnvironmentCli.getEnvTrackingInfo)(slug);
|
|
57
|
+
// eslint-disable-next-line no-await-in-loop
|
|
58
|
+
await (0, _devEnvironmentCli.handleCLIException)(error, 'dev_env_purge_command_error', trackingInfoChild);
|
|
59
|
+
process.exitCode = 1;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
await (0, _tracker.trackEvent)('dev_env_purge_command_success', trackingInfo);
|
|
63
|
+
} catch (error) {
|
|
64
|
+
await (0, _devEnvironmentCli.handleCLIException)(error, 'dev_env_purge_command_error', trackingInfo);
|
|
65
|
+
process.exitCode = 1;
|
|
66
|
+
}
|
|
67
|
+
});
|
package/dist/bin/vip-dev-env.js
CHANGED
|
@@ -5,4 +5,4 @@ var _command = _interopRequireDefault(require("../lib/cli/command"));
|
|
|
5
5
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
6
6
|
(0, _command.default)({
|
|
7
7
|
requiredArgs: 0
|
|
8
|
-
}).command('create', 'Create a new local dev environment').command('update', 'Update an already created local dev environment').command('start', 'Start a local dev environment').command('stop', 'Stop a local dev environment').command('destroy', 'Remove containers, networks, volumes and configuration files of a local dev environment').command('info', 'Provides basic info about one or multiple local dev environments').command('list', 'Provides basic info about all local dev environments').command('exec', 'Execute a WP-CLI command in local dev environment').command('import', 'Import data into a local WordPress environment').command('shell', 'Spawns a shell in a dev environment').command('logs', 'View logs from a local WordPress environment').command('sync', 'Pull data from production to local development environment').argv(process.argv);
|
|
8
|
+
}).command('create', 'Create a new local dev environment').command('update', 'Update an already created local dev environment').command('start', 'Start a local dev environment').command('stop', 'Stop a local dev environment').command('destroy', 'Remove containers, networks, volumes and configuration files of a local dev environment').command('info', 'Provides basic info about one or multiple local dev environments').command('list', 'Provides basic info about all local dev environments').command('exec', 'Execute a WP-CLI command in local dev environment').command('import', 'Import data into a local WordPress environment').command('shell', 'Spawns a shell in a dev environment').command('logs', 'View logs from a local WordPress environment').command('sync', 'Pull data from production to local development environment').command('purge', 'Destroy all existing environments').argv(process.argv);
|
|
@@ -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
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
5
5
|
var _debug = _interopRequireDefault(require("debug"));
|
|
6
6
|
var _enquirer = require("enquirer");
|
|
7
|
-
var _opn = _interopRequireDefault(require("opn"));
|
|
8
7
|
var _command = _interopRequireWildcard(require("../lib/cli/command"));
|
|
9
8
|
var _config = _interopRequireDefault(require("../lib/cli/config"));
|
|
10
9
|
var _token = _interopRequireDefault(require("../lib/token"));
|
|
@@ -22,7 +21,7 @@ if (_config.default && _config.default.environment !== 'production') {
|
|
|
22
21
|
const tokenURL = 'https://dashboard.wpvip.com/me/cli/token';
|
|
23
22
|
const runCmd = async function () {
|
|
24
23
|
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('
|
|
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');
|
|
26
25
|
cmd.argv(process.argv);
|
|
27
26
|
};
|
|
28
27
|
|
|
@@ -66,7 +65,10 @@ const rootCmd = async function () {
|
|
|
66
65
|
await (0, _tracker.trackEvent)('login_command_browser_cancelled');
|
|
67
66
|
return;
|
|
68
67
|
}
|
|
69
|
-
|
|
68
|
+
const {
|
|
69
|
+
default: open
|
|
70
|
+
} = await import('open');
|
|
71
|
+
open(tokenURL, {
|
|
70
72
|
wait: false
|
|
71
73
|
});
|
|
72
74
|
await (0, _tracker.trackEvent)('login_command_browser_opened');
|
|
@@ -376,7 +376,7 @@ class ExportSQLCommand {
|
|
|
376
376
|
error_message: err?.message,
|
|
377
377
|
stack: err?.stack
|
|
378
378
|
});
|
|
379
|
-
exit.withError('There is an export job already running for this environment: ' + `https://dashboard.wpvip.com/apps/${this.app.id}/${this.env.uniqueLabel}/
|
|
379
|
+
exit.withError('There is an export job already running for this environment: ' + `https://dashboard.wpvip.com/apps/${this.app.id}/${this.env.uniqueLabel}/database/backups\n` + 'Currently, we allow only one export job at a time, per site. Please try again later.');
|
|
380
380
|
} else {
|
|
381
381
|
await this.track('error', {
|
|
382
382
|
error_type: 'create_export_job',
|
package/dist/lib/cli/command.js
CHANGED
|
@@ -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.
|
|
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;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# Architecture
|
|
2
|
+
|
|
3
|
+
## Basic functionality
|
|
4
|
+
|
|
5
|
+
This is a CLI for interacting with and managing your [WordPress VIP applications](https://docs.wpvip.com/technical-references/vip-cli/). Data is inputted and outputted via terminal to the [API offered by WordPress VIP](#communicating-with-wpvip-api) and to/from local filesystem.
|
|
6
|
+
|
|
7
|
+
For configuration, a few [environmental variables](SETUP.md#environmental-variables) are used and some [configuration files](SETUP.md#configuration-files) as well. No [database](#database) is required.
|
|
8
|
+
|
|
9
|
+
### Scalability
|
|
10
|
+
|
|
11
|
+
No specific considerations.
|
|
12
|
+
|
|
13
|
+
### Communicating with WPVIP API
|
|
14
|
+
|
|
15
|
+
The CLI communicates primarily with https://api.wpvip.com. An authentication token is required to access the API which the CLI will ask for when executed. Tokens can be retrieved from the [VIP Dashboard](https://dashboard.wpvip.com/).
|
|
16
|
+
|
|
17
|
+
## Languages & coding standard
|
|
18
|
+
|
|
19
|
+
Both JavaScript and TypeScript are used to implement the software. **TypeScript should be used for new code.**
|
|
20
|
+
|
|
21
|
+
We require that the WPVIP defined coding style to be used, defined in [.eslintrc.js](https://github.com/Automattic/vip-cli/blob/trunk/.eslintrc.js).
|
|
22
|
+
|
|
23
|
+
## Code structure
|
|
24
|
+
|
|
25
|
+
The code is structured in the following way:
|
|
26
|
+
|
|
27
|
+
- [.github](https://github.com/Automattic/vip-cli/tree/trunk/.github) — configuration and templates for GitHub.
|
|
28
|
+
- [\_\_fixtures\_\_](https://github.com/Automattic/vip-cli/tree/trunk/__fixtures__) — fixtures for testing package.
|
|
29
|
+
- [\_\_tests\_\_](https://github.com/Automattic/vip-cli/tree/trunk/__tests__) — testing package.
|
|
30
|
+
- [config](https://github.com/Automattic/vip-cli/tree/trunk/config) — configuration files.
|
|
31
|
+
- [docs](https://github.com/Automattic/vip-cli/tree/trunk/docs) — documentation package.
|
|
32
|
+
- [types](https://github.com/Automattic/vip-cli/tree/trunk/types) - for TypeScript.
|
|
33
|
+
- [helpers](https://github.com/Automattic/vip-cli/tree/trunk/helpers) - helper scripts.
|
|
34
|
+
- [src](https://github.com/Automattic/vip-cli/tree/trunk/src) - main source code.
|
|
35
|
+
|
|
36
|
+
## API interfaces
|
|
37
|
+
|
|
38
|
+
No APIs are offered.
|
|
39
|
+
|
|
40
|
+
### GraphQL interfaces
|
|
41
|
+
|
|
42
|
+
No APIs are offered.
|
|
43
|
+
|
|
44
|
+
## Feature flags
|
|
45
|
+
|
|
46
|
+
TODO: Do we apply feature flags in this code? Describe how it works.
|
|
47
|
+
|
|
48
|
+
## Database
|
|
49
|
+
|
|
50
|
+
No database is needed.
|
|
51
|
+
|
|
52
|
+
## Dependency services
|
|
53
|
+
|
|
54
|
+
VIP-CLI communicates with a few services via APIs:
|
|
55
|
+
|
|
56
|
+
- [WPVIP API](#communicating-with-wpvip-api).
|
|
57
|
+
- https://public-api.wordpress.com/rest – for analytics (can be [disabled](SETUP.md#analytics)).
|
|
58
|
+
|
|
59
|
+
## Development
|
|
60
|
+
|
|
61
|
+
Here are guidelines to ensure we have consistency across the CLI and web interfaces.
|
|
62
|
+
|
|
63
|
+
### Adding commands
|
|
64
|
+
|
|
65
|
+
- New command names should use the singular form (e.g. site vs sites).
|
|
66
|
+
- Add new commands to `package.json#bin`.
|
|
67
|
+
- Run `npm link` so that `arg` knows how to spawn the command locally. (Skipping this step will result in `Error: spawn vip-command ENOENT`.)
|
|
68
|
+
|
|
69
|
+
### Adding libraries
|
|
70
|
+
|
|
71
|
+
New libraries should generally support both CLI and web contexts, though some cases that won't make sense (e.g. formatting for CLI output). Ensuring the libraries are useful everywhere will allow us to offer consistent experiences regardless of the interface.
|
|
72
|
+
|
|
73
|
+
### go-search-replace binaries
|
|
74
|
+
|
|
75
|
+
Some unit tests require some go-search-replace executable binary files to run. Binaries files for
|
|
76
|
+
several OS architectures can be downloaded
|
|
77
|
+
from https://github.com/Automattic/go-search-replace/releases/
|
|
78
|
+
|
|
79
|
+
If, for some reason, you need to compile these binaries yourself, please follow instructions
|
|
80
|
+
at https://github.com/Automattic/go-search-replace
|
|
81
|
+
|
|
82
|
+
### Generating the types
|
|
83
|
+
|
|
84
|
+
If you're an employee of Automattic, you can follow these steps to regenerate the GraphQL types
|
|
85
|
+
used.
|
|
86
|
+
|
|
87
|
+
1. Get a hold of `schema.gql` and paste it in project root - this is the schema of the endpoint that
|
|
88
|
+
we communicate with.
|
|
89
|
+
2. Run `npm run typescript:codegen:install-dependencies` - this will install the codegen
|
|
90
|
+
dependencies without updating `package.json`
|
|
91
|
+
3. Run `npm run typescript:codegen:generate` - this will regenerate the types.
|
|
92
|
+
|
|
93
|
+
## Alerting
|
|
94
|
+
|
|
95
|
+
There are no alerts.
|
|
@@ -1,5 +1,42 @@
|
|
|
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
|
+
|
|
16
|
+
### 2.36.2
|
|
17
|
+
|
|
18
|
+
- #1558 fix(dev-env): Fix typo on suggested start command after updating env
|
|
19
|
+
- #1557 fix(dev-env): Fix an issue where dev-env-import-sql command execute event was not being tracked
|
|
20
|
+
- #1554 chore(dev-deps): update testing tools
|
|
21
|
+
- #1556 chore(dev-deps): update eslint from 8.52.0 to 8.54.0
|
|
22
|
+
- #1555 chore(deps): replace the deprecated `opn` with `open`
|
|
23
|
+
- #1553 chore(dev-deps): update TypeScript and typings
|
|
24
|
+
- #1578 build(deps-dev): bump @types/semver from 7.5.4 to 7.5.6
|
|
25
|
+
- #1577 Updating ESLint config
|
|
26
|
+
- #1559 Restructure and refine documentation + add missing tests
|
|
27
|
+
- #1591 Fix database backup URL in error message
|
|
28
|
+
- #1537 Add vip dev-env purge command logic
|
|
29
|
+
- #1590 build(deps): bump actions/setup-node from 3 to 4
|
|
30
|
+
- #1589 build(deps): bump actions/checkout from 3 to 4
|
|
31
|
+
- #1592 chore: group dependencies that should be updated together
|
|
32
|
+
- #1594 build(deps-dev): bump the babel group with 4 updates
|
|
33
|
+
- #1593 build(deps-dev): bump the testing group with 1 update
|
|
34
|
+
- #1595 build(deps-dev): bump typescript from 5.2.2 to 5.3.2
|
|
35
|
+
- #1596 build(deps): bump @automattic/vip-go-preflight-checks from 2.0.16 to 2.0.17
|
|
36
|
+
- #1580 build(deps): bump ini from 2.0.0 to 4.1.1
|
|
37
|
+
- #1598 build(deps-dev): bump @automattic/eslint-plugin-wpvip from 0.8.0 to 0.9.0
|
|
38
|
+
- #1597 chore(deps): update Lando
|
|
39
|
+
|
|
3
40
|
### 2.36.1
|
|
4
41
|
|
|
5
42
|
- #1550 chore(deps): replace cli-table with cli-table3
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
## Pull requests & issues
|
|
4
|
+
|
|
5
|
+
We welcome any contributions to this project.
|
|
6
|
+
|
|
7
|
+
If you have a small bugfix and already have the code available, feel free to [create a pull request](https://github.com/Automattic/vip-cli/compare). If you have a feature suggestion, please [create an issue](https://github.com/Automattic/vip-cli/issues/new). Please follow the instructions provided. Please assign a priority to the issue/pull request according to the definitions found below.
|
|
8
|
+
|
|
9
|
+
Before writing a patch or a larger chunk of code, please ensure to study the [ARCHITECTURE.md](ARCHITECTURE.md) and [TESTING.md](TESTING.md) files. Ensure that all tests pass before asking for a review of your pull request.
|
|
10
|
+
|
|
11
|
+
## Priorities
|
|
12
|
+
|
|
13
|
+
Each GitHub issue and pull request relating to this repository should have a priority label to make prioritizing easier. The definition of each priority is as follows:
|
|
14
|
+
|
|
15
|
+
- [Critical](https://github.com/Automattic/vip-cli/labels/%5BPri%5D%20Critical): A bug currently affecting normal operation or a security problem that needs to be addressed urgently.
|
|
16
|
+
- [High](https://github.com/Automattic/vip-cli/labels/%5BPri%5D%20High): An issue that is: a) relevant to current goals of the project, b) a bug that needs to addressed soon to maintain stability, or c) a feature often requested.
|
|
17
|
+
- [Normal](https://github.com/Automattic/vip-cli/labels/%5BPri%5D%20Normal): Most issues belong here. These will include features less often requested, new lower priority features, documentation updates, etc.
|
|
18
|
+
- [Low](https://github.com/Automattic/vip-cli/labels/%5BPri%5D%20Low): Features that are good to have belong here.
|
|
19
|
+
|
|
20
|
+
## Type of change labels
|
|
21
|
+
|
|
22
|
+
Each GitHub issue and pull-request should have a type of change label associated with it. The definition of these are as follows:
|
|
23
|
+
|
|
24
|
+
- [Bug](https://github.com/Automattic/vip-cli/labels/%5BType%5D%20Bug): Code change to fix a bug, or a bug report.
|
|
25
|
+
- [Clean up](https://github.com/Automattic/vip-cli/labels/%5B%20Type%20%5D%20Clean%20up): Pull request for general code clean ups.
|
|
26
|
+
- [Documentation](https://github.com/Automattic/vip-cli/labels/%5B%20Type%20%5D%20Documentation): Pull request to update documentation.
|
|
27
|
+
- [Enhancement](https://github.com/Automattic/vip-cli/labels/%5BType%5D%20Enhancement): A general enhancement – new feature, better implementation, new tests and so forth.
|
|
28
|
+
- [Remove feature](https://github.com/Automattic/vip-cli/labels/%5B%20Type%20%5D%20Remove%20feature): Pull request to remove feature code.
|
|
29
|
+
- [Update dependency](https://github.com/Automattic/vip-cli/labels/%5B%20Type%20%5D%20Update%20dependency): Pull request to update one or more dependencies.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Debugging
|
|
2
|
+
|
|
3
|
+
## Using debugger
|
|
4
|
+
|
|
5
|
+
A debugger can easily be used to help pinpointing issues with the code. Follow these steps.
|
|
6
|
+
|
|
7
|
+
1. First, make sure to run the `npm run build:watch`, this will generate source maps
|
|
8
|
+
2. Run the command you want via `node --inspect`, like so: `node --inspect ./dist/bin/vip-dev-env-import-sql.js`
|
|
9
|
+
3. Note the port the debugger is listening on:
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
Debugger listening on ws://127.0.0.1:9229/db6c03e9-2585-4a08-a1c6-1fee0295c9ff
|
|
13
|
+
For help, see: https://nodejs.org/en/docs/inspector
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
4. In your editor of choice attach to the debugger. For VSCode: Hit 'Run and Debug' panel, hit the "gear" icon (open launch.json), make your `Attach` configuration entry to look like so:
|
|
17
|
+
Make sure the `port` matches the port from step 3, and the `runtimeExecutable` matches the exact `node` executable you ran. If you use a version manager like `nvm`, its especially important to check this.
|
|
18
|
+
|
|
19
|
+
```json
|
|
20
|
+
{
|
|
21
|
+
"name": "Attach",
|
|
22
|
+
"port": 9229,
|
|
23
|
+
"request": "attach",
|
|
24
|
+
"skipFiles": [ "<node_internals>/**" ],
|
|
25
|
+
"type": "node",
|
|
26
|
+
"runtimeExecutable": "/Users/user/.nvm/versions/node/v14.18.2/bin/node"
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
5. Set your breakpoints, add debug code, and hit the play button.
|
|
31
|
+
6. Confirm that you attached the debugger to continue command execution.
|
|
32
|
+
7. Resolve the problem.
|
|
33
|
+
8. [Optional but recommended] Pay it forward and implement a similar approach to other internal/external tooling.
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
# Releasing
|
|
2
|
+
|
|
3
|
+
Please familiarize yourself with the [SETUP.md](SETUP.md) file before releasing.
|
|
4
|
+
|
|
5
|
+
## New pull requests
|
|
6
|
+
|
|
7
|
+
Follow these steps for new pull requests:
|
|
8
|
+
|
|
9
|
+
1. Please note the publishing method (see [below](#releasing-a-new-version)).
|
|
10
|
+
|
|
11
|
+
1. Ensure when you create your pull request that:
|
|
12
|
+
|
|
13
|
+
a. It merges to `trunk`. The release flow for VIP-CLI follows this pattern: **_feature branch -> `trunk` branch_**
|
|
14
|
+
|
|
15
|
+
b. The feature branch follows A8C branch naming conventions, e.g.: `add/health-query`, `fix/subsite-mutation`, etc.
|
|
16
|
+
|
|
17
|
+
c. The pull request code and description contain no sensitive information. Please do not include any internal links in PRs, changelogs, testing instructions, etc. as this is a public repository.
|
|
18
|
+
|
|
19
|
+
d. You have included changelog entry by adding a `## Changelog Description` section to the GitHub pull request description. All changelogs are posted to the [VIP Cloud Changelog P2](https://wpvipchangelog.wordpress.com/) which customers can view and follow.
|
|
20
|
+
|
|
21
|
+
1. Once you've created your pull request, ensure that:
|
|
22
|
+
|
|
23
|
+
a. You have added [all the automated tests required](TESTING.md#automated-testing).
|
|
24
|
+
|
|
25
|
+
b. You have completed [manual testing of your change](TESTING.md#manual-testing).
|
|
26
|
+
|
|
27
|
+
1. If updating a dependency (NPM package or Node), follow the [guidelines on updating dependencies](SETUP.md#updating-dependencies).
|
|
28
|
+
|
|
29
|
+
1. Have your pull request reviewed by a colleague and approved — especially if it is a large change or a complex addition.
|
|
30
|
+
|
|
31
|
+
1. Verify that your pull request passes all automated tests.
|
|
32
|
+
|
|
33
|
+
1. Merge your pull request.
|
|
34
|
+
|
|
35
|
+
## Preparing for release
|
|
36
|
+
|
|
37
|
+
A few steps should be completed before releasing:
|
|
38
|
+
|
|
39
|
+
1. Verify that [all relevant pull requests](https://github.com/Automattic/vip-cli/pulls) are merged.
|
|
40
|
+
|
|
41
|
+
1. The [changelog](CHANGELOG.md) file in the repository should be [amended](#changelog-generation) to.
|
|
42
|
+
|
|
43
|
+
1. Please note the publishing method (see [below](#releasing-a-new-version)).
|
|
44
|
+
|
|
45
|
+
1. Determine strategy to [respond to problems post-deployment](#in-case-of-problems).
|
|
46
|
+
|
|
47
|
+
1. The release has been tested across macOS, Windows, and Linux.
|
|
48
|
+
|
|
49
|
+
1. All tests pass and your working directory is clean (we have pre-publish checks to catch this,
|
|
50
|
+
just-in-case).
|
|
51
|
+
|
|
52
|
+
1. You have completed [final testing before deployment](TESTING.md#final-testing-before-releasing).
|
|
53
|
+
|
|
54
|
+
1. The pre-publish [script](https://github.com/Automattic/vip-cli/blob/trunk/helpers/prepublishOnly.js) has been run. This script performs some confidence checks to avoid common mistakes.
|
|
55
|
+
|
|
56
|
+
1. Finally, release your changes as a [new minor or major NPM version](#releasing-a-new-version).
|
|
57
|
+
|
|
58
|
+
If you need to publish a security release, see [details below](#patching-old-releases).
|
|
59
|
+
|
|
60
|
+
### Changelog generation
|
|
61
|
+
|
|
62
|
+
Run the following to generate a changelog entry for CHANGELOG.md:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
export LAST_RELEASE_DATE=2021-08-25T13:40:00+02
|
|
66
|
+
gh pr list --search "is:merged sort:updated-desc closed:>$LAST_RELEASE_DATE" | sed -e 's/\s\+\S\+\tMERGED.*$//' -e 's/^/- #/'
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Releasing a new version
|
|
70
|
+
|
|
71
|
+
You can release either using GitHub Actions or locally.
|
|
72
|
+
|
|
73
|
+
### Publishing via GitHub Actions (preferred)
|
|
74
|
+
|
|
75
|
+
This is the preferred method for pushing out the latest release. The workflow runs a bunch of validations, generates a build, bump versions + tags, pushes out to npm, and bumps to the next dev version.
|
|
76
|
+
|
|
77
|
+
Please keep in mind internal guidelines before releasing.
|
|
78
|
+
|
|
79
|
+
To release, follow these steps:
|
|
80
|
+
|
|
81
|
+
1. Initiate the [release process here](https://github.com/Automattic/vip-cli/actions/workflows/npm-prepare-release.yml).
|
|
82
|
+
1. On the right-hand side, select "Run Workflow".
|
|
83
|
+
1. Pick your preferred version bump.
|
|
84
|
+
1. Click `Run Workflow`.
|
|
85
|
+
1. Wait for a pull request to appear. The pull request will update the version number and shall be assigned to you.
|
|
86
|
+
1. When ready, merge the pull request. This will lead to a new version to be [published on npmjs.com](https://www.npmjs.com/package/@automattic/vip).
|
|
87
|
+
1. Another pull request will be created to bump to a development version, also assigned to you. Merge it to finish the process.
|
|
88
|
+
|
|
89
|
+
#### Versioning Guidelines
|
|
90
|
+
|
|
91
|
+
- `patch`: for non-breaking changes/bugfixes and small updates.
|
|
92
|
+
- `minor`: for some new features, bug fixes, and other non-breaking changes.
|
|
93
|
+
- `major`: for breaking changes.
|
|
94
|
+
|
|
95
|
+
#### Note on NPM token
|
|
96
|
+
|
|
97
|
+
Publishing via the GitHub Action requires that the `NPM_TOKEN` be set correctly in GitHub Actions secrets. This should be an npm token generated for a bot user on [the npm @automattic org](https://www.npmjs.com/settings/automattic) that has publish access to this repo.
|
|
98
|
+
|
|
99
|
+
### Alternative methods of releasing
|
|
100
|
+
|
|
101
|
+
#### Publishing locally
|
|
102
|
+
|
|
103
|
+
To publish locally, follow these steps:
|
|
104
|
+
|
|
105
|
+
<summary><details>
|
|
106
|
+
|
|
107
|
+
1. Create a pull request that adds the next version's changelog into `trunk`. Use the Changelog
|
|
108
|
+
Generate Hint above to generate the changelog, and refer to previous releases to ensure that your
|
|
109
|
+
format matches.
|
|
110
|
+
1. Merge it after approval.
|
|
111
|
+
1. Make sure `trunk` branch is up-to-date: `git pull`.
|
|
112
|
+
1. Make sure to clean all of your repositories of extra files. Run a dangerous, destructive
|
|
113
|
+
command `git clean -xfd` to do so.
|
|
114
|
+
1. Run `npm install`.
|
|
115
|
+
1. Set the version (via `npm version minor` or `npm version major` or `npm version patch`)
|
|
116
|
+
1. For most regular releases, this will be `npm version minor`.
|
|
117
|
+
1. Push the tag to GitHub (`git push --tags`)
|
|
118
|
+
1. Push the trunk branch `git push`
|
|
119
|
+
1. Make sure you're part of the Automattic organization in npm
|
|
120
|
+
1. Publish the release to npm (`npm publish --access public`) the script will do some extra checks (
|
|
121
|
+
node version, branch, etc) to ensure everything is correct. If all looks good, the new version
|
|
122
|
+
will be published and you can proceed.
|
|
123
|
+
1. Edit [the release on GitHub](https://github.com/Automattic/vip-cli/releases) to include a description
|
|
124
|
+
of the changes and publish (this can just copy the details from the changelog).
|
|
125
|
+
|
|
126
|
+
Once released, it's worth running `npm i -g @automattic/vip` to install / upgrade the released version to make sure everything looks good.
|
|
127
|
+
|
|
128
|
+
</details></summary>
|
|
129
|
+
|
|
130
|
+
#### Test Releases
|
|
131
|
+
|
|
132
|
+
Sometimes, we want to release a version we can test before releasing it to the public. In order to that, we need to release it under a tag other than `latest`, usually `next`. By default, `npm` install from the `latest` tag, so if `@next` isn't specified explicitely in the installation command like `npm install @automattic/vip@next`, a user will not get this version.
|
|
133
|
+
|
|
134
|
+
In order to do that, please follow this:
|
|
135
|
+
|
|
136
|
+
<summary><details>
|
|
137
|
+
|
|
138
|
+
1. Manually change the version in `package.json` and `package-lock.json` to a dev version. Example: `1.4.0-dev1`
|
|
139
|
+
1. Run `npm publish --tag next` (When `--tag` is specified, we bypass the usual branch protection that doesn't allow you to publish form a brunch other than `trunk`).
|
|
140
|
+
|
|
141
|
+
You can repeat this with every new version until you're happy with your version and ready to a public release. We currently don't support multiple branches for multiple versions. When it's the case, this process needs to be done for every version in every branch.
|
|
142
|
+
|
|
143
|
+
</details></summary>
|
|
144
|
+
|
|
145
|
+
#### Patching Old Releases
|
|
146
|
+
|
|
147
|
+
There may be times when we need to push out a critical fix to the most recent release (or several past releases) such as for patching security issues or major bugs. This can be complicated by the fact that we may have some larger changes already merged into the `trunk` branch.
|
|
148
|
+
|
|
149
|
+
<summary><details>
|
|
150
|
+
|
|
151
|
+
For these cases:
|
|
152
|
+
|
|
153
|
+
1. `git checkout` to the tag of the previous release.
|
|
154
|
+
1. Apply the fix (either manually or by cherry-picking).
|
|
155
|
+
1. Follow the release steps outlined above (as a `patch` release).
|
|
156
|
+
|
|
157
|
+
Then, repeat for any additional versions that we need to patch.
|
|
158
|
+
|
|
159
|
+
</details></summary>
|
|
160
|
+
|
|
161
|
+
## In case of problems
|
|
162
|
+
|
|
163
|
+
TODO: How to revert to a good state in case of problems?
|