@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.
- package/CHANGELOG.md +30 -0
- package/README.md +62 -10
- package/bin/ads-cli.js +5 -1
- package/dist/cjs/atlas-cli.js +4 -1
- package/dist/cjs/cli.js +368 -70
- package/dist/cjs/commands/build-manifest.js +1 -2
- package/dist/cjs/commands/cli-metadata.js +2 -1
- package/dist/cjs/commands/definitions.js +100 -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-human-result.js +33 -0
- package/dist/cjs/output/format-manifest.js +5 -3
- package/dist/cjs/output/format-results.js +25 -18
- package/dist/cjs/output/write-human-result.js +8 -10
- package/dist/es2019/atlas-cli.js +4 -1
- package/dist/es2019/cli.js +273 -29
- package/dist/es2019/commands/build-manifest.js +1 -2
- package/dist/es2019/commands/cli-metadata.js +1 -0
- package/dist/es2019/commands/definitions.js +77 -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-human-result.js +28 -0
- package/dist/es2019/output/format-manifest.js +6 -3
- package/dist/es2019/output/format-results.js +25 -18
- package/dist/es2019/output/write-human-result.js +8 -9
- package/dist/esm/atlas-cli.js +4 -1
- package/dist/esm/cli.js +369 -71
- package/dist/esm/commands/build-manifest.js +1 -2
- package/dist/esm/commands/cli-metadata.js +1 -0
- package/dist/esm/commands/definitions.js +100 -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-human-result.js +27 -0
- package/dist/esm/output/format-manifest.js +5 -3
- package/dist/esm/output/format-results.js +26 -18
- package/dist/esm/output/write-human-result.js +8 -9
- 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 +28 -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-human-result.d.ts +17 -0
- package/dist/types/output/format-manifest.d.ts +2 -1
- package/dist/types/output/format-results.d.ts +4 -3
- package/dist/types/output/write-human-result.d.ts +2 -2
- package/dist/types/parse-args.d.ts +1 -1
- package/package.json +1 -1
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
* left to the caller's generic fallback.
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
+
import { CLI_BIN_NAME } from '../commands/cli-metadata';
|
|
13
|
+
|
|
12
14
|
/**
|
|
13
15
|
* A component result as returned by `searchComponentsTool` / `getAllComponentsTool`.
|
|
14
16
|
* Only the fields the compact view needs are modelled; others are ignored.
|
|
@@ -38,7 +40,7 @@ const pluralize = (count, noun) => `${count} ${noun}${count === 1 ? '' : 's'}`;
|
|
|
38
40
|
const truncate = (text, max = 80) => text.length > max ? `${text.slice(0, max - 1).trimEnd()}…` : text;
|
|
39
41
|
|
|
40
42
|
/**
|
|
41
|
-
* Append a `→
|
|
43
|
+
* Append a `→ <invocation> <command> <name>` drill-in hint beneath a row.
|
|
42
44
|
*
|
|
43
45
|
* Used for every `search` result, where the natural next step is to view that match in full.
|
|
44
46
|
* `--all` listings omit it because echoing every row's own name would just be noise.
|
|
@@ -47,8 +49,9 @@ const withFollowUp = ({
|
|
|
47
49
|
line,
|
|
48
50
|
command,
|
|
49
51
|
name,
|
|
50
|
-
showFollowUp
|
|
51
|
-
|
|
52
|
+
showFollowUp,
|
|
53
|
+
invocation
|
|
54
|
+
}) => showFollowUp ? `${line}\n → ${invocation} ${command} ${name}` : line;
|
|
52
55
|
|
|
53
56
|
/**
|
|
54
57
|
* Render one component as a compact line.
|
|
@@ -57,7 +60,7 @@ const withFollowUp = ({
|
|
|
57
60
|
* (`--all`, `--type`) or a titled section of grouped `search` — so the kind is always clear from
|
|
58
61
|
* context and a tag would just be noise.
|
|
59
62
|
*/
|
|
60
|
-
const formatComponentLine = (component, showFollowUp) => {
|
|
63
|
+
const formatComponentLine = (component, showFollowUp, invocation) => {
|
|
61
64
|
var _component$name;
|
|
62
65
|
const name = (_component$name = component.name) !== null && _component$name !== void 0 ? _component$name : '(unknown)';
|
|
63
66
|
const pkg = component.package ? ` ${component.package}` : '';
|
|
@@ -68,14 +71,15 @@ const formatComponentLine = (component, showFollowUp) => {
|
|
|
68
71
|
line: `${name}${pkg} (${meta})`,
|
|
69
72
|
command: 'component',
|
|
70
73
|
name,
|
|
71
|
-
showFollowUp
|
|
74
|
+
showFollowUp,
|
|
75
|
+
invocation
|
|
72
76
|
});
|
|
73
77
|
};
|
|
74
78
|
|
|
75
79
|
/**
|
|
76
80
|
* Render one token as a compact `name = value` line.
|
|
77
81
|
*/
|
|
78
|
-
const formatTokenLine = (tokenResult, showFollowUp) => {
|
|
82
|
+
const formatTokenLine = (tokenResult, showFollowUp, invocation) => {
|
|
79
83
|
var _tokenResult$name;
|
|
80
84
|
const name = (_tokenResult$name = tokenResult.name) !== null && _tokenResult$name !== void 0 ? _tokenResult$name : '(unknown)';
|
|
81
85
|
// Some token values (e.g. motion easing curves) are very long; truncate so each token stays
|
|
@@ -85,14 +89,15 @@ const formatTokenLine = (tokenResult, showFollowUp) => {
|
|
|
85
89
|
line,
|
|
86
90
|
command: 'token',
|
|
87
91
|
name,
|
|
88
|
-
showFollowUp
|
|
92
|
+
showFollowUp,
|
|
93
|
+
invocation
|
|
89
94
|
});
|
|
90
95
|
};
|
|
91
96
|
|
|
92
97
|
/**
|
|
93
98
|
* Render one icon as a compact line with its import package and short usage note.
|
|
94
99
|
*/
|
|
95
|
-
const formatIconLine = (iconResult, showFollowUp) => {
|
|
100
|
+
const formatIconLine = (iconResult, showFollowUp, invocation) => {
|
|
96
101
|
var _iconResult$component;
|
|
97
102
|
const name = (_iconResult$component = iconResult.componentName) !== null && _iconResult$component !== void 0 ? _iconResult$component : '(unknown)';
|
|
98
103
|
const pkg = iconResult.package ? ` ${iconResult.package}` : '';
|
|
@@ -101,30 +106,32 @@ const formatIconLine = (iconResult, showFollowUp) => {
|
|
|
101
106
|
line: `${name}${pkg}${usage}`,
|
|
102
107
|
command: 'icon',
|
|
103
108
|
name,
|
|
104
|
-
showFollowUp
|
|
109
|
+
showFollowUp,
|
|
110
|
+
invocation
|
|
105
111
|
});
|
|
106
112
|
};
|
|
107
113
|
|
|
108
114
|
/**
|
|
109
115
|
* Render one foundations-document match without dumping its full Markdown body.
|
|
110
116
|
*/
|
|
111
|
-
const formatDocLine = (doc, showFollowUp) => {
|
|
117
|
+
const formatDocLine = (doc, showFollowUp, invocation) => {
|
|
112
118
|
const summary = doc.summary ? ` — ${doc.summary}` : '';
|
|
113
119
|
const line = `${doc.title}${summary}`;
|
|
114
|
-
return showFollowUp ? `${line}\n →
|
|
120
|
+
return showFollowUp ? `${line}\n → ${invocation} ${doc.followUp}` : line;
|
|
115
121
|
};
|
|
116
122
|
|
|
117
123
|
/**
|
|
118
124
|
* Render an array of results as compact lines for the given kind. Returns `null` when the data
|
|
119
125
|
* is not an array (so the caller can fall back to generic JSON rendering).
|
|
120
126
|
*
|
|
121
|
-
* `showFollowUp` (default `false`) adds a `→
|
|
122
|
-
* row. Search enables it for both grouped and `--type` output; `--all` listings leave it off.
|
|
127
|
+
* `showFollowUp` (default `false`) adds a `→ <invocation> <command> <name>` drill-in hint beneath
|
|
128
|
+
* each row. Search enables it for both grouped and `--type` output; `--all` listings leave it off.
|
|
123
129
|
*/
|
|
124
130
|
export const formatCompactResults = ({
|
|
125
131
|
kind,
|
|
126
132
|
data,
|
|
127
|
-
showFollowUp = false
|
|
133
|
+
showFollowUp = false,
|
|
134
|
+
invocation = CLI_BIN_NAME
|
|
128
135
|
}) => {
|
|
129
136
|
if (!Array.isArray(data)) {
|
|
130
137
|
return null;
|
|
@@ -135,13 +142,13 @@ export const formatCompactResults = ({
|
|
|
135
142
|
const lines = data.map(entry => {
|
|
136
143
|
switch (kind) {
|
|
137
144
|
case 'components':
|
|
138
|
-
return formatComponentLine(entry, showFollowUp);
|
|
145
|
+
return formatComponentLine(entry, showFollowUp, invocation);
|
|
139
146
|
case 'tokens':
|
|
140
|
-
return formatTokenLine(entry, showFollowUp);
|
|
147
|
+
return formatTokenLine(entry, showFollowUp, invocation);
|
|
141
148
|
case 'icons':
|
|
142
|
-
return formatIconLine(entry, showFollowUp);
|
|
149
|
+
return formatIconLine(entry, showFollowUp, invocation);
|
|
143
150
|
case 'docs':
|
|
144
|
-
return formatDocLine(entry, showFollowUp);
|
|
151
|
+
return formatDocLine(entry, showFollowUp, invocation);
|
|
145
152
|
default:
|
|
146
153
|
return JSON.stringify(entry);
|
|
147
154
|
}
|
|
@@ -2,24 +2,23 @@
|
|
|
2
2
|
* Human-readable rendering of a successful command result.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import { formatHumanResult } from './format-human-result';
|
|
6
6
|
/**
|
|
7
7
|
* Emit a human-readable rendering of a successful result to stdout.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
9
|
+
* An absent payload is a diagnostic rather than data, so it goes to stderr to keep stdout clean
|
|
10
|
+
* for piping.
|
|
11
11
|
*/
|
|
12
12
|
export const writeHumanResult = ({
|
|
13
13
|
data,
|
|
14
14
|
writer
|
|
15
15
|
}) => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
16
|
+
const text = formatHumanResult({
|
|
17
|
+
data
|
|
18
|
+
});
|
|
20
19
|
if (data === null || data === undefined) {
|
|
21
|
-
writer.err(
|
|
20
|
+
writer.err(text);
|
|
22
21
|
return;
|
|
23
22
|
}
|
|
24
|
-
writer.out(
|
|
23
|
+
writer.out(text);
|
|
25
24
|
};
|
package/dist/esm/atlas-cli.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
3
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
4
|
import { run } from './cli';
|
|
5
|
+
import { CLI_ATLAS_INVOCATION } from './commands/cli-metadata';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Process entrypoint for the `atlas ads` distribution.
|
|
@@ -23,7 +24,9 @@ export var main = /*#__PURE__*/function () {
|
|
|
23
24
|
argv = _args.length > 0 && _args[0] !== undefined ? _args[0] : process.argv.slice(2);
|
|
24
25
|
_context.prev = 1;
|
|
25
26
|
_context.next = 2;
|
|
26
|
-
return run(argv
|
|
27
|
+
return run(argv, undefined, {
|
|
28
|
+
invocation: CLI_ATLAS_INVOCATION
|
|
29
|
+
});
|
|
27
30
|
case 2:
|
|
28
31
|
exitCode = _context.sent;
|
|
29
32
|
process.exitCode = exitCode;
|