@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.
@@ -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 directoryPath = path.join(__dirname, "src/opengeodeweb_back");
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
- function return_json_schema(directoryPath, folder_path) {
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.replace(/^.*[\\/]/, "").replace(".json", "");
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 = { $id: currentSchema["$id"], ...currentSchema };
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
- const jsonDataStructure = return_json_schema(directoryPath, "ogw_back");
51
- console.log("jsonDataStructure", jsonDataStructure);
52
- const outputFile = path.join("./", "schemas.json");
53
- fs.writeFileSync(outputFile, JSON.stringify(jsonDataStructure, null, 2));
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
- {"name":"@geode/opengeodeweb-back","scripts":{"json":"node generate_schemas.js"},"dependencies":{"glob":"^10.3.10"},"exports":"./schemas.json","version":"0.0.4","description":"","main":"generate_schemas.js","repository":{"type":"git","url":"git+https://github.com/Geode-solutions/OpenGeodeWeb-Back.git"},"author":{"name":"Geode-solutions","email":"contact@geode-solutions.com","url":"https://geode-solutions.com/"},"license":"MIT","bugs":{"url":"https://github.com/Geode-solutions/OpenGeodeWeb-Back/issues"},"homepage":"https://github.com/Geode-solutions/OpenGeodeWeb-Back","publishConfig":{"access":"public"},"files":["schemas.json"]}
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
- "routes": {
2
+ "opengeodeweb_back": {
3
3
  "upload_file": {
4
- "$id": "ogw_back/routes/upload_file",
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": "ogw_back/routes/missing_files",
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": "ogw_back/routes/geographic_coordinate_systems",
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": "ogw_back/routes/geode_objects_and_output_extensions",
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": "ogw_back/routes/allowed_objects",
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": "ogw_back/routes/allowed_files",
102
+ "$id": "opengeodeweb_back/allowed_files",
103
103
  "route": "/allowed_files",
104
104
  "methods": [
105
105
  "POST"