slack-term 1.31.1 → 1.31.3
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/dist/cli.js +78 -78
- package/package.json +1 -1
- package/ts/ask.ts +13 -2
- package/ts/todo.ts +21 -1
package/package.json
CHANGED
package/ts/ask.ts
CHANGED
|
@@ -112,9 +112,15 @@ export const ASK_RESOLVED_PREFIX = `:${ASK_RESOLVED_MARKER}: `;
|
|
|
112
112
|
*
|
|
113
113
|
* Both spellings are accepted on the way in: the shortcode is what Slack
|
|
114
114
|
* stores, and the glyph is what a body hand-edited in the Slack UI can be. */
|
|
115
|
+
/** How a keycap is WRITTEN into the body: the shortcode, because that is the
|
|
116
|
+
* form Slack stores and therefore the form that reads back unchanged. */
|
|
117
|
+
function askPill(i: number): string {
|
|
118
|
+
return `:${ASK_KEYCAPS[i]!.name}:`;
|
|
119
|
+
}
|
|
120
|
+
|
|
115
121
|
function askStripPill(line: string, i: number): string | null {
|
|
116
122
|
const k = ASK_KEYCAPS[i]!;
|
|
117
|
-
for (const pre of [
|
|
123
|
+
for (const pre of [askPill(i), k.glyph]) {
|
|
118
124
|
if (line.startsWith(`${pre} `)) return line.slice(pre.length + 1);
|
|
119
125
|
if (line === pre) return "";
|
|
120
126
|
}
|
|
@@ -142,7 +148,12 @@ export function askBuildText(question: string, body: string, reactable: string[]
|
|
|
142
148
|
lines.push("");
|
|
143
149
|
// Flattened: a choice is a pill label, and a newline in one would split it
|
|
144
150
|
// into a line the parser cannot tell from body text.
|
|
145
|
-
|
|
151
|
+
// Built with the SHORTCODE, matching what Slack stores. Building with the
|
|
152
|
+
// glyph worked only because the parser now accepts both — the body still
|
|
153
|
+
// came back as `:one:` and never matched what was sent. Writing the stored
|
|
154
|
+
// form keeps posted and read-back bytes identical, which is what the
|
|
155
|
+
// round-trip test can actually check. (`poll` already did this.)
|
|
156
|
+
lines.push(...reactable.map((s, i) => `${askPill(i)} ${askFlatten(s)}`));
|
|
146
157
|
if (overflow.length) {
|
|
147
158
|
lines.push("");
|
|
148
159
|
lines.push(...overflow.map((s, i) => `(${i + 11}) ${askFlatten(s)}`));
|
package/ts/todo.ts
CHANGED
|
@@ -199,9 +199,29 @@ export const MAX_RATE_LIMIT_RETRIES = 3;
|
|
|
199
199
|
|
|
200
200
|
export const _internals = {
|
|
201
201
|
// Swappable so tests never wait real time (same pattern as tail.ts).
|
|
202
|
-
|
|
202
|
+
//
|
|
203
|
+
// The spy is NOT the only defence, and must not be: a stub installed in a
|
|
204
|
+
// `beforeEach` is undone by any `vi.restoreAllMocks()` in a nested block's
|
|
205
|
+
// `afterEach`, and the next test then backs off for REAL seconds. That is
|
|
206
|
+
// what wedged CI — `todo.test.ts` burned the whole job budget in the retry
|
|
207
|
+
// path while every other file finished in under two seconds, and it never
|
|
208
|
+
// reproduced locally because the timing differs.
|
|
209
|
+
//
|
|
210
|
+
// So the backoff itself refuses to sleep under a test runner. Detecting the
|
|
211
|
+
// environment is ugly, but the alternative is a rule ("never let a nested
|
|
212
|
+
// afterEach restore this") that has to be remembered by every future test —
|
|
213
|
+
// and it already was not.
|
|
214
|
+
sleep: (ms: number): Promise<void> =>
|
|
215
|
+
isTestEnv() ? Promise.resolve() : new Promise((res) => setTimeout(res, ms)),
|
|
203
216
|
};
|
|
204
217
|
|
|
218
|
+
/** True under vitest or `bun test`. Both set NODE_ENV=test; vitest also sets
|
|
219
|
+
* VITEST. Checked at call time, not at import, so a test that deliberately
|
|
220
|
+
* wants the real timer can clear it. */
|
|
221
|
+
function isTestEnv(): boolean {
|
|
222
|
+
return !!process.env.VITEST || process.env.NODE_ENV === "test" || !!process.env.BUN_TEST;
|
|
223
|
+
}
|
|
224
|
+
|
|
205
225
|
/** Run an API call, backing off and retrying on 429. Mirrors tail.ts: warn on
|
|
206
226
|
* stderr, sleep `retryAfter`, try again — but bounded, so a persistently
|
|
207
227
|
* throttled workspace fails loudly instead of hanging forever. */
|