From ec9053d9e7a72e7eb5975193f606f1f950a5e659 Mon Sep 17 00:00:00 2001 From: Oliwia Rogala Date: Thu, 21 Nov 2024 10:40:17 +0100 Subject: [PATCH] chore(parser-adapter-workflows-yaml-1): use API Extractor for TypeScript rollup (#4527) Refs #4382 --- .../config/api-extractor/api-extractor.json | 5 +++++ .../config/rollup/types.dist.js | 11 ----------- .../package.json | 8 ++++---- .../src/adapter.ts | 12 ++++++++++++ .../src/media-types.ts | 3 +++ 5 files changed, 24 insertions(+), 15 deletions(-) create mode 100644 packages/apidom-parser-adapter-workflows-yaml-1/config/api-extractor/api-extractor.json delete mode 100644 packages/apidom-parser-adapter-workflows-yaml-1/config/rollup/types.dist.js diff --git a/packages/apidom-parser-adapter-workflows-yaml-1/config/api-extractor/api-extractor.json b/packages/apidom-parser-adapter-workflows-yaml-1/config/api-extractor/api-extractor.json new file mode 100644 index 0000000000..40bee5b261 --- /dev/null +++ b/packages/apidom-parser-adapter-workflows-yaml-1/config/api-extractor/api-extractor.json @@ -0,0 +1,5 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", + "extends": "../../../../api-extractor.json", + "mainEntryPointFilePath": "../../types/adapter.d.ts" +} diff --git a/packages/apidom-parser-adapter-workflows-yaml-1/config/rollup/types.dist.js b/packages/apidom-parser-adapter-workflows-yaml-1/config/rollup/types.dist.js deleted file mode 100644 index 6ecc45f65c..0000000000 --- a/packages/apidom-parser-adapter-workflows-yaml-1/config/rollup/types.dist.js +++ /dev/null @@ -1,11 +0,0 @@ -import dts from 'rollup-plugin-dts'; - -const config = [ - { - input: './types/adapter.d.ts', - output: [{ file: 'types/dist.d.ts', format: 'es' }], - plugins: [dts()], - }, -]; - -export default config; diff --git a/packages/apidom-parser-adapter-workflows-yaml-1/package.json b/packages/apidom-parser-adapter-workflows-yaml-1/package.json index 76d4558314..85615dd07b 100644 --- a/packages/apidom-parser-adapter-workflows-yaml-1/package.json +++ b/packages/apidom-parser-adapter-workflows-yaml-1/package.json @@ -11,11 +11,11 @@ "unpkg": "./dist/apidom-parser-adapter-workflows-yaml-1.browser.min.js", "main": "./src/adapter.cjs", "exports": { - "types": "./types/dist.d.ts", + "types": "./types/apidom-parser-adapter-workflows-yaml-1.d.ts", "import": "./src/adapter.mjs", "require": "./src/adapter.cjs" }, - "types": "./types/dist.d.ts", + "types": "./types/apidom-parser-adapter-workflows-yaml-1.d.ts", "scripts": { "build": "npm run clean && run-p --max-parallel ${CPU_CORES:-2} typescript:declaration build:es build:cjs build:umd:browser", "build:es": "cross-env BABEL_ENV=es babel src --out-dir src --extensions '.ts' --out-file-extension '.mjs' --root-mode 'upward'", @@ -25,7 +25,7 @@ "lint:fix": "eslint ./ --fix", "clean": "rimraf --glob 'src/**/*.mjs' 'src/**/*.cjs' 'test/**/*.mjs' ./dist ./types", "typescript:check-types": "tsc --noEmit && tsc -p ./test/tsconfig.json --noEmit", - "typescript:declaration": "tsc -p tsconfig.declaration.json && rollup -c config/rollup/types.dist.js", + "typescript:declaration": "tsc -p tsconfig.declaration.json && api-extractor run -l -c ./config/api-extractor/api-extractor.json", "test": "npm run build:es && cross-env BABEL_ENV=es babel test --out-dir test --extensions '.ts' --out-file-extension '.mjs' --root-mode 'upward' && cross-env NODE_ENV=test mocha", "prepack": "copyfiles -u 3 ../../LICENSES/* LICENSES && copyfiles -u 2 ../../NOTICE .", "postpack": "rimraf NOTICE LICENSES" @@ -49,7 +49,7 @@ "src/**/*.mjs", "src/**/*.cjs", "dist/", - "types/dist.d.ts", + "types/apidom-parser-adapter-workflows-yaml-1.d.ts", "LICENSES", "NOTICE", "README.md", diff --git a/packages/apidom-parser-adapter-workflows-yaml-1/src/adapter.ts b/packages/apidom-parser-adapter-workflows-yaml-1/src/adapter.ts index 348daa04e7..2e5276f1d9 100644 --- a/packages/apidom-parser-adapter-workflows-yaml-1/src/adapter.ts +++ b/packages/apidom-parser-adapter-workflows-yaml-1/src/adapter.ts @@ -11,12 +11,21 @@ import workflowsNamespace, { export { default as mediaTypes } from './media-types.ts'; +/** + * @public + */ export const detectionRegExp = /(?^(["']?)workflowsSpec\2\s*:\s*(["']?)(?1\.(?:[1-9]\d*|0)\.(?:[1-9]\d*|0))\3(?:\s+|$))|(?"workflowsSpec"\s*:\s*"(?1\.(?:[1-9]\d*|0)\.(?:[1-9]\d*|0))")/m; +/** + * @public + */ export const detect = async (source: string): Promise => detectionRegExp.test(source) && (await detectYAML(source)); +/** + * @public + */ export const parse = async ( source: string, options: Record = {}, @@ -38,4 +47,7 @@ export const parse = async ( return parseResultElement; }; +/** + * @public + */ export const namespace = createNamespace(workflowsNamespace); diff --git a/packages/apidom-parser-adapter-workflows-yaml-1/src/media-types.ts b/packages/apidom-parser-adapter-workflows-yaml-1/src/media-types.ts index f68df11fca..d72ed20fe1 100644 --- a/packages/apidom-parser-adapter-workflows-yaml-1/src/media-types.ts +++ b/packages/apidom-parser-adapter-workflows-yaml-1/src/media-types.ts @@ -1,5 +1,8 @@ import { mediaTypes, WorkflowsMediaTypes } from '@swagger-api/apidom-ns-workflows-1'; +/** + * @public + */ const yamlMediaTypes = new WorkflowsMediaTypes( ...mediaTypes.filterByFormat('generic'), ...mediaTypes.filterByFormat('yaml'),