Skip to content

Commit

Permalink
chore(parser-adapter-workflows-yaml-1): use API Extractor for TypeScr…
Browse files Browse the repository at this point in the history
…ipt rollup (#4527)

Refs #4382
  • Loading branch information
glowcloud authored Nov 21, 2024
1 parent 6ee0532 commit ec9053d
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.

8 changes: 4 additions & 4 deletions packages/apidom-parser-adapter-workflows-yaml-1/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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'",
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-workflows-yaml-1.d.ts",
"LICENSES",
"NOTICE",
"README.md",
Expand Down
12 changes: 12 additions & 0 deletions packages/apidom-parser-adapter-workflows-yaml-1/src/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,21 @@ import workflowsNamespace, {

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

/**
* @public
*/
export const detectionRegExp =
/(?<YAML>^(["']?)workflowsSpec\2\s*:\s*(["']?)(?<version_yaml>1\.(?:[1-9]\d*|0)\.(?:[1-9]\d*|0))\3(?:\s+|$))|(?<JSON>"workflowsSpec"\s*:\s*"(?<version_json>1\.(?:[1-9]\d*|0)\.(?:[1-9]\d*|0))")/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 @@ -38,4 +47,7 @@ export const parse = async (
return parseResultElement;
};

/**
* @public
*/
export const namespace = createNamespace(workflowsNamespace);
Original file line number Diff line number Diff line change
@@ -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'),
Expand Down

0 comments on commit ec9053d

Please sign in to comment.