Skip to content

Commit

Permalink
Upgrades Chalk (#659)
Browse files Browse the repository at this point in the history
* Upgrades Chalk

* Adds better support for ansi256
  • Loading branch information
arcanis authored Dec 31, 2019
1 parent 7c47533 commit 0111f86
Show file tree
Hide file tree
Showing 30 changed files with 176 additions and 82 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/integration-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
steps:
- uses: actions/checkout@master
- run: |
git fetch --depth=1 origin master
git fetch --no-tags --unshallow origin HEAD master
- name: 'Use Node.js 10.x'
uses: actions/setup-node@master
Expand All @@ -29,7 +29,7 @@ jobs:

- name: 'Check that the cache files are consistent with their remote sources'
run: |
if [[ $(git diff --name-only "$(git merge-base origin/"$TARGET_BRANCH" HEAD)" HEAD -- .yarn/{cache,virtual} | wc -l) -gt 0 ]]; then
if [[ $(git diff --name-only "$(git merge-base origin/"$TARGET_BRANCH" HEAD)" HEAD -- .yarn/cache | wc -l) -gt 0 ]]; then
node ./scripts/run-yarn.js --immutable --immutable-cache --check-cache
fi
shell: bash
Expand Down
99 changes: 65 additions & 34 deletions .pnp.js

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added .yarn/cache/chalk-npm-3.0.0-e813208025-1.zip
Binary file not shown.
Binary file not shown.
Binary file added .yarn/cache/color-name-npm-1.1.4-025792b0ea-1.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion packages/plugin-constraints/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@yarnpkg/plugin-constraints",
"version": "2.0.0-rc.8",
"nextVersion": {
"nonce": "4504081233976721"
"nonce": "6891129022827449"
},
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-dlx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@yarnpkg/plugin-dlx",
"version": "2.0.0-rc.9",
"nextVersion": {
"nonce": "5496545511674191"
"nonce": "4211435857203791"
},
"main": "./sources/index.ts",
"dependencies": {
Expand Down
3 changes: 2 additions & 1 deletion packages/plugin-essentials/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"name": "@yarnpkg/plugin-essentials",
"version": "2.0.0-rc.16",
"nextVersion": {
"nonce": "5481798449360365"
"semver": "2.0.0-rc.17",
"nonce": "3107421490620431"
},
"main": "./sources/index.ts",
"dependencies": {
Expand Down
12 changes: 9 additions & 3 deletions packages/plugin-essentials/sources/commands/remove.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,16 @@ export default class RemoveCommand extends BaseCommand {
}
}

if (unreferencedPackages.length > 1)
throw new UsageError(`Packages ${unreferencedPackages.join(`, `)} aren't referenced by any workspace`);
const arent = unreferencedPackages.length > 1
? `aren't`
: `isn't`;

const which = this.all
? `any`
: `this`;

if (unreferencedPackages.length > 0)
throw new UsageError(`Package ${unreferencedPackages[0]} isn't referenced by any workspace`);
throw new UsageError(`Package ${unreferencedPackages.join(`, `)} ${arent} referenced by ${which} workspace`);

if (hasChanged) {
await configuration.triggerMultipleHooks(
Expand Down
3 changes: 3 additions & 0 deletions packages/plugin-exec/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"name": "@yarnpkg/plugin-exec",
"version": "2.0.0-rc.12",
"nextVersion": {
"nonce": "6863143062236867"
},
"main": "./sources/index.ts",
"dependencies": {
"@yarnpkg/builder": "workspace:^2.0.0-rc.13",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-init/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@yarnpkg/plugin-init",
"version": "2.0.0-rc.9",
"nextVersion": {
"nonce": "8344405561343829"
"nonce": "6467013922696359"
},
"main": "./sources/index.ts",
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-interactive-tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@yarnpkg/plugin-interactive-tools",
"version": "2.0.0-rc.10",
"nextVersion": {
"nonce": "7452966136840619"
"nonce": "4424897610664733"
},
"main": "./sources/index.ts",
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-npm-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@yarnpkg/plugin-npm-cli",
"version": "2.0.0-rc.9",
"nextVersion": {
"nonce": "4349026436917297"
"nonce": "3779313344822199"
},
"main": "./sources/index.ts",
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-pack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@yarnpkg/plugin-pack",
"version": "2.0.0-rc.12",
"nextVersion": {
"nonce": "1837285398600697"
"nonce": "2187988580810535"
},
"main": "./sources/index.ts",
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-patch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@yarnpkg/plugin-patch",
"version": "2.0.0-rc.1",
"nextVersion": {
"nonce": "1695990524453109"
"nonce": "3120509621193809"
},
"main": "./sources/index.ts",
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-pnp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@yarnpkg/plugin-pnp",
"version": "2.0.0-rc.12",
"nextVersion": {
"nonce": "3172183830835679"
"nonce": "2880810891864029"
},
"main": "./sources/index.ts",
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-stage/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@yarnpkg/plugin-stage",
"version": "2.0.0-rc.12",
"nextVersion": {
"nonce": "1446116570980833"
"nonce": "7878425841680983"
},
"main": "./sources/index.ts",
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@yarnpkg/plugin-typescript",
"version": "2.0.0-rc.10",
"nextVersion": {
"nonce": "938098439424615"
"nonce": "6234909799596577"
},
"main": "./sources/index.ts",
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-version/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "2.0.0-rc.15",
"nextVersion": {
"semver": "2.0.0-rc.16",
"nonce": "2067310077837823"
"nonce": "6797547766767345"
},
"main": "./sources/index.ts",
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-workspace-tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@yarnpkg/plugin-workspace-tools",
"version": "2.0.0-rc.11",
"nextVersion": {
"nonce": "1746282461491163"
"nonce": "6471245243267237"
},
"main": "./sources/index.ts",
"dependencies": {
Expand Down
6 changes: 5 additions & 1 deletion packages/yarnpkg-builder/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"name": "@yarnpkg/builder",
"version": "2.0.0-rc.14",
"nextVersion": {
"semver": "2.0.0-rc.15",
"nonce": "6618178249483219"
},
"bin": "./sources/boot-dev.js",
"dependencies": {
"@babel/core": "^7.7.4",
Expand All @@ -11,7 +15,7 @@
"@yarnpkg/pnpify": "workspace:^2.0.0-rc.12",
"babel-loader": "^8.0.6",
"babel-plugin-lazy-import": "arcanis/babel-plugin-lazy-import",
"chalk": "^2.4.1",
"chalk": "^3.0.0",
"clipanion": "^2.1.5",
"filesize": "^4.1.2",
"pnp-webpack-plugin": "^1.4.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/yarnpkg-check/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@yarnpkg/check",
"version": "2.0.0-rc.8",
"nextVersion": {
"nonce": "3798325493381339"
"nonce": "2884532412443509"
},
"bin": "./sources/boot-cli-dev.js",
"dependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/yarnpkg-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "2.0.0-rc.20",
"nextVersion": {
"semver": "2.0.0-rc.21",
"nonce": "1744453385370855"
"nonce": "7754415512164123"
},
"main": "./sources/index.ts",
"dependencies": {
Expand All @@ -26,7 +26,7 @@
"@yarnpkg/plugin-pnp": "workspace:^2.0.0-rc.11",
"@yarnpkg/plugin-version": "workspace:^2.0.0-rc.13",
"@yarnpkg/shell": "workspace:^2.0.0-rc.4",
"chalk": "^2.4.1",
"chalk": "^3.0.0",
"clipanion": "^2.1.5",
"promise.prototype.finally": "^3.1.1",
"semver": "^5.6.0",
Expand Down
6 changes: 2 additions & 4 deletions packages/yarnpkg-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@yarnpkg/core",
"version": "2.0.0-rc.16",
"nextVersion": {
"nonce": "1036848147942221"
"nonce": "3582703902113017"
},
"main": "./sources/index.ts",
"sideEffects": false,
Expand All @@ -13,7 +13,7 @@
"@yarnpkg/pnp": "workspace:^2.0.0-rc.12",
"@yarnpkg/shell": "workspace:^2.0.0-rc.4",
"camelcase": "^5.3.1",
"chalk": "^2.4.1",
"chalk": "^3.0.0",
"clipanion": "^2.1.5",
"cross-spawn": "^6.0.5",
"globby": "^10.0.1",
Expand All @@ -28,7 +28,6 @@
"pretty-bytes": "^5.1.0",
"semver": "^5.6.0",
"stream-to-promise": "^2.2.0",
"supports-color": "^7.1.0",
"tar": "^4.4.6",
"tmp": "^0.1.0",
"tunnel": "^0.0.6"
Expand All @@ -39,7 +38,6 @@
"@types/is-ci": "^2.0.0",
"@types/micromatch": "^3.1.0",
"@types/semver": "^6.0.2",
"@types/supports-color": "^5.3.0",
"@types/tar": "^4.0.0",
"@types/tmp": "^0.0.33",
"@types/tunnel": "^0.0.0",
Expand Down
34 changes: 24 additions & 10 deletions packages/yarnpkg-core/sources/Configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {UsageError} from 'clipanion';
import isCI from 'is-ci';
import semver from 'semver';
import {PassThrough, Writable} from 'stream';
import supportsColor from 'supports-color';
import {tmpNameSync} from 'tmp';

import {Manifest} from './Manifest';
Expand All @@ -25,8 +24,14 @@ import * as nodeUtils from './nodeUtils
import * as structUtils from './structUtils';
import {IdentHash, Package} from './types';

// @ts-ignore
const ctx: any = new chalk.constructor({enabled: true});
const chalkOptions = process.env.GITHUB_ACTIONS
? {level: 2}
: chalk.supportsColor
? {level: chalk.supportsColor.level}
: {level: 0};

const supportsColor = chalkOptions.level !== 0;
const chalkInstance = new chalk.Instance(chalkOptions);

const IGNORED_ENV_VARIABLES = new Set([
// "binFolder" is the magic location where the parent process stored the
Expand Down Expand Up @@ -67,13 +72,20 @@ export enum FormatType {
SCOPE = 'SCOPE',
};

export const formatColors = new Map([
export const formatColors = chalkOptions.level >= 3 ? new Map([
[FormatType.NAME, `#d7875f`],
[FormatType.RANGE, `#00afaf`],
[FormatType.REFERENCE, `#87afff`],
[FormatType.NUMBER, `yellow`],
[FormatType.PATH, `cyan`],
[FormatType.NUMBER, `#ffd700`],
[FormatType.PATH, `#d75fd7`],
[FormatType.SCOPE, `#d75f00`],
]) : new Map([
[FormatType.NAME, 173],
[FormatType.RANGE, 37],
[FormatType.REFERENCE, 111],
[FormatType.NUMBER, 220],
[FormatType.PATH, 170],
[FormatType.SCOPE, 166],
]);

export type BaseSettingsDefinition<T extends SettingsType = SettingsType> = {
Expand Down Expand Up @@ -194,7 +206,7 @@ export const coreDefinitions: {[coreSettingName: string]: SettingsDefinition} =
enableColors: {
description: `If true, the CLI is allowed to use colors in its output`,
type: SettingsType.BOOLEAN,
default: !!supportsColor.stdout,
default: supportsColor,
defaultText: `<dynamic>`,
},
enableInlineBuilds: {
Expand Down Expand Up @@ -1027,9 +1039,11 @@ export class Configuration {
if (typeof color === `undefined`)
color = colorRequest;

const fn = color.startsWith(`#`)
? ctx.hex(color)
: ctx[color];
const fn = typeof color === `number`
? chalkInstance.ansi256(color)
: color.startsWith(`#`)
? chalkInstance.hex(color)
: (chalkInstance as any)[color];

return fn(text);
}
Expand Down
3 changes: 3 additions & 0 deletions packages/yarnpkg-pnp/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"name": "@yarnpkg/pnp",
"version": "2.0.0-rc.13",
"nextVersion": {
"nonce": "1334567419921365"
},
"main": "./sources/index.ts",
"dependencies": {
"@types/node": "^13.1.1",
Expand Down
Loading

0 comments on commit 0111f86

Please sign in to comment.