json-crud-ui-components 1.3.1 → 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/v4/commands/addListeners/steps/checks.js +25 -0
- package/bin/{v2 → v4}/commands/addListeners/steps/resolveFolderName.js +1 -1
- package/bin/{v2 → v4}/commands/addListeners.js +5 -0
- package/bin/v4/commands/htmlIdClick/steps/checks.js +25 -0
- package/bin/{v2 → v4}/commands/htmlIdClick/steps/resolveFolderName.js +2 -5
- package/bin/{v2 → v4}/commands/htmlIdClick.js +13 -1
- package/bin/v4/commands/init/steps/checks.js +23 -0
- package/bin/{v2 → v4}/commands/init.js +5 -2
- package/bin/v4/core/resolveCommand.js +16 -0
- package/bin/v4/core/showUsage.js +49 -0
- package/bin/{v2 → v4}/start.js +0 -1
- 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/core/showUsage.js +0 -39
- /package/bin/{v2 → v4}/commands/addListeners/steps/announce.js +0 -0
- /package/bin/{v2 → v4}/commands/addListeners/steps/createProject.js +0 -0
- /package/bin/{v2 → v4}/commands/addListeners/steps/locateDestination.js +0 -0
- /package/bin/{v2 → v4}/commands/addListeners/steps/locateSource.js +0 -0
- /package/bin/{v2 → v4}/commands/addListeners/template/v2/start.js +0 -0
- /package/bin/{v2 → v4}/commands/buildHeader/steps/announce.js +0 -0
- /package/bin/{v2 → v4}/commands/buildHeader/steps/createProject.js +0 -0
- /package/bin/{v2 → v4}/commands/buildHeader/steps/locateDestination.js +0 -0
- /package/bin/{v2 → v4}/commands/buildHeader/steps/locateSource.js +0 -0
- /package/bin/{v2 → v4}/commands/buildHeader/steps/resolveFolderName.js +0 -0
- /package/bin/{v2 → v4}/commands/buildHeader/template/v1/buildHeader.js +0 -0
- /package/bin/{v2 → v4}/commands/buildHeader.js +0 -0
- /package/bin/{v2 → v4}/commands/htmlIdClick/steps/announce.js +0 -0
- /package/bin/{v2 → v4}/commands/htmlIdClick/steps/createProject.js +0 -0
- /package/bin/{v2 → v4}/commands/htmlIdClick/steps/locateDestination.js +0 -0
- /package/bin/{v2 → v4}/commands/htmlIdClick/steps/locateSource.js +0 -0
- /package/bin/{v2 → v4}/commands/htmlIdClick/template/v1/clickFunc.js +0 -0
- /package/bin/{v2 → v4}/commands/htmlIdClick/template/v1/start.js +0 -0
- /package/bin/{v2 → v4}/commands/init/steps/announce.js +0 -0
- /package/bin/{v2 → v4}/commands/init/steps/createProject.js +0 -0
- /package/bin/{v2 → v4}/commands/init/steps/locateDestination.js +0 -0
- /package/bin/{v2 → v4}/commands/init/steps/locateSource.js +0 -0
- /package/bin/{v2 → v4}/commands/init/steps/resolveFolderName.js +0 -0
- /package/bin/{v2 → v4}/commands/init/template/v1/Index/FormLoad/DomContentLoaded/buildHeader.js +0 -0
- /package/bin/{v2 → v4}/commands/init/template/v1/Index/FormLoad/DomContentLoaded/buildMenuItem.js +0 -0
- /package/bin/{v2 → v4}/commands/init/template/v1/Index/FormLoad/DomContentLoaded/runAfterDomLoad.js +0 -0
- /package/bin/{v2 → v4}/commands/init/template/v1/Index/FormLoad/DomContentLoaded/start.js +0 -0
- /package/bin/{v2 → v4}/commands/init/template/v1/Index/FormLoad/start.js +0 -0
- /package/bin/{v2 → v4}/commands/init/template/v1/Index/start.js +0 -0
- /package/bin/{v2 → v4}/commands/init/template/v2/FormLoad/DomContentLoaded/buildHeader.js +0 -0
- /package/bin/{v2 → v4}/commands/init/template/v2/FormLoad/DomContentLoaded/buildMenuItem.js +0 -0
- /package/bin/{v2 → v4}/commands/init/template/v2/FormLoad/DomContentLoaded/runAfterDomLoad.js +0 -0
- /package/bin/{v2 → v4}/commands/init/template/v2/FormLoad/DomContentLoaded/start.js +0 -0
- /package/bin/{v2 → v4}/commands/init/template/v2/FormLoad/start.js +0 -0
- /package/bin/{v2 → v4}/commands/init/template/v2/start.js +0 -0
- /package/bin/{v2 → v4}/commands/init/template/v3/FormLoad/DomContentLoaded/buildHeader.js +0 -0
- /package/bin/{v2 → v4}/commands/init/template/v3/FormLoad/DomContentLoaded/buildMenuItem.js +0 -0
- /package/bin/{v2 → v4}/commands/init/template/v3/FormLoad/DomContentLoaded/runAfterDomLoad.js +0 -0
- /package/bin/{v2 → v4}/commands/init/template/v3/FormLoad/DomContentLoaded/start.js +0 -0
- /package/bin/{v2 → v4}/commands/init/template/v3/FormLoad/start.js +0 -0
- /package/bin/{v2 → v4}/commands/init/template/v3/headers.json +0 -0
- /package/bin/{v2 → v4}/commands/init/template/v3/start.js +0 -0
- /package/bin/{v2 → v4}/core/parseInput.js +0 -0
|
@@ -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;
|
|
@@ -5,8 +5,13 @@ import { createProject } from "./addListeners/steps/createProject.js";
|
|
|
5
5
|
import { announce } from "./addListeners/steps/announce.js";
|
|
6
6
|
|
|
7
7
|
import resolveFolderName from "./addListeners/steps/resolveFolderName.js";
|
|
8
|
+
import checks from "./addListeners/steps/checks.js";
|
|
8
9
|
|
|
9
10
|
export default ({ folderName = "", toPath = process.cwd(), inAnnounce = true }) => {
|
|
11
|
+
const fromChecks = checks({ toPath, inAnnounce });
|
|
12
|
+
|
|
13
|
+
if (fromChecks) return false;
|
|
14
|
+
|
|
10
15
|
const resolvedFolderName = resolveFolderName({
|
|
11
16
|
name: folderName
|
|
12
17
|
});
|
|
@@ -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;
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
2
|
|
|
3
|
-
export default function resolveFolderName({ name,
|
|
4
|
-
const defaultFolerName = "AddListeners";
|
|
5
|
-
|
|
6
|
-
// case 1: force new → timestamp
|
|
3
|
+
export default function resolveFolderName({ name, inDefaultFolderName = "<htmlId>" }) {
|
|
7
4
|
if (name === null) {
|
|
8
|
-
name =
|
|
5
|
+
name = inDefaultFolderName;
|
|
9
6
|
};
|
|
10
7
|
|
|
11
8
|
// case 2: user provided → strict
|
|
@@ -5,10 +5,22 @@ import { createProject } from "./htmlIdClick/steps/createProject.js";
|
|
|
5
5
|
import { announce } from "./htmlIdClick/steps/announce.js";
|
|
6
6
|
|
|
7
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";
|
|
8
12
|
|
|
9
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
|
+
|
|
10
22
|
const resolvedFolderName = resolveFolderName({
|
|
11
|
-
name: folderName
|
|
23
|
+
name: folderName, inDefaultFolderName: defaultFolderName
|
|
12
24
|
});
|
|
13
25
|
|
|
14
26
|
const source = locateSource();
|
|
@@ -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;
|
|
@@ -5,8 +5,13 @@ import { createProject } from "./init/steps/createProject.js";
|
|
|
5
5
|
import { announce } from "./init/steps/announce.js";
|
|
6
6
|
|
|
7
7
|
import resolveFolderName from "./init/steps/resolveFolderName.js";
|
|
8
|
+
import checks from "./init/steps/checks.js";
|
|
8
9
|
|
|
9
10
|
export default ({ folderName = "", toPath = process.cwd(), inAnnounce = true }) => {
|
|
11
|
+
const fromChecks = checks({ toPath, inAnnounce });
|
|
12
|
+
|
|
13
|
+
if (fromChecks) return false;
|
|
14
|
+
|
|
10
15
|
const resolvedFolderName = resolveFolderName({
|
|
11
16
|
name: folderName
|
|
12
17
|
});
|
|
@@ -17,6 +22,4 @@ export default ({ folderName = "", toPath = process.cwd(), inAnnounce = true })
|
|
|
17
22
|
createProject({ source, destination });
|
|
18
23
|
|
|
19
24
|
if (inAnnounce) announce({ inResolvedFolderName: resolvedFolderName });
|
|
20
|
-
|
|
21
|
-
console.log("aaaaaaaaa ", folderName, toPath, resolvedFolderName);
|
|
22
25
|
};
|
|
@@ -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
|
+
}
|
package/bin/{v2 → v4}/start.js
RENAMED
package/package.json
CHANGED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { funcToRun as funcToRunForLedgersHtmlId } from "./LedgersHtmlId/start.js";
|
|
2
|
-
import { funcToRun as funcToRunForStockItemsHtmlId } from "./StockItemsHtmlId/start.js";
|
|
3
|
-
|
|
4
|
-
import { funcToRun as funcToRunForImportHtmlId } from "./ImportHtmlId/start.js";
|
|
5
|
-
|
|
6
|
-
const hookAllListeners = () => {
|
|
7
|
-
funcToRunForLedgersHtmlId();
|
|
8
|
-
funcToRunForStockItemsHtmlId();
|
|
9
|
-
|
|
10
|
-
funcToRunForImportHtmlId();
|
|
11
|
-
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export { hookAllListeners };
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import init from "../commands/init.js";
|
|
2
|
-
import addListeners from "../commands/addListeners.js";
|
|
3
|
-
import htmlIdClick from "../commands/htmlIdClick.js";
|
|
4
|
-
import buildHeader from "../commands/buildHeader.js";
|
|
5
|
-
|
|
6
|
-
// resolveCommand.js
|
|
7
|
-
const map = {
|
|
8
|
-
init,
|
|
9
|
-
addListeners,
|
|
10
|
-
htmlIdClick,
|
|
11
|
-
buildHeader
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export default function resolveCommand(cmd) {
|
|
15
|
-
return map[cmd] || null;
|
|
16
|
-
};
|
package/bin/v2/core/showUsage.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
KSchema CLI – Entry Flow
|
|
3
|
-
|
|
4
|
-
1. Read user input from terminal (parseInput)
|
|
5
|
-
2. If no command → show usage (first-time user safety)
|
|
6
|
-
3. If help flags → show usage (quick guidance)
|
|
7
|
-
4. Resolve command dynamically (no hardcoding logic)
|
|
8
|
-
5. If command not found → inform + guide back to usage
|
|
9
|
-
6. Execute command with parsed input
|
|
10
|
-
|
|
11
|
-
Goal:
|
|
12
|
-
- Zero confusion for user
|
|
13
|
-
- Single source of truth (showUsage)
|
|
14
|
-
- Easy to extend (just add commands, no core changes)
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
export default function showUsage(version) {
|
|
18
|
-
const g = "\x1b[32m";
|
|
19
|
-
const y = "\x1b[33m";
|
|
20
|
-
const c = "\x1b[36m";
|
|
21
|
-
const gray = "\x1b[90m";
|
|
22
|
-
const r = "\x1b[0m";
|
|
23
|
-
|
|
24
|
-
console.log(`
|
|
25
|
-
${c}🚀 json-crud-ui v${version}${r}
|
|
26
|
-
|
|
27
|
-
${y}Usage:${r}
|
|
28
|
-
${g}npx @keshavsoft/kschema-api-gen${r} <command> [options]
|
|
29
|
-
|
|
30
|
-
${y}Commands:${r}
|
|
31
|
-
${g}endPointsJs${r} Checks for end-points.js file in that location
|
|
32
|
-
|
|
33
|
-
${y}Examples:${r}
|
|
34
|
-
${gray}npx @keshavsoft/kschema-api-gen endPointsJs ShowAll${r}
|
|
35
|
-
|
|
36
|
-
${y}Tip:${r}
|
|
37
|
-
${gray}npm i -g @keshavsoft/kschema-api-gen${r}
|
|
38
|
-
`);
|
|
39
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/bin/{v2 → v4}/commands/init/template/v1/Index/FormLoad/DomContentLoaded/buildHeader.js
RENAMED
|
File without changes
|
/package/bin/{v2 → v4}/commands/init/template/v1/Index/FormLoad/DomContentLoaded/buildMenuItem.js
RENAMED
|
File without changes
|
/package/bin/{v2 → v4}/commands/init/template/v1/Index/FormLoad/DomContentLoaded/runAfterDomLoad.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/bin/{v2 → v4}/commands/init/template/v2/FormLoad/DomContentLoaded/runAfterDomLoad.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/bin/{v2 → v4}/commands/init/template/v3/FormLoad/DomContentLoaded/runAfterDomLoad.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|