Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
boneskull committed Apr 22, 2024
1 parent 7daef13 commit 5b500b0
Show file tree
Hide file tree
Showing 38 changed files with 1,605 additions and 962 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ module.exports = {
'@typescript-eslint/require-await': 'off',

// unfortunately required when using Sets and Maps
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-non-null-assertion': 'warn',

// this rule seems broken
'@typescript-eslint/no-invalid-void-type': 'off',
Expand Down
20 changes: 10 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 28 additions & 28 deletions packages/midnight-smoker/.config/tsconfig.paths.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,34 @@
"compilerOptions": {
"paths": {
"@midnight-smoker/plugin-default": ["../../plugin-default"],
"@midnight-smoker/test-util": ["../../test-util"]
// "#cli": ["../src/cli/index.js"],
// "#cli/*": ["../src/cli/*.js"],
// "#config-file": ["../src/config-file.js"],
// "#component": ["../src/component/component/index.js"],
// "#constants": ["../src/constants.js"],
// "#controller": ["../src/controller/index.js"],
// "#controller/*": ["../src/controller/*.js"],
// "#error": ["../src/error/index.js"],
// "#error/*": ["../src/error/*.js"],
// "#event": ["../src/event/index.js"],
// "#event/*": ["../src/event/*.js"],
// "#executor": ["../src/component/executor/index.js"],
// "#options": ["../src/options/index.js"],
// "#options/*": ["../src/options/*.js"],
// "#pkg-manager": ["../src/component/pkg-manager/index.js"],
// "#pkg-manager/*": ["../src/component/pkg-manager/*.js"],
// "#plugin": ["../src/plugin/index.js"],
// "#plugin/*": ["../src/plugin/*.js"],
// "#reporter": ["../src/component/reporter/index.js"],
// "#reporter/*": ["../src/component/reporter/*.js"],
// "#rule": ["../src/component/rule/index.js"],
// "#rule/*": ["../src/component/rule/*.js"],
// "#schema": ["../src/component/schema/index.js"],
// "#schema/*": ["../src/component/schema/*.js"],
// "#smoker": ["../src/smoker.js"],
// "#util": ["../src/util/index.js"],
// "#util/*": ["../src/util/*.js"]
"@midnight-smoker/test-util": ["../../test-util"],
"#cli": ["../src/cli/index.js"],
"#cli/*": ["../src/cli/*.js"],
"#component": ["../src/component/component/index.js"],
"#config-file": ["../src/config-file.js"],
"#constants": ["../src/constants.js"],
"#error": ["../src/error/index.js"],
"#error/*": ["../src/error/*.js"],
"#event": ["../src/event/index.js"],
"#event/*": ["../src/event/*.js"],
"#executor": ["../src/component/executor/index.js"],
"#machine": ["../src/machine/index.js"],
"#machine/*": ["../src/machine/*/index.js"],
"#options": ["../src/options/index.js"],
"#options/*": ["../src/options/*.js"],
"#pkg-manager": ["../src/component/pkg-manager/index.js"],
"#pkg-manager/*": ["../src/component/pkg-manager/*.js"],
"#plugin": ["../src/plugin/index.js"],
"#plugin/*": ["../src/plugin/*.js"],
"#reporter": ["../src/component/reporter/index.js"],
"#reporter/*": ["../src/component/reporter/*.js"],
"#rule": ["../src/component/rule/index.js"],
"#rule/*": ["../src/component/rule/*.js"],
"#schema": ["../src/component/schema/index.js"],
"#schema/*": ["../src/component/schema/*.js"],
"#smoker": ["../src/smoker.js"],
"#util": ["../src/util/index.js"],
"#util/*": ["../src/util/*.js"]
}
}
}
4 changes: 2 additions & 2 deletions packages/midnight-smoker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"#config-file": "./dist/config-file.js",
"#constants": "./dist/constants.js",
"#machine": "./dist/machine/index.js",
"#machine/*": "./dist/machine/*.js",
"#machine/*": "./dist/machine/*/index.js",
"#error": "./dist/error/index.js",
"#error/*": "./dist/error/*.js",
"#event": "./dist/event/index.js",
Expand Down Expand Up @@ -196,7 +196,7 @@
"terminal-link": "2.1.1",
"type-fest": "4.8.3",
"which": "4.0.0",
"xstate": "5.9.1",
"xstate": "5.11.0",
"yargs": "17.7.2",
"zod": "3.22.4",
"zod-validation-error": "2.1.0"
Expand Down
5 changes: 3 additions & 2 deletions packages/midnight-smoker/src/component/reporter/reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@ export class Reporter<Ctx = unknown> extends ReifiedComponent<
// await Promise.resolve();
// XXX don't like these casts
if (this.hasListener(data.type)) {
const listenerName = `on${data.type}` as keyof ReporterListeners<Ctx>;
const listener = this.def[listenerName] as ReporterListener<T, Ctx>;
try {
const listenerName = `on${data.type}` as keyof ReporterListeners<Ctx>;
const listener = this.def[listenerName] as ReporterListener<T, Ctx>;
debug('%s - invoking %s', this, listenerName);
await listener(this.ctx, data);
debug('%s - invoked %s', this, listenerName);
} catch (err) {
Expand Down
4 changes: 4 additions & 0 deletions packages/midnight-smoker/src/component/rule/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ export class RuleContext implements StaticRuleContext {
return [...this.#issues];
}

public get localPath(): string {
return this.staticCtx.localPath;
}

/**
* The absolute path to this context's package's `package.json`.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const LintManifestSchema = z.object({
installPath: NonEmptyStringSchema.describe(
'Install path of package being checked',
),
localPath: NonEmptyStringSchema,
});

export const LintManifestsSchema = z
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {InstallManifestSchema} from './install-manifest';
export const PkgInstallManifest = InstallManifestSchema.extend({
isAdditional: z.literal(false).optional(),
installPath: NonEmptyStringSchema,
localPath: NonEmptyStringSchema,
});

export type PkgInstallManifest = z.infer<typeof PkgInstallManifest>;
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {z} from 'zod';
export const StaticRuleContextSchema = z
.object({
pkgName: NonEmptyStringSchema,
localPath: NonEmptyStringSchema,
pkgJson: PackageJsonSchema,
pkgJsonPath: NonEmptyStringSchema,
installPath: NonEmptyStringSchema,
Expand Down
2 changes: 1 addition & 1 deletion packages/midnight-smoker/src/error/reporter-error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class ReporterError<Ctx = unknown> extends BaseSmokerError<

constructor(error: Error, reporter: ReporterDef<Ctx>) {
super(
`Reporter ${reporter.name} threw while initializing: ${error.message}`,
`Reporter ${reporter.name} threw: ${error.message}`,
{reporter},
error,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ import {
type SmokerEventData,
} from '#schema';
import {type Simplify, type ValueOf} from 'type-fest';
import {type SomeReporter, type SomeRule} from '../../component';
import {type InstallerMachineOutput} from '../installer/installer-machine';
import {type LinterMachineOutput} from '../linter/linter-machine';
import {type PackerMachineOutput} from '../packer/packer-machine';
import {type ReifierOutput} from '../reifier/reifier-machine';
import {type PluginLoaderMachineOutput} from '../plugin-loader/plugin-loader-machine';
import {type ReporterMachineOutput} from '../reporter/reporter-machine';
import {type RunnerMachineOutput} from '../runner/runner-machine';

Expand All @@ -41,7 +42,6 @@ export type CtrlEvents =
| CtrlPkgManagerPackOkEvent
| CtrlPkgManagerInstallBeginEvent
| CtrlPkgManagerPackBeginEvent
| CtrlReifierDoneEvent
| CtrlRunScriptsEvent
| CtrlRunScriptBeginEvent
| CtrlReporterDoneEvent
Expand All @@ -65,6 +65,12 @@ export type CtrlEvents =
| CtrlPkgManagerLintBeginEvent
| CtrlPkgManagerLintOkEvent
| CtrlPkgManagerLintFailedEvent
| CtrlComponentsEvent
| CtrlPluginLoaderDoneEvent
| CtrlPackFailedEvent
| CtrlPackOkEvent
| CtrlInstallOkEvent
| CtrlInstallFailedEvent
| CtrlRunnerMachineDoneEvent;

type SourceEvents = InstallEventData &
Expand Down Expand Up @@ -217,9 +223,29 @@ export interface CtrlPkgManagerPackBeginEvent extends PackOptions {
type: 'PKG_MANAGER_PACK_BEGIN';
}

export interface CtrlReifierDoneEvent {
output: ReifierOutput;
type: 'xstate.done.actor.Reifier.*';
export interface CtrlPluginLoaderDoneEvent {
output: PluginLoaderMachineOutput;
type: 'xstate.done.actor.PluginLoaderMachine';
}

export interface CtrlPackFailedEvent {
type: 'PACK_FAILED';
error: PackError | PackParseError;
}

export interface CtrlPackOkEvent {
type: 'PACK_OK';
manifests: InstallManifest[];
}

export interface CtrlInstallOkEvent {
type: 'INSTALL_OK';
manifests: InstallManifest[];
}

export interface CtrlInstallFailedEvent {
type: 'INSTALL_FAILED';
error: InstallError;
}

export interface CtrlInstallerMachineDoneEvent {
Expand Down Expand Up @@ -319,3 +345,11 @@ export interface CtrlLintBeginEvent {
export interface CtrlRuleErrorEvent {
type: 'RULE_ERROR';
}

export interface CtrlComponentsEvent {
type: 'COMPONENTS';
sender: string;
pkgManagers: PkgManager[];
reporters: SomeReporter[];
rules: SomeRule[];
}

0 comments on commit 5b500b0

Please sign in to comment.