Skip to content

Commit

Permalink
fix(cli): make status codes easier to read
Browse files Browse the repository at this point in the history
Closes #172
  • Loading branch information
JamieMason committed Dec 24, 2023
1 parent 637f2ea commit e17b696
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/bin-lint-semver-ranges/lint-semver-ranges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ function logSemverRangeMismatch(report: Report.SemverRangeMismatch) {
const filePath = instance.packageJsonFile.jsonFile.shortPath;

return Effect.logInfo(
chalk`{red ${ICON.cross}} ${name} {red ${actual}} {dim ${ICON.rightArrow}} {green ${expected}} {gray ${filePath} > ${propPath}} {gray.dim [${_tag}]}`,
chalk`{red ${ICON.cross}} ${name} {red ${actual}} {dim ${ICON.rightArrow}} {green ${expected}} {gray ${filePath} > ${propPath}} {blue [${_tag}]}`,
);
}

Expand All @@ -122,6 +122,6 @@ function logUnsupportedMismatch(report: Report.UnsupportedMismatch) {
const filePath = instance.packageJsonFile.jsonFile.shortPath;

return Effect.logInfo(
chalk`{red ${ICON.cross} name {white ${name}} or version {white ${actual}} are not supported} {gray ${filePath} > ${propPath}} {gray.dim [${_tag}]}`,
chalk`{red ${ICON.cross} name {white ${name}} or version {white ${actual}} are not supported} {gray ${filePath} > ${propPath}} {blue [${_tag}]}`,
);
}
22 changes: 11 additions & 11 deletions src/bin-list-mismatches/list-mismatches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ function logBanned(report: Report.Banned) {
const shortPath = jsonFile.shortPath;

return Effect.logInfo(
chalk`{red ${ICON.cross}} ${name} {red banned} {gray ${shortPath} > ${path}} {gray.dim [${_tag}]}`,
chalk`{red ${ICON.cross}} ${name} {red banned} {gray ${shortPath} > ${path}} {blue [${_tag}]}`,
);
}

Expand All @@ -167,7 +167,7 @@ function logHighestSemverMismatch(report: Report.HighestSemverMismatch) {
const shortPath = jsonFile.shortPath;

return Effect.logInfo(
chalk`{red ${ICON.cross}} ${name} {red ${actual}} {dim ${ICON.rightArrow}} {green ${expected}} {gray ${shortPath} > ${path}} {gray.dim [${_tag}]}`,
chalk`{red ${ICON.cross}} ${name} {red ${actual}} {dim ${ICON.rightArrow}} {green ${expected}} {gray ${shortPath} > ${path}} {blue [${_tag}]}`,
);
}

Expand All @@ -182,7 +182,7 @@ function logLocalPackageMismatch(report: Report.LocalPackageMismatch) {
const shortPath = instance.packageJsonFile.jsonFile.shortPath;

return Effect.logInfo(
chalk`{red ${ICON.cross}} ${name} {red ${actual}} {dim ${ICON.rightArrow}} {green ${expected}} {gray ${shortPath} > ${path}} {gray.dim [${_tag}]}`,
chalk`{red ${ICON.cross}} ${name} {red ${actual}} {dim ${ICON.rightArrow}} {green ${expected}} {gray ${shortPath} > ${path}} {blue [${_tag}]}`,
);
}

Expand All @@ -197,7 +197,7 @@ function logLowestSemverMismatch(report: Report.LowestSemverMismatch) {
const shortPath = instance.packageJsonFile.jsonFile.shortPath;

return Effect.logInfo(
chalk`{red ${ICON.cross}} ${name} {red ${actual}} {dim ${ICON.rightArrow}} {green ${expected}} {gray ${shortPath} > ${path}} {gray.dim [${_tag}]}`,
chalk`{red ${ICON.cross}} ${name} {red ${actual}} {dim ${ICON.rightArrow}} {green ${expected}} {gray ${shortPath} > ${path}} {blue [${_tag}]}`,
);
}

Expand All @@ -212,7 +212,7 @@ function logPinnedMismatch(report: Report.PinnedMismatch) {
const shortPath = instance.packageJsonFile.jsonFile.shortPath;

return Effect.logInfo(
chalk`{red ${ICON.cross}} ${name} {red ${actual}} {dim ${ICON.rightArrow}} {green ${expected}} {gray ${shortPath} > ${path}} {gray.dim [${_tag}]}`,
chalk`{red ${ICON.cross}} ${name} {red ${actual}} {dim ${ICON.rightArrow}} {green ${expected}} {gray ${shortPath} > ${path}} {blue [${_tag}]}`,
);
}

Expand All @@ -227,7 +227,7 @@ function logSemverRangeMismatch(report: Report.SemverRangeMismatch) {
const shortPath = instance.packageJsonFile.jsonFile.shortPath;

return Effect.logInfo(
chalk`{red ${ICON.cross}} ${name} {red ${actual}} {dim ${ICON.rightArrow}} {green ${expected}} {gray ${shortPath} > ${path}} {gray.dim [${_tag}]}`,
chalk`{red ${ICON.cross}} ${name} {red ${actual}} {dim ${ICON.rightArrow}} {green ${expected}} {gray ${shortPath} > ${path}} {blue [${_tag}]}`,
);
}

Expand All @@ -242,7 +242,7 @@ function logSnappedToMismatch(report: Report.SnappedToMismatch) {
const shortPath = instance.packageJsonFile.jsonFile.shortPath;

return Effect.logInfo(
chalk`{red ${ICON.cross}} ${name} {red ${actual}} {dim ${ICON.rightArrow}} {green ${expected}} {gray ${shortPath} > ${path}} {gray.dim [${_tag}]}`,
chalk`{red ${ICON.cross}} ${name} {red ${actual}} {dim ${ICON.rightArrow}} {green ${expected}} {gray ${shortPath} > ${path}} {blue [${_tag}]}`,
);
}

Expand All @@ -257,7 +257,7 @@ export function logMissingLocalVersion(report: Report.MissingLocalVersion) {

return Effect.logInfo(
[
chalk`{red ${ICON.cross}} ${name} {red ${actual}} {dim ${ICON.rightArrow}} {red ???} {gray ${shortPath} > ${path}} {gray.dim [missing local version]}`,
chalk`{red ${ICON.cross}} ${name} {red ${actual}} {dim ${ICON.rightArrow}} {red ???} {gray ${shortPath} > ${path}} {blue [MissingLocalVersion]}`,
chalk` {red ${localPath} does not have a .version property which is exact semver}`,
].join(EOL),
);
Expand All @@ -273,7 +273,7 @@ export function logMissingSnappedToMismatch(report: Report.MissingSnappedToMisma

return Effect.logInfo(
[
chalk`{red ${ICON.cross}} ${name} {red ${actual}} {dim ${ICON.rightArrow}} {red ???} {gray ${shortPath} > ${path}} {gray.dim [missing snapTo version]}`,
chalk`{red ${ICON.cross}} ${name} {red ${actual}} {dim ${ICON.rightArrow}} {red ???} {gray ${shortPath} > ${path}} {blue [MissingSnappedToMismatch]}`,
chalk` {red no package in this groups .snapTo array depend on ${name}}`,
].join(EOL),
);
Expand All @@ -289,7 +289,7 @@ export function logUnsupportedMismatch(report: Report.UnsupportedMismatch) {

return Effect.logInfo(
[
chalk`{red ${ICON.cross}} ${name} {red ${actual}} {dim ${ICON.rightArrow}} {red ???} {gray ${shortPath} > ${path}} {gray.dim [unsupported mismatch]}`,
chalk`{red ${ICON.cross}} ${name} {red ${actual}} {dim ${ICON.rightArrow}} {red ???} {gray ${shortPath} > ${path}} {blue [UnsupportedMismatch]}`,
chalk` {red use {blue syncpack prompt} to fix this manually}`,
].join(EOL),
);
Expand All @@ -308,7 +308,7 @@ export function logSameRangeMismatch(report: Report.SameRangeMismatch) {
[
chalk`{red ${ICON.cross}} ${name} {red range ${actual} does not include ${mismatches.join(
', ',
)}} {gray ${shortPath} > ${path}} {gray.dim [same range mismatch]}`,
)}} {gray ${shortPath} > ${path}} {blue [SameRangeMismatch]}`,
chalk` {gray use {blue syncpack prompt} to fix this manually}`,
].join(EOL),
);
Expand Down
6 changes: 3 additions & 3 deletions src/bin-list/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export function list({ io, cli, errorHandlers = defaultErrorHandlers }: Input) {
const actual = report.specifier.raw;
matches.add(
report.specifier._tag === 'UnsupportedSpecifier'
? chalk`{gray ${actual}} {gray.dim [UnsupportedSpecifier]}`
? chalk`{gray ${actual}} {blue [UnsupportedMismatch]}`
: chalk`{gray ${actual}}`,
);
} else if (
Expand Down Expand Up @@ -134,13 +134,13 @@ function getLogForFixable(report: Report.Version.Fixable.Any) {
const _tag = report._tag;
const actual = report.fixable.instance.rawSpecifier;
const expected = report.fixable.raw;
return chalk`{red ${actual}} {gray ${ICON.rightArrow}} {green ${expected}} {gray.dim [${_tag}]}`;
return chalk`{red ${actual}} {gray ${ICON.rightArrow}} {green ${expected}} {blue [${_tag}]}`;
}

function getLogForUnfixable(report: Report.Version.Unfixable.Any) {
const _tag = report._tag;
const actual = report.unfixable.rawSpecifier;
return chalk`{red ${actual}} {gray ${ICON.rightArrow}} {gray.dim [${_tag}]}`;
return chalk`{red ${actual}} {gray ${ICON.rightArrow}} {blue [${_tag}]}`;
}

export function logOtherCommands() {
Expand Down

0 comments on commit e17b696

Please sign in to comment.