@atlaskit/ads-cli 0.4.1 → 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 +16 -0
- package/README.md +3 -5
- package/bin/ads-cli.js +6 -2
- 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/index.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
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
|
+
|
|
11
|
+
## 0.4.2
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [`3f494bce2de11`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/3f494bce2de11) -
|
|
16
|
+
Fix the Atlas CLI release pipeline to publish ADS plugin artifacts to the ADS Statlas namespace
|
|
17
|
+
with installable object paths.
|
|
18
|
+
|
|
3
19
|
## 0.4.1
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -165,8 +165,8 @@ node packages/design-system/ads-cli/build/atlas/ads-cli.js search button
|
|
|
165
165
|
```
|
|
166
166
|
|
|
167
167
|
The `.atlas-plugin` descriptor declares the `ads` plugin and the `atlas-cli-plugin-ads` Statlas
|
|
168
|
-
namespace.
|
|
169
|
-
|
|
168
|
+
namespace. Every upload fetches `manifest.toml` from Statlas before adding a release, so the remote
|
|
169
|
+
manifest history remains canonical.
|
|
170
170
|
|
|
171
171
|
Prepare an Atlas-shaped release locally:
|
|
172
172
|
|
|
@@ -180,9 +180,7 @@ smoke-tests the Linux AMD64 executable when running on Linux AMD64, and adds the
|
|
|
180
180
|
`alpha` channel in the working manifest.
|
|
181
181
|
|
|
182
182
|
The `ads-cli-build-and-upload-to-statlas` custom pipeline runs the tests and typecheck, prepares the
|
|
183
|
-
release, uploads all artifacts, then publishes the manifest. Run it from `master`.
|
|
184
|
-
`ALLOW_MISSING_REMOTE_MANIFEST` to `true` only for the first release; later runs must fetch the
|
|
185
|
-
remote release history successfully.
|
|
183
|
+
release, uploads all artifacts, then publishes the manifest. Run it from `master`.
|
|
186
184
|
|
|
187
185
|
After validating an alpha release, run the `ads-cli-promote-stable-version` custom pipeline from
|
|
188
186
|
`master` with `VERSION_TO_PROMOTE` set to its exact version. Promotion updates the canonical remote
|
package/bin/ads-cli.js
CHANGED
|
@@ -20,12 +20,16 @@ const isDev = fs.existsSync(path.join(__dirname, '..', 'tsconfig.json'));
|
|
|
20
20
|
if (isDev) {
|
|
21
21
|
// `@atlassian/ts-loader` registers `tsx` require hooks so the TypeScript source
|
|
22
22
|
// (including `.tsx` files and cross-package imports) can be `require`d directly
|
|
23
|
-
// without a pre-build step.
|
|
23
|
+
// without a pre-build step.
|
|
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
|
};
|