swaggerjsontoapidocs 1.1.0 → 1.2.0

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.
@@ -42,6 +42,8 @@ const promises_1 = require("fs/promises");
42
42
  const path = __importStar(require("path"));
43
43
  const chalk_1 = __importDefault(require("chalk"));
44
44
  const prettier_1 = require("prettier");
45
+ const os_1 = __importDefault(require("os"));
46
+ const child_process_1 = require("child_process");
45
47
  const mainFolderOutPut = path.join(__dirname, "api_docs");
46
48
  let urlSwaggerJson = "";
47
49
  let basepath = "";
@@ -142,6 +144,30 @@ async function makeFileContainer(endpoints, foldersName) {
142
144
  }
143
145
  }
144
146
  console.log(`💾 show result ---> ${mainFolderOutPut}`);
147
+ openFileManager(mainFolderOutPut);
148
+ }
149
+ function openFileManager(fullPath) {
150
+ const platform = os_1.default.platform();
151
+ let command = "";
152
+ switch (platform) {
153
+ case "win32":
154
+ command = `explorer "${fullPath}"`;
155
+ break;
156
+ case "darwin":
157
+ command = `open "${fullPath}"`;
158
+ break;
159
+ case "linux":
160
+ command = `xdg-open "${fullPath}"`;
161
+ break;
162
+ default:
163
+ console.error(`Platform ${platform} is not supported.`);
164
+ return;
165
+ }
166
+ (0, child_process_1.exec)(command, (error) => {
167
+ if (error) {
168
+ console.error(`Error attempting to open folder: ${error.message}`);
169
+ }
170
+ });
145
171
  }
146
172
  async function formatWhitPrettier(filePath) {
147
173
  const content = await (0, promises_1.readFile)(filePath, "utf8");
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "swaggerjsontoapidocs",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "script to convert swagger json to api docs, this help us to consume functions and center all endpoints in one place",
5
5
  "main": "index.ts",
6
6
  "scripts": {
7
7
  "build": "tsc",
8
8
  "api": "ts-node ./src/",
9
9
  "dist": "node ./dist/",
10
- "lint": "eslint ."
10
+ "lint": "eslint .",
11
+ "prepublishOnly": "npm run build"
11
12
  },
12
13
  "author": "Esteban Fernandez",
13
14
  "license": "ISC",
@@ -27,7 +28,8 @@
27
28
  },
28
29
  "files": [
29
30
  "dist",
30
- "package.json"
31
+ "package.json",
32
+ "!dist/api_docs"
31
33
  ],
32
34
  "engines": {
33
35
  "node": ">=15.0.0"