@automattic/vip 2.36.2-dev.0 → 2.36.2
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/dist/bin/vip-dev-env-purge.js +67 -0
- package/dist/bin/vip-dev-env.js +1 -1
- package/dist/bin/vip.js +5 -3
- package/dist/commands/export-sql.js +1 -1
- package/docs/ARCHITECTURE.md +95 -0
- package/{CHANGELOG.md → docs/CHANGELOG.md} +24 -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 +2693 -1975
- package/package.json +32 -32
- 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/docs/SETUP.md
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
# Setup
|
|
2
|
+
|
|
3
|
+
## Language & requirements
|
|
4
|
+
|
|
5
|
+
- Implemented in JavaScript and TypeScript.
|
|
6
|
+
- Requirements are:
|
|
7
|
+
- Node, see version in [package.json](https://github.com/Automattic/vip-cli/blob/trunk/package.json)
|
|
8
|
+
- A number of NPM packages are needed, those are listed in the same file.
|
|
9
|
+
- No special hardware requirements.
|
|
10
|
+
- Network access.
|
|
11
|
+
|
|
12
|
+
## Installation & setup instructions
|
|
13
|
+
|
|
14
|
+
### Installation for end-users
|
|
15
|
+
|
|
16
|
+
First, install the package:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install -g @automattic/vip
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Then, launch the command and follow the prompts:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
vip
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
If you need more information, check out our [VIP-CLI documentation](https://docs.wpvip.com/technical-references/vip-cli/).
|
|
29
|
+
|
|
30
|
+
### Installation for developers
|
|
31
|
+
|
|
32
|
+
The section below is intended for developers.
|
|
33
|
+
|
|
34
|
+
<summary><details>
|
|
35
|
+
|
|
36
|
+
#### Version manager
|
|
37
|
+
|
|
38
|
+
We recommend to use a version manager like [nvm](https://github.com/nvm-sh/nvm) or [nodenv](https://github.com/nodenv/nodenv) to automatically configure the version of Node required by this software package. The [.nvmrc](https://github.com/Automattic/vip-cli/blob/trunk/.nvmrc) file gives these tools the necessary hints for what version to use.
|
|
39
|
+
|
|
40
|
+
#### Install and setup of API
|
|
41
|
+
|
|
42
|
+
This software relies on an [API offered by WPVIP](ARCHITECTURE.md#communicating-with-wpvip-api). You may need to have a local instance of that set up for [local testing](TESTING.md#local-testing). Follow internal instructions to set it up locally.
|
|
43
|
+
|
|
44
|
+
#### Fetching & installing
|
|
45
|
+
|
|
46
|
+
This will fetch the package and install all dependencies:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
git clone git@github.com:Automattic/vip-cli.git && \
|
|
50
|
+
cd vip-cli && npm install
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
#### Building
|
|
54
|
+
|
|
55
|
+
This will build all TypeScript files so they can be executed:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
cd vip-cli && \
|
|
59
|
+
npm run build
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
</details></summary>
|
|
63
|
+
|
|
64
|
+
## Usage
|
|
65
|
+
|
|
66
|
+
The software runs as standalone CLI and relies on environmental variables for configuration and a few configuration files.
|
|
67
|
+
|
|
68
|
+
### Starting up locally
|
|
69
|
+
|
|
70
|
+
To start the software locally, run:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
vip
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
If you need more information, check out our [VIP-CLI documentation](https://docs.wpvip.com/technical-references/vip-cli/).
|
|
77
|
+
|
|
78
|
+
### Analytics
|
|
79
|
+
|
|
80
|
+
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`).
|
|
81
|
+
|
|
82
|
+
### Local application
|
|
83
|
+
|
|
84
|
+
#### Configuring access token
|
|
85
|
+
|
|
86
|
+
Install the software locally, run and follow the instructions to configure the access token.
|
|
87
|
+
|
|
88
|
+
### Environmental variables
|
|
89
|
+
|
|
90
|
+
#### Configuring environmental variables
|
|
91
|
+
|
|
92
|
+
Environmental variables are configured in the shell. Use normal shell commands to set them.
|
|
93
|
+
|
|
94
|
+
#### List of environmental variables
|
|
95
|
+
|
|
96
|
+
This application uses environmental variables for vital configuration information. Find a partial list below.
|
|
97
|
+
|
|
98
|
+
TODO: Update description of the variables.
|
|
99
|
+
|
|
100
|
+
- `API_HOST`: HTTP endpoint to use rather than the default. [For internal VIP use](TESTING.md#local-testing).
|
|
101
|
+
- `DEBUG API_HOST`:
|
|
102
|
+
- `DOCKER_CERT_PATH`:
|
|
103
|
+
- `DOCKER_CLIENT_TIMEOUT`:
|
|
104
|
+
- `DOCKER_HOST`:
|
|
105
|
+
- `DOCKER_TLS_VERIFY`:
|
|
106
|
+
- `DO_NOT_TRACK`: [To disable tracking](SETUP.md#analytics).
|
|
107
|
+
- `SOCKS_PROXY`:
|
|
108
|
+
- `HTTP_PROXY`:
|
|
109
|
+
- `NO_PROXY`:
|
|
110
|
+
- `VIP_PROXY`: [For internal VIP use](TESTING.md#local-testing).
|
|
111
|
+
- `VIP_USE_SYSTEM_PROXY`:
|
|
112
|
+
|
|
113
|
+
### Configuration files
|
|
114
|
+
|
|
115
|
+
TODO: List main configuration files and their purpose. How to update.
|
|
116
|
+
|
|
117
|
+
## Updating dependencies
|
|
118
|
+
|
|
119
|
+
### NPM packages
|
|
120
|
+
|
|
121
|
+
Dependencies generally should be updated by merging [pull requests from dependabot](https://github.com/Automattic/vip-cli/pulls/app%2Fdependabot). However, great care should be taken before merging as updating dependencies can cause fatal errors with the `vip-cli` application, or make it unstable or misbehave. There can also be effects to the release process. This can happen silently.
|
|
122
|
+
|
|
123
|
+
### Upgrading Node Version
|
|
124
|
+
|
|
125
|
+
To upgrade Node, follow these steps:
|
|
126
|
+
|
|
127
|
+
1. Update [.nvmrc](https://github.com/Automattic/vip-cli/blob/trunk/.nvmrc) to the new version and open a pull request.
|
|
128
|
+
1. Use the same pull request to update `engines.node` in [package.json](https://github.com/Automattic/vip-cli/blob/trunk/package.json).
|
|
129
|
+
1. Address any test failures.
|
|
130
|
+
1. Update the Node.js version locally and test before merging into the repository.
|
|
131
|
+
|
|
132
|
+
Upgrading Node should be considered high-risk.
|
|
133
|
+
|
|
134
|
+
### Before merging
|
|
135
|
+
|
|
136
|
+
Consider removing the dependency, if it is an NPM package. Can the functionality needed from the dependency be implemented directly into `vip-cli` or our own common libraries? If not, evaluate the following:
|
|
137
|
+
|
|
138
|
+
1. If the dependency is one of the [development dependencies](https://github.com/Automattic/vip-cli/blob/trunk/package.json) (`devDependencies`), and/or only used by one of those, the likelihood of customer-impacting failure is low.
|
|
139
|
+
1. Is the package used in the [release process](RELEASING.md#releasing-a-new-version)? If it is, evaluate if any failure is likely to be silent. If that seems not to be the case, the risk of customer-impacting failure is low.
|
|
140
|
+
|
|
141
|
+
#### Low risk dependencies
|
|
142
|
+
|
|
143
|
+
If the risk of merging is low, you can go a head and merge without doing anything further (given that all tests succeed).
|
|
144
|
+
|
|
145
|
+
#### Higher risk dependencies
|
|
146
|
+
|
|
147
|
+
For higher risk dependencies, the routes/utilities using the dependency [will have to be tested locally](TESTING.md) and the results verified. If the main application is using the dependency, you will have to [launch it locally](SETUP.md#starting-up-locally) and verify that it runs normally.
|
|
148
|
+
|
|
149
|
+
### After merging
|
|
150
|
+
|
|
151
|
+
No special considerations.
|
package/docs/TESTING.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# Testing
|
|
2
|
+
|
|
3
|
+
Testing is an integral part of creating new features and maintaining the software.
|
|
4
|
+
|
|
5
|
+
## Automated testing
|
|
6
|
+
|
|
7
|
+
A [few actions](https://github.com/Automattic/vip-cli/blob/trunk/.github/workflows/) are automatically run via Github Actions when a pull request is created or updated.
|
|
8
|
+
|
|
9
|
+
### Linting
|
|
10
|
+
|
|
11
|
+
We [run](https://github.com/Automattic/vip-cli/blob/trunk/.github/workflows/ci.yml) the following checks:
|
|
12
|
+
|
|
13
|
+
- linting
|
|
14
|
+
- format checking
|
|
15
|
+
- type checks
|
|
16
|
+
|
|
17
|
+
### Dependency checks
|
|
18
|
+
|
|
19
|
+
We [use](https://github.com/Automattic/vip-cli/blob/trunk/.github/workflows/ci.yml) the [dependaban action](https://github.com/Automattic/vip-actions/tree/trunk/dependaban) from [Automattic/vip-actions](https://github.com/Automattic/vip-actions/) to verify that no dependencies have install scripts.
|
|
20
|
+
|
|
21
|
+
### Unit tests
|
|
22
|
+
|
|
23
|
+
Unit tests in [\_\_tests\_\_](https://github.com/Automattic/vip-cli/tree/trunk/__tests__) are [run](https://github.com/Automattic/vip-cli/blob/trunk/.github/workflows/ci.yml). They are powered by [Jest](https://facebook.github.io/jest/) and report any failures, along with test coverage.
|
|
24
|
+
|
|
25
|
+
#### Adding new unit tests
|
|
26
|
+
|
|
27
|
+
Tests should be written for any major features or security sensitive functionality, as a minimum. Writing tests for new or updated [utility functions](https://github.com/Automattic/vip-cli/blob/trunk/src/lib/utils.ts) is recommended.
|
|
28
|
+
|
|
29
|
+
### E2E tests
|
|
30
|
+
|
|
31
|
+
E2E test are [run](https://github.com/Automattic/vip-cli/blob/trunk/.github/workflows/devenv-e2e.yml). They can be found at [\_\_tests\_\_/devenv-e2e](https://github.com/Automattic/vip-cli/tree/trunk/__tests__/devenv-e2e).
|
|
32
|
+
|
|
33
|
+
### Windows tests
|
|
34
|
+
|
|
35
|
+
We run the above unit and E2E tests [on Windows as well](https://github.com/Automattic/vip-cli/blob/trunk/.github./workflows/windows-tests.yml).
|
|
36
|
+
|
|
37
|
+
### CodeQL analysis
|
|
38
|
+
|
|
39
|
+
CodeQL analysis is [started automatically](https://github.com/Automattic/vip-cli/blob/trunk/.github/workflows/codeql-analysis.yml).
|
|
40
|
+
|
|
41
|
+
## Manual testing
|
|
42
|
+
|
|
43
|
+
### Running unit tests locally
|
|
44
|
+
|
|
45
|
+
[Install and set up the environment](SETUP.md#installation--setup-instructions), and then run:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npm run test
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Local testing
|
|
52
|
+
|
|
53
|
+
To test against a local instance of the WPVIP API, you can use the `API_HOST` environment variable. Unset the `VIP_PROXY` variable as well.
|
|
54
|
+
|
|
55
|
+
Examples:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
VIP_PROXY="" API_HOST=http://localhost:4000 node ./dist/bin/vip
|
|
59
|
+
|
|
60
|
+
VIP_PROXY="" API_HOST=http://localhost:4000 node ./dist/bin/vip app
|
|
61
|
+
|
|
62
|
+
VIP_PROXY="" API_HOST=http://localhost:4000 node ./dist/bin/vip -- wp option get home
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Final testing before releasing
|
|
66
|
+
|
|
67
|
+
TODO: How should final testing before releasing be done?
|