@hardfin/cli 0.1.1-dev.82 → 0.1.1-dev.84

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.
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="da9bdd25-3557-500c-ae11-3ed37eaa10ca")}catch(e){}}();
4
- import { c as toOutdatedTo, d as toJSON, f as toLastFailureCode, i as toUpdateCheckRefusal, n as isReminderDue, o as toPackageDirectory, r as toCheck, t as PACKAGE, y as API_VERSION } from "./check-CPd5pMmK.js";
3
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="565a1123-9337-547d-afb1-6f0586e6040c")}catch(e){}}();
4
+ import { O as API_VERSION, _ as toOutdatedTo, b as toJSON, d as isReminderDue, f as toCheck, h as toPackageDirectory, i as toSkillsSentence, n as isSkillsReminderDue, p as toUpdateCheckRefusal, r as toSkillsCheck, u as PACKAGE, x as toLastFailureCode } from "./check-Di68wbxY.js";
5
5
  //#region src/update/notice.ts
6
6
  /**
7
7
  * The failures a newer CLI may not have, because each can mean the API changed under this one:
@@ -21,6 +21,12 @@ const QUIET_COMMANDS = /* @__PURE__ */ new Set([
21
21
  "update",
22
22
  "__complete"
23
23
  ]);
24
+ /** Commands that report the skills in their own output, and so never repeat it in a notice. */
25
+ const SKILLS_QUIET_COMMANDS = /* @__PURE__ */ new Set([
26
+ ...QUIET_COMMANDS,
27
+ "init",
28
+ "status"
29
+ ]);
24
30
  /** The global flags that take a value, which come before the command's name. */
25
31
  const VALUE_FLAGS = /* @__PURE__ */ new Set([
26
32
  "--api-url",
@@ -35,22 +41,60 @@ function startUpdateCheck(args, env = process.env) {
35
41
  return toPending(false);
36
42
  }
37
43
  /**
38
- * writeUpdateNotice says on stderr when a newer CLI is published. It repeats a plain reminder
39
- * once a day, and says it every time a command fails in a way a newer CLI may fix.
44
+ * writeUpdateNotice says on stderr when a newer CLI is published, or when the Hardfin skills here
45
+ * are missing or out of step with this CLI. Both go in one line, so there is one setup notice.
40
46
  */
41
47
  async function writeUpdateNotice(pending, args) {
42
- if (!pending) return;
48
+ const isJSON = args.includes("--json") || !process.stdout.isTTY;
49
+ const update = pending ? await toUpdateNoticeDue(pending) : void 0;
50
+ const skills = toSkillsNotice(args, isJSON);
51
+ if (update && skills) writeNotice({
52
+ fields: {
53
+ ...update.fields,
54
+ skills: skills.fields
55
+ },
56
+ text: `${update.text} ${skills.text}`
57
+ }, isJSON);
58
+ else if (update ?? skills) writeNotice(update ?? skills, isJSON);
59
+ }
60
+ /**
61
+ * toSkillsNotice says what the skills check found, when it found something to fix. An agent hears
62
+ * it on every call, a person at a terminal once a day in each folder, and it never fails a command.
63
+ */
64
+ function toSkillsNotice(args, isJSON) {
65
+ if (SKILLS_QUIET_COMMANDS.has(toCommandName(args) ?? "")) return;
66
+ try {
67
+ const check = toSkillsCheck();
68
+ const text = toSkillsSentence(check);
69
+ if (text === void 0 || !isJSON && !isSkillsReminderDue()) return;
70
+ const skill = check.state === "missing" ? null : "hardfin-upgrade";
71
+ return {
72
+ fields: {
73
+ event: "skills_check",
74
+ code: `skills_${check.state}`,
75
+ release: check.release,
76
+ range: check.range,
77
+ command: check.command,
78
+ skill
79
+ },
80
+ text
81
+ };
82
+ } catch {
83
+ return;
84
+ }
85
+ }
86
+ /**
87
+ * toUpdateNoticeDue answers the update notice when one is due. It repeats a plain reminder once a
88
+ * day, and every time a command fails in a way a newer CLI may fix.
89
+ */
90
+ async function toUpdateNoticeDue(pending) {
43
91
  const failure = toLastFailureCode();
44
92
  const outdatedTo = toOutdatedTo();
45
93
  const reason = outdatedTo !== void 0 ? "api_version_outdated" : failure !== void 0 && SCHEMA_FAILURES.has(failure) ? "failure" : "reminder";
46
94
  let check = await toSettled(pending);
47
95
  if (reason !== "reminder" && (check === void 0 || check.isCached)) check = await toSettled(toPending(true)) ?? check;
48
- const isJSON = args.includes("--json") || !process.stdout.isTTY;
49
- if (check?.isOutdated && (reason !== "reminder" || isReminderDue(check.latest))) {
50
- writeNotice(toUpdateNotice(check, reason), isJSON);
51
- return;
52
- }
53
- if (outdatedTo !== void 0) writeNotice(toApiNotice(outdatedTo), isJSON);
96
+ if (check?.isOutdated && (reason !== "reminder" || isReminderDue(check.latest))) return toUpdateNotice(check, reason);
97
+ return outdatedTo === void 0 ? void 0 : toApiNotice(outdatedTo);
54
98
  }
55
99
  function toUpdateNotice(check, reason) {
56
100
  const command = toUpdateCommand(check.tag);
@@ -130,5 +174,5 @@ function toCommandName(args) {
130
174
  //#endregion
131
175
  export { startUpdateCheck, writeUpdateNotice };
132
176
 
133
- //# sourceMappingURL=notice-C6Hg9htX.js.map
134
- //# debugId=da9bdd25-3557-500c-ae11-3ed37eaa10ca
177
+ //# sourceMappingURL=notice-BKhXs3Hh.js.map
178
+ //# debugId=565a1123-9337-547d-afb1-6f0586e6040c