youiyoux 0.1.8 → 0.1.9

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.
@@ -2357,14 +2357,26 @@ function moveDeclarations(css, blocks, moved, importPath) {
2357
2357
  const rules = readRules(css).filter((r) => blocks.some((b) => r.preludes.at(-1) === b.selector && (b.outer ? r.preludes.length === 2 && r.preludes[0] === b.outer : r.preludes.length === 1)));
2358
2358
  if (rules.length === 0) return null;
2359
2359
  const lines = css.split("\n");
2360
+ const byLine = /* @__PURE__ */ new Map();
2361
+ for (const rule2 of rules) for (const d of rule2.declarations) if (moved.has(d.property.slice(2))) byLine.set(d.line - 1, (byLine.get(d.line - 1) ?? /* @__PURE__ */ new Set()).add(d.property));
2362
+ let count = 0;
2363
+ const kept = [];
2360
2364
  const drop = /* @__PURE__ */ new Set();
2361
- for (const rule2 of rules) {
2362
- for (const d of rule2.declarations) {
2363
- const line = lines[d.line - 1] ?? "";
2364
- if (moved.has(d.property.slice(2)) && new RegExp(`^\\s*${d.property.replace(/[-]/g, "\\-")}\\s*:[^;]*;?\\s*$`).test(line)) drop.add(d.line - 1);
2365
- }
2365
+ for (const [index, properties] of byLine) {
2366
+ const segments = lines[index].split(";");
2367
+ const left = segments.filter((segment) => {
2368
+ const property = /^\s*(--[\w-]+)\s*:/.exec(segment)?.[1];
2369
+ if (property === void 0 || !properties.has(property)) return true;
2370
+ properties.delete(property);
2371
+ count++;
2372
+ return false;
2373
+ });
2374
+ kept.push(...[...properties].map((p) => p.slice(2)));
2375
+ const text = left.join(";");
2376
+ if (text.trim() === "") drop.add(index);
2377
+ else lines[index] = /^\s/.test(text) || index === 0 ? text : `${lines[index].match(/^\s*/)[0]}${text.trimStart()}`;
2366
2378
  }
2367
- if (drop.size === 0) return null;
2379
+ if (count === 0) return null;
2368
2380
  let content = lines.filter((_, i) => !drop.has(i)).join("\n");
2369
2381
  for (const block of blocks) content = content.replace(new RegExp(`(^|\\n)[ \\t]*${block.selector.replace(/[.[\]()"=:]/g, "\\$&")}\\s*\\{\\s*\\}[ \\t]*(?=\\n|$)`, "g"), "");
2370
2382
  for (const outer of new Set(blocks.flatMap((b) => b.outer ? [b.outer] : []))) content = content.replace(new RegExp(`(^|\\n)[ \\t]*${outer.replace(/[.[\]()"=:]/g, "\\$&")}\\s*\\{\\s*\\}[ \\t]*(?=\\n|$)`, "g"), "");
@@ -2374,7 +2386,7 @@ function moveDeclarations(css, blocks, moved, importPath) {
2374
2386
  content = at > 0 ? `${content.slice(0, at)}
2375
2387
  ${statement}${content.slice(at)}` : `${statement}
2376
2388
  ${content}`;
2377
- return { content: content.replace(/\n{3,}/g, "\n\n"), moved: drop.size };
2389
+ return { content: content.replace(/\n{3,}/g, "\n\n"), moved: count, kept: [...new Set(kept)].sort() };
2378
2390
  }
2379
2391
  async function planAdoption(options) {
2380
2392
  const root = options.root;
@@ -2470,6 +2482,10 @@ async function planAdoption(options) {
2470
2482
  const rewritten = moving && found.forked ? { ...moving, content: moving.content.split("\n").filter((line) => !line.includes(GENERATED_MARK) && !/^\/\* Built with Terrazzo/.test(line)).join("\n") } : moving;
2471
2483
  if (found.forked) notes.push(`forked from ${found.forked.system ?? "the System"}${found.forked.version ? ` v${found.forked.version}` : ""}: this product's System starts from the ${found.forked.count} variables it generated into ${found.forked.file}, and the product no longer follows ${found.forked.system ?? "it"}`);
2472
2484
  if (css && moved.size > 0 && !rewritten) notes.push(`${stylesheet}'s variables were copied, not moved (their blocks are nested or share lines): import ${OUT_DIR}/tokens.css from it and remove them by hand`);
2485
+ const read = [":root", ...darkBlocks.map((b) => [b.outer, b.selector].filter(Boolean).join(" > "))];
2486
+ const others = css ? [...new Set(readRules(css).filter((r) => !read.includes(r.preludes.join(" > ")) && !r.preludes.at(-1).startsWith("@") && r.declarations.some((d) => d.property.startsWith("--"))).map((r) => r.preludes.join(" > ").replace(/\s+/g, " ")))] : [];
2487
+ if (others.length > 0) notes.push(`${plural(others.length, "other block")} in ${stylesheet} set${others.length === 1 ? "s" : ""} variables too and stay${others.length === 1 ? "s" : ""} there, as ${others.length === 1 ? "it was" : "they were"} (${others.slice(0, 4).join(" \xB7 ")}${others.length > 4 ? " \xB7 \u2026" : ""}): the System holds the :root${darkBlocks.length > 0 ? " and dark" : ""} values only`);
2488
+ if (rewritten && rewritten.kept.length > 0) notes.push(`${plural(rewritten.kept.length, "variable")} ${rewritten.kept.length === 1 ? "stays" : "stay"} in ${stylesheet} too, written where adopt cannot take them out alone (beside a selector): ${rewritten.kept.slice(0, 4).map((n) => `--${n}`).join(", ")}${rewritten.kept.length > 4 ? ", \u2026" : ""}; they hold the same values, so remove them by hand`);
2473
2489
  for (const [rule2, content] of starterRules(id, componentsDir)) out.push({ path: `design/rules/${rule2}.rule.yaml`, content });
2474
2490
  out.push({
2475
2491
  path: "design/design.md",
package/dist/youi.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import { createRequire as __youiRequire } from "node:module"; import { dirname as __youiDir } from "node:path"; import { fileURLToPath as __youiPath } from "node:url"; const require = __youiRequire(import.meta.url); const __youiDirname = __youiDir(__youiPath(import.meta.url));
3
3
  import {
4
4
  main
5
- } from "./chunks/chunk-BARSW3JO.js";
5
+ } from "./chunks/chunk-E5OHZJBS.js";
6
6
  import "./chunks/chunk-3HON5Q5K.js";
7
7
  import "./chunks/chunk-42YJX3W5.js";
8
8
  import "./chunks/chunk-HDJ2TOWZ.js";
package/dist/youiyoux.js CHANGED
@@ -3,7 +3,7 @@ import { createRequire as __youiRequire } from "node:module"; import { dirname a
3
3
  import {
4
4
  COMMAND_NAMES,
5
5
  main
6
- } from "./chunks/chunk-BARSW3JO.js";
6
+ } from "./chunks/chunk-E5OHZJBS.js";
7
7
  import "./chunks/chunk-3HON5Q5K.js";
8
8
  import "./chunks/chunk-42YJX3W5.js";
9
9
  import "./chunks/chunk-HDJ2TOWZ.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "youiyoux",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "description": "Your agent rebuilds components you already have. youiyoux catches it: npx youiyoux turns any repo into a shareable report of near-duplicate components, hardcoded token values and off-library imports, with the fixes.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -46,9 +46,9 @@
46
46
  "typescript": "6.0.3"
47
47
  },
48
48
  "devDependencies": {
49
- "@youiyoux/cli": "0.1.8",
50
- "@youiyoux/core": "0.1.8",
51
- "@youiyoux/scanner": "0.1.8"
49
+ "@youiyoux/cli": "0.1.9",
50
+ "@youiyoux/core": "0.1.9",
51
+ "@youiyoux/scanner": "0.1.9"
52
52
  },
53
53
  "exports": {
54
54
  "./package.json": "./package.json"