@automattic/vip 2.31.1-dev2 → 2.31.1-dev3
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/CONTRIBUTING.md +3 -6
- package/dist/bin/vip-dev-env-start.js +4 -1
- package/dist/bin/vip-export-sql.js +3 -2
- package/dist/commands/backup-db.js +29 -25
- package/dist/commands/export-sql.js +1 -2
- package/helpers/prepublishOnly.js +6 -4
- package/npm-shrinkwrap.json +279 -911
- package/package.json +3 -3
package/CONTRIBUTING.md
CHANGED
|
@@ -93,7 +93,7 @@ Changelogs allow customers to keep up with all the changes happening across our
|
|
|
93
93
|
|
|
94
94
|
### Pre-publish Checks
|
|
95
95
|
|
|
96
|
-
We use [
|
|
96
|
+
We use a custom pre-publish [script](https://github.com/Automattic/vip/blob/trunk/hellpers/prepublishOnly.js) that performs some confidence checks to avoid common mistakes.
|
|
97
97
|
|
|
98
98
|
Further checks can be added to this flow as needed.
|
|
99
99
|
|
|
@@ -130,7 +130,7 @@ Then, let's publish:
|
|
|
130
130
|
1. Push the tag to GitHub (`git push --tags`)
|
|
131
131
|
1. Push the trunk branch `git push`
|
|
132
132
|
1. Make sure you're part of the Automattic organization in npm
|
|
133
|
-
1. Publish the release to npm (`npm
|
|
133
|
+
1. Publish the release to npm (`npm publish --access public`) the script will do some extra checks (node version, branch, etc) to ensure everything is correct. If all looks good, the new version will be published and you can proceed.
|
|
134
134
|
1. Edit [the release on GitHub](https://github.com/Automattic/vip/releases) to include a description of the changes and publish (this can just copy the details from the changelog).
|
|
135
135
|
1. Push `trunk` changes (mostly the version bump) to `develop` (`git checkout develop && git merge trunk` )
|
|
136
136
|
|
|
@@ -143,10 +143,7 @@ Sometimes, we want to release a version we can test before releasing it to the p
|
|
|
143
143
|
In order to do that, please follow this:
|
|
144
144
|
|
|
145
145
|
1. Manually change the version in `package.json` and `package-lock.json` to a dev version. Example: `1.4.0-dev1`
|
|
146
|
-
|
|
147
|
-
3. Change the `publishTag` to `next` and `gitTag` to `false` (publish-please will expect the latest commit to have a git tag, but we don't want it in this case)
|
|
148
|
-
4. Commit your changes to `trunk`
|
|
149
|
-
5. Run `npm run publish-please`
|
|
146
|
+
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`).
|
|
150
147
|
|
|
151
148
|
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.
|
|
152
149
|
|
|
@@ -30,8 +30,11 @@ const dockerWindowsPathCmd = 'wsl -d docker-desktop bash -c "sysctl -w vm.max_ma
|
|
|
30
30
|
const examples = [{
|
|
31
31
|
usage: `${_devEnvironment.DEV_ENVIRONMENT_FULL_COMMAND} start`,
|
|
32
32
|
description: 'Starts a local dev environment'
|
|
33
|
+
}, {
|
|
34
|
+
usage: `${_devEnvironment.DEV_ENVIRONMENT_FULL_COMMAND} start --vscode`,
|
|
35
|
+
description: 'Start a local environment and generate a Workspace file for developing in Visual Studio Code'
|
|
33
36
|
}];
|
|
34
|
-
(0, _command.default)().option('slug', 'Custom name of the dev environment').option('skip-rebuild', 'Only start stopped services').option(['w', 'skip-wp-versions-check'], 'Skip prompt to update WordPress version if not on latest').option('vscode', 'Generate a Visual Studio Code Workspace file
|
|
37
|
+
(0, _command.default)().option('slug', 'Custom name of the dev environment').option('skip-rebuild', 'Only start stopped services').option(['w', 'skip-wp-versions-check'], 'Skip prompt to update WordPress version if not on latest').option('vscode', 'Generate a Visual Studio Code Workspace file').examples(examples).argv(process.argv, async (arg, opt) => {
|
|
35
38
|
const slug = await (0, _devEnvironmentCli.getEnvironmentName)(opt);
|
|
36
39
|
const lando = await (0, _devEnvironmentLando.bootstrapLando)();
|
|
37
40
|
await (0, _devEnvironmentCli.validateDependencies)(lando, slug);
|
|
@@ -46,7 +46,7 @@ const appQuery = `
|
|
|
46
46
|
module: 'export-sql',
|
|
47
47
|
requiredArgs: 0,
|
|
48
48
|
usage: 'vip export sql'
|
|
49
|
-
}).option('output', 'Specify the location where you want to save the export file').option('generate-backup', '
|
|
49
|
+
}).option('output', 'Specify the location where you want to save the export file').option('generate-backup', 'Exports a freshly created database backup instead of using the latest existing one').examples(examples).argv(process.argv, async (arg, {
|
|
50
50
|
app,
|
|
51
51
|
env,
|
|
52
52
|
output,
|
|
@@ -54,7 +54,8 @@ const appQuery = `
|
|
|
54
54
|
}) => {
|
|
55
55
|
const trackerFn = (0, _tracker.makeCommandTracker)('export_sql', {
|
|
56
56
|
app: app.id,
|
|
57
|
-
env: env.uniqueLabel
|
|
57
|
+
env: env.uniqueLabel,
|
|
58
|
+
generate_backup: generateBackup
|
|
58
59
|
});
|
|
59
60
|
await trackerFn('execute');
|
|
60
61
|
const exportCommand = new _exportSql.ExportSQLCommand(app, env, {
|
|
@@ -34,6 +34,8 @@ const CREATE_DB_BACKUP_JOB_MUTATION = (0, _graphqlTag.default)`
|
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
`;
|
|
37
|
+
|
|
38
|
+
// TODO: Replace this with the codegen
|
|
37
39
|
exports.CREATE_DB_BACKUP_JOB_MUTATION = CREATE_DB_BACKUP_JOB_MUTATION;
|
|
38
40
|
const DB_BACKUP_JOB_STATUS_QUERY = (0, _graphqlTag.default)`
|
|
39
41
|
query AppBackupJobStatus($appId: Int!, $envId: Int!) {
|
|
@@ -104,7 +106,7 @@ class BackupDBCommand {
|
|
|
104
106
|
PREPARE: 'prepare',
|
|
105
107
|
GENERATE: 'generate'
|
|
106
108
|
};
|
|
107
|
-
constructor(app, env, trackerFn = () => {}) {
|
|
109
|
+
constructor(app, env, trackerFn = async () => {}) {
|
|
108
110
|
this.app = app;
|
|
109
111
|
this.env = env;
|
|
110
112
|
this.progressTracker = new _progress.ProgressTracker([{
|
|
@@ -117,11 +119,13 @@ class BackupDBCommand {
|
|
|
117
119
|
this.track = trackerFn;
|
|
118
120
|
}
|
|
119
121
|
log(msg) {
|
|
120
|
-
if (this.silent)
|
|
122
|
+
if (this.silent) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
121
125
|
console.log(msg);
|
|
122
126
|
}
|
|
123
127
|
isDone(job) {
|
|
124
|
-
return !job.inProgressLock;
|
|
128
|
+
return !(job !== null && job !== void 0 && job.inProgressLock);
|
|
125
129
|
}
|
|
126
130
|
|
|
127
131
|
/**
|
|
@@ -134,54 +138,53 @@ class BackupDBCommand {
|
|
|
134
138
|
this.progressTracker.stopPrinting();
|
|
135
139
|
}
|
|
136
140
|
async loadBackupJob() {
|
|
137
|
-
var _this$job, _this$job$metadata$
|
|
141
|
+
var _this$job$metadata$fi, _this$job$metadata$fi2, _this$job$progress;
|
|
138
142
|
this.job = await getBackupJob(this.app.id, this.env.id);
|
|
139
|
-
this.backupName = (
|
|
140
|
-
this.jobStatus = (_this$
|
|
141
|
-
if (
|
|
142
|
-
this.jobAge = (new Date() - new Date(this.job.completedAt)) / 1000 / 60;
|
|
143
|
+
this.backupName = (_this$job$metadata$fi = (_this$job$metadata$fi2 = this.job.metadata.find(meta => meta.name === 'backupName')) === null || _this$job$metadata$fi2 === void 0 ? void 0 : _this$job$metadata$fi2.value) !== null && _this$job$metadata$fi !== void 0 ? _this$job$metadata$fi : 'Unknown';
|
|
144
|
+
this.jobStatus = (_this$job$progress = this.job.progress) === null || _this$job$progress === void 0 ? void 0 : _this$job$progress.status;
|
|
145
|
+
if (this.job.completedAt) {
|
|
146
|
+
this.jobAge = (new Date().getTime() - new Date(this.job.completedAt).getTime()) / 1000 / 60;
|
|
143
147
|
} else {
|
|
144
148
|
this.jobAge = undefined;
|
|
145
149
|
}
|
|
146
150
|
return this.job;
|
|
147
151
|
}
|
|
148
152
|
async run(silent = false) {
|
|
149
|
-
var _this$
|
|
153
|
+
var _this$job;
|
|
150
154
|
this.silent = silent;
|
|
151
|
-
const readMoreMessage = '\nLearn more about the database backup limitations here: https://docs.wpvip.com/technical-references/vip-dashboard/backups/ \n';
|
|
152
155
|
let noticeMessage = `\n${_chalk.default.yellow('NOTICE: ')}`;
|
|
153
|
-
noticeMessage += '
|
|
154
|
-
noticeMessage +=
|
|
156
|
+
noticeMessage += 'If a recent database backup does not exist, a new one will be generated for this environment. ';
|
|
157
|
+
noticeMessage += 'Learn more about this: https://docs.wpvip.com/technical-references/vip-dashboard/backups/#2-download-a-full-database-backup \n';
|
|
155
158
|
this.log(noticeMessage);
|
|
156
159
|
await this.loadBackupJob();
|
|
157
|
-
if ((_this$
|
|
160
|
+
if ((_this$job = this.job) !== null && _this$job !== void 0 && _this$job.inProgressLock) {
|
|
158
161
|
this.log('Database backup already in progress...');
|
|
159
162
|
} else {
|
|
160
163
|
try {
|
|
161
|
-
this.log('
|
|
164
|
+
this.log('Generating a new database backup...');
|
|
162
165
|
this.progressTracker.stepRunning(this.steps.PREPARE);
|
|
163
166
|
this.progressTracker.startPrinting();
|
|
164
167
|
await createBackupJob(this.app.id, this.env.id);
|
|
165
|
-
} catch (
|
|
166
|
-
|
|
168
|
+
} catch (stepErr) {
|
|
169
|
+
const err = stepErr;
|
|
167
170
|
this.progressTracker.stepFailed(this.steps.PREPARE);
|
|
168
171
|
this.stopProgressTracker();
|
|
169
|
-
if (
|
|
172
|
+
if (err.message.includes('Database backups limit reached')) {
|
|
170
173
|
await this.track('error', {
|
|
171
174
|
error_type: 'rate_limit_exceeded',
|
|
172
175
|
error_message: `Couldn't create a new database backup job: ${err === null || err === void 0 ? void 0 : err.message}`,
|
|
173
|
-
stack: err
|
|
176
|
+
stack: err.stack
|
|
174
177
|
});
|
|
175
|
-
let errMessage = err.message.replace('Database backups limit reached', '
|
|
176
|
-
errMessage = errMessage.replace('Retry after', '\
|
|
177
|
-
errMessage += `\
|
|
178
|
-
errMessage +=
|
|
178
|
+
let errMessage = err.message.replace('Database backups limit reached', 'A new database backup was not generated because a recently generated backup already exists.');
|
|
179
|
+
errMessage = errMessage.replace('Retry after', '\nIf you would like to run the same command, you can retry on or after:');
|
|
180
|
+
errMessage += `\nAlternatively, you can export the latest existing database backup by running: ${_chalk.default.green('vip @app.env export sql')}, right away.`;
|
|
181
|
+
errMessage += '\nLearn more about limitations around generating database backups: https://docs.wpvip.com/technical-references/vip-dashboard/backups/#0-limitations \n';
|
|
179
182
|
exit.withError(errMessage);
|
|
180
183
|
}
|
|
181
184
|
await this.track('error', {
|
|
182
185
|
error_type: 'db_backup_job_creation_failed',
|
|
183
186
|
error_message: `Database Backup job creation failed: ${err === null || err === void 0 ? void 0 : err.message}`,
|
|
184
|
-
stack: err
|
|
187
|
+
stack: err.stack
|
|
185
188
|
});
|
|
186
189
|
exit.withError(`Couldn't create a new database backup job: ${err === null || err === void 0 ? void 0 : err.message}`);
|
|
187
190
|
}
|
|
@@ -190,7 +193,8 @@ class BackupDBCommand {
|
|
|
190
193
|
this.progressTracker.stepRunning(this.steps.GENERATE);
|
|
191
194
|
try {
|
|
192
195
|
await (0, _utils.pollUntil)(this.loadBackupJob.bind(this), DB_BACKUP_PROGRESS_POLL_INTERVAL, this.isDone.bind(this));
|
|
193
|
-
} catch (
|
|
196
|
+
} catch (e) {
|
|
197
|
+
const err = e;
|
|
194
198
|
this.progressTracker.stepFailed(this.steps.GENERATE);
|
|
195
199
|
this.stopProgressTracker();
|
|
196
200
|
await this.track('error', {
|
|
@@ -206,7 +210,7 @@ class BackupDBCommand {
|
|
|
206
210
|
if (this.jobStatus !== 'success') {
|
|
207
211
|
exit.withError('Failed to create a new database backup');
|
|
208
212
|
} else {
|
|
209
|
-
this.log(
|
|
213
|
+
this.log('New database backup created');
|
|
210
214
|
}
|
|
211
215
|
}
|
|
212
216
|
}
|
|
@@ -186,7 +186,6 @@ async function createExportJob(appId, envId, backupId) {
|
|
|
186
186
|
*/
|
|
187
187
|
class ExportSQLCommand {
|
|
188
188
|
steps = {
|
|
189
|
-
GENERATE: 'generate',
|
|
190
189
|
PREPARE: 'prepare',
|
|
191
190
|
CREATE: 'create',
|
|
192
191
|
DOWNLOAD_LINK: 'downloadLink',
|
|
@@ -207,7 +206,7 @@ class ExportSQLCommand {
|
|
|
207
206
|
this.generateBackup = options.generateBackup || false;
|
|
208
207
|
this.progressTracker = new _progress.ProgressTracker([{
|
|
209
208
|
id: this.steps.PREPARE,
|
|
210
|
-
name: 'Preparing for backup
|
|
209
|
+
name: 'Preparing for backup download'
|
|
211
210
|
}, {
|
|
212
211
|
id: this.steps.CREATE,
|
|
213
212
|
name: 'Creating backup copy'
|
|
@@ -6,11 +6,13 @@ const packageJSON = require( '../package.json' );
|
|
|
6
6
|
|
|
7
7
|
const config = {
|
|
8
8
|
gitAllowDirty: true,
|
|
9
|
-
|
|
9
|
+
gitEnforceBranch: 'trunk',
|
|
10
10
|
nodeEnforceVersion: packageJSON.engines.node,
|
|
11
11
|
testBeforePublish: true,
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
+
const releaseTag = process.env.npm_config_tag ?? 'latest';
|
|
15
|
+
|
|
14
16
|
( async () => {
|
|
15
17
|
try {
|
|
16
18
|
if ( ! config.gitAllowDirty ) {
|
|
@@ -21,12 +23,12 @@ const config = {
|
|
|
21
23
|
}
|
|
22
24
|
}
|
|
23
25
|
|
|
24
|
-
if ( config.
|
|
26
|
+
if ( config.gitEnforceBranch && releaseTag !== 'next' ) {
|
|
25
27
|
const currentBranch = await execAsync( 'git branch --show-current' );
|
|
26
28
|
|
|
27
|
-
if ( currentBranch.trim() !== config.
|
|
29
|
+
if ( currentBranch.trim() !== config.gitEnforceBranch ) {
|
|
28
30
|
return bail(
|
|
29
|
-
`Git branch is not ${ config.
|
|
31
|
+
`Git branch is not ${ config.gitEnforceBranch }. Please switch to ${ config.gitEnforceBranch } before publishing.`
|
|
30
32
|
);
|
|
31
33
|
}
|
|
32
34
|
}
|