kschema-api-gen-appjs 1.3.2
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/LICENSE +21 -0
- package/README.md +38 -0
- package/bin/cli.js +12 -0
- package/bin/core/getLatestVersion.js +13 -0
- package/bin/core/loadRunner.js +9 -0
- package/bin/v2/AddSubRoute/Helpers/steps/UpdateRoutesJs/common/readFile.js +8 -0
- package/bin/v2/AddSubRoute/Helpers/steps/UpdateRoutesJs/common/writeFile.js +10 -0
- package/bin/v2/AddSubRoute/Helpers/steps/UpdateRoutesJs/updateImports/buildImport.js +9 -0
- package/bin/v2/AddSubRoute/Helpers/steps/UpdateRoutesJs/updateImports/checkDuplicate.js +8 -0
- package/bin/v2/AddSubRoute/Helpers/steps/UpdateRoutesJs/updateImports/findInsertIndex.js +10 -0
- package/bin/v2/AddSubRoute/Helpers/steps/UpdateRoutesJs/updateImports/index.js +41 -0
- package/bin/v2/AddSubRoute/Helpers/steps/UpdateRoutesJs/updateUse/buildUseLine.js +11 -0
- package/bin/v2/AddSubRoute/Helpers/steps/UpdateRoutesJs/updateUse/checkDuplicate.js +8 -0
- package/bin/v2/AddSubRoute/Helpers/steps/UpdateRoutesJs/updateUse/findInsertIndex.js +10 -0
- package/bin/v2/AddSubRoute/Helpers/steps/UpdateRoutesJs/updateUse/index.js +42 -0
- package/bin/v2/AddSubRoute/Helpers/steps/announce.js +9 -0
- package/bin/v2/AddSubRoute/Helpers/steps/createFolder.js +7 -0
- package/bin/v2/AddSubRoute/Helpers/steps/decideTemplate.js +3 -0
- package/bin/v2/AddSubRoute/Helpers/steps/locateDestination.js +5 -0
- package/bin/v2/AddSubRoute/Helpers/steps/locateSource.js +13 -0
- package/bin/v2/AddSubRoute/Helpers/steps/resolveFolderName.js +20 -0
- package/bin/v2/AddSubRoute/Helpers/steps/updateAppJs.js +7 -0
- package/bin/v2/AddSubRoute/Helpers/template/routes.js +5 -0
- package/bin/v2/AddSubRoute/index.js +42 -0
- package/bin/v2/StartEndPoint/Helpers/steps/UpdateAppJs/common/readFile.js +8 -0
- package/bin/v2/StartEndPoint/Helpers/steps/UpdateAppJs/common/writeFile.js +10 -0
- package/bin/v2/StartEndPoint/Helpers/steps/UpdateAppJs/index.js +11 -0
- package/bin/v2/StartEndPoint/Helpers/steps/UpdateAppJs/updateImports/buildImport.js +9 -0
- package/bin/v2/StartEndPoint/Helpers/steps/UpdateAppJs/updateImports/checkDuplicate.js +8 -0
- package/bin/v2/StartEndPoint/Helpers/steps/UpdateAppJs/updateImports/findInsertIndex.js +10 -0
- package/bin/v2/StartEndPoint/Helpers/steps/UpdateAppJs/updateImports/index.js +41 -0
- package/bin/v2/StartEndPoint/Helpers/steps/UpdateAppJs/updateUse/buildUseLine.js +9 -0
- package/bin/v2/StartEndPoint/Helpers/steps/UpdateAppJs/updateUse/checkDuplicate.js +8 -0
- package/bin/v2/StartEndPoint/Helpers/steps/UpdateAppJs/updateUse/findInsertIndex.js +10 -0
- package/bin/v2/StartEndPoint/Helpers/steps/UpdateAppJs/updateUse/index.js +42 -0
- package/bin/v2/StartEndPoint/Helpers/steps/announce.js +9 -0
- package/bin/v2/StartEndPoint/Helpers/steps/decideTemplate.js +3 -0
- package/bin/v2/StartEndPoint/Helpers/steps/locateDestination.js +7 -0
- package/bin/v2/StartEndPoint/Helpers/steps/locateSource.js +13 -0
- package/bin/v2/StartEndPoint/Helpers/steps/resolveFolderName.js +20 -0
- package/bin/v2/StartEndPoint/Helpers/template/routes.js +5 -0
- package/bin/v2/StartEndPoint/index.js +46 -0
- package/bin/v2/Tables/AddTableName/steps/UpdateRoutesJs/common/readFile.js +8 -0
- package/bin/v2/Tables/AddTableName/steps/UpdateRoutesJs/common/writeFile.js +10 -0
- package/bin/v2/Tables/AddTableName/steps/UpdateRoutesJs/index.js +9 -0
- package/bin/v2/Tables/AddTableName/steps/UpdateRoutesJs/updateImports/buildImport.js +9 -0
- package/bin/v2/Tables/AddTableName/steps/UpdateRoutesJs/updateImports/checkDuplicate.js +8 -0
- package/bin/v2/Tables/AddTableName/steps/UpdateRoutesJs/updateImports/findInsertIndex.js +10 -0
- package/bin/v2/Tables/AddTableName/steps/UpdateRoutesJs/updateImports/index.js +41 -0
- package/bin/v2/Tables/AddTableName/steps/UpdateRoutesJs/updateUse/buildUseLine.js +11 -0
- package/bin/v2/Tables/AddTableName/steps/UpdateRoutesJs/updateUse/checkDuplicate.js +8 -0
- package/bin/v2/Tables/AddTableName/steps/UpdateRoutesJs/updateUse/findInsertIndex.js +10 -0
- package/bin/v2/Tables/AddTableName/steps/UpdateRoutesJs/updateUse/index.js +42 -0
- package/bin/v2/Tables/AddTableName/steps/announce.js +9 -0
- package/bin/v2/Tables/AddTableName/steps/createFolder.js +7 -0
- package/bin/v2/Tables/AddTableName/steps/decideTemplate.js +3 -0
- package/bin/v2/Tables/AddTableName/steps/locateDestination.js +6 -0
- package/bin/v2/Tables/AddTableName/steps/locateSource.js +13 -0
- package/bin/v2/Tables/AddTableName/steps/resolveFolderName.js +20 -0
- package/bin/v2/Tables/AddTableName/steps/updateConfig.js +16 -0
- package/bin/v2/Tables/AddTableName/steps/updateEndPointsFile.js +30 -0
- package/bin/v2/Tables/AddTableName/steps/updateTableName.js +30 -0
- package/bin/v2/Tables/AddTableName/template/Config/schema.json +3 -0
- package/bin/v2/Tables/AddTableName/template/end-points.js +7 -0
- package/bin/v2/Tables/index.js +56 -0
- package/bin/v2/commands/AddSubRoute/steps/UpdateRoutesJs/common/readFile.js +8 -0
- package/bin/v2/commands/AddSubRoute/steps/UpdateRoutesJs/common/writeFile.js +10 -0
- package/bin/v2/commands/AddSubRoute/steps/UpdateRoutesJs/updateImports/buildImport.js +9 -0
- package/bin/v2/commands/AddSubRoute/steps/UpdateRoutesJs/updateImports/checkDuplicate.js +8 -0
- package/bin/v2/commands/AddSubRoute/steps/UpdateRoutesJs/updateImports/findInsertIndex.js +10 -0
- package/bin/v2/commands/AddSubRoute/steps/UpdateRoutesJs/updateImports/index.js +41 -0
- package/bin/v2/commands/AddSubRoute/steps/UpdateRoutesJs/updateUse/buildUseLine.js +11 -0
- package/bin/v2/commands/AddSubRoute/steps/UpdateRoutesJs/updateUse/checkDuplicate.js +8 -0
- package/bin/v2/commands/AddSubRoute/steps/UpdateRoutesJs/updateUse/findInsertIndex.js +10 -0
- package/bin/v2/commands/AddSubRoute/steps/UpdateRoutesJs/updateUse/index.js +42 -0
- package/bin/v2/commands/AddSubRoute/steps/announce.js +9 -0
- package/bin/v2/commands/AddSubRoute/steps/createFolder.js +7 -0
- package/bin/v2/commands/AddSubRoute/steps/decideTemplate.js +3 -0
- package/bin/v2/commands/AddSubRoute/steps/locateDestination.js +5 -0
- package/bin/v2/commands/AddSubRoute/steps/locateSource.js +13 -0
- package/bin/v2/commands/AddSubRoute/steps/resolveFolderName.js +20 -0
- package/bin/v2/commands/AddSubRoute/steps/updateAppJs.js +7 -0
- package/bin/v2/commands/AddSubRoute/template/routes.js +5 -0
- package/bin/v2/commands/StartEndPoint/steps/UpdateAppJs/common/readFile.js +8 -0
- package/bin/v2/commands/StartEndPoint/steps/UpdateAppJs/common/writeFile.js +10 -0
- package/bin/v2/commands/StartEndPoint/steps/UpdateAppJs/index.js +11 -0
- package/bin/v2/commands/StartEndPoint/steps/UpdateAppJs/updateImports/buildImport.js +9 -0
- package/bin/v2/commands/StartEndPoint/steps/UpdateAppJs/updateImports/checkDuplicate.js +8 -0
- package/bin/v2/commands/StartEndPoint/steps/UpdateAppJs/updateImports/findInsertIndex.js +10 -0
- package/bin/v2/commands/StartEndPoint/steps/UpdateAppJs/updateImports/index.js +41 -0
- package/bin/v2/commands/StartEndPoint/steps/UpdateAppJs/updateUse/buildUseLine.js +9 -0
- package/bin/v2/commands/StartEndPoint/steps/UpdateAppJs/updateUse/checkDuplicate.js +8 -0
- package/bin/v2/commands/StartEndPoint/steps/UpdateAppJs/updateUse/findInsertIndex.js +10 -0
- package/bin/v2/commands/StartEndPoint/steps/UpdateAppJs/updateUse/index.js +42 -0
- package/bin/v2/commands/StartEndPoint/steps/announce.js +9 -0
- package/bin/v2/commands/StartEndPoint/steps/decideTemplate.js +3 -0
- package/bin/v2/commands/StartEndPoint/steps/locateDestination.js +7 -0
- package/bin/v2/commands/StartEndPoint/steps/locateSource.js +13 -0
- package/bin/v2/commands/StartEndPoint/steps/resolveFolderName.js +20 -0
- package/bin/v2/commands/StartEndPoint/template/routes.js +5 -0
- package/bin/v2/commands/addSubRoute.js +42 -0
- package/bin/v2/commands/startEndPoint.js +44 -0
- package/bin/v2/core/createFolder.js +34 -0
- package/bin/v2/core/parseInput.js +12 -0
- package/bin/v2/core/resolveCommand.js +14 -0
- package/bin/v2/core/showUsage.js +50 -0
- package/bin/v2/start.js +22 -0
- package/bin/v3/AddSubRoute/Helpers/steps/UpdateRoutesJs/common/readFile.js +8 -0
- package/bin/v3/AddSubRoute/Helpers/steps/UpdateRoutesJs/common/writeFile.js +10 -0
- package/bin/v3/AddSubRoute/Helpers/steps/UpdateRoutesJs/updateImports/buildImport.js +9 -0
- package/bin/v3/AddSubRoute/Helpers/steps/UpdateRoutesJs/updateImports/checkDuplicate.js +8 -0
- package/bin/v3/AddSubRoute/Helpers/steps/UpdateRoutesJs/updateImports/findInsertIndex.js +10 -0
- package/bin/v3/AddSubRoute/Helpers/steps/UpdateRoutesJs/updateImports/index.js +41 -0
- package/bin/v3/AddSubRoute/Helpers/steps/UpdateRoutesJs/updateUse/buildUseLine.js +11 -0
- package/bin/v3/AddSubRoute/Helpers/steps/UpdateRoutesJs/updateUse/checkDuplicate.js +8 -0
- package/bin/v3/AddSubRoute/Helpers/steps/UpdateRoutesJs/updateUse/findInsertIndex.js +10 -0
- package/bin/v3/AddSubRoute/Helpers/steps/UpdateRoutesJs/updateUse/index.js +42 -0
- package/bin/v3/AddSubRoute/Helpers/steps/announce.js +9 -0
- package/bin/v3/AddSubRoute/Helpers/steps/createFolder.js +7 -0
- package/bin/v3/AddSubRoute/Helpers/steps/decideTemplate.js +3 -0
- package/bin/v3/AddSubRoute/Helpers/steps/locateDestination.js +5 -0
- package/bin/v3/AddSubRoute/Helpers/steps/locateSource.js +13 -0
- package/bin/v3/AddSubRoute/Helpers/steps/resolveFolderName.js +20 -0
- package/bin/v3/AddSubRoute/Helpers/steps/updateAppJs.js +7 -0
- package/bin/v3/AddSubRoute/Helpers/template/routes.js +5 -0
- package/bin/v3/AddSubRoute/index.js +42 -0
- package/bin/v3/StartEndPoint/Helpers/steps/UpdateAppJs/common/readFile.js +8 -0
- package/bin/v3/StartEndPoint/Helpers/steps/UpdateAppJs/common/writeFile.js +10 -0
- package/bin/v3/StartEndPoint/Helpers/steps/UpdateAppJs/index.js +19 -0
- package/bin/v3/StartEndPoint/Helpers/steps/UpdateAppJs/updateImports/buildImport.js +9 -0
- package/bin/v3/StartEndPoint/Helpers/steps/UpdateAppJs/updateImports/checkDuplicate.js +8 -0
- package/bin/v3/StartEndPoint/Helpers/steps/UpdateAppJs/updateImports/findInsertIndex.js +10 -0
- package/bin/v3/StartEndPoint/Helpers/steps/UpdateAppJs/updateImports/index.js +41 -0
- package/bin/v3/StartEndPoint/Helpers/steps/UpdateAppJs/updateUse/buildUseLine.js +9 -0
- package/bin/v3/StartEndPoint/Helpers/steps/UpdateAppJs/updateUse/checkDuplicate.js +8 -0
- package/bin/v3/StartEndPoint/Helpers/steps/UpdateAppJs/updateUse/findInsertIndex.js +10 -0
- package/bin/v3/StartEndPoint/Helpers/steps/UpdateAppJs/updateUse/index.js +42 -0
- package/bin/v3/StartEndPoint/Helpers/steps/announce.js +9 -0
- package/bin/v3/StartEndPoint/Helpers/steps/decideTemplate.js +3 -0
- package/bin/v3/StartEndPoint/Helpers/steps/locateDestination.js +7 -0
- package/bin/v3/StartEndPoint/Helpers/steps/locateSource.js +13 -0
- package/bin/v3/StartEndPoint/Helpers/steps/resolveFolderName.js +20 -0
- package/bin/v3/StartEndPoint/Helpers/template/routes.js +5 -0
- package/bin/v3/StartEndPoint/index.js +47 -0
- package/bin/v3/Tables/AddTableName/steps/UpdateRoutesJs/common/readFile.js +8 -0
- package/bin/v3/Tables/AddTableName/steps/UpdateRoutesJs/common/writeFile.js +10 -0
- package/bin/v3/Tables/AddTableName/steps/UpdateRoutesJs/index.js +9 -0
- package/bin/v3/Tables/AddTableName/steps/UpdateRoutesJs/updateImports/buildImport.js +9 -0
- package/bin/v3/Tables/AddTableName/steps/UpdateRoutesJs/updateImports/checkDuplicate.js +8 -0
- package/bin/v3/Tables/AddTableName/steps/UpdateRoutesJs/updateImports/findInsertIndex.js +10 -0
- package/bin/v3/Tables/AddTableName/steps/UpdateRoutesJs/updateImports/index.js +41 -0
- package/bin/v3/Tables/AddTableName/steps/UpdateRoutesJs/updateUse/buildUseLine.js +11 -0
- package/bin/v3/Tables/AddTableName/steps/UpdateRoutesJs/updateUse/checkDuplicate.js +8 -0
- package/bin/v3/Tables/AddTableName/steps/UpdateRoutesJs/updateUse/findInsertIndex.js +10 -0
- package/bin/v3/Tables/AddTableName/steps/UpdateRoutesJs/updateUse/index.js +42 -0
- package/bin/v3/Tables/AddTableName/steps/announce.js +9 -0
- package/bin/v3/Tables/AddTableName/steps/createFolder.js +7 -0
- package/bin/v3/Tables/AddTableName/steps/decideTemplate.js +3 -0
- package/bin/v3/Tables/AddTableName/steps/locateDestination.js +6 -0
- package/bin/v3/Tables/AddTableName/steps/locateSource.js +13 -0
- package/bin/v3/Tables/AddTableName/steps/resolveFolderName.js +20 -0
- package/bin/v3/Tables/AddTableName/steps/updateConfig.js +16 -0
- package/bin/v3/Tables/AddTableName/steps/updateEndPointsFile.js +30 -0
- package/bin/v3/Tables/AddTableName/steps/updateTableName.js +30 -0
- package/bin/v3/Tables/AddTableName/template/Config/schema.json +3 -0
- package/bin/v3/Tables/AddTableName/template/end-points.js +7 -0
- package/bin/v3/Tables/index.js +56 -0
- package/bin/v3/commands/AddSubRoute/steps/UpdateRoutesJs/common/readFile.js +8 -0
- package/bin/v3/commands/AddSubRoute/steps/UpdateRoutesJs/common/writeFile.js +10 -0
- package/bin/v3/commands/AddSubRoute/steps/UpdateRoutesJs/updateImports/buildImport.js +9 -0
- package/bin/v3/commands/AddSubRoute/steps/UpdateRoutesJs/updateImports/checkDuplicate.js +8 -0
- package/bin/v3/commands/AddSubRoute/steps/UpdateRoutesJs/updateImports/findInsertIndex.js +10 -0
- package/bin/v3/commands/AddSubRoute/steps/UpdateRoutesJs/updateImports/index.js +41 -0
- package/bin/v3/commands/AddSubRoute/steps/UpdateRoutesJs/updateUse/buildUseLine.js +11 -0
- package/bin/v3/commands/AddSubRoute/steps/UpdateRoutesJs/updateUse/checkDuplicate.js +8 -0
- package/bin/v3/commands/AddSubRoute/steps/UpdateRoutesJs/updateUse/findInsertIndex.js +10 -0
- package/bin/v3/commands/AddSubRoute/steps/UpdateRoutesJs/updateUse/index.js +42 -0
- package/bin/v3/commands/AddSubRoute/steps/announce.js +9 -0
- package/bin/v3/commands/AddSubRoute/steps/createFolder.js +7 -0
- package/bin/v3/commands/AddSubRoute/steps/decideTemplate.js +3 -0
- package/bin/v3/commands/AddSubRoute/steps/locateDestination.js +5 -0
- package/bin/v3/commands/AddSubRoute/steps/locateSource.js +13 -0
- package/bin/v3/commands/AddSubRoute/steps/resolveFolderName.js +20 -0
- package/bin/v3/commands/AddSubRoute/steps/updateAppJs.js +7 -0
- package/bin/v3/commands/AddSubRoute/template/routes.js +5 -0
- package/bin/v3/commands/StartEndPoint/steps/UpdateAppJs/common/readFile.js +8 -0
- package/bin/v3/commands/StartEndPoint/steps/UpdateAppJs/common/writeFile.js +10 -0
- package/bin/v3/commands/StartEndPoint/steps/UpdateAppJs/index.js +11 -0
- package/bin/v3/commands/StartEndPoint/steps/UpdateAppJs/updateImports/buildImport.js +9 -0
- package/bin/v3/commands/StartEndPoint/steps/UpdateAppJs/updateImports/checkDuplicate.js +8 -0
- package/bin/v3/commands/StartEndPoint/steps/UpdateAppJs/updateImports/findInsertIndex.js +10 -0
- package/bin/v3/commands/StartEndPoint/steps/UpdateAppJs/updateImports/index.js +41 -0
- package/bin/v3/commands/StartEndPoint/steps/UpdateAppJs/updateUse/buildUseLine.js +9 -0
- package/bin/v3/commands/StartEndPoint/steps/UpdateAppJs/updateUse/checkDuplicate.js +8 -0
- package/bin/v3/commands/StartEndPoint/steps/UpdateAppJs/updateUse/findInsertIndex.js +10 -0
- package/bin/v3/commands/StartEndPoint/steps/UpdateAppJs/updateUse/index.js +42 -0
- package/bin/v3/commands/StartEndPoint/steps/announce.js +9 -0
- package/bin/v3/commands/StartEndPoint/steps/decideTemplate.js +3 -0
- package/bin/v3/commands/StartEndPoint/steps/locateDestination.js +7 -0
- package/bin/v3/commands/StartEndPoint/steps/locateSource.js +13 -0
- package/bin/v3/commands/StartEndPoint/steps/resolveFolderName.js +20 -0
- package/bin/v3/commands/StartEndPoint/template/routes.js +5 -0
- package/bin/v3/commands/addSubRoute.js +42 -0
- package/bin/v3/commands/startEndPoint.js +44 -0
- package/bin/v3/core/createFolder.js +34 -0
- package/bin/v3/core/parseInput.js +12 -0
- package/bin/v3/core/resolveCommand.js +14 -0
- package/bin/v3/core/showUsage.js +50 -0
- package/bin/v3/start.js +22 -0
- package/index.js +10 -0
- package/package.json +37 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 KeshavSoft
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to do so, subject to the
|
|
10
|
+
following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# @keshavsoft/kschema-cli
|
|
2
|
+
|
|
3
|
+
CLI to generate projects using templates.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
npm install -g @keshavsoft/kschema-cli
|
|
8
|
+
|
|
9
|
+
or
|
|
10
|
+
|
|
11
|
+
npx @keshavsoft/kschema-cli init express MyApp
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
kschema init <template> [projectName]
|
|
16
|
+
|
|
17
|
+
## Examples
|
|
18
|
+
|
|
19
|
+
kschema init basic MyApp
|
|
20
|
+
kschema init express MyServer
|
|
21
|
+
kschema init express
|
|
22
|
+
|
|
23
|
+
## Templates
|
|
24
|
+
|
|
25
|
+
basic
|
|
26
|
+
express
|
|
27
|
+
|
|
28
|
+
## Behavior
|
|
29
|
+
|
|
30
|
+
- If projectName is provided → folder created with that name
|
|
31
|
+
- If not provided → auto name generated
|
|
32
|
+
|
|
33
|
+
Example auto name:
|
|
34
|
+
kschema-express-<timestamp>
|
|
35
|
+
|
|
36
|
+
## Output
|
|
37
|
+
|
|
38
|
+
Creates a new folder with selected template files.
|
package/bin/cli.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import getLatestVersion from "./core/getLatestVersion.js";
|
|
4
|
+
import loadRunner from "./core/loadRunner.js";
|
|
5
|
+
|
|
6
|
+
const run = () => {
|
|
7
|
+
const version = getLatestVersion();
|
|
8
|
+
const runner = loadRunner(version);
|
|
9
|
+
runner();
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
run();
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { fileURLToPath } from "url";
|
|
4
|
+
|
|
5
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
6
|
+
|
|
7
|
+
export default function getLatestVersion() {
|
|
8
|
+
const versions = fs.readdirSync(path.join(__dirname, ".."))
|
|
9
|
+
.filter(n => /^v\d+$/.test(n))
|
|
10
|
+
.sort((a, b) => parseInt(a.slice(1)) - parseInt(b.slice(1)));
|
|
11
|
+
|
|
12
|
+
return versions.at(-1);
|
|
13
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const buildImport = (inEndpoint) => {
|
|
2
|
+
const localEndpoint = inEndpoint;
|
|
3
|
+
|
|
4
|
+
const safeName = localEndpoint.replace(/[^a-zA-Z0-9]/g, "_");
|
|
5
|
+
|
|
6
|
+
return `import { router as routerFrom${safeName} } from "./${localEndpoint}/routes.js";`;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export default buildImport;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const findInsertIndex = (inContent) => {
|
|
2
|
+
const localContent = inContent;
|
|
3
|
+
|
|
4
|
+
const matches = [...localContent.matchAll(/^\s*import.*$/gm)];
|
|
5
|
+
const last = matches.at(-1);
|
|
6
|
+
|
|
7
|
+
return last ? last.index + last[0].length : 0;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export default findInsertIndex;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import readFile from "../common/readFile.js";
|
|
2
|
+
import buildImport from "./buildImport.js";
|
|
3
|
+
import checkDuplicate from "./checkDuplicate.js";
|
|
4
|
+
import findInsertIndex from "./findInsertIndex.js";
|
|
5
|
+
import writeFile from "../common/writeFile.js";
|
|
6
|
+
|
|
7
|
+
const updateImports = ({ appJsPath, endpoint, showLog }) => {
|
|
8
|
+
const summary = {
|
|
9
|
+
import: { added: false, line: null },
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const content = readFile(appJsPath);
|
|
13
|
+
const importLine = buildImport(endpoint);
|
|
14
|
+
|
|
15
|
+
if (checkDuplicate(content, endpoint)) {
|
|
16
|
+
summary.import.skipped = true;
|
|
17
|
+
|
|
18
|
+
if (showLog) console.log(summary);
|
|
19
|
+
|
|
20
|
+
return summary;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const index = findInsertIndex(content);
|
|
24
|
+
|
|
25
|
+
const before = content.slice(0, index);
|
|
26
|
+
const lineNumber = before.split("\n").length + 1;
|
|
27
|
+
|
|
28
|
+
const updated =
|
|
29
|
+
before + "\n" + importLine + content.slice(index);
|
|
30
|
+
|
|
31
|
+
writeFile(appJsPath, updated);
|
|
32
|
+
|
|
33
|
+
summary.import.added = true;
|
|
34
|
+
summary.import.line = lineNumber;
|
|
35
|
+
|
|
36
|
+
if (showLog) console.log(summary);
|
|
37
|
+
|
|
38
|
+
return summary;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export default updateImports;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const appOrRouter = "router";
|
|
2
|
+
|
|
3
|
+
const buildUseLine = (inEndpoint) => {
|
|
4
|
+
const localEndpoint = inEndpoint;
|
|
5
|
+
|
|
6
|
+
const safeName = localEndpoint.replace(/[^a-zA-Z0-9]/g, "_");
|
|
7
|
+
|
|
8
|
+
return `${appOrRouter}.use("/${localEndpoint}", routerFrom${safeName});`;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export default buildUseLine;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const findUseInsertIndex = (inContent) => {
|
|
2
|
+
const localContent = inContent;
|
|
3
|
+
|
|
4
|
+
const matches = [...localContent.matchAll(/const\s+router\s*=\s*express\.Router\(\)/g)];
|
|
5
|
+
const match = matches.at(0);
|
|
6
|
+
|
|
7
|
+
return match ? match.index + match[0].length : localContent.length;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export default findUseInsertIndex;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import readFile from "../common/readFile.js";
|
|
2
|
+
import writeFile from "../common/writeFile.js";
|
|
3
|
+
|
|
4
|
+
import buildUseLine from "./buildUseLine.js";
|
|
5
|
+
import checkDuplicate from "./checkDuplicate.js";
|
|
6
|
+
import findUseInsertIndex from "./findInsertIndex.js";
|
|
7
|
+
|
|
8
|
+
const updateAppUse = ({ appJsPath, endpoint, showLog }) => {
|
|
9
|
+
const summary = {
|
|
10
|
+
use: { added: false, skipped: false, line: null }
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const content = readFile(appJsPath);
|
|
14
|
+
const useLine = buildUseLine(endpoint);
|
|
15
|
+
|
|
16
|
+
if (checkDuplicate(content, endpoint)) {
|
|
17
|
+
summary.use.skipped = true;
|
|
18
|
+
|
|
19
|
+
if (showLog) console.log(summary);
|
|
20
|
+
|
|
21
|
+
return summary;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const index = findUseInsertIndex(content);
|
|
25
|
+
|
|
26
|
+
const before = content.slice(0, index);
|
|
27
|
+
const lineNumber = before.split("\n").length + 1;
|
|
28
|
+
|
|
29
|
+
const updated =
|
|
30
|
+
before + "\n" + useLine + content.slice(index);
|
|
31
|
+
|
|
32
|
+
writeFile(appJsPath, updated);
|
|
33
|
+
|
|
34
|
+
summary.use.added = true;
|
|
35
|
+
summary.use.line = lineNumber;
|
|
36
|
+
|
|
37
|
+
if (showLog) console.log(summary);
|
|
38
|
+
|
|
39
|
+
return summary;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export default updateAppUse;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export const announce = ({ inResolvedFolderName }) => {
|
|
2
|
+
console.log(`[keshavsoft] Folder created: ${inResolvedFolderName}`);
|
|
3
|
+
|
|
4
|
+
console.log("");
|
|
5
|
+
console.log("Next:");
|
|
6
|
+
console.log("");
|
|
7
|
+
console.log(`cd ${inResolvedFolderName}`);
|
|
8
|
+
console.log(`npx kschema-api-gen AddSubRoute`);
|
|
9
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import { fileURLToPath } from "url";
|
|
3
|
+
|
|
4
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
5
|
+
const __dirname = path.dirname(__filename);
|
|
6
|
+
|
|
7
|
+
export const locateSource = () => {
|
|
8
|
+
return path.join(
|
|
9
|
+
__dirname,
|
|
10
|
+
"..",
|
|
11
|
+
"template"
|
|
12
|
+
);
|
|
13
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
|
|
3
|
+
export default function resolveFolderName({ name }) {
|
|
4
|
+
const defaultFolerName = "V1";
|
|
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
|
+
return {
|
|
14
|
+
KTF: false,
|
|
15
|
+
KReason: `Folder already exists : ${name}`
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
return name;
|
|
20
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import updateImports from "./UpdateRoutesJs/updateImports/index.js";
|
|
2
|
+
import updateAppUse from "./UpdateRoutesJs/updateUse/index.js";
|
|
3
|
+
|
|
4
|
+
export function updateAppJs({ appJsPath, endpoint }) {
|
|
5
|
+
updateImports({ appJsPath, endpoint });
|
|
6
|
+
updateAppUse({ appJsPath, endpoint });
|
|
7
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { locateSource } from "./Helpers/steps/locateSource.js";
|
|
2
|
+
import { locateDestination } from "./Helpers/steps/locateDestination.js";
|
|
3
|
+
import { createFolder } from "../core/createFolder.js";
|
|
4
|
+
import { updateAppJs } from "./Helpers/steps/updateAppJs.js";
|
|
5
|
+
import { announce } from "./Helpers/steps/announce.js";
|
|
6
|
+
|
|
7
|
+
import resolveFolderName from "./Helpers/steps/resolveFolderName.js";
|
|
8
|
+
|
|
9
|
+
export default ({ folderName = "", argsAsIs, toPath, isAnnounce = true, checkBeforeCreate = true }) => {
|
|
10
|
+
const localToPath = toPath;
|
|
11
|
+
const resolvedFolderName = resolveFolderName({
|
|
12
|
+
name: folderName
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
if (resolvedFolderName.KTF === false) {
|
|
16
|
+
console.log(resolvedFolderName.KReason);
|
|
17
|
+
|
|
18
|
+
return folderName;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const source = locateSource();
|
|
22
|
+
const destination = locateDestination({
|
|
23
|
+
inResolvedFolderName: resolvedFolderName,
|
|
24
|
+
toPath: localToPath
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const createFolderResponse = createFolder({
|
|
28
|
+
source, destination,
|
|
29
|
+
isAnnounce, checkBeforeCreate
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
if (createFolderResponse.KTF) {
|
|
33
|
+
updateAppJs({
|
|
34
|
+
appJsPath: `${localToPath}/routes.js`,
|
|
35
|
+
endpoint: resolvedFolderName
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
if (isAnnounce) announce({ inResolvedFolderName: resolvedFolderName });
|
|
40
|
+
|
|
41
|
+
return resolvedFolderName;
|
|
42
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
|
|
3
|
+
import updateImports from "./updateImports/index.js";
|
|
4
|
+
import updateAppUse from "./updateUse/index.js";
|
|
5
|
+
|
|
6
|
+
export function updateAppJs({ appJsPath, endpoint }) {
|
|
7
|
+
if (!fs.existsSync(appJsPath)) return;
|
|
8
|
+
|
|
9
|
+
updateImports({ appJsPath, endpoint });
|
|
10
|
+
updateAppUse({ appJsPath, endpoint });
|
|
11
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const buildImport = (inEndpoint) => {
|
|
2
|
+
const localEndpoint = inEndpoint;
|
|
3
|
+
|
|
4
|
+
const safeName = localEndpoint.replace(/[^a-zA-Z0-9]/g, "_");
|
|
5
|
+
|
|
6
|
+
return `import { router as routerFrom${safeName} } from "./${localEndpoint}/routes.js";`;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export default buildImport;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const findInsertIndex = (inContent) => {
|
|
2
|
+
const localContent = inContent;
|
|
3
|
+
|
|
4
|
+
const matches = [...localContent.matchAll(/^\s*import.*$/gm)];
|
|
5
|
+
const last = matches.at(-1);
|
|
6
|
+
|
|
7
|
+
return last ? last.index + last[0].length : 0;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export default findInsertIndex;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import readFile from "../common/readFile.js";
|
|
2
|
+
import buildImport from "./buildImport.js";
|
|
3
|
+
import checkDuplicate from "./checkDuplicate.js";
|
|
4
|
+
import findInsertIndex from "./findInsertIndex.js";
|
|
5
|
+
import writeFile from "../common/writeFile.js";
|
|
6
|
+
|
|
7
|
+
const updateImports = ({ appJsPath, endpoint, showLog }) => {
|
|
8
|
+
const summary = {
|
|
9
|
+
import: { added: false, line: null },
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const content = readFile(appJsPath);
|
|
13
|
+
const importLine = buildImport(endpoint);
|
|
14
|
+
|
|
15
|
+
if (checkDuplicate(content, endpoint)) {
|
|
16
|
+
summary.import.skipped = true;
|
|
17
|
+
|
|
18
|
+
if (showLog) console.log(summary);
|
|
19
|
+
|
|
20
|
+
return summary;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const index = findInsertIndex(content);
|
|
24
|
+
|
|
25
|
+
const before = content.slice(0, index);
|
|
26
|
+
const lineNumber = before.split("\n").length + 1;
|
|
27
|
+
|
|
28
|
+
const updated =
|
|
29
|
+
before + "\n" + importLine + content.slice(index);
|
|
30
|
+
|
|
31
|
+
writeFile(appJsPath, updated);
|
|
32
|
+
|
|
33
|
+
summary.import.added = true;
|
|
34
|
+
summary.import.line = lineNumber;
|
|
35
|
+
|
|
36
|
+
if (showLog) console.log(summary);
|
|
37
|
+
|
|
38
|
+
return summary;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export default updateImports;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const findUseInsertIndex = (inContent) => {
|
|
2
|
+
const localContent = inContent;
|
|
3
|
+
|
|
4
|
+
const matches = [...localContent.matchAll(/const\s+app\s*=\s*express\(\)/g)];
|
|
5
|
+
const match = matches.at(0);
|
|
6
|
+
|
|
7
|
+
return match ? match.index + match[0].length : localContent.length;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export default findUseInsertIndex;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import readFile from "../common/readFile.js";
|
|
2
|
+
import writeFile from "../common/writeFile.js";
|
|
3
|
+
|
|
4
|
+
import buildUseLine from "./buildUseLine.js";
|
|
5
|
+
import checkDuplicate from "./checkDuplicate.js";
|
|
6
|
+
import findUseInsertIndex from "./findInsertIndex.js";
|
|
7
|
+
|
|
8
|
+
const updateAppUse = ({ appJsPath, endpoint, showLog = false }) => {
|
|
9
|
+
const summary = {
|
|
10
|
+
use: { added: false, skipped: false, line: null }
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const content = readFile(appJsPath);
|
|
14
|
+
const useLine = buildUseLine(endpoint);
|
|
15
|
+
|
|
16
|
+
if (checkDuplicate(content, endpoint)) {
|
|
17
|
+
summary.use.skipped = true;
|
|
18
|
+
|
|
19
|
+
if (showLog) console.log(summary);
|
|
20
|
+
|
|
21
|
+
return summary;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const index = findUseInsertIndex(content);
|
|
25
|
+
|
|
26
|
+
const before = content.slice(0, index);
|
|
27
|
+
const lineNumber = before.split("\n").length + 1;
|
|
28
|
+
|
|
29
|
+
const updated =
|
|
30
|
+
before + "\n" + useLine + content.slice(index);
|
|
31
|
+
|
|
32
|
+
writeFile(appJsPath, updated);
|
|
33
|
+
|
|
34
|
+
summary.use.added = true;
|
|
35
|
+
summary.use.line = lineNumber;
|
|
36
|
+
|
|
37
|
+
if (showLog) console.log(summary);
|
|
38
|
+
|
|
39
|
+
return summary;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export default updateAppUse;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export const announce = ({ inResolvedFolderName }) => {
|
|
2
|
+
console.log(`[keshavsoft] Folder created: ${inResolvedFolderName}`);
|
|
3
|
+
|
|
4
|
+
console.log("");
|
|
5
|
+
console.log("Next:");
|
|
6
|
+
console.log("");
|
|
7
|
+
console.log(`cd ${inResolvedFolderName}`);
|
|
8
|
+
console.log(`npx kschema-api-gen AddSubRoute`);
|
|
9
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import { fileURLToPath } from "url";
|
|
3
|
+
|
|
4
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
5
|
+
const __dirname = path.dirname(__filename);
|
|
6
|
+
|
|
7
|
+
export const locateSource = () => {
|
|
8
|
+
return path.join(
|
|
9
|
+
__dirname,
|
|
10
|
+
"..",
|
|
11
|
+
"template"
|
|
12
|
+
);
|
|
13
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
|
|
3
|
+
export default function resolveFolderName({ name }) {
|
|
4
|
+
const defaultFolerName = "Api";
|
|
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
|
+
return {
|
|
14
|
+
KTF: false,
|
|
15
|
+
KReason: `Folder already exists : ${name}`
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
return name;
|
|
20
|
+
};
|