mirror of
https://github.com/badges/shields.git
synced 2026-11-21 16:06:35 +03:00
* chore(deps): bump js-yaml from 4.2.0 to 5.0.0 Bumps [js-yaml](https://github.com/nodeca/js-yaml) from 4.2.0 to 5.0.0. - [Changelog](https://github.com/nodeca/js-yaml/blob/master/CHANGELOG.md) - [Commits](https://github.com/nodeca/js-yaml/compare/4.2.0...5.0.0) --- updated-dependencies: - dependency-name: js-yaml dependency-version: 5.0.0 dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> * Migrate code --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Pierre-Yves Bigourdan <10694593+PyvesB@users.noreply.github.com>
54 lines
1.4 KiB
JavaScript
54 lines
1.4 KiB
JavaScript
import fs from 'fs'
|
|
import path from 'path'
|
|
import * as 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, quoteStyle: 'double' }),
|
|
)
|
|
}
|
|
|
|
;(async () => {
|
|
const definitions = await collectDefinitions()
|
|
|
|
for (const category of definitions.categories) {
|
|
const services = definitions.services.filter(
|
|
service => service.category === category.id && !service.isRetired,
|
|
)
|
|
|
|
writeSpec(
|
|
path.join(specsPath, `${category.id}.yaml`),
|
|
category2openapi({ category, services, sort: true }),
|
|
)
|
|
}
|
|
|
|
let coreServices = []
|
|
coreServices = coreServices.concat(
|
|
definitions.services.filter(
|
|
service => service.category === 'static' && !service.isRetired,
|
|
),
|
|
)
|
|
coreServices = coreServices.concat(
|
|
definitions.services.filter(
|
|
service => service.category === 'dynamic' && !service.isRetired,
|
|
),
|
|
)
|
|
writeSpec(
|
|
path.join(specsPath, '1core.yaml'),
|
|
category2openapi({
|
|
category: { name: 'Core' },
|
|
services: coreServices,
|
|
sort: false,
|
|
}),
|
|
)
|
|
})()
|