json-crud-ui 1.1.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/LICENSE +21 -0
- package/README.md +225 -0
- package/bin/cli.js +12 -0
- package/bin/core/getLatestVersion.js +13 -0
- package/bin/core/loadRunner.js +9 -0
- package/bin/v10/commands/exportCommands/endPointsJs.js +5 -0
- package/bin/v10/core/createFolder.js +34 -0
- package/bin/v10/core/parseInput.js +9 -0
- package/bin/v10/core/resolveCommand.js +13 -0
- package/bin/v10/core/showUsage.js +39 -0
- package/bin/v10/start.js +22 -0
- package/bin/v10/tasks/actions/EndPointsJs/Distinct/index.js +32 -0
- package/bin/v10/tasks/actions/EndPointsJs/Distinct/insertImport.js +15 -0
- package/bin/v10/tasks/actions/EndPointsJs/Distinct/insertUsage.js +15 -0
- package/bin/v10/tasks/actions/EndPointsJs/Insert/index.js +33 -0
- package/bin/v10/tasks/actions/EndPointsJs/Insert/insertImport.js +15 -0
- package/bin/v10/tasks/actions/EndPointsJs/Insert/insertUsage.js +15 -0
- package/bin/v10/tasks/actions/EndPointsJs/ShowAll/index.js +33 -0
- package/bin/v10/tasks/actions/EndPointsJs/ShowAll/insertImport.js +15 -0
- package/bin/v10/tasks/actions/EndPointsJs/ShowAll/insertUsage.js +15 -0
- package/bin/v10/tasks/actions/EndPointsJs/index.js +37 -0
- package/bin/v10/tasks/actions/EndPointsJs/showUsage.js +38 -0
- package/bin/v10/tasks/actions/appJs.js +6 -0
- package/bin/v10/tasks/common/SourceEditor.js +66 -0
- package/bin/v10/tasks/tables/AddTableName/steps/UpdateRoutesJs/common/readFile.js +8 -0
- package/bin/v10/tasks/tables/AddTableName/steps/UpdateRoutesJs/common/writeFile.js +10 -0
- package/bin/v10/tasks/tables/AddTableName/steps/UpdateRoutesJs/index.js +9 -0
- package/bin/v10/tasks/tables/AddTableName/steps/UpdateRoutesJs/updateImports/buildImport.js +9 -0
- package/bin/v10/tasks/tables/AddTableName/steps/UpdateRoutesJs/updateImports/checkDuplicate.js +8 -0
- package/bin/v10/tasks/tables/AddTableName/steps/UpdateRoutesJs/updateImports/findInsertIndex.js +10 -0
- package/bin/v10/tasks/tables/AddTableName/steps/UpdateRoutesJs/updateImports/index.js +41 -0
- package/bin/v10/tasks/tables/AddTableName/steps/UpdateRoutesJs/updateUse/buildUseLine.js +11 -0
- package/bin/v10/tasks/tables/AddTableName/steps/UpdateRoutesJs/updateUse/checkDuplicate.js +8 -0
- package/bin/v10/tasks/tables/AddTableName/steps/UpdateRoutesJs/updateUse/findInsertIndex.js +10 -0
- package/bin/v10/tasks/tables/AddTableName/steps/UpdateRoutesJs/updateUse/index.js +42 -0
- package/bin/v10/tasks/tables/AddTableName/steps/announce.js +9 -0
- package/bin/v10/tasks/tables/AddTableName/steps/createFolder.js +7 -0
- package/bin/v10/tasks/tables/AddTableName/steps/decideTemplate.js +3 -0
- package/bin/v10/tasks/tables/AddTableName/steps/locateDestination.js +6 -0
- package/bin/v10/tasks/tables/AddTableName/steps/locateSource.js +13 -0
- package/bin/v10/tasks/tables/AddTableName/steps/resolveFolderName.js +20 -0
- package/bin/v10/tasks/tables/AddTableName/steps/updateConfig.js +16 -0
- package/bin/v10/tasks/tables/AddTableName/steps/updateEndPointsFile.js +30 -0
- package/bin/v10/tasks/tables/AddTableName/steps/updateTableName.js +30 -0
- package/bin/v10/tasks/tables/AddTableName/template/Config/schema.json +3 -0
- package/bin/v10/tasks/tables/AddTableName/template/end-points.js +7 -0
- package/bin/v10/tasks/tables/addTableName.js +56 -0
- package/bin/v11/commands/loadCommand.js +7 -0
- package/bin/v11/config/actions.json +35 -0
- package/bin/v11/config/actionsV1.json +20 -0
- package/bin/v11/config/actionsV2.json +27 -0
- package/bin/v11/core/createFolder.js +34 -0
- package/bin/v11/core/parseInput.js +8 -0
- package/bin/v11/core/resolveCommand.js +13 -0
- package/bin/v11/core/showUsage.js +39 -0
- package/bin/v11/start.js +29 -0
- package/bin/v11/tasks/actions/EndPointsJs/AlterJsFile/index.js +31 -0
- package/bin/v11/tasks/actions/EndPointsJs/AlterJsFile/insertImport.js +15 -0
- package/bin/v11/tasks/actions/EndPointsJs/AlterJsFile/insertUsage.js +15 -0
- package/bin/v11/tasks/actions/EndPointsJs/Distinct/index.js +32 -0
- package/bin/v11/tasks/actions/EndPointsJs/Distinct/insertImport.js +15 -0
- package/bin/v11/tasks/actions/EndPointsJs/Distinct/insertUsage.js +15 -0
- package/bin/v11/tasks/actions/EndPointsJs/Insert/index.js +33 -0
- package/bin/v11/tasks/actions/EndPointsJs/Insert/insertImport.js +15 -0
- package/bin/v11/tasks/actions/EndPointsJs/Insert/insertUsage.js +15 -0
- package/bin/v11/tasks/actions/EndPointsJs/ShowAll/index.js +33 -0
- package/bin/v11/tasks/actions/EndPointsJs/ShowAll/insertImport.js +15 -0
- package/bin/v11/tasks/actions/EndPointsJs/ShowAll/insertUsage.js +15 -0
- package/bin/v11/tasks/actions/EndPointsJs/index.js +19 -0
- package/bin/v11/tasks/actions/EndPointsJs/showUsage.js +38 -0
- package/bin/v11/tasks/actions/appJs.js +6 -0
- package/bin/v11/tasks/common/SourceEditor.js +66 -0
- package/bin/v11/tasks/tables/AddTableName/steps/UpdateRoutesJs/common/readFile.js +8 -0
- package/bin/v11/tasks/tables/AddTableName/steps/UpdateRoutesJs/common/writeFile.js +10 -0
- package/bin/v11/tasks/tables/AddTableName/steps/UpdateRoutesJs/index.js +9 -0
- package/bin/v11/tasks/tables/AddTableName/steps/UpdateRoutesJs/updateImports/buildImport.js +9 -0
- package/bin/v11/tasks/tables/AddTableName/steps/UpdateRoutesJs/updateImports/checkDuplicate.js +8 -0
- package/bin/v11/tasks/tables/AddTableName/steps/UpdateRoutesJs/updateImports/findInsertIndex.js +10 -0
- package/bin/v11/tasks/tables/AddTableName/steps/UpdateRoutesJs/updateImports/index.js +41 -0
- package/bin/v11/tasks/tables/AddTableName/steps/UpdateRoutesJs/updateUse/buildUseLine.js +11 -0
- package/bin/v11/tasks/tables/AddTableName/steps/UpdateRoutesJs/updateUse/checkDuplicate.js +8 -0
- package/bin/v11/tasks/tables/AddTableName/steps/UpdateRoutesJs/updateUse/findInsertIndex.js +10 -0
- package/bin/v11/tasks/tables/AddTableName/steps/UpdateRoutesJs/updateUse/index.js +42 -0
- package/bin/v11/tasks/tables/AddTableName/steps/announce.js +9 -0
- package/bin/v11/tasks/tables/AddTableName/steps/createFolder.js +7 -0
- package/bin/v11/tasks/tables/AddTableName/steps/decideTemplate.js +3 -0
- package/bin/v11/tasks/tables/AddTableName/steps/locateDestination.js +6 -0
- package/bin/v11/tasks/tables/AddTableName/steps/locateSource.js +13 -0
- package/bin/v11/tasks/tables/AddTableName/steps/resolveFolderName.js +20 -0
- package/bin/v11/tasks/tables/AddTableName/steps/updateConfig.js +16 -0
- package/bin/v11/tasks/tables/AddTableName/steps/updateEndPointsFile.js +30 -0
- package/bin/v11/tasks/tables/AddTableName/steps/updateTableName.js +30 -0
- package/bin/v11/tasks/tables/AddTableName/template/Config/schema.json +3 -0
- package/bin/v11/tasks/tables/AddTableName/template/end-points.js +7 -0
- package/bin/v11/tasks/tables/addTableName.js +56 -0
- package/bin/v12/commands/loadCommand.js +7 -0
- package/bin/v12/config/actions.json +46 -0
- package/bin/v12/config/actionsV1.json +20 -0
- package/bin/v12/config/actionsV2.json +27 -0
- package/bin/v12/config/actionsV3.json +35 -0
- package/bin/v12/config/actionsV4.json +35 -0
- package/bin/v12/core/createFolder.js +34 -0
- package/bin/v12/core/parseInput.js +8 -0
- package/bin/v12/core/resolveCommand.js +13 -0
- package/bin/v12/core/showUsage.js +39 -0
- package/bin/v12/start.js +21 -0
- package/bin/v12/tasks/actions/EndPointsJs/AlterJsFile/index.js +31 -0
- package/bin/v12/tasks/actions/EndPointsJs/AlterJsFile/insertImport.js +15 -0
- package/bin/v12/tasks/actions/EndPointsJs/AlterJsFile/insertUsage.js +15 -0
- package/bin/v12/tasks/actions/EndPointsJs/index.js +19 -0
- package/bin/v12/tasks/actions/EndPointsJs/showUsage.js +38 -0
- package/bin/v12/tasks/actions/appJs.js +6 -0
- package/bin/v12/tasks/common/SourceEditor.js +66 -0
- package/bin/v12/tasks/tables/AddTableName/steps/UpdateRoutesJs/common/readFile.js +8 -0
- package/bin/v12/tasks/tables/AddTableName/steps/UpdateRoutesJs/common/writeFile.js +10 -0
- package/bin/v12/tasks/tables/AddTableName/steps/UpdateRoutesJs/index.js +9 -0
- package/bin/v12/tasks/tables/AddTableName/steps/UpdateRoutesJs/updateImports/buildImport.js +9 -0
- package/bin/v12/tasks/tables/AddTableName/steps/UpdateRoutesJs/updateImports/checkDuplicate.js +8 -0
- package/bin/v12/tasks/tables/AddTableName/steps/UpdateRoutesJs/updateImports/findInsertIndex.js +10 -0
- package/bin/v12/tasks/tables/AddTableName/steps/UpdateRoutesJs/updateImports/index.js +41 -0
- package/bin/v12/tasks/tables/AddTableName/steps/UpdateRoutesJs/updateUse/buildUseLine.js +11 -0
- package/bin/v12/tasks/tables/AddTableName/steps/UpdateRoutesJs/updateUse/checkDuplicate.js +8 -0
- package/bin/v12/tasks/tables/AddTableName/steps/UpdateRoutesJs/updateUse/findInsertIndex.js +10 -0
- package/bin/v12/tasks/tables/AddTableName/steps/UpdateRoutesJs/updateUse/index.js +42 -0
- package/bin/v12/tasks/tables/AddTableName/steps/announce.js +9 -0
- package/bin/v12/tasks/tables/AddTableName/steps/createFolder.js +7 -0
- package/bin/v12/tasks/tables/AddTableName/steps/decideTemplate.js +3 -0
- package/bin/v12/tasks/tables/AddTableName/steps/locateDestination.js +6 -0
- package/bin/v12/tasks/tables/AddTableName/steps/locateSource.js +13 -0
- package/bin/v12/tasks/tables/AddTableName/steps/resolveFolderName.js +20 -0
- package/bin/v12/tasks/tables/AddTableName/steps/updateConfig.js +16 -0
- package/bin/v12/tasks/tables/AddTableName/steps/updateEndPointsFile.js +30 -0
- package/bin/v12/tasks/tables/AddTableName/steps/updateTableName.js +30 -0
- package/bin/v12/tasks/tables/AddTableName/template/Config/schema.json +3 -0
- package/bin/v12/tasks/tables/AddTableName/template/end-points.js +7 -0
- package/bin/v12/tasks/tables/addTableName.js +56 -0
- package/index.js +5 -0
- package/package.json +35 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import updateImports from "./updateImports/index.js";
|
|
2
|
+
import updateAppUse from "./updateUse/index.js";
|
|
3
|
+
|
|
4
|
+
const startFunc = ({ appJsPath, endpoint }) => {
|
|
5
|
+
updateImports({ appJsPath, endpoint });
|
|
6
|
+
updateAppUse({ appJsPath, endpoint });
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export default startFunc;
|
|
@@ -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}/end-points.js";`;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export default buildImport;
|
package/bin/v12/tasks/tables/AddTableName/steps/UpdateRoutesJs/updateImports/findInsertIndex.js
ADDED
|
@@ -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 = "KSTable1";
|
|
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,16 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
|
|
4
|
+
export function updateConfigFile({ inEndpointFolder, inTableName }) {
|
|
5
|
+
const filePath = path.join(inEndpointFolder, "Config", "schema.json");
|
|
6
|
+
|
|
7
|
+
// Read Synchronously
|
|
8
|
+
const rawData = fs.readFileSync(filePath);
|
|
9
|
+
const data = JSON.parse(rawData);
|
|
10
|
+
data.tableName = `${inTableName}.json`;
|
|
11
|
+
|
|
12
|
+
// // Write Synchronously
|
|
13
|
+
const jsonString = JSON.stringify(data, null, 2);
|
|
14
|
+
fs.writeFileSync(filePath, jsonString);
|
|
15
|
+
|
|
16
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
|
|
3
|
+
function updateEndPointsFile({ filePath, inTableName }) {
|
|
4
|
+
try {
|
|
5
|
+
let content = readFile(filePath);
|
|
6
|
+
|
|
7
|
+
content = content.replace("<TABLE_NAME>", inTableName);
|
|
8
|
+
|
|
9
|
+
writeFile(filePath, content);
|
|
10
|
+
} catch (e) {
|
|
11
|
+
handleError(e);
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
// read
|
|
16
|
+
function readFile(filePath) {
|
|
17
|
+
return fs.readFileSync(filePath, "utf-8");
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
// write
|
|
21
|
+
function writeFile(filePath, content) {
|
|
22
|
+
fs.writeFileSync(filePath, content);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// error handler
|
|
26
|
+
function handleError(e) {
|
|
27
|
+
console.error("ROUTE USE ERROR:", e.message);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export { updateEndPointsFile };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
|
|
3
|
+
function startFunc({ filePath, inTableName }) {
|
|
4
|
+
try {
|
|
5
|
+
let content = readFile(filePath);
|
|
6
|
+
|
|
7
|
+
content = content.replace("<TABLE_NAME>", inTableName);
|
|
8
|
+
|
|
9
|
+
writeFile(filePath, content);
|
|
10
|
+
} catch (e) {
|
|
11
|
+
handleError(e);
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
// read
|
|
16
|
+
function readFile(filePath) {
|
|
17
|
+
return fs.readFileSync(filePath, "utf-8");
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
// write
|
|
21
|
+
function writeFile(filePath, content) {
|
|
22
|
+
fs.writeFileSync(filePath, content);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// error handler
|
|
26
|
+
function handleError(e) {
|
|
27
|
+
console.error("ROUTE USE ERROR:", e.message);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export default startFunc;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { locateSource } from "./AddTableName/steps/locateSource.js";
|
|
2
|
+
import { locateDestination } from "./AddTableName/steps/locateDestination.js";
|
|
3
|
+
import { createFolder } from "../../core/createFolder.js";
|
|
4
|
+
import UpdateRoutesJs from "./AddTableName/steps/UpdateRoutesJs/index.js";
|
|
5
|
+
import { updateEndPointsFile } from "./AddTableName/steps/updateEndPointsFile.js";
|
|
6
|
+
import { updateConfigFile } from "./AddTableName/steps/updateConfig.js";
|
|
7
|
+
|
|
8
|
+
import { announce } from "./AddTableName/steps/announce.js";
|
|
9
|
+
|
|
10
|
+
import resolveFolderName from "./AddTableName/steps/resolveFolderName.js";
|
|
11
|
+
|
|
12
|
+
export default ({ folderName = "", toPath, isAnnounce = true, checkBeforeCreate = true }) => {
|
|
13
|
+
const localToPath = toPath;
|
|
14
|
+
|
|
15
|
+
const resolvedFolderName = resolveFolderName({
|
|
16
|
+
name: folderName
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
if (resolvedFolderName.KTF === false) {
|
|
20
|
+
console.log(resolvedFolderName.KReason);
|
|
21
|
+
|
|
22
|
+
return folderName;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const source = locateSource();
|
|
26
|
+
const destination = locateDestination({
|
|
27
|
+
inResolvedFolderName: resolvedFolderName,
|
|
28
|
+
toPath: localToPath
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const createFolderResponse = createFolder({
|
|
32
|
+
source, destination,
|
|
33
|
+
isAnnounce, checkBeforeCreate
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
if (createFolderResponse.KTF) {
|
|
37
|
+
UpdateRoutesJs({
|
|
38
|
+
appJsPath: `${localToPath}/routes.js`,
|
|
39
|
+
endpoint: resolvedFolderName
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
updateEndPointsFile({
|
|
43
|
+
filePath: `${destination}/end-points.js`,
|
|
44
|
+
inTableName: resolvedFolderName
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
updateConfigFile({
|
|
48
|
+
inEndpointFolder: destination,
|
|
49
|
+
inTableName: resolvedFolderName
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
if (isAnnounce) announce({ inResolvedFolderName: resolvedFolderName });
|
|
54
|
+
|
|
55
|
+
return resolvedFolderName;
|
|
56
|
+
};
|
package/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "json-crud-ui",
|
|
3
|
+
"version": "1.1.1",
|
|
4
|
+
"description": "working on single js of express",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"cli",
|
|
7
|
+
"scaffold",
|
|
8
|
+
"templates",
|
|
9
|
+
"node",
|
|
10
|
+
"project-generator"
|
|
11
|
+
],
|
|
12
|
+
"dependencies": {
|
|
13
|
+
},
|
|
14
|
+
"type": "module",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": "./index.js"
|
|
17
|
+
},
|
|
18
|
+
"bin": {
|
|
19
|
+
"json-crud-ui": "./bin/cli.js"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"bin/",
|
|
23
|
+
"index.js",
|
|
24
|
+
"README.md",
|
|
25
|
+
"LICENSE"
|
|
26
|
+
],
|
|
27
|
+
"homepage": "https://cli.keshavsoft.com",
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "https://github.com/keshavsoft/json-crud-ui"
|
|
31
|
+
},
|
|
32
|
+
"bugs": {
|
|
33
|
+
"url": "https://github.com/keshavsoft/json-crud-ui/issues"
|
|
34
|
+
}
|
|
35
|
+
}
|