@keshavsoft/kschema-cli 1.2.2 → 1.3.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 (55) hide show
  1. package/CHANGELOG.md +16 -30
  2. package/README.md +21 -78
  3. package/bin/cli.js +7 -3
  4. package/bin/v2/commands/template/Data/LedgerNames.json +5 -5
  5. package/bin/v3/commands/init.js +30 -0
  6. package/bin/v3/commands/template/basic/.vscode/launch.json +12 -0
  7. package/bin/v3/commands/template/basic/Config/Schemas/BillsTable.json +165 -0
  8. package/bin/v3/commands/template/basic/Config/Schemas/ItemsTable.json +200 -0
  9. package/bin/v3/commands/template/basic/Config/Schemas/LedgerNames.json +50 -0
  10. package/bin/v3/commands/template/basic/Config/Schemas/StockItems.json +45 -0
  11. package/bin/v3/commands/template/basic/Config/api.json +8 -0
  12. package/bin/v3/commands/template/basic/Config/schema.json +8 -0
  13. package/bin/v3/commands/template/basic/Config/ui.json +8 -0
  14. package/bin/v3/commands/template/basic/Data/BillsTable.json +165 -0
  15. package/bin/v3/commands/template/basic/Data/ItemsTable.json +200 -0
  16. package/bin/v3/commands/template/basic/Data/LedgerNames.json +6 -0
  17. package/bin/v3/commands/template/basic/Data/StockItems.json +45 -0
  18. package/bin/v3/commands/template/basic/app.js +4 -0
  19. package/bin/v3/commands/template/basic/config.json +4 -0
  20. package/bin/v3/commands/template/basic/package-lock.json +21 -0
  21. package/bin/v3/commands/template/basic/package.json +13 -0
  22. package/bin/v3/commands/template/basic/read.js +8 -0
  23. package/bin/v3/commands/template/basic/write.js +8 -0
  24. package/bin/v3/commands/template/express/.env +8 -0
  25. package/bin/v3/commands/template/express/.env.local +7 -0
  26. package/bin/v3/commands/template/express/.vscode/launch.json +12 -0
  27. package/bin/v3/commands/template/express/Config/Schemas/BillsTable.json +166 -0
  28. package/bin/v3/commands/template/express/Config/Schemas/ItemsTable.json +206 -0
  29. package/bin/v3/commands/template/express/Config/Schemas/LedgerNames.json +50 -0
  30. package/bin/v3/commands/template/express/Config/Schemas/StockItems.json +45 -0
  31. package/bin/v3/commands/template/express/Config/api.json +8 -0
  32. package/bin/v3/commands/template/express/Config/schema.json +8 -0
  33. package/bin/v3/commands/template/express/Config/ui.json +8 -0
  34. package/bin/v3/commands/template/express/ForFrontEnd/NonSecured/Builder/build.js +6 -0
  35. package/bin/v3/commands/template/express/ForFrontEnd/NonSecured/Builder/config.js +12 -0
  36. package/bin/v3/commands/template/express/ForFrontEnd/NonSecured/Builder/main.js +29 -0
  37. package/bin/v3/commands/template/express/ForFrontEnd/NonSecured/Builder/publish.js +22 -0
  38. package/bin/v3/commands/template/express/ForFrontEnd/NonSecured/Builder/repo.js +20 -0
  39. package/bin/v3/commands/template/express/ForFrontEnd/NonSecured/Builder/schema.js +16 -0
  40. package/bin/v3/commands/template/express/ForFrontEnd/NonSecured/Builder/utils.js +26 -0
  41. package/bin/v3/commands/template/express/ForFrontEnd/NonSecured/Builder/version.js +25 -0
  42. package/bin/v3/commands/template/express/ForFrontEnd/NonSecured/buildAndCopy.js +166 -0
  43. package/bin/v3/commands/template/express/ForFrontEnd/NonSecured/latestVersion.js +38 -0
  44. package/bin/v3/commands/template/express/ForFrontEnd/Secured/buildProtected.js +108 -0
  45. package/bin/v3/commands/template/express/ForFrontEnd/Secured/latestVersion.js +38 -0
  46. package/bin/v3/commands/template/express/app.js +33 -0
  47. package/bin/v3/commands/template/express/config.json +4 -0
  48. package/bin/v3/commands/template/express/package.json +18 -0
  49. package/bin/v3/commands/test.js +36 -0
  50. package/bin/v3/start.js +27 -0
  51. package/package.json +2 -1
  52. package/template/v2/Data/LedgerNames.json +5 -5
  53. package/template/v2/package.json +14 -14
  54. package/bin/cliV1.js +0 -18
  55. package/keshavsoft-kschema-cli-1.2.2.tgz +0 -0
package/CHANGELOG.md CHANGED
@@ -1,39 +1,25 @@
1
- # CHANGELOG
1
+ # Changelog
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ The format is based on Keep a Changelog.
6
+
5
7
  ---
6
8
 
7
- ## [1.7.1] - 2026-04-18
9
+ ## [1.3.1] - 2026-04-21
8
10
 
9
11
  ### Added
10
-
11
- * Initial release of kschema
12
- * Config loader (`loadConfig`, `getConfig`)
13
- * File-based JSON storage
14
- * Schema-driven table handling
15
- * Primary key detection (`getPrimaryKey`)
16
- * Auto-increment primary key (`attachPrimaryKey`)
17
- * CRUD operations:
18
-
19
- * insert
20
- * insertStrict
21
- * get
22
- * findByPk
23
- * update
24
- * delete
12
+ - Initial release of `@keshavsoft/kschema-cli`
13
+ - CLI command: `kschema init <template> [projectName]`
14
+ - Template support:
15
+ - basic
16
+ - express
17
+ - Auto project generation using file copy
18
+ - Auto folder naming when projectName not provided:
19
+ - `kschema-<template>-<timestamp>`
20
+ - Modular command structure (`init`, `test`)
21
+ - Version-based CLI execution (`cliVersion` support)
25
22
 
26
23
  ### Notes
27
-
28
- * Primary key is dynamically resolved from schema
29
- * Data stored as JSON files
30
- * Minimal, dependency-free design
31
-
32
- ## [1.7.3] - 2026-04-19
33
-
34
- ### filer and find columns perfect
35
-
36
- ## [1.7.4]
37
-
38
- ### delete multi added
39
-
24
+ - Designed as a wrapper over kschema ecosystem
25
+ - Focused on simplicity and fast project setup
package/README.md CHANGED
@@ -1,95 +1,38 @@
1
- # KeshavSoft
1
+ # @keshavsoft/kschema-cli
2
2
 
3
- Simple tools. Clean architecture. Fast development.
4
-
5
- ---
6
-
7
- ## @keshavsoft/kschema
8
-
9
- A lightweight schema-driven JSON database for Node.js.
10
-
11
- ---
3
+ CLI to generate projects using templates.
12
4
 
13
5
  ## Install
14
6
 
15
- npm i @keshavsoft/kschema
16
-
17
- ---
18
-
19
- ## Usage
20
-
21
- import { kschema } from "@keshavsoft/kschema";
22
-
23
- kschema.loadConfig({ dataPath: "./data" });
24
-
25
- const users = kschema.table("users");
26
-
27
- users.insert({ name: "keshav" });
28
-
29
- const data = users.get();
30
-
31
- console.log(data);
32
-
33
- ---
7
+ npm install -g @keshavsoft/kschema-cli
34
8
 
35
- ## API
9
+ or
36
10
 
37
- Create
11
+ npx @keshavsoft/kschema-cli init express MyApp
38
12
 
39
- users.insert(record);
40
- users.insertStrict(record);
41
-
42
- Read
43
-
44
- users.get();
45
- users.findByPk(id);
46
-
47
- Filter
48
-
49
- users.filterByPk(id);
50
- users.filterByColumns({ name: "keshav" });
51
-
52
- Update
53
-
54
- users.update(record);
55
-
56
- Delete
57
-
58
- users.delete(id);
59
- users.deleteByColumns({ name: "keshav" });
60
-
61
- ---
62
-
63
- ## Features
64
-
65
- * File-based JSON storage
66
- * Schema-driven design
67
- * Auto primary key
68
- * Simple CRUD API
69
- * Zero dependencies
70
-
71
- ---
72
-
73
- ## Links
13
+ ## Usage
74
14
 
75
- GitHub: https://github.com/keshavsoft/kschema
76
- NPM: https://www.npmjs.com/package/@keshavsoft/kschema
77
- Website: https://keshavsoft.com
15
+ kschema init <template> [projectName]
78
16
 
79
- ---
17
+ ## Examples
80
18
 
81
- ## Contact
19
+ kschema init basic MyApp
20
+ kschema init express MyServer
21
+ kschema init express
82
22
 
83
- Email: founder@keshavsoft.com
23
+ ## Templates
84
24
 
85
- ---
25
+ basic
26
+ express
86
27
 
87
- ## About
28
+ ## Behavior
88
29
 
89
- KeshavSoft builds simple and practical developer tools focused on clarity, speed, and real-world usage.
30
+ - If projectName is provided folder created with that name
31
+ - If not provided → auto name generated
90
32
 
91
- ---
33
+ Example auto name:
34
+ kschema-express-<timestamp>
92
35
 
93
- ## License
36
+ ## Output
94
37
 
95
- MIT License see LICENSE file
38
+ Creates a new folder with selected template files.
package/bin/cli.js CHANGED
@@ -1,17 +1,21 @@
1
1
  #!/usr/bin/env node
2
- console.log("baaaaaaaaaaaa : ");
3
2
 
4
3
  import packageJson from "../package.json" with { type: "json" };
5
4
 
6
5
  import { v2Func } from "./v2/start.js";
7
- console.log("bbbbbbbbbbbbbbb : ", packageJson);
6
+ import { v3Func } from "./v3/start.js";
8
7
 
9
- switch (packageJson?.version.split(".")[1]) {
8
+ switch (packageJson?.cliVersion) {
10
9
  case "2":
11
10
  v2Func();
12
11
 
12
+ break;
13
+ case "3":
14
+ v3Func();
15
+
13
16
  break;
14
17
 
15
18
  default:
19
+ console.log(`Unsupported CLI version: ${packageJson?.cliVersion}`);
16
20
  console.log("Usage: kschema <init|test> [name]");
17
21
  };
@@ -1,6 +1,6 @@
1
- [
2
- {
3
- "LedgerName": "Keshav",
4
- "pk": 1
5
- }
1
+ [
2
+ {
3
+ "LedgerName": "Keshav",
4
+ "pk": 1
5
+ }
6
6
  ]
@@ -0,0 +1,30 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import { fileURLToPath } from "url";
4
+
5
+ const __filename = fileURLToPath(import.meta.url);
6
+ const __dirname = path.dirname(__filename);
7
+
8
+ const defaultFolderName = "KehavSoft";
9
+
10
+ export default ({ inTemplate, inFolderName }) => {
11
+ const folderName = inFolderName || `kschema-${inTemplate}-${Date.now()}`;
12
+ let source;
13
+
14
+ switch (inTemplate) {
15
+ case "express":
16
+ source = path.join(__dirname, "template", "express");
17
+ break;
18
+
19
+ default:
20
+ source = path.join(__dirname, "template", "basic");
21
+ break;
22
+ };
23
+
24
+ const destination = path.join(process.cwd(), folderName);
25
+
26
+ fs.mkdirSync(destination, { recursive: true });
27
+ fs.cpSync(source, destination, { recursive: true });
28
+
29
+ console.log(`Project created in ${folderName}`);
30
+ };
@@ -0,0 +1,12 @@
1
+ {
2
+ "version": "0.2.0",
3
+ "configurations": [
4
+ {
5
+ "type": "node",
6
+ "request": "launch",
7
+ "name": "Debug App",
8
+ "program": "${workspaceFolder}/app.js",
9
+ "envFile": "${workspaceFolder}/.env"
10
+ }
11
+ ]
12
+ }
@@ -0,0 +1,165 @@
1
+ {
2
+ "tableName": "BillsTable",
3
+ "columns": [
4
+ {
5
+ "field": "LedgerName",
6
+ "title": "LedgerName",
7
+ "type": "text",
8
+ "isInput": false,
9
+ "isAutoFocus": true,
10
+ "WidthOptions": {
11
+ "inPx": 200
12
+ },
13
+ "defaultvalue": "Keshav",
14
+ "isDataList": true,
15
+ "dataListId": "LedgerNames",
16
+ "isConsider": true
17
+ },
18
+ {
19
+ "field": "LedgerParentName",
20
+ "title": "LedgerParentName",
21
+ "type": "text",
22
+ "isInput": true,
23
+ "WidthOptions": {
24
+ "inPx": 200
25
+ },
26
+ "isConsider": true,
27
+ "showInUi": false
28
+ },
29
+ {
30
+ "field": "LedgerGST",
31
+ "title": "LedgerGST",
32
+ "type": "text",
33
+ "isInput": true,
34
+ "isAutoFocus": true,
35
+ "WidthOptions": {
36
+ "inPx": 200
37
+ },
38
+ "isConsider": true,
39
+ "showInUi": false
40
+ },
41
+ {
42
+ "field": "InvoiceNo",
43
+ "title": "InvoiceNo",
44
+ "type": "number",
45
+ "isInput": true,
46
+ "WidthOptions": {
47
+ "inPx": 200
48
+ },
49
+ "isConsider": true
50
+ },
51
+ {
52
+ "field": "InvoiceDate",
53
+ "title": "InvoiceDate",
54
+ "isDate": true,
55
+ "type": "date",
56
+ "WidthOptions": {
57
+ "inPx": 200
58
+ },
59
+ "defaultvalue": "today",
60
+ "isConsider": true
61
+ },
62
+ {
63
+ "field": "InvoiceStateCode",
64
+ "title": "InvoiceStateCode",
65
+ "defaultvalue": "37",
66
+ "isInput": true,
67
+ "WidthOptions": {
68
+ "inPx": 200
69
+ },
70
+ "isConsider": true,
71
+ "showInUi": false
72
+ },
73
+ {
74
+ "field": "pk",
75
+ "title": "pk",
76
+ "primary": true
77
+ }
78
+ ],
79
+ "data": [],
80
+ "Vertical": [
81
+ {
82
+ "field": "LedgerName",
83
+ "title": "LedgerName",
84
+ "type": "text",
85
+ "isInput": false,
86
+ "isAutoFocus": true,
87
+ "WidthOptions": {
88
+ "inPx": 200
89
+ },
90
+ "defaultvalue": "Keshav",
91
+ "isDataList": true,
92
+ "dataListId": "LedgerNames"
93
+ },
94
+ {
95
+ "field": "LedgerParentName",
96
+ "title": "LedgerParentName",
97
+ "type": "text",
98
+ "isInput": true,
99
+ "WidthOptions": {
100
+ "inPx": 200
101
+ }
102
+ },
103
+ {
104
+ "field": "LedgerGST",
105
+ "title": "LedgerGST",
106
+ "type": "text",
107
+ "isInput": true,
108
+ "isAutoFocus": true,
109
+ "WidthOptions": {
110
+ "inPx": 200
111
+ }
112
+ },
113
+ {
114
+ "field": "InvoiceNo",
115
+ "title": "InvoiceNo",
116
+ "type": "number",
117
+ "isInput": true,
118
+ "WidthOptions": {
119
+ "inPx": 200
120
+ }
121
+ },
122
+ {
123
+ "field": "InvoiceDate",
124
+ "title": "InvoiceDate",
125
+ "isDate": true,
126
+ "type": "date",
127
+ "WidthOptions": {
128
+ "inPx": 200
129
+ },
130
+ "defaultvalue": "today"
131
+ },
132
+ {
133
+ "field": "InvoiceStateCode",
134
+ "title": "InvoiceStateCode",
135
+ "defaultvalue": "37",
136
+ "isInput": true,
137
+ "WidthOptions": {
138
+ "inPx": 200
139
+ }
140
+ }
141
+ ],
142
+ "DataTableOptions": {
143
+ "Header": {
144
+ "autoFocus": "LedgerName"
145
+ }
146
+ },
147
+ "ForeignkeyTables": [
148
+ "ItemsTable"
149
+ ],
150
+ "DependantTables": [
151
+ "LedgerNames"
152
+ ],
153
+ "NonSecured": {
154
+ "SubRoutes": [
155
+ "ShowAll",
156
+ "Insert",
157
+ "Find",
158
+ "InsertAndReturnPk",
159
+ "FindWithForeignData",
160
+ "InsertToTally"
161
+ ]
162
+ },
163
+ "PrimarykeyTableNames": [],
164
+ "PrimarykeyTables": []
165
+ }
@@ -0,0 +1,200 @@
1
+ {
2
+ "tableName": "ItemsTable",
3
+ "columns": [
4
+ {
5
+ "field": "StockItemName",
6
+ "title": "StockItemName",
7
+ "unique": false,
8
+ "type": "text",
9
+ "isInput": false,
10
+ "isAutoFocus": true,
11
+ "WidthOptions": {
12
+ "inPx": 300
13
+ },
14
+ "isDataList": true,
15
+ "dataListId": "StockItems",
16
+ "isConsider": true,
17
+ "showInUi": true
18
+ },
19
+ {
20
+ "field": "Rate",
21
+ "title": "Rate",
22
+ "unique": false,
23
+ "type": "number",
24
+ "isNumber": true,
25
+ "ShowTotal": false,
26
+ "footerFormatter": "",
27
+ "showRupee": true,
28
+ "align": "right",
29
+ "WidthOptions": {
30
+ "inPx": 250
31
+ },
32
+ "isConsider": true,
33
+ "showInUi": true
34
+ },
35
+ {
36
+ "field": "Qty",
37
+ "title": "Qty",
38
+ "unique": false,
39
+ "type": "number",
40
+ "isNumber": true,
41
+ "ShowTotal": true,
42
+ "footerFormatter": "TotalFormatter",
43
+ "showRupee": false,
44
+ "WidthOptions": {
45
+ "inPx": 200
46
+ },
47
+ "isConsider": true,
48
+ "showInUi": true
49
+ },
50
+ {
51
+ "field": "Amount",
52
+ "title": "Amount",
53
+ "unique": false,
54
+ "type": "number",
55
+ "isNumber": true,
56
+ "ShowTotal": true,
57
+ "footerFormatter": "TotalFormatter",
58
+ "enterCal": "Rate*Qty",
59
+ "showRupee": true,
60
+ "align": "right",
61
+ "WidthOptions": {
62
+ "inPx": 250
63
+ },
64
+ "isConsider": true,
65
+ "showInUi": false
66
+ },
67
+ {
68
+ "field": "TaxPer",
69
+ "title": "TaxPer",
70
+ "unique": false,
71
+ "type": "number",
72
+ "isNumber": true,
73
+ "defaultvalue": 18,
74
+ "isConsider": true,
75
+ "showInUi": true
76
+ },
77
+ {
78
+ "field": "Uom",
79
+ "title": "Uom",
80
+ "unique": false,
81
+ "type": "number",
82
+ "isNumber": true,
83
+ "defaultvalue": 18,
84
+ "isConsider": true,
85
+ "showInUi": true
86
+ },
87
+ {
88
+ "field": "ParentPk",
89
+ "title": "ParentPk",
90
+ "unique": false,
91
+ "isConsider": true,
92
+ "showInUi": true
93
+ },
94
+ {
95
+ "field": "pk",
96
+ "title": "pk",
97
+ "primary": true
98
+ }
99
+ ],
100
+ "data": [],
101
+ "Vertical": [
102
+ {
103
+ "field": "StockItemName",
104
+ "title": "StockItemName",
105
+ "unique": false,
106
+ "type": "text",
107
+ "isInput": false,
108
+ "isAutoFocus": true,
109
+ "WidthOptions": {
110
+ "inPx": 300
111
+ },
112
+ "isDataList": true,
113
+ "dataListId": "StockItems"
114
+ },
115
+ {
116
+ "field": "Rate",
117
+ "title": "Rate",
118
+ "unique": false,
119
+ "type": "number",
120
+ "isNumber": true,
121
+ "ShowTotal": false,
122
+ "footerFormatter": "",
123
+ "showRupee": true,
124
+ "align": "right",
125
+ "WidthOptions": {
126
+ "inPx": 250
127
+ }
128
+ },
129
+ {
130
+ "field": "Qty",
131
+ "title": "Qty",
132
+ "unique": false,
133
+ "type": "number",
134
+ "isNumber": true,
135
+ "ShowTotal": true,
136
+ "footerFormatter": "TotalFormatter",
137
+ "showRupee": false,
138
+ "WidthOptions": {
139
+ "inPx": 200
140
+ }
141
+ },
142
+ {
143
+ "field": "Amount",
144
+ "title": "Amount",
145
+ "unique": false,
146
+ "type": "number",
147
+ "isNumber": true,
148
+ "ShowTotal": true,
149
+ "footerFormatter": "TotalFormatter",
150
+ "showRupee": true,
151
+ "align": "right",
152
+ "WidthOptions": {
153
+ "inPx": 250
154
+ }
155
+ },
156
+ {
157
+ "field": "TaxPer",
158
+ "title": "TaxPer",
159
+ "unique": false,
160
+ "type": "number",
161
+ "isNumber": true,
162
+ "defaultvalue": 18,
163
+ "isConsider": true,
164
+ "showInUi": true
165
+ },
166
+ {
167
+ "field": "Uom",
168
+ "title": "Uom",
169
+ "unique": false,
170
+ "type": "number",
171
+ "isNumber": true,
172
+ "defaultvalue": 18,
173
+ "isConsider": true,
174
+ "showInUi": true
175
+ }
176
+ ],
177
+ "DataTableOptions": {
178
+ "Header": {
179
+ "autoFocus": "StockItemName"
180
+ }
181
+ },
182
+ "NonSecured": {
183
+ "SubRoutes": [
184
+ "ShowAll",
185
+ "Insert",
186
+ "InsertAndReturnPk",
187
+ "InsertWithDefaults"
188
+ ]
189
+ },
190
+ "DependantTables": [
191
+ "StockItems"
192
+ ],
193
+ "ForeignkeyTables": [
194
+ "BillsTable"
195
+ ],
196
+ "PrimarykeyTableNames": [
197
+ "BillsTable"
198
+ ],
199
+ "PrimarykeyTables": []
200
+ }
@@ -0,0 +1,50 @@
1
+ {
2
+ "tableName": "LedgerNames",
3
+ "columns": [
4
+ {
5
+ "field": "LedgerName",
6
+ "title": "LedgerName",
7
+ "unique": true,
8
+ "type": "text",
9
+ "isInput": true,
10
+ "isAutoFocus": true,
11
+ "defaultvalue": "KeshavSoft",
12
+ "isConsider": true
13
+ },
14
+ {
15
+ "field": "LedgerParentName",
16
+ "title": "LedgerParentName",
17
+ "type": "text",
18
+ "isInput": true,
19
+ "isConsider": true
20
+ },
21
+ {
22
+ "field": "LedgerType",
23
+ "title": "LedgerType",
24
+ "type": "text",
25
+ "isInput": true,
26
+ "isConsider": true
27
+ },
28
+ {
29
+ "field": "pk",
30
+ "title": "pk",
31
+ "primary": true
32
+ }
33
+ ],
34
+ "data": [],
35
+ "Vertical": [],
36
+ "DataTableOptions": {
37
+ "Header": {
38
+ "autoFocus": "LedgerName"
39
+ }
40
+ },
41
+ "NonSecured": {
42
+ "SubRoutes": [
43
+ "ShowAll",
44
+ "Insert",
45
+ "Pipe"
46
+ ]
47
+ },
48
+ "PrimarykeyTableNames": [],
49
+ "PrimarykeyTables": []
50
+ }