@flowscripter/dynamic-cli-framework 5.4.9 → 5.4.11

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 +1 @@
1
- {"version":3,"file":"PluginAddSubCommand.d.ts","sourceRoot":"","sources":["../../../../../src/service/plugin/command/PluginAddSubCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yCAAyC,CAAC;AAC1E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yCAAyC,CAAC;AACvE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yCAAyC,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AASxE,qBAAa,mBAAoB,YAAW,UAAU;IACpD,QAAQ,CAAC,IAAI,SAAS;IACtB,QAAQ,CAAC,WAAW,6BAA6B;IACjD,QAAQ,CAAC,mBAAmB,SAAS;IACrC,QAAQ,CAAC,OAAO,UAAM;IACtB,QAAQ,CAAC,WAAW;;;;QAMlB;IAEI,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAqFrE;CACF"}
1
+ {"version":3,"file":"PluginAddSubCommand.d.ts","sourceRoot":"","sources":["../../../../../src/service/plugin/command/PluginAddSubCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yCAAyC,CAAC;AAC1E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yCAAyC,CAAC;AACvE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yCAAyC,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AASxE,qBAAa,mBAAoB,YAAW,UAAU;IACpD,QAAQ,CAAC,IAAI,SAAS;IACtB,QAAQ,CAAC,WAAW,6BAA6B;IACjD,QAAQ,CAAC,mBAAmB,SAAS;IACrC,QAAQ,CAAC,OAAO,UAAM;IACtB,QAAQ,CAAC,WAAW;;;;QAMlB;IAEI,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAsGrE;CACF"}
@@ -57,6 +57,17 @@ export class PluginAddSubCommand {
57
57
  const installLabel = descriptor.version && descriptor.version !== "latest"
58
58
  ? `${descriptor.pluginId}@${descriptor.version}`
59
59
  : descriptor.pluginId;
60
+ // If the exact same plugin+version is already installed, there's nothing to do - avoids a
61
+ // needless reinstall and the registry round-trip below.
62
+ if (descriptor.version && descriptor.version !== "latest") {
63
+ for await (const installed of pluginService.listInstalled()) {
64
+ if (installed.pluginId === descriptor.pluginId &&
65
+ installed.version === descriptor.version) {
66
+ await printerService.print(`Plugin ${descriptor.pluginId}@${installed.version} is already installed.\n`, Icon.INFORMATION);
67
+ return;
68
+ }
69
+ }
70
+ }
60
71
  // Confirm the package (and specific version/tag, if requested) actually exists on the
61
72
  // remote marketplace before invoking the package manager - so a non-existent plugin or
62
73
  // version is reported clearly instead of failing later (and less clearly) inside
@@ -1 +1 @@
1
- {"version":3,"file":"PluginRemoveSubCommand.d.ts","sourceRoot":"","sources":["../../../../../src/service/plugin/command/PluginRemoveSubCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yCAAyC,CAAC;AAC1E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yCAAyC,CAAC;AACvE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yCAAyC,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AAMxE,qBAAa,sBAAuB,YAAW,UAAU;IACvD,QAAQ,CAAC,IAAI,YAAY;IACzB,QAAQ,CAAC,WAAW,uCAAuC;IAC3D,QAAQ,CAAC,mBAAmB,SAAS;IACrC,QAAQ,CAAC,OAAO,UAAM;IACtB,QAAQ,CAAC,WAAW;;;;QAMlB;IAEI,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAYrE;CACF"}
1
+ {"version":3,"file":"PluginRemoveSubCommand.d.ts","sourceRoot":"","sources":["../../../../../src/service/plugin/command/PluginRemoveSubCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yCAAyC,CAAC;AAC1E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yCAAyC,CAAC;AACvE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yCAAyC,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AAMxE,qBAAa,sBAAuB,YAAW,UAAU;IACvD,QAAQ,CAAC,IAAI,YAAY;IACzB,QAAQ,CAAC,WAAW,uCAAuC;IAC3D,QAAQ,CAAC,mBAAmB,SAAS;IACrC,QAAQ,CAAC,OAAO,UAAM;IACtB,QAAQ,CAAC,WAAW;;;;QAMlB;IAEI,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAyBrE;CACF"}
@@ -17,6 +17,17 @@ export class PluginRemoveSubCommand {
17
17
  const printerService = context.getServiceById(PRINTER_SERVICE_ID);
18
18
  const pluginService = context.getServiceById(PLUGIN_SERVICE_ID);
19
19
  const pluginId = argumentValues["pluginId"];
20
+ let isInstalled = false;
21
+ for await (const installed of pluginService.listInstalled()) {
22
+ if (installed.pluginId === pluginId) {
23
+ isInstalled = true;
24
+ break;
25
+ }
26
+ }
27
+ if (!isInstalled) {
28
+ await printerService.print(`Plugin ${pluginId} is not installed.\n`, Icon.INFORMATION);
29
+ return;
30
+ }
20
31
  await printerService.showSpinner(`Removing plugin: ${pluginId}...`);
21
32
  try {
22
33
  await pluginService.uninstall(pluginId);
@@ -1 +1 @@
1
- {"version":3,"file":"Progress.d.ts","sourceRoot":"","sources":["../../../../../src/service/printer/terminal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yCAAyC,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AAkBxE,MAAM,CAAC,OAAO,OAAO,QAAQ;;IAe3B,YAAmB,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAGpD;IAEM,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CA4BjF;IA4BM,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAyBrE;IAEY,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAe/C;IAEY,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAKpC;IAEY,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAqBlC;IAEM,MAAM,IAAI,IAAI,CAapB;IAgKD,IAAI,aAAa,CAAC,KAAK,EAAE,MAAM,EAE9B;IAED,IAAI,cAAc,CAAC,KAAK,EAAE,MAAM,EAE/B;IAED,IAAI,UAAU,CAAC,KAAK,EAAE,MAAM,EAE3B;IAED,IAAI,UAAU,CAAC,KAAK,EAAE,MAAM,EAE3B;IAED,IAAI,aAAa,CAAC,KAAK,EAAE,aAAa,EAErC;CAmDF"}
@@ -1,6 +1,9 @@
1
1
  // Weight given to each new rate sample in the exponential moving average - time constant is
2
2
  // roughly 1/RATE_SMOOTHING_FACTOR * 100ms (the render interval).
3
3
  const RATE_SMOOTHING_FACTOR = 0.3;
4
+ // A rate this close to zero (units/s) produces a meaningless (and, past a certain point,
5
+ // non-finite) "time remaining" estimate - treat it the same as no rate at all.
6
+ const MAX_REMAINING_MILLIS = 999 * 24 * 60 * 60 * 1000;
4
7
  export { ProgressStyle } from "@flowscripter/dynamic-cli-framework-api";
5
8
  import { ProgressStyle } from "@flowscripter/dynamic-cli-framework-api";
6
9
  const STYLE_CHARS = {
@@ -187,9 +190,14 @@ export default class Progress {
187
190
  Bun.stripANSI(taken).length;
188
191
  }
189
192
  else {
190
- const remaining = bar.rate === undefined || bar.rate === 0
193
+ const remainingMillis = bar.rate === undefined || bar.rate === 0
194
+ ? undefined
195
+ : ((bar.total - bar.current) / bar.rate) * 1000;
196
+ const remaining = remainingMillis === undefined ||
197
+ !Number.isFinite(remainingMillis) ||
198
+ remainingMillis > MAX_REMAINING_MILLIS
191
199
  ? "-"
192
- : this.#formatTime(((bar.total - bar.current) / bar.rate) * 1000);
200
+ : this.#formatTime(remainingMillis);
193
201
  const currentString = bar.current + "";
194
202
  const totalString = bar.total + "";
195
203
  suffix += `${this.#styler.colorText(currentString, this.#valColor)}${this.#styler.colorText("/", this.#labColor)}${this.#styler.colorText(totalString, this.#valColor)}${this.#styler.colorText(bar.units + ", rate:", this.#labColor)} ${rate}${this.#styler.colorText(bar.units + "/s, time remaining:", this.#labColor)} ${remaining}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowscripter/dynamic-cli-framework",
3
- "version": "5.4.9",
3
+ "version": "5.4.11",
4
4
  "description": "A framework for developing CLI applications which supports dynamic discovery and installation of new commands",
5
5
  "keywords": [
6
6
  "bun",
@@ -73,6 +73,23 @@ export class PluginAddSubCommand implements SubCommand {
73
73
  ? `${descriptor.pluginId}@${descriptor.version}`
74
74
  : descriptor.pluginId;
75
75
 
76
+ // If the exact same plugin+version is already installed, there's nothing to do - avoids a
77
+ // needless reinstall and the registry round-trip below.
78
+ if (descriptor.version && descriptor.version !== "latest") {
79
+ for await (const installed of pluginService.listInstalled()) {
80
+ if (
81
+ installed.pluginId === descriptor.pluginId &&
82
+ installed.version === descriptor.version
83
+ ) {
84
+ await printerService.print(
85
+ `Plugin ${descriptor.pluginId}@${installed.version} is already installed.\n`,
86
+ Icon.INFORMATION,
87
+ );
88
+ return;
89
+ }
90
+ }
91
+ }
92
+
76
93
  // Confirm the package (and specific version/tag, if requested) actually exists on the
77
94
  // remote marketplace before invoking the package manager - so a non-existent plugin or
78
95
  // version is reported clearly instead of failing later (and less clearly) inside
@@ -25,6 +25,19 @@ export class PluginRemoveSubCommand implements SubCommand {
25
25
  const pluginService = context.getServiceById(PLUGIN_SERVICE_ID) as PluginService;
26
26
 
27
27
  const pluginId = argumentValues["pluginId"] as string;
28
+
29
+ let isInstalled = false;
30
+ for await (const installed of pluginService.listInstalled()) {
31
+ if (installed.pluginId === pluginId) {
32
+ isInstalled = true;
33
+ break;
34
+ }
35
+ }
36
+ if (!isInstalled) {
37
+ await printerService.print(`Plugin ${pluginId} is not installed.\n`, Icon.INFORMATION);
38
+ return;
39
+ }
40
+
28
41
  await printerService.showSpinner(`Removing plugin: ${pluginId}...`);
29
42
  try {
30
43
  await pluginService.uninstall(pluginId);
@@ -5,6 +5,10 @@ import type Terminal from "../../../terminal/Terminal.ts";
5
5
  // roughly 1/RATE_SMOOTHING_FACTOR * 100ms (the render interval).
6
6
  const RATE_SMOOTHING_FACTOR = 0.3;
7
7
 
8
+ // A rate this close to zero (units/s) produces a meaningless (and, past a certain point,
9
+ // non-finite) "time remaining" estimate - treat it the same as no rate at all.
10
+ const MAX_REMAINING_MILLIS = 999 * 24 * 60 * 60 * 1000;
11
+
8
12
  export { ProgressStyle } from "@flowscripter/dynamic-cli-framework-api";
9
13
  import { ProgressStyle } from "@flowscripter/dynamic-cli-framework-api";
10
14
 
@@ -255,10 +259,16 @@ export default class Progress {
255
259
  1 +
256
260
  Bun.stripANSI(taken).length;
257
261
  } else {
258
- const remaining =
262
+ const remainingMillis =
259
263
  bar.rate === undefined || bar.rate === 0
264
+ ? undefined
265
+ : ((bar.total - bar.current) / bar.rate) * 1000;
266
+ const remaining =
267
+ remainingMillis === undefined ||
268
+ !Number.isFinite(remainingMillis) ||
269
+ remainingMillis > MAX_REMAINING_MILLIS
260
270
  ? "-"
261
- : this.#formatTime(((bar.total - bar.current) / bar.rate) * 1000);
271
+ : this.#formatTime(remainingMillis);
262
272
  const currentString = bar.current + "";
263
273
  const totalString = bar.total + "";
264
274
  suffix += `${this.#styler.colorText(currentString, this.#valColor)}${this.#styler.colorText(