tailwind-header-dom 3.4.1

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 (147) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +61 -0
  3. package/bin/cli.js +12 -0
  4. package/bin/core/getLatestVersion.js +13 -0
  5. package/bin/core/loadRunner.js +9 -0
  6. package/bin/header/v2/commands/header/steps/announce.js +3 -0
  7. package/bin/header/v2/commands/header/steps/checks.js +21 -0
  8. package/bin/header/v2/commands/header/steps/createProject.js +7 -0
  9. package/bin/header/v2/commands/header/steps/getLatestVersion.js +25 -0
  10. package/bin/header/v2/commands/header/steps/locateDestination.js +5 -0
  11. package/bin/header/v2/commands/header/steps/locateSource copy.js +32 -0
  12. package/bin/header/v2/commands/header/steps/locateSource.js +19 -0
  13. package/bin/header/v2/commands/header/steps/resolveFolderName.js +15 -0
  14. package/bin/header/v2/commands/header/template/v2/BuildMenuItem/buildMenuItem.js +49 -0
  15. package/bin/header/v2/commands/header/template/v2/BuildMenuItem/callKSTable.js +7 -0
  16. package/bin/header/v2/commands/header/template/v2/BuildMenuItem/getDefaultKSTableConfig.js +80 -0
  17. package/bin/header/v2/commands/header/template/v2/BuildMenuItem/getKSTableConfig.js +17 -0
  18. package/bin/header/v2/commands/header/template/v2/BuildMenuItem/orchestrateMenuClick.js +34 -0
  19. package/bin/header/v2/commands/header/template/v2/BuildNav/buildBrand.js +14 -0
  20. package/bin/header/v2/commands/header/template/v2/BuildNav/buildHamburger.js +20 -0
  21. package/bin/header/v2/commands/header/template/v2/BuildNav/buildMenu.js +14 -0
  22. package/bin/header/v2/commands/header/template/v2/BuildNav/buildNav.js +31 -0
  23. package/bin/header/v2/commands/header/template/v2/BuildNav/buildWrapper.js +29 -0
  24. package/bin/header/v2/commands/header/template/v2/buildNav.js +29 -0
  25. package/bin/header/v2/commands/header/template/v2/createAnchor.js +15 -0
  26. package/bin/header/v2/commands/header/template/v2/createIcon.js +19 -0
  27. package/bin/header/v2/commands/header/template/v2/createLabel.js +9 -0
  28. package/bin/header/v2/commands/header/template/v2/createLi.js +5 -0
  29. package/bin/header/v2/commands/header/template/v2/initHeader.js +49 -0
  30. package/bin/header/v2/commands/header/template/v3/BuildMenuItem/buildMenuItem.js +49 -0
  31. package/bin/header/v2/commands/header/template/v3/BuildMenuItem/callKSTable.js +7 -0
  32. package/bin/header/v2/commands/header/template/v3/BuildMenuItem/getDefaultKSTableConfig.js +80 -0
  33. package/bin/header/v2/commands/header/template/v3/BuildMenuItem/getKSTableConfig.js +17 -0
  34. package/bin/header/v2/commands/header/template/v3/BuildMenuItem/orchestrateMenuClick.js +34 -0
  35. package/bin/header/v2/commands/header/template/v3/BuildNav/buildBrand.js +14 -0
  36. package/bin/header/v2/commands/header/template/v3/BuildNav/buildHamburger.js +20 -0
  37. package/bin/header/v2/commands/header/template/v3/BuildNav/buildMenu.js +14 -0
  38. package/bin/header/v2/commands/header/template/v3/BuildNav/buildNav.js +31 -0
  39. package/bin/header/v2/commands/header/template/v3/BuildNav/buildWrapper.js +29 -0
  40. package/bin/header/v2/commands/header/template/v3/buildNav.js +29 -0
  41. package/bin/header/v2/commands/header/template/v3/createAnchor.js +15 -0
  42. package/bin/header/v2/commands/header/template/v3/createIcon.js +19 -0
  43. package/bin/header/v2/commands/header/template/v3/createLabel.js +9 -0
  44. package/bin/header/v2/commands/header/template/v3/createLi.js +5 -0
  45. package/bin/header/v2/commands/header/template/v3/initHeader.js +49 -0
  46. package/bin/header/v2/commands/header.js +74 -0
  47. package/bin/header/v2/core/parseInput.js +9 -0
  48. package/bin/header/v2/core/resolveCommand.js +16 -0
  49. package/bin/header/v2/core/showUsage.js +49 -0
  50. package/bin/header/v2/start.js +24 -0
  51. package/bin/header/v3/commands/header/steps/announce.js +3 -0
  52. package/bin/header/v3/commands/header/steps/checks.js +21 -0
  53. package/bin/header/v3/commands/header/steps/createProject.js +7 -0
  54. package/bin/header/v3/commands/header/steps/getLatestVersion.js +25 -0
  55. package/bin/header/v3/commands/header/steps/locateDestination.js +5 -0
  56. package/bin/header/v3/commands/header/steps/locateSource copy.js +32 -0
  57. package/bin/header/v3/commands/header/steps/locateSource.js +19 -0
  58. package/bin/header/v3/commands/header/steps/resolveFolderName.js +15 -0
  59. package/bin/header/v3/commands/header/template/v2/BuildMenuItem/buildMenuItem.js +49 -0
  60. package/bin/header/v3/commands/header/template/v2/BuildMenuItem/callKSTable.js +7 -0
  61. package/bin/header/v3/commands/header/template/v2/BuildMenuItem/getDefaultKSTableConfig.js +80 -0
  62. package/bin/header/v3/commands/header/template/v2/BuildMenuItem/getKSTableConfig.js +17 -0
  63. package/bin/header/v3/commands/header/template/v2/BuildMenuItem/orchestrateMenuClick.js +34 -0
  64. package/bin/header/v3/commands/header/template/v2/BuildNav/buildBrand.js +14 -0
  65. package/bin/header/v3/commands/header/template/v2/BuildNav/buildHamburger.js +20 -0
  66. package/bin/header/v3/commands/header/template/v2/BuildNav/buildMenu.js +14 -0
  67. package/bin/header/v3/commands/header/template/v2/BuildNav/buildNav.js +31 -0
  68. package/bin/header/v3/commands/header/template/v2/BuildNav/buildWrapper.js +29 -0
  69. package/bin/header/v3/commands/header/template/v2/buildNav.js +29 -0
  70. package/bin/header/v3/commands/header/template/v2/createAnchor.js +15 -0
  71. package/bin/header/v3/commands/header/template/v2/createIcon.js +19 -0
  72. package/bin/header/v3/commands/header/template/v2/createLabel.js +9 -0
  73. package/bin/header/v3/commands/header/template/v2/createLi.js +5 -0
  74. package/bin/header/v3/commands/header/template/v2/initHeader.js +49 -0
  75. package/bin/header/v3/commands/header/template/v3/BuildMenuItem/buildMenuItem.js +49 -0
  76. package/bin/header/v3/commands/header/template/v3/BuildMenuItem/callKSTable.js +7 -0
  77. package/bin/header/v3/commands/header/template/v3/BuildMenuItem/getDefaultKSTableConfig.js +80 -0
  78. package/bin/header/v3/commands/header/template/v3/BuildMenuItem/getKSTableConfig.js +17 -0
  79. package/bin/header/v3/commands/header/template/v3/BuildMenuItem/orchestrateMenuClick.js +34 -0
  80. package/bin/header/v3/commands/header/template/v3/BuildNav/buildBrand.js +14 -0
  81. package/bin/header/v3/commands/header/template/v3/BuildNav/buildHamburger.js +20 -0
  82. package/bin/header/v3/commands/header/template/v3/BuildNav/buildMenu.js +14 -0
  83. package/bin/header/v3/commands/header/template/v3/BuildNav/buildNav.js +31 -0
  84. package/bin/header/v3/commands/header/template/v3/BuildNav/buildWrapper.js +29 -0
  85. package/bin/header/v3/commands/header/template/v3/buildNav.js +29 -0
  86. package/bin/header/v3/commands/header/template/v3/createAnchor.js +15 -0
  87. package/bin/header/v3/commands/header/template/v3/createIcon.js +19 -0
  88. package/bin/header/v3/commands/header/template/v3/createLabel.js +9 -0
  89. package/bin/header/v3/commands/header/template/v3/createLi.js +5 -0
  90. package/bin/header/v3/commands/header/template/v3/initHeader.js +49 -0
  91. package/bin/header/v3/commands/header/template/v4/BuildMenuItem/buildMenuItem.js +47 -0
  92. package/bin/header/v3/commands/header/template/v4/BuildMenuItem/callKSTable.js +7 -0
  93. package/bin/header/v3/commands/header/template/v4/BuildMenuItem/getDefaultKSTableConfig.js +80 -0
  94. package/bin/header/v3/commands/header/template/v4/BuildMenuItem/getKSTableConfig.js +17 -0
  95. package/bin/header/v3/commands/header/template/v4/BuildMenuItem/orchestrateMenuClick.js +34 -0
  96. package/bin/header/v3/commands/header/template/v4/BuildNav/buildBrand.js +14 -0
  97. package/bin/header/v3/commands/header/template/v4/BuildNav/buildHamburger.js +20 -0
  98. package/bin/header/v3/commands/header/template/v4/BuildNav/buildMenu.js +14 -0
  99. package/bin/header/v3/commands/header/template/v4/BuildNav/buildNav.js +31 -0
  100. package/bin/header/v3/commands/header/template/v4/BuildNav/buildWrapper.js +29 -0
  101. package/bin/header/v3/commands/header/template/v4/buildNav.js +29 -0
  102. package/bin/header/v3/commands/header/template/v4/createAnchor.js +15 -0
  103. package/bin/header/v3/commands/header/template/v4/createIcon.js +19 -0
  104. package/bin/header/v3/commands/header/template/v4/createLabel.js +9 -0
  105. package/bin/header/v3/commands/header/template/v4/createLi.js +5 -0
  106. package/bin/header/v3/commands/header/template/v4/icons.js +20 -0
  107. package/bin/header/v3/commands/header/template/v4/initHeader.js +50 -0
  108. package/bin/header/v3/commands/header/template/v4/svg/icons.json +6 -0
  109. package/bin/header/v3/commands/header/template/v4/svg/search.svg +3 -0
  110. package/bin/header/v3/commands/header/template/v4/svg/show.svg +3 -0
  111. package/bin/header/v3/commands/header.js +74 -0
  112. package/bin/header/v3/core/parseInput.js +9 -0
  113. package/bin/header/v3/core/resolveCommand.js +16 -0
  114. package/bin/header/v3/core/showUsage.js +49 -0
  115. package/bin/header/v3/start.js +24 -0
  116. package/bin/v5/commands/header/steps/announce.js +3 -0
  117. package/bin/v5/commands/header/steps/checks.js +21 -0
  118. package/bin/v5/commands/header/steps/createProject.js +7 -0
  119. package/bin/v5/commands/header/steps/getLatestVersion.js +25 -0
  120. package/bin/v5/commands/header/steps/locateDestination.js +5 -0
  121. package/bin/v5/commands/header/steps/locateSource copy.js +32 -0
  122. package/bin/v5/commands/header/steps/locateSource.js +19 -0
  123. package/bin/v5/commands/header/steps/resolveFolderName.js +15 -0
  124. package/bin/v5/commands/header/template/v4/BuildMenuItem/buildMenuItem.js +49 -0
  125. package/bin/v5/commands/header/template/v4/BuildMenuItem/callKSTable.js +7 -0
  126. package/bin/v5/commands/header/template/v4/BuildMenuItem/getDefaultKSTableConfig.js +80 -0
  127. package/bin/v5/commands/header/template/v4/BuildMenuItem/getKSTableConfig.js +17 -0
  128. package/bin/v5/commands/header/template/v4/BuildMenuItem/orchestrateMenuClick.js +34 -0
  129. package/bin/v5/commands/header/template/v4/BuildNav/buildBrand.js +14 -0
  130. package/bin/v5/commands/header/template/v4/BuildNav/buildHamburger.js +20 -0
  131. package/bin/v5/commands/header/template/v4/BuildNav/buildMenu.js +14 -0
  132. package/bin/v5/commands/header/template/v4/BuildNav/buildNav.js +31 -0
  133. package/bin/v5/commands/header/template/v4/BuildNav/buildWrapper.js +29 -0
  134. package/bin/v5/commands/header/template/v4/buildNav.js +29 -0
  135. package/bin/v5/commands/header/template/v4/createAnchor.js +15 -0
  136. package/bin/v5/commands/header/template/v4/createIcon.js +19 -0
  137. package/bin/v5/commands/header/template/v4/createLabel.js +9 -0
  138. package/bin/v5/commands/header/template/v4/createLi.js +5 -0
  139. package/bin/v5/commands/header/template/v4/initHeader.js +49 -0
  140. package/bin/v5/commands/header.js +74 -0
  141. package/bin/v5/core/parseInput.js +9 -0
  142. package/bin/v5/core/resolveCommand.js +16 -0
  143. package/bin/v5/core/showUsage.js +46 -0
  144. package/bin/v5/core/showUsageV1.js +49 -0
  145. package/bin/v5/start.js +24 -0
  146. package/index.js +8 -0
  147. package/package.json +43 -0
@@ -0,0 +1,29 @@
1
+ // /header/v1/buildWrapper.js
2
+
3
+ export const buildWrapper = () => {
4
+
5
+ const nav = document.createElement("nav");
6
+
7
+ nav.className = "bg-gray-800 text-white";
8
+
9
+ const outerDiv = document.createElement("div");
10
+
11
+ outerDiv.className = `mx-auto px-3 py-3
12
+ max-w-3xl
13
+ lg:max-w-5xl
14
+ xl:max-w-full xl:px-10`;
15
+
16
+ const innerDiv = document.createElement("div");
17
+
18
+ innerDiv.className =
19
+ "flex flex-wrap items-center justify-between";
20
+
21
+ outerDiv.appendChild(innerDiv);
22
+
23
+ nav.appendChild(outerDiv);
24
+
25
+ return {
26
+ nav,
27
+ innerDiv
28
+ };
29
+ };
@@ -0,0 +1,15 @@
1
+ export const createAnchor = ({
2
+ inHtmlId = "", inHref = "#", cls = "", inTableName = ""
3
+ }) => {
4
+ const a = document.createElement("a");
5
+
6
+ a.id = inHtmlId;
7
+ a.href = inHref;
8
+ a.className = cls;
9
+
10
+ if (inTableName) {
11
+ a.dataset.tableName = inTableName
12
+ };
13
+
14
+ return a;
15
+ };
@@ -0,0 +1,19 @@
1
+ import icons from "./icons.js";
2
+
3
+ export const createIcon = ({
4
+ inSvgName
5
+ }) => {
6
+ console.log("inSvgName : ", inSvgName);
7
+
8
+ if (inSvgName in icons) {
9
+ return document
10
+ .createRange()
11
+ .createContextualFragment(icons[inSvgName])
12
+ .firstElementChild;
13
+ };
14
+
15
+ return document
16
+ .createRange()
17
+ .createContextualFragment(icons.search)
18
+ .firstElementChild;
19
+ };
@@ -0,0 +1,9 @@
1
+ export const createLabel = ({
2
+ inTextToShow = "",
3
+ inClassName = ""
4
+ }) => {
5
+ const span = document.createElement("span");
6
+ span.className = inClassName;
7
+ span.textContent = inTextToShow;
8
+ return span;
9
+ };
@@ -0,0 +1,5 @@
1
+ export const createLi = (cls = "") => {
2
+ const li = document.createElement("li");
3
+ li.className = cls;
4
+ return li;
5
+ };
@@ -0,0 +1,20 @@
1
+ // icons.js
2
+ export default {
3
+ search: `
4
+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6">
5
+ <path stroke-linecap="round" stroke-linejoin="round" d="m21 21-5.197-5.197m0 0A7.5 7.5 0 1 0 5.196 5.196a7.5 7.5 0 0 0 10.607 10.607Z" />
6
+ </svg>
7
+ `,
8
+ home: `<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6">
9
+ <path stroke-linecap="round" stroke-linejoin="round" d="m2.25 12 8.954-8.955c.44-.439 1.152-.439 1.591 0L21.75 12M4.5 9.75v10.125c0 .621.504 1.125 1.125 1.125H9.75v-4.875c0-.621.504-1.125 1.125-1.125h2.25c.621 0 1.125.504 1.125 1.125V21h4.125c.621 0 1.125-.504 1.125-1.125V9.75M8.25 21h8.25" />
10
+ </svg>
11
+ `,
12
+ serial: `<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6">
13
+ <path stroke-linecap="round" stroke-linejoin="round" d="M8.242 5.992h12m-12 6.003H20.24m-12 5.999h12M4.117 7.495v-3.75H2.99m1.125 3.75H2.99m1.125 0H5.24m-1.92 2.577a1.125 1.125 0 1 1 1.591 1.59l-1.83 1.83h2.16M2.99 15.745h1.125a1.125 1.125 0 0 1 0 2.25H3.74m0-.002h.375a1.125 1.125 0 0 1 0 2.25H2.99" />
14
+ </svg>
15
+ `,
16
+ currency: `<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6">
17
+ <path stroke-linecap="round" stroke-linejoin="round" d="M15 8.25H9m6 3H9m3 6-3-3h1.5a3 3 0 1 0 0-6M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z" />
18
+ </svg>
19
+ `
20
+ };
@@ -0,0 +1,50 @@
1
+ import { buildMenuItem } from "./BuildMenuItem/buildMenuItem.js";
2
+ import { buildNav } from "./BuildNav/buildNav.js";
3
+
4
+ const initHeader = (config = {}) => {
5
+
6
+ const header = document.getElementById("header");
7
+
8
+ if (!header) return;
9
+
10
+ header.appendChild(
11
+ buildNav(config.title)
12
+ );
13
+
14
+ const menu = document.getElementById("menu");
15
+
16
+ (config.items || []).forEach(item => {
17
+
18
+ const classes = {
19
+ liClass: "md:text-center",
20
+
21
+ aClass: `${item?.uiClasses?.aClass} flex justify-between items-center
22
+ bg-gray-700 px-4 py-2 rounded-md
23
+ hover:bg-gray-600
24
+ active:bg-gray-500 active:scale-95
25
+ transition-all duration-150
26
+ md:flex-col md:justify-center md:items-center
27
+ lg:bg-transparent lg:px-2 lg:py-1`,
28
+
29
+ spanClass: `ml-3 text-right w-full text-base
30
+ md:w-auto md:text-center md:ml-0 lg:text-lg`,
31
+
32
+ svgClass: "text-gray-300 w-6 h-6 lg:w-7 lg:h-7"
33
+ };
34
+
35
+ const li = buildMenuItem({
36
+ inTextToShow: item.text,
37
+ inHtmlId: item.id,
38
+ inIconPaths: item.icon,
39
+ inHref: item.href,
40
+ onClick: item.onClick,
41
+ inTableName: item.tableName,
42
+ inClasses: classes,
43
+ inSvgName: item.svgName
44
+ });
45
+
46
+ menu.appendChild(li);
47
+ });
48
+ };
49
+
50
+ export default initHeader;
@@ -0,0 +1,6 @@
1
+ {
2
+ "search":`<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6">
3
+ <path stroke-linecap="round" stroke-linejoin="round" d="m21 21-5.197-5.197m0 0A7.5 7.5 0 1 0 5.196 5.196a7.5 7.5 0 0 0 10.607 10.607Z" />
4
+ </svg>
5
+ `
6
+ }
@@ -0,0 +1,3 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6">
2
+ <path stroke-linecap="round" stroke-linejoin="round" d="m21 21-5.197-5.197m0 0A7.5 7.5 0 1 0 5.196 5.196a7.5 7.5 0 0 0 10.607 10.607Z" />
3
+ </svg>
@@ -0,0 +1,3 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6">
2
+ <path stroke-linecap="round" stroke-linejoin="round" d="M3.75 3.75v4.5m0-4.5h4.5m-4.5 0L9 9M3.75 20.25v-4.5m0 4.5h4.5m-4.5 0L9 15M20.25 3.75h-4.5m4.5 0v4.5m0-4.5L15 9m5.25 11.25h-4.5m4.5 0v-4.5m0 4.5L15 15" />
3
+ </svg>
@@ -0,0 +1,74 @@
1
+ import { locateSource } from "./header/steps/locateSource.js";
2
+ import { locateDestination } from "./header/steps/locateDestination.js";
3
+
4
+ import { createProject } from "./header/steps/createProject.js";
5
+ import { announce } from "./header/steps/announce.js";
6
+
7
+ import resolveFolderName from "./header/steps/resolveFolderName.js";
8
+ import checks from "./header/steps/checks.js";
9
+
10
+ export default ({
11
+ folderName = "",
12
+ toPath = process.cwd(),
13
+ inAnnounce = true,
14
+ showLog = false
15
+ }) => {
16
+ if (showLog) {
17
+ console.log(`Resolving folder name..., folderName : ${folderName}`);
18
+ };
19
+
20
+ const resolvedFolderName = resolveFolderName({
21
+ name: folderName
22
+ });
23
+
24
+ if (showLog) {
25
+ console.log(`\n[1] Running checks..., resolvedFolderName : ${resolvedFolderName}`);
26
+ };
27
+
28
+ const fromChecks = checks({
29
+ inFolderName: resolvedFolderName,
30
+ toPath,
31
+ inShowLog: showLog
32
+ });
33
+
34
+ if (fromChecks) return false;
35
+
36
+ if (showLog) {
37
+ console.log("Locating source...");
38
+ }
39
+
40
+ const source = locateSource({
41
+ showLog
42
+ });
43
+
44
+ if (showLog) {
45
+ console.log("Locating destination...");
46
+ }
47
+
48
+ const destination = locateDestination({
49
+ inResolvedFolderName: resolvedFolderName,
50
+ showLog
51
+ });
52
+
53
+ if (showLog) {
54
+ console.log("Creating project...");
55
+ }
56
+
57
+ createProject({
58
+ source,
59
+ destination,
60
+ showLog
61
+ });
62
+
63
+ if (inAnnounce) {
64
+
65
+ if (showLog) {
66
+ console.log("Announcing...");
67
+ }
68
+
69
+ announce({
70
+ inResolvedFolderName: resolvedFolderName,
71
+ showLog
72
+ });
73
+ }
74
+ };
@@ -0,0 +1,9 @@
1
+ export default function parseInput() {
2
+ const [cmd, folderName] = process.argv.slice(2);
3
+
4
+ return {
5
+ cmd: cmd || null,
6
+ folderName: folderName || null,
7
+ toPath: process.cwd()
8
+ };
9
+ };
@@ -0,0 +1,16 @@
1
+ import fs from "fs";
2
+
3
+ const files = fs.readdirSync(new URL("../commands/", import.meta.url));
4
+
5
+ const entries = await Promise.all(
6
+ files.filter(f => f.endsWith(".js"))
7
+ .map(async f => [f.replace(".js", ""), (await import(`../commands/${f}`)).default])
8
+ );
9
+
10
+ const map = Object.fromEntries(entries);
11
+
12
+ const resolveCommand = (cmd) => {
13
+ return map[cmd] || null;
14
+ };
15
+
16
+ export default resolveCommand;
@@ -0,0 +1,49 @@
1
+ /*
2
+ JSON CRUD UI CLI – Entry Flow
3
+
4
+ 1. Read user input from terminal (parseInput)
5
+ 2. If no command → show usage
6
+ 3. If help flags → show usage
7
+ 4. Resolve command dynamically
8
+ 5. If command not found → show usage
9
+ 6. Validate command requirements
10
+ 7. Execute command
11
+
12
+ Goal:
13
+ - Zero confusion for user
14
+ - Single source of truth (showUsage)
15
+ - Self-validating commands
16
+ - Easy to extend (drop-in command architecture)
17
+ */
18
+
19
+ export default function showUsage(version) {
20
+ const g = "\x1b[32m";
21
+ const y = "\x1b[33m";
22
+ const c = "\x1b[36m";
23
+ const gray = "\x1b[90m";
24
+ const r = "\x1b[0m";
25
+
26
+ console.log(`
27
+ ${c}🚀 json-crud-ui-components v${version}${r}
28
+
29
+ ${y}Usage:${r}
30
+ ${g}npx json-crud-ui-components${r} <command>
31
+
32
+ ${y}Commands:${r}
33
+ ${g}init${r} Creates initial boilerplate structure
34
+ ${g}addListeners${r} Adds listeners boilerplate
35
+ ${g}buildHeader${r} Builds header structure
36
+ ${g}htmlIdClick${r} Adds htmlIdClick handler
37
+
38
+ ${y}Examples:${r}
39
+ ${gray}npx json-crud-ui-components init${r}
40
+ ${gray}npx json-crud-ui-components addListeners${r}
41
+
42
+ ${y}Architecture:${r}
43
+ ${gray}commands are auto-loaded dynamically${r}
44
+ ${gray}each command validates required files${r}
45
+
46
+ ${y}Tip:${r}
47
+ ${gray}Run init first before feature commands${r}
48
+ `);
49
+ }
@@ -0,0 +1,24 @@
1
+ import parseInput from "./core/parseInput.js";
2
+ import showUsage from './core/showUsage.js';
3
+
4
+ import resolveCommand from "./core/resolveCommand.js";
5
+
6
+ import pkg from '../../package.json' with { type: 'json' };
7
+
8
+ const version = pkg.version;
9
+
10
+ const run = async () => {
11
+ const input = parseInput();
12
+
13
+ if (input.action === "--help" || input.action === "-h" || input.action === "help") return showUsage(version);
14
+
15
+ const command = resolveCommand(input.cmd);
16
+
17
+ if (!command) return (console.log(`Unknown command: ${input.cmd}\n`), showUsage(version));
18
+
19
+ await command({
20
+ folderName: input.folderName
21
+ });
22
+ };
23
+
24
+ export default run;
@@ -0,0 +1,3 @@
1
+ export const announce = ({ inResolvedFolderName }) => {
2
+ console.log(`[keshavsoft] Project created: ${inResolvedFolderName}`);
3
+ };
@@ -0,0 +1,21 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+
4
+ const validate = ({ toPath, inFolderName, inShowLog }) => {
5
+ const fullPath = path.join(toPath, inFolderName);
6
+
7
+ if (!fs.existsSync(fullPath)) {
8
+ return false;
9
+ }
10
+
11
+ const files = fs.readdirSync(fullPath);
12
+
13
+ if (files.length > 0) {
14
+ console.log("Folder should be empty");
15
+ return true;
16
+ };
17
+
18
+ return false;
19
+ };
20
+
21
+ export default validate;
@@ -0,0 +1,7 @@
1
+ import fs from "fs";
2
+
3
+ export const createProject = ({ source, destination }) => {
4
+ fs.mkdirSync(destination, { recursive: true });
5
+
6
+ fs.cpSync(source, destination, { recursive: true });
7
+ };
@@ -0,0 +1,25 @@
1
+ import fs from "fs";
2
+
3
+ import path from "path";
4
+ import { fileURLToPath } from "url";
5
+
6
+ const __filename = fileURLToPath(import.meta.url);
7
+ const __dirname = path.dirname(__filename);
8
+
9
+ const templatePath = path.join(
10
+ __dirname,
11
+ "..",
12
+ "template"
13
+ );
14
+
15
+ const versions = fs
16
+ .readdirSync(templatePath)
17
+ .filter(item => item.startsWith("v"));
18
+
19
+ const highestVersion =
20
+ versions.sort().at(-1);
21
+
22
+ const sourceVersion =
23
+ highestVersion;
24
+
25
+ export default sourceVersion;
@@ -0,0 +1,5 @@
1
+ import path from "path";
2
+
3
+ export const locateDestination = ({ inResolvedFolderName }) => {
4
+ return path.join(process.cwd(), inResolvedFolderName);
5
+ };
@@ -0,0 +1,32 @@
1
+ import fs from "fs";
2
+
3
+ import path from "path";
4
+ import { fileURLToPath } from "url";
5
+
6
+ const __filename = fileURLToPath(import.meta.url);
7
+ const __dirname = path.dirname(__filename);
8
+
9
+ const templatePath = path.join(
10
+ __dirname,
11
+ "..",
12
+ "template"
13
+ );
14
+
15
+ const versions = fs
16
+ .readdirSync(templatePath)
17
+ .filter(item => item.startsWith("v"));
18
+
19
+ const highestVersion =
20
+ versions.sort().at(-1);
21
+
22
+ const sourceVersion =
23
+ highestVersion;
24
+
25
+ export const locateSource = () => {
26
+ return path.join(
27
+ __dirname,
28
+ "..",
29
+ "template",
30
+ sourceVersion
31
+ );
32
+ };
@@ -0,0 +1,19 @@
1
+ import path from "path";
2
+
3
+ import sourceVersion from "./getLatestVersion.js";
4
+
5
+ import fs from "fs";
6
+
7
+ import { fileURLToPath } from "url";
8
+
9
+ const __filename = fileURLToPath(import.meta.url);
10
+ const __dirname = path.dirname(__filename);
11
+
12
+ export const locateSource = () => {
13
+ return path.join(
14
+ __dirname,
15
+ "..",
16
+ "template",
17
+ sourceVersion
18
+ );
19
+ };
@@ -0,0 +1,15 @@
1
+ import fs from "fs";
2
+
3
+ export default function resolveFolderName({ name, defaultFolerName = "headerV1" }) {
4
+ // case 1: force new → timestamp
5
+ if (name === null) {
6
+ name = defaultFolerName;
7
+ };
8
+
9
+ // case 2: user provided → strict
10
+ if (fs.existsSync(name)) {
11
+ throw new Error(`Folder already exists: ${name}`);
12
+ };
13
+
14
+ return name;
15
+ };
@@ -0,0 +1,49 @@
1
+ import { createLi } from "../createLi.js";
2
+ import { createAnchor } from "../createAnchor.js";
3
+ import { createLabel } from "../createLabel.js";
4
+ import { createIcon } from "../createIcon.js";
5
+ import { orchestrateMenuClick } from "./orchestrateMenuClick.js";
6
+
7
+ export const buildMenuItem = ({
8
+ inTextToShow,
9
+ inHtmlId,
10
+ inIconPaths,
11
+ inHref,
12
+ onClick,
13
+ inTableName,
14
+ inClasses
15
+ }) => {
16
+ const li = createLi(inClasses.liClass);
17
+
18
+ const a = createAnchor({
19
+ inHtmlId,
20
+ inHref,
21
+ cls: inClasses.aClass,
22
+ inTableName
23
+ });
24
+ // debugger;
25
+ const span = createLabel({
26
+ inTextToShow: inTextToShow,
27
+ inClassName: inClasses.spanClass
28
+ });
29
+
30
+ const svg = createIcon({
31
+ inClassName: inClasses.svgClass,
32
+ inIconPaths
33
+ });
34
+
35
+ a.addEventListener(
36
+ "click",
37
+ orchestrateMenuClick({
38
+ onClick
39
+ })
40
+ );
41
+
42
+ a.addEventListener("click1", orchestrateMenuClick);
43
+
44
+ a.append(svg, span);
45
+
46
+ li.appendChild(a);
47
+
48
+ return li;
49
+ };
@@ -0,0 +1,7 @@
1
+ export const callKSTable = async (config) => {
2
+ if (window.KSTable?.initTableOnly) {
3
+ return window.KSTable.initTableOnly(config);
4
+ };
5
+
6
+ return initTableOnly(config);
7
+ };
@@ -0,0 +1,80 @@
1
+ export const getDefaultKSTableConfig = () => {
2
+ return {
3
+ containerId: 'kSTableContainer',
4
+
5
+ tableName: "",
6
+
7
+ mode: "create",
8
+
9
+ layout: {
10
+ verticalPosition: "top",
11
+ type: "table",
12
+ },
13
+
14
+ endPoints: {
15
+ create: "",
16
+ update: "",
17
+ delete: "",
18
+ read: "",
19
+ find: ""
20
+ },
21
+
22
+ options: {
23
+ firstRow: {
24
+ showSearch: true
25
+ },
26
+
27
+ vertical: {
28
+ showVertical: true,
29
+ isDisabled: false,
30
+ showSaveButton: true
31
+ },
32
+
33
+ dataList: {
34
+ show: true,
35
+ },
36
+
37
+ table: {
38
+ isDisabled: false,
39
+ showTable: true,
40
+ showRowOptions: false,
41
+ showSerial: true,
42
+ showFooter: false,
43
+
44
+ footer: {
45
+ showDataList: true
46
+ }
47
+ },
48
+
49
+ focus: {
50
+ priority: ["vertical", "footer", "search"]
51
+ }
52
+ },
53
+
54
+ columnsConfig: [],
55
+
56
+ uiClasses: {
57
+ form: {
58
+ formClass: 'grid grid-cols-3 gap-x-8 gap-y-4 p-6 verticalForm',
59
+ buttonClass: 'mt-2 px-4 py-1 bg-green-500 text-white',
60
+ rowClass: 'flex items-center space-x-4',
61
+ labelClass: 'w-24 text-sm font-medium',
62
+ inputClass: 'flex-1 border rounded px-3 py-2'
63
+ }
64
+ },
65
+
66
+ callbacks: {
67
+ table: {
68
+ onDelete: async ({ toDeletePk }) => {
69
+ const fromDelete = await startFetchAsGet({
70
+ inQuery: {
71
+ ParentPk: toDeletePk
72
+ }
73
+ });
74
+
75
+ return await fromDelete;
76
+ }
77
+ }
78
+ }
79
+ };
80
+ };
@@ -0,0 +1,17 @@
1
+ import { getDefaultKSTableConfig } from "./getDefaultKSTableConfig.js";
2
+
3
+ export const getKSTableConfig = async ({ tableName }) => {
4
+ const config = getDefaultKSTableConfig();
5
+
6
+ const fromPromise = await fetch("/columns.json");
7
+ // debugger;
8
+ const columnsConfig = await fromPromise.json();
9
+
10
+ config.columnsConfig = columnsConfig[tableName].columnsConfig;
11
+
12
+ config.tableName = tableName;
13
+
14
+ config.endPoints.read = `/Api/V1/${tableName}/ShowAll`;
15
+
16
+ return config;
17
+ };