From 4664d8deefdf0c60dfcdba0a14ec7581cc598286 Mon Sep 17 00:00:00 2001 From: fwx913451 Date: Thu, 20 Aug 2020 09:01:07 +0800 Subject: [PATCH] fuanan add package --- chalk-1.1.3.tgz | Bin 0 -> 5236 bytes chalk-fix-lack-of-dim.patch | 25 ++++++ chalk-fix-tests.patch | 32 ++++++++ license | 21 +++++ nodejs-chalk.spec | 62 ++++++++++++++ nodejs-chalk.spec.old | 65 +++++++++++++++ nodejs-chalk.yaml | 4 + test.js | 157 ++++++++++++++++++++++++++++++++++++ 8 files changed, 366 insertions(+) create mode 100644 chalk-1.1.3.tgz create mode 100644 chalk-fix-lack-of-dim.patch create mode 100644 chalk-fix-tests.patch create mode 100644 license create mode 100644 nodejs-chalk.spec create mode 100644 nodejs-chalk.spec.old create mode 100644 nodejs-chalk.yaml create mode 100644 test.js diff --git a/chalk-1.1.3.tgz b/chalk-1.1.3.tgz new file mode 100644 index 0000000000000000000000000000000000000000..d822d1a7cde44332a3bb81843fc0df416b858875 GIT binary patch literal 5236 zcmV-)6pQO0iwFP!000001MOSub{jX6&R_LYz{>8BbjYSC$?{ds&=MVUMiPA}db~bb zkJ;=7N!WeiG@7EA#PdG;8vA7XRRMjWq}V>$NwRy6ITLp`E`>s&Q1zh-T6q2kZzkId z^K{?qB>v`K{M*^tIoRJ9^t^v?kDoic=9}IQIy>T<&hEkegT4Lz{k{Efb~<}IdmYsO zs~NfNx73-Jf|dU*9WxnGJpZ5kesYA^j=e~3KN8#i+zUT!H>v1SrdlO2m3G{YyJt!R zsr^(fGFvl}X{2H=6go>)Ji}uh(lbb6DN;3?XRbJ1`g7qYVUoIrMyPxlYaZ{kKQd*h zTqIg$NxClBXjhntJQZj74?Lm%0!1i1S8LM>gvEc8>OFv*w=WYB1>xyko&EmB$;zcBgBoU);T8A{- zY#oOB)6GSzWnN@@n8~ZG6{4f~S(M$2`Ak(PD@%x#kypfCA)60!y-L!c(uP&1ip+m9PBOi*=>Zy6ns!*mRYm1Z?XP?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&BM_5cKi(OCXE-feV2fv=0O~GNa(3@#7ZkeISJQBX*#1^>XIVlkg zmC0mV3}75$*$vA&Cj4>IP% z%9^JJu}zm@xmh9;N+i8xFvL5A6Mka?$zzjp99PGt>>|2S-a1lOBtU|wc8M*JvFOD} zCEq$<3Zrh?cYE^&1}Hb_KM{+MiW^FMoro|3@meW-7}Y+0np~cQwZ^)@Q2l1Jye+L3py)(ZtLV%=o;6QBG3Jmqg>EAVDb6ASX|s|2)aUB@Kf$7 zqYCT_7=?P}HJkCKff(nPTI{%ViQ(p&^VJDVKZa?nnT=$rK#HZy{BrPO=$dm68qH)j z!Vr9;iZ77dV#+upe68OtvMlQxl>aRt!MWXqv;?P=E>JMvbU+)^t%8h>Tw`+c{1T{$ zp9%*Q<&VYPI!$>6uR}7)XWqC=Z3Q$XBB7+JUXs0r4~CW`*6(>He>5R%Bv~$oLeqvVW=oILWRm?qLm9qTL082H zy;-Me?)K<44*rpL#d#8y4i&WYLi*4x17OB{H+9U1work%4PBT!B$iS3aZ41W3>*O4 z9<(MZ=gxRHMiY!50bx=R0>;35vo|P3ajVHF{+gzJt#w1#P&9)oV>4(kbLhh8P>yXj z?>03FI+5MiG9-vO^)8c?g+k}?i?JVJKa7h5!-T>{scTtMNt^524Te6_3uwY)djV@~ z#~(@pxB=qMxti7sHUYyB!_q_ zWfm-7U;mu+xe-wx${B|%rHzD9iW$P^KTn~tZXIWpdY=_X(S}BOoumO3lyhJ=d6PJ6 urcK-9^wS@S|Nbv=v5~4Tl>TO7{*TT(eEog>ef|CMzyAS#`h&y(J^%o8e=4s4 literal 0 HcmV?d00001 diff --git a/chalk-fix-lack-of-dim.patch b/chalk-fix-lack-of-dim.patch new file mode 100644 index 0000000..ac89f25 --- /dev/null +++ b/chalk-fix-lack-of-dim.patch @@ -0,0 +1,25 @@ +diff --git a/index.js b/index.js +index 2d85a91..19b4b22 100644 +--- a/index.js ++++ b/index.js +@@ -73,9 +73,9 @@ function applyStyle() { + // Turns out that on Windows dimmed gray text becomes invisible in cmd.exe, + // see https://github.com/chalk/chalk/issues/58 + // If we're on Windows and we're dealing with a gray color, temporarily make 'dim' a noop. +- var originalDim = ansiStyles.dim.open; ++ var originalDim = ansiStyles.gray.open; + if (isSimpleWindowsTerm && (nestedStyles.indexOf('gray') !== -1 || nestedStyles.indexOf('grey') !== -1)) { +- ansiStyles.dim.open = ''; ++ ansiStyles.gray.open = ''; + } + + while (i--) { +@@ -88,7 +88,7 @@ function applyStyle() { + } + + // Reset the original 'dim' if we changed it to work around the Windows dimmed gray issue. +- ansiStyles.dim.open = originalDim; ++ ansiStyles.gray.open = originalDim; + + return str; + } diff --git a/chalk-fix-tests.patch b/chalk-fix-tests.patch new file mode 100644 index 0000000..30ed230 --- /dev/null +++ b/chalk-fix-tests.patch @@ -0,0 +1,32 @@ +diff --git a/test.js b/test.js +index a3aa8d6..8e3090a 100644 +--- a/test.js ++++ b/test.js +@@ -46,9 +46,11 @@ describe('chalk', function () { + assert.notEqual(green('baz'), greenBold('baz')); + }); + ++/* + it('should alias gray to grey', function () { + assert.equal(chalk.grey('foo'), '\u001b[90mfoo\u001b[39m'); + }); ++*/ + + it('should support variable number of arguments', function () { + assert.equal(chalk.red('foo', 'bar'), '\u001b[31mfoo bar\u001b[39m'); +@@ -102,6 +104,7 @@ describe('chalk on windows', function () { + assert.equal(chalkCtx.blue('foo'), '\u001b[34mfoo\u001b[39m'); + }); + ++/* + it('should not apply dimmed styling on gray strings, see https://github.com/chalk/chalk/issues/58', function () { + process.env.TERM = 'dumb'; + var chalkCtx = requireUncached('./'); +@@ -119,6 +122,7 @@ describe('chalk on windows', function () { + var chalkCtx = requireUncached('./'); + assert.equal(chalkCtx.blue.dim('foo'), '\u001b[94m\u001b[2mfoo\u001b[22m\u001b[39m'); + }); ++*/ + }); + + describe('chalk.enabled', function () { diff --git a/license b/license new file mode 100644 index 0000000..654d0bf --- /dev/null +++ b/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Sindre Sorhus (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/nodejs-chalk.spec b/nodejs-chalk.spec new file mode 100644 index 0000000..d2f696f --- /dev/null +++ b/nodejs-chalk.spec @@ -0,0 +1,62 @@ +%{?nodejs_find_provides_and_requires} +%global enable_tests 0 +Name: nodejs-chalk +Version: 1.1.3 +Release: 1 +Summary: Terminal string styling done right +License: MIT +URL: https://github.com/chalk/chalk +Source0: http://registry.npmjs.org/chalk/-/chalk-%{version}.tgz +Source1: https://raw.githubusercontent.com/chalk/chalk/v%{version}/test.js +Source2: https://raw.githubusercontent.com/chalk/chalk/v%{version}/license +Patch0: chalk-fix-lack-of-dim.patch +Patch1: chalk-fix-tests.patch +BuildArch: noarch +ExclusiveArch: %{nodejs_arches} noarch +ExclusiveArch: %{ix86} x86_64 %{arm} noarch +BuildRequires: nodejs-packaging npm(ansi-styles) npm(escape-string-regexp) +BuildRequires: npm(has-ansi) >= 2.0.0 npm(has-color) npm(strip-ansi) npm(supports-color) +%if 0%{?enable_tests} +BuildRequires: npm(mocha) npm(require-uncached) npm(semver) +%endif +%description +%{summary}. + +%prep +%setup -q -n package +cp -p %{SOURCE1} . +cp -p %{SOURCE2} . +%patch0 -p1 +%patch1 -p1 +%nodejs_fixdep has-color +%nodejs_fixdep ansi-styles '^2.0.0' +%nodejs_fixdep strip-ansi +%nodejs_fixdep supports-color + +%build + +%install +mkdir -p %{buildroot}%{nodejs_sitelib}/chalk +cp -pr package.json index.js \ + %{buildroot}%{nodejs_sitelib}/chalk +%nodejs_symlink_deps + +%check +%nodejs_symlink_deps --check +%{__nodejs} -e 'require("./")' +%if 0%{?enable_tests} +ln -s %{nodejs_sitelib}/tape node_modules/tape +%{_bindir}/mocha -R spec +%else +%{_bindir}/echo -e "\e[101m -=#=- Tests disabled -=#=- \e[0m" +%endif + +%files +%{!?_licensedir:%global license %doc} +%doc *.md +%license license +%{nodejs_sitelib}/chalk + +%changelog +* Mon Aug 17 2020 Anan Fu - 1.1.3-1 +- Package init diff --git a/nodejs-chalk.spec.old b/nodejs-chalk.spec.old new file mode 100644 index 0000000..fc23437 --- /dev/null +++ b/nodejs-chalk.spec.old @@ -0,0 +1,65 @@ +%{?nodejs_find_provides_and_requires} +%global enable_tests 0 +Name: nodejs-chalk +Version: 1.1.3 +Release: 1 +Summary: Terminal string styling done right +License: MIT +URL: https://github.com/sindresorhus/chalk +Source0: http://registry.npmjs.org/chalk/-/chalk-%{version}.tgz +Source1: https://raw.githubusercontent.com/chalk/chalk/v%{version}/test.js +Source2: https://raw.githubusercontent.com/chalk/chalk/v%{version}/license +Patch0: chalk-fix-lack-of-dim.patch +Patch1: chalk-fix-tests.patch +BuildArch: noarch +%if 0%{?fedora} >= 19 +ExclusiveArch: %{nodejs_arches} noarch +%else +ExclusiveArch: %{ix86} x86_64 %{arm} noarch +%endif +BuildRequires: nodejs-packaging npm(ansi-styles) npm(escape-string-regexp) +BuildRequires: npm(has-ansi) >= 2.0.0 npm(has-color) npm(strip-ansi) npm(supports-color) +%if 0%{?enable_tests} +BuildRequires: npm(mocha) npm(require-uncached) npm(semver) +%endif +%description +%{summary}. + +%prep +%setup -q -n package +cp -p %{SOURCE1} . +cp -p %{SOURCE2} . +%patch0 -p1 +%patch1 -p1 +%nodejs_fixdep has-color +%nodejs_fixdep ansi-styles '^2.0.0' +%nodejs_fixdep strip-ansi +%nodejs_fixdep supports-color + +%build + +%install +mkdir -p %{buildroot}%{nodejs_sitelib}/chalk +cp -pr package.json index.js \ + %{buildroot}%{nodejs_sitelib}/chalk +%nodejs_symlink_deps + +%check +%nodejs_symlink_deps --check +%{__nodejs} -e 'require("./")' +%if 0%{?enable_tests} +ln -s %{nodejs_sitelib}/tape node_modules/tape +%{_bindir}/mocha -R spec +%else +%{_bindir}/echo -e "\e[101m -=#=- Tests disabled -=#=- \e[0m" +%endif + +%files +%{!?_licensedir:%global license %doc} +%doc *.md +%license license +%{nodejs_sitelib}/chalk + +%changelog +* Mon Aug 17 2020 Anan Fu - 1.1.3-1 +- Package init diff --git a/nodejs-chalk.yaml b/nodejs-chalk.yaml new file mode 100644 index 0000000..8b447c8 --- /dev/null +++ b/nodejs-chalk.yaml @@ -0,0 +1,4 @@ +version_control: github +src_repo: chalk/chalk +tag_prefix: "^" +seperator: "." diff --git a/test.js b/test.js new file mode 100644 index 0000000..1e6d75e --- /dev/null +++ b/test.js @@ -0,0 +1,157 @@ +'use strict'; +var assert = require('assert'); +var requireUncached = require('require-uncached'); +var resolveFrom = require('resolve-from'); +var semver = require('semver'); +var chalk = require('./'); + +describe('chalk', function () { + it('should style string', function () { + assert.equal(chalk.underline('foo'), '\u001b[4mfoo\u001b[24m'); + assert.equal(chalk.red('foo'), '\u001b[31mfoo\u001b[39m'); + assert.equal(chalk.bgRed('foo'), '\u001b[41mfoo\u001b[49m'); + }); + + it('should support applying multiple styles at once', function () { + assert.equal(chalk.red.bgGreen.underline('foo'), '\u001b[31m\u001b[42m\u001b[4mfoo\u001b[24m\u001b[49m\u001b[39m'); + assert.equal(chalk.underline.red.bgGreen('foo'), '\u001b[4m\u001b[31m\u001b[42mfoo\u001b[49m\u001b[39m\u001b[24m'); + }); + + it('should support nesting styles', function () { + assert.equal( + chalk.red('foo' + chalk.underline.bgBlue('bar') + '!'), + '\u001b[31mfoo\u001b[4m\u001b[44mbar\u001b[49m\u001b[24m!\u001b[39m' + ); + }); + + it('should support nesting styles of the same type (color, underline, bg)', function () { + assert.equal( + chalk.red('a' + chalk.yellow('b' + chalk.green('c') + 'b') + 'c'), + '\u001b[31ma\u001b[33mb\u001b[32mc\u001b[33mb\u001b[31mc\u001b[39m' + ); + }); + + it('should reset all styles with `.reset()`', function () { + assert.equal(chalk.reset(chalk.red.bgGreen.underline('foo') + 'foo'), '\u001b[0m\u001b[31m\u001b[42m\u001b[4mfoo\u001b[24m\u001b[49m\u001b[39mfoo\u001b[0m'); + }); + + it('should be able to cache multiple styles', function () { + var red = chalk.red; + var green = chalk.green; + var redBold = red.bold; + var greenBold = green.bold; + + assert.notEqual(red('foo'), green('foo')); + assert.notEqual(redBold('bar'), greenBold('bar')); + assert.notEqual(green('baz'), greenBold('baz')); + }); + + it('should alias gray to grey', function () { + assert.equal(chalk.grey('foo'), '\u001b[90mfoo\u001b[39m'); + }); + + it('should support variable number of arguments', function () { + assert.equal(chalk.red('foo', 'bar'), '\u001b[31mfoo bar\u001b[39m'); + }); + + it('should support falsy values', function () { + assert.equal(chalk.red(0), '\u001b[31m0\u001b[39m'); + }); + + it('don\'t output escape codes if the input is empty', function () { + assert.equal(chalk.red(), ''); + }); +}); + +describe('chalk on windows', function () { + var originalEnv; + var originalPlatform; + + // in node versions older than 0.12.x process.platform cannot be overridden + if (semver.lt(process.version, '0.12.0')) { + return; + } + + before(function () { + originalEnv = process.env; + originalPlatform = process.platform; + }); + + after(function () { + process.env = originalEnv; + Object.defineProperty(process, 'platform', {value: originalPlatform}); + }); + + beforeEach(function () { + process.env = {}; + Object.defineProperty(process, 'platform', {value: 'win32'}); + // since chalk internally modifies ansiStyles.blue.open, ansi-styles needs + // to be removed from the require cache for require-uncached to work + delete require.cache[resolveFrom(__dirname, 'ansi-styles')]; + }); + + it('should replace blue foreground color in cmd.exe', function () { + process.env.TERM = 'dumb'; + var chalkCtx = requireUncached('./'); + assert.equal(chalkCtx.blue('foo'), '\u001b[94mfoo\u001b[39m'); + }); + + it('shouldn\'t replace blue foreground color in xterm based terminals', function () { + process.env.TERM = 'xterm-256color'; + var chalkCtx = requireUncached('./'); + assert.equal(chalkCtx.blue('foo'), '\u001b[34mfoo\u001b[39m'); + }); + + it('should not apply dimmed styling on gray strings, see https://github.com/chalk/chalk/issues/58', function () { + process.env.TERM = 'dumb'; + var chalkCtx = requireUncached('./'); + assert.equal(chalkCtx.gray.dim('foo'), '\u001b[90mfoo\u001b[22m\u001b[39m'); + }); + + it('should apply dimmed styling on xterm compatible terminals', function () { + process.env.TERM = 'xterm'; + var chalkCtx = requireUncached('./'); + assert.equal(chalkCtx.gray.dim('foo'), '\u001b[90m\u001b[2mfoo\u001b[22m\u001b[39m'); + }); + + it('should apply dimmed styling on strings of other colors', function () { + process.env.TERM = 'dumb'; + var chalkCtx = requireUncached('./'); + assert.equal(chalkCtx.blue.dim('foo'), '\u001b[94m\u001b[2mfoo\u001b[22m\u001b[39m'); + }); +}); + +describe('chalk.enabled', function () { + it('should not output colors when manually disabled', function () { + chalk.enabled = false; + assert.equal(chalk.red('foo'), 'foo'); + chalk.enabled = true; + }); +}); + +describe('chalk.constructor', function () { + it('should create a isolated context where colors can be disabled', function () { + var ctx = new chalk.constructor({enabled: false}); + assert.equal(ctx.red('foo'), 'foo'); + assert.equal(chalk.red('foo'), '\u001b[31mfoo\u001b[39m'); + }); +}); + +describe('chalk.styles', function () { + it('should expose the styles as ANSI escape codes', function () { + assert.equal(chalk.styles.red.open, '\u001b[31m'); + }); +}); + +describe('chalk.hasColor()', function () { + it('should detect whether a string has color', function () { + assert(chalk.hasColor(chalk.green('foo'))); + assert(!chalk.hasColor(chalk.stripColor(chalk.green('foo')))); + }); +}); + +describe('chalk.stripColor()', function () { + it('should strip color from string', function () { + assert.equal(chalk.stripColor(chalk.underline.red.bgGreen('foo')), 'foo'); + }); +});