UNPKG

3.54 kBTypeScriptView Raw
1import { ICruiseResult } from "./cruise-result";
2import { ICruiseOptions } from "./options";
3import { OutputType } from "./shared-types";
4export * from "./rule-set";
5export * from "./options";
6export * from "./configuration";
7export * from "./shared-types";
8export * from "./cruise-result";
9
10/**
11 * all supported extensions; for each extension whether or not
12 * it is supported in the current environment
13 */
14export const allExtensions: IAvailableExtension[];
15
16export interface IAvailableExtension {
17 /**
18 * File extension (e.g. ".js", ".ts", ".jsx")
19 */
20 extension: string;
21 /**
22 * Whether or not the extension is available as supported in the current environment
23 */
24 available: boolean;
25}
26
27export interface IAvailableTranspiler {
28 /**
29 * The name of the transpiler (e.g. "typescript", "coffeescript")
30 */
31 name: string;
32 /**
33 * A semver version range (e.g. ">=2.0.0 <3.0.0")
34 */
35 version: string;
36 /**
37 * Whether or not the transpiler is available in the current environment
38 */
39 available: boolean;
40}
41
42export interface IReporterOutput {
43 /**
44 * The output proper of the reporter. For most reporters this will be
45 * a string.
46 */
47 output: ICruiseResult | string;
48 /**
49 * The exit code - reporters can return a non-zero value when they find
50 * errors here. api consumers (like a cli) can use this to return a
51 * non-zero exit code, so the build breaks when something is wrong
52 *
53 * This is e.g. the default behavior of the `err` and `err-long` reporters.
54 */
55 exitCode: number;
56}
57
58/**
59 * Cruises the specified files and files with supported extensions in
60 * the specified directories in the pFileDirArray and returns the result
61 * in an object.
62 *
63 * @param pFileDirArray An array of (names of) files, directories and/ or glob patterns
64 * to start the cruise with
65 * @param pOptions Options that influence the way the dependencies are cruised - and
66 * how they are returned.
67 * @param pResolveOptions Options that influence how dependency references are resolved to disk.
68 * See https://webpack.js.org/configuration/resolve/ for the details.
69 * @param pTSConfig An object with with a typescript config object. Note that the
70 * API will not take any 'extends' keys there into account, so
71 * before calling make sure to flatten them out if you want them
72 * used (the dependency-cruiser cli does this
73 * [here](../src/cli/parse-ts-config.js))
74 */
75export function cruise(
76 pFileDirArray: string[],
77 pOptions?: ICruiseOptions,
78 pResolveOptions?: any,
79 pTSConfig?: any
80): IReporterOutput;
81
82/**
83 * Given a cruise result, formats it with the given reporter (pOutputType)
84 *
85 * @param pResult A javascript object that contains the result of a cruise. Must adhere
86 * to the [dependency-cruiser results schema](https://github.com/sverweij/dependency-cruiser/blob/develop/src/schema/cruise-result.json)
87 * @param pOutputType Which reporter to use to format the cruise result with
88 */
89export function format(
90 pResult: ICruiseResult,
91 pOutputType: OutputType
92): IReporterOutput;
93
94/**
95 * Returns an array of supported transpilers and for each of the transpilers
96 * - the name of the transpiler
97 * - the supported version range (semver version range)
98 * - whether or not the transpiler is available in the current environment
99 */
100export function getAvailableTranspilers(): IAvailableTranspiler[];