@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.cjs CHANGED
@@ -1,12 +1,3 @@
1
- "use strict";
2
-
3
- var __esmCache = {};
4
- var __loadESMSync = function(moduleName) {
5
- if (!__esmCache[moduleName]) {
6
- throw new Error(`ESM module "${moduleName}" not loaded. Please call the load() function first: const toolkit = require("@nmakarov/cli-toolkit"); await toolkit.load();`);
7
- }
8
- return __esmCache[moduleName];
9
- };
10
1
  var __create = Object.create;
11
2
  var __defProp = Object.defineProperty;
12
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -35,7 +26,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
35
26
  ));
36
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
37
28
 
38
- // src/screen/index.ts
29
+ // src/screen/index.js
39
30
  var screen_exports = {};
40
31
  __export(screen_exports, {
41
32
  Box: () => import_ink5.Box,
@@ -61,6 +52,7 @@ __export(screen_exports, {
61
52
  buildFooter: () => buildFooter,
62
53
  h: () => import_react5.createElement,
63
54
  load: () => load,
55
+ memo: () => import_react5.memo,
64
56
  organizeFooterMessages: () => organizeFooterMessages,
65
57
  showListScreen: () => showListScreen,
66
58
  showMenuScreen: () => showMenuScreen,
@@ -71,6 +63,7 @@ __export(screen_exports, {
71
63
  useCallback: () => import_react5.useCallback,
72
64
  useEffect: () => import_react5.useEffect,
73
65
  useInput: () => import_ink5.useInput,
66
+ useLayoutEffect: () => import_react5.useLayoutEffect,
74
67
  useMemo: () => import_react5.useMemo,
75
68
  useRef: () => import_react5.useRef,
76
69
  useState: () => import_react5.useState
@@ -79,11 +72,11 @@ module.exports = __toCommonJS(screen_exports);
79
72
  var import_react5 = null; // Will be set by load();
80
73
  var import_ink5 = null; // Will be set by load();
81
74
 
82
- // src/screen/screens.ts
75
+ // src/screen/screens.js
83
76
  var import_react3 = null; // Will be set by load();
84
77
  var import_ink3 = null; // Will be set by load();
85
78
 
86
- // src/screen/components.ts
79
+ // src/screen/components.js
87
80
  var import_react = null; // Will be set by load();
88
81
  var import_ink = null; // Will be set by load();
89
82
  function getScreenWidth(maxWidth = null) {
@@ -158,7 +151,7 @@ function ScreenFooter({ lines, textStyle }) {
158
151
  );
159
152
  }
160
153
 
161
- // src/screen/list-components.ts
154
+ // src/screen/list-components.js
162
155
  var import_react2 = null; // Will be set by load();
163
156
  var import_ink2 = null; // Will be set by load();
164
157
  // Removed: intermediate assignment - code will access import variable directly
@@ -313,11 +306,13 @@ function MultiColumnListWithPreviewComponent({
313
306
  ...previewRows
314
307
  );
315
308
  }
316
- function ListComponent({ items, ctx, selectedIndexRef, renderItem, getTitle, sortable = false, maxHeight, sortHighlightStyle, selectionMarker = " " }) {
309
+ function ListComponent({ items, ctx, selectedIndexRef, renderItem, getTitle, sortable = false, maxHeight, sortHighlightStyle, selectionMarker = " ", onSelectionChange }) {
317
310
  const [, forceUpdate] = (0, import_react2.useState)({});
318
311
  const [sortOrder, setSortOrder] = (0, import_react2.useState)("none");
319
312
  const [scrollOffset, setScrollOffset] = (0, import_react2.useState)(0);
320
313
  const scrollStateRef = (0, import_react2.useRef)({ scrollOffset: 0, maxHeight: 0, totalItems: 0 });
314
+ const itemsRef = (0, import_react2.useRef)(items);
315
+ itemsRef.current = items;
321
316
  const defaultGetTitle = (item) => {
322
317
  return getTitle ? getTitle(item) : typeof item.value === "string" ? item.value : item.value?.title || item.name;
323
318
  };
@@ -331,18 +326,24 @@ function ListComponent({ items, ctx, selectedIndexRef, renderItem, getTitle, sor
331
326
  return titleA > titleB ? -1 : titleA < titleB ? 1 : 0;
332
327
  }
333
328
  }) : items;
329
+ const displayItemsRef = (0, import_react2.useRef)(displayItems);
330
+ displayItemsRef.current = displayItems;
334
331
  const effectiveMaxHeight = maxHeight || displayItems.length;
335
- const canScroll = displayItems.length > effectiveMaxHeight;
332
+ const _canScroll = displayItems.length > effectiveMaxHeight;
336
333
  const maxScrollOffset = Math.max(0, displayItems.length - effectiveMaxHeight);
337
334
  const clampedScrollOffset = Math.min(Math.max(0, scrollOffset), maxScrollOffset);
338
335
  const visibleItems = displayItems.slice(clampedScrollOffset, clampedScrollOffset + effectiveMaxHeight);
339
336
  const canScrollUp = clampedScrollOffset > 0;
340
337
  const canScrollDown = clampedScrollOffset < maxScrollOffset;
341
338
  scrollStateRef.current = { scrollOffset, maxHeight: effectiveMaxHeight, totalItems: displayItems.length };
339
+ const onSelectionChangeRef = (0, import_react2.useRef)(onSelectionChange);
340
+ onSelectionChangeRef.current = onSelectionChange;
342
341
  (0, import_react2.useEffect)(() => {
343
342
  ctx.setAction("moveUp", () => {
344
343
  const newIndex = Math.max(0, selectedIndexRef.current - 1);
345
344
  selectedIndexRef.current = newIndex;
345
+ const list = displayItemsRef.current;
346
+ onSelectionChangeRef.current?.(newIndex, list[newIndex]);
346
347
  const { scrollOffset: currentScrollOffset, maxHeight: currentMaxHeight, totalItems } = scrollStateRef.current;
347
348
  const currentMaxScrollOffset = Math.max(0, totalItems - currentMaxHeight);
348
349
  const currentClampedScrollOffset = Math.min(Math.max(0, currentScrollOffset), currentMaxScrollOffset);
@@ -352,18 +353,11 @@ function ListComponent({ items, ctx, selectedIndexRef, renderItem, getTitle, sor
352
353
  forceUpdate({});
353
354
  });
354
355
  ctx.setAction("moveDown", () => {
355
- const currentItems = sortable && sortOrder !== "none" ? [...items].sort((a, b) => {
356
- const titleA = titleGetter(a).toLowerCase();
357
- const titleB = titleGetter(b).toLowerCase();
358
- if (sortOrder === "asc") {
359
- return titleA < titleB ? -1 : titleA > titleB ? 1 : 0;
360
- } else {
361
- return titleA > titleB ? -1 : titleA < titleB ? 1 : 0;
362
- }
363
- }) : items;
364
- const maxIndex = currentItems.length - 1;
356
+ const currentItems = displayItemsRef.current;
357
+ const maxIndex = Math.max(0, currentItems.length - 1);
365
358
  const newIndex = Math.min(maxIndex, selectedIndexRef.current + 1);
366
359
  selectedIndexRef.current = newIndex;
360
+ onSelectionChangeRef.current?.(newIndex, currentItems[newIndex]);
367
361
  const { scrollOffset: currentScrollOffset, maxHeight: currentMaxHeight, totalItems } = scrollStateRef.current;
368
362
  const currentMaxScrollOffset = Math.max(0, totalItems - currentMaxHeight);
369
363
  const currentClampedScrollOffset = Math.min(Math.max(0, currentScrollOffset), currentMaxScrollOffset);
@@ -373,8 +367,7 @@ function ListComponent({ items, ctx, selectedIndexRef, renderItem, getTitle, sor
373
367
  forceUpdate({});
374
368
  });
375
369
  ctx.setAction("scrollUp", () => {
376
- const { scrollOffset: currentScrollOffset, maxHeight: currentMaxHeight, totalItems } = scrollStateRef.current;
377
- const currentMaxScrollOffset = Math.max(0, totalItems - currentMaxHeight);
370
+ const { scrollOffset: currentScrollOffset } = scrollStateRef.current;
378
371
  const newScrollOffset = Math.max(0, currentScrollOffset - 1);
379
372
  setScrollOffset(newScrollOffset);
380
373
  forceUpdate({});
@@ -389,9 +382,9 @@ function ListComponent({ items, ctx, selectedIndexRef, renderItem, getTitle, sor
389
382
  if (sortable) {
390
383
  ctx.setAction("toggleSort", () => {
391
384
  const nextSort = sortOrder === "none" ? "asc" : sortOrder === "asc" ? "desc" : "none";
392
- const currentSelectedItem = displayItems[selectedIndexRef.current];
385
+ const currentSelectedItem = displayItemsRef.current[selectedIndexRef.current];
393
386
  setSortOrder(nextSort);
394
- const newSortedItems = nextSort !== "none" ? [...items].sort((a, b) => {
387
+ const newSortedItems = nextSort !== "none" ? [...itemsRef.current].sort((a, b) => {
395
388
  const titleA = titleGetter(a).toLowerCase();
396
389
  const titleB = titleGetter(b).toLowerCase();
397
390
  if (nextSort === "asc") {
@@ -399,7 +392,7 @@ function ListComponent({ items, ctx, selectedIndexRef, renderItem, getTitle, sor
399
392
  } else {
400
393
  return titleA > titleB ? -1 : titleA < titleB ? 1 : 0;
401
394
  }
402
- }) : items;
395
+ }) : itemsRef.current;
403
396
  const newIndex = newSortedItems.findIndex((item) => item === currentSelectedItem);
404
397
  if (newIndex !== -1) {
405
398
  selectedIndexRef.current = newIndex;
@@ -536,7 +529,7 @@ function ListComponent({ items, ctx, selectedIndexRef, renderItem, getTitle, sor
536
529
  );
537
530
  }
538
531
 
539
- // src/screen/screens.ts
532
+ // src/screen/screens.js
540
533
  function groupKeyBindings(bindings) {
541
534
  const groups = {};
542
535
  const enabledBindings = bindings.filter((b) => b.enabled !== false);
@@ -612,7 +605,7 @@ async function showScreen(config) {
612
605
  let renderResult = null;
613
606
  let initialized = false;
614
607
  const Screen = () => {
615
- const [updateCounter, setUpdateCounter] = (0, import_react3.useState)(0);
608
+ const [, setUpdateCounter] = (0, import_react3.useState)(0);
616
609
  if (!initialized) {
617
610
  const defaultBindings = [
618
611
  { key: "escape", caption: "go back", action: "back", protected: true, order: 1 },
@@ -731,7 +724,7 @@ async function showScreen(config) {
731
724
  }
732
725
  }
733
726
  if (matchedBinding && actions[matchedBinding.action]) {
734
- const actionResult = actions[matchedBinding.action]({
727
+ actions[matchedBinding.action]({
735
728
  input,
736
729
  key,
737
730
  binding: matchedBinding
@@ -862,7 +855,7 @@ async function showMultiColumnListWithPreviewScreen(config) {
862
855
  var showMenuScreen = showListScreen;
863
856
  var showWordGridScreen = showMultiColumnListScreen;
864
857
 
865
- // src/screen/ui-elements.ts
858
+ // src/screen/ui-elements.js
866
859
  var import_react4 = null; // Will be set by load();
867
860
  var import_ink4 = null; // Will be set by load();
868
861
  function ListItem({
@@ -889,7 +882,7 @@ function TextBlock({
889
882
  color = "white",
890
883
  dimmed = false,
891
884
  bold = false,
892
- maxWidth
885
+ maxWidth: _maxWidth
893
886
  }) {
894
887
  return (0, import_react4.createElement)(
895
888
  import_ink4.Box,
@@ -929,7 +922,7 @@ function GridCell({
929
922
  }, children)
930
923
  );
931
924
  }
932
- function InputField({ prompt, value, onChange, onSubmit }) {
925
+ function InputField({ prompt, value, onChange: _onChange, onSubmit: _onSubmit }) {
933
926
  return (0, import_react4.createElement)(
934
927
  import_ink4.Box,
935
928
  { flexDirection: "column" },
@@ -942,7 +935,7 @@ function InputField({ prompt, value, onChange, onSubmit }) {
942
935
  );
943
936
  }
944
937
 
945
- // src/screen/utils.ts
938
+ // src/screen/utils.js
946
939
  function buildBreadcrumb(parts) {
947
940
  if (parts.length === 0) return "";
948
941
  if (parts.length === 1) return parts[0];
@@ -956,7 +949,7 @@ function buildDetailBreadcrumb(path, suffix = "") {
956
949
  return suffix ? `${breadcrumb} ${suffix}` : breadcrumb;
957
950
  }
958
951
 
959
- // src/screen/footer-builder.ts
952
+ // src/screen/footer-builder.js
960
953
  function buildFooter(config = {}) {
961
954
  const {
962
955
  navigation = null,
@@ -1061,7 +1054,7 @@ function organizeFooterMessages(messages) {
1061
1054
  return lines;
1062
1055
  }
1063
1056
 
1064
- // src/screen/index.ts
1057
+ // src/screen/index.js
1065
1058
  var loadPromise = null;
1066
1059
  async function load() {
1067
1060
  if (loadPromise) return loadPromise;
@@ -1111,6 +1104,7 @@ if (typeof window === "undefined") {
1111
1104
  buildFooter,
1112
1105
  h,
1113
1106
  load,
1107
+ memo,
1114
1108
  organizeFooterMessages,
1115
1109
  showListScreen,
1116
1110
  showMenuScreen,
@@ -1121,6 +1115,7 @@ if (typeof window === "undefined") {
1121
1115
  useCallback,
1122
1116
  useEffect,
1123
1117
  useInput,
1118
+ useLayoutEffect,
1124
1119
  useMemo,
1125
1120
  useRef,
1126
1121
  useState