kschema-fs-api-gen-post-actions 1.6.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 +323 -0
- package/bin/cli.js +12 -0
- package/bin/core/getLatestVersion.js +13 -0
- package/bin/core/loadRunner.js +9 -0
- package/bin/v5/core/createFolder.js +34 -0
- package/bin/v5/core/parseInput.js +9 -0
- package/bin/v5/core/resolveCommand.js +11 -0
- package/bin/v5/core/showUsage.js +49 -0
- package/bin/v5/start.js +22 -0
- package/bin/v5/tasks/actions/WithMail/actions.json +26 -0
- package/bin/v5/tasks/actions/WithMail/steps/UpdateRoutesJs/common/readFile.js +8 -0
- package/bin/v5/tasks/actions/WithMail/steps/UpdateRoutesJs/common/writeFile.js +10 -0
- package/bin/v5/tasks/actions/WithMail/steps/UpdateRoutesJs/updateImports/buildImport.js +9 -0
- package/bin/v5/tasks/actions/WithMail/steps/UpdateRoutesJs/updateImports/checkDuplicate.js +8 -0
- package/bin/v5/tasks/actions/WithMail/steps/UpdateRoutesJs/updateImports/findInsertIndex.js +10 -0
- package/bin/v5/tasks/actions/WithMail/steps/UpdateRoutesJs/updateImports/index.js +47 -0
- package/bin/v5/tasks/actions/WithMail/steps/UpdateRoutesJs/updateUse/buildUseLine.js +5 -0
- package/bin/v5/tasks/actions/WithMail/steps/UpdateRoutesJs/updateUse/checkDuplicate.js +9 -0
- package/bin/v5/tasks/actions/WithMail/steps/UpdateRoutesJs/updateUse/findInsertIndex.js +10 -0
- package/bin/v5/tasks/actions/WithMail/steps/UpdateRoutesJs/updateUse/index.js +56 -0
- package/bin/v5/tasks/actions/WithMail/steps/announce.js +9 -0
- package/bin/v5/tasks/actions/WithMail/steps/createFolder.js +7 -0
- package/bin/v5/tasks/actions/WithMail/steps/createHttpFile.js +12 -0
- package/bin/v5/tasks/actions/WithMail/steps/decideTemplate.js +3 -0
- package/bin/v5/tasks/actions/WithMail/steps/locateDestination.js +7 -0
- package/bin/v5/tasks/actions/WithMail/steps/locateSource.js +18 -0
- package/bin/v5/tasks/actions/WithMail/steps/resolveFolderName.js +20 -0
- package/bin/v5/tasks/actions/WithMail/steps/updateAppJs.js +7 -0
- package/bin/v5/tasks/actions/WithMail/steps/updateEndPointsFile.js +30 -0
- package/bin/v5/tasks/actions/WithMail/steps/updateEndPointsJs.js +16 -0
- package/bin/v5/tasks/actions/WithMail/template/v1/controller.js +28 -0
- package/bin/v5/tasks/actions/WithMail/template/v1/errors.js +11 -0
- package/bin/v5/tasks/actions/WithMail/template/v1/middleware.js +19 -0
- package/bin/v5/tasks/actions/WithMail/template/v1/service.js +44 -0
- package/bin/v5/tasks/actions/WithMail/template/v2/Mail/sendMailCC.js +45 -0
- package/bin/v5/tasks/actions/WithMail/template/v2/Mail/welcome.html +213 -0
- package/bin/v5/tasks/actions/WithMail/template/v2/controller.js +24 -0
- package/bin/v5/tasks/actions/WithMail/template/v2/errors.js +11 -0
- package/bin/v5/tasks/actions/WithMail/template/v2/middleware.js +19 -0
- package/bin/v5/tasks/actions/WithMail/template/v2/rest.http +7 -0
- package/bin/v5/tasks/actions/WithMail/template/v2/service.js +18 -0
- package/bin/v5/tasks/actions/WithMail/template/v3/Mail/sendMailCC.js +45 -0
- package/bin/v5/tasks/actions/WithMail/template/v3/Mail/welcome.html +213 -0
- package/bin/v5/tasks/actions/WithMail/template/v3/config/getSchema.js +20 -0
- package/bin/v5/tasks/actions/WithMail/template/v3/controller.js +27 -0
- package/bin/v5/tasks/actions/WithMail/template/v3/errors.js +11 -0
- package/bin/v5/tasks/actions/WithMail/template/v3/getData.js +11 -0
- package/bin/v5/tasks/actions/WithMail/template/v3/getSchema.js +11 -0
- package/bin/v5/tasks/actions/WithMail/template/v3/helpers/buildMutate.js +32 -0
- package/bin/v5/tasks/actions/WithMail/template/v3/helpers/buildQuery.js +32 -0
- package/bin/v5/tasks/actions/WithMail/template/v3/helpers/file/read.js +7 -0
- package/bin/v5/tasks/actions/WithMail/template/v3/helpers/file/write.js +5 -0
- package/bin/v5/tasks/actions/WithMail/template/v3/helpers/pkHelper.js +19 -0
- package/bin/v5/tasks/actions/WithMail/template/v3/helpers/validate.js +27 -0
- package/bin/v5/tasks/actions/WithMail/template/v3/helpers/validateHelper.js +27 -0
- package/bin/v5/tasks/actions/WithMail/template/v3/helpers/validators/default.js +5 -0
- package/bin/v5/tasks/actions/WithMail/template/v3/helpers/validators/enum.js +7 -0
- package/bin/v5/tasks/actions/WithMail/template/v3/helpers/validators/length.js +11 -0
- package/bin/v5/tasks/actions/WithMail/template/v3/helpers/validators/minMax.js +11 -0
- package/bin/v5/tasks/actions/WithMail/template/v3/helpers/validators/pattern.js +8 -0
- package/bin/v5/tasks/actions/WithMail/template/v3/helpers/validators/required.js +5 -0
- package/bin/v5/tasks/actions/WithMail/template/v3/helpers/validators/type.js +15 -0
- package/bin/v5/tasks/actions/WithMail/template/v3/helpers/validators/unique.js +8 -0
- package/bin/v5/tasks/actions/WithMail/template/v3/insertBase.js +9 -0
- package/bin/v5/tasks/actions/WithMail/template/v3/insertGenPk.js +31 -0
- package/bin/v5/tasks/actions/WithMail/template/v3/middleware.js +19 -0
- package/bin/v5/tasks/actions/WithMail/template/v3/rest.http +7 -0
- package/bin/v5/tasks/actions/WithMail/template/v3/service.js +16 -0
- package/bin/v5/tasks/actions/withMail.js +60 -0
- package/bin/v5/tasks/core/createFolder.js +34 -0
- package/bin/v5/tasks/core/parseInput.js +12 -0
- package/bin/v5/tasks/core/resolveCommand.js +24 -0
- package/bin/v5/tasks/core/showUsage.js +43 -0
- package/bin/v6/core/createFolder.js +34 -0
- package/bin/v6/core/parseInput.js +9 -0
- package/bin/v6/core/resolveCommand.js +11 -0
- package/bin/v6/core/showUsage.js +49 -0
- package/bin/v6/start.js +22 -0
- package/bin/v6/tasks/actions/InsertGenPk/actions.json +26 -0
- package/bin/v6/tasks/actions/InsertGenPk/steps/UpdateRoutesJs/common/readFile.js +8 -0
- package/bin/v6/tasks/actions/InsertGenPk/steps/UpdateRoutesJs/common/writeFile.js +10 -0
- package/bin/v6/tasks/actions/InsertGenPk/steps/UpdateRoutesJs/updateImports/buildImport.js +9 -0
- package/bin/v6/tasks/actions/InsertGenPk/steps/UpdateRoutesJs/updateImports/checkDuplicate.js +8 -0
- package/bin/v6/tasks/actions/InsertGenPk/steps/UpdateRoutesJs/updateImports/findInsertIndex.js +10 -0
- package/bin/v6/tasks/actions/InsertGenPk/steps/UpdateRoutesJs/updateImports/index.js +47 -0
- package/bin/v6/tasks/actions/InsertGenPk/steps/UpdateRoutesJs/updateUse/buildUseLine.js +5 -0
- package/bin/v6/tasks/actions/InsertGenPk/steps/UpdateRoutesJs/updateUse/checkDuplicate.js +9 -0
- package/bin/v6/tasks/actions/InsertGenPk/steps/UpdateRoutesJs/updateUse/findInsertIndex.js +10 -0
- package/bin/v6/tasks/actions/InsertGenPk/steps/UpdateRoutesJs/updateUse/index.js +56 -0
- package/bin/v6/tasks/actions/InsertGenPk/steps/announce.js +9 -0
- package/bin/v6/tasks/actions/InsertGenPk/steps/createFolder.js +7 -0
- package/bin/v6/tasks/actions/InsertGenPk/steps/createHttpFile.js +12 -0
- package/bin/v6/tasks/actions/InsertGenPk/steps/decideTemplate.js +3 -0
- package/bin/v6/tasks/actions/InsertGenPk/steps/locateDestination.js +7 -0
- package/bin/v6/tasks/actions/InsertGenPk/steps/locateSource.js +18 -0
- package/bin/v6/tasks/actions/InsertGenPk/steps/resolveFolderName.js +20 -0
- package/bin/v6/tasks/actions/InsertGenPk/steps/updateAppJs.js +7 -0
- package/bin/v6/tasks/actions/InsertGenPk/steps/updateEndPointsFile.js +30 -0
- package/bin/v6/tasks/actions/InsertGenPk/steps/updateEndPointsJs.js +16 -0
- package/bin/v6/tasks/actions/InsertGenPk/template/v1/config/getSchema.js +20 -0
- package/bin/v6/tasks/actions/InsertGenPk/template/v1/controller.js +27 -0
- package/bin/v6/tasks/actions/InsertGenPk/template/v1/errors.js +11 -0
- package/bin/v6/tasks/actions/InsertGenPk/template/v1/getData.js +11 -0
- package/bin/v6/tasks/actions/InsertGenPk/template/v1/getSchema.js +11 -0
- package/bin/v6/tasks/actions/InsertGenPk/template/v1/helpers/buildMutate.js +32 -0
- package/bin/v6/tasks/actions/InsertGenPk/template/v1/helpers/buildQuery.js +32 -0
- package/bin/v6/tasks/actions/InsertGenPk/template/v1/helpers/file/read.js +7 -0
- package/bin/v6/tasks/actions/InsertGenPk/template/v1/helpers/file/write.js +5 -0
- package/bin/v6/tasks/actions/InsertGenPk/template/v1/helpers/pkHelper.js +19 -0
- package/bin/v6/tasks/actions/InsertGenPk/template/v1/helpers/validate.js +27 -0
- package/bin/v6/tasks/actions/InsertGenPk/template/v1/helpers/validateHelper.js +27 -0
- package/bin/v6/tasks/actions/InsertGenPk/template/v1/helpers/validators/default.js +5 -0
- package/bin/v6/tasks/actions/InsertGenPk/template/v1/helpers/validators/enum.js +7 -0
- package/bin/v6/tasks/actions/InsertGenPk/template/v1/helpers/validators/length.js +11 -0
- package/bin/v6/tasks/actions/InsertGenPk/template/v1/helpers/validators/minMax.js +11 -0
- package/bin/v6/tasks/actions/InsertGenPk/template/v1/helpers/validators/pattern.js +8 -0
- package/bin/v6/tasks/actions/InsertGenPk/template/v1/helpers/validators/required.js +5 -0
- package/bin/v6/tasks/actions/InsertGenPk/template/v1/helpers/validators/type.js +15 -0
- package/bin/v6/tasks/actions/InsertGenPk/template/v1/helpers/validators/unique.js +8 -0
- package/bin/v6/tasks/actions/InsertGenPk/template/v1/insertBase.js +9 -0
- package/bin/v6/tasks/actions/InsertGenPk/template/v1/insertGenPk.js +31 -0
- package/bin/v6/tasks/actions/InsertGenPk/template/v1/middleware.js +19 -0
- package/bin/v6/tasks/actions/InsertGenPk/template/v1/rest.http +7 -0
- package/bin/v6/tasks/actions/InsertGenPk/template/v1/service.js +16 -0
- package/bin/v6/tasks/actions/WithMail/actions.json +26 -0
- package/bin/v6/tasks/actions/WithMail/steps/UpdateRoutesJs/common/readFile.js +8 -0
- package/bin/v6/tasks/actions/WithMail/steps/UpdateRoutesJs/common/writeFile.js +10 -0
- package/bin/v6/tasks/actions/WithMail/steps/UpdateRoutesJs/updateImports/buildImport.js +9 -0
- package/bin/v6/tasks/actions/WithMail/steps/UpdateRoutesJs/updateImports/checkDuplicate.js +8 -0
- package/bin/v6/tasks/actions/WithMail/steps/UpdateRoutesJs/updateImports/findInsertIndex.js +10 -0
- package/bin/v6/tasks/actions/WithMail/steps/UpdateRoutesJs/updateImports/index.js +47 -0
- package/bin/v6/tasks/actions/WithMail/steps/UpdateRoutesJs/updateUse/buildUseLine.js +5 -0
- package/bin/v6/tasks/actions/WithMail/steps/UpdateRoutesJs/updateUse/checkDuplicate.js +9 -0
- package/bin/v6/tasks/actions/WithMail/steps/UpdateRoutesJs/updateUse/findInsertIndex.js +10 -0
- package/bin/v6/tasks/actions/WithMail/steps/UpdateRoutesJs/updateUse/index.js +56 -0
- package/bin/v6/tasks/actions/WithMail/steps/announce.js +9 -0
- package/bin/v6/tasks/actions/WithMail/steps/createFolder.js +7 -0
- package/bin/v6/tasks/actions/WithMail/steps/createHttpFile.js +12 -0
- package/bin/v6/tasks/actions/WithMail/steps/decideTemplate.js +3 -0
- package/bin/v6/tasks/actions/WithMail/steps/locateDestination.js +7 -0
- package/bin/v6/tasks/actions/WithMail/steps/locateSource.js +18 -0
- package/bin/v6/tasks/actions/WithMail/steps/resolveFolderName.js +20 -0
- package/bin/v6/tasks/actions/WithMail/steps/updateAppJs.js +7 -0
- package/bin/v6/tasks/actions/WithMail/steps/updateEndPointsFile.js +30 -0
- package/bin/v6/tasks/actions/WithMail/steps/updateEndPointsJs.js +16 -0
- package/bin/v6/tasks/actions/WithMail/template/v1/controller.js +28 -0
- package/bin/v6/tasks/actions/WithMail/template/v1/errors.js +11 -0
- package/bin/v6/tasks/actions/WithMail/template/v1/middleware.js +19 -0
- package/bin/v6/tasks/actions/WithMail/template/v1/service.js +44 -0
- package/bin/v6/tasks/actions/WithMail/template/v2/Mail/sendMailCC.js +45 -0
- package/bin/v6/tasks/actions/WithMail/template/v2/Mail/welcome.html +213 -0
- package/bin/v6/tasks/actions/WithMail/template/v2/controller.js +24 -0
- package/bin/v6/tasks/actions/WithMail/template/v2/errors.js +11 -0
- package/bin/v6/tasks/actions/WithMail/template/v2/middleware.js +19 -0
- package/bin/v6/tasks/actions/WithMail/template/v2/rest.http +7 -0
- package/bin/v6/tasks/actions/WithMail/template/v2/service.js +18 -0
- package/bin/v6/tasks/actions/WithMail/template/v3/Mail/sendMailCC.js +45 -0
- package/bin/v6/tasks/actions/WithMail/template/v3/Mail/welcome.html +213 -0
- package/bin/v6/tasks/actions/WithMail/template/v3/config/getSchema.js +20 -0
- package/bin/v6/tasks/actions/WithMail/template/v3/controller.js +27 -0
- package/bin/v6/tasks/actions/WithMail/template/v3/errors.js +11 -0
- package/bin/v6/tasks/actions/WithMail/template/v3/getData.js +11 -0
- package/bin/v6/tasks/actions/WithMail/template/v3/getSchema.js +11 -0
- package/bin/v6/tasks/actions/WithMail/template/v3/helpers/buildMutate.js +32 -0
- package/bin/v6/tasks/actions/WithMail/template/v3/helpers/buildQuery.js +32 -0
- package/bin/v6/tasks/actions/WithMail/template/v3/helpers/file/read.js +7 -0
- package/bin/v6/tasks/actions/WithMail/template/v3/helpers/file/write.js +5 -0
- package/bin/v6/tasks/actions/WithMail/template/v3/helpers/pkHelper.js +19 -0
- package/bin/v6/tasks/actions/WithMail/template/v3/helpers/validate.js +27 -0
- package/bin/v6/tasks/actions/WithMail/template/v3/helpers/validateHelper.js +27 -0
- package/bin/v6/tasks/actions/WithMail/template/v3/helpers/validators/default.js +5 -0
- package/bin/v6/tasks/actions/WithMail/template/v3/helpers/validators/enum.js +7 -0
- package/bin/v6/tasks/actions/WithMail/template/v3/helpers/validators/length.js +11 -0
- package/bin/v6/tasks/actions/WithMail/template/v3/helpers/validators/minMax.js +11 -0
- package/bin/v6/tasks/actions/WithMail/template/v3/helpers/validators/pattern.js +8 -0
- package/bin/v6/tasks/actions/WithMail/template/v3/helpers/validators/required.js +5 -0
- package/bin/v6/tasks/actions/WithMail/template/v3/helpers/validators/type.js +15 -0
- package/bin/v6/tasks/actions/WithMail/template/v3/helpers/validators/unique.js +8 -0
- package/bin/v6/tasks/actions/WithMail/template/v3/insertBase.js +9 -0
- package/bin/v6/tasks/actions/WithMail/template/v3/insertGenPk.js +31 -0
- package/bin/v6/tasks/actions/WithMail/template/v3/middleware.js +19 -0
- package/bin/v6/tasks/actions/WithMail/template/v3/rest.http +7 -0
- package/bin/v6/tasks/actions/WithMail/template/v3/service.js +16 -0
- package/bin/v6/tasks/actions/insertGenPk.js +68 -0
- package/bin/v6/tasks/actions/withMail.js +60 -0
- package/bin/v6/tasks/core/createFolder.js +34 -0
- package/bin/v6/tasks/core/parseInput.js +12 -0
- package/bin/v6/tasks/core/resolveCommand.js +24 -0
- package/bin/v6/tasks/core/showUsage.js +43 -0
- package/index.js +34 -0
- package/package.json +37 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import fixEndpointsJs from "express-fix-any-js";
|
|
3
|
+
import generateRest from "kschema-fs-api-gen-rest";
|
|
4
|
+
|
|
5
|
+
import { locateSource } from "./InsertGenPk/steps/locateSource.js";
|
|
6
|
+
import { locateDestination } from "./InsertGenPk/steps/locateDestination.js";
|
|
7
|
+
import { createFolder } from "../../core/createFolder.js";
|
|
8
|
+
|
|
9
|
+
import updateEndPointsJs from "./InsertGenPk/steps/updateEndPointsJs.js";
|
|
10
|
+
// import createHttpFile from "./InsertGenPk/steps/createHttpFile.js";
|
|
11
|
+
|
|
12
|
+
import { announce } from "./InsertGenPk/steps/announce.js";
|
|
13
|
+
|
|
14
|
+
import resolveFolderName from "./InsertGenPk/steps/resolveFolderName.js";
|
|
15
|
+
import actions from "./InsertGenPk/actions.json" with { type: "json" };
|
|
16
|
+
|
|
17
|
+
const startFunc = async ({ cmd = "", toPath, isAnnounce = true, checkBeforeCreate = true,
|
|
18
|
+
toConfigPath
|
|
19
|
+
}) => {
|
|
20
|
+
|
|
21
|
+
const matched = actions;
|
|
22
|
+
|
|
23
|
+
const localToPath = toPath;
|
|
24
|
+
|
|
25
|
+
const resolvedFolderName = resolveFolderName({
|
|
26
|
+
name: cmd
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
if (resolvedFolderName.KTF === false) {
|
|
30
|
+
console.log(resolvedFolderName.KReason);
|
|
31
|
+
|
|
32
|
+
return;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const source = locateSource();
|
|
36
|
+
const destination = locateDestination({
|
|
37
|
+
inResolvedFolderName: resolvedFolderName,
|
|
38
|
+
toPath: localToPath
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const createFolderResponse = createFolder({
|
|
42
|
+
source, destination,
|
|
43
|
+
isAnnounce, checkBeforeCreate
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
if (createFolderResponse.KTF) {
|
|
47
|
+
const fromEndPointsJs = await fixEndpointsJs({
|
|
48
|
+
jsFilePath: path.join(localToPath, "end-points.js"),
|
|
49
|
+
inCheckLines: matched.endPointsJs
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
// createHttpFile({
|
|
53
|
+
// inTargetPath: path.join(localToPath, resolvedFolderName),
|
|
54
|
+
// toPath: process.cwd()
|
|
55
|
+
// });
|
|
56
|
+
|
|
57
|
+
generateRest({
|
|
58
|
+
toConfigPath,
|
|
59
|
+
toPath: path.join(localToPath, resolvedFolderName),
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
if (isAnnounce) announce({ inResolvedFolderName: resolvedFolderName });
|
|
64
|
+
|
|
65
|
+
return resolvedFolderName;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export default startFunc;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import fixEndpointsJs from "express-fix-any-js";
|
|
3
|
+
|
|
4
|
+
import { locateSource } from "./WithMail/steps/locateSource.js";
|
|
5
|
+
import { locateDestination } from "./WithMail/steps/locateDestination.js";
|
|
6
|
+
import { createFolder } from "../../core/createFolder.js";
|
|
7
|
+
|
|
8
|
+
import updateEndPointsJs from "./WithMail/steps/updateEndPointsJs.js";
|
|
9
|
+
import createHttpFile from "./WithMail/steps/createHttpFile.js";
|
|
10
|
+
|
|
11
|
+
import { announce } from "./WithMail/steps/announce.js";
|
|
12
|
+
|
|
13
|
+
import resolveFolderName from "./WithMail/steps/resolveFolderName.js";
|
|
14
|
+
import actions from "./WithMail/actions.json" with { type: "json" };
|
|
15
|
+
|
|
16
|
+
const startFunc = async ({ cmd = "", toPath, isAnnounce = true, checkBeforeCreate = true }) => {
|
|
17
|
+
|
|
18
|
+
const matched = actions;
|
|
19
|
+
|
|
20
|
+
const localToPath = toPath;
|
|
21
|
+
|
|
22
|
+
const resolvedFolderName = resolveFolderName({
|
|
23
|
+
name: cmd
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
if (resolvedFolderName.KTF === false) {
|
|
27
|
+
console.log(resolvedFolderName.KReason);
|
|
28
|
+
|
|
29
|
+
return;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const source = locateSource();
|
|
33
|
+
const destination = locateDestination({
|
|
34
|
+
inResolvedFolderName: resolvedFolderName,
|
|
35
|
+
toPath: localToPath
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const createFolderResponse = createFolder({
|
|
39
|
+
source, destination,
|
|
40
|
+
isAnnounce, checkBeforeCreate
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
if (createFolderResponse.KTF) {
|
|
44
|
+
const fromEndPointsJs = await fixEndpointsJs({
|
|
45
|
+
jsFilePath: path.join(localToPath, "end-points.js"),
|
|
46
|
+
inCheckLines: matched.endPointsJs
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
createHttpFile({
|
|
50
|
+
inTargetPath: path.join(localToPath, resolvedFolderName),
|
|
51
|
+
toPath: process.cwd()
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
if (isAnnounce) announce({ inResolvedFolderName: resolvedFolderName });
|
|
56
|
+
|
|
57
|
+
return resolvedFolderName;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export default startFunc;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
|
|
3
|
+
export const createFolder = ({ source, destination, checkBeforeCreate = false, isAnnounce = true }) => {
|
|
4
|
+
if (checkBeforeCreate) {
|
|
5
|
+
return createFolderWithCheck({ source, destination, isAnnounce });
|
|
6
|
+
} else {
|
|
7
|
+
return createOnly({ source, destination });
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const createOnly = ({ source, destination }) => {
|
|
12
|
+
fs.mkdirSync(destination, { recursive: true });
|
|
13
|
+
|
|
14
|
+
fs.cpSync(source, destination, { recursive: true });
|
|
15
|
+
|
|
16
|
+
return {
|
|
17
|
+
KTF: true
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const createFolderWithCheck = ({ source, destination, isAnnounce }) => {
|
|
22
|
+
if (fs.existsSync(destination)) {
|
|
23
|
+
if (isAnnounce) console.log("Folder already exists :", destination);
|
|
24
|
+
|
|
25
|
+
return {
|
|
26
|
+
KTF: false,
|
|
27
|
+
KReason: "Folder already exists"
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
if (isAnnounce) console.log("Folder created :", destination);
|
|
32
|
+
|
|
33
|
+
return createOnly({ source, destination });
|
|
34
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import StartEndPoint from "../commands/startEndPoint.js";
|
|
2
|
+
import AddSubRoute from "../commands/addSubRoute.js";
|
|
3
|
+
import AddTableName from "../tasks/tables/addTableName.js";
|
|
4
|
+
// import ShowAll from "../commands/showAll.js";
|
|
5
|
+
import Insert from "../tasks/actions/insert.js";
|
|
6
|
+
import ShowAll from "../tasks/actions/showAll.js";
|
|
7
|
+
|
|
8
|
+
import CreateApi from "../Orchestration/CreateApi/createApi.js";
|
|
9
|
+
import InsertApi from "../Orchestration/InsertApi/insertApi.js";
|
|
10
|
+
|
|
11
|
+
// resolveCommand.js
|
|
12
|
+
const map = {
|
|
13
|
+
StartEndPoint,
|
|
14
|
+
AddSubRoute,
|
|
15
|
+
AddTableName,
|
|
16
|
+
ShowAll,
|
|
17
|
+
CreateApi,
|
|
18
|
+
InsertApi,
|
|
19
|
+
Insert
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default function resolveCommand(cmd) {
|
|
23
|
+
return map[cmd] || null;
|
|
24
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
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}🚀 KSchema Api Generator 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}StartEndPoint${r} Initialize a new folder and files
|
|
32
|
+
${g}CreateApi${r} Creates new end point and hooks to app.js
|
|
33
|
+
${g}InsertApi${r} Creates new InsertApi end point and hooks to app.js
|
|
34
|
+
|
|
35
|
+
${y}Examples:${r}
|
|
36
|
+
${gray}npx @keshavsoft/kschema-api-gen StartEndPoint${r}
|
|
37
|
+
${gray}npx @keshavsoft/kschema-api-gen CreateApi Api/V1/journals/ShowAll${r}
|
|
38
|
+
${gray}npx @keshavsoft/kschema-api-gen InsertApi Api/V1/journals/Insert${r}
|
|
39
|
+
|
|
40
|
+
${y}Tip:${r}
|
|
41
|
+
${gray}npm i -g @keshavsoft/kschema-api-gen${r}
|
|
42
|
+
`);
|
|
43
|
+
}
|
package/index.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import getLatestVersion from "./bin/core/getLatestVersion.js";
|
|
2
|
+
|
|
3
|
+
const load = async (cmd) => {
|
|
4
|
+
const module = await import(`./bin/${getLatestVersion()}/tasks/actions/${cmd}.js`);
|
|
5
|
+
|
|
6
|
+
return module.default; // Returns a function
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const withMail = async ({ toPath }) => {
|
|
10
|
+
const commandToSend = "withMail";
|
|
11
|
+
|
|
12
|
+
const commandFunction = await load(commandToSend);
|
|
13
|
+
// console.log(" ...args :", args);
|
|
14
|
+
await commandFunction({
|
|
15
|
+
toPath,
|
|
16
|
+
cmd: "WithMail"
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const insertGenPk = async ({ toPath, showLog, toConfigPath }) => {
|
|
21
|
+
const commandToSend = "insertGenPk";
|
|
22
|
+
|
|
23
|
+
const commandFunction = await load(commandToSend);
|
|
24
|
+
// console.log(" ...args :", args);
|
|
25
|
+
await commandFunction({
|
|
26
|
+
toPath,
|
|
27
|
+
cmd: "WithMail",
|
|
28
|
+
toConfigPath
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export {
|
|
33
|
+
withMail, insertGenPk
|
|
34
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "kschema-fs-api-gen-post-actions",
|
|
3
|
+
"version": "1.6.2",
|
|
4
|
+
"description": "start from end points js, generate post methods",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"cli",
|
|
7
|
+
"scaffold",
|
|
8
|
+
"templates",
|
|
9
|
+
"node",
|
|
10
|
+
"project-generator"
|
|
11
|
+
],
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"express-fix-any-js": "^1.2.3",
|
|
14
|
+
"kschema-fs-api-gen-rest": "^1.3.2"
|
|
15
|
+
},
|
|
16
|
+
"type": "module",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": "./index.js"
|
|
19
|
+
},
|
|
20
|
+
"bin": {
|
|
21
|
+
"kschema-fs-api-gen-post-actions": "./bin/cli.js"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"bin/",
|
|
25
|
+
"index.js",
|
|
26
|
+
"README.md",
|
|
27
|
+
"LICENSE"
|
|
28
|
+
],
|
|
29
|
+
"homepage": "https://cli.keshavsoft.com",
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "https://github.com/keshavsoft/kschema-fs-api-gen-post-actions"
|
|
33
|
+
},
|
|
34
|
+
"bugs": {
|
|
35
|
+
"url": "https://github.com/keshavsoft/kschema-fs-api-gen-post-actions/issues"
|
|
36
|
+
}
|
|
37
|
+
}
|