Skip to content

Commit

Permalink
fix: heap of fixes
Browse files Browse the repository at this point in the history
- remove `tinyexec`
- add `terminate`
  • Loading branch information
boneskull committed Nov 10, 2024
1 parent 7fdfb22 commit d835297
Show file tree
Hide file tree
Showing 103 changed files with 2,541 additions and 722 deletions.
101 changes: 93 additions & 8 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions packages/midnight-smoker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
"test": "run-s test:unit test:smoke",
"test:ci": "run-s test:unit test:smoke test:e2e",
"test:e2e": "mocha --timeout 20s --slow 10s \"test/e2e/**/*.spec.ts\" --fgrep \"[snapshot]\" --invert",
"test:smoke": "node ./bin/smoker.js run smoke:ts smoke:js --reporter progress --add tsx --add @tsconfig/node18",
"test:smoke": "node ./bin/smoker.js run smoke:ts smoke:js --add tsx --add @tsconfig/node18",
"test:snapshots-only": "npm run test:e2e -- --fgrep \"[snapshot]\"",
"test:unit": "mocha \"test/unit/**/*.spec.ts\"",
"test:update-snapshots": "cross-env SNAPSHOT_UPDATE=1 mocha --timeout 20s --slow 10s \"test/e2e/**/*.spec.ts\" -- --fgrep \"[snapshot]\"",
Expand All @@ -182,7 +182,7 @@
"semver": "7.5.4",
"string-width": "4.2.3",
"terminal-link": "2.1.1",
"tinyexec": "0.3.1",
"terminate": "2.8.0",
"type-fest": "4.19.0",
"which": "4.0.0",
"wrap-ansi": "7.0.0",
Expand Down
14 changes: 5 additions & 9 deletions packages/midnight-smoker/src/cli/command/list-cmd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import {createTable} from '#cli/cli-util';
import {Smoker} from '#smoker';
import {createDebug} from '#util/debug';
import {formatUrl} from '#util/format';
import {isBlessedPlugin} from '#util/guard/blessed-plugin';
import {isString} from '#util/guard/common';
import {orderBy} from 'lodash';
Expand Down Expand Up @@ -159,21 +160,16 @@ export class ListCommand extends BaseCommand {

debug('Found %d rules', rules.length);

const headers =
terminalLink.isSupported && !smoker.smokerOptions.json
? ['Name', 'Description', 'Plugin']
: ['Name', 'Description', 'Plugin', 'URL'];

if (smoker.smokerOptions.json) {
BaseCommand.writeJson(rules);
return;
}

const headers = terminalLink.isSupported
? ['Name', 'Description', 'Plugin']
: ['Name', 'Description', 'Plugin', 'URL'];
const data = rules.map((rule) => {
const ruleName =
terminalLink.isSupported && rule.url
? terminalLink(rule.id, rule.url)
: rule.id;
const ruleName = formatUrl(rule.id, rule.url, {fallback: false});
const pluginName = rule.isBlessed ? '(built-in)' : rule.pluginName;
const row: (string | undefined)[] = [
ruleName,
Expand Down
4 changes: 3 additions & 1 deletion packages/midnight-smoker/src/cli/command/view-cmd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ export class ViewCommand extends BaseCommand {
return;
}

BaseCommand.write(inspect(smoker.smokerOptions, {colors: true, depth: 5}));
BaseCommand.write(
inspect(smoker.smokerOptions, {colors: true, depth: 5, sorted: true}),
);
}

public static async viewDefaultPkgManager(
Expand Down
4 changes: 2 additions & 2 deletions packages/midnight-smoker/src/cli/smoker-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {ConfigReader} from '#config/config-reader';
import {SCRIPT_NAME} from '#constants';
import {createDebug} from '#util/debug';
import {FileManager} from '#util/filemanager';
import terminalLink from 'terminal-link';
import {formatUrl} from '#util/format';
import {hideBin} from 'yargs/helpers';
import yargs from 'yargs/yargs';

Expand Down Expand Up @@ -51,7 +51,7 @@ async function main(args: string[]): Promise<void> {
})
// this is the USA dammit
.epilog(
`RTFM at: ${terminalLink(`${homepage}`, `${homepage}`, {
`RTFM at: ${formatUrl(`${homepage}`, `${homepage}`, {
fallback: false,
})}\n`,
)
Expand Down
10 changes: 10 additions & 0 deletions packages/midnight-smoker/src/constants/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,13 @@ export const SYSTEM = 'system';
export const TS_CONFIG_EXTENSIONS = Object.freeze(['.ts', '.mts', '.cts']);

export const ALLOWED_DEFAULT_PKG_MANAGERS = constant(['yarn', 'npm', 'pnpm']);

/**
* The URL to submit bug reports.
*
* @remarks
* This should be read from `midnight-smoker/package.json`. At some point we can
* just read it synchronously.
*/
export const BUGS_URL =
'https://github.com/boneskull/midnight-smoker/issues/new';
2 changes: 1 addition & 1 deletion packages/midnight-smoker/src/defs/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @packageDocumentation
*/

import {type ExecOptions, type ExecOutput} from '#schema/exec-result';
import {type ExecOptions, type ExecOutput} from '#schema/exec-output';
import {type StaticPkgManagerSpec} from '#schema/static-pkg-manager-spec';
import {type SpawnOptions as NodeOptions} from 'node:child_process';

Expand Down
21 changes: 14 additions & 7 deletions packages/midnight-smoker/src/defs/reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,28 @@
import {type Events} from '#constants/event';
import {type StaticPluginMetadata} from '#defs/plugin';
import {type EventData, type EventType} from '#event/events';
import {type ReporterContext} from '#reporter/reporter-context';
import {
type Observer,
type ReporterContext,
type Subscribable,
type Subscription,
} from '#reporter/reporter-context';
import {type PackageJson} from '#schema/package-json';
import {type SmokerOptions} from '#schema/smoker-options';

export type {Observer, ReporterContext, Subscribable, Subscription};

/**
* Mapping of event types to listener method names
*/
export type EventToListenerNameMap = {
[K in keyof InvertedEvents]: `on${InvertedEvents[K]}`;
export type EventTypeToListenerName = {
[K in keyof EventTypeToEventName]: `on${EventTypeToEventName[K]}`;
};

/**
* Mapping of event types to event names
*/
export type InvertedEvents = {
export type EventTypeToEventName = {
[K in keyof typeof Events as (typeof Events)[K]]: K;
};

Expand All @@ -45,7 +52,7 @@ export interface BaseReporterContext {
* @template Ctx Extra context
*/
export type ReporterListener<
T extends EventType,
T extends EventType = EventType,
Ctx extends object = object,
> = (
this: void,
Expand All @@ -60,7 +67,7 @@ export type ReporterListener<
* This is only used to define {@link Reporter}.
*/
export type ReporterListeners<Ctx extends object = object> = {
-readonly [K in keyof EventToListenerNameMap as EventToListenerNameMap[K]]: ReporterListener<
-readonly [K in keyof EventTypeToListenerName as EventTypeToListenerName[K]]?: ReporterListener<
K,
Ctx
>;
Expand Down Expand Up @@ -99,7 +106,7 @@ export type SomeReporter = Reporter<any>;
* A `Reporter` definition, as provided by a plugin author.
*/
export interface Reporter<Ctx extends object = object>
extends Partial<ReporterListeners<Ctx>> {
extends ReporterListeners<Ctx> {
/**
* A plugin author can add whatever props they want
*/
Expand Down
Loading

0 comments on commit d835297

Please sign in to comment.