tailwindcss-patch 8.7.1 → 8.7.3
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/README.md +38 -36
- package/dist/{chunk-OK2PBYIA.mjs → chunk-3T6WSV7F.mjs} +1464 -1320
- package/dist/chunk-7JAOSSRO.js +7 -0
- package/dist/{chunk-K3NZYVML.js → chunk-EFYAZO6C.js} +1496 -1356
- package/dist/chunk-JHEI2MLC.mjs +10 -0
- package/dist/cli.js +5 -4
- package/dist/cli.mjs +2 -1
- package/dist/dist-EMUBVNNO.mjs +269 -0
- package/dist/dist-NW65QXLC.js +269 -0
- package/dist/index.d.mts +61 -44
- package/dist/index.d.ts +61 -44
- package/dist/index.js +3 -2
- package/dist/index.mjs +2 -1
- package/package.json +6 -6
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2
|
|
2
|
-
|
|
3
|
-
var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2;
|
|
2
|
+
|
|
3
|
+
var _chunk7JAOSSROjs = require('./chunk-7JAOSSRO.js');
|
|
4
4
|
|
|
5
5
|
// src/logger.ts
|
|
6
6
|
var _consola = require('consola');
|
|
@@ -20,7 +20,7 @@ var _pathe = require('pathe'); var _pathe2 = _interopRequireDefault(_pathe);
|
|
|
20
20
|
// package.json
|
|
21
21
|
var package_default = {
|
|
22
22
|
name: "tailwindcss-patch",
|
|
23
|
-
version: "8.7.
|
|
23
|
+
version: "8.7.3",
|
|
24
24
|
description: "patch tailwindcss for exposing context and extract classes",
|
|
25
25
|
author: "ice breaker <1324318532@qq.com>",
|
|
26
26
|
license: "MIT",
|
|
@@ -41,17 +41,17 @@ var package_default = {
|
|
|
41
41
|
],
|
|
42
42
|
exports: {
|
|
43
43
|
".": {
|
|
44
|
-
types: "./
|
|
45
|
-
import: "./
|
|
46
|
-
require: "./
|
|
44
|
+
types: "./dist/index.d.ts",
|
|
45
|
+
import: "./dist/index.mjs",
|
|
46
|
+
require: "./dist/index.js"
|
|
47
47
|
},
|
|
48
48
|
"./migration-report.schema.json": "./schema/migration-report.schema.json",
|
|
49
49
|
"./restore-result.schema.json": "./schema/restore-result.schema.json",
|
|
50
50
|
"./validate-result.schema.json": "./schema/validate-result.schema.json"
|
|
51
51
|
},
|
|
52
|
-
main: "./
|
|
53
|
-
module: "./
|
|
54
|
-
types: "./
|
|
52
|
+
main: "./dist/index.js",
|
|
53
|
+
module: "./dist/index.mjs",
|
|
54
|
+
types: "./dist/index.d.ts",
|
|
55
55
|
bin: {
|
|
56
56
|
"tw-patch": "dev/bin.ts",
|
|
57
57
|
"tailwindcss-patch": "dev/bin.ts"
|
|
@@ -105,7 +105,7 @@ var package_default = {
|
|
|
105
105
|
"@babel/traverse": "^7.29.0",
|
|
106
106
|
"@babel/types": "^7.29.0",
|
|
107
107
|
"@tailwindcss-mangle/config": "workspace:*",
|
|
108
|
-
"@tailwindcss/node": "^4.2.
|
|
108
|
+
"@tailwindcss/node": "^4.2.1",
|
|
109
109
|
cac: "^6.7.14",
|
|
110
110
|
consola: "^3.4.2",
|
|
111
111
|
"fs-extra": "^11.3.3",
|
|
@@ -116,9 +116,9 @@ var package_default = {
|
|
|
116
116
|
"tailwindcss-config": "^1.1.4"
|
|
117
117
|
},
|
|
118
118
|
devDependencies: {
|
|
119
|
-
"@tailwindcss/oxide": "^4.2.
|
|
120
|
-
"@tailwindcss/postcss": "^4.2.
|
|
121
|
-
"@tailwindcss/vite": "^4.2.
|
|
119
|
+
"@tailwindcss/oxide": "^4.2.1",
|
|
120
|
+
"@tailwindcss/postcss": "^4.2.1",
|
|
121
|
+
"@tailwindcss/vite": "^4.2.1",
|
|
122
122
|
tailwindcss: "catalog:tailwindcss4",
|
|
123
123
|
"tailwindcss-3": "catalog:tailwindcss3",
|
|
124
124
|
"tailwindcss-4": "catalog:tailwindcss4"
|
|
@@ -1511,226 +1511,6 @@ ${Date.now()}`, { flag: "wx" });
|
|
|
1511
1511
|
}
|
|
1512
1512
|
}, _class);
|
|
1513
1513
|
|
|
1514
|
-
// src/extraction/candidate-extractor.ts
|
|
1515
|
-
var _fs = require('fs');
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
async function importNode() {
|
|
1519
|
-
return Promise.resolve().then(() => _interopRequireWildcard(require("@tailwindcss/node")));
|
|
1520
|
-
}
|
|
1521
|
-
async function importOxide() {
|
|
1522
|
-
return Promise.resolve().then(() => _interopRequireWildcard(require("@tailwindcss/oxide")));
|
|
1523
|
-
}
|
|
1524
|
-
async function loadDesignSystem(css, bases) {
|
|
1525
|
-
const uniqueBases = Array.from(new Set(bases.filter(Boolean)));
|
|
1526
|
-
if (uniqueBases.length === 0) {
|
|
1527
|
-
throw new Error("No base directories provided for Tailwind CSS design system.");
|
|
1528
|
-
}
|
|
1529
|
-
const { __unstable__loadDesignSystem } = await importNode();
|
|
1530
|
-
let lastError;
|
|
1531
|
-
for (const base of uniqueBases) {
|
|
1532
|
-
try {
|
|
1533
|
-
return await __unstable__loadDesignSystem(css, { base });
|
|
1534
|
-
} catch (error) {
|
|
1535
|
-
lastError = error;
|
|
1536
|
-
}
|
|
1537
|
-
}
|
|
1538
|
-
if (lastError instanceof Error) {
|
|
1539
|
-
throw lastError;
|
|
1540
|
-
}
|
|
1541
|
-
throw new Error("Failed to load Tailwind CSS design system.");
|
|
1542
|
-
}
|
|
1543
|
-
async function extractRawCandidatesWithPositions(content, extension = "html") {
|
|
1544
|
-
const { Scanner } = await importOxide();
|
|
1545
|
-
const scanner = new Scanner({});
|
|
1546
|
-
const result = scanner.getCandidatesWithPositions({ content, extension });
|
|
1547
|
-
return result.map(({ candidate, position }) => ({
|
|
1548
|
-
rawCandidate: candidate,
|
|
1549
|
-
start: position,
|
|
1550
|
-
end: position + candidate.length
|
|
1551
|
-
}));
|
|
1552
|
-
}
|
|
1553
|
-
async function extractRawCandidates(sources) {
|
|
1554
|
-
const { Scanner } = await importOxide();
|
|
1555
|
-
const scanner = new Scanner(sources === void 0 ? {} : { sources });
|
|
1556
|
-
return scanner.scan();
|
|
1557
|
-
}
|
|
1558
|
-
async function extractValidCandidates(options) {
|
|
1559
|
-
const providedOptions = _nullishCoalesce(options, () => ( {}));
|
|
1560
|
-
const defaultCwd = _nullishCoalesce(providedOptions.cwd, () => ( _process2.default.cwd()));
|
|
1561
|
-
const base = _nullishCoalesce(providedOptions.base, () => ( defaultCwd));
|
|
1562
|
-
const baseFallbacks = _nullishCoalesce(providedOptions.baseFallbacks, () => ( []));
|
|
1563
|
-
const css = _nullishCoalesce(providedOptions.css, () => ( '@import "tailwindcss";'));
|
|
1564
|
-
const sources = (_nullishCoalesce(providedOptions.sources, () => ( [
|
|
1565
|
-
{
|
|
1566
|
-
base: defaultCwd,
|
|
1567
|
-
pattern: "**/*",
|
|
1568
|
-
negated: false
|
|
1569
|
-
}
|
|
1570
|
-
]))).map((source) => ({
|
|
1571
|
-
base: _nullishCoalesce(source.base, () => ( defaultCwd)),
|
|
1572
|
-
pattern: source.pattern,
|
|
1573
|
-
negated: source.negated
|
|
1574
|
-
}));
|
|
1575
|
-
const designSystem = await loadDesignSystem(css, [base, ...baseFallbacks]);
|
|
1576
|
-
const candidates = await extractRawCandidates(sources);
|
|
1577
|
-
const parsedCandidates = candidates.filter(
|
|
1578
|
-
(rawCandidate) => designSystem.parseCandidate(rawCandidate).length > 0
|
|
1579
|
-
);
|
|
1580
|
-
if (parsedCandidates.length === 0) {
|
|
1581
|
-
return parsedCandidates;
|
|
1582
|
-
}
|
|
1583
|
-
const cssByCandidate = designSystem.candidatesToCss(parsedCandidates);
|
|
1584
|
-
const validCandidates = [];
|
|
1585
|
-
for (let index = 0; index < parsedCandidates.length; index++) {
|
|
1586
|
-
const candidate = parsedCandidates[index];
|
|
1587
|
-
if (candidate === void 0) {
|
|
1588
|
-
continue;
|
|
1589
|
-
}
|
|
1590
|
-
const css2 = cssByCandidate[index];
|
|
1591
|
-
if (typeof css2 === "string" && css2.trim().length > 0) {
|
|
1592
|
-
validCandidates.push(candidate);
|
|
1593
|
-
}
|
|
1594
|
-
}
|
|
1595
|
-
return validCandidates;
|
|
1596
|
-
}
|
|
1597
|
-
function normalizeSources(sources, cwd) {
|
|
1598
|
-
const baseSources = _optionalChain([sources, 'optionalAccess', _23 => _23.length]) ? sources : [
|
|
1599
|
-
{
|
|
1600
|
-
base: cwd,
|
|
1601
|
-
pattern: "**/*",
|
|
1602
|
-
negated: false
|
|
1603
|
-
}
|
|
1604
|
-
];
|
|
1605
|
-
return baseSources.map((source) => ({
|
|
1606
|
-
base: _nullishCoalesce(source.base, () => ( cwd)),
|
|
1607
|
-
pattern: source.pattern,
|
|
1608
|
-
negated: source.negated
|
|
1609
|
-
}));
|
|
1610
|
-
}
|
|
1611
|
-
function buildLineOffsets(content) {
|
|
1612
|
-
const offsets = [0];
|
|
1613
|
-
for (let i = 0; i < content.length; i++) {
|
|
1614
|
-
if (content[i] === "\n") {
|
|
1615
|
-
offsets.push(i + 1);
|
|
1616
|
-
}
|
|
1617
|
-
}
|
|
1618
|
-
if (offsets[offsets.length - 1] !== content.length) {
|
|
1619
|
-
offsets.push(content.length);
|
|
1620
|
-
}
|
|
1621
|
-
return offsets;
|
|
1622
|
-
}
|
|
1623
|
-
function resolveLineMeta(content, offsets, index) {
|
|
1624
|
-
let low = 0;
|
|
1625
|
-
let high = offsets.length - 1;
|
|
1626
|
-
while (low <= high) {
|
|
1627
|
-
const mid = Math.floor((low + high) / 2);
|
|
1628
|
-
const start = offsets[mid];
|
|
1629
|
-
if (start === void 0) {
|
|
1630
|
-
break;
|
|
1631
|
-
}
|
|
1632
|
-
const nextStart = _nullishCoalesce(offsets[mid + 1], () => ( content.length));
|
|
1633
|
-
if (index < start) {
|
|
1634
|
-
high = mid - 1;
|
|
1635
|
-
continue;
|
|
1636
|
-
}
|
|
1637
|
-
if (index >= nextStart) {
|
|
1638
|
-
low = mid + 1;
|
|
1639
|
-
continue;
|
|
1640
|
-
}
|
|
1641
|
-
const line = mid + 1;
|
|
1642
|
-
const column = index - start + 1;
|
|
1643
|
-
const lineEnd = content.indexOf("\n", start);
|
|
1644
|
-
const lineText = content.slice(start, lineEnd === -1 ? content.length : lineEnd);
|
|
1645
|
-
return { line, column, lineText };
|
|
1646
|
-
}
|
|
1647
|
-
const lastStart = _nullishCoalesce(offsets[offsets.length - 2], () => ( 0));
|
|
1648
|
-
return {
|
|
1649
|
-
line: offsets.length - 1,
|
|
1650
|
-
column: index - lastStart + 1,
|
|
1651
|
-
lineText: content.slice(lastStart)
|
|
1652
|
-
};
|
|
1653
|
-
}
|
|
1654
|
-
function toExtension(filename) {
|
|
1655
|
-
const ext = _pathe2.default.extname(filename).replace(/^\./, "");
|
|
1656
|
-
return ext || "txt";
|
|
1657
|
-
}
|
|
1658
|
-
function toRelativeFile(cwd, filename) {
|
|
1659
|
-
const relative = _pathe2.default.relative(cwd, filename);
|
|
1660
|
-
return relative === "" ? _pathe2.default.basename(filename) : relative;
|
|
1661
|
-
}
|
|
1662
|
-
async function extractProjectCandidatesWithPositions(options) {
|
|
1663
|
-
const cwd = _optionalChain([options, 'optionalAccess', _24 => _24.cwd]) ? _pathe2.default.resolve(options.cwd) : _process2.default.cwd();
|
|
1664
|
-
const normalizedSources = normalizeSources(_optionalChain([options, 'optionalAccess', _25 => _25.sources]), cwd);
|
|
1665
|
-
const { Scanner } = await importOxide();
|
|
1666
|
-
const scanner = new Scanner({
|
|
1667
|
-
sources: normalizedSources
|
|
1668
|
-
});
|
|
1669
|
-
const files = _nullishCoalesce(scanner.files, () => ( []));
|
|
1670
|
-
const entries = [];
|
|
1671
|
-
const skipped = [];
|
|
1672
|
-
for (const file of files) {
|
|
1673
|
-
let content;
|
|
1674
|
-
try {
|
|
1675
|
-
content = await _fs.promises.readFile(file, "utf8");
|
|
1676
|
-
} catch (error) {
|
|
1677
|
-
skipped.push({
|
|
1678
|
-
file,
|
|
1679
|
-
reason: error instanceof Error ? error.message : "Unknown error"
|
|
1680
|
-
});
|
|
1681
|
-
continue;
|
|
1682
|
-
}
|
|
1683
|
-
const extension = toExtension(file);
|
|
1684
|
-
const matches = scanner.getCandidatesWithPositions({
|
|
1685
|
-
file,
|
|
1686
|
-
content,
|
|
1687
|
-
extension
|
|
1688
|
-
});
|
|
1689
|
-
if (!matches.length) {
|
|
1690
|
-
continue;
|
|
1691
|
-
}
|
|
1692
|
-
const offsets = buildLineOffsets(content);
|
|
1693
|
-
const relativeFile = toRelativeFile(cwd, file);
|
|
1694
|
-
for (const match of matches) {
|
|
1695
|
-
const info = resolveLineMeta(content, offsets, match.position);
|
|
1696
|
-
entries.push({
|
|
1697
|
-
rawCandidate: match.candidate,
|
|
1698
|
-
file,
|
|
1699
|
-
relativeFile,
|
|
1700
|
-
extension,
|
|
1701
|
-
start: match.position,
|
|
1702
|
-
end: match.position + match.candidate.length,
|
|
1703
|
-
length: match.candidate.length,
|
|
1704
|
-
line: info.line,
|
|
1705
|
-
column: info.column,
|
|
1706
|
-
lineText: info.lineText
|
|
1707
|
-
});
|
|
1708
|
-
}
|
|
1709
|
-
}
|
|
1710
|
-
return {
|
|
1711
|
-
entries,
|
|
1712
|
-
filesScanned: files.length,
|
|
1713
|
-
skippedFiles: skipped,
|
|
1714
|
-
sources: normalizedSources
|
|
1715
|
-
};
|
|
1716
|
-
}
|
|
1717
|
-
function groupTokensByFile(report, options) {
|
|
1718
|
-
const key = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _26 => _26.key]), () => ( "relative"));
|
|
1719
|
-
const stripAbsolute = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _27 => _27.stripAbsolutePaths]), () => ( key !== "absolute"));
|
|
1720
|
-
return report.entries.reduce((acc, entry) => {
|
|
1721
|
-
const bucketKey = key === "absolute" ? entry.file : entry.relativeFile;
|
|
1722
|
-
if (!acc[bucketKey]) {
|
|
1723
|
-
acc[bucketKey] = [];
|
|
1724
|
-
}
|
|
1725
|
-
const value = stripAbsolute ? {
|
|
1726
|
-
...entry,
|
|
1727
|
-
file: entry.relativeFile
|
|
1728
|
-
} : entry;
|
|
1729
|
-
acc[bucketKey].push(value);
|
|
1730
|
-
return acc;
|
|
1731
|
-
}, {});
|
|
1732
|
-
}
|
|
1733
|
-
|
|
1734
1514
|
// src/options/normalize.ts
|
|
1735
1515
|
|
|
1736
1516
|
|
|
@@ -1795,11 +1575,11 @@ function normalizeCacheOptions(cache, projectRoot) {
|
|
|
1795
1575
|
};
|
|
1796
1576
|
}
|
|
1797
1577
|
function normalizeOutputOptions(output) {
|
|
1798
|
-
const enabled = _nullishCoalesce(_optionalChain([output, 'optionalAccess',
|
|
1799
|
-
const file = _nullishCoalesce(_optionalChain([output, 'optionalAccess',
|
|
1800
|
-
const format = _nullishCoalesce(_optionalChain([output, 'optionalAccess',
|
|
1801
|
-
const pretty = toPrettyValue(_nullishCoalesce(_optionalChain([output, 'optionalAccess',
|
|
1802
|
-
const removeUniversalSelector = _nullishCoalesce(_optionalChain([output, 'optionalAccess',
|
|
1578
|
+
const enabled = _nullishCoalesce(_optionalChain([output, 'optionalAccess', _23 => _23.write]), () => ( true));
|
|
1579
|
+
const file = _nullishCoalesce(_optionalChain([output, 'optionalAccess', _24 => _24.file]), () => ( ".tw-patch/tw-class-list.json"));
|
|
1580
|
+
const format = _nullishCoalesce(_optionalChain([output, 'optionalAccess', _25 => _25.format]), () => ( "json"));
|
|
1581
|
+
const pretty = toPrettyValue(_nullishCoalesce(_optionalChain([output, 'optionalAccess', _26 => _26.pretty]), () => ( true)));
|
|
1582
|
+
const removeUniversalSelector = _nullishCoalesce(_optionalChain([output, 'optionalAccess', _27 => _27.removeUniversalSelector]), () => ( true));
|
|
1803
1583
|
return {
|
|
1804
1584
|
enabled,
|
|
1805
1585
|
file,
|
|
@@ -1846,11 +1626,11 @@ function normalizeExtendLengthUnitsOptions(extend) {
|
|
|
1846
1626
|
};
|
|
1847
1627
|
}
|
|
1848
1628
|
function normalizeTailwindV4Options(v4, fallbackBase) {
|
|
1849
|
-
const configuredBase = _optionalChain([v4, 'optionalAccess',
|
|
1629
|
+
const configuredBase = _optionalChain([v4, 'optionalAccess', _28 => _28.base]) ? _pathe2.default.resolve(v4.base) : void 0;
|
|
1850
1630
|
const base = _nullishCoalesce(configuredBase, () => ( fallbackBase));
|
|
1851
|
-
const cssEntries = Array.isArray(_optionalChain([v4, 'optionalAccess',
|
|
1852
|
-
const userSources = _optionalChain([v4, 'optionalAccess',
|
|
1853
|
-
const hasUserDefinedSources = Boolean(_optionalChain([userSources, 'optionalAccess',
|
|
1631
|
+
const cssEntries = Array.isArray(_optionalChain([v4, 'optionalAccess', _29 => _29.cssEntries])) ? v4.cssEntries.filter((entry) => Boolean(entry)).map((entry) => _pathe2.default.resolve(entry)) : [];
|
|
1632
|
+
const userSources = _optionalChain([v4, 'optionalAccess', _30 => _30.sources]);
|
|
1633
|
+
const hasUserDefinedSources = Boolean(_optionalChain([userSources, 'optionalAccess', _31 => _31.length]));
|
|
1854
1634
|
const sources = hasUserDefinedSources ? userSources : [
|
|
1855
1635
|
{
|
|
1856
1636
|
base: fallbackBase,
|
|
@@ -1861,20 +1641,20 @@ function normalizeTailwindV4Options(v4, fallbackBase) {
|
|
|
1861
1641
|
return {
|
|
1862
1642
|
base,
|
|
1863
1643
|
...configuredBase === void 0 ? {} : { configuredBase },
|
|
1864
|
-
..._optionalChain([v4, 'optionalAccess',
|
|
1644
|
+
..._optionalChain([v4, 'optionalAccess', _32 => _32.css]) === void 0 ? {} : { css: v4.css },
|
|
1865
1645
|
cssEntries,
|
|
1866
1646
|
sources,
|
|
1867
1647
|
hasUserDefinedSources
|
|
1868
1648
|
};
|
|
1869
1649
|
}
|
|
1870
1650
|
function normalizeTailwindOptions(tailwind, projectRoot) {
|
|
1871
|
-
const packageName = _nullishCoalesce(_optionalChain([tailwind, 'optionalAccess',
|
|
1872
|
-
const versionHint = _optionalChain([tailwind, 'optionalAccess',
|
|
1873
|
-
const resolve = _optionalChain([tailwind, 'optionalAccess',
|
|
1874
|
-
const cwd = _nullishCoalesce(_optionalChain([tailwind, 'optionalAccess',
|
|
1875
|
-
const config = _optionalChain([tailwind, 'optionalAccess',
|
|
1876
|
-
const postcssPlugin = _optionalChain([tailwind, 'optionalAccess',
|
|
1877
|
-
const v4 = normalizeTailwindV4Options(_optionalChain([tailwind, 'optionalAccess',
|
|
1651
|
+
const packageName = _nullishCoalesce(_optionalChain([tailwind, 'optionalAccess', _33 => _33.packageName]), () => ( "tailwindcss"));
|
|
1652
|
+
const versionHint = _optionalChain([tailwind, 'optionalAccess', _34 => _34.version]);
|
|
1653
|
+
const resolve = _optionalChain([tailwind, 'optionalAccess', _35 => _35.resolve]);
|
|
1654
|
+
const cwd = _nullishCoalesce(_optionalChain([tailwind, 'optionalAccess', _36 => _36.cwd]), () => ( projectRoot));
|
|
1655
|
+
const config = _optionalChain([tailwind, 'optionalAccess', _37 => _37.config]);
|
|
1656
|
+
const postcssPlugin = _optionalChain([tailwind, 'optionalAccess', _38 => _38.postcssPlugin]);
|
|
1657
|
+
const v4 = normalizeTailwindV4Options(_optionalChain([tailwind, 'optionalAccess', _39 => _39.v4]), cwd);
|
|
1878
1658
|
return {
|
|
1879
1659
|
packageName,
|
|
1880
1660
|
cwd,
|
|
@@ -1882,22 +1662,22 @@ function normalizeTailwindOptions(tailwind, projectRoot) {
|
|
|
1882
1662
|
...resolve === void 0 ? {} : { resolve },
|
|
1883
1663
|
...config === void 0 ? {} : { config },
|
|
1884
1664
|
...postcssPlugin === void 0 ? {} : { postcssPlugin },
|
|
1885
|
-
..._optionalChain([tailwind, 'optionalAccess',
|
|
1886
|
-
..._optionalChain([tailwind, 'optionalAccess',
|
|
1665
|
+
..._optionalChain([tailwind, 'optionalAccess', _40 => _40.v2]) === void 0 ? {} : { v2: tailwind.v2 },
|
|
1666
|
+
..._optionalChain([tailwind, 'optionalAccess', _41 => _41.v3]) === void 0 ? {} : { v3: tailwind.v3 },
|
|
1887
1667
|
v4
|
|
1888
1668
|
};
|
|
1889
1669
|
}
|
|
1890
1670
|
function resolveOptionSlices(options) {
|
|
1891
1671
|
const projectRoot = _nullishCoalesce(options.projectRoot, () => ( options.cwd));
|
|
1892
|
-
const overwrite = _nullishCoalesce(_optionalChain([options, 'access',
|
|
1672
|
+
const overwrite = _nullishCoalesce(_optionalChain([options, 'access', _42 => _42.apply, 'optionalAccess', _43 => _43.overwrite]), () => ( options.overwrite));
|
|
1893
1673
|
const tailwind = _nullishCoalesce(options.tailwindcss, () => ( options.tailwind));
|
|
1894
|
-
const exposeContext = _optionalChain([options, 'access',
|
|
1895
|
-
const extendLengthUnits = _optionalChain([options, 'access',
|
|
1896
|
-
const write = _nullishCoalesce(_optionalChain([options, 'access',
|
|
1897
|
-
const file = _nullishCoalesce(_optionalChain([options, 'access',
|
|
1898
|
-
const format = _nullishCoalesce(_optionalChain([options, 'access',
|
|
1899
|
-
const pretty = _nullishCoalesce(_optionalChain([options, 'access',
|
|
1900
|
-
const removeUniversalSelector = _nullishCoalesce(_optionalChain([options, 'access',
|
|
1674
|
+
const exposeContext = _optionalChain([options, 'access', _44 => _44.apply, 'optionalAccess', _45 => _45.exposeContext]) !== void 0 ? options.apply.exposeContext : _optionalChain([options, 'access', _46 => _46.features, 'optionalAccess', _47 => _47.exposeContext]);
|
|
1675
|
+
const extendLengthUnits = _optionalChain([options, 'access', _48 => _48.apply, 'optionalAccess', _49 => _49.extendLengthUnits]) !== void 0 ? options.apply.extendLengthUnits : _optionalChain([options, 'access', _50 => _50.features, 'optionalAccess', _51 => _51.extendLengthUnits]);
|
|
1676
|
+
const write = _nullishCoalesce(_optionalChain([options, 'access', _52 => _52.extract, 'optionalAccess', _53 => _53.write]), () => ( _optionalChain([options, 'access', _54 => _54.output, 'optionalAccess', _55 => _55.enabled])));
|
|
1677
|
+
const file = _nullishCoalesce(_optionalChain([options, 'access', _56 => _56.extract, 'optionalAccess', _57 => _57.file]), () => ( _optionalChain([options, 'access', _58 => _58.output, 'optionalAccess', _59 => _59.file])));
|
|
1678
|
+
const format = _nullishCoalesce(_optionalChain([options, 'access', _60 => _60.extract, 'optionalAccess', _61 => _61.format]), () => ( _optionalChain([options, 'access', _62 => _62.output, 'optionalAccess', _63 => _63.format])));
|
|
1679
|
+
const pretty = _nullishCoalesce(_optionalChain([options, 'access', _64 => _64.extract, 'optionalAccess', _65 => _65.pretty]), () => ( _optionalChain([options, 'access', _66 => _66.output, 'optionalAccess', _67 => _67.pretty])));
|
|
1680
|
+
const removeUniversalSelector = _nullishCoalesce(_optionalChain([options, 'access', _68 => _68.extract, 'optionalAccess', _69 => _69.removeUniversalSelector]), () => ( _optionalChain([options, 'access', _70 => _70.output, 'optionalAccess', _71 => _71.removeUniversalSelector])));
|
|
1901
1681
|
const extract = {
|
|
1902
1682
|
...write === void 0 ? {} : { write },
|
|
1903
1683
|
...file === void 0 ? {} : { file },
|
|
@@ -1970,27 +1750,625 @@ function normalizeOptions(options = {}) {
|
|
|
1970
1750
|
};
|
|
1971
1751
|
}
|
|
1972
1752
|
|
|
1973
|
-
// src/
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1753
|
+
// src/options/legacy.ts
|
|
1754
|
+
function normalizeLegacyFeatures(patch) {
|
|
1755
|
+
const apply = _optionalChain([patch, 'optionalAccess', _72 => _72.applyPatches]);
|
|
1756
|
+
const extend = _optionalChain([apply, 'optionalAccess', _73 => _73.extendLengthUnits]);
|
|
1757
|
+
let extendOption = false;
|
|
1758
|
+
if (extend && typeof extend === "object") {
|
|
1759
|
+
extendOption = {
|
|
1760
|
+
...extend,
|
|
1761
|
+
enabled: true
|
|
1762
|
+
};
|
|
1763
|
+
} else if (extend === true) {
|
|
1764
|
+
extendOption = {
|
|
1765
|
+
enabled: true,
|
|
1766
|
+
units: ["rpx"],
|
|
1767
|
+
..._optionalChain([patch, 'optionalAccess', _74 => _74.overwrite]) === void 0 ? {} : { overwrite: patch.overwrite }
|
|
1768
|
+
};
|
|
1769
|
+
}
|
|
1770
|
+
return {
|
|
1771
|
+
exposeContext: _nullishCoalesce(_optionalChain([apply, 'optionalAccess', _75 => _75.exportContext]), () => ( true)),
|
|
1772
|
+
extendLengthUnits: extendOption
|
|
1773
|
+
};
|
|
1984
1774
|
}
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1775
|
+
function fromLegacyOptions(options) {
|
|
1776
|
+
if (!options) {
|
|
1777
|
+
return {};
|
|
1778
|
+
}
|
|
1779
|
+
const patch = options.patch;
|
|
1780
|
+
const features = normalizeLegacyFeatures(patch);
|
|
1781
|
+
const output = _optionalChain([patch, 'optionalAccess', _76 => _76.output]);
|
|
1782
|
+
const tailwindConfig = _optionalChain([patch, 'optionalAccess', _77 => _77.tailwindcss]);
|
|
1783
|
+
const tailwindVersion = _optionalChain([tailwindConfig, 'optionalAccess', _78 => _78.version]);
|
|
1784
|
+
const tailwindV2 = _optionalChain([tailwindConfig, 'optionalAccess', _79 => _79.v2]);
|
|
1785
|
+
const tailwindV3 = _optionalChain([tailwindConfig, 'optionalAccess', _80 => _80.v3]);
|
|
1786
|
+
const tailwindV4 = _optionalChain([tailwindConfig, 'optionalAccess', _81 => _81.v4]);
|
|
1787
|
+
const tailwindConfigPath = _nullishCoalesce(_optionalChain([tailwindV3, 'optionalAccess', _82 => _82.config]), () => ( _optionalChain([tailwindV2, 'optionalAccess', _83 => _83.config])));
|
|
1788
|
+
const tailwindCwd = _nullishCoalesce(_nullishCoalesce(_optionalChain([tailwindV3, 'optionalAccess', _84 => _84.cwd]), () => ( _optionalChain([tailwindV2, 'optionalAccess', _85 => _85.cwd]))), () => ( _optionalChain([patch, 'optionalAccess', _86 => _86.cwd])));
|
|
1789
|
+
const normalizedExtract = output ? {
|
|
1790
|
+
...output.filename === void 0 ? {} : { file: output.filename },
|
|
1791
|
+
pretty: output.loose ? 2 : false,
|
|
1792
|
+
...output.removeUniversalSelector === void 0 ? {} : { removeUniversalSelector: output.removeUniversalSelector }
|
|
1793
|
+
} : void 0;
|
|
1794
|
+
const normalizedTailwindcss = {
|
|
1795
|
+
..._optionalChain([patch, 'optionalAccess', _87 => _87.packageName]) === void 0 ? {} : { packageName: patch.packageName },
|
|
1796
|
+
...tailwindVersion === void 0 ? {} : { version: tailwindVersion },
|
|
1797
|
+
..._optionalChain([patch, 'optionalAccess', _88 => _88.resolve]) === void 0 ? {} : { resolve: patch.resolve },
|
|
1798
|
+
...tailwindConfigPath === void 0 ? {} : { config: tailwindConfigPath },
|
|
1799
|
+
...tailwindCwd === void 0 ? {} : { cwd: tailwindCwd },
|
|
1800
|
+
...tailwindV2 === void 0 ? {} : { v2: tailwindV2 },
|
|
1801
|
+
...tailwindV3 === void 0 ? {} : { v3: tailwindV3 },
|
|
1802
|
+
...tailwindV4 === void 0 ? {} : { v4: tailwindV4 }
|
|
1803
|
+
};
|
|
1804
|
+
const normalizedCache = typeof options.cache === "boolean" ? options.cache : options.cache ? {
|
|
1805
|
+
...options.cache,
|
|
1806
|
+
enabled: _nullishCoalesce(options.cache.enabled, () => ( true))
|
|
1807
|
+
} : void 0;
|
|
1808
|
+
const normalizedApply = {
|
|
1809
|
+
..._optionalChain([patch, 'optionalAccess', _89 => _89.overwrite]) === void 0 ? {} : { overwrite: patch.overwrite },
|
|
1810
|
+
exposeContext: features.exposeContext,
|
|
1811
|
+
extendLengthUnits: features.extendLengthUnits
|
|
1812
|
+
};
|
|
1813
|
+
return {
|
|
1814
|
+
..._optionalChain([patch, 'optionalAccess', _90 => _90.cwd]) === void 0 ? {} : { projectRoot: patch.cwd },
|
|
1815
|
+
..._optionalChain([patch, 'optionalAccess', _91 => _91.filter]) === void 0 ? {} : { filter: patch.filter },
|
|
1816
|
+
...normalizedCache === void 0 ? {} : { cache: normalizedCache },
|
|
1817
|
+
...normalizedExtract === void 0 ? {} : { extract: normalizedExtract },
|
|
1818
|
+
...Object.keys(normalizedTailwindcss).length === 0 ? {} : { tailwindcss: normalizedTailwindcss },
|
|
1819
|
+
apply: normalizedApply
|
|
1820
|
+
};
|
|
1821
|
+
}
|
|
1822
|
+
function fromUnifiedConfig(registry) {
|
|
1823
|
+
if (!registry) {
|
|
1824
|
+
return {};
|
|
1825
|
+
}
|
|
1826
|
+
const tailwind = _nullishCoalesce(registry.tailwindcss, () => ( registry.tailwind));
|
|
1827
|
+
const modernExtract = registry.extract;
|
|
1828
|
+
const legacyOutput = registry.output;
|
|
1829
|
+
const pretty = (() => {
|
|
1830
|
+
const value = _nullishCoalesce(_optionalChain([modernExtract, 'optionalAccess', _92 => _92.pretty]), () => ( _optionalChain([legacyOutput, 'optionalAccess', _93 => _93.pretty])));
|
|
1831
|
+
if (value === void 0) {
|
|
1832
|
+
return void 0;
|
|
1833
|
+
}
|
|
1834
|
+
if (typeof value === "boolean") {
|
|
1835
|
+
return value ? 2 : false;
|
|
1836
|
+
}
|
|
1837
|
+
return value;
|
|
1838
|
+
})();
|
|
1839
|
+
const removeUniversalSelector = _nullishCoalesce(_optionalChain([modernExtract, 'optionalAccess', _94 => _94.removeUniversalSelector]), () => ( _optionalChain([legacyOutput, 'optionalAccess', _95 => _95.stripUniversalSelector])));
|
|
1840
|
+
const outputFile = _nullishCoalesce(_optionalChain([modernExtract, 'optionalAccess', _96 => _96.file]), () => ( _optionalChain([legacyOutput, 'optionalAccess', _97 => _97.file])));
|
|
1841
|
+
const normalizedExtract = modernExtract || legacyOutput ? {
|
|
1842
|
+
..._optionalChain([modernExtract, 'optionalAccess', _98 => _98.write]) === void 0 ? {} : { write: modernExtract.write },
|
|
1843
|
+
...outputFile === void 0 ? {} : { file: outputFile },
|
|
1844
|
+
...pretty === void 0 ? {} : { pretty },
|
|
1845
|
+
...removeUniversalSelector === void 0 ? {} : { removeUniversalSelector },
|
|
1846
|
+
..._optionalChain([modernExtract, 'optionalAccess', _99 => _99.format]) === void 0 ? {} : { format: modernExtract.format }
|
|
1847
|
+
} : void 0;
|
|
1848
|
+
const normalizedTailwindcss = tailwind ? {
|
|
1849
|
+
...tailwind.version === void 0 ? {} : { version: tailwind.version },
|
|
1850
|
+
...tailwind.packageName === void 0 ? tailwind.package === void 0 ? {} : { packageName: tailwind.package } : { packageName: tailwind.packageName },
|
|
1851
|
+
...tailwind.resolve === void 0 ? {} : { resolve: tailwind.resolve },
|
|
1852
|
+
...tailwind.config === void 0 ? {} : { config: tailwind.config },
|
|
1853
|
+
...tailwind.cwd === void 0 ? {} : { cwd: tailwind.cwd },
|
|
1854
|
+
...tailwind.v2 === void 0 ? tailwind.legacy === void 0 ? {} : { v2: tailwind.legacy } : { v2: tailwind.v2 },
|
|
1855
|
+
...tailwind.v3 === void 0 ? tailwind.classic === void 0 ? {} : { v3: tailwind.classic } : { v3: tailwind.v3 },
|
|
1856
|
+
...tailwind.v4 === void 0 ? tailwind.next === void 0 ? {} : { v4: tailwind.next } : { v4: tailwind.v4 }
|
|
1857
|
+
} : void 0;
|
|
1858
|
+
const normalizedApply = registry.apply ? {
|
|
1859
|
+
...registry.apply.overwrite === void 0 ? {} : { overwrite: registry.apply.overwrite },
|
|
1860
|
+
...registry.apply.exposeContext === void 0 ? {} : { exposeContext: registry.apply.exposeContext },
|
|
1861
|
+
...registry.apply.extendLengthUnits === void 0 ? {} : { extendLengthUnits: registry.apply.extendLengthUnits }
|
|
1862
|
+
} : void 0;
|
|
1863
|
+
return {
|
|
1864
|
+
...registry.projectRoot === void 0 ? {} : { projectRoot: registry.projectRoot },
|
|
1865
|
+
...normalizedApply === void 0 ? {} : { apply: normalizedApply },
|
|
1866
|
+
...registry.cache === void 0 ? {} : { cache: registry.cache },
|
|
1867
|
+
...registry.filter === void 0 ? {} : { filter: registry.filter },
|
|
1868
|
+
...normalizedExtract === void 0 ? {} : { extract: normalizedExtract },
|
|
1869
|
+
...normalizedTailwindcss === void 0 ? {} : { tailwindcss: normalizedTailwindcss }
|
|
1870
|
+
};
|
|
1871
|
+
}
|
|
1872
|
+
|
|
1873
|
+
// src/config/workspace.ts
|
|
1874
|
+
var _url = require('url');
|
|
1875
|
+
|
|
1876
|
+
var configModulePromise;
|
|
1877
|
+
var defuPromise;
|
|
1878
|
+
function isNodeError(error) {
|
|
1879
|
+
return !!error && typeof error === "object" && ("code" in error || "message" in error);
|
|
1880
|
+
}
|
|
1881
|
+
function isMissingConfigModuleError(error) {
|
|
1882
|
+
if (!isNodeError(error) || error.code !== "MODULE_NOT_FOUND") {
|
|
1883
|
+
return false;
|
|
1884
|
+
}
|
|
1885
|
+
const message = _nullishCoalesce(error.message, () => ( ""));
|
|
1886
|
+
return message.includes("@tailwindcss-mangle/config");
|
|
1887
|
+
}
|
|
1888
|
+
function isMissingSharedModuleError(error) {
|
|
1889
|
+
if (!isNodeError(error) || error.code !== "MODULE_NOT_FOUND") {
|
|
1890
|
+
return false;
|
|
1891
|
+
}
|
|
1892
|
+
const message = _nullishCoalesce(error.message, () => ( ""));
|
|
1893
|
+
return message.includes("@tailwindcss-mangle/shared");
|
|
1894
|
+
}
|
|
1895
|
+
async function loadWorkspaceConfigModule() {
|
|
1896
|
+
if (!configModulePromise) {
|
|
1897
|
+
configModulePromise = Promise.resolve().then(() => _interopRequireWildcard(require("@tailwindcss-mangle/config"))).catch(async (error) => {
|
|
1898
|
+
if (!isMissingConfigModuleError(error)) {
|
|
1899
|
+
throw error;
|
|
1900
|
+
}
|
|
1901
|
+
const fallback = _pathe2.default.resolve(__dirname, "../../../config/src/index.ts");
|
|
1902
|
+
return Promise.resolve().then(() => _interopRequireWildcard(require(_url.pathToFileURL.call(void 0, fallback).href)));
|
|
1903
|
+
});
|
|
1904
|
+
}
|
|
1905
|
+
return configModulePromise;
|
|
1906
|
+
}
|
|
1907
|
+
async function loadWorkspaceDefu() {
|
|
1908
|
+
if (!defuPromise) {
|
|
1909
|
+
defuPromise = Promise.resolve().then(() => _interopRequireWildcard(require("./dist-NW65QXLC.js"))).then((mod) => mod.defu).catch(async (error) => {
|
|
1910
|
+
if (!isMissingSharedModuleError(error)) {
|
|
1911
|
+
throw error;
|
|
1912
|
+
}
|
|
1913
|
+
const fallback = _pathe2.default.resolve(__dirname, "../../../shared/src/utils.ts");
|
|
1914
|
+
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require(_url.pathToFileURL.call(void 0, fallback).href)));
|
|
1915
|
+
return mod.defu;
|
|
1916
|
+
});
|
|
1917
|
+
}
|
|
1918
|
+
return defuPromise;
|
|
1919
|
+
}
|
|
1920
|
+
async function loadPatchOptionsForWorkspace(cwd, overrides) {
|
|
1921
|
+
const merge = await loadWorkspaceDefu();
|
|
1922
|
+
const configModule = await loadWorkspaceConfigModule();
|
|
1923
|
+
const { config } = await configModule.getConfig(cwd);
|
|
1924
|
+
const legacyConfig = config;
|
|
1925
|
+
const base = _optionalChain([config, 'optionalAccess', _100 => _100.registry]) ? fromUnifiedConfig(config.registry) : _optionalChain([legacyConfig, 'optionalAccess', _101 => _101.patch]) ? fromLegacyOptions({ patch: legacyConfig.patch }) : {};
|
|
1926
|
+
const merged = merge(_nullishCoalesce(overrides, () => ( {})), base);
|
|
1927
|
+
return merged;
|
|
1928
|
+
}
|
|
1929
|
+
|
|
1930
|
+
// src/extraction/candidate-extractor.ts
|
|
1931
|
+
var _fs = require('fs');
|
|
1932
|
+
|
|
1933
|
+
|
|
1934
|
+
async function importNode() {
|
|
1935
|
+
return Promise.resolve().then(() => _interopRequireWildcard(require("@tailwindcss/node")));
|
|
1936
|
+
}
|
|
1937
|
+
async function importOxide() {
|
|
1938
|
+
return Promise.resolve().then(() => _interopRequireWildcard(require("@tailwindcss/oxide")));
|
|
1939
|
+
}
|
|
1940
|
+
async function loadDesignSystem(css, bases) {
|
|
1941
|
+
const uniqueBases = Array.from(new Set(bases.filter(Boolean)));
|
|
1942
|
+
if (uniqueBases.length === 0) {
|
|
1943
|
+
throw new Error("No base directories provided for Tailwind CSS design system.");
|
|
1944
|
+
}
|
|
1945
|
+
const { __unstable__loadDesignSystem } = await importNode();
|
|
1946
|
+
let lastError;
|
|
1947
|
+
for (const base of uniqueBases) {
|
|
1948
|
+
try {
|
|
1949
|
+
return await __unstable__loadDesignSystem(css, { base });
|
|
1950
|
+
} catch (error) {
|
|
1951
|
+
lastError = error;
|
|
1952
|
+
}
|
|
1953
|
+
}
|
|
1954
|
+
if (lastError instanceof Error) {
|
|
1955
|
+
throw lastError;
|
|
1956
|
+
}
|
|
1957
|
+
throw new Error("Failed to load Tailwind CSS design system.");
|
|
1958
|
+
}
|
|
1959
|
+
async function extractRawCandidatesWithPositions(content, extension = "html") {
|
|
1960
|
+
const { Scanner } = await importOxide();
|
|
1961
|
+
const scanner = new Scanner({});
|
|
1962
|
+
const result = scanner.getCandidatesWithPositions({ content, extension });
|
|
1963
|
+
return result.map(({ candidate, position }) => ({
|
|
1964
|
+
rawCandidate: candidate,
|
|
1965
|
+
start: position,
|
|
1966
|
+
end: position + candidate.length
|
|
1967
|
+
}));
|
|
1968
|
+
}
|
|
1969
|
+
async function extractRawCandidates(sources) {
|
|
1970
|
+
const { Scanner } = await importOxide();
|
|
1971
|
+
const scanner = new Scanner(sources === void 0 ? {} : { sources });
|
|
1972
|
+
return scanner.scan();
|
|
1973
|
+
}
|
|
1974
|
+
async function extractValidCandidates(options) {
|
|
1975
|
+
const providedOptions = _nullishCoalesce(options, () => ( {}));
|
|
1976
|
+
const defaultCwd = _nullishCoalesce(providedOptions.cwd, () => ( _process2.default.cwd()));
|
|
1977
|
+
const base = _nullishCoalesce(providedOptions.base, () => ( defaultCwd));
|
|
1978
|
+
const baseFallbacks = _nullishCoalesce(providedOptions.baseFallbacks, () => ( []));
|
|
1979
|
+
const css = _nullishCoalesce(providedOptions.css, () => ( '@import "tailwindcss";'));
|
|
1980
|
+
const sources = (_nullishCoalesce(providedOptions.sources, () => ( [
|
|
1981
|
+
{
|
|
1982
|
+
base: defaultCwd,
|
|
1983
|
+
pattern: "**/*",
|
|
1984
|
+
negated: false
|
|
1985
|
+
}
|
|
1986
|
+
]))).map((source) => ({
|
|
1987
|
+
base: _nullishCoalesce(source.base, () => ( defaultCwd)),
|
|
1988
|
+
pattern: source.pattern,
|
|
1989
|
+
negated: source.negated
|
|
1990
|
+
}));
|
|
1991
|
+
const designSystem = await loadDesignSystem(css, [base, ...baseFallbacks]);
|
|
1992
|
+
const candidates = await extractRawCandidates(sources);
|
|
1993
|
+
const parsedCandidates = candidates.filter(
|
|
1994
|
+
(rawCandidate) => designSystem.parseCandidate(rawCandidate).length > 0
|
|
1995
|
+
);
|
|
1996
|
+
if (parsedCandidates.length === 0) {
|
|
1997
|
+
return parsedCandidates;
|
|
1998
|
+
}
|
|
1999
|
+
const cssByCandidate = designSystem.candidatesToCss(parsedCandidates);
|
|
2000
|
+
const validCandidates = [];
|
|
2001
|
+
for (let index = 0; index < parsedCandidates.length; index++) {
|
|
2002
|
+
const candidate = parsedCandidates[index];
|
|
2003
|
+
if (candidate === void 0) {
|
|
2004
|
+
continue;
|
|
2005
|
+
}
|
|
2006
|
+
const css2 = cssByCandidate[index];
|
|
2007
|
+
if (typeof css2 === "string" && css2.trim().length > 0) {
|
|
2008
|
+
validCandidates.push(candidate);
|
|
2009
|
+
}
|
|
2010
|
+
}
|
|
2011
|
+
return validCandidates;
|
|
2012
|
+
}
|
|
2013
|
+
function normalizeSources(sources, cwd) {
|
|
2014
|
+
const baseSources = _optionalChain([sources, 'optionalAccess', _102 => _102.length]) ? sources : [
|
|
2015
|
+
{
|
|
2016
|
+
base: cwd,
|
|
2017
|
+
pattern: "**/*",
|
|
2018
|
+
negated: false
|
|
2019
|
+
}
|
|
2020
|
+
];
|
|
2021
|
+
return baseSources.map((source) => ({
|
|
2022
|
+
base: _nullishCoalesce(source.base, () => ( cwd)),
|
|
2023
|
+
pattern: source.pattern,
|
|
2024
|
+
negated: source.negated
|
|
2025
|
+
}));
|
|
2026
|
+
}
|
|
2027
|
+
function buildLineOffsets(content) {
|
|
2028
|
+
const offsets = [0];
|
|
2029
|
+
for (let i = 0; i < content.length; i++) {
|
|
2030
|
+
if (content[i] === "\n") {
|
|
2031
|
+
offsets.push(i + 1);
|
|
2032
|
+
}
|
|
2033
|
+
}
|
|
2034
|
+
if (offsets[offsets.length - 1] !== content.length) {
|
|
2035
|
+
offsets.push(content.length);
|
|
2036
|
+
}
|
|
2037
|
+
return offsets;
|
|
2038
|
+
}
|
|
2039
|
+
function resolveLineMeta(content, offsets, index) {
|
|
2040
|
+
let low = 0;
|
|
2041
|
+
let high = offsets.length - 1;
|
|
2042
|
+
while (low <= high) {
|
|
2043
|
+
const mid = Math.floor((low + high) / 2);
|
|
2044
|
+
const start = offsets[mid];
|
|
2045
|
+
if (start === void 0) {
|
|
2046
|
+
break;
|
|
2047
|
+
}
|
|
2048
|
+
const nextStart = _nullishCoalesce(offsets[mid + 1], () => ( content.length));
|
|
2049
|
+
if (index < start) {
|
|
2050
|
+
high = mid - 1;
|
|
2051
|
+
continue;
|
|
2052
|
+
}
|
|
2053
|
+
if (index >= nextStart) {
|
|
2054
|
+
low = mid + 1;
|
|
2055
|
+
continue;
|
|
2056
|
+
}
|
|
2057
|
+
const line = mid + 1;
|
|
2058
|
+
const column = index - start + 1;
|
|
2059
|
+
const lineEnd = content.indexOf("\n", start);
|
|
2060
|
+
const lineText = content.slice(start, lineEnd === -1 ? content.length : lineEnd);
|
|
2061
|
+
return { line, column, lineText };
|
|
2062
|
+
}
|
|
2063
|
+
const lastStart = _nullishCoalesce(offsets[offsets.length - 2], () => ( 0));
|
|
2064
|
+
return {
|
|
2065
|
+
line: offsets.length - 1,
|
|
2066
|
+
column: index - lastStart + 1,
|
|
2067
|
+
lineText: content.slice(lastStart)
|
|
2068
|
+
};
|
|
2069
|
+
}
|
|
2070
|
+
function toExtension(filename) {
|
|
2071
|
+
const ext = _pathe2.default.extname(filename).replace(/^\./, "");
|
|
2072
|
+
return ext || "txt";
|
|
2073
|
+
}
|
|
2074
|
+
function toRelativeFile(cwd, filename) {
|
|
2075
|
+
const relative = _pathe2.default.relative(cwd, filename);
|
|
2076
|
+
return relative === "" ? _pathe2.default.basename(filename) : relative;
|
|
2077
|
+
}
|
|
2078
|
+
async function extractProjectCandidatesWithPositions(options) {
|
|
2079
|
+
const cwd = _optionalChain([options, 'optionalAccess', _103 => _103.cwd]) ? _pathe2.default.resolve(options.cwd) : _process2.default.cwd();
|
|
2080
|
+
const normalizedSources = normalizeSources(_optionalChain([options, 'optionalAccess', _104 => _104.sources]), cwd);
|
|
2081
|
+
const { Scanner } = await importOxide();
|
|
2082
|
+
const scanner = new Scanner({
|
|
2083
|
+
sources: normalizedSources
|
|
2084
|
+
});
|
|
2085
|
+
const files = _nullishCoalesce(scanner.files, () => ( []));
|
|
2086
|
+
const entries = [];
|
|
2087
|
+
const skipped = [];
|
|
2088
|
+
for (const file of files) {
|
|
2089
|
+
let content;
|
|
2090
|
+
try {
|
|
2091
|
+
content = await _fs.promises.readFile(file, "utf8");
|
|
2092
|
+
} catch (error) {
|
|
2093
|
+
skipped.push({
|
|
2094
|
+
file,
|
|
2095
|
+
reason: error instanceof Error ? error.message : "Unknown error"
|
|
2096
|
+
});
|
|
2097
|
+
continue;
|
|
2098
|
+
}
|
|
2099
|
+
const extension = toExtension(file);
|
|
2100
|
+
const matches = scanner.getCandidatesWithPositions({
|
|
2101
|
+
file,
|
|
2102
|
+
content,
|
|
2103
|
+
extension
|
|
2104
|
+
});
|
|
2105
|
+
if (!matches.length) {
|
|
2106
|
+
continue;
|
|
2107
|
+
}
|
|
2108
|
+
const offsets = buildLineOffsets(content);
|
|
2109
|
+
const relativeFile = toRelativeFile(cwd, file);
|
|
2110
|
+
for (const match of matches) {
|
|
2111
|
+
const info = resolveLineMeta(content, offsets, match.position);
|
|
2112
|
+
entries.push({
|
|
2113
|
+
rawCandidate: match.candidate,
|
|
2114
|
+
file,
|
|
2115
|
+
relativeFile,
|
|
2116
|
+
extension,
|
|
2117
|
+
start: match.position,
|
|
2118
|
+
end: match.position + match.candidate.length,
|
|
2119
|
+
length: match.candidate.length,
|
|
2120
|
+
line: info.line,
|
|
2121
|
+
column: info.column,
|
|
2122
|
+
lineText: info.lineText
|
|
2123
|
+
});
|
|
2124
|
+
}
|
|
2125
|
+
}
|
|
2126
|
+
return {
|
|
2127
|
+
entries,
|
|
2128
|
+
filesScanned: files.length,
|
|
2129
|
+
skippedFiles: skipped,
|
|
2130
|
+
sources: normalizedSources
|
|
2131
|
+
};
|
|
2132
|
+
}
|
|
2133
|
+
function groupTokensByFile(report, options) {
|
|
2134
|
+
const key = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _105 => _105.key]), () => ( "relative"));
|
|
2135
|
+
const stripAbsolute = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _106 => _106.stripAbsolutePaths]), () => ( key !== "absolute"));
|
|
2136
|
+
return report.entries.reduce((acc, entry) => {
|
|
2137
|
+
const bucketKey = key === "absolute" ? entry.file : entry.relativeFile;
|
|
2138
|
+
if (!acc[bucketKey]) {
|
|
2139
|
+
acc[bucketKey] = [];
|
|
2140
|
+
}
|
|
2141
|
+
const value = stripAbsolute ? {
|
|
2142
|
+
...entry,
|
|
2143
|
+
file: entry.relativeFile
|
|
2144
|
+
} : entry;
|
|
2145
|
+
acc[bucketKey].push(value);
|
|
2146
|
+
return acc;
|
|
2147
|
+
}, {});
|
|
2148
|
+
}
|
|
2149
|
+
|
|
2150
|
+
// src/runtime/class-collector.ts
|
|
2151
|
+
|
|
2152
|
+
|
|
2153
|
+
|
|
2154
|
+
|
|
2155
|
+
// src/utils.ts
|
|
2156
|
+
function isObject(val) {
|
|
2157
|
+
return val !== null && typeof val === "object" && Array.isArray(val) === false;
|
|
2158
|
+
}
|
|
2159
|
+
function spliceChangesIntoString(str, changes) {
|
|
2160
|
+
if (!changes[0]) {
|
|
2161
|
+
return str;
|
|
2162
|
+
}
|
|
2163
|
+
changes.sort((a, b) => {
|
|
2164
|
+
return a.end - b.end || a.start - b.start;
|
|
2165
|
+
});
|
|
2166
|
+
let result = "";
|
|
2167
|
+
let previous = changes[0];
|
|
2168
|
+
result += str.slice(0, previous.start);
|
|
2169
|
+
result += previous.replacement;
|
|
2170
|
+
for (let i = 1; i < changes.length; ++i) {
|
|
2171
|
+
const change = changes[i];
|
|
2172
|
+
result += str.slice(previous.end, change.start);
|
|
2173
|
+
result += change.replacement;
|
|
2174
|
+
previous = change;
|
|
2175
|
+
}
|
|
2176
|
+
result += str.slice(previous.end);
|
|
2177
|
+
return result;
|
|
2178
|
+
}
|
|
2179
|
+
|
|
2180
|
+
// src/runtime/class-collector.ts
|
|
2181
|
+
function collectClassesFromContexts(contexts, filter) {
|
|
2182
|
+
const set = /* @__PURE__ */ new Set();
|
|
2183
|
+
for (const context of contexts) {
|
|
2184
|
+
if (!isObject(context) || !context.classCache) {
|
|
2185
|
+
continue;
|
|
2186
|
+
}
|
|
2187
|
+
for (const key of context.classCache.keys()) {
|
|
2188
|
+
const className = key.toString();
|
|
2189
|
+
if (filter(className)) {
|
|
2190
|
+
set.add(className);
|
|
2191
|
+
}
|
|
2192
|
+
}
|
|
2193
|
+
}
|
|
2194
|
+
return set;
|
|
2195
|
+
}
|
|
2196
|
+
async function collectClassesFromTailwindV4(options) {
|
|
2197
|
+
const set = /* @__PURE__ */ new Set();
|
|
2198
|
+
const v4Options = options.tailwind.v4;
|
|
2199
|
+
if (!v4Options) {
|
|
2200
|
+
return set;
|
|
2201
|
+
}
|
|
2202
|
+
const toAbsolute = (value) => {
|
|
2203
|
+
if (!value) {
|
|
2204
|
+
return void 0;
|
|
2205
|
+
}
|
|
2206
|
+
return _pathe2.default.isAbsolute(value) ? value : _pathe2.default.resolve(options.projectRoot, value);
|
|
2207
|
+
};
|
|
2208
|
+
const resolvedConfiguredBase = toAbsolute(v4Options.configuredBase);
|
|
2209
|
+
const resolvedDefaultBase = _nullishCoalesce(toAbsolute(v4Options.base), () => ( _process2.default.cwd()));
|
|
2210
|
+
const resolveSources = (base) => {
|
|
2211
|
+
if (!_optionalChain([v4Options, 'access', _107 => _107.sources, 'optionalAccess', _108 => _108.length])) {
|
|
2212
|
+
return void 0;
|
|
2213
|
+
}
|
|
2214
|
+
return v4Options.sources.map((source) => ({
|
|
2215
|
+
base: _nullishCoalesce(source.base, () => ( base)),
|
|
2216
|
+
pattern: source.pattern,
|
|
2217
|
+
negated: source.negated
|
|
2218
|
+
}));
|
|
2219
|
+
};
|
|
2220
|
+
if (v4Options.cssEntries.length > 0) {
|
|
2221
|
+
for (const entry of v4Options.cssEntries) {
|
|
2222
|
+
const filePath = _pathe2.default.isAbsolute(entry) ? entry : _pathe2.default.resolve(options.projectRoot, entry);
|
|
2223
|
+
if (!await _fsextra2.default.pathExists(filePath)) {
|
|
2224
|
+
continue;
|
|
2225
|
+
}
|
|
2226
|
+
const css = await _fsextra2.default.readFile(filePath, "utf8");
|
|
2227
|
+
const entryDir = _pathe2.default.dirname(filePath);
|
|
2228
|
+
const designSystemBases = resolvedConfiguredBase && resolvedConfiguredBase !== entryDir ? [entryDir, resolvedConfiguredBase] : [entryDir];
|
|
2229
|
+
const sourcesBase = _nullishCoalesce(resolvedConfiguredBase, () => ( entryDir));
|
|
2230
|
+
const sources = resolveSources(sourcesBase);
|
|
2231
|
+
const firstBase = _nullishCoalesce(designSystemBases[0], () => ( entryDir));
|
|
2232
|
+
const extractOptions = {
|
|
2233
|
+
cwd: options.projectRoot,
|
|
2234
|
+
base: firstBase,
|
|
2235
|
+
baseFallbacks: designSystemBases.slice(1),
|
|
2236
|
+
css,
|
|
2237
|
+
...sources === void 0 ? {} : { sources }
|
|
2238
|
+
};
|
|
2239
|
+
const candidates = await extractValidCandidates(extractOptions);
|
|
2240
|
+
for (const candidate of candidates) {
|
|
2241
|
+
if (options.filter(candidate)) {
|
|
2242
|
+
set.add(candidate);
|
|
2243
|
+
}
|
|
2244
|
+
}
|
|
2245
|
+
}
|
|
2246
|
+
} else {
|
|
2247
|
+
const baseForCss = _nullishCoalesce(resolvedConfiguredBase, () => ( resolvedDefaultBase));
|
|
2248
|
+
const sources = resolveSources(baseForCss);
|
|
2249
|
+
const extractOptions = {
|
|
2250
|
+
cwd: options.projectRoot,
|
|
2251
|
+
base: baseForCss,
|
|
2252
|
+
...v4Options.css === void 0 ? {} : { css: v4Options.css },
|
|
2253
|
+
...sources === void 0 ? {} : { sources }
|
|
2254
|
+
};
|
|
2255
|
+
const candidates = await extractValidCandidates(extractOptions);
|
|
2256
|
+
for (const candidate of candidates) {
|
|
2257
|
+
if (options.filter(candidate)) {
|
|
2258
|
+
set.add(candidate);
|
|
2259
|
+
}
|
|
2260
|
+
}
|
|
2261
|
+
}
|
|
2262
|
+
return set;
|
|
2263
|
+
}
|
|
2264
|
+
|
|
2265
|
+
// src/runtime/context-registry.ts
|
|
2266
|
+
var _module = require('module');
|
|
2267
|
+
|
|
2268
|
+
|
|
2269
|
+
var require2 = _module.createRequire.call(void 0, _chunk7JAOSSROjs.importMetaUrl);
|
|
2270
|
+
function resolveRuntimeEntry(packageInfo, majorVersion) {
|
|
2271
|
+
const root = packageInfo.rootPath;
|
|
2272
|
+
if (majorVersion === 2) {
|
|
2273
|
+
const jitIndex = _pathe2.default.join(root, "lib/jit/index.js");
|
|
2274
|
+
if (_fsextra2.default.existsSync(jitIndex)) {
|
|
2275
|
+
return jitIndex;
|
|
2276
|
+
}
|
|
2277
|
+
} else if (majorVersion === 3) {
|
|
2278
|
+
const plugin = _pathe2.default.join(root, "lib/plugin.js");
|
|
2279
|
+
const index = _pathe2.default.join(root, "lib/index.js");
|
|
2280
|
+
if (_fsextra2.default.existsSync(plugin)) {
|
|
2281
|
+
return plugin;
|
|
2282
|
+
}
|
|
2283
|
+
if (_fsextra2.default.existsSync(index)) {
|
|
2284
|
+
return index;
|
|
2285
|
+
}
|
|
2286
|
+
}
|
|
2287
|
+
return void 0;
|
|
2288
|
+
}
|
|
2289
|
+
function loadRuntimeContexts(packageInfo, majorVersion, refProperty) {
|
|
2290
|
+
if (majorVersion === 4) {
|
|
2291
|
+
return [];
|
|
2292
|
+
}
|
|
2293
|
+
const entry = resolveRuntimeEntry(packageInfo, majorVersion);
|
|
2294
|
+
if (!entry) {
|
|
2295
|
+
return [];
|
|
2296
|
+
}
|
|
2297
|
+
const moduleExports = require2(entry);
|
|
2298
|
+
if (!moduleExports) {
|
|
2299
|
+
return [];
|
|
2300
|
+
}
|
|
2301
|
+
const ref = moduleExports[refProperty];
|
|
2302
|
+
if (!ref) {
|
|
2303
|
+
return [];
|
|
2304
|
+
}
|
|
2305
|
+
if (Array.isArray(ref)) {
|
|
2306
|
+
return ref;
|
|
2307
|
+
}
|
|
2308
|
+
if (typeof ref === "object" && Array.isArray(ref.value)) {
|
|
2309
|
+
return ref.value;
|
|
2310
|
+
}
|
|
2311
|
+
return [];
|
|
2312
|
+
}
|
|
2313
|
+
|
|
2314
|
+
// src/runtime/process-tailwindcss.ts
|
|
2315
|
+
|
|
2316
|
+
|
|
2317
|
+
var _postcss = require('postcss'); var _postcss2 = _interopRequireDefault(_postcss);
|
|
2318
|
+
var _tailwindcssconfig = require('tailwindcss-config');
|
|
2319
|
+
var require3 = _module.createRequire.call(void 0, _chunk7JAOSSROjs.importMetaUrl);
|
|
2320
|
+
async function resolveConfigPath(options) {
|
|
2321
|
+
if (options.config && _pathe2.default.isAbsolute(options.config)) {
|
|
2322
|
+
return options.config;
|
|
2323
|
+
}
|
|
2324
|
+
const result = await _tailwindcssconfig.loadConfig.call(void 0, { cwd: options.cwd });
|
|
2325
|
+
if (!result) {
|
|
2326
|
+
throw new Error(`Unable to locate Tailwind CSS config from ${options.cwd}`);
|
|
2327
|
+
}
|
|
2328
|
+
return result.filepath;
|
|
2329
|
+
}
|
|
2330
|
+
async function runTailwindBuild(options) {
|
|
2331
|
+
const configPath = await resolveConfigPath(options);
|
|
2332
|
+
const pluginName = _nullishCoalesce(options.postcssPlugin, () => ( (options.majorVersion === 4 ? "@tailwindcss/postcss" : "tailwindcss")));
|
|
2333
|
+
if (options.majorVersion === 4) {
|
|
2334
|
+
return _postcss2.default.call(void 0, [
|
|
2335
|
+
require3(pluginName)({
|
|
2336
|
+
config: configPath
|
|
2337
|
+
})
|
|
2338
|
+
]).process("@import 'tailwindcss';", {
|
|
2339
|
+
from: void 0
|
|
2340
|
+
});
|
|
2341
|
+
}
|
|
2342
|
+
return _postcss2.default.call(void 0, [
|
|
2343
|
+
require3(pluginName)({
|
|
2344
|
+
config: configPath
|
|
2345
|
+
})
|
|
2346
|
+
]).process("@tailwind base;@tailwind components;@tailwind utilities;", {
|
|
2347
|
+
from: void 0
|
|
2348
|
+
});
|
|
2349
|
+
}
|
|
2350
|
+
|
|
2351
|
+
// src/patching/status.ts
|
|
2352
|
+
var _types = require('@babel/types'); var t4 = _interopRequireWildcard(_types); var t = _interopRequireWildcard(_types); var t2 = _interopRequireWildcard(_types); var t3 = _interopRequireWildcard(_types); var t5 = _interopRequireWildcard(_types);
|
|
2353
|
+
|
|
2354
|
+
|
|
2355
|
+
|
|
2356
|
+
// src/babel/index.ts
|
|
2357
|
+
var _generator = require('@babel/generator'); var _generator2 = _interopRequireDefault(_generator);
|
|
2358
|
+
var _traverse = require('@babel/traverse'); var _traverse2 = _interopRequireDefault(_traverse);
|
|
2359
|
+
var _parser = require('@babel/parser');
|
|
2360
|
+
function _interopDefaultCompat(e) {
|
|
2361
|
+
return e && typeof e === "object" && "default" in e ? e.default : e;
|
|
2362
|
+
}
|
|
2363
|
+
var generate = _interopDefaultCompat(_generator2.default);
|
|
2364
|
+
var traverse = _interopDefaultCompat(_traverse2.default);
|
|
2365
|
+
|
|
2366
|
+
// src/patching/operations/export-context/postcss-v2.ts
|
|
2367
|
+
|
|
2368
|
+
var IDENTIFIER_RE = /^[A-Z_$][\w$]*$/i;
|
|
2369
|
+
function toIdentifierName(property) {
|
|
2370
|
+
if (!property) {
|
|
2371
|
+
return "contextRef";
|
|
1994
2372
|
}
|
|
1995
2373
|
const sanitized = property.replace(/[^\w$]/gu, "_");
|
|
1996
2374
|
if (/^\d/.test(sanitized)) {
|
|
@@ -2010,9 +2388,9 @@ function transformProcessTailwindFeaturesReturnContextV2(content) {
|
|
|
2010
2388
|
});
|
|
2011
2389
|
let hasPatched = false;
|
|
2012
2390
|
traverse(ast, {
|
|
2013
|
-
FunctionDeclaration(
|
|
2014
|
-
const node =
|
|
2015
|
-
if (_optionalChain([node, 'access',
|
|
2391
|
+
FunctionDeclaration(path18) {
|
|
2392
|
+
const node = path18.node;
|
|
2393
|
+
if (_optionalChain([node, 'access', _109 => _109.id, 'optionalAccess', _110 => _110.name]) !== "processTailwindFeatures" || node.body.body.length !== 1 || !t.isReturnStatement(node.body.body[0])) {
|
|
2016
2394
|
return;
|
|
2017
2395
|
}
|
|
2018
2396
|
const returnStatement3 = node.body.body[0];
|
|
@@ -2042,10 +2420,10 @@ function transformPostcssPluginV2(content, options) {
|
|
|
2042
2420
|
const ast = _parser.parse.call(void 0, content);
|
|
2043
2421
|
let hasPatched = false;
|
|
2044
2422
|
traverse(ast, {
|
|
2045
|
-
Program(
|
|
2046
|
-
const program =
|
|
2423
|
+
Program(path18) {
|
|
2424
|
+
const program = path18.node;
|
|
2047
2425
|
const index = program.body.findIndex((statement) => {
|
|
2048
|
-
return t.isFunctionDeclaration(statement) && _optionalChain([statement, 'access',
|
|
2426
|
+
return t.isFunctionDeclaration(statement) && _optionalChain([statement, 'access', _111 => _111.id, 'optionalAccess', _112 => _112.name]) === "_default";
|
|
2049
2427
|
});
|
|
2050
2428
|
if (index === -1) {
|
|
2051
2429
|
return;
|
|
@@ -2077,12 +2455,12 @@ function transformPostcssPluginV2(content, options) {
|
|
|
2077
2455
|
);
|
|
2078
2456
|
}
|
|
2079
2457
|
},
|
|
2080
|
-
FunctionDeclaration(
|
|
2458
|
+
FunctionDeclaration(path18) {
|
|
2081
2459
|
if (hasPatched) {
|
|
2082
2460
|
return;
|
|
2083
2461
|
}
|
|
2084
|
-
const fn =
|
|
2085
|
-
if (_optionalChain([fn, 'access',
|
|
2462
|
+
const fn = path18.node;
|
|
2463
|
+
if (_optionalChain([fn, 'access', _113 => _113.id, 'optionalAccess', _114 => _114.name]) !== "_default") {
|
|
2086
2464
|
return;
|
|
2087
2465
|
}
|
|
2088
2466
|
if (fn.body.body.length !== 1 || !t.isReturnStatement(fn.body.body[0])) {
|
|
@@ -2170,9 +2548,9 @@ function transformProcessTailwindFeaturesReturnContext(content) {
|
|
|
2170
2548
|
const ast = _parser.parse.call(void 0, content);
|
|
2171
2549
|
let hasPatched = false;
|
|
2172
2550
|
traverse(ast, {
|
|
2173
|
-
FunctionDeclaration(
|
|
2174
|
-
const node =
|
|
2175
|
-
if (_optionalChain([node, 'access',
|
|
2551
|
+
FunctionDeclaration(path18) {
|
|
2552
|
+
const node = path18.node;
|
|
2553
|
+
if (_optionalChain([node, 'access', _115 => _115.id, 'optionalAccess', _116 => _116.name]) !== "processTailwindFeatures" || node.body.body.length !== 1) {
|
|
2176
2554
|
return;
|
|
2177
2555
|
}
|
|
2178
2556
|
const [returnStatement3] = node.body.body;
|
|
@@ -2203,10 +2581,10 @@ function transformPostcssPlugin(content, { refProperty }) {
|
|
|
2203
2581
|
const valueMember = t2.memberExpression(refIdentifier, t2.identifier("value"));
|
|
2204
2582
|
let hasPatched = false;
|
|
2205
2583
|
traverse(ast, {
|
|
2206
|
-
Program(
|
|
2207
|
-
const program =
|
|
2584
|
+
Program(path18) {
|
|
2585
|
+
const program = path18.node;
|
|
2208
2586
|
const index = program.body.findIndex((statement) => {
|
|
2209
|
-
return t2.isExpressionStatement(statement) && t2.isAssignmentExpression(statement.expression) && t2.isMemberExpression(statement.expression.left) && t2.isFunctionExpression(statement.expression.right) && _optionalChain([statement, 'access',
|
|
2587
|
+
return t2.isExpressionStatement(statement) && t2.isAssignmentExpression(statement.expression) && t2.isMemberExpression(statement.expression.left) && t2.isFunctionExpression(statement.expression.right) && _optionalChain([statement, 'access', _117 => _117.expression, 'access', _118 => _118.right, 'access', _119 => _119.id, 'optionalAccess', _120 => _120.name]) === "tailwindcss";
|
|
2210
2588
|
});
|
|
2211
2589
|
if (index === -1) {
|
|
2212
2590
|
return;
|
|
@@ -2242,12 +2620,12 @@ function transformPostcssPlugin(content, { refProperty }) {
|
|
|
2242
2620
|
);
|
|
2243
2621
|
}
|
|
2244
2622
|
},
|
|
2245
|
-
FunctionExpression(
|
|
2623
|
+
FunctionExpression(path18) {
|
|
2246
2624
|
if (hasPatched) {
|
|
2247
2625
|
return;
|
|
2248
2626
|
}
|
|
2249
|
-
const fn =
|
|
2250
|
-
if (_optionalChain([fn, 'access',
|
|
2627
|
+
const fn = path18.node;
|
|
2628
|
+
if (_optionalChain([fn, 'access', _121 => _121.id, 'optionalAccess', _122 => _122.name]) !== "tailwindcss" || fn.body.body.length !== 1) {
|
|
2251
2629
|
return;
|
|
2252
2630
|
}
|
|
2253
2631
|
const [returnStatement3] = fn.body.body;
|
|
@@ -2319,54 +2697,27 @@ function transformPostcssPlugin(content, { refProperty }) {
|
|
|
2319
2697
|
|
|
2320
2698
|
|
|
2321
2699
|
|
|
2322
|
-
|
|
2323
|
-
// src/utils.ts
|
|
2324
|
-
function isObject(val) {
|
|
2325
|
-
return val !== null && typeof val === "object" && Array.isArray(val) === false;
|
|
2326
|
-
}
|
|
2327
|
-
function spliceChangesIntoString(str, changes) {
|
|
2328
|
-
if (!changes[0]) {
|
|
2329
|
-
return str;
|
|
2330
|
-
}
|
|
2331
|
-
changes.sort((a, b) => {
|
|
2332
|
-
return a.end - b.end || a.start - b.start;
|
|
2333
|
-
});
|
|
2334
|
-
let result = "";
|
|
2335
|
-
let previous = changes[0];
|
|
2336
|
-
result += str.slice(0, previous.start);
|
|
2337
|
-
result += previous.replacement;
|
|
2338
|
-
for (let i = 1; i < changes.length; ++i) {
|
|
2339
|
-
const change = changes[i];
|
|
2340
|
-
result += str.slice(previous.end, change.start);
|
|
2341
|
-
result += change.replacement;
|
|
2342
|
-
previous = change;
|
|
2343
|
-
}
|
|
2344
|
-
result += str.slice(previous.end);
|
|
2345
|
-
return result;
|
|
2346
|
-
}
|
|
2347
|
-
|
|
2348
|
-
// src/patching/operations/extend-length-units.ts
|
|
2349
2700
|
function updateLengthUnitsArray(content, options) {
|
|
2350
2701
|
const { variableName = "lengthUnits", units } = options;
|
|
2351
2702
|
const ast = _parser.parse.call(void 0, content);
|
|
2352
2703
|
let arrayRef;
|
|
2353
2704
|
let changed = false;
|
|
2354
2705
|
traverse(ast, {
|
|
2355
|
-
Identifier(
|
|
2356
|
-
if (
|
|
2357
|
-
arrayRef =
|
|
2706
|
+
Identifier(path18) {
|
|
2707
|
+
if (path18.node.name === variableName && t3.isVariableDeclarator(path18.parent) && t3.isArrayExpression(path18.parent.init)) {
|
|
2708
|
+
arrayRef = path18.parent.init;
|
|
2358
2709
|
const existing = new Set(
|
|
2359
|
-
|
|
2710
|
+
path18.parent.init.elements.map((element) => t3.isStringLiteral(element) ? element.value : void 0).filter(Boolean)
|
|
2360
2711
|
);
|
|
2361
2712
|
for (const unit of units) {
|
|
2362
2713
|
if (!existing.has(unit)) {
|
|
2363
|
-
|
|
2714
|
+
path18.parent.init.elements = path18.parent.init.elements.map((element) => {
|
|
2364
2715
|
if (t3.isStringLiteral(element)) {
|
|
2365
2716
|
return t3.stringLiteral(element.value);
|
|
2366
2717
|
}
|
|
2367
2718
|
return element;
|
|
2368
2719
|
});
|
|
2369
|
-
|
|
2720
|
+
path18.parent.init.elements.push(t3.stringLiteral(unit));
|
|
2370
2721
|
changed = true;
|
|
2371
2722
|
}
|
|
2372
2723
|
}
|
|
@@ -2447,13 +2798,13 @@ function applyExtendLengthUnitsPatchV4(rootDir, options) {
|
|
|
2447
2798
|
const { code, file, match } = item;
|
|
2448
2799
|
const ast = _parser.parse.call(void 0, match[0], { sourceType: "unambiguous" });
|
|
2449
2800
|
traverse(ast, {
|
|
2450
|
-
ArrayExpression(
|
|
2801
|
+
ArrayExpression(path18) {
|
|
2451
2802
|
for (const unit of opts.units) {
|
|
2452
|
-
if (
|
|
2803
|
+
if (path18.node.elements.some((element) => t3.isStringLiteral(element) && element.value === unit)) {
|
|
2453
2804
|
item.hasPatched = true;
|
|
2454
2805
|
return;
|
|
2455
2806
|
}
|
|
2456
|
-
|
|
2807
|
+
path18.node.elements.push(t3.stringLiteral(unit));
|
|
2457
2808
|
}
|
|
2458
2809
|
}
|
|
2459
2810
|
});
|
|
@@ -2489,501 +2840,207 @@ function inspectLengthUnitsArray(content, variableName, units) {
|
|
|
2489
2840
|
let found = false;
|
|
2490
2841
|
let missingUnits = [];
|
|
2491
2842
|
traverse(ast, {
|
|
2492
|
-
Identifier(
|
|
2493
|
-
if (
|
|
2843
|
+
Identifier(path18) {
|
|
2844
|
+
if (path18.node.name === variableName && t4.isVariableDeclarator(path18.parent) && t4.isArrayExpression(path18.parent.init)) {
|
|
2494
2845
|
found = true;
|
|
2495
2846
|
const existing = new Set(
|
|
2496
|
-
|
|
2847
|
+
path18.parent.init.elements.map((element) => t4.isStringLiteral(element) ? element.value : void 0).filter(Boolean)
|
|
2497
2848
|
);
|
|
2498
2849
|
missingUnits = units.filter((unit) => !existing.has(unit));
|
|
2499
|
-
|
|
2850
|
+
path18.stop();
|
|
2500
2851
|
}
|
|
2501
2852
|
}
|
|
2502
2853
|
});
|
|
2503
2854
|
return {
|
|
2504
|
-
found,
|
|
2505
|
-
missingUnits
|
|
2506
|
-
};
|
|
2507
|
-
}
|
|
2508
|
-
function checkExposeContextPatch(context) {
|
|
2509
|
-
const { packageInfo, options, majorVersion } = context;
|
|
2510
|
-
const refProperty = options.features.exposeContext.refProperty;
|
|
2511
|
-
if (!options.features.exposeContext.enabled) {
|
|
2512
|
-
return {
|
|
2513
|
-
name: "exposeContext",
|
|
2514
|
-
status: "skipped",
|
|
2515
|
-
reason: "exposeContext feature disabled",
|
|
2516
|
-
files: []
|
|
2517
|
-
};
|
|
2518
|
-
}
|
|
2519
|
-
if (majorVersion === 4) {
|
|
2520
|
-
return {
|
|
2521
|
-
name: "exposeContext",
|
|
2522
|
-
status: "unsupported",
|
|
2523
|
-
reason: "Context export patch is only required for Tailwind v2/v3",
|
|
2524
|
-
files: []
|
|
2525
|
-
};
|
|
2526
|
-
}
|
|
2527
|
-
const checks = [];
|
|
2528
|
-
function inspectFile(relative, transform) {
|
|
2529
|
-
const filePath = _pathe2.default.resolve(packageInfo.rootPath, relative);
|
|
2530
|
-
if (!_fsextra2.default.existsSync(filePath)) {
|
|
2531
|
-
checks.push({ relative, exists: false, patched: false });
|
|
2532
|
-
return;
|
|
2533
|
-
}
|
|
2534
|
-
const content = _fsextra2.default.readFileSync(filePath, "utf8");
|
|
2535
|
-
const { hasPatched } = transform(content);
|
|
2536
|
-
checks.push({
|
|
2537
|
-
relative,
|
|
2538
|
-
exists: true,
|
|
2539
|
-
patched: hasPatched
|
|
2540
|
-
});
|
|
2541
|
-
}
|
|
2542
|
-
if (majorVersion === 3) {
|
|
2543
|
-
inspectFile("lib/processTailwindFeatures.js", transformProcessTailwindFeaturesReturnContext);
|
|
2544
|
-
const pluginCandidates = ["lib/plugin.js", "lib/index.js"];
|
|
2545
|
-
const pluginRelative = pluginCandidates.find((candidate) => _fsextra2.default.existsSync(_pathe2.default.resolve(packageInfo.rootPath, candidate)));
|
|
2546
|
-
if (pluginRelative) {
|
|
2547
|
-
inspectFile(pluginRelative, (content) => transformPostcssPlugin(content, { refProperty }));
|
|
2548
|
-
} else {
|
|
2549
|
-
checks.push({ relative: "lib/plugin.js", exists: false, patched: false });
|
|
2550
|
-
}
|
|
2551
|
-
} else {
|
|
2552
|
-
inspectFile("lib/jit/processTailwindFeatures.js", transformProcessTailwindFeaturesReturnContextV2);
|
|
2553
|
-
inspectFile("lib/jit/index.js", (content) => transformPostcssPluginV2(content, { refProperty }));
|
|
2554
|
-
}
|
|
2555
|
-
const files = checks.filter((check) => check.exists).map((check) => check.relative);
|
|
2556
|
-
const missingFiles = checks.filter((check) => !check.exists);
|
|
2557
|
-
const unpatchedFiles = checks.filter((check) => check.exists && !check.patched);
|
|
2558
|
-
const reasons = [];
|
|
2559
|
-
if (missingFiles.length) {
|
|
2560
|
-
reasons.push(`missing files: ${missingFiles.map((item) => item.relative).join(", ")}`);
|
|
2561
|
-
}
|
|
2562
|
-
if (unpatchedFiles.length) {
|
|
2563
|
-
reasons.push(`unpatched files: ${unpatchedFiles.map((item) => item.relative).join(", ")}`);
|
|
2564
|
-
}
|
|
2565
|
-
return {
|
|
2566
|
-
name: "exposeContext",
|
|
2567
|
-
status: reasons.length ? "not-applied" : "applied",
|
|
2568
|
-
...reasons.length ? { reason: reasons.join("; ") } : {},
|
|
2569
|
-
files
|
|
2570
|
-
};
|
|
2571
|
-
}
|
|
2572
|
-
function checkExtendLengthUnitsV3(rootDir, options) {
|
|
2573
|
-
const lengthUnitsFilePath = _nullishCoalesce(options.lengthUnitsFilePath, () => ( "lib/util/dataTypes.js"));
|
|
2574
|
-
const variableName = _nullishCoalesce(options.variableName, () => ( "lengthUnits"));
|
|
2575
|
-
const target = _pathe2.default.resolve(rootDir, lengthUnitsFilePath);
|
|
2576
|
-
const files = _fsextra2.default.existsSync(target) ? [_pathe2.default.relative(rootDir, target)] : [];
|
|
2577
|
-
if (!_fsextra2.default.existsSync(target)) {
|
|
2578
|
-
return {
|
|
2579
|
-
name: "extendLengthUnits",
|
|
2580
|
-
status: "not-applied",
|
|
2581
|
-
reason: `missing ${lengthUnitsFilePath}`,
|
|
2582
|
-
files
|
|
2583
|
-
};
|
|
2584
|
-
}
|
|
2585
|
-
const content = _fsextra2.default.readFileSync(target, "utf8");
|
|
2586
|
-
const { found, missingUnits } = inspectLengthUnitsArray(content, variableName, options.units);
|
|
2587
|
-
if (!found) {
|
|
2588
|
-
return {
|
|
2589
|
-
name: "extendLengthUnits",
|
|
2590
|
-
status: "not-applied",
|
|
2591
|
-
reason: `could not locate ${variableName} array in ${lengthUnitsFilePath}`,
|
|
2592
|
-
files
|
|
2593
|
-
};
|
|
2594
|
-
}
|
|
2595
|
-
if (missingUnits.length) {
|
|
2596
|
-
return {
|
|
2597
|
-
name: "extendLengthUnits",
|
|
2598
|
-
status: "not-applied",
|
|
2599
|
-
reason: `missing units: ${missingUnits.join(", ")}`,
|
|
2600
|
-
files
|
|
2601
|
-
};
|
|
2602
|
-
}
|
|
2603
|
-
return {
|
|
2604
|
-
name: "extendLengthUnits",
|
|
2605
|
-
status: "applied",
|
|
2606
|
-
files
|
|
2607
|
-
};
|
|
2608
|
-
}
|
|
2609
|
-
function checkExtendLengthUnitsV4(rootDir, options) {
|
|
2610
|
-
const distDir = _pathe2.default.resolve(rootDir, "dist");
|
|
2611
|
-
if (!_fsextra2.default.existsSync(distDir)) {
|
|
2612
|
-
return {
|
|
2613
|
-
name: "extendLengthUnits",
|
|
2614
|
-
status: "not-applied",
|
|
2615
|
-
reason: "dist directory not found for Tailwind v4 package",
|
|
2616
|
-
files: []
|
|
2617
|
-
};
|
|
2618
|
-
}
|
|
2619
|
-
const result = applyExtendLengthUnitsPatchV4(rootDir, {
|
|
2620
|
-
...options,
|
|
2621
|
-
enabled: true,
|
|
2622
|
-
overwrite: false
|
|
2623
|
-
});
|
|
2624
|
-
if (result.files.length === 0) {
|
|
2625
|
-
return {
|
|
2626
|
-
name: "extendLengthUnits",
|
|
2627
|
-
status: "not-applied",
|
|
2628
|
-
reason: "no bundle chunks matched the length unit pattern",
|
|
2629
|
-
files: []
|
|
2630
|
-
};
|
|
2631
|
-
}
|
|
2632
|
-
const files = result.files.map((file) => _pathe2.default.relative(rootDir, file.file));
|
|
2633
|
-
const pending = result.files.filter((file) => !file.hasPatched);
|
|
2634
|
-
if (pending.length) {
|
|
2635
|
-
return {
|
|
2636
|
-
name: "extendLengthUnits",
|
|
2637
|
-
status: "not-applied",
|
|
2638
|
-
reason: `missing units in ${pending.length} bundle${pending.length > 1 ? "s" : ""}`,
|
|
2639
|
-
files: pending.map((file) => _pathe2.default.relative(rootDir, file.file))
|
|
2640
|
-
};
|
|
2641
|
-
}
|
|
2642
|
-
return {
|
|
2643
|
-
name: "extendLengthUnits",
|
|
2644
|
-
status: "applied",
|
|
2645
|
-
files
|
|
2855
|
+
found,
|
|
2856
|
+
missingUnits
|
|
2646
2857
|
};
|
|
2647
2858
|
}
|
|
2648
|
-
function
|
|
2859
|
+
function checkExposeContextPatch(context) {
|
|
2649
2860
|
const { packageInfo, options, majorVersion } = context;
|
|
2650
|
-
|
|
2861
|
+
const refProperty = options.features.exposeContext.refProperty;
|
|
2862
|
+
if (!options.features.exposeContext.enabled) {
|
|
2651
2863
|
return {
|
|
2652
|
-
name: "
|
|
2864
|
+
name: "exposeContext",
|
|
2653
2865
|
status: "skipped",
|
|
2654
|
-
reason: "
|
|
2866
|
+
reason: "exposeContext feature disabled",
|
|
2655
2867
|
files: []
|
|
2656
2868
|
};
|
|
2657
2869
|
}
|
|
2658
|
-
if (majorVersion ===
|
|
2870
|
+
if (majorVersion === 4) {
|
|
2659
2871
|
return {
|
|
2660
|
-
name: "
|
|
2872
|
+
name: "exposeContext",
|
|
2661
2873
|
status: "unsupported",
|
|
2662
|
-
reason: "
|
|
2874
|
+
reason: "Context export patch is only required for Tailwind v2/v3",
|
|
2663
2875
|
files: []
|
|
2664
2876
|
};
|
|
2665
2877
|
}
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
}
|
|
2671
|
-
|
|
2672
|
-
return {
|
|
2673
|
-
package: {
|
|
2674
|
-
name: _nullishCoalesce(context.packageInfo.name, () => ( _optionalChain([context, 'access', _91 => _91.packageInfo, 'access', _92 => _92.packageJson, 'optionalAccess', _93 => _93.name]))),
|
|
2675
|
-
version: context.packageInfo.version,
|
|
2676
|
-
root: context.packageInfo.rootPath
|
|
2677
|
-
},
|
|
2678
|
-
majorVersion: context.majorVersion,
|
|
2679
|
-
entries: [
|
|
2680
|
-
checkExposeContextPatch(context),
|
|
2681
|
-
checkExtendLengthUnitsPatch(context)
|
|
2682
|
-
]
|
|
2683
|
-
};
|
|
2684
|
-
}
|
|
2685
|
-
|
|
2686
|
-
// src/runtime/class-collector.ts
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
function collectClassesFromContexts(contexts, filter) {
|
|
2691
|
-
const set = /* @__PURE__ */ new Set();
|
|
2692
|
-
for (const context of contexts) {
|
|
2693
|
-
if (!isObject(context) || !context.classCache) {
|
|
2694
|
-
continue;
|
|
2695
|
-
}
|
|
2696
|
-
for (const key of context.classCache.keys()) {
|
|
2697
|
-
const className = key.toString();
|
|
2698
|
-
if (filter(className)) {
|
|
2699
|
-
set.add(className);
|
|
2700
|
-
}
|
|
2878
|
+
const checks = [];
|
|
2879
|
+
function inspectFile(relative, transform) {
|
|
2880
|
+
const filePath = _pathe2.default.resolve(packageInfo.rootPath, relative);
|
|
2881
|
+
if (!_fsextra2.default.existsSync(filePath)) {
|
|
2882
|
+
checks.push({ relative, exists: false, patched: false });
|
|
2883
|
+
return;
|
|
2701
2884
|
}
|
|
2885
|
+
const content = _fsextra2.default.readFileSync(filePath, "utf8");
|
|
2886
|
+
const { hasPatched } = transform(content);
|
|
2887
|
+
checks.push({
|
|
2888
|
+
relative,
|
|
2889
|
+
exists: true,
|
|
2890
|
+
patched: hasPatched
|
|
2891
|
+
});
|
|
2702
2892
|
}
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
const toAbsolute = (value) => {
|
|
2712
|
-
if (!value) {
|
|
2713
|
-
return void 0;
|
|
2714
|
-
}
|
|
2715
|
-
return _pathe2.default.isAbsolute(value) ? value : _pathe2.default.resolve(options.projectRoot, value);
|
|
2716
|
-
};
|
|
2717
|
-
const resolvedConfiguredBase = toAbsolute(v4Options.configuredBase);
|
|
2718
|
-
const resolvedDefaultBase = _nullishCoalesce(toAbsolute(v4Options.base), () => ( _process2.default.cwd()));
|
|
2719
|
-
const resolveSources = (base) => {
|
|
2720
|
-
if (!_optionalChain([v4Options, 'access', _94 => _94.sources, 'optionalAccess', _95 => _95.length])) {
|
|
2721
|
-
return void 0;
|
|
2722
|
-
}
|
|
2723
|
-
return v4Options.sources.map((source) => ({
|
|
2724
|
-
base: _nullishCoalesce(source.base, () => ( base)),
|
|
2725
|
-
pattern: source.pattern,
|
|
2726
|
-
negated: source.negated
|
|
2727
|
-
}));
|
|
2728
|
-
};
|
|
2729
|
-
if (v4Options.cssEntries.length > 0) {
|
|
2730
|
-
for (const entry of v4Options.cssEntries) {
|
|
2731
|
-
const filePath = _pathe2.default.isAbsolute(entry) ? entry : _pathe2.default.resolve(options.projectRoot, entry);
|
|
2732
|
-
if (!await _fsextra2.default.pathExists(filePath)) {
|
|
2733
|
-
continue;
|
|
2734
|
-
}
|
|
2735
|
-
const css = await _fsextra2.default.readFile(filePath, "utf8");
|
|
2736
|
-
const entryDir = _pathe2.default.dirname(filePath);
|
|
2737
|
-
const designSystemBases = resolvedConfiguredBase && resolvedConfiguredBase !== entryDir ? [entryDir, resolvedConfiguredBase] : [entryDir];
|
|
2738
|
-
const sourcesBase = _nullishCoalesce(resolvedConfiguredBase, () => ( entryDir));
|
|
2739
|
-
const sources = resolveSources(sourcesBase);
|
|
2740
|
-
const firstBase = _nullishCoalesce(designSystemBases[0], () => ( entryDir));
|
|
2741
|
-
const extractOptions = {
|
|
2742
|
-
cwd: options.projectRoot,
|
|
2743
|
-
base: firstBase,
|
|
2744
|
-
baseFallbacks: designSystemBases.slice(1),
|
|
2745
|
-
css,
|
|
2746
|
-
...sources === void 0 ? {} : { sources }
|
|
2747
|
-
};
|
|
2748
|
-
const candidates = await extractValidCandidates(extractOptions);
|
|
2749
|
-
for (const candidate of candidates) {
|
|
2750
|
-
if (options.filter(candidate)) {
|
|
2751
|
-
set.add(candidate);
|
|
2752
|
-
}
|
|
2753
|
-
}
|
|
2893
|
+
if (majorVersion === 3) {
|
|
2894
|
+
inspectFile("lib/processTailwindFeatures.js", transformProcessTailwindFeaturesReturnContext);
|
|
2895
|
+
const pluginCandidates = ["lib/plugin.js", "lib/index.js"];
|
|
2896
|
+
const pluginRelative = pluginCandidates.find((candidate) => _fsextra2.default.existsSync(_pathe2.default.resolve(packageInfo.rootPath, candidate)));
|
|
2897
|
+
if (pluginRelative) {
|
|
2898
|
+
inspectFile(pluginRelative, (content) => transformPostcssPlugin(content, { refProperty }));
|
|
2899
|
+
} else {
|
|
2900
|
+
checks.push({ relative: "lib/plugin.js", exists: false, patched: false });
|
|
2754
2901
|
}
|
|
2755
2902
|
} else {
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
const extractOptions = {
|
|
2759
|
-
cwd: options.projectRoot,
|
|
2760
|
-
base: baseForCss,
|
|
2761
|
-
...v4Options.css === void 0 ? {} : { css: v4Options.css },
|
|
2762
|
-
...sources === void 0 ? {} : { sources }
|
|
2763
|
-
};
|
|
2764
|
-
const candidates = await extractValidCandidates(extractOptions);
|
|
2765
|
-
for (const candidate of candidates) {
|
|
2766
|
-
if (options.filter(candidate)) {
|
|
2767
|
-
set.add(candidate);
|
|
2768
|
-
}
|
|
2769
|
-
}
|
|
2770
|
-
}
|
|
2771
|
-
return set;
|
|
2772
|
-
}
|
|
2773
|
-
|
|
2774
|
-
// src/runtime/context-registry.ts
|
|
2775
|
-
var _module = require('module');
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
var require2 = _module.createRequire.call(void 0, importMetaUrl);
|
|
2779
|
-
function resolveRuntimeEntry(packageInfo, majorVersion) {
|
|
2780
|
-
const root = packageInfo.rootPath;
|
|
2781
|
-
if (majorVersion === 2) {
|
|
2782
|
-
const jitIndex = _pathe2.default.join(root, "lib/jit/index.js");
|
|
2783
|
-
if (_fsextra2.default.existsSync(jitIndex)) {
|
|
2784
|
-
return jitIndex;
|
|
2785
|
-
}
|
|
2786
|
-
} else if (majorVersion === 3) {
|
|
2787
|
-
const plugin = _pathe2.default.join(root, "lib/plugin.js");
|
|
2788
|
-
const index = _pathe2.default.join(root, "lib/index.js");
|
|
2789
|
-
if (_fsextra2.default.existsSync(plugin)) {
|
|
2790
|
-
return plugin;
|
|
2791
|
-
}
|
|
2792
|
-
if (_fsextra2.default.existsSync(index)) {
|
|
2793
|
-
return index;
|
|
2794
|
-
}
|
|
2795
|
-
}
|
|
2796
|
-
return void 0;
|
|
2797
|
-
}
|
|
2798
|
-
function loadRuntimeContexts(packageInfo, majorVersion, refProperty) {
|
|
2799
|
-
if (majorVersion === 4) {
|
|
2800
|
-
return [];
|
|
2801
|
-
}
|
|
2802
|
-
const entry = resolveRuntimeEntry(packageInfo, majorVersion);
|
|
2803
|
-
if (!entry) {
|
|
2804
|
-
return [];
|
|
2805
|
-
}
|
|
2806
|
-
const moduleExports = require2(entry);
|
|
2807
|
-
if (!moduleExports) {
|
|
2808
|
-
return [];
|
|
2809
|
-
}
|
|
2810
|
-
const ref = moduleExports[refProperty];
|
|
2811
|
-
if (!ref) {
|
|
2812
|
-
return [];
|
|
2813
|
-
}
|
|
2814
|
-
if (Array.isArray(ref)) {
|
|
2815
|
-
return ref;
|
|
2816
|
-
}
|
|
2817
|
-
if (typeof ref === "object" && Array.isArray(ref.value)) {
|
|
2818
|
-
return ref.value;
|
|
2819
|
-
}
|
|
2820
|
-
return [];
|
|
2821
|
-
}
|
|
2822
|
-
|
|
2823
|
-
// src/runtime/process-tailwindcss.ts
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
var _postcss = require('postcss'); var _postcss2 = _interopRequireDefault(_postcss);
|
|
2827
|
-
var _tailwindcssconfig = require('tailwindcss-config');
|
|
2828
|
-
var require3 = _module.createRequire.call(void 0, importMetaUrl);
|
|
2829
|
-
async function resolveConfigPath(options) {
|
|
2830
|
-
if (options.config && _pathe2.default.isAbsolute(options.config)) {
|
|
2831
|
-
return options.config;
|
|
2903
|
+
inspectFile("lib/jit/processTailwindFeatures.js", transformProcessTailwindFeaturesReturnContextV2);
|
|
2904
|
+
inspectFile("lib/jit/index.js", (content) => transformPostcssPluginV2(content, { refProperty }));
|
|
2832
2905
|
}
|
|
2833
|
-
const
|
|
2834
|
-
|
|
2835
|
-
|
|
2906
|
+
const files = checks.filter((check) => check.exists).map((check) => check.relative);
|
|
2907
|
+
const missingFiles = checks.filter((check) => !check.exists);
|
|
2908
|
+
const unpatchedFiles = checks.filter((check) => check.exists && !check.patched);
|
|
2909
|
+
const reasons = [];
|
|
2910
|
+
if (missingFiles.length) {
|
|
2911
|
+
reasons.push(`missing files: ${missingFiles.map((item) => item.relative).join(", ")}`);
|
|
2836
2912
|
}
|
|
2837
|
-
|
|
2838
|
-
}
|
|
2839
|
-
async function runTailwindBuild(options) {
|
|
2840
|
-
const configPath = await resolveConfigPath(options);
|
|
2841
|
-
const pluginName = _nullishCoalesce(options.postcssPlugin, () => ( (options.majorVersion === 4 ? "@tailwindcss/postcss" : "tailwindcss")));
|
|
2842
|
-
if (options.majorVersion === 4) {
|
|
2843
|
-
return _postcss2.default.call(void 0, [
|
|
2844
|
-
require3(pluginName)({
|
|
2845
|
-
config: configPath
|
|
2846
|
-
})
|
|
2847
|
-
]).process("@import 'tailwindcss';", {
|
|
2848
|
-
from: void 0
|
|
2849
|
-
});
|
|
2913
|
+
if (unpatchedFiles.length) {
|
|
2914
|
+
reasons.push(`unpatched files: ${unpatchedFiles.map((item) => item.relative).join(", ")}`);
|
|
2850
2915
|
}
|
|
2851
|
-
return
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
}
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
});
|
|
2916
|
+
return {
|
|
2917
|
+
name: "exposeContext",
|
|
2918
|
+
status: reasons.length ? "not-applied" : "applied",
|
|
2919
|
+
...reasons.length ? { reason: reasons.join("; ") } : {},
|
|
2920
|
+
files
|
|
2921
|
+
};
|
|
2858
2922
|
}
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
const extend = _optionalChain([apply, 'optionalAccess', _97 => _97.extendLengthUnits]);
|
|
2871
|
-
let extendOption = false;
|
|
2872
|
-
if (extend && typeof extend === "object") {
|
|
2873
|
-
extendOption = {
|
|
2874
|
-
...extend,
|
|
2875
|
-
enabled: true
|
|
2923
|
+
function checkExtendLengthUnitsV3(rootDir, options) {
|
|
2924
|
+
const lengthUnitsFilePath = _nullishCoalesce(options.lengthUnitsFilePath, () => ( "lib/util/dataTypes.js"));
|
|
2925
|
+
const variableName = _nullishCoalesce(options.variableName, () => ( "lengthUnits"));
|
|
2926
|
+
const target = _pathe2.default.resolve(rootDir, lengthUnitsFilePath);
|
|
2927
|
+
const files = _fsextra2.default.existsSync(target) ? [_pathe2.default.relative(rootDir, target)] : [];
|
|
2928
|
+
if (!_fsextra2.default.existsSync(target)) {
|
|
2929
|
+
return {
|
|
2930
|
+
name: "extendLengthUnits",
|
|
2931
|
+
status: "not-applied",
|
|
2932
|
+
reason: `missing ${lengthUnitsFilePath}`,
|
|
2933
|
+
files
|
|
2876
2934
|
};
|
|
2877
|
-
}
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2935
|
+
}
|
|
2936
|
+
const content = _fsextra2.default.readFileSync(target, "utf8");
|
|
2937
|
+
const { found, missingUnits } = inspectLengthUnitsArray(content, variableName, options.units);
|
|
2938
|
+
if (!found) {
|
|
2939
|
+
return {
|
|
2940
|
+
name: "extendLengthUnits",
|
|
2941
|
+
status: "not-applied",
|
|
2942
|
+
reason: `could not locate ${variableName} array in ${lengthUnitsFilePath}`,
|
|
2943
|
+
files
|
|
2944
|
+
};
|
|
2945
|
+
}
|
|
2946
|
+
if (missingUnits.length) {
|
|
2947
|
+
return {
|
|
2948
|
+
name: "extendLengthUnits",
|
|
2949
|
+
status: "not-applied",
|
|
2950
|
+
reason: `missing units: ${missingUnits.join(", ")}`,
|
|
2951
|
+
files
|
|
2882
2952
|
};
|
|
2883
2953
|
}
|
|
2884
2954
|
return {
|
|
2885
|
-
|
|
2886
|
-
|
|
2955
|
+
name: "extendLengthUnits",
|
|
2956
|
+
status: "applied",
|
|
2957
|
+
files
|
|
2887
2958
|
};
|
|
2888
2959
|
}
|
|
2889
|
-
function
|
|
2890
|
-
|
|
2891
|
-
|
|
2960
|
+
function checkExtendLengthUnitsV4(rootDir, options) {
|
|
2961
|
+
const distDir = _pathe2.default.resolve(rootDir, "dist");
|
|
2962
|
+
if (!_fsextra2.default.existsSync(distDir)) {
|
|
2963
|
+
return {
|
|
2964
|
+
name: "extendLengthUnits",
|
|
2965
|
+
status: "not-applied",
|
|
2966
|
+
reason: "dist directory not found for Tailwind v4 package",
|
|
2967
|
+
files: []
|
|
2968
|
+
};
|
|
2969
|
+
}
|
|
2970
|
+
const result = applyExtendLengthUnitsPatchV4(rootDir, {
|
|
2971
|
+
...options,
|
|
2972
|
+
enabled: true,
|
|
2973
|
+
overwrite: false
|
|
2974
|
+
});
|
|
2975
|
+
if (result.files.length === 0) {
|
|
2976
|
+
return {
|
|
2977
|
+
name: "extendLengthUnits",
|
|
2978
|
+
status: "not-applied",
|
|
2979
|
+
reason: "no bundle chunks matched the length unit pattern",
|
|
2980
|
+
files: []
|
|
2981
|
+
};
|
|
2982
|
+
}
|
|
2983
|
+
const files = result.files.map((file) => _pathe2.default.relative(rootDir, file.file));
|
|
2984
|
+
const pending = result.files.filter((file) => !file.hasPatched);
|
|
2985
|
+
if (pending.length) {
|
|
2986
|
+
return {
|
|
2987
|
+
name: "extendLengthUnits",
|
|
2988
|
+
status: "not-applied",
|
|
2989
|
+
reason: `missing units in ${pending.length} bundle${pending.length > 1 ? "s" : ""}`,
|
|
2990
|
+
files: pending.map((file) => _pathe2.default.relative(rootDir, file.file))
|
|
2991
|
+
};
|
|
2892
2992
|
}
|
|
2893
|
-
const patch = options.patch;
|
|
2894
|
-
const features = normalizeLegacyFeatures(patch);
|
|
2895
|
-
const output = _optionalChain([patch, 'optionalAccess', _100 => _100.output]);
|
|
2896
|
-
const tailwindConfig = _optionalChain([patch, 'optionalAccess', _101 => _101.tailwindcss]);
|
|
2897
|
-
const tailwindVersion = _optionalChain([tailwindConfig, 'optionalAccess', _102 => _102.version]);
|
|
2898
|
-
const tailwindV2 = _optionalChain([tailwindConfig, 'optionalAccess', _103 => _103.v2]);
|
|
2899
|
-
const tailwindV3 = _optionalChain([tailwindConfig, 'optionalAccess', _104 => _104.v3]);
|
|
2900
|
-
const tailwindV4 = _optionalChain([tailwindConfig, 'optionalAccess', _105 => _105.v4]);
|
|
2901
|
-
const tailwindConfigPath = _nullishCoalesce(_optionalChain([tailwindV3, 'optionalAccess', _106 => _106.config]), () => ( _optionalChain([tailwindV2, 'optionalAccess', _107 => _107.config])));
|
|
2902
|
-
const tailwindCwd = _nullishCoalesce(_nullishCoalesce(_optionalChain([tailwindV3, 'optionalAccess', _108 => _108.cwd]), () => ( _optionalChain([tailwindV2, 'optionalAccess', _109 => _109.cwd]))), () => ( _optionalChain([patch, 'optionalAccess', _110 => _110.cwd])));
|
|
2903
|
-
const normalizedExtract = output ? {
|
|
2904
|
-
...output.filename === void 0 ? {} : { file: output.filename },
|
|
2905
|
-
pretty: output.loose ? 2 : false,
|
|
2906
|
-
...output.removeUniversalSelector === void 0 ? {} : { removeUniversalSelector: output.removeUniversalSelector }
|
|
2907
|
-
} : void 0;
|
|
2908
|
-
const normalizedTailwindcss = {
|
|
2909
|
-
..._optionalChain([patch, 'optionalAccess', _111 => _111.packageName]) === void 0 ? {} : { packageName: patch.packageName },
|
|
2910
|
-
...tailwindVersion === void 0 ? {} : { version: tailwindVersion },
|
|
2911
|
-
..._optionalChain([patch, 'optionalAccess', _112 => _112.resolve]) === void 0 ? {} : { resolve: patch.resolve },
|
|
2912
|
-
...tailwindConfigPath === void 0 ? {} : { config: tailwindConfigPath },
|
|
2913
|
-
...tailwindCwd === void 0 ? {} : { cwd: tailwindCwd },
|
|
2914
|
-
...tailwindV2 === void 0 ? {} : { v2: tailwindV2 },
|
|
2915
|
-
...tailwindV3 === void 0 ? {} : { v3: tailwindV3 },
|
|
2916
|
-
...tailwindV4 === void 0 ? {} : { v4: tailwindV4 }
|
|
2917
|
-
};
|
|
2918
|
-
const normalizedCache = typeof options.cache === "boolean" ? options.cache : options.cache ? {
|
|
2919
|
-
...options.cache,
|
|
2920
|
-
enabled: _nullishCoalesce(options.cache.enabled, () => ( true))
|
|
2921
|
-
} : void 0;
|
|
2922
|
-
const normalizedApply = {
|
|
2923
|
-
..._optionalChain([patch, 'optionalAccess', _113 => _113.overwrite]) === void 0 ? {} : { overwrite: patch.overwrite },
|
|
2924
|
-
exposeContext: features.exposeContext,
|
|
2925
|
-
extendLengthUnits: features.extendLengthUnits
|
|
2926
|
-
};
|
|
2927
2993
|
return {
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
...normalizedExtract === void 0 ? {} : { extract: normalizedExtract },
|
|
2932
|
-
...Object.keys(normalizedTailwindcss).length === 0 ? {} : { tailwindcss: normalizedTailwindcss },
|
|
2933
|
-
apply: normalizedApply
|
|
2994
|
+
name: "extendLengthUnits",
|
|
2995
|
+
status: "applied",
|
|
2996
|
+
files
|
|
2934
2997
|
};
|
|
2935
2998
|
}
|
|
2936
|
-
function
|
|
2937
|
-
|
|
2938
|
-
|
|
2999
|
+
function checkExtendLengthUnitsPatch(context) {
|
|
3000
|
+
const { packageInfo, options, majorVersion } = context;
|
|
3001
|
+
if (!options.features.extendLengthUnits) {
|
|
3002
|
+
return {
|
|
3003
|
+
name: "extendLengthUnits",
|
|
3004
|
+
status: "skipped",
|
|
3005
|
+
reason: "extendLengthUnits feature disabled",
|
|
3006
|
+
files: []
|
|
3007
|
+
};
|
|
2939
3008
|
}
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
const outputFile = _nullishCoalesce(_optionalChain([modernExtract, 'optionalAccess', _120 => _120.file]), () => ( _optionalChain([legacyOutput, 'optionalAccess', _121 => _121.file])));
|
|
2955
|
-
const normalizedExtract = modernExtract || legacyOutput ? {
|
|
2956
|
-
..._optionalChain([modernExtract, 'optionalAccess', _122 => _122.write]) === void 0 ? {} : { write: modernExtract.write },
|
|
2957
|
-
...outputFile === void 0 ? {} : { file: outputFile },
|
|
2958
|
-
...pretty === void 0 ? {} : { pretty },
|
|
2959
|
-
...removeUniversalSelector === void 0 ? {} : { removeUniversalSelector },
|
|
2960
|
-
..._optionalChain([modernExtract, 'optionalAccess', _123 => _123.format]) === void 0 ? {} : { format: modernExtract.format }
|
|
2961
|
-
} : void 0;
|
|
2962
|
-
const normalizedTailwindcss = tailwind ? {
|
|
2963
|
-
...tailwind.version === void 0 ? {} : { version: tailwind.version },
|
|
2964
|
-
...tailwind.packageName === void 0 ? tailwind.package === void 0 ? {} : { packageName: tailwind.package } : { packageName: tailwind.packageName },
|
|
2965
|
-
...tailwind.resolve === void 0 ? {} : { resolve: tailwind.resolve },
|
|
2966
|
-
...tailwind.config === void 0 ? {} : { config: tailwind.config },
|
|
2967
|
-
...tailwind.cwd === void 0 ? {} : { cwd: tailwind.cwd },
|
|
2968
|
-
...tailwind.v2 === void 0 ? tailwind.legacy === void 0 ? {} : { v2: tailwind.legacy } : { v2: tailwind.v2 },
|
|
2969
|
-
...tailwind.v3 === void 0 ? tailwind.classic === void 0 ? {} : { v3: tailwind.classic } : { v3: tailwind.v3 },
|
|
2970
|
-
...tailwind.v4 === void 0 ? tailwind.next === void 0 ? {} : { v4: tailwind.next } : { v4: tailwind.v4 }
|
|
2971
|
-
} : void 0;
|
|
2972
|
-
const normalizedApply = registry.apply ? {
|
|
2973
|
-
...registry.apply.overwrite === void 0 ? {} : { overwrite: registry.apply.overwrite },
|
|
2974
|
-
...registry.apply.exposeContext === void 0 ? {} : { exposeContext: registry.apply.exposeContext },
|
|
2975
|
-
...registry.apply.extendLengthUnits === void 0 ? {} : { extendLengthUnits: registry.apply.extendLengthUnits }
|
|
2976
|
-
} : void 0;
|
|
3009
|
+
if (majorVersion === 2) {
|
|
3010
|
+
return {
|
|
3011
|
+
name: "extendLengthUnits",
|
|
3012
|
+
status: "unsupported",
|
|
3013
|
+
reason: "length unit extension is only applied for Tailwind v3/v4",
|
|
3014
|
+
files: []
|
|
3015
|
+
};
|
|
3016
|
+
}
|
|
3017
|
+
if (majorVersion === 3) {
|
|
3018
|
+
return checkExtendLengthUnitsV3(packageInfo.rootPath, options.features.extendLengthUnits);
|
|
3019
|
+
}
|
|
3020
|
+
return checkExtendLengthUnitsV4(packageInfo.rootPath, options.features.extendLengthUnits);
|
|
3021
|
+
}
|
|
3022
|
+
function getPatchStatusReport(context) {
|
|
2977
3023
|
return {
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
3024
|
+
package: {
|
|
3025
|
+
name: _nullishCoalesce(context.packageInfo.name, () => ( _optionalChain([context, 'access', _123 => _123.packageInfo, 'access', _124 => _124.packageJson, 'optionalAccess', _125 => _125.name]))),
|
|
3026
|
+
version: context.packageInfo.version,
|
|
3027
|
+
root: context.packageInfo.rootPath
|
|
3028
|
+
},
|
|
3029
|
+
majorVersion: context.majorVersion,
|
|
3030
|
+
entries: [
|
|
3031
|
+
checkExposeContextPatch(context),
|
|
3032
|
+
checkExtendLengthUnitsPatch(context)
|
|
3033
|
+
]
|
|
2984
3034
|
};
|
|
2985
3035
|
}
|
|
2986
3036
|
|
|
3037
|
+
// src/api/tailwindcss-patcher.ts
|
|
3038
|
+
|
|
3039
|
+
|
|
3040
|
+
var _localpkg = require('local-pkg');
|
|
3041
|
+
|
|
3042
|
+
var _semver = require('semver');
|
|
3043
|
+
|
|
2987
3044
|
// src/patching/operations/export-context/index.ts
|
|
2988
3045
|
|
|
2989
3046
|
|
|
@@ -3085,7 +3142,7 @@ function applyTailwindPatches(context) {
|
|
|
3085
3142
|
majorVersion
|
|
3086
3143
|
});
|
|
3087
3144
|
}
|
|
3088
|
-
if (_optionalChain([options, 'access',
|
|
3145
|
+
if (_optionalChain([options, 'access', _126 => _126.features, 'access', _127 => _127.extendLengthUnits, 'optionalAccess', _128 => _128.enabled])) {
|
|
3089
3146
|
if (majorVersion === 3) {
|
|
3090
3147
|
results.extendLengthUnits = applyExtendLengthUnitsPatchV3(
|
|
3091
3148
|
packageInfo.rootPath,
|
|
@@ -3213,12 +3270,12 @@ var TailwindcssPatcher = (_class2 = class {
|
|
|
3213
3270
|
debugCacheRead(meta) {
|
|
3214
3271
|
if (meta.hit) {
|
|
3215
3272
|
logger_default.debug(
|
|
3216
|
-
`[cache] hit fingerprint=${_nullishCoalesce(_optionalChain([meta, 'access',
|
|
3273
|
+
`[cache] hit fingerprint=${_nullishCoalesce(_optionalChain([meta, 'access', _129 => _129.fingerprint, 'optionalAccess', _130 => _130.slice, 'call', _131 => _131(0, 12)]), () => ( "n/a"))} schema=${_nullishCoalesce(meta.schemaVersion, () => ( "legacy"))} ${meta.details.join("; ")}`
|
|
3217
3274
|
);
|
|
3218
3275
|
return;
|
|
3219
3276
|
}
|
|
3220
3277
|
logger_default.debug(
|
|
3221
|
-
`[cache] miss reason=${meta.reason} fingerprint=${_nullishCoalesce(_optionalChain([meta, 'access',
|
|
3278
|
+
`[cache] miss reason=${meta.reason} fingerprint=${_nullishCoalesce(_optionalChain([meta, 'access', _132 => _132.fingerprint, 'optionalAccess', _133 => _133.slice, 'call', _134 => _134(0, 12)]), () => ( "n/a"))} schema=${_nullishCoalesce(meta.schemaVersion, () => ( "legacy"))} ${meta.details.join("; ")}`
|
|
3222
3279
|
);
|
|
3223
3280
|
}
|
|
3224
3281
|
async mergeWithCache(set) {
|
|
@@ -3291,7 +3348,7 @@ var TailwindcssPatcher = (_class2 = class {
|
|
|
3291
3348
|
return merged;
|
|
3292
3349
|
}
|
|
3293
3350
|
async extract(options) {
|
|
3294
|
-
const shouldWrite = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
3351
|
+
const shouldWrite = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _135 => _135.write]), () => ( this.options.output.enabled));
|
|
3295
3352
|
const classSet = await this.getClassSet();
|
|
3296
3353
|
const classList = Array.from(classSet);
|
|
3297
3354
|
const result = {
|
|
@@ -3327,55 +3384,112 @@ var TailwindcssPatcher = (_class2 = class {
|
|
|
3327
3384
|
__init4() {this.extractValidCandidates = exports.extractValidCandidates = extractValidCandidates}
|
|
3328
3385
|
async collectContentTokens(options) {
|
|
3329
3386
|
return extractProjectCandidatesWithPositions({
|
|
3330
|
-
cwd: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
3331
|
-
sources: _nullishCoalesce(_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
3387
|
+
cwd: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _136 => _136.cwd]), () => ( this.options.projectRoot)),
|
|
3388
|
+
sources: _nullishCoalesce(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _137 => _137.sources]), () => ( _optionalChain([this, 'access', _138 => _138.options, 'access', _139 => _139.tailwind, 'access', _140 => _140.v4, 'optionalAccess', _141 => _141.sources]))), () => ( []))
|
|
3332
3389
|
});
|
|
3333
3390
|
}
|
|
3334
3391
|
async collectContentTokensByFile(options) {
|
|
3335
3392
|
const collectContentOptions = {
|
|
3336
|
-
..._optionalChain([options, 'optionalAccess',
|
|
3337
|
-
..._optionalChain([options, 'optionalAccess',
|
|
3393
|
+
..._optionalChain([options, 'optionalAccess', _142 => _142.cwd]) === void 0 ? {} : { cwd: options.cwd },
|
|
3394
|
+
..._optionalChain([options, 'optionalAccess', _143 => _143.sources]) === void 0 ? {} : { sources: options.sources }
|
|
3338
3395
|
};
|
|
3339
3396
|
const report = await this.collectContentTokens(collectContentOptions);
|
|
3340
3397
|
const groupOptions = {
|
|
3341
|
-
..._optionalChain([options, 'optionalAccess',
|
|
3342
|
-
..._optionalChain([options, 'optionalAccess',
|
|
3398
|
+
..._optionalChain([options, 'optionalAccess', _144 => _144.key]) === void 0 ? {} : { key: options.key },
|
|
3399
|
+
..._optionalChain([options, 'optionalAccess', _145 => _145.stripAbsolutePaths]) === void 0 ? {} : { stripAbsolutePaths: options.stripAbsolutePaths }
|
|
3343
3400
|
};
|
|
3344
3401
|
return groupTokensByFile(report, groupOptions);
|
|
3345
3402
|
}
|
|
3346
3403
|
}, _class2);
|
|
3347
3404
|
|
|
3348
|
-
// src/
|
|
3349
|
-
|
|
3350
|
-
|
|
3405
|
+
// src/commands/migration-report.ts
|
|
3406
|
+
var MIGRATION_REPORT_KIND = "tw-patch-migrate-report";
|
|
3407
|
+
var MIGRATION_REPORT_SCHEMA_VERSION = 1;
|
|
3408
|
+
function assertMigrationReportCompatibility(report, reportFile) {
|
|
3409
|
+
if (report.reportKind !== void 0 && report.reportKind !== MIGRATION_REPORT_KIND) {
|
|
3410
|
+
throw new Error(`Unsupported report kind "${report.reportKind}" in ${reportFile}.`);
|
|
3411
|
+
}
|
|
3412
|
+
if (report.schemaVersion !== void 0 && (!Number.isInteger(report.schemaVersion) || report.schemaVersion > MIGRATION_REPORT_SCHEMA_VERSION)) {
|
|
3413
|
+
throw new Error(
|
|
3414
|
+
`Unsupported report schema version "${String(report.schemaVersion)}" in ${reportFile}. Current supported version is ${MIGRATION_REPORT_SCHEMA_VERSION}.`
|
|
3415
|
+
);
|
|
3416
|
+
}
|
|
3417
|
+
}
|
|
3418
|
+
|
|
3419
|
+
// src/commands/migrate-config.ts
|
|
3420
|
+
|
|
3421
|
+
|
|
3422
|
+
// src/commands/migration-aggregation.ts
|
|
3423
|
+
function createMigrationAggregationState() {
|
|
3424
|
+
return {
|
|
3425
|
+
scannedFiles: 0,
|
|
3426
|
+
changedFiles: 0,
|
|
3427
|
+
writtenFiles: 0,
|
|
3428
|
+
backupsWritten: 0,
|
|
3429
|
+
unchangedFiles: 0,
|
|
3430
|
+
missingFiles: 0,
|
|
3431
|
+
entries: []
|
|
3432
|
+
};
|
|
3433
|
+
}
|
|
3434
|
+
function collectMigrationExecutionResult(state, result) {
|
|
3435
|
+
if (result.missing) {
|
|
3436
|
+
state.missingFiles += 1;
|
|
3437
|
+
return;
|
|
3438
|
+
}
|
|
3439
|
+
state.scannedFiles += 1;
|
|
3440
|
+
state.entries.push(result.entry);
|
|
3441
|
+
if (result.changed) {
|
|
3442
|
+
state.changedFiles += 1;
|
|
3443
|
+
if (result.wrote) {
|
|
3444
|
+
state.writtenFiles += 1;
|
|
3445
|
+
}
|
|
3446
|
+
if (result.backupWritten) {
|
|
3447
|
+
state.backupsWritten += 1;
|
|
3448
|
+
}
|
|
3449
|
+
} else {
|
|
3450
|
+
state.unchangedFiles += 1;
|
|
3451
|
+
}
|
|
3452
|
+
}
|
|
3453
|
+
function buildMigrationReport(state, context) {
|
|
3454
|
+
const {
|
|
3455
|
+
cwd,
|
|
3456
|
+
dryRun,
|
|
3457
|
+
rollbackOnError,
|
|
3458
|
+
backupDirectory,
|
|
3459
|
+
toolName,
|
|
3460
|
+
toolVersion,
|
|
3461
|
+
generatedAt = (/* @__PURE__ */ new Date()).toISOString()
|
|
3462
|
+
} = context;
|
|
3463
|
+
return {
|
|
3464
|
+
reportKind: MIGRATION_REPORT_KIND,
|
|
3465
|
+
schemaVersion: MIGRATION_REPORT_SCHEMA_VERSION,
|
|
3466
|
+
generatedAt,
|
|
3467
|
+
tool: {
|
|
3468
|
+
name: toolName,
|
|
3469
|
+
version: toolVersion
|
|
3470
|
+
},
|
|
3471
|
+
cwd,
|
|
3472
|
+
dryRun,
|
|
3473
|
+
rollbackOnError,
|
|
3474
|
+
...backupDirectory ? { backupDirectory } : {},
|
|
3475
|
+
scannedFiles: state.scannedFiles,
|
|
3476
|
+
changedFiles: state.changedFiles,
|
|
3477
|
+
writtenFiles: state.writtenFiles,
|
|
3478
|
+
backupsWritten: state.backupsWritten,
|
|
3479
|
+
unchangedFiles: state.unchangedFiles,
|
|
3480
|
+
missingFiles: state.missingFiles,
|
|
3481
|
+
entries: state.entries
|
|
3482
|
+
};
|
|
3483
|
+
}
|
|
3484
|
+
|
|
3485
|
+
// src/commands/migration-file-executor.ts
|
|
3486
|
+
|
|
3487
|
+
|
|
3488
|
+
|
|
3489
|
+
// src/commands/migration-source.ts
|
|
3351
3490
|
|
|
3352
3491
|
|
|
3353
3492
|
|
|
3354
|
-
var DEFAULT_CONFIG_FILENAMES = [
|
|
3355
|
-
"tailwindcss-patch.config.ts",
|
|
3356
|
-
"tailwindcss-patch.config.js",
|
|
3357
|
-
"tailwindcss-patch.config.mjs",
|
|
3358
|
-
"tailwindcss-patch.config.cjs",
|
|
3359
|
-
"tailwindcss-mangle.config.ts",
|
|
3360
|
-
"tailwindcss-mangle.config.js",
|
|
3361
|
-
"tailwindcss-mangle.config.mjs",
|
|
3362
|
-
"tailwindcss-mangle.config.cjs"
|
|
3363
|
-
];
|
|
3364
|
-
var DEFAULT_CONFIG_FILENAME_SET = new Set(DEFAULT_CONFIG_FILENAMES);
|
|
3365
|
-
var DEFAULT_WORKSPACE_IGNORED_DIRS = /* @__PURE__ */ new Set([
|
|
3366
|
-
".git",
|
|
3367
|
-
".idea",
|
|
3368
|
-
".turbo",
|
|
3369
|
-
".vscode",
|
|
3370
|
-
".yarn",
|
|
3371
|
-
"coverage",
|
|
3372
|
-
"dist",
|
|
3373
|
-
"node_modules",
|
|
3374
|
-
"tmp"
|
|
3375
|
-
]);
|
|
3376
|
-
var DEFAULT_WORKSPACE_MAX_DEPTH = 6;
|
|
3377
|
-
var MIGRATION_REPORT_KIND = "tw-patch-migrate-report";
|
|
3378
|
-
var MIGRATION_REPORT_SCHEMA_VERSION = 1;
|
|
3379
3493
|
var ROOT_LEGACY_KEYS = ["cwd", "overwrite", "tailwind", "features", "output", "applyPatches"];
|
|
3380
3494
|
function getPropertyKeyName(property) {
|
|
3381
3495
|
if (!property.computed && t5.isIdentifier(property.key)) {
|
|
@@ -3636,6 +3750,33 @@ function migrateConfigSource(source) {
|
|
|
3636
3750
|
changes: [...changes]
|
|
3637
3751
|
};
|
|
3638
3752
|
}
|
|
3753
|
+
|
|
3754
|
+
// src/commands/migration-target-files.ts
|
|
3755
|
+
|
|
3756
|
+
|
|
3757
|
+
var DEFAULT_CONFIG_FILENAMES = [
|
|
3758
|
+
"tailwindcss-patch.config.ts",
|
|
3759
|
+
"tailwindcss-patch.config.js",
|
|
3760
|
+
"tailwindcss-patch.config.mjs",
|
|
3761
|
+
"tailwindcss-patch.config.cjs",
|
|
3762
|
+
"tailwindcss-mangle.config.ts",
|
|
3763
|
+
"tailwindcss-mangle.config.js",
|
|
3764
|
+
"tailwindcss-mangle.config.mjs",
|
|
3765
|
+
"tailwindcss-mangle.config.cjs"
|
|
3766
|
+
];
|
|
3767
|
+
var DEFAULT_CONFIG_FILENAME_SET = new Set(DEFAULT_CONFIG_FILENAMES);
|
|
3768
|
+
var DEFAULT_WORKSPACE_IGNORED_DIRS = /* @__PURE__ */ new Set([
|
|
3769
|
+
".git",
|
|
3770
|
+
".idea",
|
|
3771
|
+
".turbo",
|
|
3772
|
+
".vscode",
|
|
3773
|
+
".yarn",
|
|
3774
|
+
"coverage",
|
|
3775
|
+
"dist",
|
|
3776
|
+
"node_modules",
|
|
3777
|
+
"tmp"
|
|
3778
|
+
]);
|
|
3779
|
+
var DEFAULT_WORKSPACE_MAX_DEPTH = 6;
|
|
3639
3780
|
function resolveTargetFiles(cwd, files) {
|
|
3640
3781
|
const candidates = files && files.length > 0 ? files : [...DEFAULT_CONFIG_FILENAMES];
|
|
3641
3782
|
const resolved = /* @__PURE__ */ new Set();
|
|
@@ -3746,114 +3887,85 @@ function filterTargetFiles(targetFiles, cwd, include, exclude) {
|
|
|
3746
3887
|
return !inExclude;
|
|
3747
3888
|
});
|
|
3748
3889
|
}
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
const
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
|
|
3760
|
-
let writtenFiles = 0;
|
|
3761
|
-
let backupsWritten = 0;
|
|
3762
|
-
let unchangedFiles = 0;
|
|
3763
|
-
let missingFiles = 0;
|
|
3764
|
-
const wroteEntries = [];
|
|
3765
|
-
for (const file of targetFiles) {
|
|
3766
|
-
const exists = await _fsextra2.default.pathExists(file);
|
|
3767
|
-
if (!exists) {
|
|
3768
|
-
missingFiles += 1;
|
|
3769
|
-
continue;
|
|
3770
|
-
}
|
|
3771
|
-
scannedFiles += 1;
|
|
3772
|
-
const source = await _fsextra2.default.readFile(file, "utf8");
|
|
3773
|
-
const migrated = migrateConfigSource(source);
|
|
3774
|
-
const entry = {
|
|
3775
|
-
file,
|
|
3776
|
-
changed: migrated.changed,
|
|
3777
|
-
written: false,
|
|
3778
|
-
rolledBack: false,
|
|
3779
|
-
changes: migrated.changes
|
|
3780
|
-
};
|
|
3781
|
-
entries.push(entry);
|
|
3782
|
-
if (migrated.changed) {
|
|
3783
|
-
changedFiles += 1;
|
|
3784
|
-
if (!dryRun) {
|
|
3785
|
-
try {
|
|
3786
|
-
if (backupDirectory) {
|
|
3787
|
-
const backupRelativePath = resolveBackupRelativePath(cwd, file);
|
|
3788
|
-
const backupFile = _pathe2.default.resolve(backupDirectory, backupRelativePath);
|
|
3789
|
-
await _fsextra2.default.ensureDir(_pathe2.default.dirname(backupFile));
|
|
3790
|
-
await _fsextra2.default.writeFile(backupFile, source, "utf8");
|
|
3791
|
-
entry.backupFile = backupFile;
|
|
3792
|
-
backupsWritten += 1;
|
|
3793
|
-
}
|
|
3794
|
-
await _fsextra2.default.writeFile(file, migrated.code, "utf8");
|
|
3795
|
-
entry.written = true;
|
|
3796
|
-
wroteEntries.push({ file, source, entry });
|
|
3797
|
-
writtenFiles += 1;
|
|
3798
|
-
} catch (error) {
|
|
3799
|
-
let rollbackCount = 0;
|
|
3800
|
-
if (rollbackOnError && wroteEntries.length > 0) {
|
|
3801
|
-
for (const written of [...wroteEntries].reverse()) {
|
|
3802
|
-
try {
|
|
3803
|
-
await _fsextra2.default.writeFile(written.file, written.source, "utf8");
|
|
3804
|
-
written.entry.written = false;
|
|
3805
|
-
written.entry.rolledBack = true;
|
|
3806
|
-
rollbackCount += 1;
|
|
3807
|
-
} catch (e11) {
|
|
3808
|
-
}
|
|
3809
|
-
}
|
|
3810
|
-
writtenFiles = Math.max(0, writtenFiles - rollbackCount);
|
|
3811
|
-
}
|
|
3812
|
-
const reason = error instanceof Error ? error.message : String(error);
|
|
3813
|
-
const rollbackHint = rollbackOnError && rollbackCount > 0 ? ` Rolled back ${rollbackCount} previously written file(s).` : "";
|
|
3814
|
-
throw new Error(`Failed to write migrated config "${file}": ${reason}.${rollbackHint}`);
|
|
3815
|
-
}
|
|
3816
|
-
}
|
|
3817
|
-
} else {
|
|
3818
|
-
unchangedFiles += 1;
|
|
3890
|
+
|
|
3891
|
+
// src/commands/migration-file-executor.ts
|
|
3892
|
+
async function rollbackWrittenEntries(wroteEntries) {
|
|
3893
|
+
let rollbackCount = 0;
|
|
3894
|
+
for (const written of [...wroteEntries].reverse()) {
|
|
3895
|
+
try {
|
|
3896
|
+
await _fsextra2.default.writeFile(written.file, written.source, "utf8");
|
|
3897
|
+
written.entry.written = false;
|
|
3898
|
+
written.entry.rolledBack = true;
|
|
3899
|
+
rollbackCount += 1;
|
|
3900
|
+
} catch (e11) {
|
|
3819
3901
|
}
|
|
3820
3902
|
}
|
|
3821
|
-
return
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
tool: {
|
|
3826
|
-
name: pkgName,
|
|
3827
|
-
version: pkgVersion
|
|
3828
|
-
},
|
|
3903
|
+
return rollbackCount;
|
|
3904
|
+
}
|
|
3905
|
+
async function executeMigrationFile(options) {
|
|
3906
|
+
const {
|
|
3829
3907
|
cwd,
|
|
3908
|
+
file,
|
|
3830
3909
|
dryRun,
|
|
3831
3910
|
rollbackOnError,
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3911
|
+
backupDirectory,
|
|
3912
|
+
wroteEntries
|
|
3913
|
+
} = options;
|
|
3914
|
+
const exists = await _fsextra2.default.pathExists(file);
|
|
3915
|
+
if (!exists) {
|
|
3916
|
+
return {
|
|
3917
|
+
missing: true,
|
|
3918
|
+
changed: false,
|
|
3919
|
+
wrote: false,
|
|
3920
|
+
backupWritten: false
|
|
3921
|
+
};
|
|
3922
|
+
}
|
|
3923
|
+
const source = await _fsextra2.default.readFile(file, "utf8");
|
|
3924
|
+
const migrated = migrateConfigSource(source);
|
|
3925
|
+
const entry = {
|
|
3926
|
+
file,
|
|
3927
|
+
changed: migrated.changed,
|
|
3928
|
+
written: false,
|
|
3929
|
+
rolledBack: false,
|
|
3930
|
+
changes: migrated.changes
|
|
3840
3931
|
};
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
throw new Error(`Unsupported report kind "${report.reportKind}" in ${reportFile}.`);
|
|
3932
|
+
if (!migrated.changed || dryRun) {
|
|
3933
|
+
return {
|
|
3934
|
+
missing: false,
|
|
3935
|
+
changed: migrated.changed,
|
|
3936
|
+
wrote: false,
|
|
3937
|
+
backupWritten: false,
|
|
3938
|
+
entry
|
|
3939
|
+
};
|
|
3850
3940
|
}
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3941
|
+
let backupWritten = false;
|
|
3942
|
+
try {
|
|
3943
|
+
if (backupDirectory) {
|
|
3944
|
+
const backupRelativePath = resolveBackupRelativePath(cwd, file);
|
|
3945
|
+
const backupFile = _pathe2.default.resolve(backupDirectory, backupRelativePath);
|
|
3946
|
+
await _fsextra2.default.ensureDir(_pathe2.default.dirname(backupFile));
|
|
3947
|
+
await _fsextra2.default.writeFile(backupFile, source, "utf8");
|
|
3948
|
+
entry.backupFile = backupFile;
|
|
3949
|
+
backupWritten = true;
|
|
3950
|
+
}
|
|
3951
|
+
await _fsextra2.default.writeFile(file, migrated.code, "utf8");
|
|
3952
|
+
entry.written = true;
|
|
3953
|
+
wroteEntries.push({ file, source, entry });
|
|
3954
|
+
return {
|
|
3955
|
+
missing: false,
|
|
3956
|
+
changed: true,
|
|
3957
|
+
wrote: true,
|
|
3958
|
+
backupWritten,
|
|
3959
|
+
entry
|
|
3960
|
+
};
|
|
3961
|
+
} catch (error) {
|
|
3962
|
+
const rollbackCount = rollbackOnError && wroteEntries.length > 0 ? await rollbackWrittenEntries(wroteEntries) : 0;
|
|
3963
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
3964
|
+
const rollbackHint = rollbackOnError && rollbackCount > 0 ? ` Rolled back ${rollbackCount} previously written file(s).` : "";
|
|
3965
|
+
throw new Error(`Failed to write migrated config "${file}": ${reason}.${rollbackHint}`);
|
|
3855
3966
|
}
|
|
3856
|
-
|
|
3967
|
+
}
|
|
3968
|
+
async function restoreConfigEntries(entries, dryRun) {
|
|
3857
3969
|
let scannedEntries = 0;
|
|
3858
3970
|
let restorableEntries = 0;
|
|
3859
3971
|
let restoredFiles = 0;
|
|
@@ -3882,6 +3994,93 @@ async function restoreConfigFiles(options) {
|
|
|
3882
3994
|
restoredFiles += 1;
|
|
3883
3995
|
restored.push(targetFile);
|
|
3884
3996
|
}
|
|
3997
|
+
return {
|
|
3998
|
+
scannedEntries,
|
|
3999
|
+
restorableEntries,
|
|
4000
|
+
restoredFiles,
|
|
4001
|
+
missingBackups,
|
|
4002
|
+
skippedEntries,
|
|
4003
|
+
restored
|
|
4004
|
+
};
|
|
4005
|
+
}
|
|
4006
|
+
|
|
4007
|
+
// src/commands/migration-report-loader.ts
|
|
4008
|
+
|
|
4009
|
+
async function loadMigrationReportForRestore(reportFile) {
|
|
4010
|
+
const report = await _fsextra2.default.readJSON(reportFile);
|
|
4011
|
+
assertMigrationReportCompatibility(report, reportFile);
|
|
4012
|
+
return {
|
|
4013
|
+
...report.reportKind === void 0 ? {} : { reportKind: report.reportKind },
|
|
4014
|
+
...report.schemaVersion === void 0 ? {} : { schemaVersion: report.schemaVersion },
|
|
4015
|
+
entries: Array.isArray(report.entries) ? report.entries : []
|
|
4016
|
+
};
|
|
4017
|
+
}
|
|
4018
|
+
|
|
4019
|
+
// src/commands/migration-target-resolver.ts
|
|
4020
|
+
async function resolveMigrationTargetFiles(options) {
|
|
4021
|
+
const {
|
|
4022
|
+
cwd,
|
|
4023
|
+
files,
|
|
4024
|
+
workspace,
|
|
4025
|
+
maxDepth,
|
|
4026
|
+
include,
|
|
4027
|
+
exclude
|
|
4028
|
+
} = options;
|
|
4029
|
+
const resolvedMaxDepth = _nullishCoalesce(maxDepth, () => ( DEFAULT_WORKSPACE_MAX_DEPTH));
|
|
4030
|
+
const discoveredTargetFiles = files && files.length > 0 ? resolveTargetFiles(cwd, files) : workspace ? await collectWorkspaceConfigFiles(cwd, resolvedMaxDepth) : resolveTargetFiles(cwd);
|
|
4031
|
+
return filterTargetFiles(discoveredTargetFiles, cwd, include, exclude);
|
|
4032
|
+
}
|
|
4033
|
+
|
|
4034
|
+
// src/commands/migrate-config.ts
|
|
4035
|
+
async function migrateConfigFiles(options) {
|
|
4036
|
+
const cwd = _pathe2.default.resolve(options.cwd);
|
|
4037
|
+
const dryRun = _nullishCoalesce(options.dryRun, () => ( false));
|
|
4038
|
+
const rollbackOnError = _nullishCoalesce(options.rollbackOnError, () => ( true));
|
|
4039
|
+
const backupDirectory = options.backupDir ? _pathe2.default.resolve(cwd, options.backupDir) : void 0;
|
|
4040
|
+
const targetFiles = await resolveMigrationTargetFiles({
|
|
4041
|
+
cwd,
|
|
4042
|
+
files: options.files,
|
|
4043
|
+
workspace: options.workspace,
|
|
4044
|
+
maxDepth: options.maxDepth,
|
|
4045
|
+
include: options.include,
|
|
4046
|
+
exclude: options.exclude
|
|
4047
|
+
});
|
|
4048
|
+
const aggregation = createMigrationAggregationState();
|
|
4049
|
+
const wroteEntries = [];
|
|
4050
|
+
for (const file of targetFiles) {
|
|
4051
|
+
const result = await executeMigrationFile({
|
|
4052
|
+
cwd,
|
|
4053
|
+
file,
|
|
4054
|
+
dryRun,
|
|
4055
|
+
rollbackOnError,
|
|
4056
|
+
wroteEntries,
|
|
4057
|
+
...backupDirectory ? { backupDirectory } : {}
|
|
4058
|
+
});
|
|
4059
|
+
collectMigrationExecutionResult(aggregation, result);
|
|
4060
|
+
}
|
|
4061
|
+
return buildMigrationReport(aggregation, {
|
|
4062
|
+
cwd,
|
|
4063
|
+
dryRun,
|
|
4064
|
+
rollbackOnError,
|
|
4065
|
+
...backupDirectory ? { backupDirectory } : {},
|
|
4066
|
+
toolName: pkgName,
|
|
4067
|
+
toolVersion: pkgVersion
|
|
4068
|
+
});
|
|
4069
|
+
}
|
|
4070
|
+
async function restoreConfigFiles(options) {
|
|
4071
|
+
const cwd = _pathe2.default.resolve(options.cwd);
|
|
4072
|
+
const dryRun = _nullishCoalesce(options.dryRun, () => ( false));
|
|
4073
|
+
const strict = _nullishCoalesce(options.strict, () => ( false));
|
|
4074
|
+
const reportFile = _pathe2.default.resolve(cwd, options.reportFile);
|
|
4075
|
+
const report = await loadMigrationReportForRestore(reportFile);
|
|
4076
|
+
const {
|
|
4077
|
+
scannedEntries,
|
|
4078
|
+
restorableEntries,
|
|
4079
|
+
restoredFiles,
|
|
4080
|
+
missingBackups,
|
|
4081
|
+
skippedEntries,
|
|
4082
|
+
restored
|
|
4083
|
+
} = await restoreConfigEntries(report.entries, dryRun);
|
|
3885
4084
|
if (strict && missingBackups > 0) {
|
|
3886
4085
|
throw new Error(`Restore failed: ${missingBackups} backup file(s) missing in report ${reportFile}.`);
|
|
3887
4086
|
}
|
|
@@ -3901,105 +4100,7 @@ async function restoreConfigFiles(options) {
|
|
|
3901
4100
|
};
|
|
3902
4101
|
}
|
|
3903
4102
|
|
|
3904
|
-
// src/
|
|
3905
|
-
|
|
3906
|
-
var _config = require('@tailwindcss-mangle/config');
|
|
3907
|
-
|
|
3908
|
-
// ../../node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.mjs
|
|
3909
|
-
function isPlainObject(value) {
|
|
3910
|
-
if (value === null || typeof value !== "object") {
|
|
3911
|
-
return false;
|
|
3912
|
-
}
|
|
3913
|
-
const prototype = Object.getPrototypeOf(value);
|
|
3914
|
-
if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) {
|
|
3915
|
-
return false;
|
|
3916
|
-
}
|
|
3917
|
-
if (Symbol.iterator in value) {
|
|
3918
|
-
return false;
|
|
3919
|
-
}
|
|
3920
|
-
if (Symbol.toStringTag in value) {
|
|
3921
|
-
return Object.prototype.toString.call(value) === "[object Module]";
|
|
3922
|
-
}
|
|
3923
|
-
return true;
|
|
3924
|
-
}
|
|
3925
|
-
function _defu(baseObject, defaults, namespace = ".", merger) {
|
|
3926
|
-
if (!isPlainObject(defaults)) {
|
|
3927
|
-
return _defu(baseObject, {}, namespace, merger);
|
|
3928
|
-
}
|
|
3929
|
-
const object = Object.assign({}, defaults);
|
|
3930
|
-
for (const key in baseObject) {
|
|
3931
|
-
if (key === "__proto__" || key === "constructor") {
|
|
3932
|
-
continue;
|
|
3933
|
-
}
|
|
3934
|
-
const value = baseObject[key];
|
|
3935
|
-
if (value === null || value === void 0) {
|
|
3936
|
-
continue;
|
|
3937
|
-
}
|
|
3938
|
-
if (merger && merger(object, key, value, namespace)) {
|
|
3939
|
-
continue;
|
|
3940
|
-
}
|
|
3941
|
-
if (Array.isArray(value) && Array.isArray(object[key])) {
|
|
3942
|
-
object[key] = [...value, ...object[key]];
|
|
3943
|
-
} else if (isPlainObject(value) && isPlainObject(object[key])) {
|
|
3944
|
-
object[key] = _defu(
|
|
3945
|
-
value,
|
|
3946
|
-
object[key],
|
|
3947
|
-
(namespace ? `${namespace}.` : "") + key.toString(),
|
|
3948
|
-
merger
|
|
3949
|
-
);
|
|
3950
|
-
} else {
|
|
3951
|
-
object[key] = value;
|
|
3952
|
-
}
|
|
3953
|
-
}
|
|
3954
|
-
return object;
|
|
3955
|
-
}
|
|
3956
|
-
function createDefu(merger) {
|
|
3957
|
-
return (...arguments_) => (
|
|
3958
|
-
// eslint-disable-next-line unicorn/no-array-reduce
|
|
3959
|
-
arguments_.reduce((p, c) => _defu(p, c, "", merger), {})
|
|
3960
|
-
);
|
|
3961
|
-
}
|
|
3962
|
-
var defu = createDefu();
|
|
3963
|
-
var defuFn = createDefu((object, key, currentValue) => {
|
|
3964
|
-
if (object[key] !== void 0 && typeof currentValue === "function") {
|
|
3965
|
-
object[key] = currentValue(object[key]);
|
|
3966
|
-
return true;
|
|
3967
|
-
}
|
|
3968
|
-
});
|
|
3969
|
-
var defuArrayFn = createDefu((object, key, currentValue) => {
|
|
3970
|
-
if (Array.isArray(object[key]) && typeof currentValue === "function") {
|
|
3971
|
-
object[key] = currentValue(object[key]);
|
|
3972
|
-
return true;
|
|
3973
|
-
}
|
|
3974
|
-
});
|
|
3975
|
-
|
|
3976
|
-
// ../shared/src/utils.ts
|
|
3977
|
-
var defuOverrideArray = createDefu((obj, key, value) => {
|
|
3978
|
-
if (Array.isArray(obj[key]) && Array.isArray(value)) {
|
|
3979
|
-
obj[key] = value;
|
|
3980
|
-
return true;
|
|
3981
|
-
}
|
|
3982
|
-
});
|
|
3983
|
-
var preserveClassNames = [
|
|
3984
|
-
// https://tailwindcss.com/docs/transition-timing-function start
|
|
3985
|
-
// https://github.com/sonofmagic/tailwindcss-mangle/issues/21
|
|
3986
|
-
"ease-out",
|
|
3987
|
-
"ease-linear",
|
|
3988
|
-
"ease-in",
|
|
3989
|
-
"ease-in-out"
|
|
3990
|
-
// https://tailwindcss.com/docs/transition-timing-function end
|
|
3991
|
-
];
|
|
3992
|
-
var preserveClassNamesMap = preserveClassNames.reduce((acc, cur) => {
|
|
3993
|
-
acc[cur] = true;
|
|
3994
|
-
return acc;
|
|
3995
|
-
}, {});
|
|
3996
|
-
var acceptChars = [..."abcdefghijklmnopqrstuvwxyz"];
|
|
3997
|
-
|
|
3998
|
-
// src/cli/commands.ts
|
|
3999
|
-
var _cac = require('cac'); var _cac2 = _interopRequireDefault(_cac);
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
var tailwindcssPatchCommands = ["install", "extract", "tokens", "init", "migrate", "restore", "validate", "status"];
|
|
4103
|
+
// src/commands/validate.ts
|
|
4003
4104
|
var VALIDATE_EXIT_CODES = {
|
|
4004
4105
|
OK: 0,
|
|
4005
4106
|
REPORT_INCOMPATIBLE: 21,
|
|
@@ -4014,7 +4115,7 @@ var VALIDATE_FAILURE_REASONS = [
|
|
|
4014
4115
|
"unknown-error"
|
|
4015
4116
|
];
|
|
4016
4117
|
var IO_ERROR_CODES = /* @__PURE__ */ new Set(["ENOENT", "EACCES", "EPERM", "EISDIR", "ENOTDIR", "EMFILE", "ENFILE"]);
|
|
4017
|
-
function
|
|
4118
|
+
function isNodeError2(error) {
|
|
4018
4119
|
return !!error && typeof error === "object" && ("code" in error || "message" in error);
|
|
4019
4120
|
}
|
|
4020
4121
|
function classifyValidateError(error) {
|
|
@@ -4033,7 +4134,7 @@ function classifyValidateError(error) {
|
|
|
4033
4134
|
message
|
|
4034
4135
|
};
|
|
4035
4136
|
}
|
|
4036
|
-
if (
|
|
4137
|
+
if (isNodeError2(error) && typeof error.code === "string" && IO_ERROR_CODES.has(error.code)) {
|
|
4037
4138
|
return {
|
|
4038
4139
|
reason: "io-error",
|
|
4039
4140
|
exitCode: VALIDATE_EXIT_CODES.IO_ERROR,
|
|
@@ -4056,6 +4157,17 @@ var ValidateCommandError = class extends Error {
|
|
|
4056
4157
|
this.exitCode = summary.exitCode;
|
|
4057
4158
|
}
|
|
4058
4159
|
};
|
|
4160
|
+
|
|
4161
|
+
// src/commands/types.ts
|
|
4162
|
+
var tailwindcssPatchCommands = ["install", "extract", "tokens", "init", "migrate", "restore", "validate", "status"];
|
|
4163
|
+
|
|
4164
|
+
// src/commands/cli.ts
|
|
4165
|
+
var _cac = require('cac'); var _cac2 = _interopRequireDefault(_cac);
|
|
4166
|
+
|
|
4167
|
+
// src/commands/command-definitions.ts
|
|
4168
|
+
|
|
4169
|
+
|
|
4170
|
+
// src/commands/token-output.ts
|
|
4059
4171
|
var TOKEN_FORMATS = ["json", "lines", "grouped-json"];
|
|
4060
4172
|
var DEFAULT_TOKEN_REPORT = ".tw-patch/tw-token-report.json";
|
|
4061
4173
|
function formatTokenLine(entry) {
|
|
@@ -4077,68 +4189,8 @@ function formatGroupedPreview(map, limit = 3) {
|
|
|
4077
4189
|
moreFiles: Math.max(0, files.length - limit)
|
|
4078
4190
|
};
|
|
4079
4191
|
}
|
|
4080
|
-
|
|
4081
|
-
|
|
4082
|
-
return _process2.default.cwd();
|
|
4083
|
-
}
|
|
4084
|
-
return _pathe2.default.resolve(rawCwd);
|
|
4085
|
-
}
|
|
4086
|
-
function createDefaultRunner(factory) {
|
|
4087
|
-
let promise;
|
|
4088
|
-
return () => {
|
|
4089
|
-
if (!promise) {
|
|
4090
|
-
promise = factory();
|
|
4091
|
-
}
|
|
4092
|
-
return promise;
|
|
4093
|
-
};
|
|
4094
|
-
}
|
|
4095
|
-
async function loadPatchOptionsForCwd(cwd, overrides) {
|
|
4096
|
-
const { config } = await _config.getConfig.call(void 0, cwd);
|
|
4097
|
-
const legacyConfig = config;
|
|
4098
|
-
const base = _optionalChain([config, 'optionalAccess', _144 => _144.registry]) ? fromUnifiedConfig(config.registry) : _optionalChain([legacyConfig, 'optionalAccess', _145 => _145.patch]) ? fromLegacyOptions({ patch: legacyConfig.patch }) : {};
|
|
4099
|
-
const merged = defu(_nullishCoalesce(overrides, () => ( {})), base);
|
|
4100
|
-
return merged;
|
|
4101
|
-
}
|
|
4102
|
-
function createCommandContext(cli, command, commandName, args, cwd) {
|
|
4103
|
-
let cachedOptions;
|
|
4104
|
-
let cachedPatcher;
|
|
4105
|
-
let cachedConfig;
|
|
4106
|
-
const loadPatchOptionsForContext = (overrides) => {
|
|
4107
|
-
if (overrides) {
|
|
4108
|
-
return loadPatchOptionsForCwd(cwd, overrides);
|
|
4109
|
-
}
|
|
4110
|
-
if (!cachedOptions) {
|
|
4111
|
-
cachedOptions = loadPatchOptionsForCwd(cwd);
|
|
4112
|
-
}
|
|
4113
|
-
return cachedOptions;
|
|
4114
|
-
};
|
|
4115
|
-
const createPatcherForContext = async (overrides) => {
|
|
4116
|
-
if (overrides) {
|
|
4117
|
-
const patchOptions = await loadPatchOptionsForCwd(cwd, overrides);
|
|
4118
|
-
return new TailwindcssPatcher(patchOptions);
|
|
4119
|
-
}
|
|
4120
|
-
if (!cachedPatcher) {
|
|
4121
|
-
cachedPatcher = loadPatchOptionsForContext().then((options) => new TailwindcssPatcher(options));
|
|
4122
|
-
}
|
|
4123
|
-
return cachedPatcher;
|
|
4124
|
-
};
|
|
4125
|
-
return {
|
|
4126
|
-
cli,
|
|
4127
|
-
command,
|
|
4128
|
-
commandName,
|
|
4129
|
-
args,
|
|
4130
|
-
cwd,
|
|
4131
|
-
logger: logger_default,
|
|
4132
|
-
loadConfig: () => {
|
|
4133
|
-
if (!cachedConfig) {
|
|
4134
|
-
cachedConfig = _config.getConfig.call(void 0, cwd);
|
|
4135
|
-
}
|
|
4136
|
-
return cachedConfig;
|
|
4137
|
-
},
|
|
4138
|
-
loadPatchOptions: loadPatchOptionsForContext,
|
|
4139
|
-
createPatcher: createPatcherForContext
|
|
4140
|
-
};
|
|
4141
|
-
}
|
|
4192
|
+
|
|
4193
|
+
// src/commands/command-definitions.ts
|
|
4142
4194
|
function createCwdOptionDefinition(description = "Working directory") {
|
|
4143
4195
|
return {
|
|
4144
4196
|
flags: "--cwd <dir>",
|
|
@@ -4228,6 +4280,8 @@ function buildDefaultCommandDefinitions() {
|
|
|
4228
4280
|
}
|
|
4229
4281
|
};
|
|
4230
4282
|
}
|
|
4283
|
+
|
|
4284
|
+
// src/commands/command-metadata.ts
|
|
4231
4285
|
function addPrefixIfMissing(value, prefix) {
|
|
4232
4286
|
if (!prefix || value.startsWith(prefix)) {
|
|
4233
4287
|
return value;
|
|
@@ -4255,30 +4309,93 @@ function resolveOptionDefinitions(defaults, override) {
|
|
|
4255
4309
|
}
|
|
4256
4310
|
return [...defaults, ...customDefs];
|
|
4257
4311
|
}
|
|
4258
|
-
function
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
|
|
4312
|
+
function resolveCommandMetadata(command, mountOptions, prefix, defaults) {
|
|
4313
|
+
const names = resolveCommandNames(command, mountOptions, prefix);
|
|
4314
|
+
const definition = defaults[command];
|
|
4315
|
+
const override = _optionalChain([mountOptions, 'access', _150 => _150.commandOptions, 'optionalAccess', _151 => _151[command]]);
|
|
4316
|
+
const description = _nullishCoalesce(_optionalChain([override, 'optionalAccess', _152 => _152.description]), () => ( definition.description));
|
|
4317
|
+
const optionDefs = resolveOptionDefinitions(definition.optionDefs, override);
|
|
4318
|
+
return { ...names, description, optionDefs };
|
|
4319
|
+
}
|
|
4320
|
+
function applyCommandOptions(command, optionDefs) {
|
|
4321
|
+
for (const option of optionDefs) {
|
|
4322
|
+
command.option(option.flags, _nullishCoalesce(option.description, () => ( "")), option.config);
|
|
4323
|
+
}
|
|
4324
|
+
}
|
|
4325
|
+
|
|
4326
|
+
// src/commands/command-context.ts
|
|
4327
|
+
|
|
4328
|
+
|
|
4329
|
+
function resolveCommandCwd(rawCwd) {
|
|
4330
|
+
if (!rawCwd) {
|
|
4331
|
+
return _process2.default.cwd();
|
|
4332
|
+
}
|
|
4333
|
+
return _pathe2.default.resolve(rawCwd);
|
|
4334
|
+
}
|
|
4335
|
+
function createMemoizedPromiseRunner(factory) {
|
|
4336
|
+
let promise;
|
|
4337
|
+
return () => {
|
|
4338
|
+
if (!promise) {
|
|
4339
|
+
promise = factory();
|
|
4340
|
+
}
|
|
4341
|
+
return promise;
|
|
4342
|
+
};
|
|
4343
|
+
}
|
|
4344
|
+
function createTailwindcssPatchCommandContext(cli, command, commandName, args, cwd) {
|
|
4345
|
+
const loadCachedConfig = createMemoizedPromiseRunner(
|
|
4346
|
+
() => loadWorkspaceConfigModule().then((mod) => mod.getConfig(cwd))
|
|
4347
|
+
);
|
|
4348
|
+
const loadCachedPatchOptions = createMemoizedPromiseRunner(
|
|
4349
|
+
() => loadPatchOptionsForWorkspace(cwd)
|
|
4350
|
+
);
|
|
4351
|
+
const createCachedPatcher = createMemoizedPromiseRunner(async () => {
|
|
4352
|
+
const patchOptions = await loadCachedPatchOptions();
|
|
4353
|
+
return new TailwindcssPatcher(patchOptions);
|
|
4354
|
+
});
|
|
4355
|
+
const loadPatchOptionsForContext = (overrides) => {
|
|
4356
|
+
if (overrides) {
|
|
4357
|
+
return loadPatchOptionsForWorkspace(cwd, overrides);
|
|
4358
|
+
}
|
|
4359
|
+
return loadCachedPatchOptions();
|
|
4360
|
+
};
|
|
4361
|
+
const createPatcherForContext = async (overrides) => {
|
|
4362
|
+
if (overrides) {
|
|
4363
|
+
const patchOptions = await loadPatchOptionsForWorkspace(cwd, overrides);
|
|
4364
|
+
return new TailwindcssPatcher(patchOptions);
|
|
4365
|
+
}
|
|
4366
|
+
return createCachedPatcher();
|
|
4367
|
+
};
|
|
4368
|
+
return {
|
|
4369
|
+
cli,
|
|
4370
|
+
command,
|
|
4371
|
+
commandName,
|
|
4372
|
+
args,
|
|
4373
|
+
cwd,
|
|
4374
|
+
logger: logger_default,
|
|
4375
|
+
loadConfig: loadCachedConfig,
|
|
4376
|
+
loadPatchOptions: loadPatchOptionsForContext,
|
|
4377
|
+
createPatcher: createPatcherForContext
|
|
4378
|
+
};
|
|
4262
4379
|
}
|
|
4380
|
+
|
|
4381
|
+
// src/commands/command-runtime.ts
|
|
4263
4382
|
function runWithCommandHandler(cli, command, commandName, args, handler, defaultHandler) {
|
|
4264
|
-
const cwd =
|
|
4265
|
-
const context =
|
|
4266
|
-
const runDefault =
|
|
4383
|
+
const cwd = resolveCommandCwd(args.cwd);
|
|
4384
|
+
const context = createTailwindcssPatchCommandContext(cli, command, commandName, args, cwd);
|
|
4385
|
+
const runDefault = createMemoizedPromiseRunner(() => defaultHandler(context));
|
|
4267
4386
|
if (!handler) {
|
|
4268
4387
|
return runDefault();
|
|
4269
4388
|
}
|
|
4270
4389
|
return handler(context, runDefault);
|
|
4271
4390
|
}
|
|
4272
|
-
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
async function installCommandDefaultHandler(ctx) {
|
|
4281
|
-
const patcher = await ctx.createPatcher();
|
|
4391
|
+
|
|
4392
|
+
// src/commands/basic-handlers.ts
|
|
4393
|
+
|
|
4394
|
+
|
|
4395
|
+
|
|
4396
|
+
var DEFAULT_CONFIG_NAME = "tailwindcss-mangle";
|
|
4397
|
+
async function installCommandDefaultHandler(_ctx) {
|
|
4398
|
+
const patcher = new TailwindcssPatcher();
|
|
4282
4399
|
await patcher.patch();
|
|
4283
4400
|
logger_default.success("Tailwind CSS runtime patched successfully.");
|
|
4284
4401
|
}
|
|
@@ -4379,60 +4496,94 @@ async function tokensCommandDefaultHandler(ctx) {
|
|
|
4379
4496
|
return report;
|
|
4380
4497
|
}
|
|
4381
4498
|
async function initCommandDefaultHandler(ctx) {
|
|
4382
|
-
await
|
|
4383
|
-
|
|
4499
|
+
const configModule = await loadWorkspaceConfigModule();
|
|
4500
|
+
await configModule.initConfig(ctx.cwd);
|
|
4501
|
+
const configName = configModule.CONFIG_NAME || DEFAULT_CONFIG_NAME;
|
|
4502
|
+
logger_default.success(`\u2728 ${configName}.config.ts initialized!`);
|
|
4384
4503
|
}
|
|
4385
|
-
|
|
4386
|
-
|
|
4387
|
-
|
|
4388
|
-
|
|
4389
|
-
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
|
|
4504
|
+
|
|
4505
|
+
// src/commands/migration-args.ts
|
|
4506
|
+
function normalizePatternArgs(value) {
|
|
4507
|
+
if (!value) {
|
|
4508
|
+
return void 0;
|
|
4509
|
+
}
|
|
4510
|
+
const raw = Array.isArray(value) ? value : [value];
|
|
4511
|
+
const values = raw.flatMap((item) => item.split(",")).map((item) => item.trim()).filter(Boolean);
|
|
4512
|
+
return values.length > 0 ? values : void 0;
|
|
4513
|
+
}
|
|
4514
|
+
function parseMaxDepth(value) {
|
|
4515
|
+
if (value === void 0) {
|
|
4516
|
+
return {
|
|
4517
|
+
maxDepth: void 0,
|
|
4518
|
+
hasInvalidMaxDepth: false
|
|
4519
|
+
};
|
|
4520
|
+
}
|
|
4521
|
+
const parsed = Number(value);
|
|
4522
|
+
if (!Number.isFinite(parsed) || parsed < 0) {
|
|
4523
|
+
return {
|
|
4524
|
+
maxDepth: void 0,
|
|
4525
|
+
hasInvalidMaxDepth: true
|
|
4526
|
+
};
|
|
4527
|
+
}
|
|
4528
|
+
return {
|
|
4529
|
+
maxDepth: Math.floor(parsed),
|
|
4530
|
+
hasInvalidMaxDepth: false
|
|
4394
4531
|
};
|
|
4532
|
+
}
|
|
4533
|
+
function resolveMigrateCommandArgs(args) {
|
|
4395
4534
|
const include = normalizePatternArgs(args.include);
|
|
4396
4535
|
const exclude = normalizePatternArgs(args.exclude);
|
|
4397
|
-
const
|
|
4398
|
-
const maxDepth = parsedMaxDepth !== void 0 && Number.isFinite(parsedMaxDepth) && parsedMaxDepth >= 0 ? Math.floor(parsedMaxDepth) : void 0;
|
|
4536
|
+
const { maxDepth, hasInvalidMaxDepth } = parseMaxDepth(args.maxDepth);
|
|
4399
4537
|
const checkMode = _nullishCoalesce(args.check, () => ( false));
|
|
4400
4538
|
const dryRun = _nullishCoalesce(args.dryRun, () => ( checkMode));
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
|
-
|
|
4405
|
-
|
|
4539
|
+
return {
|
|
4540
|
+
include,
|
|
4541
|
+
exclude,
|
|
4542
|
+
maxDepth,
|
|
4543
|
+
checkMode,
|
|
4406
4544
|
dryRun,
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
|
|
4410
|
-
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4418
|
-
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
|
|
4422
|
-
|
|
4423
|
-
|
|
4424
|
-
|
|
4425
|
-
|
|
4426
|
-
|
|
4427
|
-
|
|
4428
|
-
|
|
4429
|
-
|
|
4430
|
-
|
|
4431
|
-
|
|
4432
|
-
|
|
4433
|
-
|
|
4545
|
+
hasInvalidMaxDepth
|
|
4546
|
+
};
|
|
4547
|
+
}
|
|
4548
|
+
function resolveRestoreCommandArgs(args) {
|
|
4549
|
+
return {
|
|
4550
|
+
reportFile: _nullishCoalesce(args.reportFile, () => ( ".tw-patch/migrate-report.json")),
|
|
4551
|
+
dryRun: _nullishCoalesce(args.dryRun, () => ( false)),
|
|
4552
|
+
strict: _nullishCoalesce(args.strict, () => ( false))
|
|
4553
|
+
};
|
|
4554
|
+
}
|
|
4555
|
+
function resolveValidateCommandArgs(args) {
|
|
4556
|
+
return {
|
|
4557
|
+
reportFile: _nullishCoalesce(args.reportFile, () => ( ".tw-patch/migrate-report.json")),
|
|
4558
|
+
strict: _nullishCoalesce(args.strict, () => ( false))
|
|
4559
|
+
};
|
|
4560
|
+
}
|
|
4561
|
+
|
|
4562
|
+
// src/commands/migration-output.ts
|
|
4563
|
+
|
|
4564
|
+
|
|
4565
|
+
|
|
4566
|
+
function formatPathForLog(file) {
|
|
4567
|
+
return file.replace(_process2.default.cwd(), ".");
|
|
4568
|
+
}
|
|
4569
|
+
function createMigrationCheckFailureError(changedFiles) {
|
|
4570
|
+
return new Error(`Migration check failed: ${changedFiles} file(s) still need migration.`);
|
|
4571
|
+
}
|
|
4572
|
+
async function writeMigrationReportFile(cwd, reportFile, report) {
|
|
4573
|
+
const reportPath = _pathe2.default.resolve(cwd, reportFile);
|
|
4574
|
+
await _fsextra2.default.ensureDir(_pathe2.default.dirname(reportPath));
|
|
4575
|
+
await _fsextra2.default.writeJSON(reportPath, report, { spaces: 2 });
|
|
4576
|
+
logger_default.info(`Migration report written: ${formatPathForLog(reportPath)}`);
|
|
4577
|
+
}
|
|
4578
|
+
function logMigrationReportAsJson(report) {
|
|
4579
|
+
logger_default.log(JSON.stringify(report, null, 2));
|
|
4580
|
+
}
|
|
4581
|
+
function logNoMigrationConfigFilesWarning() {
|
|
4582
|
+
logger_default.warn("No config files found for migration.");
|
|
4583
|
+
}
|
|
4584
|
+
function logMigrationEntries(report, dryRun) {
|
|
4434
4585
|
for (const entry of report.entries) {
|
|
4435
|
-
const fileLabel = entry.file
|
|
4586
|
+
const fileLabel = formatPathForLog(entry.file);
|
|
4436
4587
|
if (!entry.changed) {
|
|
4437
4588
|
logger_default.info(`No changes: ${fileLabel}`);
|
|
4438
4589
|
continue;
|
|
@@ -4446,105 +4597,156 @@ async function migrateCommandDefaultHandler(ctx) {
|
|
|
4446
4597
|
logger_default.info(` - ${change}`);
|
|
4447
4598
|
}
|
|
4448
4599
|
if (entry.backupFile) {
|
|
4449
|
-
logger_default.info(` - backup: ${entry.backupFile
|
|
4600
|
+
logger_default.info(` - backup: ${formatPathForLog(entry.backupFile)}`);
|
|
4450
4601
|
}
|
|
4451
4602
|
}
|
|
4603
|
+
}
|
|
4604
|
+
function logMigrationSummary(report) {
|
|
4452
4605
|
logger_default.info(
|
|
4453
4606
|
`Migration summary: scanned=${report.scannedFiles}, changed=${report.changedFiles}, written=${report.writtenFiles}, backups=${report.backupsWritten}, missing=${report.missingFiles}, unchanged=${report.unchangedFiles}`
|
|
4454
4607
|
);
|
|
4455
|
-
if (checkMode && report.changedFiles > 0) {
|
|
4456
|
-
throw new Error(`Migration check failed: ${report.changedFiles} file(s) still need migration.`);
|
|
4457
|
-
}
|
|
4458
|
-
return report;
|
|
4459
4608
|
}
|
|
4460
|
-
|
|
4461
|
-
|
|
4462
|
-
|
|
4463
|
-
|
|
4464
|
-
cwd: ctx.cwd,
|
|
4465
|
-
reportFile,
|
|
4466
|
-
dryRun: _nullishCoalesce(args.dryRun, () => ( false)),
|
|
4467
|
-
strict: _nullishCoalesce(args.strict, () => ( false))
|
|
4468
|
-
});
|
|
4469
|
-
if (args.json) {
|
|
4470
|
-
logger_default.log(JSON.stringify(result, null, 2));
|
|
4471
|
-
return result;
|
|
4472
|
-
}
|
|
4609
|
+
function logRestoreResultAsJson(result) {
|
|
4610
|
+
logger_default.log(JSON.stringify(result, null, 2));
|
|
4611
|
+
}
|
|
4612
|
+
function logRestoreSummary(result) {
|
|
4473
4613
|
logger_default.info(
|
|
4474
4614
|
`Restore summary: scanned=${result.scannedEntries}, restorable=${result.restorableEntries}, restored=${result.restoredFiles}, missingBackups=${result.missingBackups}, skipped=${result.skippedEntries}`
|
|
4475
4615
|
);
|
|
4476
4616
|
if (result.restored.length > 0) {
|
|
4477
4617
|
const preview = result.restored.slice(0, 5);
|
|
4478
4618
|
for (const file of preview) {
|
|
4479
|
-
logger_default.info(` - ${file
|
|
4619
|
+
logger_default.info(` - ${formatPathForLog(file)}`);
|
|
4480
4620
|
}
|
|
4481
4621
|
if (result.restored.length > preview.length) {
|
|
4482
4622
|
logger_default.info(` ...and ${result.restored.length - preview.length} more`);
|
|
4483
4623
|
}
|
|
4484
4624
|
}
|
|
4485
|
-
return result;
|
|
4486
4625
|
}
|
|
4487
|
-
|
|
4626
|
+
function logValidateSuccessAsJson(result) {
|
|
4627
|
+
const payload = {
|
|
4628
|
+
ok: true,
|
|
4629
|
+
...result
|
|
4630
|
+
};
|
|
4631
|
+
logger_default.log(JSON.stringify(payload, null, 2));
|
|
4632
|
+
}
|
|
4633
|
+
function logValidateSuccessSummary(result) {
|
|
4634
|
+
logger_default.success(
|
|
4635
|
+
`Migration report validated: scanned=${result.scannedEntries}, restorable=${result.restorableEntries}, missingBackups=${result.missingBackups}, skipped=${result.skippedEntries}`
|
|
4636
|
+
);
|
|
4637
|
+
if (result.reportKind || result.reportSchemaVersion !== void 0) {
|
|
4638
|
+
const kind = _nullishCoalesce(result.reportKind, () => ( "unknown"));
|
|
4639
|
+
const schema = result.reportSchemaVersion === void 0 ? "unknown" : String(result.reportSchemaVersion);
|
|
4640
|
+
logger_default.info(` metadata: kind=${kind}, schema=${schema}`);
|
|
4641
|
+
}
|
|
4642
|
+
}
|
|
4643
|
+
function logValidateFailureAsJson(summary) {
|
|
4644
|
+
const payload = {
|
|
4645
|
+
ok: false,
|
|
4646
|
+
reason: summary.reason,
|
|
4647
|
+
exitCode: summary.exitCode,
|
|
4648
|
+
message: summary.message
|
|
4649
|
+
};
|
|
4650
|
+
logger_default.log(JSON.stringify(payload, null, 2));
|
|
4651
|
+
}
|
|
4652
|
+
function logValidateFailureSummary(summary) {
|
|
4653
|
+
logger_default.error(`Validation failed [${summary.reason}] (exit ${summary.exitCode}): ${summary.message}`);
|
|
4654
|
+
}
|
|
4655
|
+
|
|
4656
|
+
// src/commands/migrate-handler.ts
|
|
4657
|
+
async function migrateCommandDefaultHandler(ctx) {
|
|
4488
4658
|
const { args } = ctx;
|
|
4489
|
-
const
|
|
4490
|
-
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
|
|
4494
|
-
|
|
4495
|
-
|
|
4496
|
-
|
|
4497
|
-
|
|
4498
|
-
|
|
4499
|
-
|
|
4500
|
-
|
|
4501
|
-
|
|
4502
|
-
|
|
4503
|
-
|
|
4659
|
+
const {
|
|
4660
|
+
include,
|
|
4661
|
+
exclude,
|
|
4662
|
+
maxDepth,
|
|
4663
|
+
checkMode,
|
|
4664
|
+
dryRun,
|
|
4665
|
+
hasInvalidMaxDepth
|
|
4666
|
+
} = resolveMigrateCommandArgs(args);
|
|
4667
|
+
if (args.workspace && hasInvalidMaxDepth) {
|
|
4668
|
+
logger_default.warn(`Invalid --max-depth value "${String(args.maxDepth)}", fallback to default depth.`);
|
|
4669
|
+
}
|
|
4670
|
+
const report = await migrateConfigFiles({
|
|
4671
|
+
cwd: ctx.cwd,
|
|
4672
|
+
dryRun,
|
|
4673
|
+
...args.config ? { files: [args.config] } : {},
|
|
4674
|
+
...args.workspace ? { workspace: true } : {},
|
|
4675
|
+
...args.workspace && maxDepth !== void 0 ? { maxDepth } : {},
|
|
4676
|
+
...args.backupDir ? { backupDir: args.backupDir } : {},
|
|
4677
|
+
...include ? { include } : {},
|
|
4678
|
+
...exclude ? { exclude } : {}
|
|
4679
|
+
});
|
|
4680
|
+
if (args.reportFile) {
|
|
4681
|
+
await writeMigrationReportFile(ctx.cwd, args.reportFile, report);
|
|
4682
|
+
}
|
|
4683
|
+
if (args.json) {
|
|
4684
|
+
logMigrationReportAsJson(report);
|
|
4685
|
+
if (checkMode && report.changedFiles > 0) {
|
|
4686
|
+
throw createMigrationCheckFailureError(report.changedFiles);
|
|
4504
4687
|
}
|
|
4505
|
-
|
|
4506
|
-
|
|
4507
|
-
);
|
|
4508
|
-
if (result.reportKind || result.reportSchemaVersion !== void 0) {
|
|
4509
|
-
const kind = _nullishCoalesce(result.reportKind, () => ( "unknown"));
|
|
4510
|
-
const schema = result.reportSchemaVersion === void 0 ? "unknown" : String(result.reportSchemaVersion);
|
|
4511
|
-
logger_default.info(` metadata: kind=${kind}, schema=${schema}`);
|
|
4688
|
+
if (report.scannedFiles === 0) {
|
|
4689
|
+
logNoMigrationConfigFilesWarning();
|
|
4512
4690
|
}
|
|
4691
|
+
return report;
|
|
4692
|
+
}
|
|
4693
|
+
if (report.scannedFiles === 0) {
|
|
4694
|
+
logNoMigrationConfigFilesWarning();
|
|
4695
|
+
return report;
|
|
4696
|
+
}
|
|
4697
|
+
logMigrationEntries(report, dryRun);
|
|
4698
|
+
logMigrationSummary(report);
|
|
4699
|
+
if (checkMode && report.changedFiles > 0) {
|
|
4700
|
+
throw createMigrationCheckFailureError(report.changedFiles);
|
|
4701
|
+
}
|
|
4702
|
+
return report;
|
|
4703
|
+
}
|
|
4704
|
+
|
|
4705
|
+
// src/commands/restore-handler.ts
|
|
4706
|
+
async function restoreCommandDefaultHandler(ctx) {
|
|
4707
|
+
const { args } = ctx;
|
|
4708
|
+
const restoreArgs = resolveRestoreCommandArgs(args);
|
|
4709
|
+
const result = await restoreConfigFiles({
|
|
4710
|
+
cwd: ctx.cwd,
|
|
4711
|
+
reportFile: restoreArgs.reportFile,
|
|
4712
|
+
dryRun: restoreArgs.dryRun,
|
|
4713
|
+
strict: restoreArgs.strict
|
|
4714
|
+
});
|
|
4715
|
+
if (args.json) {
|
|
4716
|
+
logRestoreResultAsJson(result);
|
|
4513
4717
|
return result;
|
|
4514
|
-
} catch (error) {
|
|
4515
|
-
const summary = classifyValidateError(error);
|
|
4516
|
-
if (args.json) {
|
|
4517
|
-
const payload = {
|
|
4518
|
-
ok: false,
|
|
4519
|
-
reason: summary.reason,
|
|
4520
|
-
exitCode: summary.exitCode,
|
|
4521
|
-
message: summary.message
|
|
4522
|
-
};
|
|
4523
|
-
logger_default.log(JSON.stringify(payload, null, 2));
|
|
4524
|
-
} else {
|
|
4525
|
-
logger_default.error(`Validation failed [${summary.reason}] (exit ${summary.exitCode}): ${summary.message}`);
|
|
4526
|
-
}
|
|
4527
|
-
throw new ValidateCommandError(summary, { cause: error });
|
|
4528
4718
|
}
|
|
4719
|
+
logRestoreSummary(result);
|
|
4720
|
+
return result;
|
|
4529
4721
|
}
|
|
4722
|
+
|
|
4723
|
+
// src/commands/status-output.ts
|
|
4530
4724
|
function formatFilesHint(entry) {
|
|
4531
4725
|
if (!entry.files.length) {
|
|
4532
4726
|
return "";
|
|
4533
4727
|
}
|
|
4534
4728
|
return ` (${entry.files.join(", ")})`;
|
|
4535
4729
|
}
|
|
4536
|
-
|
|
4537
|
-
|
|
4538
|
-
|
|
4539
|
-
|
|
4540
|
-
|
|
4541
|
-
|
|
4542
|
-
|
|
4543
|
-
|
|
4544
|
-
|
|
4545
|
-
|
|
4546
|
-
|
|
4547
|
-
logger_default.
|
|
4730
|
+
function formatPackageLabel(report) {
|
|
4731
|
+
return `${_nullishCoalesce(report.package.name, () => ( "tailwindcss"))}@${_nullishCoalesce(report.package.version, () => ( "unknown"))}`;
|
|
4732
|
+
}
|
|
4733
|
+
function partitionStatusEntries(report) {
|
|
4734
|
+
return {
|
|
4735
|
+
applied: report.entries.filter((entry) => entry.status === "applied"),
|
|
4736
|
+
pending: report.entries.filter((entry) => entry.status === "not-applied"),
|
|
4737
|
+
skipped: report.entries.filter((entry) => entry.status === "skipped" || entry.status === "unsupported")
|
|
4738
|
+
};
|
|
4739
|
+
}
|
|
4740
|
+
function logStatusReportAsJson(report) {
|
|
4741
|
+
logger_default.log(JSON.stringify(report, null, 2));
|
|
4742
|
+
}
|
|
4743
|
+
function logStatusReportSummary(report) {
|
|
4744
|
+
const {
|
|
4745
|
+
applied,
|
|
4746
|
+
pending,
|
|
4747
|
+
skipped
|
|
4748
|
+
} = partitionStatusEntries(report);
|
|
4749
|
+
logger_default.info(`Patch status for ${formatPackageLabel(report)} (v${report.majorVersion})`);
|
|
4548
4750
|
if (applied.length) {
|
|
4549
4751
|
logger_default.success("Applied:");
|
|
4550
4752
|
applied.forEach((entry) => logger_default.success(` \u2022 ${entry.name}${formatFilesHint(entry)}`));
|
|
@@ -4552,7 +4754,7 @@ async function statusCommandDefaultHandler(ctx) {
|
|
|
4552
4754
|
if (pending.length) {
|
|
4553
4755
|
logger_default.warn("Needs attention:");
|
|
4554
4756
|
pending.forEach((entry) => {
|
|
4555
|
-
const details = entry.reason ? `
|
|
4757
|
+
const details = entry.reason ? ` - ${entry.reason}` : "";
|
|
4556
4758
|
logger_default.warn(` \u2022 ${entry.name}${formatFilesHint(entry)}${details}`);
|
|
4557
4759
|
});
|
|
4558
4760
|
} else {
|
|
@@ -4561,151 +4763,89 @@ async function statusCommandDefaultHandler(ctx) {
|
|
|
4561
4763
|
if (skipped.length) {
|
|
4562
4764
|
logger_default.info("Skipped:");
|
|
4563
4765
|
skipped.forEach((entry) => {
|
|
4564
|
-
const details = entry.reason ? `
|
|
4766
|
+
const details = entry.reason ? ` - ${entry.reason}` : "";
|
|
4565
4767
|
logger_default.info(` \u2022 ${entry.name}${details}`);
|
|
4566
4768
|
});
|
|
4567
4769
|
}
|
|
4770
|
+
}
|
|
4771
|
+
|
|
4772
|
+
// src/commands/status-handler.ts
|
|
4773
|
+
async function statusCommandDefaultHandler(ctx) {
|
|
4774
|
+
const patcher = await ctx.createPatcher();
|
|
4775
|
+
const report = await patcher.getPatchStatus();
|
|
4776
|
+
if (ctx.args.json) {
|
|
4777
|
+
logStatusReportAsJson(report);
|
|
4778
|
+
return report;
|
|
4779
|
+
}
|
|
4780
|
+
logStatusReportSummary(report);
|
|
4568
4781
|
return report;
|
|
4569
4782
|
}
|
|
4783
|
+
|
|
4784
|
+
// src/commands/validate-handler.ts
|
|
4785
|
+
async function validateCommandDefaultHandler(ctx) {
|
|
4786
|
+
const { args } = ctx;
|
|
4787
|
+
const validateArgs = resolveValidateCommandArgs(args);
|
|
4788
|
+
try {
|
|
4789
|
+
const result = await restoreConfigFiles({
|
|
4790
|
+
cwd: ctx.cwd,
|
|
4791
|
+
reportFile: validateArgs.reportFile,
|
|
4792
|
+
dryRun: true,
|
|
4793
|
+
strict: validateArgs.strict
|
|
4794
|
+
});
|
|
4795
|
+
if (args.json) {
|
|
4796
|
+
logValidateSuccessAsJson(result);
|
|
4797
|
+
return result;
|
|
4798
|
+
}
|
|
4799
|
+
logValidateSuccessSummary(result);
|
|
4800
|
+
return result;
|
|
4801
|
+
} catch (error) {
|
|
4802
|
+
const summary = classifyValidateError(error);
|
|
4803
|
+
if (args.json) {
|
|
4804
|
+
logValidateFailureAsJson(summary);
|
|
4805
|
+
} else {
|
|
4806
|
+
logValidateFailureSummary(summary);
|
|
4807
|
+
}
|
|
4808
|
+
throw new ValidateCommandError(summary, { cause: error });
|
|
4809
|
+
}
|
|
4810
|
+
}
|
|
4811
|
+
|
|
4812
|
+
// src/commands/default-handler-map.ts
|
|
4813
|
+
var defaultCommandHandlers = {
|
|
4814
|
+
install: installCommandDefaultHandler,
|
|
4815
|
+
extract: extractCommandDefaultHandler,
|
|
4816
|
+
tokens: tokensCommandDefaultHandler,
|
|
4817
|
+
init: initCommandDefaultHandler,
|
|
4818
|
+
migrate: migrateCommandDefaultHandler,
|
|
4819
|
+
restore: restoreCommandDefaultHandler,
|
|
4820
|
+
validate: validateCommandDefaultHandler,
|
|
4821
|
+
status: statusCommandDefaultHandler
|
|
4822
|
+
};
|
|
4823
|
+
|
|
4824
|
+
// src/commands/command-registrar.ts
|
|
4825
|
+
function registerTailwindcssPatchCommand(cli, commandName, options, prefix, defaultDefinitions) {
|
|
4826
|
+
const metadata = resolveCommandMetadata(commandName, options, prefix, defaultDefinitions);
|
|
4827
|
+
const command = cli.command(metadata.name, metadata.description);
|
|
4828
|
+
applyCommandOptions(command, metadata.optionDefs);
|
|
4829
|
+
command.action(async (args) => {
|
|
4830
|
+
return runWithCommandHandler(
|
|
4831
|
+
cli,
|
|
4832
|
+
command,
|
|
4833
|
+
commandName,
|
|
4834
|
+
args,
|
|
4835
|
+
_optionalChain([options, 'access', _153 => _153.commandHandlers, 'optionalAccess', _154 => _154[commandName]]),
|
|
4836
|
+
defaultCommandHandlers[commandName]
|
|
4837
|
+
);
|
|
4838
|
+
});
|
|
4839
|
+
metadata.aliases.forEach((alias) => command.alias(alias));
|
|
4840
|
+
}
|
|
4841
|
+
|
|
4842
|
+
// src/commands/cli.ts
|
|
4570
4843
|
function mountTailwindcssPatchCommands(cli, options = {}) {
|
|
4571
4844
|
const prefix = _nullishCoalesce(options.commandPrefix, () => ( ""));
|
|
4572
4845
|
const selectedCommands = _nullishCoalesce(options.commands, () => ( tailwindcssPatchCommands));
|
|
4573
4846
|
const defaultDefinitions = buildDefaultCommandDefinitions();
|
|
4574
|
-
const registrars = {
|
|
4575
|
-
install: () => {
|
|
4576
|
-
const metadata = resolveCommandMetadata("install", options, prefix, defaultDefinitions);
|
|
4577
|
-
const command = cli.command(metadata.name, metadata.description);
|
|
4578
|
-
applyCommandOptions(command, metadata.optionDefs);
|
|
4579
|
-
command.action(async (args) => {
|
|
4580
|
-
return runWithCommandHandler(
|
|
4581
|
-
cli,
|
|
4582
|
-
command,
|
|
4583
|
-
"install",
|
|
4584
|
-
args,
|
|
4585
|
-
_optionalChain([options, 'access', _153 => _153.commandHandlers, 'optionalAccess', _154 => _154.install]),
|
|
4586
|
-
installCommandDefaultHandler
|
|
4587
|
-
);
|
|
4588
|
-
});
|
|
4589
|
-
metadata.aliases.forEach((alias) => command.alias(alias));
|
|
4590
|
-
},
|
|
4591
|
-
extract: () => {
|
|
4592
|
-
const metadata = resolveCommandMetadata("extract", options, prefix, defaultDefinitions);
|
|
4593
|
-
const command = cli.command(metadata.name, metadata.description);
|
|
4594
|
-
applyCommandOptions(command, metadata.optionDefs);
|
|
4595
|
-
command.action(async (args) => {
|
|
4596
|
-
return runWithCommandHandler(
|
|
4597
|
-
cli,
|
|
4598
|
-
command,
|
|
4599
|
-
"extract",
|
|
4600
|
-
args,
|
|
4601
|
-
_optionalChain([options, 'access', _155 => _155.commandHandlers, 'optionalAccess', _156 => _156.extract]),
|
|
4602
|
-
extractCommandDefaultHandler
|
|
4603
|
-
);
|
|
4604
|
-
});
|
|
4605
|
-
metadata.aliases.forEach((alias) => command.alias(alias));
|
|
4606
|
-
},
|
|
4607
|
-
tokens: () => {
|
|
4608
|
-
const metadata = resolveCommandMetadata("tokens", options, prefix, defaultDefinitions);
|
|
4609
|
-
const command = cli.command(metadata.name, metadata.description);
|
|
4610
|
-
applyCommandOptions(command, metadata.optionDefs);
|
|
4611
|
-
command.action(async (args) => {
|
|
4612
|
-
return runWithCommandHandler(
|
|
4613
|
-
cli,
|
|
4614
|
-
command,
|
|
4615
|
-
"tokens",
|
|
4616
|
-
args,
|
|
4617
|
-
_optionalChain([options, 'access', _157 => _157.commandHandlers, 'optionalAccess', _158 => _158.tokens]),
|
|
4618
|
-
tokensCommandDefaultHandler
|
|
4619
|
-
);
|
|
4620
|
-
});
|
|
4621
|
-
metadata.aliases.forEach((alias) => command.alias(alias));
|
|
4622
|
-
},
|
|
4623
|
-
init: () => {
|
|
4624
|
-
const metadata = resolveCommandMetadata("init", options, prefix, defaultDefinitions);
|
|
4625
|
-
const command = cli.command(metadata.name, metadata.description);
|
|
4626
|
-
applyCommandOptions(command, metadata.optionDefs);
|
|
4627
|
-
command.action(async (args) => {
|
|
4628
|
-
return runWithCommandHandler(
|
|
4629
|
-
cli,
|
|
4630
|
-
command,
|
|
4631
|
-
"init",
|
|
4632
|
-
args,
|
|
4633
|
-
_optionalChain([options, 'access', _159 => _159.commandHandlers, 'optionalAccess', _160 => _160.init]),
|
|
4634
|
-
initCommandDefaultHandler
|
|
4635
|
-
);
|
|
4636
|
-
});
|
|
4637
|
-
metadata.aliases.forEach((alias) => command.alias(alias));
|
|
4638
|
-
},
|
|
4639
|
-
migrate: () => {
|
|
4640
|
-
const metadata = resolveCommandMetadata("migrate", options, prefix, defaultDefinitions);
|
|
4641
|
-
const command = cli.command(metadata.name, metadata.description);
|
|
4642
|
-
applyCommandOptions(command, metadata.optionDefs);
|
|
4643
|
-
command.action(async (args) => {
|
|
4644
|
-
return runWithCommandHandler(
|
|
4645
|
-
cli,
|
|
4646
|
-
command,
|
|
4647
|
-
"migrate",
|
|
4648
|
-
args,
|
|
4649
|
-
_optionalChain([options, 'access', _161 => _161.commandHandlers, 'optionalAccess', _162 => _162.migrate]),
|
|
4650
|
-
migrateCommandDefaultHandler
|
|
4651
|
-
);
|
|
4652
|
-
});
|
|
4653
|
-
metadata.aliases.forEach((alias) => command.alias(alias));
|
|
4654
|
-
},
|
|
4655
|
-
restore: () => {
|
|
4656
|
-
const metadata = resolveCommandMetadata("restore", options, prefix, defaultDefinitions);
|
|
4657
|
-
const command = cli.command(metadata.name, metadata.description);
|
|
4658
|
-
applyCommandOptions(command, metadata.optionDefs);
|
|
4659
|
-
command.action(async (args) => {
|
|
4660
|
-
return runWithCommandHandler(
|
|
4661
|
-
cli,
|
|
4662
|
-
command,
|
|
4663
|
-
"restore",
|
|
4664
|
-
args,
|
|
4665
|
-
_optionalChain([options, 'access', _163 => _163.commandHandlers, 'optionalAccess', _164 => _164.restore]),
|
|
4666
|
-
restoreCommandDefaultHandler
|
|
4667
|
-
);
|
|
4668
|
-
});
|
|
4669
|
-
metadata.aliases.forEach((alias) => command.alias(alias));
|
|
4670
|
-
},
|
|
4671
|
-
validate: () => {
|
|
4672
|
-
const metadata = resolveCommandMetadata("validate", options, prefix, defaultDefinitions);
|
|
4673
|
-
const command = cli.command(metadata.name, metadata.description);
|
|
4674
|
-
applyCommandOptions(command, metadata.optionDefs);
|
|
4675
|
-
command.action(async (args) => {
|
|
4676
|
-
return runWithCommandHandler(
|
|
4677
|
-
cli,
|
|
4678
|
-
command,
|
|
4679
|
-
"validate",
|
|
4680
|
-
args,
|
|
4681
|
-
_optionalChain([options, 'access', _165 => _165.commandHandlers, 'optionalAccess', _166 => _166.validate]),
|
|
4682
|
-
validateCommandDefaultHandler
|
|
4683
|
-
);
|
|
4684
|
-
});
|
|
4685
|
-
metadata.aliases.forEach((alias) => command.alias(alias));
|
|
4686
|
-
},
|
|
4687
|
-
status: () => {
|
|
4688
|
-
const metadata = resolveCommandMetadata("status", options, prefix, defaultDefinitions);
|
|
4689
|
-
const command = cli.command(metadata.name, metadata.description);
|
|
4690
|
-
applyCommandOptions(command, metadata.optionDefs);
|
|
4691
|
-
command.action(async (args) => {
|
|
4692
|
-
return runWithCommandHandler(
|
|
4693
|
-
cli,
|
|
4694
|
-
command,
|
|
4695
|
-
"status",
|
|
4696
|
-
args,
|
|
4697
|
-
_optionalChain([options, 'access', _167 => _167.commandHandlers, 'optionalAccess', _168 => _168.status]),
|
|
4698
|
-
statusCommandDefaultHandler
|
|
4699
|
-
);
|
|
4700
|
-
});
|
|
4701
|
-
metadata.aliases.forEach((alias) => command.alias(alias));
|
|
4702
|
-
}
|
|
4703
|
-
};
|
|
4704
4847
|
for (const name of selectedCommands) {
|
|
4705
|
-
|
|
4706
|
-
if (register) {
|
|
4707
|
-
register();
|
|
4708
|
-
}
|
|
4848
|
+
registerTailwindcssPatchCommand(cli, name, options, prefix, defaultDefinitions);
|
|
4709
4849
|
}
|
|
4710
4850
|
return cli;
|
|
4711
4851
|
}
|
|
@@ -4740,4 +4880,4 @@ function createTailwindcssPatchCli(options = {}) {
|
|
|
4740
4880
|
|
|
4741
4881
|
|
|
4742
4882
|
|
|
4743
|
-
exports.logger_default = logger_default; exports.CacheStore = CacheStore; exports.extractRawCandidatesWithPositions = extractRawCandidatesWithPositions; exports.extractRawCandidates = extractRawCandidates; exports.extractValidCandidates = extractValidCandidates; exports.extractProjectCandidatesWithPositions = extractProjectCandidatesWithPositions; exports.groupTokensByFile = groupTokensByFile; exports.
|
|
4883
|
+
exports.logger_default = logger_default; exports.CacheStore = CacheStore; exports.normalizeOptions = normalizeOptions; exports.extractRawCandidatesWithPositions = extractRawCandidatesWithPositions; exports.extractRawCandidates = extractRawCandidates; exports.extractValidCandidates = extractValidCandidates; exports.extractProjectCandidatesWithPositions = extractProjectCandidatesWithPositions; exports.groupTokensByFile = groupTokensByFile; exports.collectClassesFromContexts = collectClassesFromContexts; exports.collectClassesFromTailwindV4 = collectClassesFromTailwindV4; exports.loadRuntimeContexts = loadRuntimeContexts; exports.runTailwindBuild = runTailwindBuild; exports.getPatchStatusReport = getPatchStatusReport; exports.TailwindcssPatcher = TailwindcssPatcher; exports.MIGRATION_REPORT_KIND = MIGRATION_REPORT_KIND; exports.MIGRATION_REPORT_SCHEMA_VERSION = MIGRATION_REPORT_SCHEMA_VERSION; exports.migrateConfigFiles = migrateConfigFiles; exports.restoreConfigFiles = restoreConfigFiles; exports.VALIDATE_EXIT_CODES = VALIDATE_EXIT_CODES; exports.VALIDATE_FAILURE_REASONS = VALIDATE_FAILURE_REASONS; exports.ValidateCommandError = ValidateCommandError; exports.tailwindcssPatchCommands = tailwindcssPatchCommands; exports.mountTailwindcssPatchCommands = mountTailwindcssPatchCommands; exports.createTailwindcssPatchCli = createTailwindcssPatchCli;
|