@automattic/vip 2.32.2 → 2.32.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/CHANGELOG.md +17 -0
- package/assets/dev-env.lando.template.yml.ejs +10 -2
- package/dist/bin/vip-dev-env-exec.js +1 -7
- package/dist/bin/vip-dev-env-shell.js +0 -4
- package/dist/bin/vip-dev-env-start.js +1 -1
- package/dist/bin/vip-dev-env-sync-sql.js +8 -6
- package/dist/bin/vip-dev-env-update.js +1 -2
- package/dist/bin/vip-import-sql.js +2 -2
- package/dist/bin/vip-logout.js +23 -0
- package/dist/bin/vip-slowlogs.js +192 -0
- package/dist/bin/vip-validate-preflight.js +8 -10
- package/dist/bin/vip-whoami.js +1 -2
- package/dist/bin/vip.js +1 -5
- package/dist/commands/backup-db.js +8 -9
- package/dist/lib/api/app.js +2 -2
- package/dist/lib/api/cache-purge.js +2 -2
- package/dist/lib/api/http.js +2 -3
- package/dist/lib/app-logs/app-logs.js +2 -2
- package/dist/lib/app-slowlogs/app-slowlogs.js +63 -0
- package/dist/lib/app-slowlogs/types.js +1 -0
- package/dist/lib/cli/apiConfig.js +1 -1
- package/dist/lib/client-file-uploader.js +19 -4
- package/dist/lib/config/software.js +4 -4
- package/dist/lib/constants/dev-environment.js +7 -3
- package/dist/lib/dev-environment/dev-environment-cli.js +110 -117
- package/dist/lib/dev-environment/dev-environment-configuration-file.js +34 -36
- package/dist/lib/dev-environment/dev-environment-core.js +36 -19
- package/dist/lib/dev-environment/dev-environment-lando.js +80 -72
- package/dist/lib/dev-environment/docker-utils.js +8 -9
- package/dist/lib/envvar/api-get-all.js +2 -2
- package/dist/lib/envvar/api-list.js +3 -6
- package/dist/lib/envvar/input.js +1 -2
- package/dist/lib/site-import/status.js +5 -5
- package/dist/lib/token.js +3 -6
- package/dist/lib/validations/is-multi-site-sql-dump.js +0 -1
- package/dist/lib/validations/is-multi-site.js +14 -12
- package/dist/lib/validations/is-multisite-domain-mapped.js +5 -10
- package/dist/lib/validations/line-by-line.js +9 -13
- package/dist/lib/validations/site-type.js +2 -7
- package/dist/lib/validations/sql.js +14 -19
- package/dist/lib/validations/utils.js +1 -1
- package/npm-shrinkwrap.json +913 -926
- package/package.json +12 -9
- package/tsconfig.json +3 -1
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.LIMIT_MAX = void 0;
|
|
7
|
+
exports.getRecentSlowlogs = getRecentSlowlogs;
|
|
8
|
+
var _graphqlTag = _interopRequireDefault(require("graphql-tag"));
|
|
9
|
+
var _api = _interopRequireDefault(require("../../lib/api"));
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
// @format
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* External dependencies
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Internal dependencies
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
const LIMIT_MAX = 5000;
|
|
22
|
+
exports.LIMIT_MAX = LIMIT_MAX;
|
|
23
|
+
const QUERY_ENVIRONMENT_SLOWLOGS = (0, _graphqlTag.default)`
|
|
24
|
+
query GetAppLogs($appId: Int, $envId: Int, $limit: Int, $after: String) {
|
|
25
|
+
app(id: $appId) {
|
|
26
|
+
environments(id: $envId) {
|
|
27
|
+
id
|
|
28
|
+
slowlogs(limit: $limit, after: $after) {
|
|
29
|
+
nodes {
|
|
30
|
+
timestamp
|
|
31
|
+
rowsSent
|
|
32
|
+
rowsExamined
|
|
33
|
+
queryTime
|
|
34
|
+
requestUri
|
|
35
|
+
query
|
|
36
|
+
}
|
|
37
|
+
nextCursor
|
|
38
|
+
pollingDelaySeconds
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
`;
|
|
44
|
+
async function getRecentSlowlogs(appId, envId, limit, after) {
|
|
45
|
+
var _response$data$app;
|
|
46
|
+
const api = await (0, _api.default)({
|
|
47
|
+
exitOnError: false
|
|
48
|
+
});
|
|
49
|
+
const response = await api.query({
|
|
50
|
+
query: QUERY_ENVIRONMENT_SLOWLOGS,
|
|
51
|
+
variables: {
|
|
52
|
+
appId,
|
|
53
|
+
envId,
|
|
54
|
+
limit,
|
|
55
|
+
after
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
const slowlogs = (_response$data$app = response.data.app) === null || _response$data$app === void 0 || (_response$data$app = _response$data$app.environments) === null || _response$data$app === void 0 || (_response$data$app = _response$data$app[0]) === null || _response$data$app === void 0 ? void 0 : _response$data$app.slowlogs;
|
|
59
|
+
if (!(slowlogs !== null && slowlogs !== void 0 && slowlogs.nodes)) {
|
|
60
|
+
throw new Error('Unable to query slowlogs');
|
|
61
|
+
}
|
|
62
|
+
return slowlogs;
|
|
63
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -34,7 +34,7 @@ async function checkFeatureEnabled(featureName, exitOnFalse = false) {
|
|
|
34
34
|
try {
|
|
35
35
|
var _res$data$me;
|
|
36
36
|
const res = await featureFlags.get();
|
|
37
|
-
if ((res === null || res === void 0
|
|
37
|
+
if ((res === null || res === void 0 || (_res$data$me = res.data.me) === null || _res$data$me === void 0 ? void 0 : _res$data$me.isVIP) !== undefined) {
|
|
38
38
|
isVIP = res.data.me.isVIP;
|
|
39
39
|
} else {
|
|
40
40
|
isVIP = false;
|
|
@@ -39,6 +39,18 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
39
39
|
* Internal dependencies
|
|
40
40
|
*/
|
|
41
41
|
|
|
42
|
+
// Need to use CommonJS imports here as the `fetch-retry` typedefs are messed up and throwing TypeJS errors when using `import`
|
|
43
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
44
|
+
const fetchWithRetry =
|
|
45
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
46
|
+
require('fetch-retry')(_nodeFetch.default, {
|
|
47
|
+
// Set default retry options
|
|
48
|
+
retries: 3,
|
|
49
|
+
retryDelay: (attempt, error, response) => {
|
|
50
|
+
return Math.pow(2, attempt) * 1000; // 1000, 2000, 4000
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
|
|
42
54
|
const debug = (0, _debug.default)('vip:lib/client-file-uploader');
|
|
43
55
|
|
|
44
56
|
// Files smaller than COMPRESS_THRESHOLD will not be compressed before upload
|
|
@@ -66,6 +78,8 @@ const getFileMD5Hash = async fileName => {
|
|
|
66
78
|
return dst.digest().toString('hex');
|
|
67
79
|
} catch (err) {
|
|
68
80
|
throw new Error(`could not generate file hash: ${err.message}`);
|
|
81
|
+
} finally {
|
|
82
|
+
src.close();
|
|
69
83
|
}
|
|
70
84
|
};
|
|
71
85
|
exports.getFileMD5Hash = getFileMD5Hash;
|
|
@@ -197,7 +211,7 @@ async function uploadUsingPutObject({
|
|
|
197
211
|
progressCallback(percentage);
|
|
198
212
|
}
|
|
199
213
|
});
|
|
200
|
-
const response = await (
|
|
214
|
+
const response = await fetchWithRetry(presignedRequest.url, {
|
|
201
215
|
...fetchOptions,
|
|
202
216
|
body: fileContent ? fileContent : (0, _fs.createReadStream)(fileName).pipe(progressPassThrough)
|
|
203
217
|
});
|
|
@@ -247,7 +261,7 @@ async function uploadUsingMultipart({
|
|
|
247
261
|
basename,
|
|
248
262
|
action: 'CreateMultipartUpload'
|
|
249
263
|
});
|
|
250
|
-
const multipartUploadResponse = await (
|
|
264
|
+
const multipartUploadResponse = await fetchWithRetry(presignedCreateMultipartUpload.url, presignedCreateMultipartUpload.options);
|
|
251
265
|
const multipartUploadResult = await multipartUploadResponse.text();
|
|
252
266
|
|
|
253
267
|
// TODO is any hardening needed here?
|
|
@@ -343,6 +357,7 @@ async function detectCompressedMimeType(fileName) {
|
|
|
343
357
|
buffer
|
|
344
358
|
} = await file.read(Buffer.alloc(4), 0, 4, 0);
|
|
345
359
|
const fileHeader = buffer.toString('hex');
|
|
360
|
+
await file.close();
|
|
346
361
|
if (ZIP_MAGIC_NUMBER === fileHeader.slice(0, ZIP_MAGIC_NUMBER.length)) {
|
|
347
362
|
return 'application/zip';
|
|
348
363
|
}
|
|
@@ -476,7 +491,7 @@ async function uploadPart({
|
|
|
476
491
|
start,
|
|
477
492
|
end
|
|
478
493
|
}).pipe(progressPassThrough);
|
|
479
|
-
const fetchResponse = await (
|
|
494
|
+
const fetchResponse = await fetchWithRetry(partUploadRequestData.url, fetchOptions);
|
|
480
495
|
if (fetchResponse.status === 200) {
|
|
481
496
|
const responseHeaders = fetchResponse.headers.raw();
|
|
482
497
|
const [etag] = responseHeaders.etag;
|
|
@@ -524,7 +539,7 @@ async function completeMultipartUpload({
|
|
|
524
539
|
uploadId,
|
|
525
540
|
etagResults
|
|
526
541
|
});
|
|
527
|
-
const completeMultipartUploadResponse = await (
|
|
542
|
+
const completeMultipartUploadResponse = await fetchWithRetry(completeMultipartUploadRequestData.url, completeMultipartUploadRequestData.options);
|
|
528
543
|
if (completeMultipartUploadResponse.status !== 200) {
|
|
529
544
|
throw await completeMultipartUploadResponse.text();
|
|
530
545
|
}
|
|
@@ -264,7 +264,7 @@ const triggerUpdate = async variables => {
|
|
|
264
264
|
};
|
|
265
265
|
exports.triggerUpdate = triggerUpdate;
|
|
266
266
|
const _getLatestJob = async (appId, envId) => {
|
|
267
|
-
var _result$data$app
|
|
267
|
+
var _result$data$app;
|
|
268
268
|
const api = await (0, _api.default)();
|
|
269
269
|
const result = await api.query({
|
|
270
270
|
query: updateJobQuery,
|
|
@@ -274,7 +274,7 @@ const _getLatestJob = async (appId, envId) => {
|
|
|
274
274
|
},
|
|
275
275
|
fetchPolicy: 'network-only'
|
|
276
276
|
});
|
|
277
|
-
const jobs = (
|
|
277
|
+
const jobs = ((_result$data$app = result.data.app) === null || _result$data$app === void 0 || (_result$data$app = _result$data$app.environments) === null || _result$data$app === void 0 || (_result$data$app = _result$data$app[0]) === null || _result$data$app === void 0 ? void 0 : _result$data$app.jobs) ?? [];
|
|
278
278
|
if (jobs.length) {
|
|
279
279
|
return jobs.reduce((prev, current) => ((prev === null || prev === void 0 ? void 0 : prev.createdAt) || '') > ((current === null || current === void 0 ? void 0 : current.createdAt) || '') ? prev : current);
|
|
280
280
|
}
|
|
@@ -291,7 +291,7 @@ const _getCompletedJob = async (appId, envId) => {
|
|
|
291
291
|
return _getCompletedJob(appId, envId);
|
|
292
292
|
};
|
|
293
293
|
const getUpdateResult = async (appId, envId) => {
|
|
294
|
-
var _completedJob$progres, _completedJob$progres2
|
|
294
|
+
var _completedJob$progres, _completedJob$progres2;
|
|
295
295
|
debug('Getting update result', {
|
|
296
296
|
appId,
|
|
297
297
|
envId
|
|
@@ -303,7 +303,7 @@ const getUpdateResult = async (appId, envId) => {
|
|
|
303
303
|
ok: true
|
|
304
304
|
};
|
|
305
305
|
}
|
|
306
|
-
const failedStep = (_completedJob$progres2 = completedJob.progress) === null || _completedJob$progres2 === void 0
|
|
306
|
+
const failedStep = (_completedJob$progres2 = completedJob.progress) === null || _completedJob$progres2 === void 0 || (_completedJob$progres2 = _completedJob$progres2.steps) === null || _completedJob$progres2 === void 0 ? void 0 : _completedJob$progres2.find(step => (step === null || step === void 0 ? void 0 : step.status) === 'failed');
|
|
307
307
|
const error = failedStep ? `Failed during step: ${failedStep.name}` : 'Software update failed';
|
|
308
308
|
return {
|
|
309
309
|
ok: false,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.DEV_ENVIRONMENT_WORDPRESS_VERSION_TTL = exports.DEV_ENVIRONMENT_WORDPRESS_VERSIONS_URI = exports.DEV_ENVIRONMENT_WORDPRESS_CACHE_KEY = exports.DEV_ENVIRONMENT_SUBCOMMAND = exports.DEV_ENVIRONMENT_RAW_GITHUB_HOST = exports.DEV_ENVIRONMENT_PROMPT_INTRO = exports.DEV_ENVIRONMENT_PHP_VERSIONS = exports.DEV_ENVIRONMENT_NOT_FOUND = exports.DEV_ENVIRONMENT_FULL_COMMAND = exports.DEV_ENVIRONMENT_DEFAULTS = exports.DEV_ENVIRONMENT_COMPONENTS = void 0;
|
|
6
|
+
exports.DEV_ENVIRONMENT_WORDPRESS_VERSION_TTL = exports.DEV_ENVIRONMENT_WORDPRESS_VERSIONS_URI = exports.DEV_ENVIRONMENT_WORDPRESS_CACHE_KEY = exports.DEV_ENVIRONMENT_VERSION = exports.DEV_ENVIRONMENT_SUBCOMMAND = exports.DEV_ENVIRONMENT_RAW_GITHUB_HOST = exports.DEV_ENVIRONMENT_PROMPT_INTRO = exports.DEV_ENVIRONMENT_PHP_VERSIONS = exports.DEV_ENVIRONMENT_NOT_FOUND = exports.DEV_ENVIRONMENT_FULL_COMMAND = exports.DEV_ENVIRONMENT_DEFAULTS = exports.DEV_ENVIRONMENT_COMPONENTS_WITH_WP = exports.DEV_ENVIRONMENT_COMPONENTS = void 0;
|
|
7
7
|
const DEV_ENVIRONMENT_SUBCOMMAND = 'dev-env';
|
|
8
8
|
exports.DEV_ENVIRONMENT_SUBCOMMAND = DEV_ENVIRONMENT_SUBCOMMAND;
|
|
9
9
|
const DEV_ENVIRONMENT_FULL_COMMAND = `vip ${DEV_ENVIRONMENT_SUBCOMMAND}`;
|
|
@@ -18,8 +18,10 @@ const DEV_ENVIRONMENT_PROMPT_INTRO = 'This is a wizard to help you set up your l
|
|
|
18
18
|
exports.DEV_ENVIRONMENT_PROMPT_INTRO = DEV_ENVIRONMENT_PROMPT_INTRO;
|
|
19
19
|
const DEV_ENVIRONMENT_NOT_FOUND = 'Environment not found.';
|
|
20
20
|
exports.DEV_ENVIRONMENT_NOT_FOUND = DEV_ENVIRONMENT_NOT_FOUND;
|
|
21
|
-
const DEV_ENVIRONMENT_COMPONENTS = ['
|
|
21
|
+
const DEV_ENVIRONMENT_COMPONENTS = ['muPlugins', 'appCode'];
|
|
22
22
|
exports.DEV_ENVIRONMENT_COMPONENTS = DEV_ENVIRONMENT_COMPONENTS;
|
|
23
|
+
const DEV_ENVIRONMENT_COMPONENTS_WITH_WP = ['wordpress', ...DEV_ENVIRONMENT_COMPONENTS];
|
|
24
|
+
exports.DEV_ENVIRONMENT_COMPONENTS_WITH_WP = DEV_ENVIRONMENT_COMPONENTS_WITH_WP;
|
|
23
25
|
const DEV_ENVIRONMENT_RAW_GITHUB_HOST = 'raw.githubusercontent.com';
|
|
24
26
|
exports.DEV_ENVIRONMENT_RAW_GITHUB_HOST = DEV_ENVIRONMENT_RAW_GITHUB_HOST;
|
|
25
27
|
const DEV_ENVIRONMENT_WORDPRESS_VERSIONS_URI = '/Automattic/vip-container-images/master/wordpress/versions.json';
|
|
@@ -34,4 +36,6 @@ const DEV_ENVIRONMENT_PHP_VERSIONS = {
|
|
|
34
36
|
8.1: 'ghcr.io/automattic/vip-container-images/php-fpm:8.1',
|
|
35
37
|
7.4: 'ghcr.io/automattic/vip-container-images/php-fpm:7.4'
|
|
36
38
|
};
|
|
37
|
-
exports.DEV_ENVIRONMENT_PHP_VERSIONS = DEV_ENVIRONMENT_PHP_VERSIONS;
|
|
39
|
+
exports.DEV_ENVIRONMENT_PHP_VERSIONS = DEV_ENVIRONMENT_PHP_VERSIONS;
|
|
40
|
+
const DEV_ENVIRONMENT_VERSION = '2.0.0';
|
|
41
|
+
exports.DEV_ENVIRONMENT_VERSION = DEV_ENVIRONMENT_VERSION;
|