Skip to content

Commit

Permalink
fix(npm): apply breaking changes after updates
Browse files Browse the repository at this point in the history
  • Loading branch information
JamieMason committed Jul 24, 2024
1 parent bbf2cd9 commit c2a7744
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
8 changes: 4 additions & 4 deletions src/bin-update/effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export const updateEffects = {
if (gtr(latest, String(instance.rawSpecifier.raw), true)) {
outdatedCount++;
mostRecent.push(
chalk`${instance.name} {gray {red ${instance.rawSpecifier.raw}} ${ICON.rightArrow}} {green ${latest}}`,
chalk`${instance.name} {gray {red ${String(instance.rawSpecifier.raw)}} ${ICON.rightArrow}} {green ${latest}}`,
);
} else {
mostRecent.push(chalk`{green ${instance.name}}`);
Expand All @@ -116,7 +116,7 @@ export const updateEffects = {
onOutdated(instance: Instance, latest: string) {
outdatedCount++;
mostRecent.push(
chalk`${instance.name} {gray {red ${instance.rawSpecifier.raw}} ${ICON.rightArrow}} {green ${latest}}`,
chalk`${instance.name} {gray {red ${String(instance.rawSpecifier.raw)}} ${ICON.rightArrow}} {green ${latest}}`,
);
return Effect.void;
},
Expand All @@ -136,7 +136,7 @@ export const updateEffects = {
Schema.decodeUnknownEither(
Schema.Struct({
'dist-tags': Schema.Struct({ latest: Schema.String }),
'time': Schema.Record(Schema.String, Schema.String),
'time': Schema.Record({ key: Schema.String, value: Schema.String }),
'homepage': Schema.optional(Schema.String),
'repository': Schema.optional(
Schema.Union(Schema.String, Schema.Struct({ url: Schema.optional(Schema.String) })),
Expand Down Expand Up @@ -271,7 +271,7 @@ function promptForReleaseType(
: '';

return {
title: chalk`${updateable.instance.name} {gray ${updateable.instance.rawSpecifier.raw} ${ICON.rightArrow}} {green ${updateable.versions.latest}} ${repoUrl}`,
title: chalk`${updateable.instance.name} {gray ${String(updateable.instance.rawSpecifier.raw)} ${ICON.rightArrow}} {green ${updateable.versions.latest}} ${repoUrl}`,
selected: true,
value: updateable,
};
Expand Down
11 changes: 6 additions & 5 deletions src/lib/with-logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@ import { Effect, Logger, LogLevel } from 'effect';

export function withLogger(program: Effect.Effect<unknown>) {
const logger = Logger.make(({ logLevel, message }) => {
const args = Array.isArray(message) ? message : [message];
if (logLevel === LogLevel.Info) {
globalThis.console.info(message);
globalThis.console.info(...args);
} else if (logLevel === LogLevel.Debug) {
globalThis.console.info(chalk`{magenta ? %s}`, message);
globalThis.console.info(chalk`{magenta ? %s}`, ...args);
} else if (logLevel === LogLevel.Error) {
globalThis.console.error(chalk`{red ! %s}`, message);
globalThis.console.error(chalk`{red ! %s}`, ...args);
} else if (logLevel === LogLevel.Warning) {
globalThis.console.warn(chalk`{yellow ! %s}`, message);
globalThis.console.warn(chalk`{yellow ! %s}`, ...args);
} else {
globalThis.console.log(chalk`{cyan [%s] %s}`, logLevel, message);
globalThis.console.log(chalk`{cyan [%s] %s}`, logLevel, ...args);
}
});
const layer = Logger.replace(Logger.defaultLogger, logger);
Expand Down
10 changes: 4 additions & 6 deletions test/lib/create-scenario.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ import type { Report } from '../../src/report.js';

type NodeFs = typeof fs;

type MockFn<F extends (...args: any) => any> = Mock<Parameters<F>, ReturnType<F>>;

export interface TestScenario {
cli: Partial<CliConfig>;
errorHandlers: ErrorHandlers;
Expand All @@ -35,18 +33,18 @@ export interface TestScenario {
mockIo: {
cosmiconfig: Io['cosmiconfig'];
enquirer: {
prompt: MockFn<Io['enquirer']['prompt']>;
prompt: Mock<Io['enquirer']['prompt']>;
};
fs: NodeFs;
globby: {
sync: MockFn<Io['globby']['sync']>;
sync: Mock<Io['globby']['sync']>;
};
process: {
cwd: Io['process']['cwd'];
exit: MockFn<Io['process']['exit']>;
exit: Mock<Io['process']['exit']>;
};
readYamlFile: {
sync: MockFn<Io['readYamlFile']['sync']>;
sync: Mock<Io['readYamlFile']['sync']>;
};
};
readPackages(): Record<string, PackageJson>;
Expand Down

0 comments on commit c2a7744

Please sign in to comment.