Skip to content

Commit

Permalink
chore(parser-adapter-api-design-systems-yaml): use API Extractor for …
Browse files Browse the repository at this point in the history
…TypeScript rollup (#4525)

Refs #4382
  • Loading branch information
glowcloud authored Nov 21, 2024
1 parent 2bd39d8 commit 5adb4f5
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -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"
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
"unpkg": "./dist/apidom-parser-adapter-api-design-systems-yaml.browser.min.js",
"main": "./src/adapter.cjs",
"exports": {
"types": "./types/dist.d.ts",
"types": "./types/apidom-parser-adapter-api-design-systems-yaml.d.ts",
"import": "./src/adapter.mjs",
"require": "./src/adapter.cjs"
},
"types": "./types/dist.d.ts",
"types": "./types/apidom-parser-adapter-api-design-systems-yaml.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'",
Expand All @@ -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"
Expand All @@ -49,7 +49,7 @@
"src/**/*.mjs",
"src/**/*.cjs",
"dist/",
"types/dist.d.ts",
"types/apidom-parser-adapter-api-design-systems-yaml.d.ts",
"LICENSES",
"NOTICE",
"README.md",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,21 @@ import apiDesignSystemsNamespace, { MainElement } from '@swagger-api/apidom-ns-a

export { default as mediaTypes } from './media-types.ts';

/**
* @public
*/
export const detectionRegExp =
/(?<YAML>^(["']?)version\2\s*:\s*(["']?)(?<version_yaml>2021-05-07)\3)|(?<JSON>"version"\s*:\s*"(?<version_json>2021-05-07)")/m;

/**
* @public
*/
export const detect = async (source: string): Promise<boolean> =>
detectionRegExp.test(source) && (await detectYAML(source));

/**
* @public
*/
export const parse = async (
source: string,
options: Record<string, unknown> = {},
Expand All @@ -33,4 +42,7 @@ export const parse = async (
return parseResultElement;
};

/**
* @public
*/
export const namespace = createNamespace(apiDesignSystemsNamespace);
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { mediaTypes, ApiDesignSystemsMediaTypes } from '@swagger-api/apidom-ns-api-design-systems';

/**
* @public
*/
const yamlMediaTypes = new ApiDesignSystemsMediaTypes(
...mediaTypes.filterByFormat('generic'),
...mediaTypes.filterByFormat('yaml'),
Expand Down

0 comments on commit 5adb4f5

Please sign in to comment.