@automattic/vip 4.0.0 → 4.0.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.
@@ -107,6 +107,9 @@ function createOptionDefinition(name, description, defaultValue, parseFn, usedSh
107
107
  parser
108
108
  };
109
109
  }
110
+ function isOptionToken(arg) {
111
+ return arg !== '-' && arg.startsWith('-');
112
+ }
110
113
  class CommanderArgsCompat {
111
114
  constructor(opts) {
112
115
  this.details = {
@@ -197,16 +200,37 @@ class CommanderArgsCompat {
197
200
  this.sub = this.program.args.slice();
198
201
  return this.program.opts();
199
202
  }
203
+ findSubcommand(argv) {
204
+ const dashDashIndex = argv.indexOf('--', 2);
205
+ const searchEnd = dashDashIndex === -1 ? argv.length : dashDashIndex;
206
+ for (let index = 2; index < searchEnd; index++) {
207
+ const arg = argv[index];
208
+ if (this.isDefined(arg, 'commands')) {
209
+ return {
210
+ index,
211
+ name: arg
212
+ };
213
+ }
214
+ if (!isOptionToken(arg)) {
215
+ return null;
216
+ }
217
+ const nextArg = argv[index + 1];
218
+ const optionHasInlineValue = arg.includes('=');
219
+ const nextArgCouldBeOptionValue = nextArg && !isOptionToken(nextArg) && !this.isDefined(nextArg, 'commands');
220
+ if (!optionHasInlineValue && nextArgCouldBeOptionValue) {
221
+ index++;
222
+ }
223
+ }
224
+ return null;
225
+ }
200
226
  async executeSubcommand(argv, parsedAlias, subcommand) {
201
227
  const currentScript = argv[1];
228
+ const subcommandName = subcommand.name;
202
229
  const extension = _nodePath.default.extname(currentScript);
203
230
  const baseScriptPath = extension ? currentScript.slice(0, -extension.length) : currentScript;
204
- const childScriptPath = extension ? `${baseScriptPath}-${subcommand}${extension}` : `${baseScriptPath}-${subcommand}`;
231
+ const childScriptPath = extension ? `${baseScriptPath}-${subcommandName}${extension}` : `${baseScriptPath}-${subcommandName}`;
205
232
  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) : [];
233
+ let childArgs = [...parsedAlias.argv.slice(2, subcommand.index), ...parsedAlias.argv.slice(subcommand.index + 1)];
210
234
  if (aliasFromRawArgv) {
211
235
  childArgs = [aliasFromRawArgv, ...childArgs];
212
236
  }
@@ -217,7 +241,7 @@ class CommanderArgsCompat {
217
241
  env: process.env
218
242
  });
219
243
  } else {
220
- const fallbackCommand = `${_nodePath.default.basename(baseScriptPath)}-${subcommand}`;
244
+ const fallbackCommand = `${_nodePath.default.basename(baseScriptPath)}-${subcommandName}`;
221
245
  if (process.env.VIP_CLI_SEA_MODE === '1' && (0, _internalBinLoader.hasInternalBin)(fallbackCommand)) {
222
246
  process.argv = [process.argv[0], process.argv[1], ...childArgs];
223
247
  const loaded = await (0, _internalBinLoader.loadInternalBin)(fallbackCommand);
@@ -256,8 +280,9 @@ CommanderArgsCompat.prototype.argv = async function (argv, cb) {
256
280
  const options = this.parse(parsedAlias.argv);
257
281
 
258
282
  // If there's a sub-command, run that instead
259
- if (this.isDefined(this.sub[0], 'commands')) {
260
- await this.executeSubcommand(argv, parsedAlias, this.sub[0]);
283
+ const dispatchSubcommand = this.findSubcommand(parsedAlias.argv);
284
+ if (dispatchSubcommand) {
285
+ await this.executeSubcommand(argv, parsedAlias, dispatchSubcommand);
261
286
  return {};
262
287
  }
263
288
  if (_opts.format && !options.format) {
@@ -267,11 +267,12 @@ function parseComponentForInfo(component) {
267
267
  async function showLogs(lando, slug, options = {}) {
268
268
  debug('Will display logs command on env', slug, 'with options', options);
269
269
  const instancePath = getEnvironmentPath(slug);
270
- debug('Instance path for', slug, 'is:', instancePath);
270
+ debug('Instance path for %s is %s', slug, instancePath);
271
271
  if (options.service) {
272
- const appInfo = await (0, _devEnvironmentLando.landoInfo)(lando, instancePath);
273
- if (!appInfo.services.includes(options.service)) {
274
- throw new _userError.default(`Service '${options.service}' not found. Please choose from one: ${appInfo.services.toString()}`);
272
+ const application = await (0, _devEnvironmentLando.getLandoApplication)(lando, instancePath);
273
+ const services = application.info.map(service => service.service);
274
+ if (!services.includes(options.service)) {
275
+ throw new _userError.default(`Service '${options.service}' not found. Please choose from: ${services.join(', ')}`);
275
276
  }
276
277
  }
277
278
  return (0, _devEnvironmentLando.landoLogs)(lando, instancePath, options);
@@ -3,6 +3,7 @@
3
3
  exports.__esModule = true;
4
4
  exports.bootstrapLando = bootstrapLando;
5
5
  exports.checkEnvHealth = checkEnvHealth;
6
+ exports.getLandoApplication = getLandoApplication;
6
7
  exports.getProxyContainer = getProxyContainer;
7
8
  exports.isContainerRunning = isContainerRunning;
8
9
  exports.isEnvUp = isEnvUp;
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@automattic/vip",
3
- "version": "4.0.0",
3
+ "version": "4.0.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@automattic/vip",
9
- "version": "4.0.0",
9
+ "version": "4.0.1",
10
10
  "hasInstallScript": true,
11
11
  "license": "MIT",
12
12
  "dependencies": {
@@ -212,9 +212,9 @@
212
212
  }
213
213
  },
214
214
  "node_modules/@automattic/vip-search-replace": {
215
- "version": "2.0.0",
216
- "resolved": "https://registry.npmjs.org/@automattic/vip-search-replace/-/vip-search-replace-2.0.0.tgz",
217
- "integrity": "sha512-i1d3/KCK0sVgNjsJAV4UlMnC51AypLDfX8iEWTDLBiSR3wEvSWMSftF3f7yK46VdbBXB5zDvnVM48kFvASW9Ig==",
215
+ "version": "2.0.1",
216
+ "resolved": "https://registry.npmjs.org/@automattic/vip-search-replace/-/vip-search-replace-2.0.1.tgz",
217
+ "integrity": "sha512-awcVa6V9RDc2vCd2UpqNDtmgJb51U3788A9QgLoiFahhztgR8ngV11e9gqhYOG5CtI/CGSv7X9KIrr6hazzCjg==",
218
218
  "cpu": [
219
219
  "ia32",
220
220
  "x64",
@@ -14329,9 +14329,9 @@
14329
14329
  }
14330
14330
  },
14331
14331
  "node_modules/tar": {
14332
- "version": "7.5.13",
14333
- "resolved": "https://registry.npmjs.org/tar/-/tar-7.5.13.tgz",
14334
- "integrity": "sha512-tOG/7GyXpFevhXVh8jOPJrmtRpOTsYqUIkVdVooZYJS/z8WhfQUX8RJILmeuJNinGAMSu1veBr4asSHFt5/hng==",
14332
+ "version": "7.5.15",
14333
+ "resolved": "https://registry.npmjs.org/tar/-/tar-7.5.15.tgz",
14334
+ "integrity": "sha512-dzGK0boVlC4W5QFuQN1EFSl3bIDYsk7Tj40U6eIBnK2k/8ml7TZ5agbI5j5+qnoVcAA+rNtBml8SEiLxZpNqRQ==",
14335
14335
  "license": "BlueOak-1.0.0",
14336
14336
  "dependencies": {
14337
14337
  "@isaacs/fs-minipass": "^4.0.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automattic/vip",
3
- "version": "4.0.0",
3
+ "version": "4.0.1",
4
4
  "description": "The VIP Javascript library & CLI",
5
5
  "main": "index.js",
6
6
  "bin": {