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.
- package/bin/cli.js +1 -1
- package/bin/{v2 → v3}/commands/addListeners/steps/resolveFolderName.js +1 -1
- package/bin/{v2 → v3}/commands/init.js +1 -0
- package/bin/v3/core/resolveCommand.js +16 -0
- package/bin/{v2 → v3}/start.js +0 -1
- package/bin/v4/commands/addListeners/steps/announce.js +3 -0
- package/bin/v4/commands/addListeners/steps/checks.js +25 -0
- package/bin/v4/commands/addListeners/steps/createProject.js +7 -0
- package/bin/v4/commands/addListeners/steps/locateDestination.js +5 -0
- package/bin/v4/commands/addListeners/steps/locateSource.js +32 -0
- package/bin/v4/commands/addListeners/steps/resolveFolderName.js +17 -0
- package/bin/v4/commands/addListeners/template/v2/start.js +4 -0
- package/bin/v4/commands/addListeners.js +25 -0
- package/bin/v4/commands/buildHeader/steps/announce.js +3 -0
- package/bin/v4/commands/buildHeader/steps/createProject.js +7 -0
- package/bin/v4/commands/buildHeader/steps/locateDestination.js +5 -0
- package/bin/v4/commands/buildHeader/steps/locateSource.js +32 -0
- package/bin/v4/commands/buildHeader/steps/resolveFolderName.js +17 -0
- package/bin/v4/commands/buildHeader/template/v1/buildHeader.js +68 -0
- package/bin/v4/commands/buildHeader.js +20 -0
- package/bin/v4/commands/htmlIdClick/steps/announce.js +3 -0
- package/bin/v4/commands/htmlIdClick/steps/checks.js +25 -0
- package/bin/v4/commands/htmlIdClick/steps/createProject.js +7 -0
- package/bin/v4/commands/htmlIdClick/steps/locateDestination.js +5 -0
- package/bin/v4/commands/htmlIdClick/steps/locateSource.js +32 -0
- package/bin/v4/commands/htmlIdClick/steps/resolveFolderName.js +14 -0
- package/bin/v4/commands/htmlIdClick/template/v1/clickFunc.js +4 -0
- package/bin/v4/commands/htmlIdClick/template/v1/start.js +9 -0
- package/bin/v4/commands/htmlIdClick.js +32 -0
- package/bin/v4/commands/init/steps/announce.js +3 -0
- package/bin/v4/commands/init/steps/checks.js +23 -0
- package/bin/v4/commands/init/steps/createProject.js +7 -0
- package/bin/v4/commands/init/steps/locateDestination.js +5 -0
- package/bin/v4/commands/init/steps/locateSource.js +32 -0
- package/bin/v4/commands/init/steps/resolveFolderName.js +17 -0
- package/bin/v4/commands/init/template/v1/Index/FormLoad/DomContentLoaded/buildHeader.js +68 -0
- package/bin/v4/commands/init/template/v1/Index/FormLoad/DomContentLoaded/buildMenuItem.js +121 -0
- package/bin/v4/commands/init/template/v1/Index/FormLoad/DomContentLoaded/runAfterDomLoad.js +7 -0
- package/bin/v4/commands/init/template/v1/Index/FormLoad/DomContentLoaded/start.js +7 -0
- package/bin/v4/commands/init/template/v1/Index/FormLoad/start.js +5 -0
- package/bin/v4/commands/init/template/v1/Index/start.js +7 -0
- package/bin/v4/commands/init/template/v2/FormLoad/DomContentLoaded/buildHeader.js +68 -0
- package/bin/v4/commands/init/template/v2/FormLoad/DomContentLoaded/buildMenuItem.js +121 -0
- package/bin/v4/commands/init/template/v2/FormLoad/DomContentLoaded/runAfterDomLoad.js +7 -0
- package/bin/v4/commands/init/template/v2/FormLoad/DomContentLoaded/start.js +7 -0
- package/bin/v4/commands/init/template/v2/FormLoad/start.js +5 -0
- package/bin/v4/commands/init/template/v2/start.js +7 -0
- package/bin/v4/commands/init/template/v3/FormLoad/DomContentLoaded/buildHeader.js +58 -0
- package/bin/v4/commands/init/template/v3/FormLoad/DomContentLoaded/buildMenuItem.js +121 -0
- package/bin/v4/commands/init/template/v3/FormLoad/DomContentLoaded/runAfterDomLoad.js +7 -0
- package/bin/v4/commands/init/template/v3/FormLoad/DomContentLoaded/start.js +7 -0
- package/bin/v4/commands/init/template/v3/FormLoad/start.js +5 -0
- package/bin/v4/commands/init/template/v3/headers.json +45 -0
- package/bin/v4/commands/init/template/v3/start.js +7 -0
- package/bin/v4/commands/init.js +25 -0
- package/bin/v4/core/parseInput.js +9 -0
- package/bin/v4/core/resolveCommand.js +16 -0
- package/bin/v4/core/showUsage.js +49 -0
- package/bin/v4/start.js +24 -0
- package/package.json +1 -1
- package/bin/v2/commands/addListeners/template/v1/AddListeners/start.js +0 -14
- package/bin/v2/core/resolveCommand.js +0 -16
- /package/bin/{v2 → v3}/commands/addListeners/steps/announce.js +0 -0
- /package/bin/{v2 → v3}/commands/addListeners/steps/createProject.js +0 -0
- /package/bin/{v2 → v3}/commands/addListeners/steps/locateDestination.js +0 -0
- /package/bin/{v2 → v3}/commands/addListeners/steps/locateSource.js +0 -0
- /package/bin/{v2 → v3}/commands/addListeners/template/v2/start.js +0 -0
- /package/bin/{v2 → v3}/commands/addListeners.js +0 -0
- /package/bin/{v2 → v3}/commands/buildHeader/steps/announce.js +0 -0
- /package/bin/{v2 → v3}/commands/buildHeader/steps/createProject.js +0 -0
- /package/bin/{v2 → v3}/commands/buildHeader/steps/locateDestination.js +0 -0
- /package/bin/{v2 → v3}/commands/buildHeader/steps/locateSource.js +0 -0
- /package/bin/{v2 → v3}/commands/buildHeader/steps/resolveFolderName.js +0 -0
- /package/bin/{v2 → v3}/commands/buildHeader/template/v1/buildHeader.js +0 -0
- /package/bin/{v2 → v3}/commands/buildHeader.js +0 -0
- /package/bin/{v2 → v3}/commands/htmlIdClick/steps/announce.js +0 -0
- /package/bin/{v2 → v3}/commands/htmlIdClick/steps/createProject.js +0 -0
- /package/bin/{v2 → v3}/commands/htmlIdClick/steps/locateDestination.js +0 -0
- /package/bin/{v2 → v3}/commands/htmlIdClick/steps/locateSource.js +0 -0
- /package/bin/{v2 → v3}/commands/htmlIdClick/steps/resolveFolderName.js +0 -0
- /package/bin/{v2 → v3}/commands/htmlIdClick/template/v1/clickFunc.js +0 -0
- /package/bin/{v2 → v3}/commands/htmlIdClick/template/v1/start.js +0 -0
- /package/bin/{v2 → v3}/commands/htmlIdClick.js +0 -0
- /package/bin/{v2 → v3}/commands/init/steps/announce.js +0 -0
- /package/bin/{v2 → v3}/commands/init/steps/createProject.js +0 -0
- /package/bin/{v2 → v3}/commands/init/steps/locateDestination.js +0 -0
- /package/bin/{v2 → v3}/commands/init/steps/locateSource.js +0 -0
- /package/bin/{v2 → v3}/commands/init/steps/resolveFolderName.js +0 -0
- /package/bin/{v2 → v3}/commands/init/template/v1/Index/FormLoad/DomContentLoaded/buildHeader.js +0 -0
- /package/bin/{v2 → v3}/commands/init/template/v1/Index/FormLoad/DomContentLoaded/buildMenuItem.js +0 -0
- /package/bin/{v2 → v3}/commands/init/template/v1/Index/FormLoad/DomContentLoaded/runAfterDomLoad.js +0 -0
- /package/bin/{v2 → v3}/commands/init/template/v1/Index/FormLoad/DomContentLoaded/start.js +0 -0
- /package/bin/{v2 → v3}/commands/init/template/v1/Index/FormLoad/start.js +0 -0
- /package/bin/{v2 → v3}/commands/init/template/v1/Index/start.js +0 -0
- /package/bin/{v2 → v3}/commands/init/template/v2/FormLoad/DomContentLoaded/buildHeader.js +0 -0
- /package/bin/{v2 → v3}/commands/init/template/v2/FormLoad/DomContentLoaded/buildMenuItem.js +0 -0
- /package/bin/{v2 → v3}/commands/init/template/v2/FormLoad/DomContentLoaded/runAfterDomLoad.js +0 -0
- /package/bin/{v2 → v3}/commands/init/template/v2/FormLoad/DomContentLoaded/start.js +0 -0
- /package/bin/{v2 → v3}/commands/init/template/v2/FormLoad/start.js +0 -0
- /package/bin/{v2 → v3}/commands/init/template/v2/start.js +0 -0
- /package/bin/{v2 → v3}/commands/init/template/v3/FormLoad/DomContentLoaded/buildHeader.js +0 -0
- /package/bin/{v2 → v3}/commands/init/template/v3/FormLoad/DomContentLoaded/buildMenuItem.js +0 -0
- /package/bin/{v2 → v3}/commands/init/template/v3/FormLoad/DomContentLoaded/runAfterDomLoad.js +0 -0
- /package/bin/{v2 → v3}/commands/init/template/v3/FormLoad/DomContentLoaded/start.js +0 -0
- /package/bin/{v2 → v3}/commands/init/template/v3/FormLoad/start.js +0 -0
- /package/bin/{v2 → v3}/commands/init/template/v3/headers.json +0 -0
- /package/bin/{v2 → v3}/commands/init/template/v3/start.js +0 -0
- /package/bin/{v2 → v3}/core/parseInput.js +0 -0
- /package/bin/{v2 → v3}/core/showUsage.js +0 -0
package/bin/cli.js
CHANGED
|
@@ -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;
|
package/bin/{v2 → v3}/start.js
RENAMED
|
@@ -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,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,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,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,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,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,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,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,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 };
|