@atlaskit/ads-cli 0.8.1 → 0.9.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 +17 -0
- package/README.md +23 -0
- package/dist/cjs/cli.js +49 -20
- package/dist/cjs/commands/definitions.js +18 -2
- package/dist/cjs/commands/init.js +427 -0
- package/dist/es2019/cli.js +20 -0
- package/dist/es2019/commands/definitions.js +17 -2
- package/dist/es2019/commands/init.js +303 -0
- package/dist/esm/cli.js +46 -17
- package/dist/esm/commands/definitions.js +18 -2
- package/dist/esm/commands/init.js +420 -0
- package/dist/types/commands/init.d.ts +10 -0
- package/dist/types/commands/types.d.ts +10 -1
- package/package.json +2 -2
|
@@ -0,0 +1,427 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.runInitCommand = void 0;
|
|
8
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
10
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
11
|
+
var _nodeChild_process = require("node:child_process");
|
|
12
|
+
var _nodeFs = require("node:fs");
|
|
13
|
+
var _nodePath = _interopRequireDefault(require("node:path"));
|
|
14
|
+
var _createErrorEnvelope = require("../envelope/create-error-envelope");
|
|
15
|
+
var _createSuccessEnvelope = require("../envelope/create-success-envelope");
|
|
16
|
+
var _writeHumanError = require("../output/write-human-error");
|
|
17
|
+
var _writeJsonEnvelope = require("../output/write-json-envelope");
|
|
18
|
+
var _types = require("../types");
|
|
19
|
+
var _cliMetadata = require("./cli-metadata");
|
|
20
|
+
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; } } }; }
|
|
21
|
+
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; } }
|
|
22
|
+
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; }
|
|
23
|
+
var SKILL_ENTRYPOINT = 'SKILL.md';
|
|
24
|
+
var SKILLS = [{
|
|
25
|
+
name: 'atlassian-design-system',
|
|
26
|
+
displayName: 'ADS',
|
|
27
|
+
relativePath: '.agents/skills/atlassian-design-system',
|
|
28
|
+
requiredFiles: [SKILL_ENTRYPOINT]
|
|
29
|
+
}, {
|
|
30
|
+
name: 'ui-styling-standard',
|
|
31
|
+
displayName: 'UI Styling Standard',
|
|
32
|
+
relativePath: '.agents/skills/ui-styling-standard',
|
|
33
|
+
requiredFiles: [SKILL_ENTRYPOINT]
|
|
34
|
+
}, {
|
|
35
|
+
name: 'a11y-foundation',
|
|
36
|
+
displayName: 'Accessibility Foundation',
|
|
37
|
+
relativePath: '.agents/skills/a11y-foundation',
|
|
38
|
+
requiredFiles: [SKILL_ENTRYPOINT]
|
|
39
|
+
}];
|
|
40
|
+
var GIT_MARKER = '.git';
|
|
41
|
+
var SKILLS_INSTALLER_PACKAGE = '@atlassian/skills';
|
|
42
|
+
var SKILLS_INSTALLER_UNAVAILABLE_REASON = 'skills-installer-unavailable';
|
|
43
|
+
var SKILLS_INSTALLER_UNAVAILABLE_ERROR_CODES = new Set(['EACCES', 'EAI_AGAIN', 'ECONNREFUSED', 'ECONNRESET', 'ENOENT', 'ENOTFOUND', 'ETIMEDOUT']);
|
|
44
|
+
var defaultPathExists = function defaultPathExists(target) {
|
|
45
|
+
try {
|
|
46
|
+
(0, _nodeFs.lstatSync)(target);
|
|
47
|
+
return true;
|
|
48
|
+
} catch (error) {
|
|
49
|
+
if (error.code === 'ENOENT') {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
throw error;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
var defaultRunProcess = function defaultRunProcess(_ref) {
|
|
56
|
+
var command = _ref.command,
|
|
57
|
+
args = _ref.args,
|
|
58
|
+
cwd = _ref.cwd,
|
|
59
|
+
capture = _ref.capture;
|
|
60
|
+
var result = (0, _nodeChild_process.spawnSync)(command, args, {
|
|
61
|
+
cwd: cwd,
|
|
62
|
+
encoding: 'utf8',
|
|
63
|
+
stdio: capture ? 'pipe' : 'inherit'
|
|
64
|
+
});
|
|
65
|
+
return {
|
|
66
|
+
status: result.status,
|
|
67
|
+
stdout: typeof result.stdout === 'string' ? result.stdout : '',
|
|
68
|
+
stderr: typeof result.stderr === 'string' ? result.stderr : '',
|
|
69
|
+
error: result.error
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
var processFailureMessage = function processFailureMessage(result, fallback) {
|
|
73
|
+
var _result$error;
|
|
74
|
+
var details = result.stderr.trim() || ((_result$error = result.error) === null || _result$error === void 0 ? void 0 : _result$error.message);
|
|
75
|
+
return details ? "".concat(fallback, ": ").concat(details) : fallback;
|
|
76
|
+
};
|
|
77
|
+
var isSkillsInstallerUnavailableFailure = function isSkillsInstallerUnavailableFailure(result) {
|
|
78
|
+
var _result$error2, _result$error$message, _result$error3;
|
|
79
|
+
if (result.status === null || (_result$error2 = result.error) !== null && _result$error2 !== void 0 && _result$error2.code && SKILLS_INSTALLER_UNAVAILABLE_ERROR_CODES.has(result.error.code)) {
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
var details = "".concat(result.stdout, "\n").concat(result.stderr, "\n").concat((_result$error$message = (_result$error3 = result.error) === null || _result$error3 === void 0 ? void 0 : _result$error3.message) !== null && _result$error$message !== void 0 ? _result$error$message : '').toLowerCase();
|
|
83
|
+
if (!details.trim()) {
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
return ['401 unauthorized', '403 forbidden', '404 not found', 'authentication required', 'could not resolve', 'e401', 'e403', 'e404', 'eneedauth', 'failed to fetch', 'network error', 'not in this registry', 'registry unavailable', 'unable to authenticate', 'unable to resolve'].some(function (message) {
|
|
87
|
+
return details.includes(message);
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
var createNotInstalledSkillResults = function createNotInstalledSkillResults(reason) {
|
|
91
|
+
return SKILLS.map(function (skillDefinition) {
|
|
92
|
+
return {
|
|
93
|
+
name: skillDefinition.name,
|
|
94
|
+
status: 'not-installed',
|
|
95
|
+
path: skillDefinition.relativePath,
|
|
96
|
+
reason: reason
|
|
97
|
+
};
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
var findRepositoryRoot = function findRepositoryRoot(cwd) {
|
|
101
|
+
var current = _nodePath.default.resolve(cwd);
|
|
102
|
+
while (true) {
|
|
103
|
+
if (defaultPathExists(_nodePath.default.join(current, GIT_MARKER))) {
|
|
104
|
+
return current;
|
|
105
|
+
}
|
|
106
|
+
var parent = _nodePath.default.dirname(current);
|
|
107
|
+
if (parent === current) {
|
|
108
|
+
return undefined;
|
|
109
|
+
}
|
|
110
|
+
current = parent;
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
var writeUsageError = function writeUsageError(_ref2) {
|
|
114
|
+
var message = _ref2.message,
|
|
115
|
+
json = _ref2.json,
|
|
116
|
+
writer = _ref2.writer;
|
|
117
|
+
if (json) {
|
|
118
|
+
(0, _writeJsonEnvelope.writeJsonEnvelope)({
|
|
119
|
+
envelope: (0, _createErrorEnvelope.createErrorEnvelope)({
|
|
120
|
+
command: 'init',
|
|
121
|
+
code: 'USAGE_ERROR',
|
|
122
|
+
message: message
|
|
123
|
+
}),
|
|
124
|
+
writer: writer
|
|
125
|
+
});
|
|
126
|
+
} else {
|
|
127
|
+
(0, _writeHumanError.writeHumanError)({
|
|
128
|
+
message: message,
|
|
129
|
+
writer: writer
|
|
130
|
+
});
|
|
131
|
+
writer.err('Usage: init');
|
|
132
|
+
}
|
|
133
|
+
return _types.ExitCode.UsageError;
|
|
134
|
+
};
|
|
135
|
+
var validateInput = function validateInput(input) {
|
|
136
|
+
if (input.positionals.length > 0) {
|
|
137
|
+
return '`init` does not accept positional arguments.';
|
|
138
|
+
}
|
|
139
|
+
var allowedFlags = new Set(['json']);
|
|
140
|
+
var unknownFlag = Object.keys(input.flags).find(function (flag) {
|
|
141
|
+
return !allowedFlags.has(flag);
|
|
142
|
+
});
|
|
143
|
+
if (unknownFlag) {
|
|
144
|
+
return "Unknown flag \"--".concat(unknownFlag, "\".");
|
|
145
|
+
}
|
|
146
|
+
return undefined;
|
|
147
|
+
};
|
|
148
|
+
var runInitCommand = exports.runInitCommand = /*#__PURE__*/function () {
|
|
149
|
+
var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(_ref3) {
|
|
150
|
+
var input, json, writer, invocation, cwd, usageError, projectRoot, skills, repositorySetupErrors, npxCommand, skillsInstallerUnavailable, skillHumanOutput, _loop, _i, _SKILLS, skillResultsByName, _iterator, _step, line, atlasCwd, atlasPluginStatus, _atlasCheck$error, atlasCheck, installResult, verification, data;
|
|
151
|
+
return _regenerator.default.wrap(function (_context2) {
|
|
152
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
153
|
+
case 0:
|
|
154
|
+
input = _ref3.input, json = _ref3.json, writer = _ref3.writer, invocation = _ref3.invocation, cwd = _ref3.cwd;
|
|
155
|
+
usageError = validateInput(input);
|
|
156
|
+
if (!usageError) {
|
|
157
|
+
_context2.next = 1;
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
160
|
+
return _context2.abrupt("return", writeUsageError({
|
|
161
|
+
message: usageError,
|
|
162
|
+
json: json,
|
|
163
|
+
writer: writer
|
|
164
|
+
}));
|
|
165
|
+
case 1:
|
|
166
|
+
projectRoot = findRepositoryRoot(cwd);
|
|
167
|
+
skills = [];
|
|
168
|
+
repositorySetupErrors = [];
|
|
169
|
+
if (projectRoot) {
|
|
170
|
+
_context2.next = 2;
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
skills.push.apply(skills, (0, _toConsumableArray2.default)(createNotInstalledSkillResults('not-in-git-repository')));
|
|
174
|
+
if (!json) {
|
|
175
|
+
writer.out('– Repository-local skills not installed because the current directory is not in a Git repository');
|
|
176
|
+
}
|
|
177
|
+
_context2.next = 7;
|
|
178
|
+
break;
|
|
179
|
+
case 2:
|
|
180
|
+
npxCommand = process.platform === 'win32' ? 'npx.cmd' : 'npx';
|
|
181
|
+
skillsInstallerUnavailable = false;
|
|
182
|
+
skillHumanOutput = [];
|
|
183
|
+
_loop = /*#__PURE__*/_regenerator.default.mark(function _loop() {
|
|
184
|
+
var skillDefinition, skillPath, skillEntrypoint, skillPathExists, skillEntrypointExists, isCurrent, skillResult, result, missingRequiredFile, missingRelativePath, statusMessage, _t;
|
|
185
|
+
return _regenerator.default.wrap(function (_context) {
|
|
186
|
+
while (1) switch (_context.prev = _context.next) {
|
|
187
|
+
case 0:
|
|
188
|
+
skillDefinition = _SKILLS[_i];
|
|
189
|
+
_context.prev = 1;
|
|
190
|
+
skillPath = _nodePath.default.join(projectRoot, skillDefinition.relativePath);
|
|
191
|
+
skillEntrypoint = _nodePath.default.join(skillPath, SKILL_ENTRYPOINT);
|
|
192
|
+
skillPathExists = defaultPathExists(skillPath);
|
|
193
|
+
skillEntrypointExists = defaultPathExists(skillEntrypoint);
|
|
194
|
+
isCurrent = skillDefinition.requiredFiles.every(function (requiredFile) {
|
|
195
|
+
return defaultPathExists(_nodePath.default.join(skillPath, requiredFile));
|
|
196
|
+
});
|
|
197
|
+
if (!(skillPathExists && !skillEntrypointExists)) {
|
|
198
|
+
_context.next = 2;
|
|
199
|
+
break;
|
|
200
|
+
}
|
|
201
|
+
throw new Error("Cannot install the ".concat(skillDefinition.displayName, " skill because ").concat(skillDefinition.relativePath, " already exists without a ").concat(SKILL_ENTRYPOINT, ". Move or remove it, then run init again."));
|
|
202
|
+
case 2:
|
|
203
|
+
if (!isCurrent) {
|
|
204
|
+
_context.next = 3;
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
skillResult = {
|
|
208
|
+
name: skillDefinition.name,
|
|
209
|
+
status: 'already-installed',
|
|
210
|
+
path: skillDefinition.relativePath
|
|
211
|
+
};
|
|
212
|
+
_context.next = 7;
|
|
213
|
+
break;
|
|
214
|
+
case 3:
|
|
215
|
+
result = defaultRunProcess({
|
|
216
|
+
command: npxCommand,
|
|
217
|
+
args: ['--yes', SKILLS_INSTALLER_PACKAGE, 'add', skillDefinition.name, '--universal', '--yes'],
|
|
218
|
+
cwd: projectRoot,
|
|
219
|
+
capture: true
|
|
220
|
+
});
|
|
221
|
+
if (!(result.status !== 0)) {
|
|
222
|
+
_context.next = 5;
|
|
223
|
+
break;
|
|
224
|
+
}
|
|
225
|
+
if (!isSkillsInstallerUnavailableFailure(result)) {
|
|
226
|
+
_context.next = 4;
|
|
227
|
+
break;
|
|
228
|
+
}
|
|
229
|
+
skillsInstallerUnavailable = true;
|
|
230
|
+
return _context.abrupt("return", 1);
|
|
231
|
+
case 4:
|
|
232
|
+
throw new Error(processFailureMessage(result, "Failed to install the ".concat(skillDefinition.displayName, " skill")));
|
|
233
|
+
case 5:
|
|
234
|
+
missingRequiredFile = skillDefinition.requiredFiles.find(function (requiredFile) {
|
|
235
|
+
return !defaultPathExists(_nodePath.default.join(skillPath, requiredFile));
|
|
236
|
+
});
|
|
237
|
+
if (!missingRequiredFile) {
|
|
238
|
+
_context.next = 6;
|
|
239
|
+
break;
|
|
240
|
+
}
|
|
241
|
+
missingRelativePath = "".concat(skillDefinition.relativePath, "/").concat(missingRequiredFile);
|
|
242
|
+
throw new Error("The skill installer completed without creating ".concat(missingRelativePath, "."));
|
|
243
|
+
case 6:
|
|
244
|
+
skillResult = {
|
|
245
|
+
name: skillDefinition.name,
|
|
246
|
+
status: skillEntrypointExists ? 'updated' : 'installed',
|
|
247
|
+
path: skillDefinition.relativePath
|
|
248
|
+
};
|
|
249
|
+
case 7:
|
|
250
|
+
skills.push(skillResult);
|
|
251
|
+
if (!json) {
|
|
252
|
+
statusMessage = skillResult.status === 'already-installed' ? 'already set up' : skillResult.status;
|
|
253
|
+
skillHumanOutput.push("\u2713 ".concat(skillDefinition.displayName, " skill ").concat(statusMessage, " at ").concat(skillDefinition.relativePath));
|
|
254
|
+
}
|
|
255
|
+
_context.next = 9;
|
|
256
|
+
break;
|
|
257
|
+
case 8:
|
|
258
|
+
_context.prev = 8;
|
|
259
|
+
_t = _context["catch"](1);
|
|
260
|
+
repositorySetupErrors.push(_t instanceof Error ? _t : new Error("Failed to set up the ".concat(skillDefinition.displayName, " skill.")));
|
|
261
|
+
case 9:
|
|
262
|
+
case "end":
|
|
263
|
+
return _context.stop();
|
|
264
|
+
}
|
|
265
|
+
}, _loop, null, [[1, 8]]);
|
|
266
|
+
});
|
|
267
|
+
_i = 0, _SKILLS = SKILLS;
|
|
268
|
+
case 3:
|
|
269
|
+
if (!(_i < _SKILLS.length)) {
|
|
270
|
+
_context2.next = 6;
|
|
271
|
+
break;
|
|
272
|
+
}
|
|
273
|
+
return _context2.delegateYield(_loop(), "t0", 4);
|
|
274
|
+
case 4:
|
|
275
|
+
if (!_context2.t0) {
|
|
276
|
+
_context2.next = 5;
|
|
277
|
+
break;
|
|
278
|
+
}
|
|
279
|
+
return _context2.abrupt("continue", 6);
|
|
280
|
+
case 5:
|
|
281
|
+
_i++;
|
|
282
|
+
_context2.next = 3;
|
|
283
|
+
break;
|
|
284
|
+
case 6:
|
|
285
|
+
if (skillsInstallerUnavailable) {
|
|
286
|
+
skillResultsByName = new Map(skills.map(function (skill) {
|
|
287
|
+
return [skill.name, skill];
|
|
288
|
+
}));
|
|
289
|
+
skills.splice.apply(skills, [0, skills.length].concat((0, _toConsumableArray2.default)(SKILLS.map(function (skillDefinition) {
|
|
290
|
+
var _skillResultsByName$g;
|
|
291
|
+
return (_skillResultsByName$g = skillResultsByName.get(skillDefinition.name)) !== null && _skillResultsByName$g !== void 0 ? _skillResultsByName$g : {
|
|
292
|
+
name: skillDefinition.name,
|
|
293
|
+
status: 'not-installed',
|
|
294
|
+
path: skillDefinition.relativePath,
|
|
295
|
+
reason: SKILLS_INSTALLER_UNAVAILABLE_REASON
|
|
296
|
+
};
|
|
297
|
+
}))));
|
|
298
|
+
}
|
|
299
|
+
if (!json) {
|
|
300
|
+
_iterator = _createForOfIteratorHelper(skillHumanOutput);
|
|
301
|
+
try {
|
|
302
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
303
|
+
line = _step.value;
|
|
304
|
+
writer.out(line);
|
|
305
|
+
}
|
|
306
|
+
} catch (err) {
|
|
307
|
+
_iterator.e(err);
|
|
308
|
+
} finally {
|
|
309
|
+
_iterator.f();
|
|
310
|
+
}
|
|
311
|
+
if (skillsInstallerUnavailable) {
|
|
312
|
+
writer.out(skillHumanOutput.length > 0 ? '– Remaining repository-local skills skipped because @atlassian/skills is unavailable; npx @atlaskit/ads-cli remains available' : '– Repository-local skills skipped because @atlassian/skills is unavailable; npx @atlaskit/ads-cli remains available');
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
case 7:
|
|
316
|
+
atlasCwd = projectRoot !== null && projectRoot !== void 0 ? projectRoot : _nodePath.default.resolve(cwd);
|
|
317
|
+
if (!(invocation === _cliMetadata.CLI_ATLAS_INVOCATION)) {
|
|
318
|
+
_context2.next = 8;
|
|
319
|
+
break;
|
|
320
|
+
}
|
|
321
|
+
atlasPluginStatus = 'already-installed';
|
|
322
|
+
if (!json) {
|
|
323
|
+
writer.out('✓ Atlas CLI ADS plugin already available');
|
|
324
|
+
}
|
|
325
|
+
_context2.next = 13;
|
|
326
|
+
break;
|
|
327
|
+
case 8:
|
|
328
|
+
atlasCheck = defaultRunProcess({
|
|
329
|
+
command: 'atlas',
|
|
330
|
+
args: ['ads', '--help'],
|
|
331
|
+
cwd: atlasCwd,
|
|
332
|
+
capture: true
|
|
333
|
+
});
|
|
334
|
+
if (!(atlasCheck.status === 0)) {
|
|
335
|
+
_context2.next = 9;
|
|
336
|
+
break;
|
|
337
|
+
}
|
|
338
|
+
atlasPluginStatus = 'already-installed';
|
|
339
|
+
if (!json) {
|
|
340
|
+
writer.out('✓ Atlas CLI ADS plugin already available');
|
|
341
|
+
}
|
|
342
|
+
_context2.next = 13;
|
|
343
|
+
break;
|
|
344
|
+
case 9:
|
|
345
|
+
if (!(((_atlasCheck$error = atlasCheck.error) === null || _atlasCheck$error === void 0 ? void 0 : _atlasCheck$error.code) === 'ENOENT')) {
|
|
346
|
+
_context2.next = 10;
|
|
347
|
+
break;
|
|
348
|
+
}
|
|
349
|
+
atlasPluginStatus = 'atlas-cli-unavailable';
|
|
350
|
+
if (!json) {
|
|
351
|
+
writer.out('– Atlas CLI is unavailable; use npx @atlaskit/ads-cli for ADS commands');
|
|
352
|
+
}
|
|
353
|
+
_context2.next = 13;
|
|
354
|
+
break;
|
|
355
|
+
case 10:
|
|
356
|
+
installResult = defaultRunProcess({
|
|
357
|
+
command: 'atlas',
|
|
358
|
+
args: ['plugin', 'install', '--name', 'ads'],
|
|
359
|
+
cwd: atlasCwd,
|
|
360
|
+
capture: json
|
|
361
|
+
});
|
|
362
|
+
if (!(installResult.status !== 0)) {
|
|
363
|
+
_context2.next = 11;
|
|
364
|
+
break;
|
|
365
|
+
}
|
|
366
|
+
throw new Error(processFailureMessage(installResult, 'Failed to install the Atlas CLI ADS plugin. npx @atlaskit/ads-cli remains available'));
|
|
367
|
+
case 11:
|
|
368
|
+
verification = defaultRunProcess({
|
|
369
|
+
command: 'atlas',
|
|
370
|
+
args: ['ads', '--help'],
|
|
371
|
+
cwd: atlasCwd,
|
|
372
|
+
capture: true
|
|
373
|
+
});
|
|
374
|
+
if (!(verification.status !== 0)) {
|
|
375
|
+
_context2.next = 12;
|
|
376
|
+
break;
|
|
377
|
+
}
|
|
378
|
+
throw new Error('The Atlas CLI ADS plugin was installed but `atlas ads --help` did not succeed. npx @atlaskit/ads-cli remains available.');
|
|
379
|
+
case 12:
|
|
380
|
+
atlasPluginStatus = 'installed';
|
|
381
|
+
if (!json) {
|
|
382
|
+
writer.out('✓ Atlas CLI ADS plugin installed');
|
|
383
|
+
}
|
|
384
|
+
case 13:
|
|
385
|
+
if (!(repositorySetupErrors.length > 0)) {
|
|
386
|
+
_context2.next = 14;
|
|
387
|
+
break;
|
|
388
|
+
}
|
|
389
|
+
throw new Error(repositorySetupErrors.map(function (error) {
|
|
390
|
+
return error.message;
|
|
391
|
+
}).join('\n'));
|
|
392
|
+
case 14:
|
|
393
|
+
if (!(skills.length !== SKILLS.length)) {
|
|
394
|
+
_context2.next = 15;
|
|
395
|
+
break;
|
|
396
|
+
}
|
|
397
|
+
throw new Error('Failed to determine the ADS repository setup result.');
|
|
398
|
+
case 15:
|
|
399
|
+
data = {
|
|
400
|
+
projectRoot: projectRoot !== null && projectRoot !== void 0 ? projectRoot : null,
|
|
401
|
+
skills: skills,
|
|
402
|
+
atlas: {
|
|
403
|
+
status: atlasPluginStatus
|
|
404
|
+
}
|
|
405
|
+
};
|
|
406
|
+
if (json) {
|
|
407
|
+
(0, _writeJsonEnvelope.writeJsonEnvelope)({
|
|
408
|
+
envelope: (0, _createSuccessEnvelope.createSuccessEnvelope)({
|
|
409
|
+
envelopeType: 'init',
|
|
410
|
+
command: 'init',
|
|
411
|
+
data: data,
|
|
412
|
+
meta: {}
|
|
413
|
+
}),
|
|
414
|
+
writer: writer
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
return _context2.abrupt("return", _types.ExitCode.Ok);
|
|
418
|
+
case 16:
|
|
419
|
+
case "end":
|
|
420
|
+
return _context2.stop();
|
|
421
|
+
}
|
|
422
|
+
}, _callee);
|
|
423
|
+
}));
|
|
424
|
+
return function runInitCommand(_x) {
|
|
425
|
+
return _ref4.apply(this, arguments);
|
|
426
|
+
};
|
|
427
|
+
}();
|
package/dist/es2019/cli.js
CHANGED
|
@@ -14,6 +14,7 @@ import { commands } from './commands/definitions';
|
|
|
14
14
|
import { getCommand } from './commands/get-command';
|
|
15
15
|
import { getVersion } from './commands/get-version';
|
|
16
16
|
import { importToolHandler } from './commands/import-tool-handler';
|
|
17
|
+
import { runInitCommand } from './commands/init';
|
|
17
18
|
import { runTool } from './commands/run-tool';
|
|
18
19
|
import { createErrorEnvelope } from './envelope/create-error-envelope';
|
|
19
20
|
import { createSuccessEnvelope } from './envelope/create-success-envelope';
|
|
@@ -53,6 +54,9 @@ const buildHelpText = invocation => {
|
|
|
53
54
|
return ` --${flag.name}${aliases}`.padEnd(18) + flag.description;
|
|
54
55
|
}).join('\n');
|
|
55
56
|
const examples = [{
|
|
57
|
+
command: 'init',
|
|
58
|
+
comment: 'set up repository-local frontend skills and the Atlas plugin'
|
|
59
|
+
}, {
|
|
56
60
|
command: 'search contrast',
|
|
57
61
|
comment: 'unified: components, tokens, icons & docs'
|
|
58
62
|
}, {
|
|
@@ -111,6 +115,15 @@ const runRegistryCommand = async ({
|
|
|
111
115
|
invocation
|
|
112
116
|
}) => {
|
|
113
117
|
var _resolved$meta3;
|
|
118
|
+
if (command.action === 'init') {
|
|
119
|
+
return runInitCommand({
|
|
120
|
+
input,
|
|
121
|
+
json,
|
|
122
|
+
writer,
|
|
123
|
+
invocation,
|
|
124
|
+
cwd: process.cwd()
|
|
125
|
+
});
|
|
126
|
+
}
|
|
114
127
|
const resolved = command.resolve(input);
|
|
115
128
|
|
|
116
129
|
// A resolver returning `{ error }` indicates invalid input (a usage error).
|
|
@@ -366,6 +379,7 @@ const runBatchChild = async ({
|
|
|
366
379
|
request,
|
|
367
380
|
invocation
|
|
368
381
|
}) => {
|
|
382
|
+
var _getCommand;
|
|
369
383
|
const parsed = parseArgs(request.argv);
|
|
370
384
|
let response;
|
|
371
385
|
if (!parsed.command) {
|
|
@@ -380,6 +394,12 @@ const runBatchChild = async ({
|
|
|
380
394
|
code: 'USAGE_ERROR',
|
|
381
395
|
message: 'Nested batch requests are not supported.'
|
|
382
396
|
});
|
|
397
|
+
} else if ((_getCommand = getCommand(parsed.command)) !== null && _getCommand !== void 0 && _getCommand.action) {
|
|
398
|
+
response = createErrorEnvelope({
|
|
399
|
+
command: parsed.command,
|
|
400
|
+
code: 'USAGE_ERROR',
|
|
401
|
+
message: `Action command "${parsed.command}" cannot run inside batch.`
|
|
402
|
+
});
|
|
383
403
|
} else {
|
|
384
404
|
const captured = createCapturedWriter();
|
|
385
405
|
await run([...request.argv, '--json'], captured, {
|
|
@@ -38,6 +38,11 @@ const limitFlag = {
|
|
|
38
38
|
alias: 'l',
|
|
39
39
|
description: 'Maximum matches per term.'
|
|
40
40
|
};
|
|
41
|
+
const searchLimitFlag = {
|
|
42
|
+
...limitFlag,
|
|
43
|
+
default: 2,
|
|
44
|
+
description: 'Maximum matches per term, per result type (default: 2).'
|
|
45
|
+
};
|
|
41
46
|
|
|
42
47
|
/**
|
|
43
48
|
* Parse and validate the `--limit` flag.
|
|
@@ -537,8 +542,18 @@ const resolveBatch = input => {
|
|
|
537
542
|
* The full set of CLI commands. Order here is the order shown by `manifest` and `--help`.
|
|
538
543
|
*/
|
|
539
544
|
export const commands = [{
|
|
545
|
+
name: 'init',
|
|
546
|
+
action: 'init',
|
|
547
|
+
description: 'Set up the ADS, UI Styling Standard, and Accessibility Foundation skills at the Git repository root and install the Atlas CLI ADS plugin.',
|
|
548
|
+
usage: 'init',
|
|
549
|
+
arguments: [],
|
|
550
|
+
flags: [],
|
|
551
|
+
examples: ['init'],
|
|
552
|
+
responseTypes: ['ads-cli/init'],
|
|
553
|
+
envelopeType: () => 'init'
|
|
554
|
+
}, {
|
|
540
555
|
name: 'search',
|
|
541
|
-
description: 'Fuzzy-search ADS components, tokens, icons, and docs together (or narrow results with --type).',
|
|
556
|
+
description: 'Fuzzy-search ADS components, tokens, icons, and docs together (or narrow results with --type). Returns up to 2 matches per term, per result type by default; override with --limit.',
|
|
542
557
|
usage: `search <query...> [--type ${Object.keys(SEARCH_TYPE_VALUES).join('|')}] [--limit N]`,
|
|
543
558
|
arguments: [{
|
|
544
559
|
name: 'query',
|
|
@@ -553,7 +568,7 @@ export const commands = [{
|
|
|
553
568
|
alias: 't',
|
|
554
569
|
choices: Object.keys(SEARCH_TYPE_VALUES),
|
|
555
570
|
description: `Narrow the search to a single kind: ${Object.keys(SEARCH_TYPE_VALUES).join(', ')}.`
|
|
556
|
-
},
|
|
571
|
+
}, searchLimitFlag],
|
|
557
572
|
examples: ['search button', 'search space color --type token', 'search add --type icon --limit 5', 'search contrast --type docs'],
|
|
558
573
|
responseTypes: ['ads-cli/search', ...Object.values(searchKindTools).map(tool => `ads-cli/${tool.envelopeType}`)],
|
|
559
574
|
// With `--type`, the result is a single kind (compact per-row rendering). Without it, the
|