Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop Chalk from deps #124

Merged
merged 6 commits into from
Jun 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "Drop Chalk dependency",
"packageName": "@ot-builder/cli-help-shower",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "Drop Chalk dependency",
"packageName": "ot-builder-cli",
"email": "[email protected]",
"dependentChangeType": "patch"
}
2 changes: 1 addition & 1 deletion packages/cli-help-shower/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
"dependencies": {
"tslib": "^2.6.3",
"chalk": "^4.1.1"
"picocolors": "^1.0.1"
},
"devDependencies": {
"@types/jest": "^29.5.12",
Expand Down
26 changes: 19 additions & 7 deletions packages/cli-help-shower/src/style.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as Chalk from "chalk";
import * as pc from "picocolors";

const terminalSupportsUnicode =
process.platform !== "win32" ||
Expand All @@ -9,12 +9,14 @@ export const CONSOLE_WIDTH = 80;
export const Bullet = terminalSupportsUnicode ? `· ` : `+ `;
export const Rule = (terminalSupportsUnicode ? `─` : `-`).repeat(CONSOLE_WIDTH);

export const Cmd = Chalk.cyan;
export const Option = Chalk.green;
export const Param = (s: TemplateStringsArray, ...placeholders: unknown[]) =>
`<` + Chalk.yellow(s, ...placeholders) + `>`;
export const Cmd = (s: TemplateStringsArray, ...placeholders: unknown[]) =>
pc.cyan(simpleTemplateCombine(s, placeholders));
export const Option = (s: TemplateStringsArray, ...placeholders: unknown[]) =>
pc.green(simpleTemplateCombine(s, placeholders));
export const Arg = (s: TemplateStringsArray, ...placeholders: unknown[]) =>
Chalk.yellow(s, ...placeholders);
pc.yellow(simpleTemplateCombine(s, placeholders));
export const Param = (s: TemplateStringsArray, ...placeholders: unknown[]) =>
`<` + pc.yellow(simpleTemplateCombine(s, placeholders)) + `>`;

export function OptRun(...xs: string[]) {
return ["[", ...xs, "]"];
Expand All @@ -30,5 +32,15 @@ export function AltRun(...xs: string[]) {
}

export function ArgvParseError(s: string) {
return Chalk.bold.red.underline(s);
return pc.bold(pc.red(pc.underline(s)));
}

function simpleTemplateCombine(s: TemplateStringsArray, placeholders: unknown[]) {
let res = s[0];

for (let i = 0; i < placeholders.length; i++) {
res += String(placeholders[i]) + (s[i + 1] || "");
}

return res;
}
2 changes: 1 addition & 1 deletion packages/cli/src/syntax/actions/merge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const MergeSyntax: Syntax<null | CliAction> = {
)
.message(
`When`,
Style.Option(`--override`),
Style.Option`--override`,
`is provided, characters from`,
Style.Arg`b.ttf`,
`will be preferred; otherwise, characters from`,
Expand Down
Loading