Skip to content

Commit

Permalink
fix: fixed all chalk colors which were prefixed with {dim
Browse files Browse the repository at this point in the history
  • Loading branch information
yankeeinlondon committed Jan 28, 2023
1 parent f071bea commit 272a850
Show file tree
Hide file tree
Showing 19 changed files with 50 additions and 43 deletions.
2 changes: 1 addition & 1 deletion src/commands/autoindex/private/util/communicateApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ export function communicateApi(paths: string[]) {
chalk.italic("named,defaults")
);
console.log(
` {white {bold Note:}}\n {dim {italic you can also add the "--add" flag to look for other regex files patterns}}`
` ${chalk.white.bold`Note:`}\n ${chalk.dim.italic`you can also add the "--add" flag to look for other regex files patterns`}`
);
}
3 changes: 2 additions & 1 deletion src/commands/deploy/parts/deploy.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import chalk from "chalk";
import { DoDevopsHandler } from "src/@types/command";
import { IOptionDefinition } from "src/@types/option-types";
import { proxyToPackageManager } from "src/shared/core/proxyToPackageManager";
Expand All @@ -12,7 +13,7 @@ export const defaultConfig = {
export const description = "Deployment services for {bold Serverless}";

export const syntax =
"dd deploy [fn1] [fn2] <options>\n\n{dim Note: {italic stating particular functions is {italic optional} and if excluded will result in a full deployment of all functions.}}";
`dd deploy [fn1] [fn2] <options>\n\n${chalk.dim`Note: {italic stating particular functions is {italic optional} and if excluded will result in a full deployment of all functions.`}`;

export const options: IOptionDefinition = {
interactive: {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/fns/parts/fns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const handler: DoDevopsHandler<Options<IFnsOptions>> = async ({

if (fns) {
console.log(
`- AWS functions found using {blue {bold ${opts.profile}}} profile {dim [ ${region} ]}${stageFilterMsg}\n`
`- AWS functions found using {blue {bold ${opts.profile}}} profile ${chalk.dim`[ ${region} ]`}${stageFilterMsg}\n`
);
if (opts.json) {
console.log(
Expand Down
2 changes: 1 addition & 1 deletion src/commands/info/parts/otherPackages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export async function otherPackages(
latest: opts.verbose
? `${latest?.version} - {italic ${latest?.timing.replace("about ", "")}}${
prior
? `\n{dim ${prior?.version} - {italic ${prior?.timing.replace("about ", "")}}}`
? chalk.dim`\n ${prior?.version} - ${chalk.italic(prior?.timing.replace("about ", ""))}`
: ""
}`
: getLatest(repo.value),
Expand Down
6 changes: 3 additions & 3 deletions src/commands/info/parts/thisRepo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,15 @@ export async function thisRepo(opts: Options, observations: Set<DoDevopObservati

const depsSummary =
deps.length > 0
? `This repo has ${deps.map((d) => `{green ${d.count}} ${d.name}`).join(", ")}`
: `{italic {dim no dependencies}}`;
? `This repo has ${deps.map((d) => chalk.green` ${d.count}} ${d.name}`).join(", ")}`
: chalk.italic.dim` no dependencies}}`;

`This repo has ${green(
Object.keys(pkg?.dependencies || {}).length
)} dependencies, and {green ${
Object.keys(pkg?.devDependencies || {}).length
}} {italic dev} dependencies`;
const depDetails = `${depsSummary}\n\nThe dependencies are:\n - ${dim(
const depDetails = `${depsSummary}\n\nThe dependencies are:\n - ${chalk.dim(
Object.keys(pkg?.dependencies || {}).join("\n - ")
)}`;

Expand Down
3 changes: 2 additions & 1 deletion src/commands/madge/parts/options.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import chalk from "chalk";
import { IOptionDefinition } from "src/@types";

export interface IMadgeOptions {
Expand Down Expand Up @@ -61,7 +62,7 @@ export const options: IOptionDefinition = {
layout: {
type: String,
group: "local",
description: `layout engine for graph; choices are: {dim {italic dot, neato, fdp, sfdp, twopi, circo}}`,
description: `layout engine for graph; choices are: ${chalk.dim.italic` dot, neato, fdp, sfdp, twopi, circo`}`,
},

"include-npm": {
Expand Down
3 changes: 2 additions & 1 deletion src/commands/ssm/private/completeSsmName.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import chalk from "chalk";
import { DevopsError } from "src/errors";
import { askConfirmQuestion } from "src/shared/interactive";

Expand Down Expand Up @@ -44,7 +45,7 @@ export async function completeSsmName(name: string, hints: ISsmNameHints = {}) {
console.log(
`\nThe SSM variable {italic name} does not appear to be correctly formatted. The format\nshould be:\n`
);
console.log(`/{dim [stage]}/{dim [version]}/{dim [moduleName]}/{dim [VAR NAME]}\n`);
console.log(`/${chalk.dim` [stage]`}/${chalk.dim` [version]`}/${chalk.dim` [moduleName]`}/${chalk.dim` [VAR NAME]`}\n`);
console.log(
`In most cases the best strategy is just to state the module name and final\nvariable name and let the autocomplete do the rest.`
);
Expand Down
10 changes: 6 additions & 4 deletions src/commands/ssm/private/subCommands/set.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable unicorn/no-process-exit */
import { getAwsProfile, getAwsIdentityFromProfile } from "src/shared/aws";
import { SSM } from "aws-ssm";
import { completeSsmName } from "../index";
Expand All @@ -7,6 +8,7 @@ import { askForStage } from "src/shared/serverless";
import { emoji } from "src/shared/ui";
import { DoDevopsHandler } from "src/@types";
import { ISsmOptions } from "../../parts";
import chalk from "chalk";

export const execute: DoDevopsHandler<ISsmOptions> = async ({ opts, unknown: argv }) => {
if (argv.length < 2) {
Expand Down Expand Up @@ -39,7 +41,7 @@ export const execute: DoDevopsHandler<ISsmOptions> = async ({ opts, unknown: arg
process.env.AWS_STAGE ||
process.env.NODE_ENV ||
(await askForStage(
`SSM variables should be namespaced to a STAGE, what stage are you setting for {dim [ profile: {italic ${profile}}, region: {italic ${region}}, account: {italic ${identity.accountId}} ]}?`
`SSM variables should be namespaced to a STAGE, what stage are you setting for ${chalk.dim`[ profile: {italic ${profile}}, region: {italic ${region}}, account: {italic ${identity.accountId}} ]`}?`
));

const ssm = new SSM({ profile, region });
Expand All @@ -55,16 +57,16 @@ export const execute: DoDevopsHandler<ISsmOptions> = async ({ opts, unknown: arg
override: opts.force,
});
console.log(
`\n- ${emoji.party} the {bold {yellow ${name}}} variable was set successfully to the {italic ${region}} region {dim [ profile: {italic ${profile}}, region: {italic ${region}}, account: {italic ${identity.accountId}} ]}\n`
`\n- ${emoji.party} the {bold {yellow ${name}}} variable was set successfully to the {italic ${region}} region ${chalk.dim`[ profile: ${chalk.italic(profile)}, region: ${chalk.italic(region)}, account: ${chalk.italic(identity.accountId)} ]`}\n`
);
} catch (error) {
console.log();
if ((error as any)?.code === "ParameterAlreadyExists") {
console.log(
`- {red {bold Paramater Already Exists!}} to overwrite a parameter which already exists you must add {blue --force} to the CLI command`
`- {red {bold Parameter Already Exists!}} to overwrite a parameter which already exists you must add {blue --force} to the CLI command`
);
} else {
console.log(`{red {bold Error:}} ${(error as Error).message}`);
console.log(`${chalk.red.bold`Error:`} ${(error as Error).message}`);
}

console.log();
Expand Down
2 changes: 1 addition & 1 deletion src/dd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ import { isDevopsError } from "./@type-guards";
const noPkgJsonMsg =
useScriptProxy === undefined
? ""
: `\n\n{dim - Note: you're in a directory with no {italic package.json} file so if you\nwere trying to proxy a script please move to the right directory first.}`;
: chalk.dim`\n\n - Note: you're in a directory with no ${chalk.italic`package.json`} file so if you\nwere trying to proxy a script please move to the right directory first.`;
console.log(
`${emoji.poop} ${chalk.italic.yellowBright`${cmdName}`}} is an unknown command!${noPkgJsonMsg} \n\n` +
`- Valid command syntax is: ${chalk.bold.inverse(
Expand Down
2 changes: 1 addition & 1 deletion src/shared/core/util/commandAnnouncement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function commandAnnouncement(cmdDefn?: IDoDevopsCommand, cmd?: ICommandPa

const argv = cmd && cmd.argv.length > 0 ? ` {italic ${cmd.argv.join(" ")}}` : "";

const subCmd = cmd && cmd.subCommand ? ` {dim ${cmd.subCommand}}` : "";
const subCmd = cmd && cmd.subCommand ? chalk.dim` ${cmd.subCommand}` : "";

const helpText =
(!cmdDefn && !cmd) || (cmd && cmd.opts?.help)
Expand Down
9 changes: 5 additions & 4 deletions src/shared/core/util/finalizeCommandDefinition.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import chalk from "chalk";
import { IDictionary } from "common-types";
import {
DoDevopObservation,
Expand Down Expand Up @@ -33,24 +34,24 @@ export function finalizeCommandDefinition(
? cmdDefn.subCommands(observations, options)
: cmdDefn.subCommands;

const argv = hasArgv(cmdDefn) ? ` {italic {dim argv[]}}` : "";
const argv = hasArgv(cmdDefn) ? chalk.italic.dim` argv[]}}` : "";
const argvDescription = getArgvOption(cmdDefn)?.description
? `\n\n\t\t{bold {blue [argv]:}} ${getArgvOption(cmdDefn)?.description}`
: "";

const subCommandSyntax =
subCommands && subCommands.length > 0
? ` {bold <cmd:}{dim ${subCommands
? ` ${chalk.bold`<cmd:`}${chalk.dim(subCommands
.map((i) => i.name)
.join(`{blue {bold |}}`)}}{bold >}`
.join(`{blue {bold |}}`))}${chalk.bold`>`}`
: "";

return {
kind: cmdDefn.kind,
handler: cmdDefn.handler,
syntax:
cmdDefn.syntax ||
`dd ${cmdDefn.kind}${subCommandSyntax}${argv} [{italic options}]${argvDescription}`,
`dd ${cmdDefn.kind}${subCommandSyntax}${argv} [${chalk.italic`options`}]${argvDescription}`,
description,
subCommands,
options: { ...cmdDefn.options, ...globalOptions },
Expand Down
6 changes: 4 additions & 2 deletions src/shared/file/crud/readFile.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/* eslint-disable unicorn/no-process-exit */

import chalk from "chalk";
import { readFileSync } from "node:fs";
import { emoji } from "src/shared/ui";
import { filesExist } from "../existence/filesExist";
Expand All @@ -24,7 +26,7 @@ export function readFile(filename: string) {
filename = interpolateFilePath(filename);

try {
return filesExist(filename) ? readFileSync(filename, { encoding: "utf-8" }) : undefined;
return filesExist(filename) ? readFileSync(filename, { encoding: "utf8" }) : undefined;
} catch (error) {
console.log(
`{red - ${
Expand All @@ -33,7 +35,7 @@ export function readFile(filename: string) {
(error as Error).message
}`
);
console.log(`- Stack:{dim \n${(error as Error).stack}}`);
console.log(`- Stack:\n${chalk.dim((error as Error).stack)}`);

process.exit(1);
}
Expand Down
11 changes: 5 additions & 6 deletions src/shared/images/useImageApi/convertStale.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable unicorn/no-await-expression-member */
import chalk from "chalk";
import { IImageCacheRef, IImageRule } from "src/@types/image-types";
import { getProjectConfig } from "src/shared/config";
Expand All @@ -23,9 +24,7 @@ export async function convertStale(
// iterate over rules
for (const [i, rule] of rules.entries()) {
log.info(
`- checking rule {blue ${rule.name}} for stale source images [ {dim ${
i + 1
} {italic of} ${rules.length}} ]`
`- checking rule {blue ${rule.name}} for stale source images [ ${chalk.dim(i + 1)} ${chalk.italic`of`} ${rules.length}} ]`
);
const { missing, outOfDate } = await checkCacheFreshness(tools.cache, rule);
if (missing.length > 0) {
Expand All @@ -35,9 +34,9 @@ export async function convertStale(
}
if (outOfDate.length > 0) {
log.whisper(
`- there are ${outOfDate.length} images who are out of date: {dim ${missing.join(
`- there are ${outOfDate.length} images who are out of date: ${chalk.dim(missing.join(
", "
)}}`
))}`
);
}
if (missing.length === 0 && outOfDate.length === 0) {
Expand All @@ -58,7 +57,7 @@ export async function convertStale(
})
);
}
const resizedComplete = [...(await Promise.all(resized))].flat();
const resizedComplete = (await Promise.all(resized)).flat();
log.whisper(
chalk.dim`- the following images were {italic resized}:\n${wordWrap(
resizedComplete.map((i) => i.file).join("\t"),
Expand Down
20 changes: 10 additions & 10 deletions src/shared/images/useImageApi/refreshCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ export async function refreshCache(rule: IImageRule, tools: IImageTools, stale:
sharpMeta: m,
} as IImageCacheRef)
),
(rule.metaDetail !== "basic"
? rule.metaDetail === "categorical"
(rule.metaDetail === "basic"
? Promise.resolve()
: rule.metaDetail === "categorical"
? tools.exif.categorizedMetadata(file)
: tools.exif.getMetadata(file)
: Promise.resolve()) as Promise<IExifToolMetadata | undefined>,
: tools.exif.getMetadata(file)) as Promise<IExifToolMetadata | undefined>,
])
);

Expand Down Expand Up @@ -101,14 +101,14 @@ export async function refreshCache(rule: IImageRule, tools: IImageTools, stale:

const metaMessages: string[] = [];

if (!rule.preserveMeta) {
if (rule.preserveMeta) {
metaMessages.push(
"all meta data from the original image will be preserved in the converted image",
"note that colorspace profile was converted to sRGB in conversion process and this will not be reverted back"
"all meta data from the original image was removed and a web friendly sRGB color profile was added to the converted image"
);
} else {
metaMessages.push(
"all meta data from the original image was removed and a web friendly sRGB color profile was added to the converted image"
"all meta data from the original image will be preserved in the converted image",
"note that colorspace profile was converted to sRGB in conversion process and this will not be reverted back"
);
}

Expand Down Expand Up @@ -166,9 +166,9 @@ export async function refreshCache(rule: IImageRule, tools: IImageTools, stale:
log.info(
`- ${
emoji.party
} all images are now up-to-date based on recent source image changes [ {dim ${format(
} all images are now up-to-date based on recent source image changes [ ${chalk.dim(format(
Date.now(),
"h:mm:ss aaaa"
)}} ]`
))} ]`
);
}
4 changes: 2 additions & 2 deletions src/shared/interactive/specific/askForDependency.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import chalk from "chalk";
import { DoDevopObservation, INpmDep, INpmDependencies, INpmDepProperty } from "src/@types";
import { askListQuestion } from "src/shared/interactive";

import { dependencies } from "src/shared/npm";

export const LOOKUP = (p: INpmDependencies) =>
Expand Down Expand Up @@ -57,7 +57,7 @@ export async function askForDependency(

const answer = await askListQuestion(
`- Choose the {italic specific} dependency to run "ls" on`,
Object.fromEntries(depChoices.map((i) => [i.name, `${i.name} {dim - ${i.version}}`]))
Object.fromEntries(depChoices.map((i) => [i.name, `${i.name} ${chalk.dim`- ${i.version}`}`]))
);

return answer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export async function askForAutoindexConfig(opts: Options<IAutoindexOptions>, o:
);
if (!confirmIndexGlob) {
console.log(`- input patterns in a CSV format that can be parsed.`);
console.log(` for example {dim [ "**foobar.ts" ] }.`);
console.log(` for example ${chalk.dim`[ "**foobar.ts" ] `}.`);
console.log(
`- Note: you should NOT include the exclusion pattern for {blue node_modules} as this will always be included`
);
Expand Down
3 changes: 2 additions & 1 deletion src/shared/npm/package-json/pkgDepsInTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
import { IDictionary } from "common-types";
import { toTable } from "src/shared/ui";
import { getPackageJson, convertDepDictionaryToArray } from "src/shared/npm";
import chalk from "chalk";

function formatDependencies(deps: Array<{ name: string; version: string }>) {
return deps.map((dep) => `{bold ${dep.name}} [{dim ${dep.version} }]`);
return deps.map((dep) => `${chalk.bold(dep.name)} [ ${chalk.dim(dep.version)} ]`);
}

export interface IPkgDepsInTableOptions {
Expand Down
2 changes: 1 addition & 1 deletion src/shared/serverless/build/saveFunctionsTypeDefinition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ export async function saveFunctionsTypeDefinition(config: IServerlessYaml) {
console.log(
`- Attempt to save {italic type definitions} for ${chalk.bold`functions`} and ${chalk.bold`stepFunctions`} failed; this will be ignored for now so build can continue.`
);
console.log(`- The actual error received was: {dim ${(error as Error).message}}`);
console.log(`- The actual error received was: ${chalk.dim((error as Error).message)}`);
}
}
1 change: 0 additions & 1 deletion test/helpers/removeTempFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export function removeTempFiles() {
.map((i) => i.file)
.filter((i) => !["README.md", ".DS_Store"].includes(i));

// console.log(`- removing temp files: {dim ${files.join(", ")}}`);
for (const file of files) {
removeFile(join("./test/data/temp/", file));
}
Expand Down

0 comments on commit 272a850

Please sign in to comment.