@atlaskit/ads-cli 0.4.2 → 0.5.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/CHANGELOG.md +8 -0
- package/bin/ads-cli.js +5 -1
- package/dist/cjs/atlas-cli.js +4 -1
- package/dist/cjs/cli.js +91 -35
- package/dist/cjs/commands/build-manifest.js +1 -2
- package/dist/cjs/commands/cli-metadata.js +2 -1
- package/dist/cjs/commands/definitions.js +16 -16
- package/dist/cjs/output/format-disambiguation.js +3 -1
- package/dist/cjs/output/format-grouped-results.js +6 -2
- package/dist/cjs/output/format-manifest.js +5 -3
- package/dist/cjs/output/format-results.js +25 -18
- package/dist/es2019/atlas-cli.js +4 -1
- package/dist/es2019/cli.js +69 -17
- package/dist/es2019/commands/build-manifest.js +1 -2
- package/dist/es2019/commands/cli-metadata.js +1 -0
- package/dist/es2019/commands/definitions.js +8 -6
- package/dist/es2019/output/format-disambiguation.js +3 -2
- package/dist/es2019/output/format-grouped-results.js +5 -2
- package/dist/es2019/output/format-manifest.js +6 -3
- package/dist/es2019/output/format-results.js +25 -18
- package/dist/esm/atlas-cli.js +4 -1
- package/dist/esm/cli.js +92 -36
- package/dist/esm/commands/build-manifest.js +1 -2
- package/dist/esm/commands/cli-metadata.js +1 -0
- package/dist/esm/commands/definitions.js +16 -16
- package/dist/esm/output/format-disambiguation.js +3 -1
- package/dist/esm/output/format-grouped-results.js +6 -2
- package/dist/esm/output/format-manifest.js +5 -3
- package/dist/esm/output/format-results.js +26 -18
- package/dist/types/cli.d.ts +10 -1
- package/dist/types/commands/build-manifest.d.ts +1 -2
- package/dist/types/commands/cli-metadata.d.ts +1 -0
- package/dist/types/commands/types.d.ts +12 -1
- package/dist/types/output/format-disambiguation.d.ts +1 -1
- package/dist/types/output/format-grouped-results.d.ts +2 -1
- package/dist/types/output/format-manifest.d.ts +2 -1
- package/dist/types/output/format-results.d.ts +4 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/ads-cli
|
|
2
2
|
|
|
3
|
+
## 0.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`34cfe0f138d1c`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/34cfe0f138d1c) -
|
|
8
|
+
Show the active command invocation in ADS CLI help, errors, and follow-up hints. The v2 JSON
|
|
9
|
+
manifest removes the redundant `invocation` field.
|
|
10
|
+
|
|
3
11
|
## 0.4.2
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
package/bin/ads-cli.js
CHANGED
|
@@ -24,8 +24,12 @@ if (isDev) {
|
|
|
24
24
|
require('@atlassian/ts-loader');
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
// The AFM repo-root shell shim sets this display-only value because it delegates to this same
|
|
28
|
+
// package entrypoint. Published package runs have no override and advertise their npx command.
|
|
29
|
+
const invocation = process.env.ADS_CLI_DISPLAY_INVOCATION || 'npx @atlaskit/ads-cli';
|
|
30
|
+
|
|
27
31
|
require(path.join('..', isDev ? 'src/cli' : 'dist/cjs/cli'))
|
|
28
|
-
.run(process.argv.slice(2))
|
|
32
|
+
.run(process.argv.slice(2), undefined, { invocation })
|
|
29
33
|
.then((exitCode) => {
|
|
30
34
|
// A resolved numeric value is treated as an explicit exit code.
|
|
31
35
|
process.exit(typeof exitCode === 'number' ? exitCode : 0);
|
package/dist/cjs/atlas-cli.js
CHANGED
|
@@ -9,6 +9,7 @@ exports.main = void 0;
|
|
|
9
9
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
10
10
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
11
11
|
var _cli = require("./cli");
|
|
12
|
+
var _cliMetadata = require("./commands/cli-metadata");
|
|
12
13
|
/**
|
|
13
14
|
* Process entrypoint for the `atlas ads` distribution.
|
|
14
15
|
*
|
|
@@ -29,7 +30,9 @@ var main = exports.main = /*#__PURE__*/function () {
|
|
|
29
30
|
argv = _args.length > 0 && _args[0] !== undefined ? _args[0] : process.argv.slice(2);
|
|
30
31
|
_context.prev = 1;
|
|
31
32
|
_context.next = 2;
|
|
32
|
-
return (0, _cli.run)(argv
|
|
33
|
+
return (0, _cli.run)(argv, undefined, {
|
|
34
|
+
invocation: _cliMetadata.CLI_ATLAS_INVOCATION
|
|
35
|
+
});
|
|
33
36
|
case 2:
|
|
34
37
|
exitCode = _context.sent;
|
|
35
38
|
process.exitCode = exitCode;
|
package/dist/cjs/cli.js
CHANGED
|
@@ -8,6 +8,7 @@ exports.run = void 0;
|
|
|
8
8
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
10
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
11
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
12
|
var _cliMetadata = require("./commands/cli-metadata");
|
|
12
13
|
var _definitions = require("./commands/definitions");
|
|
13
14
|
var _getCommand = require("./commands/get-command");
|
|
@@ -43,7 +44,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
43
44
|
* Build the top-level help text from the command registry so it can never drift from the
|
|
44
45
|
* runnable surface.
|
|
45
46
|
*/
|
|
46
|
-
var buildHelpText = function buildHelpText() {
|
|
47
|
+
var buildHelpText = function buildHelpText(invocation) {
|
|
47
48
|
// Width of the usage "gutter"; descriptions align to this column. Usages longer than the
|
|
48
49
|
// gutter wrap onto their own line with the description indented beneath, so a long usage
|
|
49
50
|
// (e.g. `docs`, which lists every topic) never produces a single 130-column line.
|
|
@@ -63,20 +64,61 @@ var buildHelpText = function buildHelpText() {
|
|
|
63
64
|
var aliases = flag.alias ? ", -".concat(flag.alias) : '';
|
|
64
65
|
return " --".concat(flag.name).concat(aliases).padEnd(18) + flag.description;
|
|
65
66
|
}).join('\n');
|
|
66
|
-
|
|
67
|
+
var examples = [{
|
|
68
|
+
command: 'search contrast',
|
|
69
|
+
comment: 'unified: components, tokens, icons & docs'
|
|
70
|
+
}, {
|
|
71
|
+
command: 'search button --type component'
|
|
72
|
+
}, {
|
|
73
|
+
command: 'search contrast --type docs'
|
|
74
|
+
}, {
|
|
75
|
+
command: 'component Button',
|
|
76
|
+
comment: 'detail for one component'
|
|
77
|
+
}, {
|
|
78
|
+
command: 'token space.100',
|
|
79
|
+
comment: 'detail for one token'
|
|
80
|
+
}, {
|
|
81
|
+
command: 'icon --all',
|
|
82
|
+
comment: 'list every icon'
|
|
83
|
+
}, {
|
|
84
|
+
command: 'docs spacing',
|
|
85
|
+
comment: 'foundations docs'
|
|
86
|
+
}, {
|
|
87
|
+
command: 'docs a11y buttons',
|
|
88
|
+
comment: 'accessibility guidance'
|
|
89
|
+
}, {
|
|
90
|
+
command: 'docs migration motion',
|
|
91
|
+
comment: 'migration guide'
|
|
92
|
+
}, {
|
|
93
|
+
command: 'manifest --json',
|
|
94
|
+
comment: 'machine-readable CLI contract'
|
|
95
|
+
}];
|
|
96
|
+
var exampleCommands = examples.map(function (_ref) {
|
|
97
|
+
var command = _ref.command;
|
|
98
|
+
return "$ ".concat(invocation, " ").concat(command);
|
|
99
|
+
});
|
|
100
|
+
var exampleWidth = Math.max.apply(Math, (0, _toConsumableArray2.default)(exampleCommands.map(function (command) {
|
|
101
|
+
return command.length;
|
|
102
|
+
})));
|
|
103
|
+
var exampleLines = examples.map(function (_ref2, index) {
|
|
104
|
+
var comment = _ref2.comment;
|
|
105
|
+
var command = exampleCommands[index];
|
|
106
|
+
return " ".concat(comment ? "".concat(command.padEnd(exampleWidth), " # ").concat(comment) : command);
|
|
107
|
+
}).join('\n');
|
|
108
|
+
return [_cliMetadata.CLI_DESCRIPTION, '', 'Usage', " $ ".concat(invocation, " <command> [options]"), '', 'Commands', commandLines, '', 'Global options', globalFlagLines, '', 'Examples', exampleLines].join('\n');
|
|
67
109
|
};
|
|
68
110
|
|
|
69
111
|
/**
|
|
70
112
|
* Execute a registry-backed command: resolve its tool + args, dispatch, and format output.
|
|
71
113
|
*/
|
|
72
114
|
var runRegistryCommand = /*#__PURE__*/function () {
|
|
73
|
-
var
|
|
115
|
+
var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(_ref3) {
|
|
74
116
|
var _resolved$meta3;
|
|
75
|
-
var command, input, json, writer, resolved, _resolved$meta, results, _resolved$meta2;
|
|
117
|
+
var command, input, json, writer, invocation, resolved, _resolved$meta, results, _resolved$meta2;
|
|
76
118
|
return _regenerator.default.wrap(function (_context2) {
|
|
77
119
|
while (1) switch (_context2.prev = _context2.next) {
|
|
78
120
|
case 0:
|
|
79
|
-
command =
|
|
121
|
+
command = _ref3.command, input = _ref3.input, json = _ref3.json, writer = _ref3.writer, invocation = _ref3.invocation;
|
|
80
122
|
resolved = command.resolve(input); // A resolver returning `{ error }` indicates invalid input (a usage error).
|
|
81
123
|
if (!('error' in resolved)) {
|
|
82
124
|
_context2.next = 1;
|
|
@@ -113,12 +155,13 @@ var runRegistryCommand = /*#__PURE__*/function () {
|
|
|
113
155
|
},
|
|
114
156
|
meta: (_resolved$meta = resolved.meta) !== null && _resolved$meta !== void 0 ? _resolved$meta : {},
|
|
115
157
|
json: json,
|
|
116
|
-
writer: writer
|
|
158
|
+
writer: writer,
|
|
159
|
+
invocation: invocation
|
|
117
160
|
}));
|
|
118
161
|
case 2:
|
|
119
162
|
_context2.next = 3;
|
|
120
163
|
return Promise.all(resolved.tools.map( /*#__PURE__*/function () {
|
|
121
|
-
var
|
|
164
|
+
var _ref5 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(tool) {
|
|
122
165
|
var handler, _t, _t2;
|
|
123
166
|
return _regenerator.default.wrap(function (_context) {
|
|
124
167
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -148,7 +191,7 @@ var runRegistryCommand = /*#__PURE__*/function () {
|
|
|
148
191
|
}, _callee);
|
|
149
192
|
}));
|
|
150
193
|
return function (_x2) {
|
|
151
|
-
return
|
|
194
|
+
return _ref5.apply(this, arguments);
|
|
152
195
|
};
|
|
153
196
|
}()));
|
|
154
197
|
case 3:
|
|
@@ -163,7 +206,8 @@ var runRegistryCommand = /*#__PURE__*/function () {
|
|
|
163
206
|
results: results,
|
|
164
207
|
meta: (_resolved$meta2 = resolved.meta) !== null && _resolved$meta2 !== void 0 ? _resolved$meta2 : {},
|
|
165
208
|
json: json,
|
|
166
|
-
writer: writer
|
|
209
|
+
writer: writer,
|
|
210
|
+
invocation: invocation
|
|
167
211
|
}));
|
|
168
212
|
case 4:
|
|
169
213
|
return _context2.abrupt("return", renderSingleResult({
|
|
@@ -172,7 +216,8 @@ var runRegistryCommand = /*#__PURE__*/function () {
|
|
|
172
216
|
result: results[0],
|
|
173
217
|
meta: (_resolved$meta3 = resolved.meta) !== null && _resolved$meta3 !== void 0 ? _resolved$meta3 : {},
|
|
174
218
|
json: json,
|
|
175
|
-
writer: writer
|
|
219
|
+
writer: writer,
|
|
220
|
+
invocation: invocation
|
|
176
221
|
}));
|
|
177
222
|
case 5:
|
|
178
223
|
case "end":
|
|
@@ -181,21 +226,22 @@ var runRegistryCommand = /*#__PURE__*/function () {
|
|
|
181
226
|
}, _callee2);
|
|
182
227
|
}));
|
|
183
228
|
return function runRegistryCommand(_x) {
|
|
184
|
-
return
|
|
229
|
+
return _ref4.apply(this, arguments);
|
|
185
230
|
};
|
|
186
231
|
}();
|
|
187
232
|
|
|
188
233
|
/**
|
|
189
234
|
* Render a single-tool command result (the common case).
|
|
190
235
|
*/
|
|
191
|
-
var renderSingleResult = function renderSingleResult(
|
|
192
|
-
var _command$resultKind,
|
|
193
|
-
var command =
|
|
194
|
-
input =
|
|
195
|
-
result =
|
|
196
|
-
meta =
|
|
197
|
-
json =
|
|
198
|
-
writer =
|
|
236
|
+
var renderSingleResult = function renderSingleResult(_ref6) {
|
|
237
|
+
var _command$resultKind, _ref7, _command$formatHuman;
|
|
238
|
+
var command = _ref6.command,
|
|
239
|
+
input = _ref6.input,
|
|
240
|
+
result = _ref6.result,
|
|
241
|
+
meta = _ref6.meta,
|
|
242
|
+
json = _ref6.json,
|
|
243
|
+
writer = _ref6.writer,
|
|
244
|
+
invocation = _ref6.invocation;
|
|
199
245
|
var isError = result.isError;
|
|
200
246
|
|
|
201
247
|
// The ADS search tools return an `Error: No … found` text block when nothing matches.
|
|
@@ -271,9 +317,12 @@ var renderSingleResult = function renderSingleResult(_ref4) {
|
|
|
271
317
|
var compact = resultKind ? (0, _formatResults.formatCompactResults)({
|
|
272
318
|
kind: resultKind,
|
|
273
319
|
data: data,
|
|
274
|
-
showFollowUp: command.name === 'search'
|
|
320
|
+
showFollowUp: command.name === 'search',
|
|
321
|
+
invocation: invocation
|
|
275
322
|
}) : null;
|
|
276
|
-
var human = (
|
|
323
|
+
var human = (_ref7 = compact !== null && compact !== void 0 ? compact : (_command$formatHuman = command.formatHuman) === null || _command$formatHuman === void 0 ? void 0 : _command$formatHuman.call(command, data, {
|
|
324
|
+
invocation: invocation
|
|
325
|
+
})) !== null && _ref7 !== void 0 ? _ref7 : null;
|
|
277
326
|
if (human !== null) {
|
|
278
327
|
writer.out(human);
|
|
279
328
|
} else {
|
|
@@ -291,13 +340,14 @@ var renderSingleResult = function renderSingleResult(_ref4) {
|
|
|
291
340
|
* Each sub-result is keyed by its {@link ToolCall.key}. A sub-search that finds nothing simply
|
|
292
341
|
* contributes an empty array; the command is only treated as NOT_FOUND when every group is empty.
|
|
293
342
|
*/
|
|
294
|
-
var renderGroupedResult = function renderGroupedResult(
|
|
295
|
-
var command =
|
|
296
|
-
input =
|
|
297
|
-
results =
|
|
298
|
-
meta =
|
|
299
|
-
json =
|
|
300
|
-
writer =
|
|
343
|
+
var renderGroupedResult = function renderGroupedResult(_ref8) {
|
|
344
|
+
var command = _ref8.command,
|
|
345
|
+
input = _ref8.input,
|
|
346
|
+
results = _ref8.results,
|
|
347
|
+
meta = _ref8.meta,
|
|
348
|
+
json = _ref8.json,
|
|
349
|
+
writer = _ref8.writer,
|
|
350
|
+
invocation = _ref8.invocation;
|
|
301
351
|
// Assemble `{ [key]: results }`, coercing "no matches" sub-results to empty arrays so one
|
|
302
352
|
// empty domain does not blank out the others. The guidelines tool returns full Markdown, so
|
|
303
353
|
// summarize its highest-ranked match for search; `docs <query>` remains the detail view.
|
|
@@ -364,22 +414,26 @@ var renderGroupedResult = function renderGroupedResult(_ref6) {
|
|
|
364
414
|
}
|
|
365
415
|
writer.out((0, _formatGroupedResults.formatGroupedResults)({
|
|
366
416
|
groups: grouped,
|
|
367
|
-
totalCount: totalCount
|
|
417
|
+
totalCount: totalCount,
|
|
418
|
+
invocation: invocation
|
|
368
419
|
}));
|
|
369
420
|
return _types.ExitCode.Ok;
|
|
370
421
|
};
|
|
371
|
-
|
|
372
422
|
/**
|
|
373
423
|
* Parse and execute a single CLI invocation.
|
|
374
424
|
*
|
|
375
425
|
* @param argv - Arguments after `node <script>` (i.e. `process.argv.slice(2)`).
|
|
376
426
|
* @param writer - Injectable output sink; defaults to console-backed stdout/stderr.
|
|
427
|
+
* @param options - Distribution-specific rendering options.
|
|
377
428
|
* @returns The process exit code. The bin wrapper maps this onto `process.exit`.
|
|
378
429
|
*/
|
|
379
430
|
var run = exports.run = /*#__PURE__*/function () {
|
|
380
|
-
var
|
|
431
|
+
var _ref9 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
|
|
381
432
|
var argv,
|
|
382
433
|
writer,
|
|
434
|
+
_ref0,
|
|
435
|
+
_ref0$invocation,
|
|
436
|
+
invocation,
|
|
383
437
|
_parseArgs,
|
|
384
438
|
command,
|
|
385
439
|
positionals,
|
|
@@ -395,6 +449,7 @@ var run = exports.run = /*#__PURE__*/function () {
|
|
|
395
449
|
case 0:
|
|
396
450
|
argv = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : process.argv.slice(2);
|
|
397
451
|
writer = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : _writer.defaultWriter;
|
|
452
|
+
_ref0 = _args3.length > 2 && _args3[2] !== undefined ? _args3[2] : {}, _ref0$invocation = _ref0.invocation, invocation = _ref0$invocation === void 0 ? _cliMetadata.CLI_BIN_NAME : _ref0$invocation;
|
|
398
453
|
_parseArgs = (0, _parseArgs2.parseArgs)(argv), command = _parseArgs.command, positionals = _parseArgs.positionals, flags = _parseArgs.flags;
|
|
399
454
|
json = flags.json === true; // `--version` / `-v` takes precedence and short-circuits.
|
|
400
455
|
if (!(flags.version === true)) {
|
|
@@ -408,7 +463,7 @@ var run = exports.run = /*#__PURE__*/function () {
|
|
|
408
463
|
_context3.next = 2;
|
|
409
464
|
break;
|
|
410
465
|
}
|
|
411
|
-
writer.out(buildHelpText());
|
|
466
|
+
writer.out(buildHelpText(invocation));
|
|
412
467
|
return _context3.abrupt("return", command === undefined && flags.help !== true ? _types.ExitCode.UsageError : _types.ExitCode.Ok);
|
|
413
468
|
case 2:
|
|
414
469
|
definition = (0, _getCommand.getCommand)(command);
|
|
@@ -431,7 +486,7 @@ var run = exports.run = /*#__PURE__*/function () {
|
|
|
431
486
|
message: message,
|
|
432
487
|
writer: writer
|
|
433
488
|
});
|
|
434
|
-
writer.err(
|
|
489
|
+
writer.err("Run `".concat(invocation, " --help` to see available commands."));
|
|
435
490
|
}
|
|
436
491
|
return _context3.abrupt("return", _types.ExitCode.UsageError);
|
|
437
492
|
case 3:
|
|
@@ -444,7 +499,8 @@ var run = exports.run = /*#__PURE__*/function () {
|
|
|
444
499
|
flags: flags
|
|
445
500
|
},
|
|
446
501
|
json: json,
|
|
447
|
-
writer: writer
|
|
502
|
+
writer: writer,
|
|
503
|
+
invocation: invocation
|
|
448
504
|
});
|
|
449
505
|
case 4:
|
|
450
506
|
return _context3.abrupt("return", _context3.sent);
|
|
@@ -475,6 +531,6 @@ var run = exports.run = /*#__PURE__*/function () {
|
|
|
475
531
|
}, _callee3, null, [[3, 5]]);
|
|
476
532
|
}));
|
|
477
533
|
return function run() {
|
|
478
|
-
return
|
|
534
|
+
return _ref9.apply(this, arguments);
|
|
479
535
|
};
|
|
480
536
|
}();
|
|
@@ -17,12 +17,11 @@ var _cliMetadata = require("./cli-metadata");
|
|
|
17
17
|
*/
|
|
18
18
|
var buildManifest = exports.buildManifest = function buildManifest(commands, version) {
|
|
19
19
|
return {
|
|
20
|
-
schemaVersion:
|
|
20
|
+
schemaVersion: 2,
|
|
21
21
|
name: _cliMetadata.CLI_NAME,
|
|
22
22
|
bin: _cliMetadata.CLI_BIN_NAME,
|
|
23
23
|
version: version,
|
|
24
24
|
description: _cliMetadata.CLI_DESCRIPTION,
|
|
25
|
-
invocation: "npx ".concat(_cliMetadata.CLI_NAME),
|
|
26
25
|
commands: commands.map(function (_ref) {
|
|
27
26
|
var name = _ref.name,
|
|
28
27
|
description = _ref.description,
|
|
@@ -3,13 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.globalFlags = exports.CLI_NAME = exports.CLI_DESCRIPTION = exports.CLI_BIN_NAME = void 0;
|
|
6
|
+
exports.globalFlags = exports.CLI_NAME = exports.CLI_DESCRIPTION = exports.CLI_BIN_NAME = exports.CLI_ATLAS_INVOCATION = void 0;
|
|
7
7
|
/**
|
|
8
8
|
* Shared top-level ADS CLI metadata used by help and the capability manifest.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
var CLI_NAME = exports.CLI_NAME = '@atlaskit/ads-cli';
|
|
12
12
|
var CLI_BIN_NAME = exports.CLI_BIN_NAME = 'ads-cli';
|
|
13
|
+
var CLI_ATLAS_INVOCATION = exports.CLI_ATLAS_INVOCATION = 'atlas ads';
|
|
13
14
|
var CLI_DESCRIPTION = exports.CLI_DESCRIPTION = 'Query Atlassian Design System (ADS) structured content — components, tokens, icons, and guidelines — from the terminal.';
|
|
14
15
|
var globalFlags = exports.globalFlags = [{
|
|
15
16
|
name: 'json',
|
|
@@ -341,19 +341,20 @@ var makeItemCommand = function makeItemCommand(_ref3) {
|
|
|
341
341
|
envelopeType: function envelopeType(input) {
|
|
342
342
|
return input.flags.all ? listTool.envelopeType : name;
|
|
343
343
|
},
|
|
344
|
-
formatHuman: function formatHuman(data) {
|
|
344
|
+
formatHuman: function formatHuman(data, _ref4) {
|
|
345
|
+
var invocation = _ref4.invocation;
|
|
345
346
|
// Ambiguous lookup → render the "did you mean?" list; otherwise the item detail view.
|
|
346
347
|
if ((0, _disambiguation.isDisambiguation)(data)) {
|
|
347
|
-
return (0, _formatDisambiguation.formatDisambiguation)(data);
|
|
348
|
+
return (0, _formatDisambiguation.formatDisambiguation)(data, invocation);
|
|
348
349
|
}
|
|
349
350
|
return _formatHuman(data);
|
|
350
351
|
},
|
|
351
352
|
// Turn the ranked candidate window into an exact match, a lone match, or a disambiguation
|
|
352
353
|
// marker. Skipped for `--all` (that path returns the full array untouched).
|
|
353
|
-
transform: function transform(
|
|
354
|
+
transform: function transform(_ref5) {
|
|
354
355
|
var _input$positionals$;
|
|
355
|
-
var data =
|
|
356
|
-
input =
|
|
356
|
+
var data = _ref5.data,
|
|
357
|
+
input = _ref5.input;
|
|
357
358
|
if (input.flags.all) {
|
|
358
359
|
return data;
|
|
359
360
|
}
|
|
@@ -499,9 +500,9 @@ var commands = exports.commands = [{
|
|
|
499
500
|
var _resolveSearchType;
|
|
500
501
|
return (_resolveSearchType = resolveSearchType(input.flags)) !== null && _resolveSearchType !== void 0 ? _resolveSearchType : undefined;
|
|
501
502
|
},
|
|
502
|
-
transform: function transform(
|
|
503
|
-
var data =
|
|
504
|
-
input =
|
|
503
|
+
transform: function transform(_ref6) {
|
|
504
|
+
var data = _ref6.data,
|
|
505
|
+
input = _ref6.input;
|
|
505
506
|
return resolveSearchType(input.flags) === 'docs' ? (0, _createDocSearchResults.createDocSearchResults)({
|
|
506
507
|
data: data,
|
|
507
508
|
query: input.positionals.join(' ')
|
|
@@ -561,16 +562,17 @@ var commands = exports.commands = [{
|
|
|
561
562
|
},
|
|
562
563
|
// Ambiguous fuzzy lookup → render the "did you mean?" list; otherwise print each rule's
|
|
563
564
|
// Markdown `content` verbatim rather than JSON.
|
|
564
|
-
formatHuman: function formatHuman(data) {
|
|
565
|
-
|
|
565
|
+
formatHuman: function formatHuman(data, _ref7) {
|
|
566
|
+
var invocation = _ref7.invocation;
|
|
567
|
+
return (0, _disambiguation.isDisambiguation)(data) ? (0, _formatDisambiguation.formatDisambiguation)(data, invocation) : (0, _formatLintRules.formatLintRules)(data);
|
|
566
568
|
},
|
|
567
569
|
// Mirror the item commands: a fuzzy term that matches one rule exactly (or a lone match)
|
|
568
570
|
// shows that rule's docs, but several matches with no exact name surface a disambiguation
|
|
569
571
|
// list instead of dumping every rule's full Markdown. Skipped for bare `lint-rules` (which
|
|
570
572
|
// intentionally returns every rule's content).
|
|
571
|
-
transform: function transform(
|
|
572
|
-
var data =
|
|
573
|
-
input =
|
|
573
|
+
transform: function transform(_ref8) {
|
|
574
|
+
var data = _ref8.data,
|
|
575
|
+
input = _ref8.input;
|
|
574
576
|
var terms = input.positionals;
|
|
575
577
|
if (terms.length === 0) {
|
|
576
578
|
return data;
|
|
@@ -784,9 +786,7 @@ var commands = exports.commands = [{
|
|
|
784
786
|
resolve: function resolve() {
|
|
785
787
|
return {
|
|
786
788
|
data: (0, _buildManifest.buildManifest)(commands, (0, _getVersion.getVersion)()),
|
|
787
|
-
meta: {
|
|
788
|
-
schemaVersion: 1
|
|
789
|
-
}
|
|
789
|
+
meta: {}
|
|
790
790
|
};
|
|
791
791
|
}
|
|
792
792
|
}];
|
|
@@ -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
|
|
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);
|
|
@@ -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
|
-
|
|
13
|
-
|
|
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(
|
|
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 `→
|
|
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
|
-
|
|
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
|
|
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 `→
|
|
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
|
}
|
package/dist/es2019/atlas-cli.js
CHANGED
|
@@ -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;
|