@hop-top/kit 0.5.0-alpha.6 → 0.5.0-alpha.7
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 +36 -0
- package/LICENSE-cobra.txt +174 -0
- package/NOTICE +15 -0
- package/README.md +3 -3
- package/dist/{alias-BOj0-VAr.d.ts → alias-BsJ2jGqQ.d.ts} +9 -1
- package/dist/alias.d.ts +1 -1
- package/dist/alias.js +4 -2
- package/dist/chunk-263IZ6Z6.js +915 -0
- package/dist/{chunk-S45UHXQF.js → chunk-DIDN4X5C.js} +8 -6
- package/dist/{chunk-7FDIN5KE.js → chunk-GHPJJV5L.js} +8 -4
- package/dist/chunk-JKMQSAJP.js +174 -0
- package/dist/chunk-JZ22ZUFA.js +1131 -0
- package/dist/{chunk-GAZPYCQD.js → chunk-NLMS7HGP.js} +93 -35
- package/dist/chunk-QQQYCWSC.js +240 -0
- package/dist/chunk-XJTRY453.js +868 -0
- package/dist/cli.js +6 -4
- package/dist/completion-sDKVXPUL.d.ts +109 -0
- package/dist/completion-values-By-mnjNt.d.ts +142 -0
- package/dist/completion-values.d.ts +1 -0
- package/dist/completion-values.js +29 -0
- package/dist/completion.d.ts +2 -1
- package/dist/completion.js +23 -2
- package/dist/compliance-AxFf-uMy.d.ts +60 -0
- package/dist/compliance.d.ts +1 -0
- package/dist/compliance.js +17 -0
- package/dist/config-CaK60ByQ.d.ts +241 -0
- package/dist/config.d.ts +1 -1
- package/dist/config.js +4 -2
- package/dist/index.d.ts +7 -5
- package/dist/index.js +26 -18
- package/dist/log-CkaxMX3U.d.ts +115 -0
- package/dist/log.d.ts +1 -1
- package/dist/log.js +2 -2
- package/dist/toolspec-UrWnoJ3Y.d.ts +336 -0
- package/dist/toolspec.d.ts +2 -1
- package/dist/toolspec.js +27 -2
- package/package.json +19 -3
- package/src/alias.test.ts +110 -1
- package/src/alias.ts +19 -4
- package/src/cli.ts +5 -0
- package/src/completion-scripts.ts +16 -0
- package/src/completion-values.test.ts +70 -10
- package/src/completion-values.ts +170 -66
- package/src/completion.conformance.test.ts +297 -0
- package/src/completion.test.ts +256 -145
- package/src/completion.ts +764 -121
- package/src/config-merge.test.ts +425 -0
- package/src/config.test.ts +41 -0
- package/src/config.ts +265 -18
- package/src/index.test.ts +2 -1
- package/src/index.ts +5 -1
- package/src/log.test.ts +270 -1
- package/src/log.ts +172 -44
- package/src/published-types.test.ts +18 -0
- package/src/toolspec-internal.ts +197 -0
- package/src/toolspec-manifest.test.ts +82 -0
- package/src/toolspec-manifest.ts +404 -0
- package/src/toolspec-spec-schemas.ts +12 -0
- package/src/toolspec-spec.test.ts +273 -0
- package/src/toolspec-spec.ts +458 -0
- package/src/toolspec.from-command.test.ts +216 -0
- package/src/toolspec.ts +159 -0
- package/test/toolspec/fixture.ts +73 -0
- package/dist/chunk-6RFRV4VP.js +0 -128
- package/dist/chunk-IQXEISMC.js +0 -142
- package/dist/chunk-W7ERKNSQ.js +0 -171
- package/dist/completion-CVnPcWMZ.d.ts +0 -32
- package/dist/config-Bm9fBXch.d.ts +0 -134
- package/dist/log-uKjHsK-c.d.ts +0 -62
- package/dist/toolspec-DPBr18Ub.d.ts +0 -106
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
|
+
var _chunkJZ22ZUFAjs = require('./chunk-JZ22ZUFA.js');
|
|
4
|
+
|
|
5
|
+
|
|
3
6
|
var _chunkR5U7XKVJjs = require('./chunk-R5U7XKVJ.js');
|
|
4
7
|
|
|
5
8
|
// src/alias.ts
|
|
@@ -147,6 +150,7 @@ function findCommand(program, cmdPath) {
|
|
|
147
150
|
function bridgeAliases(program, store) {
|
|
148
151
|
const all = store.all();
|
|
149
152
|
for (const [name, target] of Object.entries(all)) {
|
|
153
|
+
_chunkJZ22ZUFAjs.registerRootAlias.call(void 0, program, name, target);
|
|
150
154
|
const parts = target.split(/\s+/);
|
|
151
155
|
if (parts.length === 1) {
|
|
152
156
|
const targetCmd = findCommand(program, target);
|
|
@@ -157,12 +161,10 @@ function bridgeAliases(program, store) {
|
|
|
157
161
|
}
|
|
158
162
|
const proxy = new (0, _commander.Command)(name).description(`Alias for ${target}`).allowUnknownOption(true).allowExcessArguments(true).action(function() {
|
|
159
163
|
const expanded = target.split(/\s+/);
|
|
160
|
-
program.
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
...this.args
|
|
165
|
-
]);
|
|
164
|
+
return program._parseCommand(
|
|
165
|
+
[],
|
|
166
|
+
[...expanded, ...this.args]
|
|
167
|
+
);
|
|
166
168
|
});
|
|
167
169
|
proxy.helpOption(false);
|
|
168
170
|
proxy._hidden = true;
|
|
@@ -1,22 +1,25 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunk72XZWQX7js = require('./chunk-72XZWQX7.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
+
var _chunkPOR5L2DGjs = require('./chunk-POR5L2DG.js');
|
|
6
7
|
|
|
7
8
|
|
|
9
|
+
var _chunkQPUCXQXTjs = require('./chunk-QPUCXQXT.js');
|
|
8
10
|
|
|
9
11
|
|
|
10
12
|
|
|
11
13
|
|
|
12
14
|
|
|
13
|
-
var _chunkKVG7YCTSjs = require('./chunk-KVG7YCTS.js');
|
|
14
15
|
|
|
15
16
|
|
|
16
|
-
var _chunk72XZWQX7js = require('./chunk-72XZWQX7.js');
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
var
|
|
19
|
+
var _chunkKVG7YCTSjs = require('./chunk-KVG7YCTS.js');
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
var _chunkJZ22ZUFAjs = require('./chunk-JZ22ZUFA.js');
|
|
20
23
|
|
|
21
24
|
|
|
22
25
|
var _chunkR5U7XKVJjs = require('./chunk-R5U7XKVJ.js');
|
|
@@ -558,6 +561,7 @@ ${cfg.help.disclaimer}` : cfg.description;
|
|
|
558
561
|
const flag = g.short ? `-${g.short}, --${g.name} <value>` : `--${g.name} <value>`;
|
|
559
562
|
program.option(flag, g.usage, _nullishCoalesce(g.default, () => ( "")));
|
|
560
563
|
}
|
|
564
|
+
_chunkJZ22ZUFAjs.installCompletionRequest.call(void 0, program);
|
|
561
565
|
applyHelpTheme(
|
|
562
566
|
program,
|
|
563
567
|
theme,
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
+
|
|
3
|
+
var _chunkR5U7XKVJjs = require('./chunk-R5U7XKVJ.js');
|
|
4
|
+
|
|
5
|
+
// src/completion-values.ts
|
|
6
|
+
var completion_values_exports = {};
|
|
7
|
+
_chunkR5U7XKVJjs.__export.call(void 0, completion_values_exports, {
|
|
8
|
+
CompletionRegistry: () => CompletionRegistry,
|
|
9
|
+
ShellCompDirective: () => ShellCompDirective,
|
|
10
|
+
configKeysCompleter: () => configKeysCompleter,
|
|
11
|
+
dirCompleter: () => dirCompleter,
|
|
12
|
+
directiveName: () => directiveName,
|
|
13
|
+
fileCompleter: () => fileCompleter,
|
|
14
|
+
funcCompleter: () => funcCompleter,
|
|
15
|
+
prefixedCompleter: () => prefixedCompleter,
|
|
16
|
+
resolveCompletions: () => resolveCompletions,
|
|
17
|
+
staticCompleter: () => staticCompleter,
|
|
18
|
+
staticValues: () => staticValues,
|
|
19
|
+
withDescription: () => withDescription
|
|
20
|
+
});
|
|
21
|
+
var ShellCompDirective = {
|
|
22
|
+
Default: 0,
|
|
23
|
+
Error: 1,
|
|
24
|
+
NoSpace: 2,
|
|
25
|
+
NoFileComp: 4,
|
|
26
|
+
FilterFileExt: 8,
|
|
27
|
+
FilterDirs: 16,
|
|
28
|
+
KeepOrder: 32
|
|
29
|
+
};
|
|
30
|
+
function directiveName(d) {
|
|
31
|
+
if (d >= 64) return `ERROR: unexpected ShellCompDirective value: ${d}`;
|
|
32
|
+
const names = [
|
|
33
|
+
[ShellCompDirective.Error, "ShellCompDirectiveError"],
|
|
34
|
+
[ShellCompDirective.NoSpace, "ShellCompDirectiveNoSpace"],
|
|
35
|
+
[ShellCompDirective.NoFileComp, "ShellCompDirectiveNoFileComp"],
|
|
36
|
+
[ShellCompDirective.FilterFileExt, "ShellCompDirectiveFilterFileExt"],
|
|
37
|
+
[ShellCompDirective.FilterDirs, "ShellCompDirectiveFilterDirs"],
|
|
38
|
+
[ShellCompDirective.KeepOrder, "ShellCompDirectiveKeepOrder"]
|
|
39
|
+
];
|
|
40
|
+
const set = names.filter(([bit]) => (d & bit) === bit).map(([, n]) => n);
|
|
41
|
+
return set.length ? set.join(", ") : "ShellCompDirectiveDefault";
|
|
42
|
+
}
|
|
43
|
+
async function resolveCompletions(c, toComplete, ctx = { commandPath: "", args: [] }) {
|
|
44
|
+
const f = c.fileFilter;
|
|
45
|
+
if (_optionalChain([f, 'optionalAccess', _ => _.kind]) === "dirs") {
|
|
46
|
+
return { completions: [], directive: ShellCompDirective.FilterDirs };
|
|
47
|
+
}
|
|
48
|
+
if (_optionalChain([f, 'optionalAccess', _2 => _2.kind]) === "extensions") {
|
|
49
|
+
return f.extensions.length === 0 ? { completions: [], directive: ShellCompDirective.Default } : { completions: [...f.extensions], directive: ShellCompDirective.FilterFileExt };
|
|
50
|
+
}
|
|
51
|
+
try {
|
|
52
|
+
const items = await c.complete(toComplete, ctx);
|
|
53
|
+
return {
|
|
54
|
+
completions: items.map(withDescription),
|
|
55
|
+
directive: ShellCompDirective.NoFileComp
|
|
56
|
+
};
|
|
57
|
+
} catch (e2) {
|
|
58
|
+
return { completions: [], directive: ShellCompDirective.Error };
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function withDescription(i) {
|
|
62
|
+
return i.description ? `${i.value} ${i.description}` : i.value;
|
|
63
|
+
}
|
|
64
|
+
var CompletionRegistry = class {
|
|
65
|
+
constructor() {
|
|
66
|
+
this.flags = /* @__PURE__ */ new Map();
|
|
67
|
+
this.args = /* @__PURE__ */ new Map();
|
|
68
|
+
}
|
|
69
|
+
register(flag, completer) {
|
|
70
|
+
this.flags.set(flag, completer);
|
|
71
|
+
}
|
|
72
|
+
registerArg(cmd, pos, completer) {
|
|
73
|
+
this.args.set(`${cmd}:${pos}`, completer);
|
|
74
|
+
}
|
|
75
|
+
forFlag(flag) {
|
|
76
|
+
return this.flags.get(flag);
|
|
77
|
+
}
|
|
78
|
+
forArg(cmd, pos) {
|
|
79
|
+
return this.args.get(`${cmd}:${pos}`);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
function filterByPrefix(items, prefix) {
|
|
83
|
+
if (!prefix) return [...items];
|
|
84
|
+
const lp = prefix.toLowerCase();
|
|
85
|
+
return items.filter((i) => i.value.toLowerCase().startsWith(lp));
|
|
86
|
+
}
|
|
87
|
+
function staticCompleter(...items) {
|
|
88
|
+
return {
|
|
89
|
+
complete(prefix) {
|
|
90
|
+
return filterByPrefix(items, prefix);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
function staticValues(...values) {
|
|
95
|
+
const items = values.map((v) => ({ value: v }));
|
|
96
|
+
return staticCompleter(...items);
|
|
97
|
+
}
|
|
98
|
+
function funcCompleter(fn) {
|
|
99
|
+
return {
|
|
100
|
+
complete(prefix, ctx = { commandPath: "", args: [] }) {
|
|
101
|
+
return fn(prefix, ctx);
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
function prefixedCompleter(dimension, values) {
|
|
106
|
+
const lower = dimension.toLowerCase();
|
|
107
|
+
const prepend = (items) => items.map((i) => {
|
|
108
|
+
const v = `${dimension}:${i.value}`;
|
|
109
|
+
return i.description ? { value: v, description: i.description } : { value: v };
|
|
110
|
+
});
|
|
111
|
+
return {
|
|
112
|
+
complete(prefix, ctx) {
|
|
113
|
+
const colonIdx = prefix.indexOf(":");
|
|
114
|
+
if (colonIdx < 0) {
|
|
115
|
+
const dim = `${dimension}:`;
|
|
116
|
+
return dim.toLowerCase().startsWith(prefix.toLowerCase()) ? [{ value: dim, description: `${dimension} values` }] : [];
|
|
117
|
+
}
|
|
118
|
+
if (prefix.slice(0, colonIdx).toLowerCase() !== lower) return [];
|
|
119
|
+
const inner = values.complete(prefix.slice(colonIdx + 1), ctx);
|
|
120
|
+
return Array.isArray(inner) ? prepend(inner) : inner.then(prepend);
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
function leafKeys(obj, prefix, out) {
|
|
125
|
+
for (const [k, v] of Object.entries(obj)) {
|
|
126
|
+
const full = prefix ? `${prefix}.${k.toLowerCase()}` : k.toLowerCase();
|
|
127
|
+
if (v != null && typeof v === "object" && !Array.isArray(v)) {
|
|
128
|
+
leafKeys(v, full, out);
|
|
129
|
+
} else {
|
|
130
|
+
out.add(full);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
function configKeysCompleter(config) {
|
|
135
|
+
return {
|
|
136
|
+
complete(prefix) {
|
|
137
|
+
const keys = /* @__PURE__ */ new Set();
|
|
138
|
+
leafKeys(config, "", keys);
|
|
139
|
+
return filterByPrefix([...keys].map((k) => ({ value: k })), prefix);
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
function fileCompleter(...extensions) {
|
|
144
|
+
return {
|
|
145
|
+
fileFilter: { kind: "extensions", extensions: [...extensions] },
|
|
146
|
+
complete() {
|
|
147
|
+
return extensions.map((e) => ({ value: e }));
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
function dirCompleter() {
|
|
152
|
+
return {
|
|
153
|
+
fileFilter: { kind: "dirs" },
|
|
154
|
+
complete() {
|
|
155
|
+
return [];
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
exports.ShellCompDirective = ShellCompDirective; exports.directiveName = directiveName; exports.resolveCompletions = resolveCompletions; exports.withDescription = withDescription; exports.CompletionRegistry = CompletionRegistry; exports.staticCompleter = staticCompleter; exports.staticValues = staticValues; exports.funcCompleter = funcCompleter; exports.prefixedCompleter = prefixedCompleter; exports.configKeysCompleter = configKeysCompleter; exports.fileCompleter = fileCompleter; exports.dirCompleter = dirCompleter; exports.completion_values_exports = completion_values_exports;
|