refactor: inline the colors we need (#1987)

This commit is contained in:
Tommy Nguyen 2024-04-23 19:43:16 +02:00 коммит произвёл GitHub
Родитель fe164588fc
Коммит 84acc29c9a
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
8 изменённых файлов: 23 добавлений и 14 удалений

Просмотреть файл

@ -42,6 +42,7 @@
"schema.json",
"scripts/*.js",
"scripts/apply-config-plugins.mjs",
"scripts/colors.mjs",
"scripts/config-plugins",
"scripts/configure.mjs",
"scripts/embed-manifest",
@ -92,8 +93,7 @@
"fast-xml-parser": "^4.0.0",
"prompts": "^2.4.0",
"semver": "^7.3.5",
"uuid": "^9.0.0",
"yoctocolors": "^2.0.0"
"uuid": "^9.0.0"
},
"peerDependencies": {
"@callstack/react-native-visionos": "0.73 - 0.74",

16
scripts/colors.mjs Normal file
Просмотреть файл

@ -0,0 +1,16 @@
// @ts-check
import { WriteStream } from "node:tty";
const hasColors =
WriteStream.prototype.hasColors() && process.env["NODE_ENV"] !== "test";
/** @type {(start: number, end: number) => (s: string) => string} */
const color = hasColors
? (start, end) => (s) => "\u001B[" + start + "m" + s + "\u001B[" + end + "m"
: () => (s) => s;
export const bold = color(1, 22);
export const dim = color(2, 22);
export const red = color(31, 39);
export const yellow = color(33, 39);
export const cyan = color(36, 39);

Просмотреть файл

@ -6,7 +6,7 @@ import * as path from "node:path";
import { fileURLToPath } from "node:url";
import semverCoerce from "semver/functions/coerce.js";
import semverSatisfies from "semver/functions/satisfies.js";
import * as colors from "yoctocolors";
import * as colors from "./colors.mjs";
import { cliPlatformIOSVersion } from "./configure-projects.js";
import {
getPackageVersion,

Просмотреть файл

@ -8,7 +8,7 @@ import * as os from "node:os";
import * as path from "node:path";
import { fileURLToPath } from "node:url";
import prompts from "prompts";
import * as colors from "yoctocolors";
import * as colors from "./colors.mjs";
import { configure, getDefaultPlatformPackageName } from "./configure.mjs";
import { fetchPackageMetadata, memo, readJSONFile } from "./helpers.js";
import { parseArgs } from "./parseargs.mjs";

Просмотреть файл

@ -175,6 +175,7 @@ describe("npm pack", () => {
"react-native.config.js",
"schema.json",
"scripts/apply-config-plugins.mjs",
"scripts/colors.mjs",
"scripts/config-plugins/ExpoConfigPlugins.mjs",
"scripts/config-plugins/apply.mjs",
"scripts/config-plugins/index.mjs",

Просмотреть файл

@ -3,7 +3,7 @@ import { XMLParser } from "fast-xml-parser";
import * as nodefs from "node:fs";
import * as path from "node:path";
import { v5 as uuidv5 } from "uuid";
import * as colors from "yoctocolors";
import * as colors from "../scripts/colors.mjs";
import {
findNearest,
getPackageVersion,

Просмотреть файл

@ -4,7 +4,7 @@ import * as nodefs from "node:fs";
import * as os from "node:os";
import * as path from "node:path";
import { fileURLToPath } from "node:url";
import * as colors from "yoctocolors";
import * as colors from "../scripts/colors.mjs";
import {
findNearest,
isMain,

Просмотреть файл

@ -12200,7 +12200,6 @@ __metadata:
suggestion-bot: "npm:^3.0.0"
typescript: "npm:^5.0.0"
uuid: "npm:^9.0.0"
yoctocolors: "npm:^2.0.0"
peerDependencies:
"@callstack/react-native-visionos": 0.73 - 0.74
"@expo/config-plugins": ">=5.0"
@ -15215,13 +15214,6 @@ __metadata:
languageName: node
linkType: hard
"yoctocolors@npm:^2.0.0":
version: 2.0.0
resolution: "yoctocolors@npm:2.0.0"
checksum: 10c0/994f5d99e7647a1b333331ffecbbf7c4463d9c2823e371b44e21146a4496cad0f14fbe2f73f44383312a6f843d93523f830f1360009f0ac93027b167ef5c63be
languageName: node
linkType: hard
"zip-stream@npm:^6.0.1":
version: 6.0.1
resolution: "zip-stream@npm:6.0.1"