@automattic/vip 2.27.0 → 2.28.0-dev
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/dist/bin/vip-cache.js +1 -1
- package/dist/bin/vip-config-envvar.js +1 -1
- package/dist/bin/vip-dev-env.js +1 -1
- package/dist/bin/vip-validate.js +1 -1
- package/dist/lib/dev-environment/dev-environment-lando.js +23 -88
- package/npm-shrinkwrap.json +11666 -16347
- package/package.json +15 -15
package/dist/bin/vip-cache.js
CHANGED
|
@@ -17,5 +17,5 @@
|
|
|
17
17
|
var _command = _interopRequireDefault(require("../lib/cli/command"));
|
|
18
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
19
|
(0, _command.default)({
|
|
20
|
-
requiredArgs:
|
|
20
|
+
requiredArgs: 1
|
|
21
21
|
}).command('purge-url', 'Purge page cache').argv(process.argv);
|
|
@@ -17,5 +17,5 @@
|
|
|
17
17
|
var _command = _interopRequireDefault(require("../lib/cli/command"));
|
|
18
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
19
|
(0, _command.default)({
|
|
20
|
-
requiredArgs:
|
|
20
|
+
requiredArgs: 0
|
|
21
21
|
}).command('delete', 'Permanently delete an environment variable').command('get', 'Get the value of an environment variable').command('get-all', 'Get the values of all environment variable').command('list', 'List the names of all environment variables').command('set', 'Add or update an environment variable').argv(process.argv);
|
package/dist/bin/vip-dev-env.js
CHANGED
|
@@ -17,5 +17,5 @@
|
|
|
17
17
|
var _command = _interopRequireDefault(require("../lib/cli/command"));
|
|
18
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
19
|
(0, _command.default)({
|
|
20
|
-
requiredArgs:
|
|
20
|
+
requiredArgs: 0
|
|
21
21
|
}).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').argv(process.argv);
|
package/dist/bin/vip-validate.js
CHANGED
|
@@ -13,7 +13,7 @@ var _command = _interopRequireDefault(require("../lib/cli/command"));
|
|
|
13
13
|
var _tracker = require("../lib/tracker");
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
15
|
(0, _command.default)({
|
|
16
|
-
requiredArgs:
|
|
16
|
+
requiredArgs: 0
|
|
17
17
|
}).command('preflight', 'Runs preflight tests to validate if your application is ready to be deployed').argv(process.argv, async () => {
|
|
18
18
|
await (0, _tracker.trackEvent)('vip_validate_command_execute');
|
|
19
19
|
});
|
|
@@ -83,13 +83,7 @@ async function getLandoConfig() {
|
|
|
83
83
|
subdir: '.',
|
|
84
84
|
namespace: '@lando'
|
|
85
85
|
}],
|
|
86
|
-
disablePlugins: [
|
|
87
|
-
// Plugins we need:
|
|
88
|
-
// '@lando/compose',
|
|
89
|
-
// '@lando/mailhog',
|
|
90
|
-
// '@lando/phpmyadmin',
|
|
91
|
-
// The rest we don't need
|
|
92
|
-
'@lando/acquia', '@lando/apache', '@lando/argv', '@lando/backdrop', '@lando/dotnet', '@lando/drupal', '@lando/elasticsearch', '@lando/go', '@lando/joomla', '@lando/lagoon', '@lando/lamp', '@lando/laravel', '@lando/lemp', '@lando/mariadb', '@lando/mean', '@lando/memcached', '@lando/mongo', '@lando/mssql', '@lando/mysql', '@lando/nginx', '@lando/node', '@lando/pantheon', '@lando/php', '@lando/platformsh', '@lando/postgres', '@lando/python', '@lando/redis', '@lando/ruby', '@lando/solr', '@lando/symfony', '@lando/tomcat', '@lando/varnish', '@lando/wordpress'],
|
|
86
|
+
disablePlugins: ['@lando/argv'],
|
|
93
87
|
proxyName: 'vip-dev-env-proxy',
|
|
94
88
|
userConfRoot: landoDir,
|
|
95
89
|
home: fakeHomeDir,
|
|
@@ -125,7 +119,6 @@ async function landoRecovery(lando, instancePath, error) {
|
|
|
125
119
|
console.error(_chalk.default.green('Recovery successful, trying to initialize again...'));
|
|
126
120
|
try {
|
|
127
121
|
const app = lando.getApp(instancePath);
|
|
128
|
-
addHooks(app, lando);
|
|
129
122
|
await app.init();
|
|
130
123
|
return app;
|
|
131
124
|
} catch (initError) {
|
|
@@ -143,7 +136,6 @@ async function getLandoApplication(lando, instancePath) {
|
|
|
143
136
|
let app;
|
|
144
137
|
try {
|
|
145
138
|
app = lando.getApp(instancePath);
|
|
146
|
-
await addHooks(app, lando);
|
|
147
139
|
await app.init();
|
|
148
140
|
} catch (error) {
|
|
149
141
|
app = await landoRecovery(lando, instancePath, error);
|
|
@@ -153,6 +145,28 @@ async function getLandoApplication(lando, instancePath) {
|
|
|
153
145
|
}
|
|
154
146
|
async function bootstrapLando() {
|
|
155
147
|
const lando = new _lando.default(await getLandoConfig());
|
|
148
|
+
lando.events.once('pre-engine-build', async data => {
|
|
149
|
+
const instanceData = (0, _devEnvironmentCore.readEnvironmentData)(data.name);
|
|
150
|
+
let registryResolvable = false;
|
|
151
|
+
try {
|
|
152
|
+
registryResolvable = (await _dns.default.promises.lookup('ghcr.io')).address || false;
|
|
153
|
+
debug('Registry ghcr.io is resolvable');
|
|
154
|
+
} catch (err) {
|
|
155
|
+
debug('Registry ghcr.io is not resolvable, image pull might be broken.');
|
|
156
|
+
registryResolvable = false;
|
|
157
|
+
}
|
|
158
|
+
const pull = registryResolvable && (instanceData.pullAfter || 0) < Date.now();
|
|
159
|
+
if (Array.isArray(data.opts.pullable) && Array.isArray(data.opts.local) && data.opts.local.length === 0 && !pull) {
|
|
160
|
+
// Setting `data.opts.pullable` to an empty array prevents Lando from pulling images with `docker pull`.
|
|
161
|
+
// Note that if some of the images are not available, they will still be pulled by `docker-compose`.
|
|
162
|
+
data.opts.local = data.opts.pullable;
|
|
163
|
+
data.opts.pullable = [];
|
|
164
|
+
}
|
|
165
|
+
if (pull || !instanceData.pullAfter) {
|
|
166
|
+
instanceData.pullAfter = Date.now() + 7 * 24 * 60 * 60 * 1000;
|
|
167
|
+
(0, _devEnvironmentCore.writeEnvironmentData)(data.name, instanceData);
|
|
168
|
+
}
|
|
169
|
+
});
|
|
156
170
|
await lando.bootstrap();
|
|
157
171
|
return lando;
|
|
158
172
|
}
|
|
@@ -178,85 +192,6 @@ async function landoRebuild(lando, instancePath) {
|
|
|
178
192
|
await ensureNoOrphantProxyContainer(lando);
|
|
179
193
|
await app.rebuild();
|
|
180
194
|
}
|
|
181
|
-
async function addHooks(app, lando) {
|
|
182
|
-
app.events.on('post-start', 1, () => healthcheckHook(app, lando));
|
|
183
|
-
lando.events.once('pre-engine-build', async data => {
|
|
184
|
-
const instanceData = (0, _devEnvironmentCore.readEnvironmentData)(app._name);
|
|
185
|
-
let registryResolvable = false;
|
|
186
|
-
try {
|
|
187
|
-
registryResolvable = (await _dns.default.promises.lookup('ghcr.io')).address || false;
|
|
188
|
-
debug('Registry ghcr.io is resolvable');
|
|
189
|
-
} catch (err) {
|
|
190
|
-
debug('Registry ghcr.io is not resolvable, image pull might be broken.');
|
|
191
|
-
registryResolvable = false;
|
|
192
|
-
}
|
|
193
|
-
const pull = registryResolvable && (instanceData.pullAfter || 0) < Date.now();
|
|
194
|
-
if (Array.isArray(data.opts.pullable) && Array.isArray(data.opts.local) && data.opts.local.length === 0 && !pull) {
|
|
195
|
-
// Settigs `data.opts.pullable` to an empty array prevents Lando from pulling images with `docker pull`.
|
|
196
|
-
// Note that if some of the images are not available, they will still be pulled by `docker-compose`.
|
|
197
|
-
data.opts.local = data.opts.pullable;
|
|
198
|
-
data.opts.pullable = [];
|
|
199
|
-
}
|
|
200
|
-
if (pull || !instanceData.pullAfter) {
|
|
201
|
-
instanceData.pullAfter = Date.now() + 7 * 24 * 60 * 60 * 1000;
|
|
202
|
-
(0, _devEnvironmentCore.writeEnvironmentData)(app._name, instanceData);
|
|
203
|
-
}
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
const healthChecks = {
|
|
207
|
-
database: 'mysql -uroot --silent --execute "SHOW DATABASES;"',
|
|
208
|
-
elasticsearch: "curl -s --noproxy '*' -XGET localhost:9200",
|
|
209
|
-
php: '[[ -f /wp/wp-includes/pomo/mo.php ]]'
|
|
210
|
-
};
|
|
211
|
-
async function healthcheckHook(app, lando) {
|
|
212
|
-
const now = new Date();
|
|
213
|
-
try {
|
|
214
|
-
await lando.Promise.retry(async () => {
|
|
215
|
-
const list = await lando.engine.list({
|
|
216
|
-
project: app.project
|
|
217
|
-
});
|
|
218
|
-
const notHealthyContainers = [];
|
|
219
|
-
const checkPromises = [];
|
|
220
|
-
const containerOrder = [];
|
|
221
|
-
for (const container of list) {
|
|
222
|
-
if (healthChecks[container.service]) {
|
|
223
|
-
debug(`Testing ${container.service}: ${healthChecks[container.service]}`);
|
|
224
|
-
containerOrder.push(container);
|
|
225
|
-
checkPromises.push(app.engine.run({
|
|
226
|
-
id: container.id,
|
|
227
|
-
cmd: healthChecks[container.service],
|
|
228
|
-
compose: app.compose,
|
|
229
|
-
project: app.project,
|
|
230
|
-
opts: {
|
|
231
|
-
silent: true,
|
|
232
|
-
noTTY: true,
|
|
233
|
-
cstdio: 'pipe',
|
|
234
|
-
services: [container.service]
|
|
235
|
-
}
|
|
236
|
-
}));
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
const results = await Promise.allSettled(checkPromises);
|
|
240
|
-
results.forEach((result, index) => {
|
|
241
|
-
if (result.status === 'rejected') {
|
|
242
|
-
debug(`${containerOrder[index].service} Health check failed`);
|
|
243
|
-
notHealthyContainers.push(containerOrder[index]);
|
|
244
|
-
}
|
|
245
|
-
});
|
|
246
|
-
if (notHealthyContainers.length) {
|
|
247
|
-
notHealthyContainers.forEach(container => console.log(`Waiting for service ${container.service} ...`));
|
|
248
|
-
return Promise.reject(notHealthyContainers);
|
|
249
|
-
}
|
|
250
|
-
}, {
|
|
251
|
-
max: 20,
|
|
252
|
-
backoff: 1000
|
|
253
|
-
});
|
|
254
|
-
} catch (containersWithFailingHealthCheck) {
|
|
255
|
-
containersWithFailingHealthCheck.forEach(container => console.log(_chalk.default.yellow('WARNING:') + ` Service ${container.service} failed healthcheck`));
|
|
256
|
-
}
|
|
257
|
-
const duration = new Date().getTime() - now.getTime();
|
|
258
|
-
debug(`Healthcheck completed in ${duration}ms`);
|
|
259
|
-
}
|
|
260
195
|
async function landoStop(lando, instancePath) {
|
|
261
196
|
debug('Will stop lando app on path:', instancePath);
|
|
262
197
|
const app = await getLandoApplication(lando, instancePath);
|