zyncat-ui 0.15.0 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +262 -45
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1506,6 +1506,99 @@ function gradientText(text, from, to) {
|
|
|
1506
1506
|
return chars.map((char, i2) => fg(lerpHex(from, to, i2 / span))(char)).join("");
|
|
1507
1507
|
}
|
|
1508
1508
|
|
|
1509
|
+
// src/theme-file.ts
|
|
1510
|
+
var BASELINE_VERSION = "0.15.0";
|
|
1511
|
+
var TOKEN_HISTORY = {};
|
|
1512
|
+
var ROOT_BLOCK = /^[ \t]*:root\b[^{]*\{/m;
|
|
1513
|
+
var STAMP = /@zyncat-ui\s+(\d+\.\d+\.\d+)/;
|
|
1514
|
+
var COMMENT_OR_DECLARATION = /\/\*[\s\S]*?\*\/|(--[\w-]+)\s*:\s*([^;]+);/g;
|
|
1515
|
+
var COMMENT_OR_NAME = /\/\*[\s\S]*?\*\/|(--[\w-]+)\s*:/g;
|
|
1516
|
+
function rootBlock(css) {
|
|
1517
|
+
const rule = ROOT_BLOCK.exec(css);
|
|
1518
|
+
if (!rule) return null;
|
|
1519
|
+
const start = rule.index + rule[0].length;
|
|
1520
|
+
let depth = 1;
|
|
1521
|
+
for (let i2 = start; i2 < css.length; i2++) {
|
|
1522
|
+
if (css[i2] === "{") depth++;
|
|
1523
|
+
else if (css[i2] === "}" && --depth === 0) return { start, end: i2 };
|
|
1524
|
+
}
|
|
1525
|
+
return null;
|
|
1526
|
+
}
|
|
1527
|
+
function parseDecisions(css) {
|
|
1528
|
+
const block2 = rootBlock(css);
|
|
1529
|
+
if (!block2) return [];
|
|
1530
|
+
const body = css.slice(block2.start, block2.end);
|
|
1531
|
+
const decisions = [];
|
|
1532
|
+
let comment = "";
|
|
1533
|
+
COMMENT_OR_DECLARATION.lastIndex = 0;
|
|
1534
|
+
for (let match = COMMENT_OR_DECLARATION.exec(body); match; match = COMMENT_OR_DECLARATION.exec(body)) {
|
|
1535
|
+
if (match[1] === void 0) {
|
|
1536
|
+
comment = match[0];
|
|
1537
|
+
continue;
|
|
1538
|
+
}
|
|
1539
|
+
decisions.push({ name: match[1], value: match[2].trim(), comment });
|
|
1540
|
+
comment = "";
|
|
1541
|
+
}
|
|
1542
|
+
return decisions;
|
|
1543
|
+
}
|
|
1544
|
+
function declaredNames(css) {
|
|
1545
|
+
const names = /* @__PURE__ */ new Set();
|
|
1546
|
+
COMMENT_OR_NAME.lastIndex = 0;
|
|
1547
|
+
for (let match = COMMENT_OR_NAME.exec(css); match; match = COMMENT_OR_NAME.exec(css))
|
|
1548
|
+
if (match[1] !== void 0) names.add(match[1]);
|
|
1549
|
+
return names;
|
|
1550
|
+
}
|
|
1551
|
+
var readStamp = (css) => STAMP.exec(css)?.[1] ?? null;
|
|
1552
|
+
var stampOf = (css) => readStamp(css) ?? BASELINE_VERSION;
|
|
1553
|
+
function themeDrift(existing, shipped) {
|
|
1554
|
+
const declared = declaredNames(existing);
|
|
1555
|
+
const stamp = stampOf(existing);
|
|
1556
|
+
const added = shipped.filter((decision) => {
|
|
1557
|
+
if (declared.has(decision.name)) return false;
|
|
1558
|
+
const since = TOKEN_HISTORY[decision.name]?.since;
|
|
1559
|
+
return since !== void 0 && isOlder(stamp, since);
|
|
1560
|
+
});
|
|
1561
|
+
const deprecated = [];
|
|
1562
|
+
const removed = [];
|
|
1563
|
+
for (const name of declared) {
|
|
1564
|
+
const note = TOKEN_HISTORY[name];
|
|
1565
|
+
if (!note) continue;
|
|
1566
|
+
if (note.removed) removed.push({ name, note });
|
|
1567
|
+
else if (note.deprecated) deprecated.push({ name, note });
|
|
1568
|
+
}
|
|
1569
|
+
return { added, deprecated, removed };
|
|
1570
|
+
}
|
|
1571
|
+
function renderDecision(decision, indent) {
|
|
1572
|
+
const comment = decision.comment ? `${decision.comment.split("\n").map((line, index) => `${indent}${index === 0 ? "" : " "}${line.trim()}`).join("\n")}
|
|
1573
|
+
` : "";
|
|
1574
|
+
return `${comment}${indent}${decision.name}: ${decision.value};`;
|
|
1575
|
+
}
|
|
1576
|
+
function stampCss(css, version2) {
|
|
1577
|
+
if (STAMP.test(css)) return css.replace(STAMP, `@zyncat-ui ${version2}`);
|
|
1578
|
+
const header = /^\s*\/\*[\s\S]*?\*\//.exec(css);
|
|
1579
|
+
const line = `@zyncat-ui ${version2} - the version whose decisions this mirrors; \`npx zyncat-ui update\` refreshes it.`;
|
|
1580
|
+
if (!header) return `/* ${line} */
|
|
1581
|
+
${css}`;
|
|
1582
|
+
const close = header.index + header[0].length - 2;
|
|
1583
|
+
return `${css.slice(0, close).trimEnd()}
|
|
1584
|
+
${line} */${css.slice(close + 2)}`;
|
|
1585
|
+
}
|
|
1586
|
+
function withDecisions(css, decisions, version2) {
|
|
1587
|
+
const stamped = stampCss(css, version2);
|
|
1588
|
+
if (!decisions.length) return stamped;
|
|
1589
|
+
const body = decisions.map((decision) => renderDecision(decision, " ")).join("\n");
|
|
1590
|
+
const block2 = rootBlock(stamped);
|
|
1591
|
+
if (!block2) return `${stamped.trimEnd()}
|
|
1592
|
+
|
|
1593
|
+
:root {
|
|
1594
|
+
${body}
|
|
1595
|
+
}
|
|
1596
|
+
`;
|
|
1597
|
+
return `${stamped.slice(0, block2.end).trimEnd()}
|
|
1598
|
+
${body}
|
|
1599
|
+
${stamped.slice(block2.end)}`;
|
|
1600
|
+
}
|
|
1601
|
+
|
|
1509
1602
|
// src/ui.ts
|
|
1510
1603
|
var SPINNER_FRAMES = unicode ? ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"] : ["-", "\\", "|", "/"];
|
|
1511
1604
|
var SPINNER_DELAY = 80;
|
|
@@ -1598,6 +1691,31 @@ var ADD_COMMAND = {
|
|
|
1598
1691
|
yarn: "yarn add",
|
|
1599
1692
|
bun: "bun add"
|
|
1600
1693
|
};
|
|
1694
|
+
function removedWarning(removed) {
|
|
1695
|
+
const one = removed.length === 1;
|
|
1696
|
+
const named = removed.map(({ name, note }) => `${name} (removed in ${note.removed}${note.use ? ` - use ${note.use}` : ""})`).join(", ");
|
|
1697
|
+
const lead = one ? "A token your theme file sets no longer exists" : `${removed.length} tokens your theme file sets no longer exist`;
|
|
1698
|
+
return `${lead}: ${named}. Nothing reads ${one ? "it" : "them"} now, so ${one ? "that line is" : "those lines are"} dead.`;
|
|
1699
|
+
}
|
|
1700
|
+
function deprecatedNote(deprecated) {
|
|
1701
|
+
const one = deprecated.length === 1;
|
|
1702
|
+
const named = deprecated.map(({ name, note }) => `${name} (deprecated in ${note.deprecated}${note.use ? ` - now feeds ${note.use}` : ""})`).join(", ");
|
|
1703
|
+
const lead = one ? "A token your theme file sets is deprecated" : `${deprecated.length} tokens are deprecated`;
|
|
1704
|
+
return `${lead}: ${named}. ${one ? "It still works" : "They still work"} - rename ${one ? "it" : "them"} before the alias goes.`;
|
|
1705
|
+
}
|
|
1706
|
+
var minorOf = (version2) => Number(version2.split(".")[1] ?? 0);
|
|
1707
|
+
function crossedVersions(before, after) {
|
|
1708
|
+
const minors = minorOf(after) - minorOf(before);
|
|
1709
|
+
if (minors < 1) return row("Upgraded", `${before} ${arrow} ${after}`);
|
|
1710
|
+
const releases = `${minors} minor release${minors === 1 ? "" : "s"}`;
|
|
1711
|
+
return row("Upgraded", `${before} ${arrow} ${after} \xB7 ${releases}, each breaking before 1.0`);
|
|
1712
|
+
}
|
|
1713
|
+
function driftHint(drift, command2) {
|
|
1714
|
+
const one = drift.added.length === 1;
|
|
1715
|
+
const names = drift.added.map((decision) => decision.name).join(", ");
|
|
1716
|
+
const running = one ? "it already runs on its default" : "each already runs on its default";
|
|
1717
|
+
return `${names} - ${running}, so nothing is broken. ${command2} adds ${one ? "it" : "them"} to your file.`;
|
|
1718
|
+
}
|
|
1601
1719
|
async function planInstall(cwd, targetPkg, flags, version2) {
|
|
1602
1720
|
const deps = { ...targetPkg.dependencies, ...targetPkg.devDependencies };
|
|
1603
1721
|
const specs = [];
|
|
@@ -1725,7 +1843,7 @@ function wireSkill(cwd, packageRoot, pm) {
|
|
|
1725
1843
|
return {
|
|
1726
1844
|
line: row("Agent skill", `skipped \xB7 ${PACKAGE}${onDisk ? ` ${onDisk}` : ""} ships no skills/`),
|
|
1727
1845
|
done: false,
|
|
1728
|
-
|
|
1846
|
+
hints: [`Upgrade it with ${ADD_COMMAND[pm]} ${PACKAGE}@latest, then re-run init.`]
|
|
1729
1847
|
};
|
|
1730
1848
|
}
|
|
1731
1849
|
const dest = join3(cwd, ".claude/skills");
|
|
@@ -1743,17 +1861,19 @@ function wireMcp(cwd) {
|
|
|
1743
1861
|
if (!parsed) bail(`.mcp.json exists but is not valid JSON - fix it, then re-run init.`);
|
|
1744
1862
|
config = parsed;
|
|
1745
1863
|
}
|
|
1746
|
-
|
|
1864
|
+
if (JSON.stringify(config.mcpServers?.["zyncat-ui"]) === JSON.stringify(MCP_SERVER_ENTRY))
|
|
1865
|
+
return { line: row("MCP server", ".mcp.json \xB7 kept"), done: true };
|
|
1747
1866
|
config.mcpServers = { ...config.mcpServers, "zyncat-ui": MCP_SERVER_ENTRY };
|
|
1748
1867
|
writeFileSync(path, `${JSON.stringify(config, null, 2)}
|
|
1749
1868
|
`);
|
|
1750
|
-
return { line: row("MCP server",
|
|
1869
|
+
return { line: row("MCP server", `.mcp.json ${arrow} zyncat-ui`), done: true };
|
|
1751
1870
|
}
|
|
1752
|
-
function
|
|
1871
|
+
function shippedDecisionsCss(packageRoot) {
|
|
1753
1872
|
const source = join3(packageRoot, THEME_SOURCE);
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1873
|
+
return existsSync3(source) ? readFileSync2(source, "utf8") : null;
|
|
1874
|
+
}
|
|
1875
|
+
function themeFileText(css, version2) {
|
|
1876
|
+
const rule = /^\s*:root\b[^{]*\{/m.exec(css);
|
|
1757
1877
|
if (!rule) return null;
|
|
1758
1878
|
const open = rule.index + rule[0].length - 1;
|
|
1759
1879
|
const close = css.indexOf("}", open);
|
|
@@ -1764,55 +1884,87 @@ function themeFileText(packageRoot) {
|
|
|
1764
1884
|
return [
|
|
1765
1885
|
`/* ${THEME_FILE} - the decisions every other token derives from, written by zyncat-ui init.`,
|
|
1766
1886
|
" Loaded after @zyncat/ui/styles.css, so a value here wins; whatever you delete keeps the default.",
|
|
1767
|
-
" A [data-
|
|
1768
|
-
"
|
|
1887
|
+
" A [data-polarity='dark'] block here extends the dark polarity, a [data-theme='<name>'] one adds a",
|
|
1888
|
+
' palette, and data-theme="default" on a subtree brings these back inside another palette.',
|
|
1889
|
+
" Docs: https://ui.zyncat.app/theming",
|
|
1890
|
+
` @zyncat-ui ${version2} - the version whose decisions this mirrors; \`npx zyncat-ui update\` refreshes it. */`,
|
|
1891
|
+
":root,",
|
|
1892
|
+
"[data-theme='default'] {",
|
|
1769
1893
|
body,
|
|
1770
1894
|
"}",
|
|
1771
1895
|
""
|
|
1772
1896
|
].join("\n");
|
|
1773
1897
|
}
|
|
1774
|
-
|
|
1898
|
+
var themePath = (cwd, entry) => {
|
|
1775
1899
|
const dir = entry ? dirname3(entry) : ".";
|
|
1776
1900
|
const rel = dir === "." ? THEME_FILE : `${dir}/${THEME_FILE}`;
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1901
|
+
return { rel, path: join3(cwd, rel) };
|
|
1902
|
+
};
|
|
1903
|
+
function wireTheme(cwd, packageRoot, pm, entry, version2) {
|
|
1904
|
+
const { rel, path } = themePath(cwd, entry);
|
|
1905
|
+
const css = shippedDecisionsCss(packageRoot);
|
|
1906
|
+
if (!css)
|
|
1781
1907
|
return {
|
|
1782
1908
|
line: row("Theme file", `skipped \xB7 ${PACKAGE} ships no ${THEME_SOURCE}`),
|
|
1783
1909
|
done: false,
|
|
1784
|
-
|
|
1910
|
+
hints: [`Upgrade it with ${ADD_COMMAND[pm]} ${PACKAGE}@latest, then re-run init.`]
|
|
1911
|
+
};
|
|
1912
|
+
if (existsSync3(path)) {
|
|
1913
|
+
const drift = themeDrift(readFileSync2(path, "utf8"), parseDecisions(css));
|
|
1914
|
+
const news = drift.added.length ? ` \xB7 ${drift.added.length} new decision${drift.added.length === 1 ? "" : "s"} available` : "";
|
|
1915
|
+
const hints = [];
|
|
1916
|
+
if (drift.added.length) hints.push(driftHint(drift, "npx zyncat-ui update"));
|
|
1917
|
+
if (drift.deprecated.length) hints.push(deprecatedNote(drift.deprecated));
|
|
1918
|
+
return {
|
|
1919
|
+
line: row("Theme file", `${rel} \xB7 kept${news}`),
|
|
1920
|
+
done: true,
|
|
1921
|
+
hints,
|
|
1922
|
+
warn: drift.removed.length ? removedWarning(drift.removed) : void 0
|
|
1923
|
+
};
|
|
1924
|
+
}
|
|
1925
|
+
const text = themeFileText(css, version2);
|
|
1926
|
+
if (!text)
|
|
1927
|
+
return {
|
|
1928
|
+
line: row("Theme file", `skipped \xB7 ${THEME_SOURCE} has no :root block`),
|
|
1929
|
+
done: false,
|
|
1930
|
+
hints: [`Upgrade it with ${ADD_COMMAND[pm]} ${PACKAGE}@latest, then re-run init.`]
|
|
1785
1931
|
};
|
|
1786
1932
|
writeFileSync(path, text);
|
|
1787
1933
|
return { line: row("Theme file", `${rel} \xB7 written`), done: true };
|
|
1788
1934
|
}
|
|
1789
|
-
|
|
1935
|
+
var STYLES_LINE = /^\s*import\s+(['"])@zyncat\/ui\/styles\.css\1;?\s*$/;
|
|
1936
|
+
var THEME_LINE = new RegExp(`^\\s*import\\s+(['"])[^'"]*${THEME_FILE.replace(/\./g, "\\.")}\\1;?\\s*$`);
|
|
1937
|
+
var CSS_LINE = /^\s*import\s+(['"])(\.[^'"]*\.css)\1;?\s*$/;
|
|
1938
|
+
var slashes = (path) => path.split(/[\\/]/).filter(Boolean).join("/");
|
|
1939
|
+
function importsStylesheet(line, fromDir, target) {
|
|
1940
|
+
const spec = CSS_LINE.exec(line)?.[2];
|
|
1941
|
+
return spec !== void 0 && slashes(join3(fromDir, spec)) === slashes(target);
|
|
1942
|
+
}
|
|
1943
|
+
function wireStyles(cwd, entry, tailwindEntry) {
|
|
1944
|
+
const below = tailwindEntry ? `below the ${tailwindEntry} import` : "above your own stylesheets";
|
|
1790
1945
|
if (!entry)
|
|
1791
1946
|
return {
|
|
1792
1947
|
line: row("Stylesheet", "no app entry found \xB7 add the imports yourself"),
|
|
1793
1948
|
done: false,
|
|
1794
|
-
|
|
1949
|
+
hints: [`Put ${STYLES_IMPORT} then ${THEME_IMPORT} at your app root, ${below}.`]
|
|
1795
1950
|
};
|
|
1796
1951
|
const path = join3(cwd, entry);
|
|
1797
1952
|
const text = readFileSync2(path, "utf8");
|
|
1798
1953
|
const eol = text.includes("\r\n") ? "\r\n" : "\n";
|
|
1799
|
-
const
|
|
1800
|
-
const
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
}
|
|
1813
|
-
if (!added.length) return { line: row("Stylesheet", `${entry} \xB7 already imported`), done: true };
|
|
1814
|
-
writeFileSync(path, lines.join(eol));
|
|
1815
|
-
const what = added.length === 2 ? "imports added" : added[0] === "theme" ? "theme import added" : "import added";
|
|
1954
|
+
const dir = dirname3(entry);
|
|
1955
|
+
const hasTheme = existsSync3(join3(cwd, dir, THEME_FILE));
|
|
1956
|
+
const mine = (line) => STYLES_LINE.test(line) || hasTheme && THEME_LINE.test(line);
|
|
1957
|
+
const had = text.split(eol).some(mine);
|
|
1958
|
+
const kept = text.split(eol).filter((line) => !mine(line));
|
|
1959
|
+
const bridgeAt = tailwindEntry ? kept.findIndex((line) => importsStylesheet(line, dir, tailwindEntry)) : -1;
|
|
1960
|
+
let at = 0;
|
|
1961
|
+
if (bridgeAt !== -1) at = bridgeAt + 1;
|
|
1962
|
+
else while (at < kept.length && (kept[at].trim() === "" || /^(['"])use [\w-]+\1;?$/.test(kept[at].trim()))) at++;
|
|
1963
|
+
kept.splice(at, 0, STYLES_IMPORT, ...hasTheme ? [THEME_IMPORT] : []);
|
|
1964
|
+
const next = kept.join(eol);
|
|
1965
|
+
if (next === text) return { line: row("Stylesheet", `${entry} \xB7 already imported`), done: true };
|
|
1966
|
+
writeFileSync(path, next);
|
|
1967
|
+
const what = had && bridgeAt !== -1 ? `imports moved below ${tailwindEntry}` : had ? "imports updated" : "imports added";
|
|
1816
1968
|
return { line: row("Stylesheet", `${entry} \xB7 ${what}`), done: true };
|
|
1817
1969
|
}
|
|
1818
1970
|
function wireTailwind(cwd, targetPkg) {
|
|
@@ -1822,25 +1974,26 @@ function wireTailwind(cwd, targetPkg) {
|
|
|
1822
1974
|
return {
|
|
1823
1975
|
line: row("Tailwind", `skipped \xB7 Tailwind ${major} has no @theme`),
|
|
1824
1976
|
done: false,
|
|
1825
|
-
|
|
1977
|
+
hints: [`The bridge needs Tailwind v4 - ${DOCS_URL}/theming#tailwind.`]
|
|
1826
1978
|
};
|
|
1827
1979
|
const entry = findTailwindEntry(cwd);
|
|
1828
1980
|
if (!entry)
|
|
1829
1981
|
return {
|
|
1830
1982
|
line: row("Tailwind", "no stylesheet imports tailwindcss \xB7 add the line yourself"),
|
|
1831
1983
|
done: false,
|
|
1832
|
-
|
|
1984
|
+
hints: [`Put @import '${TAILWIND_BRIDGE}'; above @import 'tailwindcss'; in the stylesheet Tailwind compiles.`]
|
|
1833
1985
|
};
|
|
1834
1986
|
const path = join3(cwd, entry);
|
|
1835
1987
|
const text = readFileSync2(path, "utf8");
|
|
1836
|
-
if (text.includes(TAILWIND_BRIDGE))
|
|
1988
|
+
if (text.includes(TAILWIND_BRIDGE))
|
|
1989
|
+
return { line: row("Tailwind", `${entry} \xB7 already imported`), done: true, bridge: entry };
|
|
1837
1990
|
const eol = text.includes("\r\n") ? "\r\n" : "\n";
|
|
1838
1991
|
const lines = text.split(eol);
|
|
1839
1992
|
const at = lines.findIndex((line) => TAILWIND_IMPORT.test(line));
|
|
1840
1993
|
const quote = lines[at].includes('"') ? '"' : "'";
|
|
1841
1994
|
lines.splice(at, 0, `@import ${quote}${TAILWIND_BRIDGE}${quote};`);
|
|
1842
1995
|
writeFileSync(path, lines.join(eol));
|
|
1843
|
-
return { line: row("Tailwind", `${entry} \xB7 import added`), done: true };
|
|
1996
|
+
return { line: row("Tailwind", `${entry} \xB7 import added`), done: true, bridge: entry };
|
|
1844
1997
|
}
|
|
1845
1998
|
async function init(flags) {
|
|
1846
1999
|
const startedAt = performance.now();
|
|
@@ -1862,6 +2015,7 @@ async function init(flags) {
|
|
|
1862
2015
|
const pmVer = pmVersion(pm);
|
|
1863
2016
|
const project = targetPkg.name ?? "unnamed project";
|
|
1864
2017
|
log.message(dim(`${project} \xB7 ${pm}${pmVer ? ` ${pmVer}` : ""}`));
|
|
2018
|
+
const before = installedVersion(cwd, PACKAGE);
|
|
1865
2019
|
const plan = await planInstall(cwd, targetPkg, flags, version2);
|
|
1866
2020
|
const installed = await installPhase(pm, plan, cwd);
|
|
1867
2021
|
installTouchedProject = true;
|
|
@@ -1869,18 +2023,21 @@ async function init(flags) {
|
|
|
1869
2023
|
if (plan.reactNote) log.warn(plan.reactNote);
|
|
1870
2024
|
await alignVersion(pm, cwd, version2);
|
|
1871
2025
|
const packageRoot = sourceRoot(cwd, ownRoot);
|
|
2026
|
+
const landed = installedVersion(cwd, PACKAGE) ?? version2;
|
|
2027
|
+
if (before && isOlder(before, landed)) log.message(crossedVersions(before, landed), { symbol: check });
|
|
1872
2028
|
const entry = findAppEntry(cwd);
|
|
1873
2029
|
const tailwind = wireTailwind(cwd, targetPkg);
|
|
1874
2030
|
const rows = [
|
|
1875
2031
|
wireSkill(cwd, packageRoot, pm),
|
|
1876
2032
|
wireMcp(cwd),
|
|
1877
|
-
wireTheme(cwd, packageRoot, pm, entry),
|
|
1878
|
-
wireStyles(cwd, entry),
|
|
2033
|
+
wireTheme(cwd, packageRoot, pm, entry, landed),
|
|
2034
|
+
wireStyles(cwd, entry, tailwind?.bridge ?? null),
|
|
1879
2035
|
...tailwind ? [tailwind] : []
|
|
1880
2036
|
];
|
|
1881
2037
|
for (const [index, entry2] of rows.entries()) {
|
|
1882
2038
|
log.message(entry2.line, { symbol: entry2.done ? check : skip, spacing: index === 0 ? 1 : 0 });
|
|
1883
|
-
|
|
2039
|
+
for (const hint of entry2.hints ?? []) log.message(dim(hint), { spacing: 0 });
|
|
2040
|
+
if (entry2.warn) log.warn(entry2.warn);
|
|
1884
2041
|
}
|
|
1885
2042
|
log.message(`${dim("Docs")} ${arrow} ${accentDeep(DOCS_URL)}`);
|
|
1886
2043
|
const skipped = rows.filter((entry2) => !entry2.done).length;
|
|
@@ -1888,6 +2045,64 @@ async function init(flags) {
|
|
|
1888
2045
|
outro(closing);
|
|
1889
2046
|
}
|
|
1890
2047
|
|
|
2048
|
+
// src/update.ts
|
|
2049
|
+
import { existsSync as existsSync4, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "fs";
|
|
2050
|
+
import { join as join4 } from "path";
|
|
2051
|
+
var PACKAGE2 = "@zyncat/ui";
|
|
2052
|
+
var DOCS_URL2 = "https://ui.zyncat.app";
|
|
2053
|
+
var interactive2 = () => Boolean(process.stdout.isTTY && process.stdin.isTTY);
|
|
2054
|
+
function stop(message, hint) {
|
|
2055
|
+
log.error(message);
|
|
2056
|
+
if (hint) log.message(dim(hint), { spacing: 0 });
|
|
2057
|
+
outro(red("Nothing was changed."));
|
|
2058
|
+
process.exit(1);
|
|
2059
|
+
}
|
|
2060
|
+
async function update(flags) {
|
|
2061
|
+
const { root: ownRoot, version: version2 } = findOwnRoot();
|
|
2062
|
+
const cwd = process.cwd();
|
|
2063
|
+
intro(wordmark(version2));
|
|
2064
|
+
const targetPkg = readJson(join4(cwd, "package.json"));
|
|
2065
|
+
if (!targetPkg) stop("No package.json here - update runs inside a React project that already ran init.");
|
|
2066
|
+
if (targetPkg.name === PACKAGE2 || targetPkg.name === "zyncat-ui")
|
|
2067
|
+
stop("This is the zyncat-ui repository - update runs in a consumer project.");
|
|
2068
|
+
const packageRoot = sourceRoot(cwd, ownRoot);
|
|
2069
|
+
const landed = installedVersion(cwd, PACKAGE2);
|
|
2070
|
+
if (!landed) stop(`${PACKAGE2} is not installed here.`, "Run npx zyncat-ui init first.");
|
|
2071
|
+
log.message(dim(`${targetPkg.name ?? "unnamed project"} \xB7 ${PACKAGE2} ${landed}`));
|
|
2072
|
+
const shipped = shippedDecisionsCss(packageRoot);
|
|
2073
|
+
if (!shipped) stop(`${PACKAGE2} ${landed} ships no decisions to compare against.`);
|
|
2074
|
+
const { rel, path } = themePath(cwd, findAppEntry(cwd));
|
|
2075
|
+
if (!existsSync4(path)) stop(`No ${rel} here.`, "Run npx zyncat-ui init to write one.");
|
|
2076
|
+
const current = readFileSync3(path, "utf8");
|
|
2077
|
+
const stamp = stampOf(current);
|
|
2078
|
+
const drift = themeDrift(current, parseDecisions(shipped));
|
|
2079
|
+
if (drift.deprecated.length) log.message(dim(deprecatedNote(drift.deprecated)), { spacing: 0 });
|
|
2080
|
+
if (drift.removed.length) log.warn(removedWarning(drift.removed));
|
|
2081
|
+
if (!drift.added.length) {
|
|
2082
|
+
if (stamp !== landed) writeFileSync2(path, withDecisions(current, [], landed));
|
|
2083
|
+
log.message(row("Theme file", `${rel} \xB7 every decision in ${landed} is already in your file`), { symbol: check });
|
|
2084
|
+
outro(bold(stamp === landed ? "Up to date." : `Up to date. Stamp ${stamp} ${arrow} ${landed}.`));
|
|
2085
|
+
return;
|
|
2086
|
+
}
|
|
2087
|
+
log.message(
|
|
2088
|
+
`${bold(`${drift.added.length} new decision${drift.added.length === 1 ? "" : "s"}`)} ${dim(`since ${stamp}`)}
|
|
2089
|
+
|
|
2090
|
+
${drift.added.map((decision) => renderDecision(decision, " ")).join("\n")}`
|
|
2091
|
+
);
|
|
2092
|
+
log.message(dim(driftHint(drift, "This")), { spacing: 0 });
|
|
2093
|
+
if (!flags.yes && interactive2()) {
|
|
2094
|
+
const answer = await confirm({ message: `Add ${drift.added.length === 1 ? "it" : "them"} to ${rel}?` });
|
|
2095
|
+
if (isCancel(answer) || !answer) {
|
|
2096
|
+
cancel("Cancelled - nothing was changed.");
|
|
2097
|
+
process.exit(isCancel(answer) ? 130 : 0);
|
|
2098
|
+
}
|
|
2099
|
+
}
|
|
2100
|
+
writeFileSync2(path, withDecisions(current, drift.added, landed));
|
|
2101
|
+
log.message(row("Theme file", `${rel} \xB7 ${drift.added.length} added, stamped ${landed}`), { symbol: check });
|
|
2102
|
+
log.message(`${dim("Docs")} ${arrow} ${accentDeep(`${DOCS_URL2}/theming`)}`);
|
|
2103
|
+
outro(bold("Your values were not touched."));
|
|
2104
|
+
}
|
|
2105
|
+
|
|
1891
2106
|
// src/cli.ts
|
|
1892
2107
|
function parseFlags(args) {
|
|
1893
2108
|
const flags = { yes: false };
|
|
@@ -1912,11 +2127,12 @@ function help(version2) {
|
|
|
1912
2127
|
` ${dim("and, under Tailwind v4, the utility bridge.")}`,
|
|
1913
2128
|
"",
|
|
1914
2129
|
` ${bold("Usage")}`,
|
|
1915
|
-
` zyncat-ui init ${dim("[flags]")}`,
|
|
2130
|
+
` zyncat-ui init ${dim("[flags]")} ${dim("set the project up, or re-wire it after an upgrade")}`,
|
|
2131
|
+
` zyncat-ui update ${dim("[flags]")} ${dim("add decisions the library gained since your theme file")}`,
|
|
1916
2132
|
"",
|
|
1917
2133
|
` ${bold("Flags")}`,
|
|
1918
2134
|
` --yes, -y ${dim("accept every default, never prompt")}`,
|
|
1919
|
-
` --pm <name> ${dim(`force the package manager (${PACKAGE_MANAGERS.join(", ")})`)}`,
|
|
2135
|
+
` --pm <name> ${dim(`force the package manager (${PACKAGE_MANAGERS.join(", ")}) - init only`)}`,
|
|
1920
2136
|
"",
|
|
1921
2137
|
` ${dim("Docs")} ${arrow} ${accentDeep("https://ui.zyncat.app")}`,
|
|
1922
2138
|
""
|
|
@@ -1927,13 +2143,14 @@ var [command, ...rest] = process.argv.slice(2);
|
|
|
1927
2143
|
var { version } = findOwnRoot();
|
|
1928
2144
|
if (command === "--version" || command === "-v") {
|
|
1929
2145
|
console.log(version);
|
|
1930
|
-
} else if (command === "init") {
|
|
2146
|
+
} else if (command === "init" || command === "update") {
|
|
1931
2147
|
const flags = parseFlags(rest);
|
|
1932
2148
|
if (!flags) {
|
|
1933
2149
|
console.error(help(version));
|
|
1934
2150
|
process.exit(1);
|
|
1935
2151
|
}
|
|
1936
|
-
await init(flags);
|
|
2152
|
+
if (command === "init") await init(flags);
|
|
2153
|
+
else await update({ yes: flags.yes });
|
|
1937
2154
|
} else {
|
|
1938
2155
|
console.log(help(version));
|
|
1939
2156
|
process.exit(command ? 1 : 0);
|