@automattic/vip 3.25.2-dev.0 → 3.25.3-dev.0
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/AGENTS.md +0 -6
- package/CLAUDE.md +0 -1
- package/dist/bin/vip-db-phpmyadmin.js +11 -4
- package/dist/bin/vip-dev-env-exec.js +1 -18
- package/dist/bin/vip-dev-env-start.js +8 -3
- package/dist/bin/vip.js +69 -111
- package/dist/commands/phpmyadmin.js +64 -16
- package/dist/lib/cli/command.js +53 -224
- package/dist/lib/cli/config.js +5 -13
- package/dist/lib/cli/exit.js +1 -2
- package/dist/lib/dev-environment/dev-environment-cli.js +2 -9
- package/dist/lib/dev-environment/dev-environment-core.js +6 -64
- package/dist/lib/dev-environment/dev-environment-lando.js +95 -53
- package/dist/lib/dev-environment/hosts-updater.js +184 -0
- package/npm-shrinkwrap.json +669 -933
- package/package.json +11 -14
- package/tsconfig.json +1 -7
- package/dist/bin/vip-sea.js +0 -19
- package/dist/lib/cli/internal-bin-loader.js +0 -81
- package/dist/lib/cli/runtime-mode.js +0 -21
- package/dist/lib/cli/sea-dispatch.js +0 -88
- package/dist/lib/cli/sea-runtime.js +0 -75
- package/dist/lib/dev-environment/lando-loader.js +0 -48
- package/docs/COMMANDER-MIGRATION.md +0 -55
- package/docs/SEA-BUILD-SIGNING.md +0 -171
- package/helpers/build-sea.js +0 -167
package/dist/lib/cli/command.js
CHANGED
|
@@ -4,18 +4,14 @@ exports.__esModule = true;
|
|
|
4
4
|
exports.containsAppEnvArgument = containsAppEnvArgument;
|
|
5
5
|
exports.default = _default;
|
|
6
6
|
exports.getEnvIdentifier = getEnvIdentifier;
|
|
7
|
+
var _args = _interopRequireDefault(require("args"));
|
|
7
8
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
8
|
-
var _commander = require("commander");
|
|
9
9
|
var _debug = _interopRequireDefault(require("debug"));
|
|
10
10
|
var _enquirer = require("enquirer");
|
|
11
11
|
var _graphqlTag = _interopRequireDefault(require("graphql-tag"));
|
|
12
|
-
var _nodeChild_process = require("node:child_process");
|
|
13
|
-
var _nodeFs = _interopRequireDefault(require("node:fs"));
|
|
14
|
-
var _nodePath = _interopRequireDefault(require("node:path"));
|
|
15
12
|
var _envAlias = require("./envAlias");
|
|
16
13
|
var exit = _interopRequireWildcard(require("./exit"));
|
|
17
14
|
var _format = require("./format");
|
|
18
|
-
var _internalBinLoader = require("./internal-bin-loader");
|
|
19
15
|
var _prompt = require("./prompt");
|
|
20
16
|
var _package = _interopRequireDefault(require("../../../package.json"));
|
|
21
17
|
var _api = _interopRequireDefault(require("../../lib/api"));
|
|
@@ -41,209 +37,15 @@ process.on('uncaughtException', uncaughtError);
|
|
|
41
37
|
process.on('unhandledRejection', uncaughtError);
|
|
42
38
|
let _opts = {};
|
|
43
39
|
let alreadyConfirmedDebugAttachment = false;
|
|
44
|
-
const RESERVED_AUTO_SHORT_ALIASES = new Set(['h', 'v', 'd']);
|
|
45
|
-
function normalizeUsage(program, usage) {
|
|
46
|
-
if (!usage) {
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
const [rootCommand, ...rest] = usage.trim().split(/\s+/);
|
|
50
|
-
if (rootCommand) {
|
|
51
|
-
program.name(rootCommand);
|
|
52
|
-
}
|
|
53
|
-
if (rest.length) {
|
|
54
|
-
const usageString = rest.join(' ');
|
|
55
|
-
program.usage(usageString.includes('[options]') ? usageString : `${usageString} [options]`);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
function createOptionDefinition(name, description, defaultValue, parseFn, usedShortNames) {
|
|
59
|
-
const isArray = Array.isArray(name);
|
|
60
|
-
const shortName = isArray ? name[0] : null;
|
|
61
|
-
const longName = isArray ? name[1] : name;
|
|
62
|
-
const normalizedLongName = String(longName).trim().replace(/^--?/, '');
|
|
63
|
-
const explicitShortName = shortName ? String(shortName).trim().replace(/^-/, '') : null;
|
|
64
|
-
let normalizedShortName = explicitShortName;
|
|
65
|
-
if (!normalizedShortName) {
|
|
66
|
-
const autoShortName = normalizedLongName.charAt(0);
|
|
67
|
-
const canUseAutoShortName = autoShortName && !RESERVED_AUTO_SHORT_ALIASES.has(autoShortName) && !usedShortNames.has(autoShortName);
|
|
68
|
-
if (canUseAutoShortName) {
|
|
69
|
-
normalizedShortName = autoShortName;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
if (normalizedShortName) {
|
|
73
|
-
usedShortNames.add(normalizedShortName);
|
|
74
|
-
}
|
|
75
|
-
const isBooleanOption = typeof defaultValue === 'boolean';
|
|
76
|
-
const usesOptionalValue = !isBooleanOption;
|
|
77
|
-
const parseOptionValue = value => {
|
|
78
|
-
if (parseFn) {
|
|
79
|
-
return parseFn(value);
|
|
80
|
-
}
|
|
81
|
-
return value;
|
|
82
|
-
};
|
|
83
|
-
let parser;
|
|
84
|
-
if (usesOptionalValue) {
|
|
85
|
-
parser = (value, previousValue) => {
|
|
86
|
-
const parsedValue = parseOptionValue(value);
|
|
87
|
-
if (previousValue === undefined) {
|
|
88
|
-
return parsedValue;
|
|
89
|
-
}
|
|
90
|
-
if (Array.isArray(previousValue)) {
|
|
91
|
-
return [...previousValue, parsedValue];
|
|
92
|
-
}
|
|
93
|
-
return [previousValue, parsedValue];
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
let flags = `--${normalizedLongName}`;
|
|
97
|
-
if (usesOptionalValue) {
|
|
98
|
-
flags += ' [value]';
|
|
99
|
-
}
|
|
100
|
-
if (normalizedShortName) {
|
|
101
|
-
flags = `-${normalizedShortName}, ${flags}`;
|
|
102
|
-
}
|
|
103
|
-
return {
|
|
104
|
-
flags,
|
|
105
|
-
description,
|
|
106
|
-
defaultValue,
|
|
107
|
-
parser
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
class CommanderArgsCompat {
|
|
111
|
-
constructor(opts) {
|
|
112
|
-
this.details = {
|
|
113
|
-
commands: []
|
|
114
|
-
};
|
|
115
|
-
this.sub = [];
|
|
116
|
-
this.examplesList = [];
|
|
117
|
-
this.usedShortNames = new Set();
|
|
118
|
-
this._opts = opts;
|
|
119
|
-
this.program = new _commander.Command();
|
|
120
|
-
this.program.allowUnknownOption(true);
|
|
121
|
-
this.program.allowExcessArguments(true);
|
|
122
|
-
this.program.helpOption(false);
|
|
123
|
-
normalizeUsage(this.program, this._opts.usage);
|
|
124
|
-
}
|
|
125
|
-
option(name, description, defaultValue, parseFn) {
|
|
126
|
-
const definition = createOptionDefinition(name, description, defaultValue, parseFn, this.usedShortNames);
|
|
127
|
-
const {
|
|
128
|
-
flags,
|
|
129
|
-
parser
|
|
130
|
-
} = definition;
|
|
131
|
-
if (parser && defaultValue !== undefined) {
|
|
132
|
-
this.program.option(flags, description, parser, defaultValue);
|
|
133
|
-
} else if (parser) {
|
|
134
|
-
this.program.option(flags, description, parser);
|
|
135
|
-
} else if (defaultValue !== undefined) {
|
|
136
|
-
this.program.option(flags, description, defaultValue);
|
|
137
|
-
} else {
|
|
138
|
-
this.program.option(flags, description);
|
|
139
|
-
}
|
|
140
|
-
return this;
|
|
141
|
-
}
|
|
142
|
-
command(name, description = '') {
|
|
143
|
-
this.details.commands.push({
|
|
144
|
-
usage: name,
|
|
145
|
-
description
|
|
146
|
-
});
|
|
147
|
-
return this;
|
|
148
|
-
}
|
|
149
|
-
example(usage, description) {
|
|
150
|
-
this.examplesList.push({
|
|
151
|
-
usage,
|
|
152
|
-
description
|
|
153
|
-
});
|
|
154
|
-
return this;
|
|
155
|
-
}
|
|
156
|
-
examples(examples = []) {
|
|
157
|
-
for (const example of examples) {
|
|
158
|
-
this.example(example.usage, example.description);
|
|
159
|
-
}
|
|
160
|
-
return this;
|
|
161
|
-
}
|
|
162
|
-
showVersion() {
|
|
163
|
-
console.log(_package.default.version);
|
|
164
|
-
process.exit(0);
|
|
165
|
-
}
|
|
166
|
-
showHelp() {
|
|
167
|
-
const lines = [this.program.helpInformation().trimEnd()];
|
|
168
|
-
if (this.details.commands.length) {
|
|
169
|
-
lines.push('');
|
|
170
|
-
lines.push('Commands:');
|
|
171
|
-
for (const entry of this.details.commands) {
|
|
172
|
-
const commandName = entry.usage.padEnd(26, ' ');
|
|
173
|
-
lines.push(` ${commandName}${entry.description}`);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
if (this.examplesList.length) {
|
|
177
|
-
lines.push('');
|
|
178
|
-
lines.push('Examples:');
|
|
179
|
-
for (const example of this.examplesList) {
|
|
180
|
-
lines.push(` - ${example.description}`);
|
|
181
|
-
lines.push(` $ ${example.usage}`);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
console.log(lines.join('\n'));
|
|
185
|
-
process.exit(0);
|
|
186
|
-
}
|
|
187
|
-
isDefined(value, key) {
|
|
188
|
-
if (key !== 'commands') {
|
|
189
|
-
return false;
|
|
190
|
-
}
|
|
191
|
-
return this.details.commands.some(entry => entry.usage === value);
|
|
192
|
-
}
|
|
193
|
-
parse(argv) {
|
|
194
|
-
this.program.parse(argv, {
|
|
195
|
-
from: 'node'
|
|
196
|
-
});
|
|
197
|
-
this.sub = this.program.args.slice();
|
|
198
|
-
return this.program.opts();
|
|
199
|
-
}
|
|
200
|
-
async executeSubcommand(argv, parsedAlias, subcommand) {
|
|
201
|
-
const currentScript = argv[1];
|
|
202
|
-
const extension = _nodePath.default.extname(currentScript);
|
|
203
|
-
const baseScriptPath = extension ? currentScript.slice(0, -extension.length) : currentScript;
|
|
204
|
-
const childScriptPath = extension ? `${baseScriptPath}-${subcommand}${extension}` : `${baseScriptPath}-${subcommand}`;
|
|
205
|
-
const aliasFromRawArgv = argv.slice(2).find(arg => (0, _envAlias.isAlias)(arg));
|
|
206
|
-
const subcommandIndex = parsedAlias.argv.findIndex((arg, index) => {
|
|
207
|
-
return index > 1 && arg === subcommand;
|
|
208
|
-
});
|
|
209
|
-
let childArgs = subcommandIndex > -1 ? parsedAlias.argv.slice(subcommandIndex + 1) : [];
|
|
210
|
-
if (aliasFromRawArgv) {
|
|
211
|
-
childArgs = [aliasFromRawArgv, ...childArgs];
|
|
212
|
-
}
|
|
213
|
-
let runResult;
|
|
214
|
-
if (_nodeFs.default.existsSync(childScriptPath)) {
|
|
215
|
-
runResult = (0, _nodeChild_process.spawnSync)(process.execPath, [childScriptPath, ...childArgs], {
|
|
216
|
-
stdio: 'inherit',
|
|
217
|
-
env: process.env
|
|
218
|
-
});
|
|
219
|
-
} else {
|
|
220
|
-
const fallbackCommand = `${_nodePath.default.basename(baseScriptPath)}-${subcommand}`;
|
|
221
|
-
if (process.env.VIP_CLI_SEA_MODE === '1' && (0, _internalBinLoader.hasInternalBin)(fallbackCommand)) {
|
|
222
|
-
process.argv = [process.argv[0], process.argv[1], ...childArgs];
|
|
223
|
-
const loaded = await (0, _internalBinLoader.loadInternalBin)(fallbackCommand);
|
|
224
|
-
if (!loaded) {
|
|
225
|
-
throw new Error(`Unable to load SEA subcommand "${fallbackCommand}"`);
|
|
226
|
-
}
|
|
227
|
-
return;
|
|
228
|
-
}
|
|
229
|
-
runResult = (0, _nodeChild_process.spawnSync)(fallbackCommand, childArgs, {
|
|
230
|
-
stdio: 'inherit',
|
|
231
|
-
env: process.env,
|
|
232
|
-
shell: process.platform === 'win32'
|
|
233
|
-
});
|
|
234
|
-
}
|
|
235
|
-
if (runResult.error) {
|
|
236
|
-
throw runResult.error;
|
|
237
|
-
}
|
|
238
|
-
process.exit(runResult.status ?? 1);
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
40
|
|
|
242
41
|
/**
|
|
243
42
|
* @param {string[]} argv
|
|
244
43
|
*/
|
|
245
44
|
// eslint-disable-next-line complexity
|
|
246
|
-
|
|
45
|
+
_args.default.argv = async function (argv, cb) {
|
|
46
|
+
if (process.platform !== 'win32' && argv[1]?.endsWith('.js')) {
|
|
47
|
+
argv[1] = argv[1].slice(0, -3);
|
|
48
|
+
}
|
|
247
49
|
if (process.execArgv.includes('--inspect') && !alreadyConfirmedDebugAttachment) {
|
|
248
50
|
await (0, _enquirer.prompt)({
|
|
249
51
|
type: 'confirm',
|
|
@@ -253,13 +55,25 @@ CommanderArgsCompat.prototype.argv = async function (argv, cb) {
|
|
|
253
55
|
alreadyConfirmedDebugAttachment = true;
|
|
254
56
|
}
|
|
255
57
|
const parsedAlias = (0, _envAlias.parseEnvAliasFromArgv)(argv);
|
|
256
|
-
const options = this.parse(parsedAlias.argv);
|
|
257
58
|
|
|
258
|
-
//
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
59
|
+
// A usage option allows us to override the default usage text, which isn't
|
|
60
|
+
// accurate for subcommands. By default, it will display something like (note
|
|
61
|
+
// the hyphen):
|
|
62
|
+
// Usage: vip command-subcommand [options]
|
|
63
|
+
//
|
|
64
|
+
// We can pass "vip command subcommand" to the name param for more accurate
|
|
65
|
+
// usage text:
|
|
66
|
+
// Usage: vip command subcommand [options]
|
|
67
|
+
//
|
|
68
|
+
// It also allows us to represent required args in usage text:
|
|
69
|
+
// Usage: vip command subcommand <arg1> <arg2> [options]
|
|
70
|
+
const name = _opts.usage || null;
|
|
71
|
+
const options = this.parse(parsedAlias.argv, {
|
|
72
|
+
help: false,
|
|
73
|
+
name,
|
|
74
|
+
version: false,
|
|
75
|
+
debug: false
|
|
76
|
+
});
|
|
263
77
|
if (_opts.format && !options.format) {
|
|
264
78
|
options.format = 'table';
|
|
265
79
|
}
|
|
@@ -291,7 +105,12 @@ CommanderArgsCompat.prototype.argv = async function (argv, cb) {
|
|
|
291
105
|
});
|
|
292
106
|
exit.withError(error);
|
|
293
107
|
}
|
|
294
|
-
|
|
108
|
+
|
|
109
|
+
// If there's a sub-command, run that instead
|
|
110
|
+
if (this.isDefined(this.sub[0], 'commands')) {
|
|
111
|
+
return {};
|
|
112
|
+
}
|
|
113
|
+
if (process.env.NODE_ENV !== 'test') {
|
|
295
114
|
const {
|
|
296
115
|
default: updateNotifier
|
|
297
116
|
} = await import('update-notifier');
|
|
@@ -302,7 +121,18 @@ CommanderArgsCompat.prototype.argv = async function (argv, cb) {
|
|
|
302
121
|
isGlobal: true
|
|
303
122
|
});
|
|
304
123
|
}
|
|
305
|
-
|
|
124
|
+
|
|
125
|
+
// `help` and `version` are always defined as subcommands
|
|
126
|
+
const customCommands = this.details.commands.filter(command => {
|
|
127
|
+
switch (command.usage) {
|
|
128
|
+
case 'help':
|
|
129
|
+
case 'version':
|
|
130
|
+
case 'debug':
|
|
131
|
+
return false;
|
|
132
|
+
default:
|
|
133
|
+
return true;
|
|
134
|
+
}
|
|
135
|
+
});
|
|
306
136
|
|
|
307
137
|
// Show help if no args passed
|
|
308
138
|
if (Boolean(customCommands.length) && !this.sub.length) {
|
|
@@ -322,7 +152,7 @@ CommanderArgsCompat.prototype.argv = async function (argv, cb) {
|
|
|
322
152
|
|
|
323
153
|
// Show help if subcommand is invalid
|
|
324
154
|
const subCommands = this.details.commands.map(cmd => cmd.usage);
|
|
325
|
-
if (!_opts.wildcardCommand && this.sub[_opts.requiredArgs] &&
|
|
155
|
+
if (!_opts.wildcardCommand && this.sub[_opts.requiredArgs] && 0 > subCommands.indexOf(this.sub[_opts.requiredArgs])) {
|
|
326
156
|
const subcommand = this.sub.join(' ');
|
|
327
157
|
await (0, _tracker.trackEvent)('command_validation_error', {
|
|
328
158
|
error: `Invalid subcommand: ${subcommand}`
|
|
@@ -538,7 +368,7 @@ CommanderArgsCompat.prototype.argv = async function (argv, cb) {
|
|
|
538
368
|
value: `${_chalk.default.cyan(launched)}`
|
|
539
369
|
});
|
|
540
370
|
}
|
|
541
|
-
if (this.sub
|
|
371
|
+
if (this.sub) {
|
|
542
372
|
info.push({
|
|
543
373
|
key: 'SQL File',
|
|
544
374
|
value: `${_chalk.default.blueBright(this.sub)}`
|
|
@@ -611,7 +441,7 @@ CommanderArgsCompat.prototype.argv = async function (argv, cb) {
|
|
|
611
441
|
}
|
|
612
442
|
case 'import-media':
|
|
613
443
|
{
|
|
614
|
-
const isUrl = this.sub
|
|
444
|
+
const isUrl = this.sub && (String(this.sub).startsWith('http://') || String(this.sub).startsWith('https://'));
|
|
615
445
|
const archiveLabel = isUrl ? 'Archive URL' : 'Archive Path';
|
|
616
446
|
info.push({
|
|
617
447
|
key: archiveLabel,
|
|
@@ -706,7 +536,7 @@ function validateOpts(opts) {
|
|
|
706
536
|
}
|
|
707
537
|
|
|
708
538
|
/**
|
|
709
|
-
* @returns {
|
|
539
|
+
* @returns {args}
|
|
710
540
|
*/
|
|
711
541
|
function _default(opts) {
|
|
712
542
|
_opts = {
|
|
@@ -720,25 +550,24 @@ function _default(opts) {
|
|
|
720
550
|
wildcardCommand: false,
|
|
721
551
|
...opts
|
|
722
552
|
};
|
|
723
|
-
const args = new CommanderArgsCompat(_opts);
|
|
724
553
|
if (_opts.appContext || _opts.requireConfirm) {
|
|
725
|
-
|
|
554
|
+
_args.default.option('app', 'Target an application. Accepts a string value for the application name or an integer for the application ID.');
|
|
726
555
|
}
|
|
727
556
|
if (_opts.envContext || _opts.childEnvContext) {
|
|
728
|
-
|
|
557
|
+
_args.default.option('env', 'Target an environment. Accepts a string value for the environment type.');
|
|
729
558
|
}
|
|
730
559
|
if (_opts.requireConfirm) {
|
|
731
|
-
|
|
560
|
+
_args.default.option('force', 'Skip confirmation.', false);
|
|
732
561
|
}
|
|
733
562
|
if (_opts.format) {
|
|
734
|
-
|
|
563
|
+
_args.default.option('format', 'Render output in a particular format. Accepts “table“ (default), “csv“, and “json“.');
|
|
735
564
|
}
|
|
736
565
|
|
|
737
566
|
// Add help and version to all subcommands
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
return
|
|
567
|
+
_args.default.option('help', 'Retrieve a description, examples, and available options for a (sub)command.');
|
|
568
|
+
_args.default.option('version', 'Retrieve the version number of VIP-CLI currently installed on the local machine.');
|
|
569
|
+
_args.default.option('debug', 'Generate verbose output during command execution to help identify or fix errors or bugs.');
|
|
570
|
+
return _args.default;
|
|
742
571
|
}
|
|
743
572
|
function getEnvIdentifier(env) {
|
|
744
573
|
let identifier = env.type;
|
package/dist/lib/cli/config.js
CHANGED
|
@@ -4,9 +4,8 @@ exports.__esModule = true;
|
|
|
4
4
|
exports.default = void 0;
|
|
5
5
|
exports.loadConfigFile = loadConfigFile;
|
|
6
6
|
var _debug = _interopRequireDefault(require("debug"));
|
|
7
|
-
var _nodeFs =
|
|
7
|
+
var _nodeFs = require("node:fs");
|
|
8
8
|
var _nodePath = _interopRequireDefault(require("node:path"));
|
|
9
|
-
var _configPublish = _interopRequireDefault(require("../../../config/config.publish.json"));
|
|
10
9
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
10
|
// I don't like using synchronous versions, but until we migrate to ESM, we have to.
|
|
12
11
|
|
|
@@ -15,33 +14,26 @@ function loadConfigFile() {
|
|
|
15
14
|
const paths = [
|
|
16
15
|
// Get `local` config first; this will only exist in dev as it's npmignore-d.
|
|
17
16
|
_nodePath.default.join(__dirname, '../../../config/config.local.json'), _nodePath.default.join(__dirname, '../../../config/config.publish.json')];
|
|
18
|
-
let hasNonEnoentError = false;
|
|
19
17
|
for (const filePath of paths) {
|
|
20
18
|
try {
|
|
21
|
-
const data = _nodeFs.
|
|
19
|
+
const data = (0, _nodeFs.readFileSync)(filePath, 'utf-8');
|
|
22
20
|
debug(`Found config file at ${filePath}`);
|
|
23
21
|
return JSON.parse(data);
|
|
24
22
|
} catch (err) {
|
|
25
|
-
|
|
26
|
-
if (!isEnoent) {
|
|
27
|
-
hasNonEnoentError = true;
|
|
23
|
+
if (!(err instanceof Error) || !('code' in err) || err.code !== 'ENOENT') {
|
|
28
24
|
debug(`Error reading config file at ${filePath}:`, err);
|
|
29
25
|
}
|
|
30
26
|
}
|
|
31
27
|
}
|
|
32
|
-
|
|
33
|
-
// SEA builds can miss on-disk config files, so use the bundled publish config only for ENOENT.
|
|
34
|
-
if (!hasNonEnoentError) {
|
|
35
|
-
return _configPublish.default;
|
|
36
|
-
}
|
|
37
28
|
return null;
|
|
38
29
|
}
|
|
39
30
|
const configFromFile = loadConfigFile();
|
|
40
31
|
if (null === configFromFile) {
|
|
32
|
+
// This should not happen because `config/config.publish.json` is always present.
|
|
41
33
|
console.error('FATAL ERROR: Could not find a valid configuration file');
|
|
42
34
|
process.exit(1);
|
|
43
35
|
}
|
|
44
36
|
|
|
45
|
-
// Without this, TypeScript will export `configFromFile` as `Config | null
|
|
37
|
+
// Without this, TypeScript will export `configFromFile` as `Config | null`
|
|
46
38
|
const exportedConfig = configFromFile;
|
|
47
39
|
var _default = exports.default = exportedConfig;
|
package/dist/lib/cli/exit.js
CHANGED
|
@@ -4,7 +4,6 @@ exports.__esModule = true;
|
|
|
4
4
|
exports.withError = withError;
|
|
5
5
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
6
6
|
var _debug = _interopRequireDefault(require("debug"));
|
|
7
|
-
var _runtimeMode = require("./runtime-mode");
|
|
8
7
|
var _env = _interopRequireDefault(require("../../lib/env"));
|
|
9
8
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
9
|
function withError(message) {
|
|
@@ -14,7 +13,7 @@ function withError(message) {
|
|
|
14
13
|
// Debug ouput is printed below error output both for information
|
|
15
14
|
// hierarchy and to make it more likely that the user copies it to their
|
|
16
15
|
// clipboard when dragging across output.
|
|
17
|
-
console.log(`${_chalk.default.yellow('Debug: ')} VIP-CLI v${_env.default.app.version}, Node ${_env.default.node.version}, ${_env.default.os.name} ${_env.default.os.version} ${_env.default.os.arch}
|
|
16
|
+
console.log(`${_chalk.default.yellow('Debug: ')} VIP-CLI v${_env.default.app.version}, Node ${_env.default.node.version}, ${_env.default.os.name} ${_env.default.os.version} ${_env.default.os.arch}`);
|
|
18
17
|
if (_debug.default.names.length > 0 && message instanceof Error) {
|
|
19
18
|
console.error(_chalk.default.yellow('Debug: '), message);
|
|
20
19
|
}
|
|
@@ -38,6 +38,7 @@ var _chalk = _interopRequireDefault(require("chalk"));
|
|
|
38
38
|
var _child_process = require("child_process");
|
|
39
39
|
var _debug = _interopRequireDefault(require("debug"));
|
|
40
40
|
var _enquirer = require("enquirer");
|
|
41
|
+
var _formatters = _interopRequireDefault(require("lando/lib/formatters"));
|
|
41
42
|
var _nodeFs = require("node:fs");
|
|
42
43
|
var _nodeOs = require("node:os");
|
|
43
44
|
var _path = _interopRequireDefault(require("path"));
|
|
@@ -45,7 +46,6 @@ var _shelljs = require("shelljs");
|
|
|
45
46
|
var _devEnvironmentConfigurationFile = require("./dev-environment-configuration-file");
|
|
46
47
|
var _devEnvironmentCore = require("./dev-environment-core");
|
|
47
48
|
var _devEnvironmentLando = require("./dev-environment-lando");
|
|
48
|
-
var _landoLoader = require("./lando-loader");
|
|
49
49
|
var _user = require("../api/user");
|
|
50
50
|
var _devEnvironment = require("../constants/dev-environment");
|
|
51
51
|
var _tracker = require("../tracker");
|
|
@@ -55,13 +55,6 @@ const debug = (0, _debug.default)('@automattic/vip:bin:dev-environment');
|
|
|
55
55
|
const DEFAULT_SLUG = exports.DEFAULT_SLUG = 'vip-local';
|
|
56
56
|
const CONFIGURATION_FOLDER = exports.CONFIGURATION_FOLDER = '.wpvip';
|
|
57
57
|
let isStdinTTY = Boolean(process.stdin.isTTY);
|
|
58
|
-
let landoFormatters = null;
|
|
59
|
-
const getLandoFormatters = () => {
|
|
60
|
-
if (!landoFormatters) {
|
|
61
|
-
landoFormatters = (0, _landoLoader.loadLandoModule)('lando/lib/formatters');
|
|
62
|
-
}
|
|
63
|
-
return landoFormatters;
|
|
64
|
-
};
|
|
65
58
|
|
|
66
59
|
/**
|
|
67
60
|
* Used internally for tests
|
|
@@ -157,7 +150,7 @@ function getEnvironmentStartCommand(slug, configurationFileOptions) {
|
|
|
157
150
|
return `${_devEnvironment.DEV_ENVIRONMENT_FULL_COMMAND} start --slug ${slug}`;
|
|
158
151
|
}
|
|
159
152
|
function printTable(data) {
|
|
160
|
-
const formattedData =
|
|
153
|
+
const formattedData = _formatters.default.formatData(data, {
|
|
161
154
|
format: 'table'
|
|
162
155
|
}, {
|
|
163
156
|
border: false
|
|
@@ -28,6 +28,7 @@ var _debug = _interopRequireDefault(require("debug"));
|
|
|
28
28
|
var _ejs = _interopRequireDefault(require("ejs"));
|
|
29
29
|
var _enquirer = require("enquirer");
|
|
30
30
|
var _graphql = require("graphql");
|
|
31
|
+
var _utils = require("lando/lib/utils");
|
|
31
32
|
var _nodeFetch = _interopRequireDefault(require("node-fetch"));
|
|
32
33
|
var _nodeCrypto = require("node:crypto");
|
|
33
34
|
var _nodeFs = _interopRequireDefault(require("node:fs"));
|
|
@@ -36,7 +37,6 @@ var _nodePath = _interopRequireDefault(require("node:path"));
|
|
|
36
37
|
var _semver = _interopRequireDefault(require("semver"));
|
|
37
38
|
var _devEnvironmentCli = require("./dev-environment-cli");
|
|
38
39
|
var _devEnvironmentLando = require("./dev-environment-lando");
|
|
39
|
-
var _landoLoader = require("./lando-loader");
|
|
40
40
|
var _app = _interopRequireDefault(require("../api/app"));
|
|
41
41
|
var _software = require("../config/software");
|
|
42
42
|
var _devEnvironment = require("../constants/dev-environment");
|
|
@@ -47,9 +47,7 @@ var _xdgData = require("../xdg-data");
|
|
|
47
47
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
48
48
|
const debug = (0, _debug.default)('@automattic/vip:bin:dev-environment');
|
|
49
49
|
const landoFileTemplatePath = _nodePath.default.join(__dirname, '..', '..', '..', 'assets', 'dev-env.lando.template.yml.ejs');
|
|
50
|
-
const landoTemplateAssetKey = 'dev-env.lando.template.yml.ejs';
|
|
51
50
|
const nginxFileTemplatePath = _nodePath.default.join(__dirname, '..', '..', '..', 'assets', 'dev-env.nginx.template.conf.ejs');
|
|
52
|
-
const nginxTemplateAssetKey = 'dev-env.nginx.template.conf.ejs';
|
|
53
51
|
const landoFileName = '.lando.yml';
|
|
54
52
|
const landoOverridesFileName = '.lando.local.yml';
|
|
55
53
|
const landoBackupFileName = '.lando.backup.yml';
|
|
@@ -60,53 +58,6 @@ const integrationsConfigBackupFileName = 'integrations.json.bak';
|
|
|
60
58
|
const uploadPathString = 'uploads';
|
|
61
59
|
const nginxPathString = 'nginx';
|
|
62
60
|
const integrationsConfigPathString = 'integrations-config';
|
|
63
|
-
const STARTUP_READY_ATTEMPTS = 6;
|
|
64
|
-
const STARTUP_READY_DELAY_MS = 2000;
|
|
65
|
-
let dockerComposifyFromLando = null;
|
|
66
|
-
const dockerComposify = value => {
|
|
67
|
-
if (!dockerComposifyFromLando) {
|
|
68
|
-
const landoUtils = (0, _landoLoader.loadLandoModule)('lando/lib/utils');
|
|
69
|
-
dockerComposifyFromLando = landoUtils.dockerComposify;
|
|
70
|
-
}
|
|
71
|
-
return dockerComposifyFromLando(value);
|
|
72
|
-
};
|
|
73
|
-
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
|
|
74
|
-
let seaModulePromise = null;
|
|
75
|
-
const getSeaModule = async () => {
|
|
76
|
-
if (!seaModulePromise) {
|
|
77
|
-
seaModulePromise = (async () => {
|
|
78
|
-
try {
|
|
79
|
-
return await import('node:sea');
|
|
80
|
-
} catch {
|
|
81
|
-
return null;
|
|
82
|
-
}
|
|
83
|
-
})();
|
|
84
|
-
}
|
|
85
|
-
return seaModulePromise;
|
|
86
|
-
};
|
|
87
|
-
const renderTemplateFile = async (filePath, assetKey, templateData) => {
|
|
88
|
-
const sea = await getSeaModule();
|
|
89
|
-
if (sea?.isSea?.() && sea.getAsset) {
|
|
90
|
-
const template = sea.getAsset(assetKey, 'utf8');
|
|
91
|
-
if (typeof template === 'string') {
|
|
92
|
-
return _ejs.default.render(template, templateData);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
return _ejs.default.renderFile(filePath, templateData);
|
|
96
|
-
};
|
|
97
|
-
async function waitForEnvironmentToBeUp(lando, instancePath) {
|
|
98
|
-
return pollEnvironmentUpStatus(lando, instancePath, 1);
|
|
99
|
-
}
|
|
100
|
-
async function pollEnvironmentUpStatus(lando, instancePath, attempt) {
|
|
101
|
-
if (await (0, _devEnvironmentLando.isEnvUp)(lando, instancePath)) {
|
|
102
|
-
return true;
|
|
103
|
-
}
|
|
104
|
-
if (attempt >= STARTUP_READY_ATTEMPTS) {
|
|
105
|
-
return false;
|
|
106
|
-
}
|
|
107
|
-
await sleep(STARTUP_READY_DELAY_MS);
|
|
108
|
-
return pollEnvironmentUpStatus(lando, instancePath, attempt + 1);
|
|
109
|
-
}
|
|
110
61
|
async function startEnvironment(lando, slug, options) {
|
|
111
62
|
debug('Will start an environment', slug);
|
|
112
63
|
const instancePath = getEnvironmentPath(slug);
|
|
@@ -127,18 +78,9 @@ async function startEnvironment(lando, slug, options) {
|
|
|
127
78
|
await (0, _devEnvironmentLando.removeProxyCache)(lando);
|
|
128
79
|
}
|
|
129
80
|
if (options.skipRebuild && !updated) {
|
|
130
|
-
await (0, _devEnvironmentLando.landoStart)(lando, instancePath);
|
|
81
|
+
await (0, _devEnvironmentLando.landoStart)(lando, instancePath, options.autofixDomains);
|
|
131
82
|
} else {
|
|
132
|
-
await (0, _devEnvironmentLando.landoRebuild)(lando, instancePath);
|
|
133
|
-
}
|
|
134
|
-
let isEnvironmentUp = await waitForEnvironmentToBeUp(lando, instancePath);
|
|
135
|
-
if (!isEnvironmentUp) {
|
|
136
|
-
// A second startup pass helps recover after Docker network auto-cleanup edge cases.
|
|
137
|
-
await (0, _devEnvironmentLando.landoStart)(lando, instancePath);
|
|
138
|
-
isEnvironmentUp = await waitForEnvironmentToBeUp(lando, instancePath);
|
|
139
|
-
}
|
|
140
|
-
if (!isEnvironmentUp) {
|
|
141
|
-
throw new _userError.default(`Environment "${slug}" did not reach a running state. Please try "${_chalk.default.bold(`vip dev-env start --slug ${slug}`)}" again.`);
|
|
83
|
+
await (0, _devEnvironmentLando.landoRebuild)(lando, instancePath, options.autofixDomains);
|
|
142
84
|
}
|
|
143
85
|
await printEnvironmentInfo(lando, slug, {
|
|
144
86
|
extended: false
|
|
@@ -224,7 +166,7 @@ async function destroyEnvironment(lando, slug, removeFiles) {
|
|
|
224
166
|
} else {
|
|
225
167
|
debug("Lando file doesn't exist, skipping lando destroy.");
|
|
226
168
|
}
|
|
227
|
-
await _nodeFs.default.promises.rm(_nodePath.default.join((0, _xdgData.xdgData)(), 'vip', 'lando', 'compose', dockerComposify(slug)), {
|
|
169
|
+
await _nodeFs.default.promises.rm(_nodePath.default.join((0, _xdgData.xdgData)(), 'vip', 'lando', 'compose', (0, _utils.dockerComposify)(slug)), {
|
|
228
170
|
force: true,
|
|
229
171
|
recursive: true
|
|
230
172
|
});
|
|
@@ -407,8 +349,8 @@ async function prepareLandoEnv(lando, instanceData, instancePath, integrationsCo
|
|
|
407
349
|
...instanceData,
|
|
408
350
|
domain: lando.config.domain
|
|
409
351
|
};
|
|
410
|
-
const landoFile = await
|
|
411
|
-
const nginxFile = await
|
|
352
|
+
const landoFile = await _ejs.default.renderFile(landoFileTemplatePath, templateData);
|
|
353
|
+
const nginxFile = await _ejs.default.renderFile(nginxFileTemplatePath, templateData);
|
|
412
354
|
const instanceDataFile = JSON.stringify(instanceData);
|
|
413
355
|
const landoFileTargetPath = _nodePath.default.join(instancePath, landoFileName);
|
|
414
356
|
const landoOverridesFileTargetPath = _nodePath.default.join(instancePath, landoOverridesFileName);
|