From b21bfa30a0f4340f0d4c1f7cf6a68b52128f7e7c Mon Sep 17 00:00:00 2001 From: Diego Ferreiro Val Date: Sat, 15 Jun 2019 07:21:35 -0700 Subject: [PATCH] fix: config types --- packages/@best/config/src/index.ts | 56 +++++++++--------------------- packages/@best/config/src/types.ts | 6 +++- yarn.lock | 10 +++--- 3 files changed, 26 insertions(+), 46 deletions(-) diff --git a/packages/@best/config/src/index.ts b/packages/@best/config/src/index.ts index dc32261c..4be4f8c8 100644 --- a/packages/@best/config/src/index.ts +++ b/packages/@best/config/src/index.ts @@ -2,65 +2,47 @@ import { resolveConfigPath, readConfigAndSetRootDir, ensureNoDuplicateConfigs } from './utils/resolve-config'; import { getGitInfo, GitInfo } from './utils/git'; import { normalizeConfig, normalizeRegexPattern, normalizeRootDirPattern } from './utils/normalize'; -import { BestCliOptions, DefaultProjectOptions, GlobalConfig, ProjectConfig } from './types'; +import { BestCliOptions, DefaultProjectOptions, GlobalConfig, ProjectConfig, FrozenProjectConfig, FrozenGlobalConfig } from './types'; export { BestCliOptions }; -function generateProjectConfigs(options: DefaultProjectOptions, isRoot: boolean, gitInfo?: GitInfo): { projectConfig: ProjectConfig, globalConfig: GlobalConfig | undefined } { - let globalConfig: GlobalConfig | undefined = undefined; - let projectConfig: ProjectConfig; +function generateProjectConfigs(options: DefaultProjectOptions, isRoot: boolean, gitInfo?: GitInfo): { projectConfig: FrozenProjectConfig, globalConfig: FrozenGlobalConfig | undefined } { + let globalConfig: FrozenGlobalConfig | undefined; if (isRoot) { globalConfig = Object.freeze({ gitIntegration: options.gitIntegration, detectLeaks: options.detectLeaks, compareStats: options.compareStats, - outputFile: options.outputFile, externalStorage: options.externalStorage, apiDatabase: options.apiDatabase, projects: options.projects, rootDir: options.rootDir, rootProjectName: options.projectName, nonFlagArgs: options.nonFlagArgs, - testNamePattern: options.testNamePattern, - testPathPattern: options.testPathPattern, - verbose: options.verbose, gitInfo: gitInfo, - gitCommit: options.gitCommit, - gitCommitDate: options.gitCommitDate, - gitLocalChanges: options.gitLocalChanges, - gitBranch: options.gitBranch, - gitRepository: options.gitRepository, - normalize: options.normalize, - outputMetricPattern: normalizeRegexPattern(options.outputMetricNames), - outputTotals: options.outputTotals, - outputHistograms: options.outputHistograms, - outputHistogramPattern: normalizeRegexPattern(options.outputHistogramNames), - histogramQuantileRange: options.histogramQuantileRange, - histogramMaxWidth: options.histogramMaxWidth, - openPages: options.openPages, + // outputMetricPattern: normalizeRegexPattern(options.outputMetricNames), + // outputTotals: options.outputTotals, + // outputHistograms: options.outputHistograms, + // outputHistogramPattern: normalizeRegexPattern(options.outputHistogramNames), + // histogramQuantileRange: options.histogramQuantileRange, + // histogramMaxWidth: options.histogramMaxWidth, + // normalize: options.normalize, + // openPages: options.openPages, }); } - projectConfig = Object.freeze({ + const projectConfig: ProjectConfig = Object.freeze({ cache: options.cache, cacheDirectory: options.cacheDirectory, useHttp: options.useHttp, - cwd: options.cwd, detectLeaks: options.detectLeaks, displayName: options.displayName, - globals: options.globals, moduleDirectories: options.moduleDirectories, moduleFileExtensions: options.moduleFileExtensions, - moduleLoader: options.moduleLoader, - moduleNameMapper: options.moduleNameMapper, - modulePathIgnorePatterns: options.modulePathIgnorePatterns, - modulePaths: options.modulePaths, - name: options.name, plugins: options.plugins, rootDir: options.rootDir, - roots: options.roots, - projectName: options.projectName, + benchmarkRunner: options.runnerConfig.runner || options.runner, benchmarkRunnerConfig: options.runnerConfig.config || options.runnerConfig, benchmarkEnvironment: options.benchmarkEnvironment, @@ -73,12 +55,6 @@ function generateProjectConfigs(options: DefaultProjectOptions, isRoot: boolean, testMatch: options.testMatch, testPathIgnorePatterns: options.testPathIgnorePatterns, - testRegex: options.testRegex, - testURL: options.testURL, - transform: options.transform, - transformIgnorePatterns: options.transformIgnorePatterns, - - samplesQuantileThreshold: options.samplesQuantileThreshold, }); return { globalConfig, projectConfig }; @@ -104,9 +80,9 @@ export async function readConfig(cliOptions: BestCliOptions, packageRoot: string return { configPath, globalConfig, projectConfig }; } -export async function getConfigs(projectsFromCLIArgs: string[], cliOptions: BestCliOptions): Promise<{ globalConfig: GlobalConfig, configs: ProjectConfig[] }> { - let globalConfig: GlobalConfig | undefined; - let configs: ProjectConfig[] = []; +export async function getConfigs(projectsFromCLIArgs: string[], cliOptions: BestCliOptions): Promise<{ globalConfig: FrozenGlobalConfig, configs: FrozenProjectConfig[] }> { + let globalConfig: FrozenGlobalConfig | undefined; + let configs: FrozenProjectConfig[] = []; let projects: string[] = []; let configPath: string; diff --git a/packages/@best/config/src/types.ts b/packages/@best/config/src/types.ts index 29647095..f4bfabdf 100644 --- a/packages/@best/config/src/types.ts +++ b/packages/@best/config/src/types.ts @@ -52,14 +52,18 @@ export interface BestCliOptions { projects: string[], iterations: number, compareStats: string[] | undefined -}; +} export interface GlobalConfig { gitIntegration: boolean; projects: string[]; + detectLeaks: boolean; } export interface ProjectConfig { } + +export type FrozenGlobalConfig = Readonly; +export type FrozenProjectConfig = Readonly; diff --git a/yarn.lock b/yarn.lock index 64c3f92b..450f12ae 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11259,12 +11259,12 @@ signal-exit@^3.0.0, signal-exit@^3.0.2: resolved "http://npm.lwcjs.org/signal-exit/-/signal-exit-3.0.2/b5fdc08f1287ea1178628e415e25132b73646c6d.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d" integrity sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0= -simple-git@~1.92.0: - version "1.92.0" - resolved "http://npm.lwcjs.org/simple-git/-/simple-git-1.92.0/6061468eb7d19f0141078fc742e62457e910f547.tgz#6061468eb7d19f0141078fc742e62457e910f547" - integrity sha1-YGFGjrfRnwFBB4/HQuYkV+kQ9Uc= +simple-git@~1.113.0: + version "1.113.0" + resolved "http://npm.lwcjs.org/simple-git/-/simple-git-1.113.0/668989728a1e9cf4ec6c72b69ea2eecc93489bea.tgz#668989728a1e9cf4ec6c72b69ea2eecc93489bea" + integrity sha512-i9WVsrK2u0G/cASI9nh7voxOk9mhanWY9eGtWBDSYql6m49Yk5/Fan6uZsDr/xmzv8n+eQ8ahKCoEr8cvU3h+g== dependencies: - debug "^3.1.0" + debug "^4.0.1" simple-statistics@^6.0.1: version "6.1.1"