@percy/cli-command 1.9.1 → 1.10.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/README.md CHANGED
@@ -171,9 +171,6 @@ option, if the environment variable `PERCY_ENABLE` is `0`, the callback _will no
171
171
  instance (and can act accordingly).
172
172
 
173
173
  - `percy` — Enables creation of a `@percy/core` instance initialized with provided options.
174
- - `discoveryFlags` — When `false` prevents percy discovery flags from being accepted, but will
175
- still allow other percy flags such as `--config` and `--dry-run`.
176
- - `...` — All other options are passed along to the new percy instance.
177
174
 
178
175
  #### Config
179
176
 
package/dist/command.js CHANGED
@@ -22,9 +22,14 @@ function withBuiltIns(definition) {
22
22
 
23
23
 
24
24
  if (def.percy && def.percy !== true) {
25
- builtInFlags.PERCY.forEach(addDedupedFlag); // maybe include percy discovery flags
25
+ builtInFlags.PERCY.forEach(addDedupedFlag); // maybe include percy server flags
26
26
 
27
- if (def.percy.discoveryFlags !== false) {
27
+ if (def.percy.server === true) {
28
+ builtInFlags.SERVER.forEach(addDedupedFlag);
29
+ } // maybe include percy discovery flags
30
+
31
+
32
+ if (def.percy.skipDiscovery !== true) {
28
33
  builtInFlags.DISCOVERY.forEach(addDedupedFlag);
29
34
  }
30
35
  } // always add global built-in flags
@@ -78,12 +83,12 @@ async function runCommandWithContext(parsed) {
78
83
  if (def.percy) {
79
84
  let {
80
85
  Percy
81
- } = await import('@percy/core'); // set defaults and prune preconfiguraton options
86
+ } = await import('@percy/core'); // shallow merge with default options
82
87
 
83
- let conf = del({
88
+ let conf = {
84
89
  server: false,
85
90
  ...def.percy
86
- }, 'discoveryFlags');
91
+ };
87
92
  if (pkg) conf.clientInfo || (conf.clientInfo = `${pkg.name}/${pkg.version}`);
88
93
  conf.environmentInfo || (conf.environmentInfo = `node/${process.version}`);
89
94
  Object.defineProperty(context, 'percy', {
package/dist/flags.js CHANGED
@@ -40,6 +40,17 @@ export const dryRun = {
40
40
  group: 'Percy',
41
41
  short: 'd'
42
42
  };
43
+ export const port = {
44
+ name: 'port',
45
+ description: 'Local CLI server port',
46
+ env: 'PERCY_SERVER_PORT',
47
+ percyrc: 'port',
48
+ type: 'number',
49
+ parse: Number,
50
+ default: 5338,
51
+ group: 'Percy',
52
+ short: 'P'
53
+ };
43
54
  export const allowedHostnames = {
44
55
  name: 'allowed-hostname',
45
56
  description: 'Allowed hostnames to capture in asset discovery',
@@ -82,4 +93,7 @@ export const debug = {
82
93
 
83
94
  export const GLOBAL = [verbose, quiet, silent];
84
95
  export const PERCY = [config, dryRun];
85
- export const DISCOVERY = [allowedHostnames, disallowedHostnames, networkIdleTimeout, disableCache, debug];
96
+ export const SERVER = [port];
97
+ export const DISCOVERY = [allowedHostnames, disallowedHostnames, networkIdleTimeout, disableCache, debug]; // export the namespace as the default
98
+
99
+ export * as default from './flags.js';
package/dist/help.js CHANGED
@@ -51,13 +51,15 @@ function commandUsage(command) {
51
51
  } // Helper to return an array of visible command usage-description pairs.
52
52
 
53
53
 
54
- async function visibleCommands(command, help) {
54
+ async function visibleCommands(command, nested) {
55
55
  let commands = command.definition.commands ?? [];
56
56
  if (typeof commands === 'function') commands = await commands();
57
57
  let visible = [];
58
58
 
59
59
  for (let cmd of commands) {
60
- // create parent references and format subcommand names
60
+ // skip hidden commands entirely
61
+ if (cmd.definition.hidden) continue; // create parent references and format subcommand names
62
+
61
63
  let name = command.parent ? `${command.name}:${cmd.name}` : cmd.name;
62
64
  cmd = { ...cmd,
63
65
  name,
@@ -69,16 +71,16 @@ async function visibleCommands(command, help) {
69
71
  description
70
72
  } = cmd.definition;
71
73
  visible.push([commandUsage(cmd), description]);
72
- } // include visible subcommands without their implicit help
74
+ } // include visible subcommands, but not deeply nested subcommands
73
75
 
74
76
 
75
- if (cmd.definition.commands) {
76
- visible.push(...(await visibleCommands(cmd, false)));
77
+ if (!nested && cmd.definition.commands) {
78
+ visible.push(...(await visibleCommands(cmd, true)));
77
79
  }
78
80
  } // include implicit help if there are visible commands
79
81
 
80
82
 
81
- if (help !== false && visible.length) {
83
+ if (!nested && visible.length) {
82
84
  visible.push(['help [command]', 'Display command help']);
83
85
  }
84
86
 
package/dist/parse.js CHANGED
@@ -45,7 +45,7 @@ async function maybeParseCommand(input, parsed) {
45
45
  let command;
46
46
 
47
47
  for (let name of names) {
48
- var _parent$definition$co;
48
+ var _parent$definition$co, _command;
49
49
 
50
50
  let parent = command || parsed.command; // find any nested command by name
51
51
 
@@ -56,7 +56,11 @@ async function maybeParseCommand(input, parsed) {
56
56
  command = await normalizeCommand(command, {
57
57
  name,
58
58
  parent
59
- });
59
+ }); // some hidden commands should produce warnings when used
60
+
61
+ if (typeof ((_command = command) === null || _command === void 0 ? void 0 : _command.definition.hidden) === 'string') {
62
+ logger('cli').warn(`\nWarning: ${command.definition.hidden}\n`);
63
+ }
60
64
  }
61
65
 
62
66
  if (command) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@percy/cli-command",
3
- "version": "1.9.1",
3
+ "version": "1.10.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -24,6 +24,7 @@
24
24
  "type": "module",
25
25
  "exports": {
26
26
  ".": "./dist/index.js",
27
+ "./flags": "./dist/flags.js",
27
28
  "./utils": "./dist/utils.js",
28
29
  "./test/helpers": "./test/helpers.js"
29
30
  },
@@ -34,9 +35,9 @@
34
35
  "test:coverage": "yarn test --coverage"
35
36
  },
36
37
  "dependencies": {
37
- "@percy/config": "1.9.1",
38
- "@percy/core": "1.9.1",
39
- "@percy/logger": "1.9.1"
38
+ "@percy/config": "1.10.0",
39
+ "@percy/core": "1.10.0",
40
+ "@percy/logger": "1.10.0"
40
41
  },
41
- "gitHead": "b2ff5100698488c8bf8c681972f4f2b9a1e2055f"
42
+ "gitHead": "a6934eda4fc3b84845ae606d7f5a901f25e0a56f"
42
43
  }