@nmakarov/cli-toolkit 0.18.0 → 0.23.0

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.
Files changed (69) hide show
  1. package/README.md +9 -0
  2. package/dist/args.cjs +1 -4
  3. package/dist/args.cjs.map +1 -1
  4. package/dist/args.js +1 -1
  5. package/dist/args.js.map +1 -1
  6. package/dist/cli-runner.cjs +1493 -516
  7. package/dist/cli-runner.cjs.map +1 -1
  8. package/dist/cli-runner.js +1509 -531
  9. package/dist/cli-runner.js.map +1 -1
  10. package/dist/db.cjs +85 -157
  11. package/dist/db.cjs.map +1 -1
  12. package/dist/db.js +84 -150
  13. package/dist/db.js.map +1 -1
  14. package/dist/errors.cjs +2 -2
  15. package/dist/errors.cjs.map +1 -1
  16. package/dist/errors.js +2 -1
  17. package/dist/errors.js.map +1 -1
  18. package/dist/filedatabase.cjs +19 -19
  19. package/dist/filedatabase.cjs.map +1 -1
  20. package/dist/filedatabase.js +19 -16
  21. package/dist/filedatabase.js.map +1 -1
  22. package/dist/http-client.cjs +9 -11
  23. package/dist/http-client.cjs.map +1 -1
  24. package/dist/http-client.js +10 -9
  25. package/dist/http-client.js.map +1 -1
  26. package/dist/http-client2.cjs +34 -33
  27. package/dist/http-client2.cjs.map +1 -1
  28. package/dist/http-client2.js +34 -30
  29. package/dist/http-client2.js.map +1 -1
  30. package/dist/index.cjs +2063 -658
  31. package/dist/index.cjs.map +1 -1
  32. package/dist/index.js +2063 -663
  33. package/dist/index.js.map +1 -1
  34. package/dist/init.cjs +97 -69
  35. package/dist/init.cjs.map +1 -1
  36. package/dist/init.js +112 -83
  37. package/dist/init.js.map +1 -1
  38. package/dist/logger.cjs +5 -5
  39. package/dist/logger.cjs.map +1 -1
  40. package/dist/logger.js +5 -4
  41. package/dist/logger.js.map +1 -1
  42. package/dist/mock-server.cjs +21 -33
  43. package/dist/mock-server.cjs.map +1 -1
  44. package/dist/mock-server.js +21 -28
  45. package/dist/mock-server.js.map +1 -1
  46. package/dist/params.cjs +22 -10
  47. package/dist/params.cjs.map +1 -1
  48. package/dist/params.js +22 -7
  49. package/dist/params.js.map +1 -1
  50. package/dist/s3.cjs +286 -0
  51. package/dist/s3.cjs.map +1 -0
  52. package/dist/s3.js +273 -0
  53. package/dist/s3.js.map +1 -0
  54. package/dist/screen.cjs +34 -39
  55. package/dist/screen.cjs.map +1 -1
  56. package/dist/screen.js +48 -46
  57. package/dist/screen.js.map +1 -1
  58. package/dist/tasks.cjs +1640 -416
  59. package/dist/tasks.cjs.map +1 -1
  60. package/dist/tasks.js +1614 -412
  61. package/dist/tasks.js.map +1 -1
  62. package/dist/utils.cjs +7 -8
  63. package/dist/utils.cjs.map +1 -1
  64. package/dist/utils.js +6 -6
  65. package/dist/utils.js.map +1 -1
  66. package/package.json +36 -44
  67. package/scripts/ssm/parse-cli.js +35 -0
  68. package/scripts/ssm/ssm-admin.js +151 -0
  69. package/scripts/ssm/ssm-pull.js +147 -0
package/dist/screen.js CHANGED
@@ -1,12 +1,12 @@
1
- // src/screen/index.ts
2
- import React5, { useState as useState3, useEffect as useEffect3, useRef as useRef3, useMemo, useCallback, createElement as createElement2 } from "react";
3
- import { Box as Box5, Text as Text5, useInput as useInput2 } from "ink";
1
+ // src/screen/index.js
2
+ import React2, { useState as useState3, useEffect as useEffect2, useLayoutEffect, useRef as useRef2, useMemo, useCallback, memo, createElement as createElement2 } from "react";
3
+ import { Box as Box4, Text as Text5, useInput as useInput2 } from "ink";
4
4
 
5
- // src/screen/screens.ts
5
+ // src/screen/screens.js
6
6
  import { useState as useState2, createElement as h3 } from "react";
7
7
  import { render, useInput, Text as Text3 } from "ink";
8
8
 
9
- // src/screen/components.ts
9
+ // src/screen/components.js
10
10
  import { createElement as h } from "react";
11
11
  import { Box, Text } from "ink";
12
12
  function getScreenWidth(maxWidth = null) {
@@ -81,8 +81,8 @@ function ScreenFooter({ lines, textStyle }) {
81
81
  );
82
82
  }
83
83
 
84
- // src/screen/list-components.ts
85
- import React2, { useState, useEffect, useRef, createElement } from "react";
84
+ // src/screen/list-components.js
85
+ import React, { useState, useEffect, useRef, createElement } from "react";
86
86
  import { Box as Box2, Text as Text2 } from "ink";
87
87
  var h2 = createElement;
88
88
  function MultiColumnListComponent({ items, ctx, selectedIndexRef }) {
@@ -219,11 +219,11 @@ function MultiColumnListWithPreviewComponent({
219
219
  const previewRows = [];
220
220
  if (typeof previewContent === "string") {
221
221
  previewRows.push(h2(ScreenRow, { key: "preview-string", children: h2(Text2, { bold: true }, previewContent) }));
222
- } else if (typeof previewContent === "object" && !React2.isValidElement(previewContent) && previewContent !== null) {
222
+ } else if (typeof previewContent === "object" && !React.isValidElement(previewContent) && previewContent !== null) {
223
223
  Object.entries(previewContent).forEach(([key, value], idx) => {
224
224
  previewRows.push(h2(ScreenRow, { key: `preview-${key}-${idx}`, children: h2(Text2, {}, `${key}: ${value}`) }));
225
225
  });
226
- } else if (React2.isValidElement(previewContent)) {
226
+ } else if (React.isValidElement(previewContent)) {
227
227
  previewRows.push(h2(ScreenRow, { key: "preview-element", children: previewContent }));
228
228
  }
229
229
  return h2(
@@ -236,11 +236,13 @@ function MultiColumnListWithPreviewComponent({
236
236
  ...previewRows
237
237
  );
238
238
  }
239
- function ListComponent({ items, ctx, selectedIndexRef, renderItem, getTitle, sortable = false, maxHeight, sortHighlightStyle, selectionMarker = " " }) {
239
+ function ListComponent({ items, ctx, selectedIndexRef, renderItem, getTitle, sortable = false, maxHeight, sortHighlightStyle, selectionMarker = " ", onSelectionChange }) {
240
240
  const [, forceUpdate] = useState({});
241
241
  const [sortOrder, setSortOrder] = useState("none");
242
242
  const [scrollOffset, setScrollOffset] = useState(0);
243
243
  const scrollStateRef = useRef({ scrollOffset: 0, maxHeight: 0, totalItems: 0 });
244
+ const itemsRef = useRef(items);
245
+ itemsRef.current = items;
244
246
  const defaultGetTitle = (item) => {
245
247
  return getTitle ? getTitle(item) : typeof item.value === "string" ? item.value : item.value?.title || item.name;
246
248
  };
@@ -254,18 +256,24 @@ function ListComponent({ items, ctx, selectedIndexRef, renderItem, getTitle, sor
254
256
  return titleA > titleB ? -1 : titleA < titleB ? 1 : 0;
255
257
  }
256
258
  }) : items;
259
+ const displayItemsRef = useRef(displayItems);
260
+ displayItemsRef.current = displayItems;
257
261
  const effectiveMaxHeight = maxHeight || displayItems.length;
258
- const canScroll = displayItems.length > effectiveMaxHeight;
262
+ const _canScroll = displayItems.length > effectiveMaxHeight;
259
263
  const maxScrollOffset = Math.max(0, displayItems.length - effectiveMaxHeight);
260
264
  const clampedScrollOffset = Math.min(Math.max(0, scrollOffset), maxScrollOffset);
261
265
  const visibleItems = displayItems.slice(clampedScrollOffset, clampedScrollOffset + effectiveMaxHeight);
262
266
  const canScrollUp = clampedScrollOffset > 0;
263
267
  const canScrollDown = clampedScrollOffset < maxScrollOffset;
264
268
  scrollStateRef.current = { scrollOffset, maxHeight: effectiveMaxHeight, totalItems: displayItems.length };
269
+ const onSelectionChangeRef = useRef(onSelectionChange);
270
+ onSelectionChangeRef.current = onSelectionChange;
265
271
  useEffect(() => {
266
272
  ctx.setAction("moveUp", () => {
267
273
  const newIndex = Math.max(0, selectedIndexRef.current - 1);
268
274
  selectedIndexRef.current = newIndex;
275
+ const list = displayItemsRef.current;
276
+ onSelectionChangeRef.current?.(newIndex, list[newIndex]);
269
277
  const { scrollOffset: currentScrollOffset, maxHeight: currentMaxHeight, totalItems } = scrollStateRef.current;
270
278
  const currentMaxScrollOffset = Math.max(0, totalItems - currentMaxHeight);
271
279
  const currentClampedScrollOffset = Math.min(Math.max(0, currentScrollOffset), currentMaxScrollOffset);
@@ -275,18 +283,11 @@ function ListComponent({ items, ctx, selectedIndexRef, renderItem, getTitle, sor
275
283
  forceUpdate({});
276
284
  });
277
285
  ctx.setAction("moveDown", () => {
278
- const currentItems = sortable && sortOrder !== "none" ? [...items].sort((a, b) => {
279
- const titleA = titleGetter(a).toLowerCase();
280
- const titleB = titleGetter(b).toLowerCase();
281
- if (sortOrder === "asc") {
282
- return titleA < titleB ? -1 : titleA > titleB ? 1 : 0;
283
- } else {
284
- return titleA > titleB ? -1 : titleA < titleB ? 1 : 0;
285
- }
286
- }) : items;
287
- const maxIndex = currentItems.length - 1;
286
+ const currentItems = displayItemsRef.current;
287
+ const maxIndex = Math.max(0, currentItems.length - 1);
288
288
  const newIndex = Math.min(maxIndex, selectedIndexRef.current + 1);
289
289
  selectedIndexRef.current = newIndex;
290
+ onSelectionChangeRef.current?.(newIndex, currentItems[newIndex]);
290
291
  const { scrollOffset: currentScrollOffset, maxHeight: currentMaxHeight, totalItems } = scrollStateRef.current;
291
292
  const currentMaxScrollOffset = Math.max(0, totalItems - currentMaxHeight);
292
293
  const currentClampedScrollOffset = Math.min(Math.max(0, currentScrollOffset), currentMaxScrollOffset);
@@ -296,8 +297,7 @@ function ListComponent({ items, ctx, selectedIndexRef, renderItem, getTitle, sor
296
297
  forceUpdate({});
297
298
  });
298
299
  ctx.setAction("scrollUp", () => {
299
- const { scrollOffset: currentScrollOffset, maxHeight: currentMaxHeight, totalItems } = scrollStateRef.current;
300
- const currentMaxScrollOffset = Math.max(0, totalItems - currentMaxHeight);
300
+ const { scrollOffset: currentScrollOffset } = scrollStateRef.current;
301
301
  const newScrollOffset = Math.max(0, currentScrollOffset - 1);
302
302
  setScrollOffset(newScrollOffset);
303
303
  forceUpdate({});
@@ -312,9 +312,9 @@ function ListComponent({ items, ctx, selectedIndexRef, renderItem, getTitle, sor
312
312
  if (sortable) {
313
313
  ctx.setAction("toggleSort", () => {
314
314
  const nextSort = sortOrder === "none" ? "asc" : sortOrder === "asc" ? "desc" : "none";
315
- const currentSelectedItem = displayItems[selectedIndexRef.current];
315
+ const currentSelectedItem = displayItemsRef.current[selectedIndexRef.current];
316
316
  setSortOrder(nextSort);
317
- const newSortedItems = nextSort !== "none" ? [...items].sort((a, b) => {
317
+ const newSortedItems = nextSort !== "none" ? [...itemsRef.current].sort((a, b) => {
318
318
  const titleA = titleGetter(a).toLowerCase();
319
319
  const titleB = titleGetter(b).toLowerCase();
320
320
  if (nextSort === "asc") {
@@ -322,7 +322,7 @@ function ListComponent({ items, ctx, selectedIndexRef, renderItem, getTitle, sor
322
322
  } else {
323
323
  return titleA > titleB ? -1 : titleA < titleB ? 1 : 0;
324
324
  }
325
- }) : items;
325
+ }) : itemsRef.current;
326
326
  const newIndex = newSortedItems.findIndex((item) => item === currentSelectedItem);
327
327
  if (newIndex !== -1) {
328
328
  selectedIndexRef.current = newIndex;
@@ -459,7 +459,7 @@ function ListComponent({ items, ctx, selectedIndexRef, renderItem, getTitle, sor
459
459
  );
460
460
  }
461
461
 
462
- // src/screen/screens.ts
462
+ // src/screen/screens.js
463
463
  function groupKeyBindings(bindings) {
464
464
  const groups = {};
465
465
  const enabledBindings = bindings.filter((b) => b.enabled !== false);
@@ -535,7 +535,7 @@ async function showScreen(config) {
535
535
  let renderResult = null;
536
536
  let initialized = false;
537
537
  const Screen = () => {
538
- const [updateCounter, setUpdateCounter] = useState2(0);
538
+ const [, setUpdateCounter] = useState2(0);
539
539
  if (!initialized) {
540
540
  const defaultBindings = [
541
541
  { key: "escape", caption: "go back", action: "back", protected: true, order: 1 },
@@ -654,7 +654,7 @@ async function showScreen(config) {
654
654
  }
655
655
  }
656
656
  if (matchedBinding && actions[matchedBinding.action]) {
657
- const actionResult = actions[matchedBinding.action]({
657
+ actions[matchedBinding.action]({
658
658
  input,
659
659
  key,
660
660
  binding: matchedBinding
@@ -785,9 +785,9 @@ async function showMultiColumnListWithPreviewScreen(config) {
785
785
  var showMenuScreen = showListScreen;
786
786
  var showWordGridScreen = showMultiColumnListScreen;
787
787
 
788
- // src/screen/ui-elements.ts
788
+ // src/screen/ui-elements.js
789
789
  import { createElement as h4 } from "react";
790
- import { Box as Box4, Text as Text4 } from "ink";
790
+ import { Box as Box3, Text as Text4 } from "ink";
791
791
  function ListItem({
792
792
  children,
793
793
  isSelected = false,
@@ -797,7 +797,7 @@ function ListItem({
797
797
  dimColor = false
798
798
  }) {
799
799
  return h4(
800
- Box4,
800
+ Box3,
801
801
  {},
802
802
  h4(Text4, {
803
803
  color: isSelected ? backgroundColor || "green" : color,
@@ -812,10 +812,10 @@ function TextBlock({
812
812
  color = "white",
813
813
  dimmed = false,
814
814
  bold = false,
815
- maxWidth
815
+ maxWidth: _maxWidth
816
816
  }) {
817
817
  return h4(
818
- Box4,
818
+ Box3,
819
819
  {},
820
820
  h4(Text4, {
821
821
  color,
@@ -826,7 +826,7 @@ function TextBlock({
826
826
  }
827
827
  function Divider({ character = "\u2500", width = 80 }) {
828
828
  return h4(
829
- Box4,
829
+ Box3,
830
830
  { marginY: 1 },
831
831
  h4(Text4, { dimColor: true }, character.repeat(width))
832
832
  );
@@ -841,7 +841,7 @@ function GridCell({
841
841
  align = "left"
842
842
  }) {
843
843
  return h4(
844
- Box4,
844
+ Box3,
845
845
  { width },
846
846
  h4(Text4, {
847
847
  color,
@@ -852,20 +852,20 @@ function GridCell({
852
852
  }, children)
853
853
  );
854
854
  }
855
- function InputField({ prompt, value, onChange, onSubmit }) {
855
+ function InputField({ prompt, value, onChange: _onChange, onSubmit: _onSubmit }) {
856
856
  return h4(
857
- Box4,
857
+ Box3,
858
858
  { flexDirection: "column" },
859
859
  h4(Text4, {}, prompt),
860
860
  h4(
861
- Box4,
861
+ Box3,
862
862
  { marginTop: 1 },
863
863
  h4(Text4, { color: "cyan" }, " > ", value, "_")
864
864
  )
865
865
  );
866
866
  }
867
867
 
868
- // src/screen/utils.ts
868
+ // src/screen/utils.js
869
869
  function buildBreadcrumb(parts) {
870
870
  if (parts.length === 0) return "";
871
871
  if (parts.length === 1) return parts[0];
@@ -879,7 +879,7 @@ function buildDetailBreadcrumb(path, suffix = "") {
879
879
  return suffix ? `${breadcrumb} ${suffix}` : breadcrumb;
880
880
  }
881
881
 
882
- // src/screen/footer-builder.ts
882
+ // src/screen/footer-builder.js
883
883
  function buildFooter(config = {}) {
884
884
  const {
885
885
  navigation = null,
@@ -984,7 +984,7 @@ function organizeFooterMessages(messages) {
984
984
  return lines;
985
985
  }
986
986
 
987
- // src/screen/index.ts
987
+ // src/screen/index.js
988
988
  var loadPromise = null;
989
989
  async function load() {
990
990
  if (loadPromise) return loadPromise;
@@ -1000,7 +1000,7 @@ if (typeof window === "undefined") {
1000
1000
  });
1001
1001
  }
1002
1002
  export {
1003
- Box5 as Box,
1003
+ Box4 as Box,
1004
1004
  Divider,
1005
1005
  FooterPresets,
1006
1006
  GridCell,
@@ -1009,7 +1009,7 @@ export {
1009
1009
  ListItem,
1010
1010
  MultiColumnListComponent,
1011
1011
  MultiColumnListWithPreviewComponent,
1012
- React5 as React,
1012
+ React2 as React,
1013
1013
  ScreenBody,
1014
1014
  ScreenContainer,
1015
1015
  ScreenDivider,
@@ -1023,6 +1023,7 @@ export {
1023
1023
  buildFooter,
1024
1024
  createElement2 as h,
1025
1025
  load,
1026
+ memo,
1026
1027
  organizeFooterMessages,
1027
1028
  showListScreen,
1028
1029
  showMenuScreen,
@@ -1031,10 +1032,11 @@ export {
1031
1032
  showScreen,
1032
1033
  showWordGridScreen,
1033
1034
  useCallback,
1034
- useEffect3 as useEffect,
1035
+ useEffect2 as useEffect,
1035
1036
  useInput2 as useInput,
1037
+ useLayoutEffect,
1036
1038
  useMemo,
1037
- useRef3 as useRef,
1039
+ useRef2 as useRef,
1038
1040
  useState3 as useState
1039
1041
  };
1040
1042
  //# sourceMappingURL=screen.js.map