-
-
Notifications
You must be signed in to change notification settings - Fork 740
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: automate openapi schema list #6463
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b6f3877
chore: automate openapi schema list
gastonfournier 4adf3e2
Add reference to the file itself
gastonfournier 7b1d7bf
Better instructions for local devs
gastonfournier 2817e66
Adapted to lint rules
gastonfournier 75ac4f2
Merge remote-tracking branch 'origin/main' into auto-generate-openapi…
gastonfournier 2e2097b
Merge remote-tracking branch 'origin/main' into auto-generate-openapi…
gastonfournier File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
const directoryPath = path.join(`${__dirname}/..`, 'src/lib/openapi/spec'); | ||
const indexPath = path.join(directoryPath, 'index.ts'); | ||
|
||
// Read files from the directory | ||
fs.readdir(directoryPath, (err, files) => { | ||
if (err) { | ||
console.error('Could not list the directory.', err); | ||
process.exit(1); | ||
} | ||
|
||
const exports = files | ||
.filter((file) => file.includes('schema.ts')) // Filter files by 'schema.ts' | ||
.map((file) => `export * from './${file.replace('.ts', '')}';`) // Create export statements | ||
.join('\n'); | ||
|
||
// Append export statements to index.ts | ||
const script = path.basename(__filename); | ||
const message = `/** | ||
* Auto-generated file by ${script}. Do not edit. | ||
* To run it manually execute \`node ${script}\` from ${path.basename( | ||
__dirname, | ||
)} | ||
*/\n`; | ||
fs.writeFileSync(indexPath, `${message}${exports}\n${message}`, (err) => { | ||
if (err) { | ||
console.error('Could not append to file.', err); | ||
process.exit(1); | ||
} | ||
console.log('Export statements added to index.ts successfully.'); | ||
}); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using node instead of bash, because it should be available in local dev