Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(betterer 🔧): remove built-in TypeScript handling #1193

Merged
merged 1 commit into from
Apr 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"typescript.tsdk": "node_modules/typescript/lib",
"betterer.tsconfigPath": "./tsconfig.json",
"cSpell.words": [
"automerge",
"bettere",
Expand Down
18 changes: 4 additions & 14 deletions goldens/api/betterer.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const betterer: {
export type BettererAPI = typeof betterer;

// @public
export interface BettererConfig extends BettererConfigFS, BettererConfigReporter, BettererConfigContext, BettererConfigTypeScript, BettererConfigWatcher {
export interface BettererConfig extends BettererConfigFS, BettererConfigReporter, BettererConfigContext, BettererConfigWatcher {
versionControlPath: string;
}

Expand Down Expand Up @@ -67,11 +67,6 @@ export interface BettererConfigReporter {
reporter: BettererReporter;
}

// @public
export interface BettererConfigTypeScript {
tsconfigPath: string | null;
}

// @public
export interface BettererConfigWatcher {
ignores: BettererConfigIgnores;
Expand Down Expand Up @@ -223,7 +218,7 @@ export interface BettererFileTestResultSummary {
export type BettererFileTestResultSummaryDetails = Record<string, BettererFileIssues>;

// @public
export type BettererOptions = BettererOptionsContext & BettererOptionsFS & BettererOptionsMode & BettererOptionsReporter & BettererOptionsTypeScript;
export type BettererOptions = BettererOptionsContext & BettererOptionsFS & BettererOptionsMode & BettererOptionsReporter;

// @public
export type BettererOptionsContext = BettererOptionsMode & {
Expand Down Expand Up @@ -336,7 +331,7 @@ export interface BettererOptionsModeWatch {
// (undocumented)
precommit?: false;
// (undocumented)
strict?: false;
strict?: boolean;
// (undocumented)
update?: false;
}
Expand Down Expand Up @@ -370,12 +365,7 @@ export type BettererOptionsResults = Pick<BettererOptionsFS, 'cwd' | 'configPath
export type BettererOptionsRunner = BettererOptions;

// @public
export interface BettererOptionsTypeScript {
tsconfigPath?: string;
}

// @public
export type BettererOptionsWatch = BettererOptionsContext & BettererOptionsFS & BettererOptionsModeWatch & BettererOptionsReporter & BettererOptionsTypeScript & BettererOptionsWatcher;
export type BettererOptionsWatch = BettererOptionsContext & BettererOptionsFS & BettererOptionsModeWatch & BettererOptionsReporter & BettererOptionsWatcher;

// @public
export interface BettererOptionsWatcher {
Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
},
"scripts": {
"api": "yarn compile && lerna run api",
"betterer": "node ./packages/cli/bin/betterer",
"betterer:ci": "node ./packages/cli/bin/betterer ci",
"betterer:precommit": "node ./packages/cli/bin/betterer precommit --cache",
"betterer": "tsx ./packages/cli/bin/betterer",
"betterer:ci": "tsx ./packages/cli/bin/betterer ci",
"betterer:precommit": "tsx ./packages/cli/bin/betterer precommit --cache",
"build": "yarn compile:packages && yarn test:api && yarn test:dependencies && yarn format && yarn lint && yarn test && yarn test:workers && yarn test:e2e",
"build:ci": "yarn compile:packages && yarn test:api && yarn test:dependencies && yarn format && yarn lint && yarn test && yarn test:workers && yarn betterer:ci",
"build:extension": "lerna run build:extension",
Expand All @@ -32,12 +32,12 @@
"compile:packages": "yarn compile:render && tsc -b packages",
"compile:render": "lerna run compile --scope @betterer/render",
"compile:watch": "tsc -b packages -w",
"docs": "ts-node ./tools/docs-filter.ts && api-documenter generate -i ./goldens/models -o ./website/docs/api/",
"docs": "tsx ./tools/docs-filter.ts && api-documenter generate -i ./goldens/models -o ./website/docs/api/",
"lint": "eslint \"./packages/**/src/**/*.{js,ts}\" \"./test/**/*.{ts,tsx}\" \"./*.{js,ts}\" --fix",
"format": "prettier \"**/!(*.snap)\" --write --loglevel=error",
"test": "yarn clean:tests && node node_modules/jest-cli/bin/jest.js",
"test:api": "yarn compile:api-test && node ./test/api/dist",
"test:dependencies": "yarn compile:dependencies-test && node ./test/dependencies/dist",
"test:api": "yarn compile:api-test && tsx ./test/api/dist",
"test:dependencies": "yarn compile:dependencies-test && tsx ./test/dependencies/dist",
"test:debug": "yarn clean:tests && node --inspect-brk node_modules/jest-cli/bin/jest.js --runInBand --collectCoverage=false",
"test:e2e": "yarn clean:tests && jest --config ./jest.e2e.config.js",
"test:workers": "yarn clean:tests && jest --config ./jest.workers.config.js",
Expand Down Expand Up @@ -69,18 +69,18 @@
"eslint-config-prettier": "^8.1.0",
"eslint-import-resolver-typescript": "^3.5.5",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-require-extensions": "^0.1.3",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jest": "^24.4.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-require-extensions": "^0.1.3",
"husky": "^7.0.4",
"jest": "^27.0.4",
"lerna": "^6.6.2",
"lint-staged": ">=11.1.2",
"patch-package": "^8.0.0",
"prettier": "^2.2.1",
"ts-jest": "^27.0.5",
"ts-node": "^10.2.1",
"tsx": "^4.7.2",
"typescript": "^4.4.2"
},
"config": {
Expand Down
1 change: 0 additions & 1 deletion packages/betterer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"minimatch": "^5.0.1",
"prettier": "^2.3.2",
"simple-git": "^3.6.0",
"ts-node": "^10.2.1",
"tslib": "^2.3.1"
},
"optionalDependencies": {
Expand Down
5 changes: 1 addition & 4 deletions packages/betterer/src/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import type { BettererOptionsContext, BettererOptionsMode, BettererOptionsModeWa
import type { BettererOptionsFS } from '../fs/index.js';
import type { BettererOptionsReporter } from '../reporters/index.js';
import type { BettererOptionsWatcher } from '../runner/index.js';
import type { BettererOptionsTypeScript } from '../typescript/index.js';

/**
* @public Options for when you run **Betterer** via the {@link @betterer/betterer#betterer | `betterer()` API}.
Expand All @@ -12,8 +11,7 @@ import type { BettererOptionsTypeScript } from '../typescript/index.js';
export type BettererOptions = BettererOptionsContext &
BettererOptionsFS &
BettererOptionsMode &
BettererOptionsReporter &
BettererOptionsTypeScript;
BettererOptionsReporter;

/**
* @public Options for when you create a {@link @betterer/betterer#BettererRunner | `BettererRunner` }
Expand Down Expand Up @@ -42,5 +40,4 @@ export type BettererOptionsWatch = BettererOptionsContext &
BettererOptionsFS &
BettererOptionsModeWatch &
BettererOptionsReporter &
BettererOptionsTypeScript &
BettererOptionsWatcher;
2 changes: 0 additions & 2 deletions packages/betterer/src/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import type { BettererConfigContext, BettererOptionsContextOverride } from '../c
import type { BettererConfigFS } from '../fs/index.js';
import type { BettererConfigReporter, BettererOptionsReporterOverride } from '../reporters/index.js';
import type { BettererConfigWatcher, BettererOptionsWatcherOverride } from '../runner/index.js';
import type { BettererConfigTypeScript } from '../typescript/index.js';

/**
* @public Full validated config object for **Betterer**.
Expand All @@ -11,7 +10,6 @@ export interface BettererConfig
extends BettererConfigFS,
BettererConfigReporter,
BettererConfigContext,
BettererConfigTypeScript,
BettererConfigWatcher {
/**
* The path to the local version control root.
Expand Down
2 changes: 1 addition & 1 deletion packages/betterer/src/context/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export class BettererContextΩ implements BettererContext {
}

// Load test names in a worker so the import cache is always clean:
const testNames = await this._testMetaLoader.api.loadTestNames(this.config.tsconfigPath, this.config.configPaths);
const testNames = await this._testMetaLoader.api.loadTestNames(this.config.configPaths);

const runs = await Promise.all(
testNames.map(async (testName) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/betterer/src/context/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export interface BettererOptionsModeUpdate {
export interface BettererOptionsModeWatch {
ci?: false;
precommit?: false;
strict?: false;
strict?: boolean;
update?: false;
}

Expand Down
3 changes: 0 additions & 3 deletions packages/betterer/src/globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { BettererFSΩ, createFSConfig } from './fs/index.js';
import { createReporterConfig, loadDefaultReporter } from './reporters/index.js';
import { BettererResultsΩ } from './results/index.js';
import { createWatcherConfig } from './runner/index.js';
import { createTypeScriptConfig } from './typescript/index.js';

export async function createGlobals(
options: BettererOptions,
Expand All @@ -22,7 +21,6 @@ export async function createGlobals(
const configContext = createContextConfig(options);
const configFS = createFSConfig(options);
const configReporter = createReporterConfig(configFS, options);
const configTypeScript = await createTypeScriptConfig(configFS, options);
const configWatcher = createWatcherConfig(configFS, optionsWatch);

const { resultsFile, versionControl, versionControlPath } = await BettererFSΩ.create(configFS);
Expand All @@ -31,7 +29,6 @@ export async function createGlobals(
...configContext,
...configFS,
...configReporter,
...configTypeScript,
...configWatcher,
versionControlPath
});
Expand Down
1 change: 0 additions & 1 deletion packages/betterer/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ export type {
BettererTestOptionsComplex,
BettererTestNames
} from './test/public.js';
export type { BettererConfigTypeScript, BettererOptionsTypeScript } from './typescript/public.js';
export type { MaybeAsync } from './types.js';

export { betterer, merge, results, runner, watch } from './api/index.js';
Expand Down
5 changes: 0 additions & 5 deletions packages/betterer/src/reporters/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ export interface BettererOptionsReporter {
* @defaultValue `false`
*/
silent?: boolean;
/**
* The path to the {@link https://phenomnomnominal.github.io/betterer/docs/betterer-and-typescript | TypeScript configuration}.
* The `tsconfigPath` should be relative to the `cwd`.
* @defaultValue `null`
*/
}

/**
Expand Down
3 changes: 0 additions & 3 deletions packages/betterer/src/run/run.worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ export async function init(
config: BettererConfig,
versionControl: BettererVersionControlWorker
): Promise<BettererTestMeta> {
const { registerExtensions } = await import('../typescript/register.js');
await registerExtensions(config.tsconfigPath);

const worker = await BettererWorkerRunΩ.create(config, testName, versionControl);
TEST_NAME_RUN[testName] = worker;
return worker.testMeta;
Expand Down
1 change: 1 addition & 0 deletions packages/betterer/src/test/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ function loadTestMetaFromConfig(configPath: string): BettererTestFactoryMetaMap
});
return testMeta;
} catch (error) {
debugger;
throw new BettererError(`could not import config from "${configPath}". 😔`, error as BettererError);
}
}
7 changes: 1 addition & 6 deletions packages/betterer/src/test/loader.worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,9 @@ import type { BettererTestNames } from './types.js';

import { exposeToMain__ } from '@betterer/worker';

import { registerExtensions } from '../typescript/register.js';
import { loadTestMeta } from './loader.js';

export async function loadTestNames(
tsconfigPath: string | null,
configPaths: BettererConfigPaths
): Promise<BettererTestNames> {
await registerExtensions(tsconfigPath);
export function loadTestNames(configPaths: BettererConfigPaths): BettererTestNames {
const testMeta = loadTestMeta(configPaths);
return Object.keys(testMeta);
}
Expand Down
20 changes: 0 additions & 20 deletions packages/betterer/src/typescript/config.ts

This file was deleted.

3 changes: 0 additions & 3 deletions packages/betterer/src/typescript/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/betterer/src/typescript/public.ts

This file was deleted.

55 changes: 0 additions & 55 deletions packages/betterer/src/typescript/register.ts

This file was deleted.

26 changes: 0 additions & 26 deletions packages/betterer/src/typescript/types.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/cli/src/ci.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export function ci(cwd: string): Command {
reporters: config.reporter,
resultsPath: config.results,
silent: config.silent,
tsconfigPath: config.tsconfig,
workers: config.workers
};

Expand Down
7 changes: 1 addition & 6 deletions packages/cli/src/options.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { BettererCLIArguments, BettererCLIEnvConfig } from './types.js';
import type { BettererCLIArguments } from './types.js';

import { Command } from 'commander';

Expand All @@ -18,7 +18,6 @@ export function cliCommand(name: BettererCommand): Command {
resultsPathOption();
silentOption();
strictOption();
tsconfigPathOption();
updateOption();
workersOption();
return command;
Expand Down Expand Up @@ -82,10 +81,6 @@ function resultsPathOption(): void {
command.option('-r, --results [value]', 'Path to test results file relative to CWD');
}

function tsconfigPathOption(): void {
command.option('-t, --tsconfig [value]', 'Path to TypeScript config file relative to CWD');
}

function filtersOption(): void {
command.option(
'-f, --filter [value]',
Expand Down
Loading
Loading