@geode/opengeodeweb-back 0.0.4 → 3.3.0-rc.18
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 +38 -11
- package/package.json +33 -1
- package/schemas.json +7 -7
package/generate_schemas.js
CHANGED
|
@@ -1,12 +1,30 @@
|
|
|
1
1
|
const fs = require("fs");
|
|
2
2
|
const path = require("path");
|
|
3
3
|
const glob = require("glob");
|
|
4
|
+
const process = require("process");
|
|
4
5
|
|
|
5
|
-
const
|
|
6
|
+
const findDirectoryPath = (targetDirectoryName) => {
|
|
7
|
+
const pathToCheck = path.join(process.cwd(), targetDirectoryName);
|
|
8
|
+
const folders = fs
|
|
9
|
+
.readdirSync(pathToCheck, { withFileTypes: true })
|
|
10
|
+
.filter(
|
|
11
|
+
(folder) => folder.isDirectory() && !folder.name.endsWith(".egg-info")
|
|
12
|
+
)
|
|
13
|
+
.map((folder) => ({
|
|
14
|
+
name: folder.name,
|
|
15
|
+
path: path.join(pathToCheck, folder.name),
|
|
16
|
+
}));
|
|
17
|
+
const routesDirectory = path.join(folders[0].path, "routes");
|
|
18
|
+
return [routesDirectory, folders[0].name];
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const [directoryPath, project_name] = findDirectoryPath("src/");
|
|
6
22
|
|
|
7
|
-
|
|
23
|
+
const outputFile = path.join(process.cwd(), "schemas.json");
|
|
24
|
+
|
|
25
|
+
function return_json_schema(directoryPath, folder_path, project_name) {
|
|
8
26
|
const folders = fs
|
|
9
|
-
.readdirSync(directoryPath, { withFileTypes: true })
|
|
27
|
+
.readdirSync(path.normalize(directoryPath), { withFileTypes: true })
|
|
10
28
|
.filter((folder) => folder.isDirectory())
|
|
11
29
|
.map((folder) => ({
|
|
12
30
|
name: folder.name,
|
|
@@ -21,9 +39,11 @@ function return_json_schema(directoryPath, folder_path) {
|
|
|
21
39
|
try {
|
|
22
40
|
const fileContent = fs.readFileSync(filePath, "utf8");
|
|
23
41
|
var jsonData = JSON.parse(fileContent);
|
|
24
|
-
var filename = filePath
|
|
42
|
+
var filename = filePath
|
|
43
|
+
.replace(/^.*[\\/]/, "")
|
|
44
|
+
.replace(/\.[^/.]+$/, "");
|
|
25
45
|
var route = jsonData["route"];
|
|
26
|
-
jsonData["$id"] = folder_path + route;
|
|
46
|
+
jsonData["$id"] = project_name + folder_path + route;
|
|
27
47
|
schemas[filename] = jsonData;
|
|
28
48
|
} catch (error) {
|
|
29
49
|
console.error(
|
|
@@ -34,22 +54,29 @@ function return_json_schema(directoryPath, folder_path) {
|
|
|
34
54
|
});
|
|
35
55
|
folders_schemas = Object.keys(schemas).reduce((acc, key) => {
|
|
36
56
|
const currentSchema = schemas[key];
|
|
37
|
-
const modifiedSchema = {
|
|
57
|
+
const modifiedSchema = {
|
|
58
|
+
$id: path.join(folder_path, currentSchema["$id"]),
|
|
59
|
+
...currentSchema,
|
|
60
|
+
};
|
|
38
61
|
acc[key] = modifiedSchema;
|
|
39
62
|
return acc;
|
|
40
63
|
}, folders_schemas);
|
|
41
64
|
} else {
|
|
42
65
|
var new_folder_path = folder_path + "/" + folder.name;
|
|
43
|
-
var test = return_json_schema(folder.path, new_folder_path);
|
|
66
|
+
var test = return_json_schema(folder.path, new_folder_path, project_name);
|
|
44
67
|
folders_schemas[folder.name] = test;
|
|
45
68
|
}
|
|
46
69
|
});
|
|
47
70
|
return folders_schemas;
|
|
48
71
|
}
|
|
49
72
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
73
|
+
if (fs.existsSync(outputFile)) {
|
|
74
|
+
fs.unlinkSync(outputFile);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const finalJson = {};
|
|
78
|
+
finalJson[project_name] = return_json_schema(directoryPath, "", project_name);
|
|
79
|
+
|
|
80
|
+
fs.writeFileSync(outputFile, JSON.stringify(finalJson, null, 2));
|
|
54
81
|
|
|
55
82
|
console.log("Fichier JSON créé avec succès :", outputFile);
|
package/package.json
CHANGED
|
@@ -1 +1,33 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"name": "@geode/opengeodeweb-back",
|
|
3
|
+
"scripts": {
|
|
4
|
+
"json": "node generate_schemas.js"
|
|
5
|
+
},
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"glob": "^10.3.10"
|
|
8
|
+
},
|
|
9
|
+
"exports": "./schemas.json",
|
|
10
|
+
"version": "3.3.0-rc.18",
|
|
11
|
+
"description": "",
|
|
12
|
+
"main": "generate_schemas.js",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/Geode-solutions/OpenGeodeWeb-Back.git"
|
|
16
|
+
},
|
|
17
|
+
"author": {
|
|
18
|
+
"name": "Geode-solutions",
|
|
19
|
+
"email": "contact@geode-solutions.com",
|
|
20
|
+
"url": "https://geode-solutions.com/"
|
|
21
|
+
},
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"bugs": {
|
|
24
|
+
"url": "https://github.com/Geode-solutions/OpenGeodeWeb-Back/issues"
|
|
25
|
+
},
|
|
26
|
+
"homepage": "https://github.com/Geode-solutions/OpenGeodeWeb-Back",
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"access": "public"
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"schemas.json"
|
|
32
|
+
]
|
|
33
|
+
}
|
package/schemas.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
2
|
+
"opengeodeweb_back": {
|
|
3
3
|
"upload_file": {
|
|
4
|
-
"$id": "
|
|
4
|
+
"$id": "opengeodeweb_back/upload_file",
|
|
5
5
|
"route": "/upload_file",
|
|
6
6
|
"methods": [
|
|
7
7
|
"OPTIONS",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"additionalProperties": false
|
|
17
17
|
},
|
|
18
18
|
"missing_files": {
|
|
19
|
-
"$id": "
|
|
19
|
+
"$id": "opengeodeweb_back/missing_files",
|
|
20
20
|
"route": "/missing_files",
|
|
21
21
|
"methods": [
|
|
22
22
|
"POST"
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"additionalProperties": false
|
|
38
38
|
},
|
|
39
39
|
"geographic_coordinate_systems": {
|
|
40
|
-
"$id": "
|
|
40
|
+
"$id": "opengeodeweb_back/geographic_coordinate_systems",
|
|
41
41
|
"route": "/geographic_coordinate_systems",
|
|
42
42
|
"methods": [
|
|
43
43
|
"POST"
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"additionalProperties": false
|
|
55
55
|
},
|
|
56
56
|
"geode_objects_and_output_extensions": {
|
|
57
|
-
"$id": "
|
|
57
|
+
"$id": "opengeodeweb_back/geode_objects_and_output_extensions",
|
|
58
58
|
"route": "/geode_objects_and_output_extensions",
|
|
59
59
|
"methods": [
|
|
60
60
|
"POST"
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"additionalProperties": false
|
|
76
76
|
},
|
|
77
77
|
"allowed_objects": {
|
|
78
|
-
"$id": "
|
|
78
|
+
"$id": "opengeodeweb_back/allowed_objects",
|
|
79
79
|
"route": "/allowed_objects",
|
|
80
80
|
"methods": [
|
|
81
81
|
"POST"
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
"additionalProperties": false
|
|
100
100
|
},
|
|
101
101
|
"allowed_files": {
|
|
102
|
-
"$id": "
|
|
102
|
+
"$id": "opengeodeweb_back/allowed_files",
|
|
103
103
|
"route": "/allowed_files",
|
|
104
104
|
"methods": [
|
|
105
105
|
"POST"
|