@automattic/vip 2.24.0 → 2.24.1
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
|
@@ -65,9 +65,7 @@ const examples = [{
|
|
|
65
65
|
}
|
|
66
66
|
const importArg = ['wp', 'db', 'import', inContainerPath];
|
|
67
67
|
await (0, _devEnvironmentCore.exec)(lando, slug, importArg);
|
|
68
|
-
|
|
69
|
-
_fs.default.unlinkSync(resolvedPath);
|
|
70
|
-
}
|
|
68
|
+
_fs.default.unlinkSync(resolvedPath);
|
|
71
69
|
const cacheArg = ['wp', 'cache', 'flush'];
|
|
72
70
|
await (0, _devEnvironmentCore.exec)(lando, slug, cacheArg);
|
|
73
71
|
try {
|
|
@@ -20,6 +20,7 @@ exports.resolveImportPath = resolveImportPath;
|
|
|
20
20
|
exports.startEnvironment = startEnvironment;
|
|
21
21
|
exports.stopEnvironment = stopEnvironment;
|
|
22
22
|
exports.updateEnvironment = updateEnvironment;
|
|
23
|
+
exports.writeEnvironmentData = writeEnvironmentData;
|
|
23
24
|
var _debug = _interopRequireDefault(require("debug"));
|
|
24
25
|
var _xdgBasedir = _interopRequireDefault(require("xdg-basedir"));
|
|
25
26
|
var _nodeFetch = _interopRequireDefault(require("node-fetch"));
|
|
@@ -57,7 +58,6 @@ const nginxFileTemplatePath = _path.default.join(__dirname, '..', '..', '..', 'a
|
|
|
57
58
|
const landoFileName = '.lando.yml';
|
|
58
59
|
const nginxFileName = 'extra.conf';
|
|
59
60
|
const instanceDataFileName = 'instance_data.json';
|
|
60
|
-
const homeDirPathInsideContainers = '/user';
|
|
61
61
|
const uploadPathString = 'uploads';
|
|
62
62
|
const nginxPathString = 'nginx';
|
|
63
63
|
async function startEnvironment(lando, slug, options) {
|
|
@@ -236,6 +236,20 @@ function readEnvironmentData(slug) {
|
|
|
236
236
|
}
|
|
237
237
|
return instanceData;
|
|
238
238
|
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Writes the instance data.
|
|
242
|
+
*
|
|
243
|
+
* @param {string} slug Env slug
|
|
244
|
+
* @param {InstanceData} data instance data
|
|
245
|
+
* @returns {Promise} Promise
|
|
246
|
+
*/
|
|
247
|
+
function writeEnvironmentData(slug, data) {
|
|
248
|
+
debug('Will try to write instance data for environment', slug);
|
|
249
|
+
const instancePath = getEnvironmentPath(slug);
|
|
250
|
+
const instanceDataTargetPath = _path.default.join(instancePath, instanceDataFileName);
|
|
251
|
+
return _fs.default.promises.writeFile(instanceDataTargetPath, JSON.stringify(data, null, 2));
|
|
252
|
+
}
|
|
239
253
|
async function prepareLandoEnv(instanceData, instancePath) {
|
|
240
254
|
const landoFile = await _ejs.default.renderFile(landoFileTemplatePath, instanceData);
|
|
241
255
|
const nginxFile = await _ejs.default.renderFile(nginxFileTemplatePath, instanceData);
|
|
@@ -345,7 +359,7 @@ async function getApplicationInformation(appId, envType) {
|
|
|
345
359
|
}
|
|
346
360
|
async function resolveImportPath(slug, fileName, searchReplace, inPlace) {
|
|
347
361
|
debug(`Will try to resolve path - ${fileName}`);
|
|
348
|
-
|
|
362
|
+
const resolvedPath = (0, _devEnvironmentCli.resolvePath)(fileName);
|
|
349
363
|
const instancePath = getEnvironmentPath(slug);
|
|
350
364
|
debug(`Instance path for ${slug} is ${instancePath}`);
|
|
351
365
|
const environmentExists = _fs.default.existsSync(instancePath);
|
|
@@ -359,6 +373,7 @@ async function resolveImportPath(slug, fileName, searchReplace, inPlace) {
|
|
|
359
373
|
if (_fs.default.lstatSync(resolvedPath).isDirectory()) {
|
|
360
374
|
throw new _userError.default(`The provided file ${resolvedPath} is a directory. Please point to a sql file.`);
|
|
361
375
|
}
|
|
376
|
+
let baseName;
|
|
362
377
|
|
|
363
378
|
// Run Search and Replace if the --search-replace flag was provided
|
|
364
379
|
if (searchReplace && searchReplace.length) {
|
|
@@ -372,36 +387,18 @@ async function resolveImportPath(slug, fileName, searchReplace, inPlace) {
|
|
|
372
387
|
if (typeof outputFileName !== 'string') {
|
|
373
388
|
throw new Error('Unable to determine location of the intermediate search & replace file.');
|
|
374
389
|
}
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
_fs.default.renameSync(outputFileName, resolvedPath);
|
|
379
|
-
debug(`Renamed ${outputFileName} to ${resolvedPath}`);
|
|
380
|
-
} catch (err) {
|
|
381
|
-
if (err.code !== 'EXDEV') {
|
|
382
|
-
throw err;
|
|
383
|
-
}
|
|
384
|
-
debug('Could not rename across filesystems. Copying the file instead.');
|
|
385
|
-
_fs.default.copyFileSync(outputFileName, resolvedPath);
|
|
386
|
-
debug(`Copied ${outputFileName} to ${resolvedPath}`);
|
|
387
|
-
_fs.default.unlinkSync(outputFileName);
|
|
388
|
-
debug(`Removed ${outputFileName}`);
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
/**
|
|
393
|
-
* Docker container does not have acces to the host filesystem.
|
|
394
|
-
* However lando maps os.homedir() to /user in the container. So if we replace the path in the same way
|
|
395
|
-
* in the Docker container will get the file from within the mapped volume under /user.
|
|
396
|
-
*/
|
|
397
|
-
let inContainerPath = resolvedPath.replace(_os.default.homedir(), homeDirPathInsideContainers);
|
|
398
|
-
if (_path.default.sep === '\\') {
|
|
399
|
-
// Because the file path generated for windows will have \ instead of / we need to replace that as well so that the path inside the container (unix) still works.
|
|
400
|
-
inContainerPath = inContainerPath.replace(/\\/g, '/');
|
|
390
|
+
baseName = _path.default.basename(outputFileName);
|
|
391
|
+
} else {
|
|
392
|
+
baseName = _path.default.basename(resolvedPath);
|
|
401
393
|
}
|
|
394
|
+
const targetPath = _path.default.join(instancePath, baseName);
|
|
395
|
+
const inContainerPath = `/app/${baseName}`;
|
|
396
|
+
debug(`Copying ${resolvedPath} to ${targetPath}`);
|
|
397
|
+
_fs.default.copyFileSync(resolvedPath, targetPath, _fs.default.constants.COPYFILE_FICLONE);
|
|
398
|
+
debug(`Copied ${resolvedPath} to ${targetPath}`);
|
|
402
399
|
debug(`Import file path ${resolvedPath} will be mapped to ${inContainerPath}`);
|
|
403
400
|
return {
|
|
404
|
-
resolvedPath,
|
|
401
|
+
resolvedPath: targetPath,
|
|
405
402
|
inContainerPath
|
|
406
403
|
};
|
|
407
404
|
}
|
|
@@ -21,6 +21,8 @@ var _build = _interopRequireDefault(require("lando/plugins/lando-tooling/lib/bui
|
|
|
21
21
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
22
22
|
var _app = _interopRequireDefault(require("lando/lib/app"));
|
|
23
23
|
var _userError = _interopRequireDefault(require("../user-error"));
|
|
24
|
+
var _dns = _interopRequireDefault(require("dns"));
|
|
25
|
+
var _devEnvironmentCore = require("./dev-environment-core");
|
|
24
26
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
27
|
/**
|
|
26
28
|
*
|
|
@@ -97,6 +99,26 @@ async function landoRebuild(lando, instancePath) {
|
|
|
97
99
|
}
|
|
98
100
|
function addHooks(app, lando) {
|
|
99
101
|
app.events.on('post-start', 1, () => healthcheckHook(app, lando));
|
|
102
|
+
lando.events.on('pre-engine-build', 5, async data => {
|
|
103
|
+
const instanceData = (0, _devEnvironmentCore.readEnvironmentData)(app._name);
|
|
104
|
+
let registryResolvable = false;
|
|
105
|
+
try {
|
|
106
|
+
registryResolvable = (await _dns.default.promises.lookup('ghcr.io')).address || false;
|
|
107
|
+
debug('Registry ghcr.io is resolvable');
|
|
108
|
+
} catch (err) {
|
|
109
|
+
debug('Registry ghcr.io is not resolvable, image pull might be broken.');
|
|
110
|
+
registryResolvable = false;
|
|
111
|
+
}
|
|
112
|
+
data.opts.pull = registryResolvable && instanceData.pullAfter < Date.now();
|
|
113
|
+
if (Array.isArray(data.opts.pullable) && Array.isArray(data.opts.local) && data.opts.local.length === 0 && !data.opts.pull) {
|
|
114
|
+
data.opts.local = data.opts.pullable;
|
|
115
|
+
data.opts.pullable = [];
|
|
116
|
+
}
|
|
117
|
+
if (data.opts.pull || !instanceData.pullAfter) {
|
|
118
|
+
instanceData.pullAfter = Date.now() + 7 * 24 * 60 * 60 * 1000;
|
|
119
|
+
(0, _devEnvironmentCore.writeEnvironmentData)(app._name, instanceData);
|
|
120
|
+
}
|
|
121
|
+
});
|
|
100
122
|
}
|
|
101
123
|
const healthChecks = {
|
|
102
124
|
database: 'mysql -uroot --silent --execute "SHOW DATABASES;"',
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@automattic/vip",
|
|
3
|
-
"version": "2.24.
|
|
3
|
+
"version": "2.24.1",
|
|
4
4
|
"lockfileVersion": 1,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"dependencies": {
|
|
@@ -4558,6 +4558,7 @@
|
|
|
4558
4558
|
"@types/node": "*",
|
|
4559
4559
|
"anymatch": "^3.0.3",
|
|
4560
4560
|
"fb-watchman": "^2.0.0",
|
|
4561
|
+
"fsevents": "^2.1.2",
|
|
4561
4562
|
"graceful-fs": "^4.2.4",
|
|
4562
4563
|
"jest-regex-util": "^26.0.0",
|
|
4563
4564
|
"jest-serializer": "^26.6.2",
|
|
@@ -5297,6 +5298,7 @@
|
|
|
5297
5298
|
"requires": {
|
|
5298
5299
|
"anymatch": "~3.1.2",
|
|
5299
5300
|
"braces": "~3.0.2",
|
|
5301
|
+
"fsevents": "~2.3.2",
|
|
5300
5302
|
"glob-parent": "~5.1.2",
|
|
5301
5303
|
"is-binary-path": "~2.1.0",
|
|
5302
5304
|
"is-glob": "~4.0.1",
|
|
@@ -7742,6 +7744,13 @@
|
|
|
7742
7744
|
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
|
|
7743
7745
|
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8="
|
|
7744
7746
|
},
|
|
7747
|
+
"fsevents": {
|
|
7748
|
+
"version": "2.3.2",
|
|
7749
|
+
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
|
|
7750
|
+
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
|
|
7751
|
+
"dev": true,
|
|
7752
|
+
"optional": true
|
|
7753
|
+
},
|
|
7745
7754
|
"function-bind": {
|
|
7746
7755
|
"version": "1.1.1",
|
|
7747
7756
|
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
|
|
@@ -9339,6 +9348,7 @@
|
|
|
9339
9348
|
"@types/node": "*",
|
|
9340
9349
|
"anymatch": "^3.0.3",
|
|
9341
9350
|
"fb-watchman": "^2.0.0",
|
|
9351
|
+
"fsevents": "^2.3.2",
|
|
9342
9352
|
"graceful-fs": "^4.2.4",
|
|
9343
9353
|
"jest-regex-util": "^27.0.6",
|
|
9344
9354
|
"jest-serializer": "^27.0.6",
|
|
@@ -10220,6 +10230,14 @@
|
|
|
10220
10230
|
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.1.tgz",
|
|
10221
10231
|
"integrity": "sha512-+O9Jct8wf++lXxxFc4hc8LsjaSq0HFzzL7cVsw8pRDIPdjKD2mT4ytDZlLuSBZ4cLKZFXIrMGO7DbQCtMJJMKw=="
|
|
10222
10232
|
},
|
|
10233
|
+
"cli-table": {
|
|
10234
|
+
"version": "0.3.11",
|
|
10235
|
+
"resolved": "https://registry.npmjs.org/cli-table/-/cli-table-0.3.11.tgz",
|
|
10236
|
+
"integrity": "sha512-IqLQi4lO0nIB4tcdTpN4LCB9FI3uqrJZK7RC515EnhZ6qBaglkIgICb1wjeAqpdoOabm1+SuQtkXIPdYC93jhQ==",
|
|
10237
|
+
"requires": {
|
|
10238
|
+
"colors": "1.0.3"
|
|
10239
|
+
}
|
|
10240
|
+
},
|
|
10223
10241
|
"cliui": {
|
|
10224
10242
|
"version": "4.1.0",
|
|
10225
10243
|
"resolved": "https://registry.npmjs.org/cliui/-/cliui-4.1.0.tgz",
|
|
@@ -12217,9 +12235,9 @@
|
|
|
12217
12235
|
"integrity": "sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc="
|
|
12218
12236
|
},
|
|
12219
12237
|
"prettier": {
|
|
12220
|
-
"version": "
|
|
12221
|
-
"resolved": "https://registry.npmjs.org/
|
|
12222
|
-
"integrity": "sha512-
|
|
12238
|
+
"version": "2.0.5",
|
|
12239
|
+
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.0.5.tgz",
|
|
12240
|
+
"integrity": "sha512-7PtVymN48hGcO4fGjybyBSIWDsLU4H4XlvOHfq91pz9kkGlonzwTfYkaIEwiRg/dAJF9YlbsduBAgtYLi+8cFg==",
|
|
12223
12241
|
"dev": true
|
|
12224
12242
|
},
|
|
12225
12243
|
"pretty-format": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@automattic/vip",
|
|
3
|
-
"version": "2.24.
|
|
3
|
+
"version": "2.24.1",
|
|
4
4
|
"description": "The VIP Javascript library & CLI",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"prepare": "npm run clean && npm run build",
|
|
54
54
|
"postinstall": "node ./helpers/check-version.js",
|
|
55
55
|
"build": "babel src -d dist",
|
|
56
|
-
"build:watch": "babel src -d dist --watch",
|
|
56
|
+
"build:watch": "babel src -d dist --watch --source-maps",
|
|
57
57
|
"flow": "flow",
|
|
58
58
|
"jest": "jest",
|
|
59
59
|
"lint": "eslint index.js src __tests__",
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
"flow-bin": "0.190.1",
|
|
108
108
|
"jest": "27.2.1",
|
|
109
109
|
"nock": "13.0.11",
|
|
110
|
-
"prettier": "
|
|
110
|
+
"prettier": "^2.0.5",
|
|
111
111
|
"publish-please": "5.5.2",
|
|
112
112
|
"rimraf": "3.0.2"
|
|
113
113
|
},
|