1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const cli_ux_1 = require("cli-ux");
|
4 | const globby = require("globby");
|
5 | const _ = require("lodash");
|
6 | const path = require("path");
|
7 | const Config = require(".");
|
8 | const debug = require('debug')('@anycli/config');
|
9 | var Manifest;
|
10 | (function (Manifest) {
|
11 | function build(version, dir, findCommand) {
|
12 | debug(`loading IDs from ${dir}`);
|
13 | const ids = globby.sync(['**/*.+(js|ts)', '!**/*.+(d.ts|test.ts|test.js)'], { cwd: dir })
|
14 | .map(file => {
|
15 | const p = path.parse(file);
|
16 | const topics = p.dir.split('/');
|
17 | let command = p.name !== 'index' && p.name;
|
18 | return _([...topics, command]).compact().join(':');
|
19 | });
|
20 | debug('found ids', ids);
|
21 | let commands = ids.map(id => {
|
22 | try {
|
23 | return [id, Config.Command.toCached(findCommand(id))];
|
24 | }
|
25 | catch (err) {
|
26 | cli_ux_1.default.warn(err);
|
27 | }
|
28 | });
|
29 | return {
|
30 | version,
|
31 | commands: _(commands)
|
32 | .compact()
|
33 | .fromPairs()
|
34 | .value()
|
35 | };
|
36 | }
|
37 | Manifest.build = build;
|
38 | })(Manifest = exports.Manifest || (exports.Manifest = {}));
|