@atlaskit/ads-cli 0.4.2 → 0.6.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.
Files changed (48) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/README.md +62 -10
  3. package/bin/ads-cli.js +5 -1
  4. package/dist/cjs/atlas-cli.js +4 -1
  5. package/dist/cjs/cli.js +368 -70
  6. package/dist/cjs/commands/build-manifest.js +1 -2
  7. package/dist/cjs/commands/cli-metadata.js +2 -1
  8. package/dist/cjs/commands/definitions.js +100 -16
  9. package/dist/cjs/output/format-disambiguation.js +3 -1
  10. package/dist/cjs/output/format-grouped-results.js +6 -2
  11. package/dist/cjs/output/format-human-result.js +33 -0
  12. package/dist/cjs/output/format-manifest.js +5 -3
  13. package/dist/cjs/output/format-results.js +25 -18
  14. package/dist/cjs/output/write-human-result.js +8 -10
  15. package/dist/es2019/atlas-cli.js +4 -1
  16. package/dist/es2019/cli.js +273 -29
  17. package/dist/es2019/commands/build-manifest.js +1 -2
  18. package/dist/es2019/commands/cli-metadata.js +1 -0
  19. package/dist/es2019/commands/definitions.js +77 -6
  20. package/dist/es2019/output/format-disambiguation.js +3 -2
  21. package/dist/es2019/output/format-grouped-results.js +5 -2
  22. package/dist/es2019/output/format-human-result.js +28 -0
  23. package/dist/es2019/output/format-manifest.js +6 -3
  24. package/dist/es2019/output/format-results.js +25 -18
  25. package/dist/es2019/output/write-human-result.js +8 -9
  26. package/dist/esm/atlas-cli.js +4 -1
  27. package/dist/esm/cli.js +369 -71
  28. package/dist/esm/commands/build-manifest.js +1 -2
  29. package/dist/esm/commands/cli-metadata.js +1 -0
  30. package/dist/esm/commands/definitions.js +100 -16
  31. package/dist/esm/output/format-disambiguation.js +3 -1
  32. package/dist/esm/output/format-grouped-results.js +6 -2
  33. package/dist/esm/output/format-human-result.js +27 -0
  34. package/dist/esm/output/format-manifest.js +5 -3
  35. package/dist/esm/output/format-results.js +26 -18
  36. package/dist/esm/output/write-human-result.js +8 -9
  37. package/dist/types/cli.d.ts +10 -1
  38. package/dist/types/commands/build-manifest.d.ts +1 -2
  39. package/dist/types/commands/cli-metadata.d.ts +1 -0
  40. package/dist/types/commands/types.d.ts +28 -1
  41. package/dist/types/output/format-disambiguation.d.ts +1 -1
  42. package/dist/types/output/format-grouped-results.d.ts +2 -1
  43. package/dist/types/output/format-human-result.d.ts +17 -0
  44. package/dist/types/output/format-manifest.d.ts +2 -1
  45. package/dist/types/output/format-results.d.ts +4 -3
  46. package/dist/types/output/write-human-result.d.ts +2 -2
  47. package/dist/types/parse-args.d.ts +1 -1
  48. package/package.json +1 -1
@@ -23,6 +23,8 @@ var _formatToken = require("../output/format-token");
23
23
  var _parseLintRuleRecords = require("../output/parse-lint-rule-records");
24
24
  var _buildManifest = require("./build-manifest");
25
25
  var _getVersion = require("./get-version");
26
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
27
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
26
28
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
27
29
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
28
30
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } /**
@@ -341,19 +343,20 @@ var makeItemCommand = function makeItemCommand(_ref3) {
341
343
  envelopeType: function envelopeType(input) {
342
344
  return input.flags.all ? listTool.envelopeType : name;
343
345
  },
344
- formatHuman: function formatHuman(data) {
346
+ formatHuman: function formatHuman(data, _ref4) {
347
+ var invocation = _ref4.invocation;
345
348
  // Ambiguous lookup → render the "did you mean?" list; otherwise the item detail view.
346
349
  if ((0, _disambiguation.isDisambiguation)(data)) {
347
- return (0, _formatDisambiguation.formatDisambiguation)(data);
350
+ return (0, _formatDisambiguation.formatDisambiguation)(data, invocation);
348
351
  }
349
352
  return _formatHuman(data);
350
353
  },
351
354
  // Turn the ranked candidate window into an exact match, a lone match, or a disambiguation
352
355
  // marker. Skipped for `--all` (that path returns the full array untouched).
353
- transform: function transform(_ref4) {
356
+ transform: function transform(_ref5) {
354
357
  var _input$positionals$;
355
- var data = _ref4.data,
356
- input = _ref4.input;
358
+ var data = _ref5.data,
359
+ input = _ref5.input;
357
360
  if (input.flags.all) {
358
361
  return data;
359
362
  }
@@ -467,6 +470,72 @@ var resolveUnifiedSearch = function resolveUnifiedSearch(input) {
467
470
  };
468
471
  };
469
472
 
473
+ /**
474
+ * Split a batch invocation into argv groups introduced by repeated `--command` flags. The groups
475
+ * remain tokenized, so child commands can be routed through the existing parser without evaluating
476
+ * shell strings.
477
+ */
478
+ var resolveBatch = function resolveBatch(input) {
479
+ var _input$rawArgs;
480
+ var rawArgs = (_input$rawArgs = input.rawArgs) !== null && _input$rawArgs !== void 0 ? _input$rawArgs : [];
481
+ var batchIndex = rawArgs.indexOf('batch');
482
+ var tokens = rawArgs.slice(batchIndex + 1).filter(function (token) {
483
+ return token !== '--json';
484
+ });
485
+ if (tokens.length === 0) {
486
+ return {
487
+ error: 'At least one command request is required.'
488
+ };
489
+ }
490
+ if (tokens[0] !== '--command') {
491
+ return {
492
+ error: 'Each batch request must start with `--command`.'
493
+ };
494
+ }
495
+ var requests = [];
496
+ // The leading `--command` is validated above, so every remaining token either closes the open
497
+ // request or appends to it. Seeding the accumulator here keeps it non-nullable, which is what
498
+ // lets the loop stay free of "no request open yet" checks.
499
+ var current = [];
500
+ var _iterator = _createForOfIteratorHelper(tokens.slice(1)),
501
+ _step;
502
+ try {
503
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
504
+ var token = _step.value;
505
+ if (token === '--command') {
506
+ if (current.length === 0) {
507
+ return {
508
+ error: '`--command` must be followed by a non-empty command request.'
509
+ };
510
+ }
511
+ requests.push({
512
+ argv: current
513
+ });
514
+ current = [];
515
+ continue;
516
+ }
517
+ current.push(token);
518
+ }
519
+ } catch (err) {
520
+ _iterator.e(err);
521
+ } finally {
522
+ _iterator.f();
523
+ }
524
+ if (current.length === 0) {
525
+ return {
526
+ error: '`--command` must be followed by a non-empty command request.'
527
+ };
528
+ }
529
+ requests.push({
530
+ argv: current
531
+ });
532
+ return {
533
+ tools: [],
534
+ batch: requests,
535
+ meta: {}
536
+ };
537
+ };
538
+
470
539
  /**
471
540
  * The full set of CLI commands. Order here is the order shown by `manifest` and `--help`.
472
541
  */
@@ -499,9 +568,9 @@ var commands = exports.commands = [{
499
568
  var _resolveSearchType;
500
569
  return (_resolveSearchType = resolveSearchType(input.flags)) !== null && _resolveSearchType !== void 0 ? _resolveSearchType : undefined;
501
570
  },
502
- transform: function transform(_ref5) {
503
- var data = _ref5.data,
504
- input = _ref5.input;
571
+ transform: function transform(_ref6) {
572
+ var data = _ref6.data,
573
+ input = _ref6.input;
505
574
  return resolveSearchType(input.flags) === 'docs' ? (0, _createDocSearchResults.createDocSearchResults)({
506
575
  data: data,
507
576
  query: input.positionals.join(' ')
@@ -530,6 +599,22 @@ var commands = exports.commands = [{
530
599
  tool: searchKindTools[searchType]
531
600
  });
532
601
  }
602
+ }, {
603
+ name: 'batch',
604
+ description: 'Run multiple ADS CLI queries, including different command types, in one process.',
605
+ usage: 'batch [--json] --command <command> [args...] [--command <command> [args...]]...',
606
+ arguments: [],
607
+ flags: [{
608
+ name: 'command',
609
+ type: 'string[]',
610
+ description: 'A child command name followed by its arguments. Repeat once per child command.'
611
+ }],
612
+ examples: ['batch --command search button --type icon --command token space.200', 'batch --json --command component Button --command docs spacing'],
613
+ responseTypes: ['ads-cli/batch'],
614
+ envelopeType: function envelopeType() {
615
+ return 'batch';
616
+ },
617
+ resolve: resolveBatch
533
618
  }, makeItemCommand({
534
619
  kind: 'components',
535
620
  name: 'component',
@@ -561,16 +646,17 @@ var commands = exports.commands = [{
561
646
  },
562
647
  // Ambiguous fuzzy lookup → render the "did you mean?" list; otherwise print each rule's
563
648
  // Markdown `content` verbatim rather than JSON.
564
- formatHuman: function formatHuman(data) {
565
- return (0, _disambiguation.isDisambiguation)(data) ? (0, _formatDisambiguation.formatDisambiguation)(data) : (0, _formatLintRules.formatLintRules)(data);
649
+ formatHuman: function formatHuman(data, _ref7) {
650
+ var invocation = _ref7.invocation;
651
+ return (0, _disambiguation.isDisambiguation)(data) ? (0, _formatDisambiguation.formatDisambiguation)(data, invocation) : (0, _formatLintRules.formatLintRules)(data);
566
652
  },
567
653
  // Mirror the item commands: a fuzzy term that matches one rule exactly (or a lone match)
568
654
  // shows that rule's docs, but several matches with no exact name surface a disambiguation
569
655
  // list instead of dumping every rule's full Markdown. Skipped for bare `lint-rules` (which
570
656
  // intentionally returns every rule's content).
571
- transform: function transform(_ref6) {
572
- var data = _ref6.data,
573
- input = _ref6.input;
657
+ transform: function transform(_ref8) {
658
+ var data = _ref8.data,
659
+ input = _ref8.input;
574
660
  var terms = input.positionals;
575
661
  if (terms.length === 0) {
576
662
  return data;
@@ -784,9 +870,7 @@ var commands = exports.commands = [{
784
870
  resolve: function resolve() {
785
871
  return {
786
872
  data: (0, _buildManifest.buildManifest)(commands, (0, _getVersion.getVersion)()),
787
- meta: {
788
- schemaVersion: 1
789
- }
873
+ meta: {}
790
874
  };
791
875
  }
792
876
  }];
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.formatDisambiguation = void 0;
8
8
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
+ var _cliMetadata = require("../commands/cli-metadata");
9
10
  /**
10
11
  * Human-readable renderer for an ambiguous item lookup ("did you mean?").
11
12
  */
@@ -20,10 +21,11 @@ var formatDisambiguation = exports.formatDisambiguation = function formatDisambi
20
21
  var query = _ref.query,
21
22
  noun = _ref.noun,
22
23
  candidates = _ref.candidates;
24
+ var invocation = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _cliMetadata.CLI_BIN_NAME;
23
25
  var header = "Multiple ".concat(noun, "s match \"").concat(query, "\". Did you mean one of these?");
24
26
  var rows = candidates.map(function (candidate) {
25
27
  var hint = candidate.hint ? " ".concat(candidate.hint) : '';
26
- return " ".concat(candidate.name).concat(hint, "\n \u2192 ads-cli ").concat(candidate.followUp);
28
+ return " ".concat(candidate.name).concat(hint, "\n \u2192 ").concat(invocation, " ").concat(candidate.followUp);
27
29
  });
28
30
  return [header, ''].concat((0, _toConsumableArray2.default)(rows)).join('\n');
29
31
  };
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.formatGroupedResults = void 0;
7
+ var _cliMetadata = require("../commands/cli-metadata");
7
8
  var _formatResults = require("./format-results");
8
9
  /**
9
10
  * Sectioned compact renderer for grouped (multi-kind) results, e.g. unified `search`.
@@ -17,7 +18,9 @@ var _formatResults = require("./format-results");
17
18
  */
18
19
  var formatGroupedResults = exports.formatGroupedResults = function formatGroupedResults(_ref) {
19
20
  var groups = _ref.groups,
20
- totalCount = _ref.totalCount;
21
+ totalCount = _ref.totalCount,
22
+ _ref$invocation = _ref.invocation,
23
+ invocation = _ref$invocation === void 0 ? _cliMetadata.CLI_BIN_NAME : _ref$invocation;
21
24
  // Fixed display order, with human-friendly section titles.
22
25
  var sections = [{
23
26
  kind: 'components',
@@ -48,7 +51,8 @@ var formatGroupedResults = exports.formatGroupedResults = function formatGrouped
48
51
  var rendered = (0, _formatResults.formatCompactResults)({
49
52
  kind: kind,
50
53
  data: entries,
51
- showFollowUp: true
54
+ showFollowUp: true,
55
+ invocation: invocation
52
56
  });
53
57
  var body = rendered ? rendered.split('\n').slice(2).join('\n') : '';
54
58
  blocks.push('', "".concat(title, " (").concat(entries.length, "):"), '', body);
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.formatHumanResult = void 0;
8
+ var _chalk = _interopRequireDefault(require("chalk"));
9
+ /**
10
+ * Generic last-resort human formatting for a successful command result.
11
+ */
12
+
13
+ /**
14
+ * Render a successful result with the generic last-resort formatting, used when a command
15
+ * declares neither a compact result kind nor its own `formatHuman`.
16
+ *
17
+ * Structured data is pretty-printed as JSON (the underlying tools already return rich objects),
18
+ * while plain-string payloads such as guideline markdown are returned verbatim.
19
+ *
20
+ * Kept separate from the writer so callers that compose text rather than write it — notably
21
+ * `batch`, which concatenates one section per child — produce byte-identical output without
22
+ * duplicating these rules.
23
+ */
24
+ var formatHumanResult = exports.formatHumanResult = function formatHumanResult(_ref) {
25
+ var data = _ref.data;
26
+ if (typeof data === 'string') {
27
+ return data;
28
+ }
29
+ if (data === null || data === undefined) {
30
+ return _chalk.default.yellow('No results.');
31
+ }
32
+ return JSON.stringify(data, null, 2);
33
+ };
@@ -9,8 +9,10 @@ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
9
9
  /**
10
10
  * Format a scannable human catalog of the ADS CLI capability manifest.
11
11
  */
12
- var formatManifest = exports.formatManifest = function formatManifest(data) {
13
- if ((0, _typeof2.default)(data) !== 'object' || data === null || !('bin' in data) || typeof data.bin !== 'string' || !('version' in data) || typeof data.version !== 'string' || !('invocation' in data) || typeof data.invocation !== 'string' || !('commands' in data) || !Array.isArray(data.commands)) {
12
+
13
+ var formatManifest = exports.formatManifest = function formatManifest(data, _ref) {
14
+ var invocation = _ref.invocation;
15
+ if ((0, _typeof2.default)(data) !== 'object' || data === null || !('bin' in data) || typeof data.bin !== 'string' || !('version' in data) || typeof data.version !== 'string' || !('commands' in data) || !Array.isArray(data.commands)) {
14
16
  return null;
15
17
  }
16
18
  var commands = data.commands.flatMap(function (command) {
@@ -22,5 +24,5 @@ var formatManifest = exports.formatManifest = function formatManifest(data) {
22
24
  });
23
25
  var commandCount = commands.length;
24
26
  var commandLabel = commandCount === 1 ? 'command' : 'commands';
25
- return ["".concat(data.bin, " v").concat(data.version, " \u2014 ").concat(commandCount, " ").concat(commandLabel), '', commands.join('\n'), '', "Run `".concat(data.invocation, " manifest --json` for the full structured manifest.")].join('\n');
27
+ return ["".concat(data.bin, " v").concat(data.version, " \u2014 ").concat(commandCount, " ").concat(commandLabel), '', commands.join('\n'), '', "Run `".concat(invocation, " manifest --json` for the full structured manifest.")].join('\n');
26
28
  };
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.formatCompactResults = void 0;
8
8
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
+ var _cliMetadata = require("../commands/cli-metadata");
9
10
  /**
10
11
  * Compact, human-readable renderers for the structured search/list results.
11
12
  *
@@ -53,7 +54,7 @@ var truncate = function truncate(text) {
53
54
  };
54
55
 
55
56
  /**
56
- * Append a `→ ads-cli <command> <name>` drill-in hint beneath a row.
57
+ * Append a `→ <invocation> <command> <name>` drill-in hint beneath a row.
57
58
  *
58
59
  * Used for every `search` result, where the natural next step is to view that match in full.
59
60
  * `--all` listings omit it because echoing every row's own name would just be noise.
@@ -62,8 +63,9 @@ var withFollowUp = function withFollowUp(_ref) {
62
63
  var line = _ref.line,
63
64
  command = _ref.command,
64
65
  name = _ref.name,
65
- showFollowUp = _ref.showFollowUp;
66
- return showFollowUp ? "".concat(line, "\n \u2192 ads-cli ").concat(command, " ").concat(name) : line;
66
+ showFollowUp = _ref.showFollowUp,
67
+ invocation = _ref.invocation;
68
+ return showFollowUp ? "".concat(line, "\n \u2192 ").concat(invocation, " ").concat(command, " ").concat(name) : line;
67
69
  };
68
70
 
69
71
  /**
@@ -73,7 +75,7 @@ var withFollowUp = function withFollowUp(_ref) {
73
75
  * (`--all`, `--type`) or a titled section of grouped `search` — so the kind is always clear from
74
76
  * context and a tag would just be noise.
75
77
  */
76
- var formatComponentLine = function formatComponentLine(component, showFollowUp) {
78
+ var formatComponentLine = function formatComponentLine(component, showFollowUp, invocation) {
77
79
  var _component$name;
78
80
  var name = (_component$name = component.name) !== null && _component$name !== void 0 ? _component$name : '(unknown)';
79
81
  var pkg = component.package ? " ".concat(component.package) : '';
@@ -84,14 +86,15 @@ var formatComponentLine = function formatComponentLine(component, showFollowUp)
84
86
  line: "".concat(name).concat(pkg, " (").concat(meta, ")"),
85
87
  command: 'component',
86
88
  name: name,
87
- showFollowUp: showFollowUp
89
+ showFollowUp: showFollowUp,
90
+ invocation: invocation
88
91
  });
89
92
  };
90
93
 
91
94
  /**
92
95
  * Render one token as a compact `name = value` line.
93
96
  */
94
- var formatTokenLine = function formatTokenLine(tokenResult, showFollowUp) {
97
+ var formatTokenLine = function formatTokenLine(tokenResult, showFollowUp, invocation) {
95
98
  var _tokenResult$name;
96
99
  var name = (_tokenResult$name = tokenResult.name) !== null && _tokenResult$name !== void 0 ? _tokenResult$name : '(unknown)';
97
100
  // Some token values (e.g. motion easing curves) are very long; truncate so each token stays
@@ -101,14 +104,15 @@ var formatTokenLine = function formatTokenLine(tokenResult, showFollowUp) {
101
104
  line: line,
102
105
  command: 'token',
103
106
  name: name,
104
- showFollowUp: showFollowUp
107
+ showFollowUp: showFollowUp,
108
+ invocation: invocation
105
109
  });
106
110
  };
107
111
 
108
112
  /**
109
113
  * Render one icon as a compact line with its import package and short usage note.
110
114
  */
111
- var formatIconLine = function formatIconLine(iconResult, showFollowUp) {
115
+ var formatIconLine = function formatIconLine(iconResult, showFollowUp, invocation) {
112
116
  var _iconResult$component;
113
117
  var name = (_iconResult$component = iconResult.componentName) !== null && _iconResult$component !== void 0 ? _iconResult$component : '(unknown)';
114
118
  var pkg = iconResult.package ? " ".concat(iconResult.package) : '';
@@ -117,31 +121,34 @@ var formatIconLine = function formatIconLine(iconResult, showFollowUp) {
117
121
  line: "".concat(name).concat(pkg).concat(usage),
118
122
  command: 'icon',
119
123
  name: name,
120
- showFollowUp: showFollowUp
124
+ showFollowUp: showFollowUp,
125
+ invocation: invocation
121
126
  });
122
127
  };
123
128
 
124
129
  /**
125
130
  * Render one foundations-document match without dumping its full Markdown body.
126
131
  */
127
- var formatDocLine = function formatDocLine(doc, showFollowUp) {
132
+ var formatDocLine = function formatDocLine(doc, showFollowUp, invocation) {
128
133
  var summary = doc.summary ? " \u2014 ".concat(doc.summary) : '';
129
134
  var line = "".concat(doc.title).concat(summary);
130
- return showFollowUp ? "".concat(line, "\n \u2192 ads-cli ").concat(doc.followUp) : line;
135
+ return showFollowUp ? "".concat(line, "\n \u2192 ").concat(invocation, " ").concat(doc.followUp) : line;
131
136
  };
132
137
 
133
138
  /**
134
139
  * Render an array of results as compact lines for the given kind. Returns `null` when the data
135
140
  * is not an array (so the caller can fall back to generic JSON rendering).
136
141
  *
137
- * `showFollowUp` (default `false`) adds a `→ ads-cli <command> <name>` drill-in hint beneath each
138
- * row. Search enables it for both grouped and `--type` output; `--all` listings leave it off.
142
+ * `showFollowUp` (default `false`) adds a `→ <invocation> <command> <name>` drill-in hint beneath
143
+ * each row. Search enables it for both grouped and `--type` output; `--all` listings leave it off.
139
144
  */
140
145
  var formatCompactResults = exports.formatCompactResults = function formatCompactResults(_ref2) {
141
146
  var kind = _ref2.kind,
142
147
  data = _ref2.data,
143
148
  _ref2$showFollowUp = _ref2.showFollowUp,
144
- showFollowUp = _ref2$showFollowUp === void 0 ? false : _ref2$showFollowUp;
149
+ showFollowUp = _ref2$showFollowUp === void 0 ? false : _ref2$showFollowUp,
150
+ _ref2$invocation = _ref2.invocation,
151
+ invocation = _ref2$invocation === void 0 ? _cliMetadata.CLI_BIN_NAME : _ref2$invocation;
145
152
  if (!Array.isArray(data)) {
146
153
  return null;
147
154
  }
@@ -151,13 +158,13 @@ var formatCompactResults = exports.formatCompactResults = function formatCompact
151
158
  var lines = data.map(function (entry) {
152
159
  switch (kind) {
153
160
  case 'components':
154
- return formatComponentLine(entry, showFollowUp);
161
+ return formatComponentLine(entry, showFollowUp, invocation);
155
162
  case 'tokens':
156
- return formatTokenLine(entry, showFollowUp);
163
+ return formatTokenLine(entry, showFollowUp, invocation);
157
164
  case 'icons':
158
- return formatIconLine(entry, showFollowUp);
165
+ return formatIconLine(entry, showFollowUp, invocation);
159
166
  case 'docs':
160
- return formatDocLine(entry, showFollowUp);
167
+ return formatDocLine(entry, showFollowUp, invocation);
161
168
  default:
162
169
  return JSON.stringify(entry);
163
170
  }
@@ -1,11 +1,10 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
6
  exports.writeHumanResult = void 0;
8
- var _chalk = _interopRequireDefault(require("chalk"));
7
+ var _formatHumanResult = require("./format-human-result");
9
8
  /**
10
9
  * Human-readable rendering of a successful command result.
11
10
  */
@@ -13,19 +12,18 @@ var _chalk = _interopRequireDefault(require("chalk"));
13
12
  /**
14
13
  * Emit a human-readable rendering of a successful result to stdout.
15
14
  *
16
- * Structured data is pretty-printed as JSON (the underlying tools already return rich
17
- * objects), while plain-string payloads such as guideline markdown are printed verbatim.
15
+ * An absent payload is a diagnostic rather than data, so it goes to stderr to keep stdout clean
16
+ * for piping.
18
17
  */
19
18
  var writeHumanResult = exports.writeHumanResult = function writeHumanResult(_ref) {
20
19
  var data = _ref.data,
21
20
  writer = _ref.writer;
22
- if (typeof data === 'string') {
23
- writer.out(data);
24
- return;
25
- }
21
+ var text = (0, _formatHumanResult.formatHumanResult)({
22
+ data: data
23
+ });
26
24
  if (data === null || data === undefined) {
27
- writer.err(_chalk.default.yellow('No results.'));
25
+ writer.err(text);
28
26
  return;
29
27
  }
30
- writer.out(JSON.stringify(data, null, 2));
28
+ writer.out(text);
31
29
  };
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { run } from './cli';
3
+ import { CLI_ATLAS_INVOCATION } from './commands/cli-metadata';
3
4
 
4
5
  /**
5
6
  * Process entrypoint for the `atlas ads` distribution.
@@ -10,7 +11,9 @@ import { run } from './cli';
10
11
  */
11
12
  export const main = async (argv = process.argv.slice(2)) => {
12
13
  try {
13
- const exitCode = await run(argv);
14
+ const exitCode = await run(argv, undefined, {
15
+ invocation: CLI_ATLAS_INVOCATION
16
+ });
14
17
  process.exitCode = exitCode;
15
18
  } catch (error) {
16
19
  var _error$stack;