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
|
@@ -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/v4/start.js
ADDED
|
@@ -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;
|
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
|
-
};
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/bin/{v2 → v3}/commands/init/template/v1/Index/FormLoad/DomContentLoaded/buildHeader.js
RENAMED
|
File without changes
|
/package/bin/{v2 → v3}/commands/init/template/v1/Index/FormLoad/DomContentLoaded/buildMenuItem.js
RENAMED
|
File without changes
|
/package/bin/{v2 → v3}/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 → v3}/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 → v3}/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
|
|
File without changes
|