heading-case 1.1.3 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +24 -185
- package/package.json +12 -9
package/dist/index.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { execFileSync } from "node:child_process";
|
|
2
2
|
import node_fs from "node:fs";
|
|
3
3
|
import node_util from "node:util";
|
|
4
|
-
import node_process from "node:process";
|
|
5
|
-
import node_os from "node:os";
|
|
6
|
-
import node_tty from "node:tty";
|
|
7
4
|
import * as __rspack_external_fs from "fs";
|
|
8
5
|
import { readdir, readdirSync, realpath, realpathSync, stat as external_fs_stat, statSync } from "fs";
|
|
9
6
|
import { basename, dirname, isAbsolute, normalize, posix, relative as external_path_relative, resolve, sep } from "path";
|
|
@@ -1760,146 +1757,8 @@ const color = {
|
|
|
1760
1757
|
underline: createStyler('underline'),
|
|
1761
1758
|
strikethrough: createStyler('strikethrough')
|
|
1762
1759
|
};
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
const position = argv.indexOf(prefix + flag);
|
|
1766
|
-
const terminatorPosition = argv.indexOf('--');
|
|
1767
|
-
return -1 !== position && (-1 === terminatorPosition || position < terminatorPosition);
|
|
1768
|
-
}
|
|
1769
|
-
const { env: env } = node_process;
|
|
1770
|
-
let flagForceColor;
|
|
1771
|
-
if (hasFlag('no-color') || hasFlag('no-colors') || hasFlag('color=false') || hasFlag('color=never')) flagForceColor = 0;
|
|
1772
|
-
else if (hasFlag('color') || hasFlag('colors') || hasFlag('color=true') || hasFlag('color=always')) flagForceColor = 1;
|
|
1773
|
-
function envForceColor() {
|
|
1774
|
-
if (!('FORCE_COLOR' in env)) return;
|
|
1775
|
-
if ('true' === env.FORCE_COLOR) return 1;
|
|
1776
|
-
if ('false' === env.FORCE_COLOR) return 0;
|
|
1777
|
-
if (0 === env.FORCE_COLOR.length) return 1;
|
|
1778
|
-
const level = Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
|
|
1779
|
-
if (![
|
|
1780
|
-
0,
|
|
1781
|
-
1,
|
|
1782
|
-
2,
|
|
1783
|
-
3
|
|
1784
|
-
].includes(level)) return;
|
|
1785
|
-
return level;
|
|
1786
|
-
}
|
|
1787
|
-
function translateLevel(level) {
|
|
1788
|
-
if (0 === level) return false;
|
|
1789
|
-
return {
|
|
1790
|
-
level,
|
|
1791
|
-
hasBasic: true,
|
|
1792
|
-
has256: level >= 2,
|
|
1793
|
-
has16m: level >= 3
|
|
1794
|
-
};
|
|
1795
|
-
}
|
|
1796
|
-
function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
|
|
1797
|
-
const noFlagForceColor = envForceColor();
|
|
1798
|
-
if (void 0 !== noFlagForceColor) flagForceColor = noFlagForceColor;
|
|
1799
|
-
const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
|
|
1800
|
-
if (0 === forceColor) return 0;
|
|
1801
|
-
if (sniffFlags) {
|
|
1802
|
-
if (hasFlag('color=16m') || hasFlag('color=full') || hasFlag('color=truecolor')) return 3;
|
|
1803
|
-
if (hasFlag('color=256')) return 2;
|
|
1804
|
-
}
|
|
1805
|
-
if ('TF_BUILD' in env && 'AGENT_NAME' in env) return 1;
|
|
1806
|
-
if (haveStream && !streamIsTTY && void 0 === forceColor) return 0;
|
|
1807
|
-
const min = forceColor || 0;
|
|
1808
|
-
if ('dumb' === env.TERM) return min;
|
|
1809
|
-
if ('win32' === node_process.platform) {
|
|
1810
|
-
const osRelease = node_os.release().split('.');
|
|
1811
|
-
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
1812
|
-
return 1;
|
|
1813
|
-
}
|
|
1814
|
-
if ('CI' in env) {
|
|
1815
|
-
if ([
|
|
1816
|
-
'GITHUB_ACTIONS',
|
|
1817
|
-
'GITEA_ACTIONS',
|
|
1818
|
-
'CIRCLECI'
|
|
1819
|
-
].some((key)=>key in env)) return 3;
|
|
1820
|
-
if ([
|
|
1821
|
-
'TRAVIS',
|
|
1822
|
-
'APPVEYOR',
|
|
1823
|
-
'GITLAB_CI',
|
|
1824
|
-
'BUILDKITE',
|
|
1825
|
-
'DRONE'
|
|
1826
|
-
].some((sign)=>sign in env) || 'codeship' === env.CI_NAME) return 1;
|
|
1827
|
-
return min;
|
|
1828
|
-
}
|
|
1829
|
-
if ('TEAMCITY_VERSION' in env) return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
|
1830
|
-
if ('truecolor' === env.COLORTERM) return 3;
|
|
1831
|
-
if ('xterm-kitty' === env.TERM) return 3;
|
|
1832
|
-
if ('xterm-ghostty' === env.TERM) return 3;
|
|
1833
|
-
if ('wezterm' === env.TERM) return 3;
|
|
1834
|
-
if ('TERM_PROGRAM' in env) {
|
|
1835
|
-
const version = Number.parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
|
|
1836
|
-
switch(env.TERM_PROGRAM){
|
|
1837
|
-
case 'iTerm.app':
|
|
1838
|
-
return version >= 3 ? 3 : 2;
|
|
1839
|
-
case 'Apple_Terminal':
|
|
1840
|
-
return 2;
|
|
1841
|
-
}
|
|
1842
|
-
}
|
|
1843
|
-
if (/-256(color)?$/i.test(env.TERM)) return 2;
|
|
1844
|
-
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) return 1;
|
|
1845
|
-
if ('COLORTERM' in env) return 1;
|
|
1846
|
-
return min;
|
|
1847
|
-
}
|
|
1848
|
-
function createSupportsColor(stream, options = {}) {
|
|
1849
|
-
const level = _supportsColor(stream, {
|
|
1850
|
-
streamIsTTY: stream && stream.isTTY,
|
|
1851
|
-
...options
|
|
1852
|
-
});
|
|
1853
|
-
return translateLevel(level);
|
|
1854
|
-
}
|
|
1855
|
-
const supportsColor = {
|
|
1856
|
-
stdout: createSupportsColor({
|
|
1857
|
-
isTTY: node_tty.isatty(1)
|
|
1858
|
-
}),
|
|
1859
|
-
stderr: createSupportsColor({
|
|
1860
|
-
isTTY: node_tty.isatty(2)
|
|
1861
|
-
})
|
|
1862
|
-
};
|
|
1863
|
-
const supports_color = supportsColor;
|
|
1864
|
-
const colorLevel = supports_color.stdout ? supports_color.stdout.level : 0;
|
|
1865
|
-
const errorStackRegExp = /at [^\r\n]{0,200}:\d+:\d+[\s\)]*$/;
|
|
1866
|
-
const anonymousErrorStackRegExp = /at [^\r\n]{0,200}\(<anonymous>\)$/;
|
|
1867
|
-
const indexErrorStackRegExp = /at [^\r\n]{0,200}\(index\s\d+\)$/;
|
|
1868
|
-
const isErrorStackMessage = (message)=>errorStackRegExp.test(message) || anonymousErrorStackRegExp.test(message) || indexErrorStackRegExp.test(message);
|
|
1869
|
-
const startColor = [
|
|
1870
|
-
189,
|
|
1871
|
-
255,
|
|
1872
|
-
243
|
|
1873
|
-
];
|
|
1874
|
-
const endColor = [
|
|
1875
|
-
74,
|
|
1876
|
-
194,
|
|
1877
|
-
154
|
|
1878
|
-
];
|
|
1879
|
-
const isWord = (char)=>!/[\s\n]/.test(char);
|
|
1880
|
-
const gradient = (message)=>{
|
|
1881
|
-
if (colorLevel < 3) return 2 === colorLevel ? color.cyan(message) : message;
|
|
1882
|
-
const chars = [
|
|
1883
|
-
...message
|
|
1884
|
-
];
|
|
1885
|
-
const steps = chars.filter(isWord).length;
|
|
1886
|
-
let r = startColor[0];
|
|
1887
|
-
let g = startColor[1];
|
|
1888
|
-
let b = startColor[2];
|
|
1889
|
-
const rStep = (endColor[0] - r) / steps;
|
|
1890
|
-
const gStep = (endColor[1] - g) / steps;
|
|
1891
|
-
const bStep = (endColor[2] - b) / steps;
|
|
1892
|
-
let output = '';
|
|
1893
|
-
for (const char of chars){
|
|
1894
|
-
if (isWord(char)) {
|
|
1895
|
-
r += rStep;
|
|
1896
|
-
g += gStep;
|
|
1897
|
-
b += bStep;
|
|
1898
|
-
}
|
|
1899
|
-
output += `\x1b[38;2;${Math.round(r)};${Math.round(g)};${Math.round(b)}m${char}\x1b[39m`;
|
|
1900
|
-
}
|
|
1901
|
-
return color.bold(output);
|
|
1902
|
-
};
|
|
1760
|
+
const supportsTrueColor = true === process.stdout.isTTY && process.stdout.hasColors(2 ** 24, process.env);
|
|
1761
|
+
const boldMint = (text)=>supportsTrueColor ? `\x1b[1;38;2;132;225;199m${text}\x1b[39;22m` : color.bold(color.cyan(text));
|
|
1903
1762
|
const LOG_LEVEL = {
|
|
1904
1763
|
silent: -1,
|
|
1905
1764
|
error: 0,
|
|
@@ -1908,46 +1767,29 @@ const LOG_LEVEL = {
|
|
|
1908
1767
|
log: 2,
|
|
1909
1768
|
verbose: 3
|
|
1910
1769
|
};
|
|
1770
|
+
const createLogType = (label, level, style)=>{
|
|
1771
|
+
let formattedLabel;
|
|
1772
|
+
return {
|
|
1773
|
+
get label () {
|
|
1774
|
+
return formattedLabel ??= color.bold(style(label.padEnd(7)));
|
|
1775
|
+
},
|
|
1776
|
+
level
|
|
1777
|
+
};
|
|
1778
|
+
};
|
|
1911
1779
|
const LOG_TYPES = {
|
|
1912
|
-
error:
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
label: 'warn',
|
|
1919
|
-
level: 'warn',
|
|
1920
|
-
color: color.yellow
|
|
1921
|
-
},
|
|
1922
|
-
info: {
|
|
1923
|
-
label: 'info',
|
|
1924
|
-
level: 'info',
|
|
1925
|
-
color: color.cyan
|
|
1926
|
-
},
|
|
1927
|
-
start: {
|
|
1928
|
-
label: 'start',
|
|
1929
|
-
level: 'info',
|
|
1930
|
-
color: color.cyan
|
|
1931
|
-
},
|
|
1932
|
-
ready: {
|
|
1933
|
-
label: 'ready',
|
|
1934
|
-
level: 'info',
|
|
1935
|
-
color: color.green
|
|
1936
|
-
},
|
|
1937
|
-
success: {
|
|
1938
|
-
label: 'success',
|
|
1939
|
-
level: 'info',
|
|
1940
|
-
color: color.green
|
|
1941
|
-
},
|
|
1780
|
+
error: createLogType('error', 'error', color.red),
|
|
1781
|
+
warn: createLogType('warn', 'warn', color.yellow),
|
|
1782
|
+
info: createLogType('info', 'info', color.cyan),
|
|
1783
|
+
start: createLogType('start', 'info', color.cyan),
|
|
1784
|
+
ready: createLogType('ready', 'info', color.green),
|
|
1785
|
+
success: createLogType('success', 'info', color.green),
|
|
1942
1786
|
log: {
|
|
1943
1787
|
level: 'info'
|
|
1944
1788
|
},
|
|
1945
|
-
debug:
|
|
1946
|
-
label: 'debug',
|
|
1947
|
-
level: 'verbose',
|
|
1948
|
-
color: color.magenta
|
|
1949
|
-
}
|
|
1789
|
+
debug: createLogType('debug', 'verbose', color.magenta)
|
|
1950
1790
|
};
|
|
1791
|
+
const errorStackRegExp = /at [^\r\n]{0,200}(?::\d+:\d+[\s)]*|\(<anonymous>\)|\(index\s\d+\))$/;
|
|
1792
|
+
const isErrorStackMessage = (message)=>errorStackRegExp.test(message);
|
|
1951
1793
|
const normalizeErrorMessage = (err)=>{
|
|
1952
1794
|
if (err.stack) {
|
|
1953
1795
|
const [rawName, ...rest] = err.stack.split('\n');
|
|
@@ -1964,12 +1806,8 @@ const createLogger = (options = {})=>{
|
|
|
1964
1806
|
const { level } = logType;
|
|
1965
1807
|
if (LOG_LEVEL[level] > LOG_LEVEL[maxLevel]) return;
|
|
1966
1808
|
if (null == message) return console1.log();
|
|
1967
|
-
|
|
1809
|
+
const label = 'label' in logType ? logType.label : '';
|
|
1968
1810
|
let text = '';
|
|
1969
|
-
if ('label' in logType) {
|
|
1970
|
-
label = (logType.label || '').padEnd(7);
|
|
1971
|
-
label = color.bold(logType.color ? logType.color(label) : label);
|
|
1972
|
-
}
|
|
1973
1811
|
if (message instanceof Error) {
|
|
1974
1812
|
text += normalizeErrorMessage(message);
|
|
1975
1813
|
const { cause } = message;
|
|
@@ -1983,10 +1821,10 @@ const createLogger = (options = {})=>{
|
|
|
1983
1821
|
} else text = `${message}`;
|
|
1984
1822
|
if (prefix) text = `${prefix} ${text}`;
|
|
1985
1823
|
const method = 'error' === level || 'warn' === level ? level : 'log';
|
|
1986
|
-
console1[method](label
|
|
1824
|
+
console1[method](label ? `${label} ${text}` : text, ...args);
|
|
1987
1825
|
};
|
|
1988
1826
|
const logger = {
|
|
1989
|
-
greet: (message)=>log('log',
|
|
1827
|
+
greet: (message)=>log('log', boldMint(message))
|
|
1990
1828
|
};
|
|
1991
1829
|
Object.keys(LOG_TYPES).forEach((key)=>{
|
|
1992
1830
|
logger[key] = (...args)=>log(key, ...args);
|
|
@@ -2829,6 +2667,7 @@ const dict = [
|
|
|
2829
2667
|
'Vue',
|
|
2830
2668
|
'Web Workers',
|
|
2831
2669
|
'Xcode',
|
|
2670
|
+
'Yarn',
|
|
2832
2671
|
'Zeabur',
|
|
2833
2672
|
'Zephyr',
|
|
2834
2673
|
'Zephyr Cloud'
|
package/package.json
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "heading-case",
|
|
3
|
-
"version": "1.1.
|
|
4
|
-
"repository":
|
|
3
|
+
"version": "1.1.4",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "https://github.com/rstackjs/heading-case"
|
|
7
|
+
},
|
|
5
8
|
"license": "MIT",
|
|
6
9
|
"type": "module",
|
|
7
10
|
"exports": {
|
|
@@ -21,18 +24,18 @@
|
|
|
21
24
|
"pre-commit": "pnpm run lint:write"
|
|
22
25
|
},
|
|
23
26
|
"devDependencies": {
|
|
24
|
-
"@rslib/core": "^0.
|
|
25
|
-
"@rslint/core": "^0.5
|
|
26
|
-
"@rstest/core": "^0.
|
|
27
|
-
"@types/node": "^24.
|
|
27
|
+
"@rslib/core": "^0.23.2",
|
|
28
|
+
"@rslint/core": "^0.6.5",
|
|
29
|
+
"@rstest/core": "^0.11.1",
|
|
30
|
+
"@types/node": "^24.13.3",
|
|
28
31
|
"case-police": "^2.2.1",
|
|
29
32
|
"pathe": "^2.0.3",
|
|
30
33
|
"picocolors": "^1.1.1",
|
|
31
|
-
"prettier": "^3.
|
|
32
|
-
"rslog": "^2.
|
|
34
|
+
"prettier": "^3.9.5",
|
|
35
|
+
"rslog": "^2.2.0",
|
|
33
36
|
"simple-git-hooks": "^2.13.1",
|
|
34
37
|
"tinyglobby": "^0.2.17",
|
|
35
|
-
"typescript": "^
|
|
38
|
+
"typescript": "^7.0.2"
|
|
36
39
|
},
|
|
37
40
|
"publishConfig": {
|
|
38
41
|
"access": "public",
|