1
0
mirror of https://github.com/badges/shields.git synced 2025-09-21 03:21:59 +03:00
Files
shields/scripts/export-openapi-cli.js
dependabot[bot] b9d96755ec chore(deps-dev): bump prettier from 2.8.8 to 3.0.0 (#9357)
* chore(deps-dev): bump prettier from 2.8.8 to 3.0.0

Bumps [prettier](https://github.com/prettier/prettier) from 2.8.8 to 3.0.0.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/2.8.8...3.0.0)

---
updated-dependencies:
- dependency-name: prettier
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* reformat all the things (prettier 3)

* update tests to await calls to prettier.format()

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: chris48s <git@chris-shaw.dev>
2023-07-10 09:27:51 +00:00

50 lines
1.3 KiB
JavaScript

import fs from 'fs'
import path from 'path'
import yaml from 'js-yaml'
import { collectDefinitions } from '../core/base-service/loader.js'
import { category2openapi } from '../core/base-service/openapi.js'
const specsPath = path.join('frontend', 'categories')
function writeSpec(filename, spec) {
// Omit undefined
// https://github.com/nodeca/js-yaml/issues/356#issuecomment-312430599
const cleaned = JSON.parse(JSON.stringify(spec))
fs.writeFileSync(
filename,
yaml.dump(cleaned, { flowLevel: 5, forceQuotes: true }),
)
}
;(async () => {
const definitions = await collectDefinitions()
for (const category of definitions.categories) {
const services = definitions.services.filter(
service => service.category === category.id && !service.isDeprecated,
)
writeSpec(
path.join(specsPath, `${category.id}.yaml`),
category2openapi(category, services),
)
}
let coreServices = []
coreServices = coreServices.concat(
definitions.services.filter(
service => service.category === 'static' && !service.isDeprecated,
),
)
coreServices = coreServices.concat(
definitions.services.filter(
service => service.category === 'dynamic' && !service.isDeprecated,
),
)
writeSpec(
path.join(specsPath, '1core.yaml'),
category2openapi({ name: 'Core' }, coreServices),
)
})()