@geode/opengeodeweb-back 5.4.0-rc.3 → 5.4.1-rc.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/generate_schemas.js +54 -12
- package/package.json +3 -3
package/generate_schemas.js
CHANGED
|
@@ -3,29 +3,55 @@ const path = require("path");
|
|
|
3
3
|
const glob = require("glob");
|
|
4
4
|
const process = require("process");
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
console.log("process.argv", process.argv);
|
|
7
|
+
|
|
8
|
+
var projectName = process.argv[2];
|
|
9
|
+
console.log("projectName", projectName);
|
|
10
|
+
var folderName = process.argv[3];
|
|
11
|
+
console.log("folderName", folderName);
|
|
12
|
+
var key = process.argv[4];
|
|
13
|
+
console.log("key", key);
|
|
14
|
+
var separator = process.argv[5];
|
|
15
|
+
console.log("separator", separator);
|
|
16
|
+
|
|
17
|
+
const findDirectoryPath = (targetDirectoryName, folderName) => {
|
|
18
|
+
const pathToCheck = path.join(
|
|
19
|
+
process.cwd(),
|
|
20
|
+
"/src",
|
|
21
|
+
"/",
|
|
22
|
+
targetDirectoryName
|
|
23
|
+
);
|
|
24
|
+
console.log("pathToCheck", pathToCheck);
|
|
25
|
+
|
|
8
26
|
const folders = fs
|
|
9
27
|
.readdirSync(pathToCheck, { withFileTypes: true })
|
|
10
28
|
.filter(
|
|
11
|
-
(folder) =>
|
|
29
|
+
(folder) =>
|
|
30
|
+
folder.isDirectory() &&
|
|
31
|
+
!folder.name.endsWith(".egg-info") &&
|
|
32
|
+
folder.name != "tests" &&
|
|
33
|
+
folder.name != "__pycache__" &&
|
|
34
|
+
folder.name.includes(folderName)
|
|
12
35
|
)
|
|
13
36
|
.map((folder) => ({
|
|
14
37
|
name: folder.name,
|
|
15
38
|
path: path.join(pathToCheck, folder.name),
|
|
16
39
|
}));
|
|
17
|
-
|
|
18
|
-
|
|
40
|
+
console.log("folders", folders);
|
|
41
|
+
const routesDirectory = path.join(folders[0].path);
|
|
42
|
+
return routesDirectory;
|
|
19
43
|
};
|
|
20
44
|
|
|
21
|
-
const
|
|
45
|
+
const directoryPath = findDirectoryPath(projectName, folderName);
|
|
22
46
|
|
|
23
47
|
const outputFile = path.join(process.cwd(), "schemas.json");
|
|
24
48
|
|
|
25
|
-
function return_json_schema(directoryPath, folder_path,
|
|
49
|
+
function return_json_schema(directoryPath, folder_path, projectName) {
|
|
50
|
+
console.log("return_json_schema", directoryPath, folder_path, projectName);
|
|
51
|
+
|
|
26
52
|
const folders = fs
|
|
27
53
|
.readdirSync(path.normalize(directoryPath), { withFileTypes: true })
|
|
28
|
-
.filter((folder) => folder.isDirectory())
|
|
54
|
+
.filter((folder) => folder.isDirectory() && folder.name != "__pycache__")
|
|
29
55
|
.map((folder) => ({
|
|
30
56
|
name: folder.name,
|
|
31
57
|
path: path.join(directoryPath, folder.name),
|
|
@@ -42,8 +68,24 @@ function return_json_schema(directoryPath, folder_path, project_name) {
|
|
|
42
68
|
var filename = filePath
|
|
43
69
|
.replace(/^.*[\\/]/, "")
|
|
44
70
|
.replace(/\.[^/.]+$/, "");
|
|
45
|
-
var route = jsonData[
|
|
46
|
-
|
|
71
|
+
var route = jsonData[key];
|
|
72
|
+
console.log("FOLDER PATH", projectName);
|
|
73
|
+
var values = [projectName, folder_path, route];
|
|
74
|
+
console.log("values", values);
|
|
75
|
+
values = values.map(function (x) {
|
|
76
|
+
console.log("x", x);
|
|
77
|
+
return x.replace("/", "").replace(".", "");
|
|
78
|
+
}); // first replace first . / by empty string
|
|
79
|
+
values = values.map(function (x) {
|
|
80
|
+
console.log("x", x);
|
|
81
|
+
return x.replaceAll("/", separator).replaceAll(".", separator);
|
|
82
|
+
}); // then replace all . / by separator
|
|
83
|
+
console.log("values", values);
|
|
84
|
+
jsonData["$id"] = values
|
|
85
|
+
.filter(function (val) {
|
|
86
|
+
return val;
|
|
87
|
+
})
|
|
88
|
+
.join(separator);
|
|
47
89
|
schemas[filename] = jsonData;
|
|
48
90
|
} catch (error) {
|
|
49
91
|
console.error(
|
|
@@ -63,7 +105,7 @@ function return_json_schema(directoryPath, folder_path, project_name) {
|
|
|
63
105
|
}, folders_schemas);
|
|
64
106
|
} else {
|
|
65
107
|
var new_folder_path = folder_path + "/" + folder.name;
|
|
66
|
-
var test = return_json_schema(folder.path, new_folder_path,
|
|
108
|
+
var test = return_json_schema(folder.path, new_folder_path, projectName);
|
|
67
109
|
folders_schemas[folder.name] = test;
|
|
68
110
|
}
|
|
69
111
|
});
|
|
@@ -75,6 +117,6 @@ if (fs.existsSync(outputFile)) {
|
|
|
75
117
|
}
|
|
76
118
|
|
|
77
119
|
const finalJson = {};
|
|
78
|
-
finalJson[
|
|
120
|
+
finalJson[projectName] = return_json_schema(directoryPath, "", projectName);
|
|
79
121
|
|
|
80
122
|
fs.writeFileSync(outputFile, JSON.stringify(finalJson, null, 2));
|
package/package.json
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geode/opengeodeweb-back",
|
|
3
|
+
"version": "5.4.1-rc.1",
|
|
4
|
+
"description": "",
|
|
3
5
|
"scripts": {
|
|
4
|
-
"json": "node generate_schemas.js"
|
|
6
|
+
"json": "node generate_schemas.js opengeodeweb_back routes route /"
|
|
5
7
|
},
|
|
6
8
|
"dependencies": {
|
|
7
9
|
"glob": "^10.3.10"
|
|
@@ -12,8 +14,6 @@
|
|
|
12
14
|
"require": "./schemas.json"
|
|
13
15
|
}
|
|
14
16
|
},
|
|
15
|
-
"version": "5.4.0-rc.3",
|
|
16
|
-
"description": "",
|
|
17
17
|
"main": "generate_schemas.js",
|
|
18
18
|
"repository": {
|
|
19
19
|
"type": "git",
|