@visulima/jsdoc-open-api 1.3.12 → 2.0.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.
- package/CHANGELOG.md +17 -0
- package/dist/{chunk-WCKT775T.js → chunk-GBW65CGH.js} +3 -3
- package/dist/chunk-GBW65CGH.js.map +1 -0
- package/dist/{chunk-L5IKCPR2.mjs → chunk-W7GBDROK.mjs} +3 -3
- package/dist/chunk-W7GBDROK.mjs.map +1 -0
- package/dist/cli/commander/index.js +2 -2
- package/dist/cli/commander/index.js.map +1 -1
- package/dist/cli/commander/index.mjs +1 -1
- package/dist/cli/commander/index.mjs.map +1 -1
- package/dist/cli/index.js +3 -3
- package/dist/cli/index.mjs +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +18 -18
- package/dist/chunk-L5IKCPR2.mjs.map +0 -1
- package/dist/chunk-WCKT775T.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
## @visulima/jsdoc-open-api [2.0.0](https://github.com/visulima/visulima/compare/@visulima/jsdoc-open-api@1.3.12...@visulima/jsdoc-open-api@2.0.0) (2023-08-28)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### ⚠ BREAKING CHANGES
|
|
5
|
+
|
|
6
|
+
* update minimum Node.js version requirement to 18
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* refactor query parsing and update dependencies ([#203](https://github.com/visulima/visulima/issues/203)) ([cf77427](https://github.com/visulima/visulima/commit/cf7742795f970ebeeb5da22a82fd17750028ee87))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Dependencies
|
|
15
|
+
|
|
16
|
+
* **@visulima/readdir:** upgraded to 2.0.0
|
|
17
|
+
|
|
1
18
|
## @visulima/jsdoc-open-api [1.3.12](https://github.com/visulima/visulima/compare/@visulima/jsdoc-open-api@1.3.11...@visulima/jsdoc-open-api@1.3.12) (2023-07-28)
|
|
2
19
|
|
|
3
20
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunkD7VYGB4A_js = require('./chunk-D7VYGB4A.js');
|
|
4
|
-
var readdir = require('@visulima/readdir');
|
|
5
|
-
var y = require('cli-progress');
|
|
6
4
|
var fs = require('fs');
|
|
7
5
|
var path = require('path');
|
|
8
6
|
var url = require('url');
|
|
7
|
+
var y = require('cli-progress');
|
|
8
|
+
var readdir = require('@visulima/readdir');
|
|
9
9
|
var P = require('read-pkg-up');
|
|
10
10
|
|
|
11
11
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -55,4 +55,4 @@ Swagger specification is ready, check the "${i}" file.`);},L=F;var _=(r,l=proces
|
|
|
55
55
|
exports.a = L;
|
|
56
56
|
exports.b = G;
|
|
57
57
|
//# sourceMappingURL=out.js.map
|
|
58
|
-
//# sourceMappingURL=chunk-
|
|
58
|
+
//# sourceMappingURL=chunk-GBW65CGH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli/command/generate-command.ts","../src/cli/command/init-command.ts"],"names":["lstatSync","mkdirSync","writeFileSync","dirname","normalize","pathToFileURL","cliProgress","collect","generateCommand","configName","paths","options","openapiConfig","config","multibar","spec","spec_builder_default","dir","files","bar","file","parsedJsDocumentFile","parse_file_default","comments_to_open_api_default","item","parsedSwaggerJsDocumentFile","validate_default","output","generate_command_default","existsSync","realpathSync","readPkgUp","initCommand","packageJsonPath","foundPackageJson","exportTemplate","package_","packagePath","init_command_default"],"mappings":"oEAAA,OAAS,aAAAA,EAAW,aAAAC,EAAW,iBAAAC,MAAqB,KACpD,OAAS,WAAAC,EAAS,aAAAC,MAAiB,OACnC,OAAS,iBAAAC,MAAqB,MAE9B,OAAOC,MAAiB,eACxB,OAAS,WAAAC,MAAe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,EAIxCjC,EACIO,EACA,GAAG0B,CAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAmCrB,EAGA,QAAQ,IAAI,YAAY1B,CAAU,GAAG,CACzC,EAEO6B,EAAQN","sourcesContent":["import { lstatSync, mkdirSync, writeFileSync } from \"node:fs\";\nimport { dirname, normalize } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport cliProgress from \"cli-progress\";\nimport { collect } from \"@visulima/readdir\";\n\nimport type { BaseDefinition } from \"../../exported.d\";\nimport jsDocumentCommentsToOpenApi from \"../../jsdoc/comments-to-open-api\";\nimport parseFile from \"../../parse-file\";\nimport SpecBuilder from \"../../spec-builder\";\nimport swaggerJsDocumentCommentsToOpenApi from \"../../swagger-jsdoc/comments-to-open-api\";\nimport validate from \"../../validate\";\n\nconst generateCommand = async (\n configName: string,\n paths: string[],\n options: {\n config?: string;\n output?: string;\n verbose?: boolean;\n veryVerbose?: boolean;\n },\n // eslint-disable-next-line sonarjs/cognitive-complexity\n): Promise<void> => {\n let openapiConfig: {\n exclude: string[];\n extensions?: string[];\n followSymlinks?: boolean;\n include?: ReadonlyArray<string> | string;\n swaggerDefinition: BaseDefinition;\n } = {\n exclude: [],\n swaggerDefinition: {} as BaseDefinition,\n };\n\n try {\n let config = await import(pathToFileURL(normalize(options.config ?? configName)).href);\n\n if (config?.default) {\n config = config.default;\n }\n\n openapiConfig = config;\n } catch {\n throw new Error(`No config file found, on: ${options.config ?? \".openapirc.js\"}\\n`);\n }\n\n const multibar = new cliProgress.MultiBar(\n {\n clearOnComplete: false,\n format: \"{value}/{total} | {bar} | {filename}\",\n hideCursor: true,\n },\n cliProgress.Presets.shades_grey,\n );\n const spec = new SpecBuilder(openapiConfig.swaggerDefinition);\n\n // eslint-disable-next-line no-restricted-syntax,unicorn/prevent-abbreviations\n for await (const dir of paths) {\n // Check if the path is a directory\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n lstatSync(dir).isDirectory();\n\n const files = await collect(dir, {\n extensions: openapiConfig.extensions ?? [\".js\", \".cjs\", \".mjs\", \".ts\", \".tsx\", \".jsx\", \".yaml\", \".yml\"],\n followSymlinks: openapiConfig.followSymlinks ?? false,\n match: openapiConfig.include,\n minimatchOptions: {\n match: {\n debug: options.verbose,\n matchBase: true,\n },\n skip: {\n debug: options.verbose,\n matchBase: true,\n },\n },\n skip: [...openapiConfig.exclude, \"node_modules/**\"],\n });\n\n if (options.verbose ?? options.veryVerbose) {\n // eslint-disable-next-line no-console\n console.log(`\\nFound ${files.length} files in ${dir}`);\n }\n\n if (options.veryVerbose) {\n // eslint-disable-next-line no-console\n console.log(files);\n }\n\n const bar = multibar.create(files.length, 0);\n\n files.forEach((file) => {\n if (options.verbose) {\n // eslint-disable-next-line no-console\n console.log(`Parsing file ${file}`);\n }\n\n bar.increment(1, { filename: dir });\n\n const parsedJsDocumentFile = parseFile(file, jsDocumentCommentsToOpenApi, options.verbose);\n\n spec.addData(parsedJsDocumentFile.map((item) => item.spec));\n\n const parsedSwaggerJsDocumentFile = parseFile(file, swaggerJsDocumentCommentsToOpenApi, options.verbose);\n\n spec.addData(parsedSwaggerJsDocumentFile.map((item) => item.spec));\n });\n }\n\n if (options.verbose) {\n // eslint-disable-next-line no-console\n console.log(\"Validating swagger spec\");\n }\n\n if (options.veryVerbose) {\n // eslint-disable-next-line no-console\n console.log(JSON.stringify(spec, null, 2));\n }\n\n await validate(JSON.parse(JSON.stringify(spec)) as Record<string, unknown>);\n\n const output = options.output ?? \"swagger.json\";\n\n multibar.stop();\n\n if (options.verbose) {\n // eslint-disable-next-line no-console\n console.log(`Written swagger spec to \"${output}\" file`);\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n mkdirSync(dirname(output), { recursive: true });\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n writeFileSync(output, JSON.stringify(spec, null, 2));\n\n // eslint-disable-next-line no-console\n console.log(`\\nSwagger specification is ready, check the \"${output}\" file.`);\n};\n\nexport default generateCommand;\n","import { existsSync, realpathSync, writeFileSync } from \"node:fs\";\nimport readPkgUp from \"read-pkg-up\";\n\nconst initCommand = (configName: string, packageJsonPath = process.cwd()): void => {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(configName)) {\n throw new Error(\"Config file already exists\");\n }\n\n const foundPackageJson = readPkgUp.sync({\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n cwd: realpathSync(packageJsonPath),\n });\n\n let exportTemplate = \"module.exports =\";\n\n if (foundPackageJson) {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n const { packageJson: package_, path: packagePath } = foundPackageJson;\n\n // eslint-disable-next-line no-console\n console.info(`Found package.json at \"${packagePath}\"`);\n\n if (package_[\"type\"] === \"module\") {\n // eslint-disable-next-line no-console\n console.info(\"Found package.json with type: module, using ES6 as export for the config file\");\n\n exportTemplate = \"export default\";\n }\n } else {\n // eslint-disable-next-line no-console\n console.info(\"No package.json found\");\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n writeFileSync(\n configName,\n `${exportTemplate} {\n exclude: [\n 'coverage/**',\n '.github/**',\n 'packages/*/test{,s}/**',\n '**/*.d.ts',\n 'test{,s}/**',\n 'test{,-*}.{js,cjs,mjs,ts,tsx,jsx,yaml,yml}',\n '**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx,yaml,yml}',\n '**/__tests__/**',\n '**/{ava,babel,nyc}.config.{js,cjs,mjs}',\n '**/jest.config.{js,cjs,mjs,ts}',\n '**/{karma,rollup,webpack}.config.js',\n '**/.{eslint,mocha}rc.{js,cjs}',\n '**/.{travis,yarnrc}.yml',\n '**/{docker-compose,docker}.yml',\n '**/.yamllint.{yaml,yml}',\n '**/node_modules/**',\n '**/pnpm-lock.yaml',\n '**/pnpm-workspace.yaml',\n '**/{package,package-lock}.json',\n '**/yarn.lock',\n '**/package.json5',\n '**/.next/**',\n ],\n followSymlinks: false,\n swaggerDefinition: {\n openapi: '3.0.0',\n info: {\n title: 'API',\n version: '1.0.0',\n },\n },\n};\n`,\n );\n\n // eslint-disable-next-line no-console\n console.log(`Created \"${configName}\"`);\n};\n\nexport default initCommand;\n"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { d, c, a, e, f } from './chunk-WHYPHVY6.mjs';
|
|
2
|
-
import { collect } from '@visulima/readdir';
|
|
3
|
-
import y from 'cli-progress';
|
|
4
2
|
import { lstatSync, mkdirSync, writeFileSync, existsSync, realpathSync } from 'fs';
|
|
5
3
|
import { normalize, dirname } from 'path';
|
|
6
4
|
import { pathToFileURL } from 'url';
|
|
5
|
+
import y from 'cli-progress';
|
|
6
|
+
import { collect } from '@visulima/readdir';
|
|
7
7
|
import P from 'read-pkg-up';
|
|
8
8
|
|
|
9
9
|
var F=async(r,l,e$1)=>{let o={exclude:[],swaggerDefinition:{}};try{let s=await import(pathToFileURL(normalize(e$1.config??r)).href);s?.default&&(s=s.default),o=s;}catch{throw new Error(`No config file found, on: ${e$1.config??".openapirc.js"}
|
|
@@ -47,4 +47,4 @@ Swagger specification is ready, check the "${i}" file.`);},L=F;var _=(r,l=proces
|
|
|
47
47
|
|
|
48
48
|
export { L as a, G as b };
|
|
49
49
|
//# sourceMappingURL=out.js.map
|
|
50
|
-
//# sourceMappingURL=chunk-
|
|
50
|
+
//# sourceMappingURL=chunk-W7GBDROK.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli/command/generate-command.ts","../src/cli/command/init-command.ts"],"names":["lstatSync","mkdirSync","writeFileSync","dirname","normalize","pathToFileURL","cliProgress","collect","generateCommand","configName","paths","options","openapiConfig","config","multibar","spec","spec_builder_default","dir","files","bar","file","parsedJsDocumentFile","parse_file_default","comments_to_open_api_default","item","parsedSwaggerJsDocumentFile","validate_default","output","generate_command_default","existsSync","realpathSync","readPkgUp","initCommand","packageJsonPath","foundPackageJson","exportTemplate","package_","packagePath","init_command_default"],"mappings":"qEAAA,OAAS,aAAAA,EAAW,aAAAC,EAAW,iBAAAC,MAAqB,KACpD,OAAS,WAAAC,EAAS,aAAAC,MAAiB,OACnC,OAAS,iBAAAC,MAAqB,MAE9B,OAAOC,MAAiB,eACxB,OAAS,WAAAC,MAAe,oBASxB,IAAMC,EAAkB,MACpBC,EACAC,EACAC,IAOgB,CAChB,IAAIC,EAMA,CACA,QAAS,CAAC,EACV,kBAAmB,CAAC,CACxB,EAEA,GAAI,CACA,IAAIC,EAAS,MAAM,OAAOR,EAAcD,EAAUO,EAAQ,QAAUF,CAAU,CAAC,EAAE,MAE7EI,GAAQ,UACRA,EAASA,EAAO,SAGpBD,EAAgBC,CACpB,MAAQ,CACJ,MAAM,IAAI,MAAM,6BAA6BF,EAAQ,QAAU,eAAe;AAAA,CAAI,CACtF,CAEA,IAAMG,EAAW,IAAIR,EAAY,SAC7B,CACI,gBAAiB,GACjB,OAAQ,uCACR,WAAY,EAChB,EACAA,EAAY,QAAQ,WACxB,EACMS,EAAO,IAAIC,EAAYJ,EAAc,iBAAiB,EAG5D,cAAiBK,KAAOP,EAAO,CAG3BV,EAAUiB,CAAG,EAAE,YAAY,EAE3B,IAAMC,EAAQ,MAAMX,EAAQU,EAAK,CAC7B,WAAYL,EAAc,YAAc,CAAC,MAAO,OAAQ,OAAQ,MAAO,OAAQ,OAAQ,QAAS,MAAM,EACtG,eAAgBA,EAAc,gBAAkB,GAChD,MAAOA,EAAc,QACrB,iBAAkB,CACd,MAAO,CACH,MAAOD,EAAQ,QACf,UAAW,EACf,EACA,KAAM,CACF,MAAOA,EAAQ,QACf,UAAW,EACf,CACJ,EACA,KAAM,CAAC,GAAGC,EAAc,QAAS,iBAAiB,CACtD,CAAC,GAEGD,EAAQ,SAAWA,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AM,4BAA4B,EAGhD,IAAMyB,EAAmBH,EAAU,KAAK,CAEpC,IAAKD,EAAaG,CAAe,CACrC,CAAC,EAEGE,EAAiB,mBAErB,GAAID,EAAkB,CAElB,GAAM,CAAE,YAAaE,EAAU,KAAMC,CAAY,EAAIH,EAGrD,QAAQ,KAAK,0BAA0BG,CAAW,GAAG,EAEjDD,EAAS,OAAY,WAErB,QAAQ,KAAK,+EAA+E,EAE5FD,EAAiB,iBAEzB,MAEI,QAAQ,KAAK,uBAAuB,EAIxCjC,EACIO,EACA,GAAG0B,CAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAmCrB,EAGA,QAAQ,IAAI,YAAY1B,CAAU,GAAG,CACzC,EAEO6B,EAAQN","sourcesContent":["import { lstatSync, mkdirSync, writeFileSync } from \"node:fs\";\nimport { dirname, normalize } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport cliProgress from \"cli-progress\";\nimport { collect } from \"@visulima/readdir\";\n\nimport type { BaseDefinition } from \"../../exported.d\";\nimport jsDocumentCommentsToOpenApi from \"../../jsdoc/comments-to-open-api\";\nimport parseFile from \"../../parse-file\";\nimport SpecBuilder from \"../../spec-builder\";\nimport swaggerJsDocumentCommentsToOpenApi from \"../../swagger-jsdoc/comments-to-open-api\";\nimport validate from \"../../validate\";\n\nconst generateCommand = async (\n configName: string,\n paths: string[],\n options: {\n config?: string;\n output?: string;\n verbose?: boolean;\n veryVerbose?: boolean;\n },\n // eslint-disable-next-line sonarjs/cognitive-complexity\n): Promise<void> => {\n let openapiConfig: {\n exclude: string[];\n extensions?: string[];\n followSymlinks?: boolean;\n include?: ReadonlyArray<string> | string;\n swaggerDefinition: BaseDefinition;\n } = {\n exclude: [],\n swaggerDefinition: {} as BaseDefinition,\n };\n\n try {\n let config = await import(pathToFileURL(normalize(options.config ?? configName)).href);\n\n if (config?.default) {\n config = config.default;\n }\n\n openapiConfig = config;\n } catch {\n throw new Error(`No config file found, on: ${options.config ?? \".openapirc.js\"}\\n`);\n }\n\n const multibar = new cliProgress.MultiBar(\n {\n clearOnComplete: false,\n format: \"{value}/{total} | {bar} | {filename}\",\n hideCursor: true,\n },\n cliProgress.Presets.shades_grey,\n );\n const spec = new SpecBuilder(openapiConfig.swaggerDefinition);\n\n // eslint-disable-next-line no-restricted-syntax,unicorn/prevent-abbreviations\n for await (const dir of paths) {\n // Check if the path is a directory\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n lstatSync(dir).isDirectory();\n\n const files = await collect(dir, {\n extensions: openapiConfig.extensions ?? [\".js\", \".cjs\", \".mjs\", \".ts\", \".tsx\", \".jsx\", \".yaml\", \".yml\"],\n followSymlinks: openapiConfig.followSymlinks ?? false,\n match: openapiConfig.include,\n minimatchOptions: {\n match: {\n debug: options.verbose,\n matchBase: true,\n },\n skip: {\n debug: options.verbose,\n matchBase: true,\n },\n },\n skip: [...openapiConfig.exclude, \"node_modules/**\"],\n });\n\n if (options.verbose ?? options.veryVerbose) {\n // eslint-disable-next-line no-console\n console.log(`\\nFound ${files.length} files in ${dir}`);\n }\n\n if (options.veryVerbose) {\n // eslint-disable-next-line no-console\n console.log(files);\n }\n\n const bar = multibar.create(files.length, 0);\n\n files.forEach((file) => {\n if (options.verbose) {\n // eslint-disable-next-line no-console\n console.log(`Parsing file ${file}`);\n }\n\n bar.increment(1, { filename: dir });\n\n const parsedJsDocumentFile = parseFile(file, jsDocumentCommentsToOpenApi, options.verbose);\n\n spec.addData(parsedJsDocumentFile.map((item) => item.spec));\n\n const parsedSwaggerJsDocumentFile = parseFile(file, swaggerJsDocumentCommentsToOpenApi, options.verbose);\n\n spec.addData(parsedSwaggerJsDocumentFile.map((item) => item.spec));\n });\n }\n\n if (options.verbose) {\n // eslint-disable-next-line no-console\n console.log(\"Validating swagger spec\");\n }\n\n if (options.veryVerbose) {\n // eslint-disable-next-line no-console\n console.log(JSON.stringify(spec, null, 2));\n }\n\n await validate(JSON.parse(JSON.stringify(spec)) as Record<string, unknown>);\n\n const output = options.output ?? \"swagger.json\";\n\n multibar.stop();\n\n if (options.verbose) {\n // eslint-disable-next-line no-console\n console.log(`Written swagger spec to \"${output}\" file`);\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n mkdirSync(dirname(output), { recursive: true });\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n writeFileSync(output, JSON.stringify(spec, null, 2));\n\n // eslint-disable-next-line no-console\n console.log(`\\nSwagger specification is ready, check the \"${output}\" file.`);\n};\n\nexport default generateCommand;\n","import { existsSync, realpathSync, writeFileSync } from \"node:fs\";\nimport readPkgUp from \"read-pkg-up\";\n\nconst initCommand = (configName: string, packageJsonPath = process.cwd()): void => {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(configName)) {\n throw new Error(\"Config file already exists\");\n }\n\n const foundPackageJson = readPkgUp.sync({\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n cwd: realpathSync(packageJsonPath),\n });\n\n let exportTemplate = \"module.exports =\";\n\n if (foundPackageJson) {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n const { packageJson: package_, path: packagePath } = foundPackageJson;\n\n // eslint-disable-next-line no-console\n console.info(`Found package.json at \"${packagePath}\"`);\n\n if (package_[\"type\"] === \"module\") {\n // eslint-disable-next-line no-console\n console.info(\"Found package.json with type: module, using ES6 as export for the config file\");\n\n exportTemplate = \"export default\";\n }\n } else {\n // eslint-disable-next-line no-console\n console.info(\"No package.json found\");\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n writeFileSync(\n configName,\n `${exportTemplate} {\n exclude: [\n 'coverage/**',\n '.github/**',\n 'packages/*/test{,s}/**',\n '**/*.d.ts',\n 'test{,s}/**',\n 'test{,-*}.{js,cjs,mjs,ts,tsx,jsx,yaml,yml}',\n '**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx,yaml,yml}',\n '**/__tests__/**',\n '**/{ava,babel,nyc}.config.{js,cjs,mjs}',\n '**/jest.config.{js,cjs,mjs,ts}',\n '**/{karma,rollup,webpack}.config.js',\n '**/.{eslint,mocha}rc.{js,cjs}',\n '**/.{travis,yarnrc}.yml',\n '**/{docker-compose,docker}.yml',\n '**/.yamllint.{yaml,yml}',\n '**/node_modules/**',\n '**/pnpm-lock.yaml',\n '**/pnpm-workspace.yaml',\n '**/{package,package-lock}.json',\n '**/yarn.lock',\n '**/package.json5',\n '**/.next/**',\n ],\n followSymlinks: false,\n swaggerDefinition: {\n openapi: '3.0.0',\n info: {\n title: 'API',\n version: '1.0.0',\n },\n },\n};\n`,\n );\n\n // eslint-disable-next-line no-console\n console.log(`Created \"${configName}\"`);\n};\n\nexport default initCommand;\n"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkGBW65CGH_js = require('../../chunk-GBW65CGH.js');
|
|
4
4
|
require('../../chunk-D7VYGB4A.js');
|
|
5
5
|
var process = require('process');
|
|
6
6
|
|
|
7
|
-
var s=(o,e="generate",t=".openapirc.js")=>{o.command(e).description("Generates OpenAPI (Swagger) documentation from JSDoc's").usage("[options] <path ...>").argument("[path ...]","Paths to files or directories to parse").option("-c, --config [.openapirc.js]","@visulima/jsdoc-open-api config file path.").option("-o, --output [swaggerSpec.json]","Output swagger specification.").option("-v, --verbose","Verbose output.").option("-vv, --very-verbose","Very verbose output.").action(async(r,a)=>{try{await
|
|
7
|
+
var s=(o,e="generate",t=".openapirc.js")=>{o.command(e).description("Generates OpenAPI (Swagger) documentation from JSDoc's").usage("[options] <path ...>").argument("[path ...]","Paths to files or directories to parse").option("-c, --config [.openapirc.js]","@visulima/jsdoc-open-api config file path.").option("-o, --output [swaggerSpec.json]","Output swagger specification.").option("-v, --verbose","Verbose output.").option("-vv, --very-verbose","Very verbose output.").action(async(r,a)=>{try{await chunkGBW65CGH_js.a(t,r,a);}catch(m){console.error(m),process.exit(1);}});},c=s;var f=(o,e="init",t="Inits a pre-configured @visulima/jsdoc-open-api config file.",r=".openapirc.js")=>{o.command(e).description(t).action(()=>{try{chunkGBW65CGH_js.b(r);}catch(a){console.error(a),process.exit(1);}});},u=f;
|
|
8
8
|
|
|
9
9
|
exports.generateCommand = c;
|
|
10
10
|
exports.initCommand = u;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/cli/commander/command/generate-command.ts","../../../src/cli/commander/command/init-command.ts"],"names":["exit","generateCommand","program","commandName","configName","paths","options","generate_command_default","error","initCommand","description","init_command_default"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/cli/commander/command/generate-command.ts","../../../src/cli/commander/command/init-command.ts"],"names":["exit","generateCommand","program","commandName","configName","paths","options","generate_command_default","error","initCommand","description","init_command_default"],"mappings":"mFAAA,OAAS,QAAAA,MAAY,UAKrB,IAAMC,EAAkB,CAACC,EAAkBC,EAAc,WAAYC,EAAa,kBAA0B,CACxGF,EACK,QAAQC,CAAW,EACnB,YAAY,wDAAwD,EACpE,MAAM,sBAAsB,EAC5B,SAAS,aAAc,wCAAwC,EAC/D,OAAO,+BAAgC,4CAA4C,EACnF,OAAO,kCAAmC,+BAA+B,EACzE,OAAO,gBAAiB,iBAAiB,EACzC,OAAO,sBAAuB,sBAAsB,EAEpD,OAAO,MAAOE,EAAOC,IAAY,CAC9B,GAAI,CACA,MAAMC,EAAoBH,EAAYC,EAAOC,CAAO,CACxD,OAASE,EAAO,CAEZ,QAAQ,MAAMA,CAAK,EAEnBR,EAAK,CAAC,CACV,CACJ,CAAC,CACT,EAEOO,EAAQN,EC5Bf,OAAS,QAAAD,MAAY,UAKrB,IAAMS,EAAc,CAChBP,EACAC,EAAc,OACdO,EAAc,+DACdN,EAAa,kBACN,CACPF,EACK,QAAQC,CAAW,EACnB,YAAYO,CAAW,EACvB,OAAO,IAAM,CACV,GAAI,CACAC,EAAgBP,CAAU,CAC9B,OAASI,EAAO,CAEZ,QAAQ,MAAMA,CAAK,EAEnBR,EAAK,CAAC,CACV,CACJ,CAAC,CACT,EAEOW,EAAQF","sourcesContent":["import { exit } from \"node:process\";\nimport type { Command } from \"commander\";\n\nimport baseGenerateCommand from \"../../command/generate-command\";\n\nconst generateCommand = (program: Command, commandName = \"generate\", configName = \".openapirc.js\"): void => {\n program\n .command(commandName)\n .description(\"Generates OpenAPI (Swagger) documentation from JSDoc's\")\n .usage(\"[options] <path ...>\")\n .argument(\"[path ...]\", \"Paths to files or directories to parse\")\n .option(\"-c, --config [.openapirc.js]\", \"@visulima/jsdoc-open-api config file path.\")\n .option(\"-o, --output [swaggerSpec.json]\", \"Output swagger specification.\")\n .option(\"-v, --verbose\", \"Verbose output.\")\n .option(\"-vv, --very-verbose\", \"Very verbose output.\")\n\n .action(async (paths, options) => {\n try {\n await baseGenerateCommand(configName, paths, options);\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error(error);\n\n exit(1);\n }\n });\n};\n\nexport default generateCommand;\n","import { exit } from \"node:process\";\nimport type { Command } from \"commander\";\n\nimport baseInitCommand from \"../../command/init-command\";\n\nconst initCommand = (\n program: Command,\n commandName = \"init\",\n description = \"Inits a pre-configured @visulima/jsdoc-open-api config file.\",\n configName = \".openapirc.js\",\n): void => {\n program\n .command(commandName)\n .description(description)\n .action(() => {\n try {\n baseInitCommand(configName);\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error(error);\n\n exit(1);\n }\n });\n};\n\nexport default initCommand;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/cli/commander/command/generate-command.ts","../../../src/cli/commander/command/init-command.ts"],"names":["exit","generateCommand","program","commandName","configName","paths","options","generate_command_default","error","initCommand","description","init_command_default"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/cli/commander/command/generate-command.ts","../../../src/cli/commander/command/init-command.ts"],"names":["exit","generateCommand","program","commandName","configName","paths","options","generate_command_default","error","initCommand","description","init_command_default"],"mappings":"qFAAA,OAAS,QAAAA,MAAY,UAKrB,IAAMC,EAAkB,CAACC,EAAkBC,EAAc,WAAYC,EAAa,kBAA0B,CACxGF,EACK,QAAQC,CAAW,EACnB,YAAY,wDAAwD,EACpE,MAAM,sBAAsB,EAC5B,SAAS,aAAc,wCAAwC,EAC/D,OAAO,+BAAgC,4CAA4C,EACnF,OAAO,kCAAmC,+BAA+B,EACzE,OAAO,gBAAiB,iBAAiB,EACzC,OAAO,sBAAuB,sBAAsB,EAEpD,OAAO,MAAOE,EAAOC,IAAY,CAC9B,GAAI,CACA,MAAMC,EAAoBH,EAAYC,EAAOC,CAAO,CACxD,OAASE,EAAO,CAEZ,QAAQ,MAAMA,CAAK,EAEnBR,EAAK,CAAC,CACV,CACJ,CAAC,CACT,EAEOO,EAAQN,EC5Bf,OAAS,QAAAD,MAAY,UAKrB,IAAMS,EAAc,CAChBP,EACAC,EAAc,OACdO,EAAc,+DACdN,EAAa,kBACN,CACPF,EACK,QAAQC,CAAW,EACnB,YAAYO,CAAW,EACvB,OAAO,IAAM,CACV,GAAI,CACAC,EAAgBP,CAAU,CAC9B,OAASI,EAAO,CAEZ,QAAQ,MAAMA,CAAK,EAEnBR,EAAK,CAAC,CACV,CACJ,CAAC,CACT,EAEOW,EAAQF","sourcesContent":["import { exit } from \"node:process\";\nimport type { Command } from \"commander\";\n\nimport baseGenerateCommand from \"../../command/generate-command\";\n\nconst generateCommand = (program: Command, commandName = \"generate\", configName = \".openapirc.js\"): void => {\n program\n .command(commandName)\n .description(\"Generates OpenAPI (Swagger) documentation from JSDoc's\")\n .usage(\"[options] <path ...>\")\n .argument(\"[path ...]\", \"Paths to files or directories to parse\")\n .option(\"-c, --config [.openapirc.js]\", \"@visulima/jsdoc-open-api config file path.\")\n .option(\"-o, --output [swaggerSpec.json]\", \"Output swagger specification.\")\n .option(\"-v, --verbose\", \"Verbose output.\")\n .option(\"-vv, --very-verbose\", \"Very verbose output.\")\n\n .action(async (paths, options) => {\n try {\n await baseGenerateCommand(configName, paths, options);\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error(error);\n\n exit(1);\n }\n });\n};\n\nexport default generateCommand;\n","import { exit } from \"node:process\";\nimport type { Command } from \"commander\";\n\nimport baseInitCommand from \"../../command/init-command\";\n\nconst initCommand = (\n program: Command,\n commandName = \"init\",\n description = \"Inits a pre-configured @visulima/jsdoc-open-api config file.\",\n configName = \".openapirc.js\",\n): void => {\n program\n .command(commandName)\n .description(description)\n .action(() => {\n try {\n baseInitCommand(configName);\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error(error);\n\n exit(1);\n }\n });\n};\n\nexport default initCommand;\n"]}
|
package/dist/cli/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkGBW65CGH_js = require('../chunk-GBW65CGH.js');
|
|
4
4
|
require('../chunk-D7VYGB4A.js');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
Object.defineProperty(exports, 'generateCommand', {
|
|
9
9
|
enumerable: true,
|
|
10
|
-
get: function () { return
|
|
10
|
+
get: function () { return chunkGBW65CGH_js.a; }
|
|
11
11
|
});
|
|
12
12
|
Object.defineProperty(exports, 'initCommand', {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function () { return
|
|
14
|
+
get: function () { return chunkGBW65CGH_js.b; }
|
|
15
15
|
});
|
|
16
16
|
//# sourceMappingURL=out.js.map
|
|
17
17
|
//# sourceMappingURL=index.js.map
|
package/dist/cli/index.mjs
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunkD7VYGB4A_js = require('./chunk-D7VYGB4A.js');
|
|
4
|
-
var readdir = require('@visulima/readdir');
|
|
5
4
|
var fs = require('fs');
|
|
6
5
|
var path = require('path');
|
|
7
6
|
var process = require('process');
|
|
7
|
+
var readdir = require('@visulima/readdir');
|
|
8
8
|
|
|
9
9
|
var O=["coverage/**",".github/**","packages/*/test{,s}/**","**/*.d.ts","test{,s}/**","test{,-*}.{js,cjs,mjs,ts,tsx,jsx,yaml,yml}","**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx,yaml,yml}","**/__tests__/**","**/{ava,babel,nyc}.config.{js,cjs,mjs}","**/jest.config.{js,cjs,mjs,ts}","**/{karma,rollup,webpack}.config.js","**/.{eslint,mocha}rc.{js,cjs}","**/.{travis,yarnrc}.yml","**/{docker-compose,docker}.yml","**/.yamllint.{yaml,yml}","**/node_modules/**","**/pnpm-lock.yaml","**/pnpm-workspace.yaml","**/{package,package-lock}.json","**/yarn.lock","**/package.json5","**/.next/**"],b=t=>{t&&(console.error(t),process.exit(1));},d=class{constructor(r,u,i,e){this.assetsPath=r,this.swaggerDefinition=i,this.sources=u,this.verbose=e.verbose??!1,this.ignore=e.ignore??[];}apply(r){r.hooks.make.tapAsync("SwaggerCompilerPlugin",async(u,i)=>{console.log("Build paused, switching to swagger build");let e=new chunkD7VYGB4A_js.d(this.swaggerDefinition);for await(let s of this.sources){let a=await readdir.collect(s,{extensions:[".js",".cjs",".mjs",".ts",".tsx",".jsx",".yaml",".yml"],includeDirs:!1,minimatchOptions:{match:{debug:this.verbose,matchBase:!0},skip:{debug:this.verbose,matchBase:!0}},skip:[...this.ignore,...O]});this.verbose&&(console.log(`Found ${a.length} files in ${s}`),console.log(a)),a.forEach(n=>{this.verbose&&console.log(`Parsing file ${n}`);try{let l=chunkD7VYGB4A_js.c(n,chunkD7VYGB4A_js.a,this.verbose);e.addData(l.map(c=>c.spec));let j=chunkD7VYGB4A_js.c(n,chunkD7VYGB4A_js.e,this.verbose);e.addData(j.map(c=>c.spec));}catch(l){console.error(l),process.exit(1);}});}try{this.verbose&&(console.log("Validating swagger spec"),console.log(JSON.stringify(e,null,2))),await chunkD7VYGB4A_js.f(JSON.parse(JSON.stringify(e)));}catch(s){console.error(s.toJSON()),process.exit(1);}let{assetsPath:y}=this;fs.mkdir(path.dirname(y),{recursive:!0},s=>{s&&b(s),fs.writeFile(y,JSON.stringify(e,null,2),b);}),this.verbose&&console.log(`Written swagger spec to "${this.assetsPath}" file`),console.log("switching back to normal build"),i();});}},B=d;
|
|
10
10
|
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/webpack/swagger-compiler-plugin.ts"],"names":["
|
|
1
|
+
{"version":3,"sources":["../src/webpack/swagger-compiler-plugin.ts"],"names":["mkdir","writeFile","dirname","exit","collect","exclude","errorHandler","error","SwaggerCompilerPlugin","assetsPath","sources","swaggerDefinition","options","compiler","_","callback","spec","spec_builder_default","dir","files","file","parsedJsDocumentFile","parse_file_default","comments_to_open_api_default","item","parsedSwaggerJsDocumentFile","validate_default","swagger_compiler_plugin_default"],"mappings":"2EAAA,OAAS,SAAAA,EAAO,aAAAC,MAAiB,KACjC,OAAS,WAAAC,MAAe,OACxB,OAAS,QAAAC,MAAY,UACrB,OAAS,WAAAC,MAAe,oBAWxB,IAAMC,EAAU,CACZ,cACA,aACA,yBACA,YACA,cACA,6CACA,iDACA,kBACA,yCACA,iCACA,sCACA,gCACA,0BACA,iCACA,0BACA,qBACA,oBACA,yBACA,iCACA,eACA,mBACA,aACJ,EAEMC,EAAgBC,GAAe,CAC7BA,IAEA,QAAQ,MAAMA,CAAK,EAEnBJ,EAAK,CAAC,EAEd,EAEMK,EAAN,KAA4B,CAWjB,YACHC,EACAC,EACAC,EACAC,EAIF,CACE,KAAK,WAAaH,EAClB,KAAK,kBAAoBE,EACzB,KAAK,QAAUD,EACf,KAAK,QAAUE,EAAQ,SAAW,GAClC,KAAK,OAASA,EAAQ,QAAU,CAAC,CACrC,CAEO,MAAMC,EAA0B,CAEnCA,EAAS,M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AAE,WAAAM,CAAW,EAAI,KAGvBT,EAAME,EAAQO,CAAU,EAAG,CAAE,UAAW,EAAK,EAAIF,GAAU,CACnDA,GACAD,EAAaC,CAAK,EAItBN,EAAUQ,EAAY,KAAK,UAAUO,EAAM,KAAM,CAAC,EAAGV,CAAY,CACrE,CAAC,EAEG,KAAK,SAEL,QAAQ,IAAI,4BAA4B,KAAK,UAAU,QAAQ,EAInE,QAAQ,IAAI,gCAAgC,EAE5CS,EAAS,CACb,CAAC,CACL,CACJ,EAEOY,EAAQnB","sourcesContent":["import { mkdir, writeFile } from \"node:fs\";\nimport { dirname } from \"node:path\";\nimport { exit } from \"node:process\";\nimport { collect } from \"@visulima/readdir\";\n\nimport type { Compiler } from \"webpack\";\n\nimport type { BaseDefinition } from \"../exported.d\";\nimport jsDocumentCommentsToOpenApi from \"../jsdoc/comments-to-open-api\";\nimport parseFile from \"../parse-file\";\nimport SpecBuilder from \"../spec-builder\";\nimport swaggerJsDocumentCommentsToOpenApi from \"../swagger-jsdoc/comments-to-open-api\";\nimport validate from \"../validate\";\n\nconst exclude = [\n \"coverage/**\",\n \".github/**\",\n \"packages/*/test{,s}/**\",\n \"**/*.d.ts\",\n \"test{,s}/**\",\n \"test{,-*}.{js,cjs,mjs,ts,tsx,jsx,yaml,yml}\",\n \"**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx,yaml,yml}\",\n \"**/__tests__/**\",\n \"**/{ava,babel,nyc}.config.{js,cjs,mjs}\",\n \"**/jest.config.{js,cjs,mjs,ts}\",\n \"**/{karma,rollup,webpack}.config.js\",\n \"**/.{eslint,mocha}rc.{js,cjs}\",\n \"**/.{travis,yarnrc}.yml\",\n \"**/{docker-compose,docker}.yml\",\n \"**/.yamllint.{yaml,yml}\",\n \"**/node_modules/**\",\n \"**/pnpm-lock.yaml\",\n \"**/pnpm-workspace.yaml\",\n \"**/{package,package-lock}.json\",\n \"**/yarn.lock\",\n \"**/package.json5\",\n \"**/.next/**\",\n];\n\nconst errorHandler = (error: any) => {\n if (error) {\n // eslint-disable-next-line no-console\n console.error(error);\n\n exit(1);\n }\n};\n\nclass SwaggerCompilerPlugin {\n private readonly assetsPath: string;\n\n private readonly ignore: ReadonlyArray<string> | string;\n\n private readonly sources: string[];\n\n private readonly swaggerDefinition: BaseDefinition;\n\n private readonly verbose: boolean;\n\n public constructor(\n assetsPath: string,\n sources: string[],\n swaggerDefinition: BaseDefinition,\n options: {\n ignore?: ReadonlyArray<string> | string;\n verbose?: boolean;\n },\n ) {\n this.assetsPath = assetsPath;\n this.swaggerDefinition = swaggerDefinition;\n this.sources = sources;\n this.verbose = options.verbose ?? false;\n this.ignore = options.ignore ?? [];\n }\n\n public apply(compiler: Compiler): void {\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n compiler.hooks.make.tapAsync(\"SwaggerCompilerPlugin\", async (_, callback: VoidFunction): Promise<void> => {\n // eslint-disable-next-line no-console\n console.log(\"Build paused, switching to swagger build\");\n\n const spec = new SpecBuilder(this.swaggerDefinition);\n\n // eslint-disable-next-line no-restricted-syntax,unicorn/prevent-abbreviations\n for await (const dir of this.sources) {\n const files = await collect(dir, {\n extensions: [\".js\", \".cjs\", \".mjs\", \".ts\", \".tsx\", \".jsx\", \".yaml\", \".yml\"],\n includeDirs: false,\n minimatchOptions: {\n match: {\n debug: this.verbose,\n matchBase: true,\n },\n skip: {\n debug: this.verbose,\n matchBase: true,\n },\n },\n skip: [...this.ignore, ...exclude],\n });\n\n if (this.verbose) {\n // eslint-disable-next-line no-console\n console.log(`Found ${files.length} files in ${dir}`);\n // eslint-disable-next-line no-console\n console.log(files);\n }\n\n files.forEach((file) => {\n if (this.verbose) {\n // eslint-disable-next-line no-console\n console.log(`Parsing file ${file}`);\n }\n\n try {\n const parsedJsDocumentFile = parseFile(file, jsDocumentCommentsToOpenApi, this.verbose);\n\n spec.addData(parsedJsDocumentFile.map((item) => item.spec));\n\n const parsedSwaggerJsDocumentFile = parseFile(file, swaggerJsDocumentCommentsToOpenApi, this.verbose);\n\n spec.addData(parsedSwaggerJsDocumentFile.map((item) => item.spec));\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error(error);\n\n exit(1);\n }\n });\n }\n\n try {\n if (this.verbose) {\n // eslint-disable-next-line no-console\n console.log(\"Validating swagger spec\");\n // eslint-disable-next-line no-console\n console.log(JSON.stringify(spec, null, 2));\n }\n\n await validate(JSON.parse(JSON.stringify(spec)));\n } catch (error: any) {\n // eslint-disable-next-line no-console\n console.error(error.toJSON());\n\n exit(1);\n }\n\n const { assetsPath } = this;\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n mkdir(dirname(assetsPath), { recursive: true }, (error) => {\n if (error) {\n errorHandler(error);\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n writeFile(assetsPath, JSON.stringify(spec, null, 2), errorHandler);\n });\n\n if (this.verbose) {\n // eslint-disable-next-line no-console\n console.log(`Written swagger spec to \"${this.assetsPath}\" file`);\n }\n\n // eslint-disable-next-line no-console\n console.log(\"switching back to normal build\");\n\n callback();\n });\n }\n}\n\nexport default SwaggerCompilerPlugin;\n"]}
|
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { d as d$1, c, a, e, f } from './chunk-WHYPHVY6.mjs';
|
|
2
2
|
export { d as SpecBuilder, a as jsDocumentCommentsToOpenApi, c as parseFile, e as swaggerJsDocumentCommentsToOpenApi, b as yamlLoc } from './chunk-WHYPHVY6.mjs';
|
|
3
|
-
import { collect } from '@visulima/readdir';
|
|
4
3
|
import { mkdir, writeFile } from 'fs';
|
|
5
4
|
import { dirname } from 'path';
|
|
6
5
|
import { exit } from 'process';
|
|
6
|
+
import { collect } from '@visulima/readdir';
|
|
7
7
|
|
|
8
8
|
var O=["coverage/**",".github/**","packages/*/test{,s}/**","**/*.d.ts","test{,s}/**","test{,-*}.{js,cjs,mjs,ts,tsx,jsx,yaml,yml}","**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx,yaml,yml}","**/__tests__/**","**/{ava,babel,nyc}.config.{js,cjs,mjs}","**/jest.config.{js,cjs,mjs,ts}","**/{karma,rollup,webpack}.config.js","**/.{eslint,mocha}rc.{js,cjs}","**/.{travis,yarnrc}.yml","**/{docker-compose,docker}.yml","**/.yamllint.{yaml,yml}","**/node_modules/**","**/pnpm-lock.yaml","**/pnpm-workspace.yaml","**/{package,package-lock}.json","**/yarn.lock","**/package.json5","**/.next/**"],b=t=>{t&&(console.error(t),exit(1));},d=class{constructor(r,u,i,e){this.assetsPath=r,this.swaggerDefinition=i,this.sources=u,this.verbose=e.verbose??!1,this.ignore=e.ignore??[];}apply(r){r.hooks.make.tapAsync("SwaggerCompilerPlugin",async(u,i)=>{console.log("Build paused, switching to swagger build");let e$1=new d$1(this.swaggerDefinition);for await(let s of this.sources){let a$1=await collect(s,{extensions:[".js",".cjs",".mjs",".ts",".tsx",".jsx",".yaml",".yml"],includeDirs:!1,minimatchOptions:{match:{debug:this.verbose,matchBase:!0},skip:{debug:this.verbose,matchBase:!0}},skip:[...this.ignore,...O]});this.verbose&&(console.log(`Found ${a$1.length} files in ${s}`),console.log(a$1)),a$1.forEach(n=>{this.verbose&&console.log(`Parsing file ${n}`);try{let l=c(n,a,this.verbose);e$1.addData(l.map(c=>c.spec));let j=c(n,e,this.verbose);e$1.addData(j.map(c=>c.spec));}catch(l){console.error(l),exit(1);}});}try{this.verbose&&(console.log("Validating swagger spec"),console.log(JSON.stringify(e$1,null,2))),await f(JSON.parse(JSON.stringify(e$1)));}catch(s){console.error(s.toJSON()),exit(1);}let{assetsPath:y}=this;mkdir(dirname(y),{recursive:!0},s=>{s&&b(s),writeFile(y,JSON.stringify(e$1,null,2),b);}),this.verbose&&console.log(`Written swagger spec to "${this.assetsPath}" file`),console.log("switching back to normal build"),i();});}},B=d;
|
|
9
9
|
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/webpack/swagger-compiler-plugin.ts"],"names":["
|
|
1
|
+
{"version":3,"sources":["../src/webpack/swagger-compiler-plugin.ts"],"names":["mkdir","writeFile","dirname","exit","collect","exclude","errorHandler","error","SwaggerCompilerPlugin","assetsPath","sources","swaggerDefinition","options","compiler","_","callback","spec","spec_builder_default","dir","files","file","parsedJsDocumentFile","parse_file_default","comments_to_open_api_default","item","parsedSwaggerJsDocumentFile","validate_default","swagger_compiler_plugin_default"],"mappings":"4EAAA,OAAS,SAAAA,EAAO,aAAAC,MAAiB,KACjC,OAAS,WAAAC,MAAe,OACxB,OAAS,QAAAC,MAAY,UACrB,OAAS,WAAAC,MAAe,oBAWxB,IAAMC,EAAU,CACZ,cACA,aACA,yBACA,YACA,cACA,6CACA,iDACA,kBACA,yCACA,iCACA,sCACA,gCACA,0BACA,iCACA,0BACA,qBACA,oBACA,yBACA,iCACA,eACA,mBACA,aACJ,EAEMC,EAAgBC,GAAe,CAC7BA,IAEA,QAAQ,MAAMA,CAAK,EAEnBJ,EAAK,CAAC,EAEd,EAEMK,EAAN,KAA4B,CAWjB,YACHC,EACAC,EACAC,EACAC,EAIF,CACE,KAAK,WAAaH,EAClB,KAAK,kBAAoBE,EACzB,KAAK,QAAUD,EACf,KAAK,QAAUE,EAAQ,SAAW,GAClC,KAAK,OAASA,EAAQ,QAAU,CAAC,CACrC,CAEO,MAAMC,EAA0B,CAEnCA,EAAS,MAAM,KAAK,SAAS,wBAAyB,MAAOC,EAAGC,IAA0C,CAEtG,QAAQ,IAAI,0CAA0C,EAEtD,IAAMC,EAAO,IAAIC,EAAY,KAAK,iBAAiB,EAGnD,cAAiBC,KAAO,KAAK,QAAS,CAClC,IAAMC,EAAQ,MAAMf,EAAQc,EAAK,CAC7B,WAAY,CAAC,MAAO,OAAQ,OAAQ,MAAO,OAAQ,OAAQ,QAAS,MAAM,EAC1E,YAAa,GACb,iBAAkB,CACd,MAAO,CACH,MAAO,KAAK,QACZ,UAAW,EACf,EACA,KAAM,CACF,MAAO,KAAK,QACZ,UAAW,EACf,CACJ,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{ exit } from \"node:process\";\nimport { collect } from \"@visulima/readdir\";\n\nimport type { Compiler } from \"webpack\";\n\nimport type { BaseDefinition } from \"../exported.d\";\nimport jsDocumentCommentsToOpenApi from \"../jsdoc/comments-to-open-api\";\nimport parseFile from \"../parse-file\";\nimport SpecBuilder from \"../spec-builder\";\nimport swaggerJsDocumentCommentsToOpenApi from \"../swagger-jsdoc/comments-to-open-api\";\nimport validate from \"../validate\";\n\nconst exclude = [\n \"coverage/**\",\n \".github/**\",\n \"packages/*/test{,s}/**\",\n \"**/*.d.ts\",\n \"test{,s}/**\",\n \"test{,-*}.{js,cjs,mjs,ts,tsx,jsx,yaml,yml}\",\n \"**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx,yaml,yml}\",\n \"**/__tests__/**\",\n \"**/{ava,babel,nyc}.config.{js,cjs,mjs}\",\n \"**/jest.config.{js,cjs,mjs,ts}\",\n \"**/{karma,rollup,webpack}.config.js\",\n \"**/.{eslint,mocha}rc.{js,cjs}\",\n \"**/.{travis,yarnrc}.yml\",\n \"**/{docker-compose,docker}.yml\",\n \"**/.yamllint.{yaml,yml}\",\n \"**/node_modules/**\",\n \"**/pnpm-lock.yaml\",\n \"**/pnpm-workspace.yaml\",\n \"**/{package,package-lock}.json\",\n \"**/yarn.lock\",\n \"**/package.json5\",\n \"**/.next/**\",\n];\n\nconst errorHandler = (error: any) => {\n if (error) {\n // eslint-disable-next-line no-console\n console.error(error);\n\n exit(1);\n }\n};\n\nclass SwaggerCompilerPlugin {\n private readonly assetsPath: string;\n\n private readonly ignore: ReadonlyArray<string> | string;\n\n private readonly sources: string[];\n\n private readonly swaggerDefinition: BaseDefinition;\n\n private readonly verbose: boolean;\n\n public constructor(\n assetsPath: string,\n sources: string[],\n swaggerDefinition: BaseDefinition,\n options: {\n ignore?: ReadonlyArray<string> | string;\n verbose?: boolean;\n },\n ) {\n this.assetsPath = assetsPath;\n this.swaggerDefinition = swaggerDefinition;\n this.sources = sources;\n this.verbose = options.verbose ?? false;\n this.ignore = options.ignore ?? [];\n }\n\n public apply(compiler: Compiler): void {\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n compiler.hooks.make.tapAsync(\"SwaggerCompilerPlugin\", async (_, callback: VoidFunction): Promise<void> => {\n // eslint-disable-next-line no-console\n console.log(\"Build paused, switching to swagger build\");\n\n const spec = new SpecBuilder(this.swaggerDefinition);\n\n // eslint-disable-next-line no-restricted-syntax,unicorn/prevent-abbreviations\n for await (const dir of this.sources) {\n const files = await collect(dir, {\n extensions: [\".js\", \".cjs\", \".mjs\", \".ts\", \".tsx\", \".jsx\", \".yaml\", \".yml\"],\n includeDirs: false,\n minimatchOptions: {\n match: {\n debug: this.verbose,\n matchBase: true,\n },\n skip: {\n debug: this.verbose,\n matchBase: true,\n },\n },\n skip: [...this.ignore, ...exclude],\n });\n\n if (this.verbose) {\n // eslint-disable-next-line no-console\n console.log(`Found ${files.length} files in ${dir}`);\n // eslint-disable-next-line no-console\n console.log(files);\n }\n\n files.forEach((file) => {\n if (this.verbose) {\n // eslint-disable-next-line no-console\n console.log(`Parsing file ${file}`);\n }\n\n try {\n const parsedJsDocumentFile = parseFile(file, jsDocumentCommentsToOpenApi, this.verbose);\n\n spec.addData(parsedJsDocumentFile.map((item) => item.spec));\n\n const parsedSwaggerJsDocumentFile = parseFile(file, swaggerJsDocumentCommentsToOpenApi, this.verbose);\n\n spec.addData(parsedSwaggerJsDocumentFile.map((item) => item.spec));\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error(error);\n\n exit(1);\n }\n });\n }\n\n try {\n if (this.verbose) {\n // eslint-disable-next-line no-console\n console.log(\"Validating swagger spec\");\n // eslint-disable-next-line no-console\n console.log(JSON.stringify(spec, null, 2));\n }\n\n await validate(JSON.parse(JSON.stringify(spec)));\n } catch (error: any) {\n // eslint-disable-next-line no-console\n console.error(error.toJSON());\n\n exit(1);\n }\n\n const { assetsPath } = this;\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n mkdir(dirname(assetsPath), { recursive: true }, (error) => {\n if (error) {\n errorHandler(error);\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n writeFile(assetsPath, JSON.stringify(spec, null, 2), errorHandler);\n });\n\n if (this.verbose) {\n // eslint-disable-next-line no-console\n console.log(`Written swagger spec to \"${this.assetsPath}\" file`);\n }\n\n // eslint-disable-next-line no-console\n console.log(\"switching back to normal build\");\n\n callback();\n });\n }\n}\n\nexport default SwaggerCompilerPlugin;\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visulima/jsdoc-open-api",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Generates swagger doc based on JSDoc.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"visulima",
|
|
@@ -87,39 +87,39 @@
|
|
|
87
87
|
},
|
|
88
88
|
"dependencies": {
|
|
89
89
|
"@apidevtools/swagger-parser": "^10.1.0",
|
|
90
|
-
"@visulima/readdir": "
|
|
91
|
-
"comment-parser": "^1.
|
|
90
|
+
"@visulima/readdir": "2.0.0",
|
|
91
|
+
"comment-parser": "^1.4.0",
|
|
92
92
|
"lodash.mergewith": "^4.6.2",
|
|
93
93
|
"read-pkg-up": "^7.0.1",
|
|
94
94
|
"yaml": "^2.3.1"
|
|
95
95
|
},
|
|
96
96
|
"devDependencies": {
|
|
97
|
-
"@anolilab/eslint-config": "^11.
|
|
98
|
-
"@anolilab/prettier-config": "^5.0.
|
|
99
|
-
"@anolilab/semantic-release-preset": "^6.0.
|
|
97
|
+
"@anolilab/eslint-config": "^11.3.3",
|
|
98
|
+
"@anolilab/prettier-config": "^5.0.3",
|
|
99
|
+
"@anolilab/semantic-release-preset": "^6.0.4",
|
|
100
100
|
"@rushstack/eslint-plugin-security": "^0.6.0",
|
|
101
|
-
"@stoplight/types": "^13.17.0",
|
|
102
101
|
"@types/cli-progress": "^3.11.0",
|
|
103
102
|
"@types/http-errors": "^2.0.1",
|
|
104
103
|
"@types/lodash.mergewith": "^4.6.7",
|
|
105
|
-
"@types/node": "18.
|
|
106
|
-
"@types/webpack": "^5.28.
|
|
107
|
-
"@vitest/coverage-v8": "^0.
|
|
104
|
+
"@types/node": "18.17.1",
|
|
105
|
+
"@types/webpack": "^5.28.2",
|
|
106
|
+
"@vitest/coverage-v8": "^0.34.3",
|
|
108
107
|
"c8": "^8.0.1",
|
|
109
108
|
"cli-progress": "^3.12.0",
|
|
110
109
|
"commander": "^11.0.0",
|
|
111
110
|
"cross-env": "^7.0.3",
|
|
112
|
-
"eslint": "^8.
|
|
111
|
+
"eslint": "^8.48.0",
|
|
113
112
|
"eslint-plugin-etc": "^2.0.3",
|
|
114
|
-
"eslint-plugin-mdx": "^2.
|
|
113
|
+
"eslint-plugin-mdx": "^2.2.0",
|
|
115
114
|
"eslint-plugin-vitest": "^0.2.8",
|
|
115
|
+
"eslint-plugin-vitest-globals": "^1.4.0",
|
|
116
116
|
"openapi-types": "^12.1.3",
|
|
117
|
-
"prettier": "^3.0.
|
|
117
|
+
"prettier": "^3.0.2",
|
|
118
118
|
"rimraf": "^5.0.1",
|
|
119
|
-
"semantic-release": "^21.
|
|
120
|
-
"tsup": "^7.
|
|
121
|
-
"typescript": "^5.
|
|
122
|
-
"vitest": "^0.
|
|
119
|
+
"semantic-release": "^21.1.1",
|
|
120
|
+
"tsup": "^7.2.0",
|
|
121
|
+
"typescript": "^5.2.2",
|
|
122
|
+
"vitest": "^0.34.3",
|
|
123
123
|
"webpack": "^5.88.2"
|
|
124
124
|
},
|
|
125
125
|
"optionalDependencies": {
|
|
@@ -128,7 +128,7 @@
|
|
|
128
128
|
"webpack": "^5.88.2"
|
|
129
129
|
},
|
|
130
130
|
"engines": {
|
|
131
|
-
"node": ">=
|
|
131
|
+
"node": ">=18.* <=20.*"
|
|
132
132
|
},
|
|
133
133
|
"publishConfig": {
|
|
134
134
|
"access": "public",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cli/command/generate-command.ts","../src/cli/command/init-command.ts"],"names":["collect","cliProgress","lstatSync","mkdirSync","writeFileSync","dirname","normalize","pathToFileURL","generateCommand","configName","paths","options","openapiConfig","config","multibar","spec","spec_builder_default","dir","files","bar","file","parsedJsDocumentFile","parse_file_default","comments_to_open_api_default","item","parsedSwaggerJsDocumentFile","validate_default","output","generate_command_default","existsSync","realpathSync","readPkgUp","initCommand","packageJsonPath","foundPackageJson","exportTemplate","package_","packagePath","init_command_default"],"mappings":"qEAAA,OAAS,WAAAA,MAAe,oBAExB,OAAOC,MAAiB,eACxB,OAAS,aAAAC,EAAW,aAAAC,EAAW,iBAAAC,MAAqB,KACpD,OAAS,WAAAC,EAAS,aAAAC,MAAiB,OACnC,OAAS,iBAAAC,MAAqB,MAS9B,IAAMC,EAAkB,MACpBC,EACAC,EACAC,IAOgB,CAChB,IAAIC,EAMA,CACA,QAAS,CAAC,EACV,kBAAmB,CAAC,CACxB,EAEA,GAAI,CACA,IAAIC,EAAS,MAAM,OAAON,EAAcD,EAAUK,EAAQ,QAAUF,CAAU,CAAC,EAAE,MAE7EI,GAAQ,UACRA,EAASA,EAAO,SAGpBD,EAAgBC,CACpB,MAAQ,CACJ,MAAM,IAAI,MAAM,6BAA6BF,EAAQ,QAAU,eAAe;AAAA,CAAI,CACtF,CAEA,IAAMG,EAAW,IAAIb,EAAY,SAC7B,CACI,gBAAiB,GACjB,OAAQ,uCACR,WAAY,EAChB,EACAA,EAAY,QAAQ,WACxB,EACMc,EAAO,IAAIC,EAAYJ,EAAc,iBAAiB,EAG5D,cAAiBK,KAAOP,EAAO,CAG3BR,EAAUe,CAAG,EAAE,YAAY,EAE3B,IAAMC,EAAQ,MAAMlB,EAAQiB,EAAK,CAC7B,WAAYL,EAAc,YAAc,CAAC,MAAO,OAAQ,OAAQ,MAAO,OAAQ,OAAQ,QAAS,MAAM,EACtG,eAAgBA,EAAc,gBAAkB,GAChD,MAAOA,EAAc,QACrB,iBAAkB,CACd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EAAY,gBAAAC,EAAc,iBAAA1B,MAAqB,KACxD,OAAO2B,MAAe,cAEtB,IAAMC,EAAc,CAACvB,EAAoBwB,EAAkB,QAAQ,IAAI,IAAY,CAE/E,GAAIJ,EAAWpB,CAAU,EACrB,MAAM,IAAI,MAAM,4BAA4B,EAGhD,IAAMyB,EAAmBH,EAAU,KAAK,CAEpC,IAAKD,EAAaG,CAAe,CACrC,CAAC,EAEGE,EAAiB,mBAErB,GAAID,EAAkB,CAElB,GAAM,CAAE,YAAaE,EAAU,KAAMC,CAAY,EAAIH,EAGrD,QAAQ,KAAK,0BAA0BG,CAAW,GAAG,EAEjDD,EAAS,OAAY,WAErB,QAAQ,KAAK,+EAA+E,EAE5FD,EAAiB,iBAEzB,MAEI,QAAQ,KAAK,uBAAuB,EAIxC/B,EACIK,EACA,GAAG0B,CAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAmCrB,EAGA,QAAQ,IAAI,YAAY1B,CAAU,GAAG,CACzC,EAEO6B,EAAQN","sourcesContent":["import { collect } from \"@visulima/readdir\";\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport cliProgress from \"cli-progress\";\nimport { lstatSync, mkdirSync, writeFileSync } from \"node:fs\";\nimport { dirname, normalize } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\n\nimport type { BaseDefinition } from \"../../exported.d\";\nimport jsDocumentCommentsToOpenApi from \"../../jsdoc/comments-to-open-api\";\nimport parseFile from \"../../parse-file\";\nimport SpecBuilder from \"../../spec-builder\";\nimport swaggerJsDocumentCommentsToOpenApi from \"../../swagger-jsdoc/comments-to-open-api\";\nimport validate from \"../../validate\";\n\nconst generateCommand = async (\n configName: string,\n paths: string[],\n options: {\n config?: string;\n output?: string;\n verbose?: boolean;\n veryVerbose?: boolean;\n },\n // eslint-disable-next-line sonarjs/cognitive-complexity\n): Promise<void> => {\n let openapiConfig: {\n exclude: string[];\n extensions?: string[];\n followSymlinks?: boolean;\n include?: ReadonlyArray<string> | string;\n swaggerDefinition: BaseDefinition;\n } = {\n exclude: [],\n swaggerDefinition: {} as BaseDefinition,\n };\n\n try {\n let config = await import(pathToFileURL(normalize(options.config ?? configName)).href);\n\n if (config?.default) {\n config = config.default;\n }\n\n openapiConfig = config;\n } catch {\n throw new Error(`No config file found, on: ${options.config ?? \".openapirc.js\"}\\n`);\n }\n\n const multibar = new cliProgress.MultiBar(\n {\n clearOnComplete: false,\n format: \"{value}/{total} | {bar} | {filename}\",\n hideCursor: true,\n },\n cliProgress.Presets.shades_grey,\n );\n const spec = new SpecBuilder(openapiConfig.swaggerDefinition);\n\n // eslint-disable-next-line no-restricted-syntax,unicorn/prevent-abbreviations\n for await (const dir of paths) {\n // Check if the path is a directory\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n lstatSync(dir).isDirectory();\n\n const files = await collect(dir, {\n extensions: openapiConfig.extensions ?? [\".js\", \".cjs\", \".mjs\", \".ts\", \".tsx\", \".jsx\", \".yaml\", \".yml\"],\n followSymlinks: openapiConfig.followSymlinks ?? false,\n match: openapiConfig.include,\n minimatchOptions: {\n match: {\n debug: options.verbose,\n matchBase: true,\n },\n skip: {\n debug: options.verbose,\n matchBase: true,\n },\n },\n skip: [...openapiConfig.exclude, \"node_modules/**\"],\n });\n\n if (options.verbose ?? options.veryVerbose) {\n // eslint-disable-next-line no-console\n console.log(`\\nFound ${files.length} files in ${dir}`);\n }\n\n if (options.veryVerbose) {\n // eslint-disable-next-line no-console\n console.log(files);\n }\n\n const bar = multibar.create(files.length, 0);\n\n files.forEach((file) => {\n if (options.verbose) {\n // eslint-disable-next-line no-console\n console.log(`Parsing file ${file}`);\n }\n\n bar.increment(1, { filename: dir });\n\n const parsedJsDocumentFile = parseFile(file, jsDocumentCommentsToOpenApi, options.verbose);\n\n spec.addData(parsedJsDocumentFile.map((item) => item.spec));\n\n const parsedSwaggerJsDocumentFile = parseFile(file, swaggerJsDocumentCommentsToOpenApi, options.verbose);\n\n spec.addData(parsedSwaggerJsDocumentFile.map((item) => item.spec));\n });\n }\n\n if (options.verbose) {\n // eslint-disable-next-line no-console\n console.log(\"Validating swagger spec\");\n }\n\n if (options.veryVerbose) {\n // eslint-disable-next-line no-console\n console.log(JSON.stringify(spec, null, 2));\n }\n\n await validate(JSON.parse(JSON.stringify(spec)) as Record<string, unknown>);\n\n const output = options.output ?? \"swagger.json\";\n\n multibar.stop();\n\n if (options.verbose) {\n // eslint-disable-next-line no-console\n console.log(`Written swagger spec to \"${output}\" file`);\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n mkdirSync(dirname(output), { recursive: true });\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n writeFileSync(output, JSON.stringify(spec, null, 2));\n\n // eslint-disable-next-line no-console\n console.log(`\\nSwagger specification is ready, check the \"${output}\" file.`);\n};\n\nexport default generateCommand;\n","import { existsSync, realpathSync, writeFileSync } from \"node:fs\";\nimport readPkgUp from \"read-pkg-up\";\n\nconst initCommand = (configName: string, packageJsonPath = process.cwd()): void => {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(configName)) {\n throw new Error(\"Config file already exists\");\n }\n\n const foundPackageJson = readPkgUp.sync({\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n cwd: realpathSync(packageJsonPath),\n });\n\n let exportTemplate = \"module.exports =\";\n\n if (foundPackageJson) {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n const { packageJson: package_, path: packagePath } = foundPackageJson;\n\n // eslint-disable-next-line no-console\n console.info(`Found package.json at \"${packagePath}\"`);\n\n if (package_[\"type\"] === \"module\") {\n // eslint-disable-next-line no-console\n console.info(\"Found package.json with type: module, using ES6 as export for the config file\");\n\n exportTemplate = \"export default\";\n }\n } else {\n // eslint-disable-next-line no-console\n console.info(\"No package.json found\");\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n writeFileSync(\n configName,\n `${exportTemplate} {\n exclude: [\n 'coverage/**',\n '.github/**',\n 'packages/*/test{,s}/**',\n '**/*.d.ts',\n 'test{,s}/**',\n 'test{,-*}.{js,cjs,mjs,ts,tsx,jsx,yaml,yml}',\n '**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx,yaml,yml}',\n '**/__tests__/**',\n '**/{ava,babel,nyc}.config.{js,cjs,mjs}',\n '**/jest.config.{js,cjs,mjs,ts}',\n '**/{karma,rollup,webpack}.config.js',\n '**/.{eslint,mocha}rc.{js,cjs}',\n '**/.{travis,yarnrc}.yml',\n '**/{docker-compose,docker}.yml',\n '**/.yamllint.{yaml,yml}',\n '**/node_modules/**',\n '**/pnpm-lock.yaml',\n '**/pnpm-workspace.yaml',\n '**/{package,package-lock}.json',\n '**/yarn.lock',\n '**/package.json5',\n '**/.next/**',\n ],\n followSymlinks: false,\n swaggerDefinition: {\n openapi: '3.0.0',\n info: {\n title: 'API',\n version: '1.0.0',\n },\n },\n};\n`,\n );\n\n // eslint-disable-next-line no-console\n console.log(`Created \"${configName}\"`);\n};\n\nexport default initCommand;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cli/command/generate-command.ts","../src/cli/command/init-command.ts"],"names":["collect","cliProgress","lstatSync","mkdirSync","writeFileSync","dirname","normalize","pathToFileURL","generateCommand","configName","paths","options","openapiConfig","config","multibar","spec","spec_builder_default","dir","files","bar","file","parsedJsDocumentFile","parse_file_default","comments_to_open_api_default","item","parsedSwaggerJsDocumentFile","validate_default","output","generate_command_default","existsSync","realpathSync","readPkgUp","initCommand","packageJsonPath","foundPackageJson","exportTemplate","package_","packagePath","init_command_default"],"mappings":"oEAAA,OAAS,WAAAA,MAAe,oBAExB,OAAOC,MAAiB,eACxB,OAAS,aAAAC,EAAW,aAAAC,EAAW,iBAAAC,MAAqB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,KAAK,+EAA+E,EAE5FD,EAAiB,iBAEzB,MAEI,QAAQ,KAAK,uBAAuB,EAIxC/B,EACIK,EACA,GAAG0B,CAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAmCrB,EAGA,QAAQ,IAAI,YAAY1B,CAAU,GAAG,CACzC,EAEO6B,EAAQN","sourcesContent":["import { collect } from \"@visulima/readdir\";\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport cliProgress from \"cli-progress\";\nimport { lstatSync, mkdirSync, writeFileSync } from \"node:fs\";\nimport { dirname, normalize } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\n\nimport type { BaseDefinition } from \"../../exported.d\";\nimport jsDocumentCommentsToOpenApi from \"../../jsdoc/comments-to-open-api\";\nimport parseFile from \"../../parse-file\";\nimport SpecBuilder from \"../../spec-builder\";\nimport swaggerJsDocumentCommentsToOpenApi from \"../../swagger-jsdoc/comments-to-open-api\";\nimport validate from \"../../validate\";\n\nconst generateCommand = async (\n configName: string,\n paths: string[],\n options: {\n config?: string;\n output?: string;\n verbose?: boolean;\n veryVerbose?: boolean;\n },\n // eslint-disable-next-line sonarjs/cognitive-complexity\n): Promise<void> => {\n let openapiConfig: {\n exclude: string[];\n extensions?: string[];\n followSymlinks?: boolean;\n include?: ReadonlyArray<string> | string;\n swaggerDefinition: BaseDefinition;\n } = {\n exclude: [],\n swaggerDefinition: {} as BaseDefinition,\n };\n\n try {\n let config = await import(pathToFileURL(normalize(options.config ?? configName)).href);\n\n if (config?.default) {\n config = config.default;\n }\n\n openapiConfig = config;\n } catch {\n throw new Error(`No config file found, on: ${options.config ?? \".openapirc.js\"}\\n`);\n }\n\n const multibar = new cliProgress.MultiBar(\n {\n clearOnComplete: false,\n format: \"{value}/{total} | {bar} | {filename}\",\n hideCursor: true,\n },\n cliProgress.Presets.shades_grey,\n );\n const spec = new SpecBuilder(openapiConfig.swaggerDefinition);\n\n // eslint-disable-next-line no-restricted-syntax,unicorn/prevent-abbreviations\n for await (const dir of paths) {\n // Check if the path is a directory\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n lstatSync(dir).isDirectory();\n\n const files = await collect(dir, {\n extensions: openapiConfig.extensions ?? [\".js\", \".cjs\", \".mjs\", \".ts\", \".tsx\", \".jsx\", \".yaml\", \".yml\"],\n followSymlinks: openapiConfig.followSymlinks ?? false,\n match: openapiConfig.include,\n minimatchOptions: {\n match: {\n debug: options.verbose,\n matchBase: true,\n },\n skip: {\n debug: options.verbose,\n matchBase: true,\n },\n },\n skip: [...openapiConfig.exclude, \"node_modules/**\"],\n });\n\n if (options.verbose ?? options.veryVerbose) {\n // eslint-disable-next-line no-console\n console.log(`\\nFound ${files.length} files in ${dir}`);\n }\n\n if (options.veryVerbose) {\n // eslint-disable-next-line no-console\n console.log(files);\n }\n\n const bar = multibar.create(files.length, 0);\n\n files.forEach((file) => {\n if (options.verbose) {\n // eslint-disable-next-line no-console\n console.log(`Parsing file ${file}`);\n }\n\n bar.increment(1, { filename: dir });\n\n const parsedJsDocumentFile = parseFile(file, jsDocumentCommentsToOpenApi, options.verbose);\n\n spec.addData(parsedJsDocumentFile.map((item) => item.spec));\n\n const parsedSwaggerJsDocumentFile = parseFile(file, swaggerJsDocumentCommentsToOpenApi, options.verbose);\n\n spec.addData(parsedSwaggerJsDocumentFile.map((item) => item.spec));\n });\n }\n\n if (options.verbose) {\n // eslint-disable-next-line no-console\n console.log(\"Validating swagger spec\");\n }\n\n if (options.veryVerbose) {\n // eslint-disable-next-line no-console\n console.log(JSON.stringify(spec, null, 2));\n }\n\n await validate(JSON.parse(JSON.stringify(spec)) as Record<string, unknown>);\n\n const output = options.output ?? \"swagger.json\";\n\n multibar.stop();\n\n if (options.verbose) {\n // eslint-disable-next-line no-console\n console.log(`Written swagger spec to \"${output}\" file`);\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n mkdirSync(dirname(output), { recursive: true });\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n writeFileSync(output, JSON.stringify(spec, null, 2));\n\n // eslint-disable-next-line no-console\n console.log(`\\nSwagger specification is ready, check the \"${output}\" file.`);\n};\n\nexport default generateCommand;\n","import { existsSync, realpathSync, writeFileSync } from \"node:fs\";\nimport readPkgUp from \"read-pkg-up\";\n\nconst initCommand = (configName: string, packageJsonPath = process.cwd()): void => {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(configName)) {\n throw new Error(\"Config file already exists\");\n }\n\n const foundPackageJson = readPkgUp.sync({\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n cwd: realpathSync(packageJsonPath),\n });\n\n let exportTemplate = \"module.exports =\";\n\n if (foundPackageJson) {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n const { packageJson: package_, path: packagePath } = foundPackageJson;\n\n // eslint-disable-next-line no-console\n console.info(`Found package.json at \"${packagePath}\"`);\n\n if (package_[\"type\"] === \"module\") {\n // eslint-disable-next-line no-console\n console.info(\"Found package.json with type: module, using ES6 as export for the config file\");\n\n exportTemplate = \"export default\";\n }\n } else {\n // eslint-disable-next-line no-console\n console.info(\"No package.json found\");\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n writeFileSync(\n configName,\n `${exportTemplate} {\n exclude: [\n 'coverage/**',\n '.github/**',\n 'packages/*/test{,s}/**',\n '**/*.d.ts',\n 'test{,s}/**',\n 'test{,-*}.{js,cjs,mjs,ts,tsx,jsx,yaml,yml}',\n '**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx,yaml,yml}',\n '**/__tests__/**',\n '**/{ava,babel,nyc}.config.{js,cjs,mjs}',\n '**/jest.config.{js,cjs,mjs,ts}',\n '**/{karma,rollup,webpack}.config.js',\n '**/.{eslint,mocha}rc.{js,cjs}',\n '**/.{travis,yarnrc}.yml',\n '**/{docker-compose,docker}.yml',\n '**/.yamllint.{yaml,yml}',\n '**/node_modules/**',\n '**/pnpm-lock.yaml',\n '**/pnpm-workspace.yaml',\n '**/{package,package-lock}.json',\n '**/yarn.lock',\n '**/package.json5',\n '**/.next/**',\n ],\n followSymlinks: false,\n swaggerDefinition: {\n openapi: '3.0.0',\n info: {\n title: 'API',\n version: '1.0.0',\n },\n },\n};\n`,\n );\n\n // eslint-disable-next-line no-console\n console.log(`Created \"${configName}\"`);\n};\n\nexport default initCommand;\n"]}
|