@percy/cli-command 1.26.2 → 1.26.3-alpha.4

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/command.js CHANGED
@@ -1,3 +1,8 @@
1
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
3
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
5
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
1
6
  import logger from '@percy/logger';
2
7
  import PercyConfig from '@percy/config';
3
8
  import { set, del } from '@percy/config/utils';
@@ -9,18 +14,15 @@ import parse from './parse.js';
9
14
 
10
15
  // Copies a command definition and adds built-in flags and config options.
11
16
  function withBuiltIns(definition) {
12
- let def = {
13
- ...definition
14
- };
15
- def.flags = [...(def.flags ?? [])];
17
+ var _def$flags, _def$config$schemas, _def$config$migration;
18
+ let def = _objectSpread({}, definition);
19
+ def.flags = [...((_def$flags = def.flags) !== null && _def$flags !== void 0 ? _def$flags : [])];
16
20
 
17
21
  // ensure built-ins aren't already overridden
18
22
  let addDedupedFlag = flag => {
19
23
  if (!def.flags.find(f => f.name === flag.name)) {
20
24
  let short = def.flags.find(f => f.short === flag.short);
21
- def.flags.push(short ? del({
22
- ...flag
23
- }, 'short') : flag);
25
+ def.flags.push(short ? del(_objectSpread({}, flag), 'short') : flag);
24
26
  }
25
27
  };
26
28
 
@@ -43,11 +45,9 @@ function withBuiltIns(definition) {
43
45
  builtInFlags.GLOBAL.forEach(addDedupedFlag);
44
46
 
45
47
  // copy any existing config before adding to it
46
- def.config = {
47
- ...def.config
48
- };
49
- def.config.schemas = [...(def.config.schemas ?? [])];
50
- def.config.migrations = [...(def.config.migrations ?? [])];
48
+ def.config = _objectSpread({}, def.config);
49
+ def.config.schemas = [...((_def$config$schemas = def.config.schemas) !== null && _def$config$schemas !== void 0 ? _def$config$schemas : [])];
50
+ def.config.migrations = [...((_def$config$migration = def.config.migrations) !== null && _def$config$migration !== void 0 ? _def$config$migration : [])];
51
51
 
52
52
  // add percy specific built-in config options
53
53
  if (def.percy) {
@@ -94,10 +94,9 @@ async function runCommandWithContext(parsed) {
94
94
  } = await import('@percy/core');
95
95
 
96
96
  // shallow merge with default options
97
- let conf = {
98
- server: false,
99
- ...def.percy
100
- };
97
+ let conf = _objectSpread({
98
+ server: false
99
+ }, def.percy);
101
100
  if (pkg) conf.clientInfo || (conf.clientInfo = `${pkg.name}/${pkg.version}`);
102
101
  conf.environmentInfo || (conf.environmentInfo = `node/${process.version}`);
103
102
  Object.defineProperty(context, 'percy', {
@@ -169,7 +168,8 @@ export function command(name, definition, callback) {
169
168
 
170
169
  // exit when appropriate
171
170
  if (err.exitCode !== 0) {
172
- err.exitCode ?? (err.exitCode = 1);
171
+ var _err$exitCode;
172
+ (_err$exitCode = err.exitCode) !== null && _err$exitCode !== void 0 ? _err$exitCode : err.exitCode = 1;
173
173
  err.message || (err.message = `EEXIT: ${err.exitCode}`);
174
174
  if (definition.exitOnError) {
175
175
  process.exit(err.exitCode);
package/dist/help.js CHANGED
@@ -1,3 +1,8 @@
1
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
3
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
5
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
1
6
  import logger from '@percy/logger';
2
7
 
3
8
  // Helper to return an argument's description including it's default value.
@@ -11,7 +16,8 @@ function argumentDescription(arg) {
11
16
 
12
17
  // Helper to return an array of visible argument usage-description pairs.
13
18
  async function visibleArguments(command) {
14
- let args = command.definition.args ?? [];
19
+ var _command$definition$a;
20
+ let args = (_command$definition$a = command.definition.args) !== null && _command$definition$a !== void 0 ? _command$definition$a : [];
15
21
 
16
22
  // not hidden and not deprecated
17
23
  let visible = args.reduce((visible, arg) => {
@@ -50,7 +56,8 @@ function commandUsage(command) {
50
56
 
51
57
  // Helper to return an array of visible command usage-description pairs.
52
58
  async function visibleCommands(command, nested) {
53
- let commands = command.definition.commands ?? [];
59
+ var _command$definition$c;
60
+ let commands = (_command$definition$c = command.definition.commands) !== null && _command$definition$c !== void 0 ? _command$definition$c : [];
54
61
  if (typeof commands === 'function') commands = await commands();
55
62
  let visible = [];
56
63
  for (let cmd of commands) {
@@ -59,11 +66,10 @@ async function visibleCommands(command, nested) {
59
66
 
60
67
  // create parent references and format subcommand names
61
68
  let name = command.parent ? `${command.name}:${cmd.name}` : cmd.name;
62
- cmd = {
63
- ...cmd,
69
+ cmd = _objectSpread(_objectSpread({}, cmd), {}, {
64
70
  name,
65
71
  parent: command
66
- };
72
+ });
67
73
 
68
74
  // commands without callbacks are not visible themselves
69
75
  if (cmd.callback) {
@@ -213,10 +219,9 @@ export async function formatHelp(command) {
213
219
  top = top.parent;
214
220
  }
215
221
  if (top) name = `${top.name} ${name}`;
216
- command = {
217
- ...command,
222
+ command = _objectSpread(_objectSpread({}, command), {}, {
218
223
  name
219
- };
224
+ });
220
225
 
221
226
  // include command description and own usage
222
227
  if (description) output.push(wrapString(description, maxWidth), '');
package/dist/legacy.js CHANGED
@@ -1,3 +1,12 @@
1
+ const _excluded = ["name"],
2
+ _excluded2 = ["char", "deprecated"];
3
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
4
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
5
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
6
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
7
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
8
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
9
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
1
10
  import { merge } from '@percy/config/utils';
2
11
  import { command } from './command.js';
3
12
 
@@ -8,42 +17,38 @@ export const legacyFlags = {
8
17
  discovery: {
9
18
  __percy__: {}
10
19
  },
11
- string: def => ({
12
- type: 'string',
13
- ...def
14
- }),
15
- boolean: def => ({
16
- type: 'boolean',
17
- ...def
18
- }),
19
- integer: def => ({
20
- type: 'integer',
21
- ...def
22
- })
20
+ string: def => _objectSpread({
21
+ type: 'string'
22
+ }, def),
23
+ boolean: def => _objectSpread({
24
+ type: 'boolean'
25
+ }, def),
26
+ integer: def => _objectSpread({
27
+ type: 'integer'
28
+ }, def)
23
29
  };
24
30
 
25
31
  // Maps a legacy arg that might have alternate properties
26
32
  function legacyArg(legacy) {
27
33
  let {
28
- name,
29
- ...def
30
- } = legacy;
34
+ name
35
+ } = legacy,
36
+ def = _objectWithoutProperties(legacy, _excluded);
31
37
  // do not camelcase legacy attribute names
32
38
  def.attribute = name;
33
39
  // add name back to mapped options
34
- return {
35
- name,
36
- ...def
37
- };
40
+ return _objectSpread({
41
+ name
42
+ }, def);
38
43
  }
39
44
 
40
45
  // Maps a legacy flag that might have alternate properties
41
46
  function legacyFlag(name, legacy) {
42
47
  let {
43
- char: short,
44
- deprecated,
45
- ...def
46
- } = legacy;
48
+ char: short,
49
+ deprecated
50
+ } = legacy,
51
+ def = _objectWithoutProperties(legacy, _excluded2);
47
52
  // generic legacy type looks odd in help output
48
53
  if (def.type === 'option') def.type = 'value';
49
54
  // do not camelcase legacy attribute names
@@ -60,25 +65,24 @@ function legacyFlag(name, legacy) {
60
65
  }
61
66
 
62
67
  // add name and mapped short option
63
- return {
68
+ return _objectSpread({
64
69
  name,
65
- short,
66
- ...def
67
- };
70
+ short
71
+ }, def);
68
72
  }
69
73
 
70
74
  // Maps a legacy class-based command to the new functional syntax
71
75
  export function legacyCommand(name, constructor) {
72
- var _constructor$args, _constructor$flags;
76
+ var _constructor$args, _constructor$flags, _constructor$flags$__, _constructor$flags2;
73
77
  let runner = command(name, {
74
78
  description: constructor.description,
75
79
  examples: constructor.examples,
76
80
  // map legacy args and flags
77
81
  args: (_constructor$args = constructor.args) === null || _constructor$args === void 0 ? void 0 : _constructor$args.map(legacyArg),
78
- flags: Object.entries(constructor.flags ?? []).map(([name, def]) => legacyFlag(name, def)).filter(({
82
+ flags: Object.entries((_constructor$flags = constructor.flags) !== null && _constructor$flags !== void 0 ? _constructor$flags : []).map(([name, def]) => legacyFlag(name, def)).filter(({
79
83
  name
80
84
  }) => name !== '__percy__'),
81
- percy: ((_constructor$flags = constructor.flags) === null || _constructor$flags === void 0 ? void 0 : _constructor$flags.__percy__) ?? true,
85
+ percy: (_constructor$flags$__ = (_constructor$flags2 = constructor.flags) === null || _constructor$flags2 === void 0 ? void 0 : _constructor$flags2.__percy__) !== null && _constructor$flags$__ !== void 0 ? _constructor$flags$__ : true,
82
86
  loose: constructor.strict === false,
83
87
  legacy: true
84
88
  }, async function* (ctx) {
package/dist/parse.js CHANGED
@@ -1,3 +1,9 @@
1
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
3
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
5
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
6
+ function _objectDestructuringEmpty(obj) { if (obj == null) throw new TypeError("Cannot destructure " + obj); }
1
7
  import logger from '@percy/logger';
2
8
  import { camelcase } from '@percy/config/utils';
3
9
  import { flagUsage } from './help.js';
@@ -29,7 +35,7 @@ function isFlag(option) {
29
35
  // options. If a command is found, parsed output is updated accordingly and the current input option
30
36
  // is removed from further processing. An implicit help command is also supported.
31
37
  async function maybeParseCommand(input, parsed) {
32
- var _input$;
38
+ var _input$0$split, _input$;
33
39
  // a flag, no defined commands, or already parsed other options
34
40
  if (isFlag(input[0]) || !parsed.command.definition.commands || parsed.operators.size || parsed.argv.length) {
35
41
  return;
@@ -42,7 +48,7 @@ async function maybeParseCommand(input, parsed) {
42
48
  }
43
49
 
44
50
  // nested commands can be a single argument with command names separated by colons (:)
45
- let names = ((_input$ = input[0]) === null || _input$ === void 0 ? void 0 : _input$.split(':')) ?? [];
51
+ let names = (_input$0$split = (_input$ = input[0]) === null || _input$ === void 0 ? void 0 : _input$.split(':')) !== null && _input$0$split !== void 0 ? _input$0$split : [];
46
52
  let command;
47
53
  for (let name of names) {
48
54
  var _parent$definition$co, _command;
@@ -136,7 +142,8 @@ async function maybeParseFlag(input, parsed) {
136
142
  if (flag.type === 'integer') value = parseInt(value, 10);
137
143
  if (flag.parse) value = await flag.parse(value);
138
144
  if (flag.multiple) {
139
- value = (parsed.operators.get(flag) ?? []).concat(value);
145
+ var _parsed$operators$get;
146
+ value = ((_parsed$operators$get = parsed.operators.get(flag)) !== null && _parsed$operators$get !== void 0 ? _parsed$operators$get : []).concat(value);
140
147
  }
141
148
 
142
149
  // add this flag to the set of parsed operators
@@ -162,11 +169,11 @@ async function maybeParseFlag(input, parsed) {
162
169
  // returning true if any defined argument was found. Arguments are matched according to their
163
170
  // respective index and command-line position.
164
171
  async function maybeParseArg(input, parsed) {
165
- var _parsed$command$defin;
172
+ var _parsed$__args_index_, _parsed$command$defin;
166
173
  if (isFlag(input[0])) return;
167
174
 
168
175
  // the argument index needs to be tracked since flag options can precede argument options
169
- let index = parsed.__args_index__ ?? (parsed.__args_index__ = 0);
176
+ let index = (_parsed$__args_index_ = parsed.__args_index__) !== null && _parsed$__args_index_ !== void 0 ? _parsed$__args_index_ : parsed.__args_index__ = 0;
170
177
 
171
178
  // there are arguments left to parse
172
179
  if (index < ((_parsed$command$defin = parsed.command.definition.args) === null || _parsed$command$defin === void 0 ? void 0 : _parsed$command$defin.length)) {
@@ -273,11 +280,12 @@ function validateExclusiveFlag(flag, parsed) {
273
280
  // mapped to the replacement flag's attribute name. If a deprecated option is found in the provided
274
281
  // operators, a deprecation warning will be logged with any recommendation message.
275
282
  function attributeName(option, parsed) {
283
+ var _parsed$operators$get2;
276
284
  let {
277
285
  attribute,
278
286
  deprecated
279
287
  } = option;
280
- let value = parsed.operators.get(option) ?? option.default;
288
+ let value = (_parsed$operators$get2 = parsed.operators.get(option)) !== null && _parsed$operators$get2 !== void 0 ? _parsed$operators$get2 : option.default;
281
289
  // the option's attribute name might be contingent on it's value
282
290
  let name = typeof attribute === 'function' ? attribute(value) : attribute;
283
291
  // default the attribute name to the camelcase name or short character
@@ -311,9 +319,8 @@ function attributeName(option, parsed) {
311
319
  async function normalizeCommand(command, properties) {
312
320
  var _ref;
313
321
  // shallow copy command definition
314
- let {
315
- ...definition
316
- } = command.definition;
322
+ let _command$definition = command.definition,
323
+ definition = Object.assign({}, (_objectDestructuringEmpty(_command$definition), _command$definition));
317
324
 
318
325
  // evaluate commands if needed
319
326
  if (typeof definition.commands === 'function') {
@@ -321,11 +328,9 @@ async function normalizeCommand(command, properties) {
321
328
  }
322
329
 
323
330
  // create a shallow copy with additional properties
324
- let normalized = {
325
- ...command,
326
- ...properties,
331
+ let normalized = _objectSpread(_objectSpread(_objectSpread({}, command), properties), {}, {
327
332
  definition
328
- };
333
+ });
329
334
 
330
335
  // inherit parent package information by default
331
336
  normalized.packageInformation || (normalized.packageInformation = (_ref = (properties === null || properties === void 0 ? void 0 : properties.parent) || command.parent) === null || _ref === void 0 ? void 0 : _ref.packageInformation);
@@ -377,7 +382,8 @@ export async function parse(command, argv) {
377
382
  }
378
383
 
379
384
  // validate and map defined args
380
- for (let arg of parsed.command.definition.args ?? []) {
385
+ for (let arg of (_parsed$command$defin2 = parsed.command.definition.args) !== null && _parsed$command$defin2 !== void 0 ? _parsed$command$defin2 : []) {
386
+ var _parsed$command$defin2;
381
387
  // collect last-minute env info
382
388
  await maybeParseEnv(arg, parsed);
383
389
  if (parsed.operators.has(arg)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@percy/cli-command",
3
- "version": "1.26.2",
3
+ "version": "1.26.3-alpha.4",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -9,7 +9,7 @@
9
9
  },
10
10
  "publishConfig": {
11
11
  "access": "public",
12
- "tag": "latest"
12
+ "tag": "alpha"
13
13
  },
14
14
  "files": [
15
15
  "dist",
@@ -36,9 +36,9 @@
36
36
  "test:coverage": "yarn test --coverage"
37
37
  },
38
38
  "dependencies": {
39
- "@percy/config": "1.26.2",
40
- "@percy/core": "1.26.2",
41
- "@percy/logger": "1.26.2"
39
+ "@percy/config": "1.26.3-alpha.4",
40
+ "@percy/core": "1.26.3-alpha.4",
41
+ "@percy/logger": "1.26.3-alpha.4"
42
42
  },
43
- "gitHead": "f97b6c463109420a4045dc0396bf9d429c2dc77d"
43
+ "gitHead": "d89ab97b8d5169eafd3eb42bdbbef41a2ac624ba"
44
44
  }