json-crud-ui-components 1.2.2 → 1.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 (109) hide show
  1. package/bin/cli.js +1 -1
  2. package/bin/{v2 → v3}/commands/addListeners/steps/resolveFolderName.js +1 -1
  3. package/bin/{v2 → v3}/commands/init.js +1 -0
  4. package/bin/v3/core/resolveCommand.js +16 -0
  5. package/bin/{v2 → v3}/start.js +0 -1
  6. package/bin/v4/commands/addListeners/steps/announce.js +3 -0
  7. package/bin/v4/commands/addListeners/steps/checks.js +25 -0
  8. package/bin/v4/commands/addListeners/steps/createProject.js +7 -0
  9. package/bin/v4/commands/addListeners/steps/locateDestination.js +5 -0
  10. package/bin/v4/commands/addListeners/steps/locateSource.js +32 -0
  11. package/bin/v4/commands/addListeners/steps/resolveFolderName.js +17 -0
  12. package/bin/v4/commands/addListeners/template/v2/start.js +4 -0
  13. package/bin/v4/commands/addListeners.js +25 -0
  14. package/bin/v4/commands/buildHeader/steps/announce.js +3 -0
  15. package/bin/v4/commands/buildHeader/steps/createProject.js +7 -0
  16. package/bin/v4/commands/buildHeader/steps/locateDestination.js +5 -0
  17. package/bin/v4/commands/buildHeader/steps/locateSource.js +32 -0
  18. package/bin/v4/commands/buildHeader/steps/resolveFolderName.js +17 -0
  19. package/bin/v4/commands/buildHeader/template/v1/buildHeader.js +68 -0
  20. package/bin/v4/commands/buildHeader.js +20 -0
  21. package/bin/v4/commands/htmlIdClick/steps/announce.js +3 -0
  22. package/bin/v4/commands/htmlIdClick/steps/checks.js +25 -0
  23. package/bin/v4/commands/htmlIdClick/steps/createProject.js +7 -0
  24. package/bin/v4/commands/htmlIdClick/steps/locateDestination.js +5 -0
  25. package/bin/v4/commands/htmlIdClick/steps/locateSource.js +32 -0
  26. package/bin/v4/commands/htmlIdClick/steps/resolveFolderName.js +14 -0
  27. package/bin/v4/commands/htmlIdClick/template/v1/clickFunc.js +4 -0
  28. package/bin/v4/commands/htmlIdClick/template/v1/start.js +9 -0
  29. package/bin/v4/commands/htmlIdClick.js +32 -0
  30. package/bin/v4/commands/init/steps/announce.js +3 -0
  31. package/bin/v4/commands/init/steps/checks.js +23 -0
  32. package/bin/v4/commands/init/steps/createProject.js +7 -0
  33. package/bin/v4/commands/init/steps/locateDestination.js +5 -0
  34. package/bin/v4/commands/init/steps/locateSource.js +32 -0
  35. package/bin/v4/commands/init/steps/resolveFolderName.js +17 -0
  36. package/bin/v4/commands/init/template/v1/Index/FormLoad/DomContentLoaded/buildHeader.js +68 -0
  37. package/bin/v4/commands/init/template/v1/Index/FormLoad/DomContentLoaded/buildMenuItem.js +121 -0
  38. package/bin/v4/commands/init/template/v1/Index/FormLoad/DomContentLoaded/runAfterDomLoad.js +7 -0
  39. package/bin/v4/commands/init/template/v1/Index/FormLoad/DomContentLoaded/start.js +7 -0
  40. package/bin/v4/commands/init/template/v1/Index/FormLoad/start.js +5 -0
  41. package/bin/v4/commands/init/template/v1/Index/start.js +7 -0
  42. package/bin/v4/commands/init/template/v2/FormLoad/DomContentLoaded/buildHeader.js +68 -0
  43. package/bin/v4/commands/init/template/v2/FormLoad/DomContentLoaded/buildMenuItem.js +121 -0
  44. package/bin/v4/commands/init/template/v2/FormLoad/DomContentLoaded/runAfterDomLoad.js +7 -0
  45. package/bin/v4/commands/init/template/v2/FormLoad/DomContentLoaded/start.js +7 -0
  46. package/bin/v4/commands/init/template/v2/FormLoad/start.js +5 -0
  47. package/bin/v4/commands/init/template/v2/start.js +7 -0
  48. package/bin/v4/commands/init/template/v3/FormLoad/DomContentLoaded/buildHeader.js +58 -0
  49. package/bin/v4/commands/init/template/v3/FormLoad/DomContentLoaded/buildMenuItem.js +121 -0
  50. package/bin/v4/commands/init/template/v3/FormLoad/DomContentLoaded/runAfterDomLoad.js +7 -0
  51. package/bin/v4/commands/init/template/v3/FormLoad/DomContentLoaded/start.js +7 -0
  52. package/bin/v4/commands/init/template/v3/FormLoad/start.js +5 -0
  53. package/bin/v4/commands/init/template/v3/headers.json +45 -0
  54. package/bin/v4/commands/init/template/v3/start.js +7 -0
  55. package/bin/v4/commands/init.js +25 -0
  56. package/bin/v4/core/parseInput.js +9 -0
  57. package/bin/v4/core/resolveCommand.js +16 -0
  58. package/bin/v4/core/showUsage.js +49 -0
  59. package/bin/v4/start.js +24 -0
  60. package/package.json +1 -1
  61. package/bin/v2/commands/addListeners/template/v1/AddListeners/start.js +0 -14
  62. package/bin/v2/core/resolveCommand.js +0 -16
  63. /package/bin/{v2 → v3}/commands/addListeners/steps/announce.js +0 -0
  64. /package/bin/{v2 → v3}/commands/addListeners/steps/createProject.js +0 -0
  65. /package/bin/{v2 → v3}/commands/addListeners/steps/locateDestination.js +0 -0
  66. /package/bin/{v2 → v3}/commands/addListeners/steps/locateSource.js +0 -0
  67. /package/bin/{v2 → v3}/commands/addListeners/template/v2/start.js +0 -0
  68. /package/bin/{v2 → v3}/commands/addListeners.js +0 -0
  69. /package/bin/{v2 → v3}/commands/buildHeader/steps/announce.js +0 -0
  70. /package/bin/{v2 → v3}/commands/buildHeader/steps/createProject.js +0 -0
  71. /package/bin/{v2 → v3}/commands/buildHeader/steps/locateDestination.js +0 -0
  72. /package/bin/{v2 → v3}/commands/buildHeader/steps/locateSource.js +0 -0
  73. /package/bin/{v2 → v3}/commands/buildHeader/steps/resolveFolderName.js +0 -0
  74. /package/bin/{v2 → v3}/commands/buildHeader/template/v1/buildHeader.js +0 -0
  75. /package/bin/{v2 → v3}/commands/buildHeader.js +0 -0
  76. /package/bin/{v2 → v3}/commands/htmlIdClick/steps/announce.js +0 -0
  77. /package/bin/{v2 → v3}/commands/htmlIdClick/steps/createProject.js +0 -0
  78. /package/bin/{v2 → v3}/commands/htmlIdClick/steps/locateDestination.js +0 -0
  79. /package/bin/{v2 → v3}/commands/htmlIdClick/steps/locateSource.js +0 -0
  80. /package/bin/{v2 → v3}/commands/htmlIdClick/steps/resolveFolderName.js +0 -0
  81. /package/bin/{v2 → v3}/commands/htmlIdClick/template/v1/clickFunc.js +0 -0
  82. /package/bin/{v2 → v3}/commands/htmlIdClick/template/v1/start.js +0 -0
  83. /package/bin/{v2 → v3}/commands/htmlIdClick.js +0 -0
  84. /package/bin/{v2 → v3}/commands/init/steps/announce.js +0 -0
  85. /package/bin/{v2 → v3}/commands/init/steps/createProject.js +0 -0
  86. /package/bin/{v2 → v3}/commands/init/steps/locateDestination.js +0 -0
  87. /package/bin/{v2 → v3}/commands/init/steps/locateSource.js +0 -0
  88. /package/bin/{v2 → v3}/commands/init/steps/resolveFolderName.js +0 -0
  89. /package/bin/{v2 → v3}/commands/init/template/v1/Index/FormLoad/DomContentLoaded/buildHeader.js +0 -0
  90. /package/bin/{v2 → v3}/commands/init/template/v1/Index/FormLoad/DomContentLoaded/buildMenuItem.js +0 -0
  91. /package/bin/{v2 → v3}/commands/init/template/v1/Index/FormLoad/DomContentLoaded/runAfterDomLoad.js +0 -0
  92. /package/bin/{v2 → v3}/commands/init/template/v1/Index/FormLoad/DomContentLoaded/start.js +0 -0
  93. /package/bin/{v2 → v3}/commands/init/template/v1/Index/FormLoad/start.js +0 -0
  94. /package/bin/{v2 → v3}/commands/init/template/v1/Index/start.js +0 -0
  95. /package/bin/{v2 → v3}/commands/init/template/v2/FormLoad/DomContentLoaded/buildHeader.js +0 -0
  96. /package/bin/{v2 → v3}/commands/init/template/v2/FormLoad/DomContentLoaded/buildMenuItem.js +0 -0
  97. /package/bin/{v2 → v3}/commands/init/template/v2/FormLoad/DomContentLoaded/runAfterDomLoad.js +0 -0
  98. /package/bin/{v2 → v3}/commands/init/template/v2/FormLoad/DomContentLoaded/start.js +0 -0
  99. /package/bin/{v2 → v3}/commands/init/template/v2/FormLoad/start.js +0 -0
  100. /package/bin/{v2 → v3}/commands/init/template/v2/start.js +0 -0
  101. /package/bin/{v2 → v3}/commands/init/template/v3/FormLoad/DomContentLoaded/buildHeader.js +0 -0
  102. /package/bin/{v2 → v3}/commands/init/template/v3/FormLoad/DomContentLoaded/buildMenuItem.js +0 -0
  103. /package/bin/{v2 → v3}/commands/init/template/v3/FormLoad/DomContentLoaded/runAfterDomLoad.js +0 -0
  104. /package/bin/{v2 → v3}/commands/init/template/v3/FormLoad/DomContentLoaded/start.js +0 -0
  105. /package/bin/{v2 → v3}/commands/init/template/v3/FormLoad/start.js +0 -0
  106. /package/bin/{v2 → v3}/commands/init/template/v3/headers.json +0 -0
  107. /package/bin/{v2 → v3}/commands/init/template/v3/start.js +0 -0
  108. /package/bin/{v2 → v3}/core/parseInput.js +0 -0
  109. /package/bin/{v2 → v3}/core/showUsage.js +0 -0
package/bin/cli.js CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
 
3
3
  import getLatestVersion from "./core/getLatestVersion.js";
4
4
  import loadRunner from "./core/loadRunner.js";
@@ -1,7 +1,7 @@
1
1
  import fs from "fs";
2
2
 
3
3
  export default function resolveFolderName({ name }) {
4
- const defaultFolerName = "htmlId";
4
+ const defaultFolerName = "AddListeners";
5
5
 
6
6
  // case 1: force new → timestamp
7
7
  if (name === null) {
@@ -7,6 +7,7 @@ import { announce } from "./init/steps/announce.js";
7
7
  import resolveFolderName from "./init/steps/resolveFolderName.js";
8
8
 
9
9
  export default ({ folderName = "", toPath = process.cwd(), inAnnounce = true }) => {
10
+
10
11
  const resolvedFolderName = resolveFolderName({
11
12
  name: folderName
12
13
  });
@@ -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;
@@ -11,7 +11,6 @@ const run = async () => {
11
11
  const input = parseInput();
12
12
 
13
13
  if (input.action === "--help" || input.action === "-h" || input.action === "help") return showUsage(version);
14
- console.log("input : ", input);
15
14
 
16
15
  const command = resolveCommand(input.cmd);
17
16
 
@@ -0,0 +1,3 @@
1
+ export const announce = ({ inResolvedFolderName }) => {
2
+ console.log(`[keshavsoft] Project created: ${inResolvedFolderName}`);
3
+ };
@@ -0,0 +1,25 @@
1
+ import path from "path";
2
+ import fs from "fs";
3
+
4
+ const validate = ({ toPath, inDefaultFolderName, inFileNameToCheck }) => {
5
+ const fileNameToCheck = inFileNameToCheck;
6
+
7
+ const htmlPath = path.join(toPath, fileNameToCheck);
8
+ const indexPath = path.join(toPath, inDefaultFolderName);
9
+
10
+ if (!fs.existsSync(htmlPath)) {
11
+ console.log(`${fileNameToCheck} not found`);
12
+
13
+ return true;
14
+ };
15
+
16
+ if (fs.existsSync(indexPath)) {
17
+ console.log(`${folderNameToCheck} folder found`);
18
+
19
+ return true;
20
+ };
21
+
22
+ return false;
23
+ };
24
+
25
+ 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,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,17 @@
1
+ import fs from "fs";
2
+
3
+ export default function resolveFolderName({ name }) {
4
+ const defaultFolerName = "AddListeners";
5
+
6
+ // case 1: force new → timestamp
7
+ if (name === null) {
8
+ name = defaultFolerName;
9
+ };
10
+
11
+ // case 2: user provided → strict
12
+ if (fs.existsSync(name)) {
13
+ throw new Error(`Folder already exists: ${name}`);
14
+ };
15
+
16
+ return name;
17
+ };
@@ -0,0 +1,4 @@
1
+ const hookAllListeners = () => {
2
+ };
3
+
4
+ export { hookAllListeners };
@@ -0,0 +1,25 @@
1
+ import { locateSource } from "./addListeners/steps/locateSource.js";
2
+ import { locateDestination } from "./addListeners/steps/locateDestination.js";
3
+
4
+ import { createProject } from "./addListeners/steps/createProject.js";
5
+ import { announce } from "./addListeners/steps/announce.js";
6
+
7
+ import resolveFolderName from "./addListeners/steps/resolveFolderName.js";
8
+ import checks from "./addListeners/steps/checks.js";
9
+
10
+ export default ({ folderName = "", toPath = process.cwd(), inAnnounce = true }) => {
11
+ const fromChecks = checks({ toPath, inAnnounce });
12
+
13
+ if (fromChecks) return false;
14
+
15
+ const resolvedFolderName = resolveFolderName({
16
+ name: folderName
17
+ });
18
+
19
+ const source = locateSource();
20
+ const destination = locateDestination({ inResolvedFolderName: resolvedFolderName });
21
+
22
+ createProject({ source, destination });
23
+
24
+ if (inAnnounce) announce({ inResolvedFolderName: resolvedFolderName });
25
+ };
@@ -0,0 +1,3 @@
1
+ export const announce = ({ inResolvedFolderName }) => {
2
+ console.log(`[keshavsoft] Project created: ${inResolvedFolderName}`);
3
+ };
@@ -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,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,17 @@
1
+ import fs from "fs";
2
+
3
+ export default function resolveFolderName({ name, inType = "basic" }) {
4
+ const defaultFolerName = "AddListeners";
5
+
6
+ // case 1: force new → timestamp
7
+ if (name === null) {
8
+ name = defaultFolerName;
9
+ };
10
+
11
+ // case 2: user provided → strict
12
+ if (fs.existsSync(name)) {
13
+ throw new Error(`Folder already exists: ${name}`);
14
+ };
15
+
16
+ return name;
17
+ };
@@ -0,0 +1,68 @@
1
+ import { initHeader } from "../../../../../../header/v5/initHeader.js";
2
+
3
+ const buildHeader = async () => {
4
+ const headerConfig = {
5
+ items: [
6
+ {
7
+ text: "Ledgers",
8
+ id: "LedgersHtmlId",
9
+ icon: [
10
+ "M4 6h16",
11
+ "M4 10h16",
12
+ "M4 14h10",
13
+ "M6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z"
14
+ ]
15
+ },
16
+ {
17
+ text: "StockItems",
18
+ id: "StockItemsHtmlId",
19
+ icon: [
20
+ "M3 7l9 4 9-4",
21
+ "M3 7l9-4 9 4",
22
+ "M3 7v10l9 4 9-4V7",
23
+ "M12 11v10"
24
+ ]
25
+ },
26
+ {
27
+ text: "Transactions",
28
+ id: "1",
29
+ icon: [
30
+
31
+ "M6 2h9l5 5v15a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2z",
32
+ "M14 2v6h6",
33
+ "M8 12h8",
34
+ "M8 16h8"
35
+ ],
36
+ href: "../../Transactions/V7/Create/index.html"
37
+ },
38
+ {
39
+ text: "FromTally",
40
+ id: "ImportHtmlId",
41
+ icon: [
42
+ "M4 6h16",
43
+ "M4 10h16",
44
+ "M4 14h10",
45
+ "M6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z"
46
+ ]
47
+ }
48
+ ]
49
+ };
50
+
51
+ await initHeader(headerConfig);
52
+ // await callKSHeader(headerConfig);
53
+ };
54
+
55
+ const callKSHeader = async (config) => {
56
+ if (window.KSHeader?.initHeader) {
57
+ console.log("table loaded from window.KSTable");
58
+
59
+ return window.KSHeader.initHeader(config); // extension or CDN
60
+ } else {
61
+ // const { initTableOnly } = await import("../../../../../../../../KSTableAi/V28/entry.js"); // local
62
+ const { initTableOnly } = await import("https://keshavsoft.github.io/KsJsTableAi/Public/kstable.js"); // local
63
+
64
+ return initTableOnly(config);
65
+ };
66
+ };
67
+
68
+ export default buildHeader;
@@ -0,0 +1,20 @@
1
+ import { locateSource } from "./buildHeader/steps/locateSource.js";
2
+ import { locateDestination } from "./buildHeader/steps/locateDestination.js";
3
+
4
+ import { createProject } from "./buildHeader/steps/createProject.js";
5
+ import { announce } from "./buildHeader/steps/announce.js";
6
+
7
+ import resolveFolderName from "./buildHeader/steps/resolveFolderName.js";
8
+
9
+ export default ({ folderName = "", toPath = process.cwd(), inAnnounce = true }) => {
10
+ const resolvedFolderName = resolveFolderName({
11
+ name: folderName
12
+ });
13
+
14
+ const source = locateSource();
15
+ const destination = locateDestination({ inResolvedFolderName: resolvedFolderName });
16
+
17
+ createProject({ source, destination });
18
+
19
+ if (inAnnounce) announce({ inResolvedFolderName: resolvedFolderName });
20
+ };
@@ -0,0 +1,3 @@
1
+ export const announce = ({ inResolvedFolderName }) => {
2
+ console.log(`[keshavsoft] Project created: ${inResolvedFolderName}`);
3
+ };
@@ -0,0 +1,25 @@
1
+ import path from "path";
2
+ import fs from "fs";
3
+ const fileNameToCheck = "runAfterDomLoad.js";
4
+ const folderNameToCheck = "AddListeners";
5
+
6
+ const validate = ({ toPath }) => {
7
+ const htmlPath = path.join(toPath, fileNameToCheck);
8
+ const indexPath = path.join(toPath, folderNameToCheck);
9
+
10
+ if (!fs.existsSync(htmlPath)) {
11
+ console.log(`${fileNameToCheck} not found`);
12
+
13
+ return true;
14
+ };
15
+
16
+ if (fs.existsSync(indexPath)) {
17
+ console.log(`${folderNameToCheck} folder found`);
18
+
19
+ return true;
20
+ };
21
+
22
+ return false;
23
+ };
24
+
25
+ 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,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,14 @@
1
+ import fs from "fs";
2
+
3
+ export default function resolveFolderName({ name, inDefaultFolderName = "<htmlId>" }) {
4
+ if (name === null) {
5
+ name = inDefaultFolderName;
6
+ };
7
+
8
+ // case 2: user provided → strict
9
+ if (fs.existsSync(name)) {
10
+ throw new Error(`Folder already exists: ${name}`);
11
+ };
12
+
13
+ return name;
14
+ };
@@ -0,0 +1,4 @@
1
+ const clickFuncToRun = () => {
2
+ };
3
+
4
+ export default clickFuncToRun;
@@ -0,0 +1,9 @@
1
+ import clickFuncToRun from "./clickFunc.js";
2
+
3
+ const funcToRun = () => {
4
+ const htmlElement = document.getElementById('<htmlId>');
5
+
6
+ htmlElement.addEventListener('click', clickFuncToRun);
7
+ };
8
+
9
+ export { funcToRun };
@@ -0,0 +1,32 @@
1
+ import { locateSource } from "./htmlIdClick/steps/locateSource.js";
2
+ import { locateDestination } from "./htmlIdClick/steps/locateDestination.js";
3
+
4
+ import { createProject } from "./htmlIdClick/steps/createProject.js";
5
+ import { announce } from "./htmlIdClick/steps/announce.js";
6
+
7
+ import resolveFolderName from "./htmlIdClick/steps/resolveFolderName.js";
8
+ import checks from "./addListeners/steps/checks.js";
9
+
10
+ const defaultFolderName = "<htmlId>";
11
+ const fileNameToCheck = "start.js";
12
+
13
+ export default ({ folderName = "", toPath = process.cwd(), inAnnounce = true }) => {
14
+ const fromChecks = checks({
15
+ toPath, inAnnounce,
16
+ inDefaultFolderName: defaultFolderName,
17
+ inFileNameToCheck: fileNameToCheck
18
+ });
19
+
20
+ if (fromChecks) return false;
21
+
22
+ const resolvedFolderName = resolveFolderName({
23
+ name: folderName, inDefaultFolderName: defaultFolderName
24
+ });
25
+
26
+ const source = locateSource();
27
+ const destination = locateDestination({ inResolvedFolderName: resolvedFolderName });
28
+
29
+ createProject({ source, destination });
30
+
31
+ if (inAnnounce) announce({ inResolvedFolderName: resolvedFolderName });
32
+ };
@@ -0,0 +1,3 @@
1
+ export const announce = ({ inResolvedFolderName }) => {
2
+ console.log(`[keshavsoft] Project created: ${inResolvedFolderName}`);
3
+ };
@@ -0,0 +1,23 @@
1
+ import path from "path";
2
+ import fs from "fs";
3
+
4
+ const validate = ({ toPath }) => {
5
+ const htmlPath = path.join(toPath, "index.html");
6
+ const indexPath = path.join(toPath, "index");
7
+
8
+ if (!fs.existsSync(htmlPath)) {
9
+ console.log("index.html not found");
10
+
11
+ return true;
12
+ };
13
+
14
+ if (fs.existsSync(indexPath)) {
15
+ console.log("index folder found");
16
+
17
+ return true;
18
+ };
19
+
20
+ return false;
21
+ };
22
+
23
+ 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,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,17 @@
1
+ import fs from "fs";
2
+
3
+ export default function resolveFolderName({ name, inType = "basic" }) {
4
+ const defaultFolerName = "Index";
5
+
6
+ // case 1: force new → timestamp
7
+ if (name === null) {
8
+ name = defaultFolerName;
9
+ };
10
+
11
+ // case 2: user provided → strict
12
+ if (fs.existsSync(name)) {
13
+ throw new Error(`Folder already exists: ${name}`);
14
+ };
15
+
16
+ return name;
17
+ };
@@ -0,0 +1,68 @@
1
+ import { initHeader } from "../../../../../../header/v6/initHeader.js";
2
+
3
+ const buildHeader = () => {
4
+ const headerConfig = {
5
+ items: [
6
+ {
7
+ text: "ShowAll",
8
+ id: "ShowAllHtmlId",
9
+ icon: [
10
+ "M4 6h16",
11
+ "M4 10h16",
12
+ "M4 14h10",
13
+ "M6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z"
14
+ ]
15
+ },
16
+ {
17
+ text: "StockItems",
18
+ id: "StockItemsHtmlId",
19
+ icon: [
20
+ "M3 7l9 4 9-4",
21
+ "M3 7l9-4 9 4",
22
+ "M3 7v10l9 4 9-4V7",
23
+ "M12 11v10"
24
+ ]
25
+ },
26
+ {
27
+ text: "Transactions",
28
+ id: "1",
29
+ icon: [
30
+
31
+ "M6 2h9l5 5v15a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2z",
32
+ "M14 2v6h6",
33
+ "M8 12h8",
34
+ "M8 16h8"
35
+ ],
36
+ href: "../../Transactions/V7/Create/index.html"
37
+ },
38
+ {
39
+ text: "FromTally",
40
+ id: "ImportHtmlId",
41
+ icon: [
42
+ "M4 6h16",
43
+ "M4 10h16",
44
+ "M4 14h10",
45
+ "M6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z"
46
+ ]
47
+ }
48
+ ]
49
+ };
50
+
51
+ initHeader(headerConfig);
52
+ // callKSHeader(headerConfig).then();
53
+ };
54
+
55
+ const callKSHeader = async (config) => {
56
+ if (window.KSHeader?.initHeader) {
57
+ console.log("table loaded from window.KSTable");
58
+
59
+ return window.KSHeader.initHeader(config); // extension or CDN
60
+ } else {
61
+ // const { initTableOnly } = await import("../../../../../../../../KSTableAi/V28/entry.js"); // local
62
+ const { initTableOnly } = await import("https://keshavsoft.github.io/KsJsTableAi/Public/kstable.js"); // local
63
+
64
+ return initTableOnly(config);
65
+ };
66
+ };
67
+
68
+ export { buildHeader };