diff --git a/packages/core/src/base-task-result.ts b/packages/core/src/base-task-result.ts index d1ba3f5ee..0834206bf 100644 --- a/packages/core/src/base-task-result.ts +++ b/packages/core/src/base-task-result.ts @@ -1,4 +1,4 @@ -import { TaskMetaData } from './types'; +import { TaskMetaData } from './types/tasks'; export default abstract class BaseTaskResult { meta: TaskMetaData; diff --git a/packages/core/src/configuration/checkup-config-service.ts b/packages/core/src/configuration/checkup-config-service.ts index e2da09132..278925d05 100644 --- a/packages/core/src/configuration/checkup-config-service.ts +++ b/packages/core/src/configuration/checkup-config-service.ts @@ -2,7 +2,12 @@ import * as debug from 'debug'; import * as fs from 'fs'; import * as yaml from 'js-yaml'; -import { CheckupConfig, CheckupConfigFormat, CheckupConfigLoader, ConfigMapper } from '../types'; +import { + CheckupConfig, + CheckupConfigFormat, + CheckupConfigLoader, + ConfigMapper, +} from '../types/configuration'; import { RuntimeCheckupConfig } from '../types/runtime-types'; import { fold } from 'fp-ts/lib/Either'; diff --git a/packages/core/src/configuration/cosmiconfig-service.ts b/packages/core/src/configuration/cosmiconfig-service.ts index 494a05612..20ae949cf 100644 --- a/packages/core/src/configuration/cosmiconfig-service.ts +++ b/packages/core/src/configuration/cosmiconfig-service.ts @@ -1,6 +1,7 @@ -import { cosmiconfig, defaultLoaders } from 'cosmiconfig'; import * as path from 'path'; -import { CheckupConfigFormat, CosmiconfigServiceResult } from '../types'; + +import { CheckupConfigFormat, CosmiconfigServiceResult } from '../types/configuration'; +import { cosmiconfig, defaultLoaders } from 'cosmiconfig'; type ConfigExtension = '.js' | '.json' | '.yml' | '.yaml'; const EXTENSION_TO_FORMAT: Record = { diff --git a/packages/core/src/configuration/loaders/get-filepath-loader.ts b/packages/core/src/configuration/loaders/get-filepath-loader.ts index 09ff62c96..52187cd3c 100644 --- a/packages/core/src/configuration/loaders/get-filepath-loader.ts +++ b/packages/core/src/configuration/loaders/get-filepath-loader.ts @@ -1,4 +1,4 @@ -import { CheckupConfigLoader } from '../../types'; +import { CheckupConfigLoader } from '../../types/configuration'; import CosmiconfigService from '../cosmiconfig-service'; /** diff --git a/packages/core/src/configuration/loaders/get-initialization-loader.ts b/packages/core/src/configuration/loaders/get-initialization-loader.ts index 86f40465f..a518c2c7f 100644 --- a/packages/core/src/configuration/loaders/get-initialization-loader.ts +++ b/packages/core/src/configuration/loaders/get-initialization-loader.ts @@ -1,6 +1,7 @@ -import { CheckupConfigFormat, CheckupConfigLoader } from '../../types'; import * as path from 'path'; +import { CheckupConfigFormat, CheckupConfigLoader } from '../../types/configuration'; + /** * Get a config loader given a filepath and the config format. This loader should * be used when initializing a new config (i.e. not loading a config from disk). diff --git a/packages/core/src/configuration/loaders/get-search-loader.ts b/packages/core/src/configuration/loaders/get-search-loader.ts index a2b077a3d..3abf0e87c 100644 --- a/packages/core/src/configuration/loaders/get-search-loader.ts +++ b/packages/core/src/configuration/loaders/get-search-loader.ts @@ -1,4 +1,4 @@ -import { CheckupConfigLoader } from '../../types'; +import { CheckupConfigLoader } from '../../types/configuration'; import CosmiconfigService from '../cosmiconfig-service'; /** diff --git a/packages/core/src/file-searcher-task.ts b/packages/core/src/file-searcher-task.ts index de8890ab7..d4425a360 100644 --- a/packages/core/src/file-searcher-task.ts +++ b/packages/core/src/file-searcher-task.ts @@ -1,6 +1,6 @@ import BaseTask from './base-task'; import FileSearcher from './searchers/file-searcher'; -import { SearchPatterns } from './types'; +import { SearchPatterns } from './types/tasks'; /** * @class FileSearcherTask diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 4308a727e..e8fbd3ccc 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -23,5 +23,7 @@ export { getPackageJson } from './utils/get-package-json'; export { ui } from './utils/ui'; export { toPairs } from './utils/data-transformers'; -export * from './types'; +export * from './types/parsers'; +export * from './types/tasks'; +export * from './types/configuration'; export * from './types/ember-template-lint'; diff --git a/packages/core/src/parsers/ember-template-lint-parser.ts b/packages/core/src/parsers/ember-template-lint-parser.ts index ac610bb9e..98ab78fb3 100644 --- a/packages/core/src/parsers/ember-template-lint-parser.ts +++ b/packages/core/src/parsers/ember-template-lint-parser.ts @@ -1,6 +1,6 @@ import * as fs from 'fs'; -import { CreateParser, Parser } from '../types'; +import { CreateParser, Parser } from '../types/parsers'; import { TemplateLintConfig, TemplateLintMessage, diff --git a/packages/core/src/parsers/eslint-parser.ts b/packages/core/src/parsers/eslint-parser.ts index a769e7e25..03b5821c6 100644 --- a/packages/core/src/parsers/eslint-parser.ts +++ b/packages/core/src/parsers/eslint-parser.ts @@ -1,4 +1,4 @@ -import { CreateParser, Parser } from '../types'; +import { CreateParser, Parser } from '../types/parsers'; import { CLIEngine } from 'eslint'; diff --git a/packages/core/src/parsers/registered-parsers.ts b/packages/core/src/parsers/registered-parsers.ts index 123d70447..2850f37cf 100644 --- a/packages/core/src/parsers/registered-parsers.ts +++ b/packages/core/src/parsers/registered-parsers.ts @@ -1,4 +1,4 @@ -import { CreateParser, Parser, ParserName, ParserOptions, ParserReport } from '../types'; +import { CreateParser, Parser, ParserName, ParserOptions, ParserReport } from '../types/parsers'; import { createParser as createEmberTemplateLintParser } from './ember-template-lint-parser'; import { createParser as createEslintParser } from './eslint-parser'; diff --git a/packages/core/src/report-components/graded-table-data.ts b/packages/core/src/report-components/graded-table-data.ts index f04c547cd..550f87f5c 100644 --- a/packages/core/src/report-components/graded-table-data.ts +++ b/packages/core/src/report-components/graded-table-data.ts @@ -1,4 +1,5 @@ -import { TaskMetaData, Grade, DependencyResult, ReportComponentType } from '../types'; +import { DependencyResult, Grade, ReportComponentType, TaskMetaData } from '../types/tasks'; + import { default as TableData } from './table-data'; export default class GradedTableData extends TableData { diff --git a/packages/core/src/report-components/numerical-card-data.ts b/packages/core/src/report-components/numerical-card-data.ts index 90f2d2cf4..f2f6694c4 100644 --- a/packages/core/src/report-components/numerical-card-data.ts +++ b/packages/core/src/report-components/numerical-card-data.ts @@ -1,4 +1,5 @@ -import { TaskMetaData, Grade, ReportComponentType } from '../types'; +import { Grade, ReportComponentType, TaskMetaData } from '../types/tasks'; + import { ReportComponentData } from './report-component-data'; export default class NumericalCardData extends ReportComponentData { diff --git a/packages/core/src/report-components/pie-chart-data.ts b/packages/core/src/report-components/pie-chart-data.ts index 42bab2d35..aa07d2da1 100644 --- a/packages/core/src/report-components/pie-chart-data.ts +++ b/packages/core/src/report-components/pie-chart-data.ts @@ -1,4 +1,5 @@ -import { TaskMetaData, Grade, ReportComponentType } from '../types'; +import { Grade, ReportComponentType, TaskMetaData } from '../types/tasks'; + import { ReportComponentData } from './report-component-data'; export default class PieChartData extends ReportComponentData { diff --git a/packages/core/src/report-components/report-component-data.ts b/packages/core/src/report-components/report-component-data.ts index 4075aa530..a0cd6b5b1 100644 --- a/packages/core/src/report-components/report-component-data.ts +++ b/packages/core/src/report-components/report-component-data.ts @@ -1,4 +1,4 @@ -import { TaskMetaData, ReportComponentType } from '../types'; +import { ReportComponentType, TaskMetaData } from '../types/tasks'; export abstract class ReportComponentData { constructor(public meta: TaskMetaData, public componentType: ReportComponentType) {} diff --git a/packages/core/src/report-components/table-data.ts b/packages/core/src/report-components/table-data.ts index 41c6910b9..d259cd98e 100644 --- a/packages/core/src/report-components/table-data.ts +++ b/packages/core/src/report-components/table-data.ts @@ -1,4 +1,5 @@ -import { TaskMetaData, ReportComponentType, DependencyResult } from '../types'; +import { DependencyResult, ReportComponentType, TaskMetaData } from '../types/tasks'; + import { ReportComponentData } from './report-component-data'; export default class TableData extends ReportComponentData { diff --git a/packages/core/src/searchers/file-searcher.ts b/packages/core/src/searchers/file-searcher.ts index 22718d5b3..eba7e16ba 100644 --- a/packages/core/src/searchers/file-searcher.ts +++ b/packages/core/src/searchers/file-searcher.ts @@ -1,6 +1,6 @@ import * as globby from 'globby'; -import { SearchPatterns, TaskItemData } from '../types'; +import { SearchPatterns, TaskItemData } from '../types/tasks'; const IGNORE_PATTERNS: string[] = [ '!**/node_modules/**', diff --git a/packages/core/src/types/configuration.ts b/packages/core/src/types/configuration.ts new file mode 100644 index 000000000..e214fd402 --- /dev/null +++ b/packages/core/src/types/configuration.ts @@ -0,0 +1,24 @@ +import * as t from 'io-ts'; + +import { RuntimeCheckupConfig, RuntimeTaskConfig } from './runtime-types'; + +import { PromiseValue } from 'type-fest'; + +export type CheckupConfig = t.TypeOf; +export type TaskConfig = t.TypeOf; + +export enum CheckupConfigFormat { + JSON = 'JSON', + YAML = 'YAML', + JavaScript = 'JavaScript', +} + +export type CheckupConfigLoader = () => Promise<{ + format: CheckupConfigFormat; + filepath: string; + config: CheckupConfig; +}>; + +export type ConfigMapper = (config: CheckupConfig) => CheckupConfig; + +export type CosmiconfigServiceResult = PromiseValue> | null; diff --git a/packages/core/src/types/parsers.ts b/packages/core/src/types/parsers.ts new file mode 100644 index 000000000..d1394dd63 --- /dev/null +++ b/packages/core/src/types/parsers.ts @@ -0,0 +1,10 @@ +export type ParserName = string; +export type ParserOptions = Record; +export type ParserReport = any; +export interface Parser { + execute(paths: string[]): Promise; +} + +export interface CreateParser> { + (config: ParserOptions): TParser; +} diff --git a/packages/core/src/types/index.ts b/packages/core/src/types/tasks.ts similarity index 63% rename from packages/core/src/types/index.ts rename to packages/core/src/types/tasks.ts index 43d0b85a0..709abe466 100644 --- a/packages/core/src/types/index.ts +++ b/packages/core/src/types/tasks.ts @@ -1,25 +1,37 @@ -import * as t from 'io-ts'; - -import { JsonObject, PromiseValue } from 'type-fest'; -import { RuntimeCheckupConfig, RuntimeTaskConfig } from './runtime-types'; - import GradedTableData from '../report-components/graded-table-data'; +import { JsonObject } from 'type-fest'; import NumericalCardData from '../report-components/numerical-card-data'; import PieChartData from '../report-components/pie-chart-data'; import TableData from '../report-components/table-data'; -export type CheckupConfig = t.TypeOf; -export type TaskConfig = t.TypeOf; -export type ParserName = string; +export type TaskName = string; +export type TaskClassification = { + category: Category; + priority: Priority; +}; + +export interface Task { + meta: TaskMetaData; + + run: () => Promise; +} -export type ParserOptions = Record; -export type ParserReport = any; -export interface Parser { - execute(paths: string[]): Promise; +export interface TaskResult { + stdout: () => void; + json: () => JsonMetaTaskResult | JsonTaskResult; + pdf: () => ReportResultData; +} + +export interface TaskMetaData { + taskName: TaskName; + friendlyTaskName: TaskName; + taskClassification: TaskClassification; } -export interface CreateParser> { - (config: ParserOptions): TParser; +export interface TaskItemData { + type: string; + data: string[]; + total: number; } export const enum Category { @@ -34,16 +46,11 @@ export const enum Priority { Medium = 'medium', Low = 'low', } -export type TaskName = string; -export type TaskClassification = { - category: Category; - priority: Priority; -}; - -export interface Task { - meta: TaskMetaData; - run: () => Promise; +export interface DependencyResult { + name: string; + value: string; + grade?: Grade; } export type JsonMetaTaskResult = JsonObject; @@ -53,6 +60,15 @@ export type JsonTaskResult = { result: {}; }; +export type ReportResultData = NumericalCardData | TableData | GradedTableData | PieChartData; + +export const enum ReportComponentType { + NumericalCard = 'numerical-card', + Table = 'table', + GradedTable = 'graded-table', + PieChart = 'pie-chart', +} + export const enum Grade { A = 'A', B = 'B', @@ -67,53 +83,4 @@ export enum ReporterType { pdf = 'pdf', } -export type ReportResultData = NumericalCardData | TableData | GradedTableData | PieChartData; - -export const enum ReportComponentType { - NumericalCard = 'numerical-card', - Table = 'table', - GradedTable = 'graded-table', - PieChart = 'pie-chart', -} - -export interface TaskResult { - stdout: () => void; - json: () => JsonMetaTaskResult | JsonTaskResult; - pdf: () => ReportResultData; -} - -export interface TaskMetaData { - taskName: TaskName; - friendlyTaskName: TaskName; - taskClassification: TaskClassification; -} - -export interface TaskItemData { - type: string; - data: string[]; - total: number; -} - -export interface DependencyResult { - name: string; - value: string; - grade?: Grade; -} - export type SearchPatterns = Record; - -export enum CheckupConfigFormat { - JSON = 'JSON', - YAML = 'YAML', - JavaScript = 'JavaScript', -} - -export type CheckupConfigLoader = () => Promise<{ - format: CheckupConfigFormat; - filepath: string; - config: CheckupConfig; -}>; - -export type ConfigMapper = (config: CheckupConfig) => CheckupConfig; - -export type CosmiconfigServiceResult = PromiseValue> | null; diff --git a/packages/core/src/utils/task-result-comparator.ts b/packages/core/src/utils/task-result-comparator.ts index b13dbe5d9..20c874d91 100644 --- a/packages/core/src/utils/task-result-comparator.ts +++ b/packages/core/src/utils/task-result-comparator.ts @@ -1,4 +1,4 @@ -import { Category, Priority, TaskClassification } from '../types'; +import { Category, Priority, TaskClassification } from '../types/tasks'; import BaseTaskResult from '../base-task-result';