zyncat-ui 0.15.0 → 0.17.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.
Files changed (3) hide show
  1. package/LICENSE +21 -0
  2. package/dist/cli.js +259 -43
  3. package/package.json +6 -7
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Tabsir Ahammed
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
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
- hint: `Upgrade it with ${ADD_COMMAND[pm]} ${PACKAGE}@latest, then re-run init.`
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");
@@ -1749,11 +1867,12 @@ function wireMcp(cwd) {
1749
1867
  `);
1750
1868
  return { line: row("MCP server", existed ? ".mcp.json \xB7 kept" : `.mcp.json ${arrow} zyncat-ui`), done: true };
1751
1869
  }
1752
- function themeFileText(packageRoot) {
1870
+ function shippedDecisionsCss(packageRoot) {
1753
1871
  const source = join3(packageRoot, THEME_SOURCE);
1754
- if (!existsSync3(source)) return null;
1755
- const css = readFileSync2(source, "utf8");
1756
- const rule = /^\s*:root\s*\{/m.exec(css);
1872
+ return existsSync3(source) ? readFileSync2(source, "utf8") : null;
1873
+ }
1874
+ function themeFileText(css, version2) {
1875
+ const rule = /^\s*:root\b[^{]*\{/m.exec(css);
1757
1876
  if (!rule) return null;
1758
1877
  const open = rule.index + rule[0].length - 1;
1759
1878
  const close = css.indexOf("}", open);
@@ -1764,55 +1883,87 @@ function themeFileText(packageRoot) {
1764
1883
  return [
1765
1884
  `/* ${THEME_FILE} - the decisions every other token derives from, written by zyncat-ui init.`,
1766
1885
  " Loaded after @zyncat/ui/styles.css, so a value here wins; whatever you delete keeps the default.",
1767
- " A [data-theme='dark'] block here extends the shipped dark theme. Docs: https://ui.zyncat.app/theming */",
1768
- ":root {",
1886
+ " A [data-polarity='dark'] block here extends the dark polarity, a [data-theme='<name>'] one adds a",
1887
+ ' palette, and data-theme="default" on a subtree brings these back inside another palette.',
1888
+ " Docs: https://ui.zyncat.app/theming",
1889
+ ` @zyncat-ui ${version2} - the version whose decisions this mirrors; \`npx zyncat-ui update\` refreshes it. */`,
1890
+ ":root,",
1891
+ "[data-theme='default'] {",
1769
1892
  body,
1770
1893
  "}",
1771
1894
  ""
1772
1895
  ].join("\n");
1773
1896
  }
1774
- function wireTheme(cwd, packageRoot, pm, entry) {
1897
+ var themePath = (cwd, entry) => {
1775
1898
  const dir = entry ? dirname3(entry) : ".";
1776
1899
  const rel = dir === "." ? THEME_FILE : `${dir}/${THEME_FILE}`;
1777
- const path = join3(cwd, rel);
1778
- if (existsSync3(path)) return { line: row("Theme file", `${rel} \xB7 kept`), done: true };
1779
- const text = themeFileText(packageRoot);
1780
- if (!text)
1900
+ return { rel, path: join3(cwd, rel) };
1901
+ };
1902
+ function wireTheme(cwd, packageRoot, pm, entry, version2) {
1903
+ const { rel, path } = themePath(cwd, entry);
1904
+ const css = shippedDecisionsCss(packageRoot);
1905
+ if (!css)
1781
1906
  return {
1782
1907
  line: row("Theme file", `skipped \xB7 ${PACKAGE} ships no ${THEME_SOURCE}`),
1783
1908
  done: false,
1784
- hint: `Upgrade it with ${ADD_COMMAND[pm]} ${PACKAGE}@latest, then re-run init.`
1909
+ hints: [`Upgrade it with ${ADD_COMMAND[pm]} ${PACKAGE}@latest, then re-run init.`]
1910
+ };
1911
+ if (existsSync3(path)) {
1912
+ const drift = themeDrift(readFileSync2(path, "utf8"), parseDecisions(css));
1913
+ const news = drift.added.length ? ` \xB7 ${drift.added.length} new decision${drift.added.length === 1 ? "" : "s"} available` : "";
1914
+ const hints = [];
1915
+ if (drift.added.length) hints.push(driftHint(drift, "npx zyncat-ui update"));
1916
+ if (drift.deprecated.length) hints.push(deprecatedNote(drift.deprecated));
1917
+ return {
1918
+ line: row("Theme file", `${rel} \xB7 kept${news}`),
1919
+ done: true,
1920
+ hints,
1921
+ warn: drift.removed.length ? removedWarning(drift.removed) : void 0
1922
+ };
1923
+ }
1924
+ const text = themeFileText(css, version2);
1925
+ if (!text)
1926
+ return {
1927
+ line: row("Theme file", `skipped \xB7 ${THEME_SOURCE} has no :root block`),
1928
+ done: false,
1929
+ hints: [`Upgrade it with ${ADD_COMMAND[pm]} ${PACKAGE}@latest, then re-run init.`]
1785
1930
  };
1786
1931
  writeFileSync(path, text);
1787
1932
  return { line: row("Theme file", `${rel} \xB7 written`), done: true };
1788
1933
  }
1789
- function wireStyles(cwd, entry) {
1934
+ var STYLES_LINE = /^\s*import\s+(['"])@zyncat\/ui\/styles\.css\1;?\s*$/;
1935
+ var THEME_LINE = new RegExp(`^\\s*import\\s+(['"])[^'"]*${THEME_FILE.replace(/\./g, "\\.")}\\1;?\\s*$`);
1936
+ var CSS_LINE = /^\s*import\s+(['"])(\.[^'"]*\.css)\1;?\s*$/;
1937
+ var slashes = (path) => path.split(/[\\/]/).filter(Boolean).join("/");
1938
+ function importsStylesheet(line, fromDir, target) {
1939
+ const spec = CSS_LINE.exec(line)?.[2];
1940
+ return spec !== void 0 && slashes(join3(fromDir, spec)) === slashes(target);
1941
+ }
1942
+ function wireStyles(cwd, entry, tailwindEntry) {
1943
+ const below = tailwindEntry ? `below the ${tailwindEntry} import` : "above your own stylesheets";
1790
1944
  if (!entry)
1791
1945
  return {
1792
1946
  line: row("Stylesheet", "no app entry found \xB7 add the imports yourself"),
1793
1947
  done: false,
1794
- hint: `Put ${STYLES_IMPORT} then ${THEME_IMPORT} at your app root, above your own stylesheets.`
1948
+ hints: [`Put ${STYLES_IMPORT} then ${THEME_IMPORT} at your app root, ${below}.`]
1795
1949
  };
1796
1950
  const path = join3(cwd, entry);
1797
1951
  const text = readFileSync2(path, "utf8");
1798
1952
  const eol = text.includes("\r\n") ? "\r\n" : "\n";
1799
- const lines = text.split(eol);
1800
- const added = [];
1801
- let stylesAt = lines.findIndex((line) => line.includes("@zyncat/ui/styles.css"));
1802
- if (stylesAt === -1) {
1803
- stylesAt = 0;
1804
- while (stylesAt < lines.length && (lines[stylesAt].trim() === "" || /^(['"])use [\w-]+\1;?$/.test(lines[stylesAt].trim())))
1805
- stylesAt++;
1806
- lines.splice(stylesAt, 0, STYLES_IMPORT);
1807
- added.push("styles");
1808
- }
1809
- if (existsSync3(join3(cwd, dirname3(entry), THEME_FILE)) && !text.includes(THEME_FILE)) {
1810
- lines.splice(stylesAt + 1, 0, THEME_IMPORT);
1811
- added.push("theme");
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";
1953
+ const dir = dirname3(entry);
1954
+ const hasTheme = existsSync3(join3(cwd, dir, THEME_FILE));
1955
+ const mine = (line) => STYLES_LINE.test(line) || hasTheme && THEME_LINE.test(line);
1956
+ const had = text.split(eol).some(mine);
1957
+ const kept = text.split(eol).filter((line) => !mine(line));
1958
+ const bridgeAt = tailwindEntry ? kept.findIndex((line) => importsStylesheet(line, dir, tailwindEntry)) : -1;
1959
+ let at = 0;
1960
+ if (bridgeAt !== -1) at = bridgeAt + 1;
1961
+ else while (at < kept.length && (kept[at].trim() === "" || /^(['"])use [\w-]+\1;?$/.test(kept[at].trim()))) at++;
1962
+ kept.splice(at, 0, STYLES_IMPORT, ...hasTheme ? [THEME_IMPORT] : []);
1963
+ const next = kept.join(eol);
1964
+ if (next === text) return { line: row("Stylesheet", `${entry} \xB7 already imported`), done: true };
1965
+ writeFileSync(path, next);
1966
+ const what = had && bridgeAt !== -1 ? `imports moved below ${tailwindEntry}` : had ? "imports updated" : "imports added";
1816
1967
  return { line: row("Stylesheet", `${entry} \xB7 ${what}`), done: true };
1817
1968
  }
1818
1969
  function wireTailwind(cwd, targetPkg) {
@@ -1822,25 +1973,26 @@ function wireTailwind(cwd, targetPkg) {
1822
1973
  return {
1823
1974
  line: row("Tailwind", `skipped \xB7 Tailwind ${major} has no @theme`),
1824
1975
  done: false,
1825
- hint: `The bridge needs Tailwind v4 - ${DOCS_URL}/theming#tailwind.`
1976
+ hints: [`The bridge needs Tailwind v4 - ${DOCS_URL}/theming#tailwind.`]
1826
1977
  };
1827
1978
  const entry = findTailwindEntry(cwd);
1828
1979
  if (!entry)
1829
1980
  return {
1830
1981
  line: row("Tailwind", "no stylesheet imports tailwindcss \xB7 add the line yourself"),
1831
1982
  done: false,
1832
- hint: `Put @import '${TAILWIND_BRIDGE}'; above @import 'tailwindcss'; in the stylesheet Tailwind compiles.`
1983
+ hints: [`Put @import '${TAILWIND_BRIDGE}'; above @import 'tailwindcss'; in the stylesheet Tailwind compiles.`]
1833
1984
  };
1834
1985
  const path = join3(cwd, entry);
1835
1986
  const text = readFileSync2(path, "utf8");
1836
- if (text.includes(TAILWIND_BRIDGE)) return { line: row("Tailwind", `${entry} \xB7 already imported`), done: true };
1987
+ if (text.includes(TAILWIND_BRIDGE))
1988
+ return { line: row("Tailwind", `${entry} \xB7 already imported`), done: true, bridge: entry };
1837
1989
  const eol = text.includes("\r\n") ? "\r\n" : "\n";
1838
1990
  const lines = text.split(eol);
1839
1991
  const at = lines.findIndex((line) => TAILWIND_IMPORT.test(line));
1840
1992
  const quote = lines[at].includes('"') ? '"' : "'";
1841
1993
  lines.splice(at, 0, `@import ${quote}${TAILWIND_BRIDGE}${quote};`);
1842
1994
  writeFileSync(path, lines.join(eol));
1843
- return { line: row("Tailwind", `${entry} \xB7 import added`), done: true };
1995
+ return { line: row("Tailwind", `${entry} \xB7 import added`), done: true, bridge: entry };
1844
1996
  }
1845
1997
  async function init(flags) {
1846
1998
  const startedAt = performance.now();
@@ -1862,6 +2014,7 @@ async function init(flags) {
1862
2014
  const pmVer = pmVersion(pm);
1863
2015
  const project = targetPkg.name ?? "unnamed project";
1864
2016
  log.message(dim(`${project} \xB7 ${pm}${pmVer ? ` ${pmVer}` : ""}`));
2017
+ const before = installedVersion(cwd, PACKAGE);
1865
2018
  const plan = await planInstall(cwd, targetPkg, flags, version2);
1866
2019
  const installed = await installPhase(pm, plan, cwd);
1867
2020
  installTouchedProject = true;
@@ -1869,18 +2022,21 @@ async function init(flags) {
1869
2022
  if (plan.reactNote) log.warn(plan.reactNote);
1870
2023
  await alignVersion(pm, cwd, version2);
1871
2024
  const packageRoot = sourceRoot(cwd, ownRoot);
2025
+ const landed = installedVersion(cwd, PACKAGE) ?? version2;
2026
+ if (before && isOlder(before, landed)) log.message(crossedVersions(before, landed), { symbol: check });
1872
2027
  const entry = findAppEntry(cwd);
1873
2028
  const tailwind = wireTailwind(cwd, targetPkg);
1874
2029
  const rows = [
1875
2030
  wireSkill(cwd, packageRoot, pm),
1876
2031
  wireMcp(cwd),
1877
- wireTheme(cwd, packageRoot, pm, entry),
1878
- wireStyles(cwd, entry),
2032
+ wireTheme(cwd, packageRoot, pm, entry, landed),
2033
+ wireStyles(cwd, entry, tailwind?.bridge ?? null),
1879
2034
  ...tailwind ? [tailwind] : []
1880
2035
  ];
1881
2036
  for (const [index, entry2] of rows.entries()) {
1882
2037
  log.message(entry2.line, { symbol: entry2.done ? check : skip, spacing: index === 0 ? 1 : 0 });
1883
- if (entry2.hint) log.message(dim(entry2.hint), { spacing: 0 });
2038
+ for (const hint of entry2.hints ?? []) log.message(dim(hint), { spacing: 0 });
2039
+ if (entry2.warn) log.warn(entry2.warn);
1884
2040
  }
1885
2041
  log.message(`${dim("Docs")} ${arrow} ${accentDeep(DOCS_URL)}`);
1886
2042
  const skipped = rows.filter((entry2) => !entry2.done).length;
@@ -1888,6 +2044,64 @@ async function init(flags) {
1888
2044
  outro(closing);
1889
2045
  }
1890
2046
 
2047
+ // src/update.ts
2048
+ import { existsSync as existsSync4, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "fs";
2049
+ import { join as join4 } from "path";
2050
+ var PACKAGE2 = "@zyncat/ui";
2051
+ var DOCS_URL2 = "https://ui.zyncat.app";
2052
+ var interactive2 = () => Boolean(process.stdout.isTTY && process.stdin.isTTY);
2053
+ function stop(message, hint) {
2054
+ log.error(message);
2055
+ if (hint) log.message(dim(hint), { spacing: 0 });
2056
+ outro(red("Nothing was changed."));
2057
+ process.exit(1);
2058
+ }
2059
+ async function update(flags) {
2060
+ const { root: ownRoot, version: version2 } = findOwnRoot();
2061
+ const cwd = process.cwd();
2062
+ intro(wordmark(version2));
2063
+ const targetPkg = readJson(join4(cwd, "package.json"));
2064
+ if (!targetPkg) stop("No package.json here - update runs inside a React project that already ran init.");
2065
+ if (targetPkg.name === PACKAGE2 || targetPkg.name === "zyncat-ui")
2066
+ stop("This is the zyncat-ui repository - update runs in a consumer project.");
2067
+ const packageRoot = sourceRoot(cwd, ownRoot);
2068
+ const landed = installedVersion(cwd, PACKAGE2);
2069
+ if (!landed) stop(`${PACKAGE2} is not installed here.`, "Run npx zyncat-ui init first.");
2070
+ log.message(dim(`${targetPkg.name ?? "unnamed project"} \xB7 ${PACKAGE2} ${landed}`));
2071
+ const shipped = shippedDecisionsCss(packageRoot);
2072
+ if (!shipped) stop(`${PACKAGE2} ${landed} ships no decisions to compare against.`);
2073
+ const { rel, path } = themePath(cwd, findAppEntry(cwd));
2074
+ if (!existsSync4(path)) stop(`No ${rel} here.`, "Run npx zyncat-ui init to write one.");
2075
+ const current = readFileSync3(path, "utf8");
2076
+ const stamp = stampOf(current);
2077
+ const drift = themeDrift(current, parseDecisions(shipped));
2078
+ if (drift.deprecated.length) log.message(dim(deprecatedNote(drift.deprecated)), { spacing: 0 });
2079
+ if (drift.removed.length) log.warn(removedWarning(drift.removed));
2080
+ if (!drift.added.length) {
2081
+ if (stamp !== landed) writeFileSync2(path, withDecisions(current, [], landed));
2082
+ log.message(row("Theme file", `${rel} \xB7 every decision in ${landed} is already in your file`), { symbol: check });
2083
+ outro(bold(stamp === landed ? "Up to date." : `Up to date. Stamp ${stamp} ${arrow} ${landed}.`));
2084
+ return;
2085
+ }
2086
+ log.message(
2087
+ `${bold(`${drift.added.length} new decision${drift.added.length === 1 ? "" : "s"}`)} ${dim(`since ${stamp}`)}
2088
+
2089
+ ${drift.added.map((decision) => renderDecision(decision, " ")).join("\n")}`
2090
+ );
2091
+ log.message(dim(driftHint(drift, "This")), { spacing: 0 });
2092
+ if (!flags.yes && interactive2()) {
2093
+ const answer = await confirm({ message: `Add ${drift.added.length === 1 ? "it" : "them"} to ${rel}?` });
2094
+ if (isCancel(answer) || !answer) {
2095
+ cancel("Cancelled - nothing was changed.");
2096
+ process.exit(isCancel(answer) ? 130 : 0);
2097
+ }
2098
+ }
2099
+ writeFileSync2(path, withDecisions(current, drift.added, landed));
2100
+ log.message(row("Theme file", `${rel} \xB7 ${drift.added.length} added, stamped ${landed}`), { symbol: check });
2101
+ log.message(`${dim("Docs")} ${arrow} ${accentDeep(`${DOCS_URL2}/theming`)}`);
2102
+ outro(bold("Your values were not touched."));
2103
+ }
2104
+
1891
2105
  // src/cli.ts
1892
2106
  function parseFlags(args) {
1893
2107
  const flags = { yes: false };
@@ -1912,11 +2126,12 @@ function help(version2) {
1912
2126
  ` ${dim("and, under Tailwind v4, the utility bridge.")}`,
1913
2127
  "",
1914
2128
  ` ${bold("Usage")}`,
1915
- ` zyncat-ui init ${dim("[flags]")}`,
2129
+ ` zyncat-ui init ${dim("[flags]")} ${dim("set the project up, or re-wire it after an upgrade")}`,
2130
+ ` zyncat-ui update ${dim("[flags]")} ${dim("add decisions the library gained since your theme file")}`,
1916
2131
  "",
1917
2132
  ` ${bold("Flags")}`,
1918
2133
  ` --yes, -y ${dim("accept every default, never prompt")}`,
1919
- ` --pm <name> ${dim(`force the package manager (${PACKAGE_MANAGERS.join(", ")})`)}`,
2134
+ ` --pm <name> ${dim(`force the package manager (${PACKAGE_MANAGERS.join(", ")}) - init only`)}`,
1920
2135
  "",
1921
2136
  ` ${dim("Docs")} ${arrow} ${accentDeep("https://ui.zyncat.app")}`,
1922
2137
  ""
@@ -1927,13 +2142,14 @@ var [command, ...rest] = process.argv.slice(2);
1927
2142
  var { version } = findOwnRoot();
1928
2143
  if (command === "--version" || command === "-v") {
1929
2144
  console.log(version);
1930
- } else if (command === "init") {
2145
+ } else if (command === "init" || command === "update") {
1931
2146
  const flags = parseFlags(rest);
1932
2147
  if (!flags) {
1933
2148
  console.error(help(version));
1934
2149
  process.exit(1);
1935
2150
  }
1936
- await init(flags);
2151
+ if (command === "init") await init(flags);
2152
+ else await update({ yes: flags.yes });
1937
2153
  } else {
1938
2154
  console.log(help(version));
1939
2155
  process.exit(command ? 1 : 0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zyncat-ui",
3
- "version": "0.15.0",
3
+ "version": "0.17.0",
4
4
  "description": "Setup CLI for @zyncat/ui - one command installs the package and wires the project.",
5
5
  "keywords": [
6
6
  "zyncat",
@@ -30,11 +30,6 @@
30
30
  "engines": {
31
31
  "node": ">=18"
32
32
  },
33
- "scripts": {
34
- "build": "tsup",
35
- "typecheck": "tsc -p tsconfig.json",
36
- "prepublishOnly": "pnpm build"
37
- },
38
33
  "publishConfig": {
39
34
  "access": "public"
40
35
  },
@@ -44,5 +39,9 @@
44
39
  "picocolors": "^1.1.1",
45
40
  "tsup": "^8.5.0",
46
41
  "typescript": "~6.0.3"
42
+ },
43
+ "scripts": {
44
+ "build": "tsup",
45
+ "typecheck": "tsc -p tsconfig.json"
47
46
  }
48
- }
47
+ }