7onic 0.1.5 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +76 -8
- package/llms.txt +6 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1296,10 +1296,26 @@ async function init(args) {
|
|
|
1296
1296
|
} catch {
|
|
1297
1297
|
}
|
|
1298
1298
|
}
|
|
1299
|
+
const viteConfigPath = import_node_fs4.default.existsSync(import_node_path4.default.join(projectRoot, "vite.config.ts")) ? import_node_path4.default.join(projectRoot, "vite.config.ts") : import_node_fs4.default.existsSync(import_node_path4.default.join(projectRoot, "vite.config.js")) ? import_node_path4.default.join(projectRoot, "vite.config.js") : null;
|
|
1300
|
+
const isViteProject = import_node_fs4.default.existsSync(import_node_path4.default.join(projectRoot, "tsconfig.app.json")) && viteConfigPath !== null;
|
|
1301
|
+
let needsTypesNode = false;
|
|
1299
1302
|
if (!hasPathAlias) {
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
+
if (isViteProject) {
|
|
1304
|
+
const tscPatch = patchTsconfigApp(import_node_path4.default.join(projectRoot, "tsconfig.app.json"));
|
|
1305
|
+
const vitePatch = patchViteConfig(viteConfigPath);
|
|
1306
|
+
if (vitePatch) needsTypesNode = true;
|
|
1307
|
+
if (tscPatch || vitePatch) {
|
|
1308
|
+
O2.success("Configured @/ path alias in tsconfig.app.json and vite.config.ts");
|
|
1309
|
+
} else {
|
|
1310
|
+
O2.warn(
|
|
1311
|
+
'Could not auto-configure @/ path alias. Add manually:\n tsconfig.app.json \u2192 compilerOptions.paths: { "@/*": ["./src/*"] }\n vite.config.ts \u2192 resolve: { alias: { "@": path.resolve(__dirname, "./src") } }'
|
|
1312
|
+
);
|
|
1313
|
+
}
|
|
1314
|
+
} else {
|
|
1315
|
+
O2.warn(
|
|
1316
|
+
"No @/ path alias detected.\n Next.js: automatic (no action needed)\n Other: configure compilerOptions.paths in tsconfig.json"
|
|
1317
|
+
);
|
|
1318
|
+
}
|
|
1303
1319
|
}
|
|
1304
1320
|
try {
|
|
1305
1321
|
const pkgJson = JSON.parse(import_node_fs4.default.readFileSync(import_node_path4.default.join(projectRoot, "package.json"), "utf-8"));
|
|
@@ -1363,6 +1379,9 @@ async function init(args) {
|
|
|
1363
1379
|
s.start(`Installing dependencies (${pm})...`);
|
|
1364
1380
|
try {
|
|
1365
1381
|
installDeps(baseDeps, { cwd: projectRoot, pm });
|
|
1382
|
+
if (needsTypesNode) {
|
|
1383
|
+
installDeps(["@types/node"], { cwd: projectRoot, pm, dev: true });
|
|
1384
|
+
}
|
|
1366
1385
|
s.stop("Dependencies installed");
|
|
1367
1386
|
} catch (err) {
|
|
1368
1387
|
s.stop("Failed to install dependencies");
|
|
@@ -1456,6 +1475,48 @@ async function init(args) {
|
|
|
1456
1475
|
O2.success("Created 7onic.json");
|
|
1457
1476
|
gt("Done! Run " + import_picocolors2.default.cyan("npx 7onic add <component>") + " to add components.");
|
|
1458
1477
|
}
|
|
1478
|
+
function patchTsconfigApp(tsconfigPath) {
|
|
1479
|
+
try {
|
|
1480
|
+
const raw = import_node_fs4.default.readFileSync(tsconfigPath, "utf-8");
|
|
1481
|
+
const clean = raw.replace(/\/\*[\s\S]*?\*\//g, "").replace(/\/\/.*$/gm, "").replace(/,(\s*[}\]])/g, "$1");
|
|
1482
|
+
const tc = JSON.parse(clean);
|
|
1483
|
+
if (!tc.compilerOptions) tc.compilerOptions = {};
|
|
1484
|
+
const existingPaths = tc.compilerOptions.paths ?? {};
|
|
1485
|
+
if (existingPaths["@/*"]) return false;
|
|
1486
|
+
tc.compilerOptions.paths = { "@/*": ["./src/*"], ...existingPaths };
|
|
1487
|
+
import_node_fs4.default.writeFileSync(tsconfigPath, JSON.stringify(tc, null, 2), "utf-8");
|
|
1488
|
+
return true;
|
|
1489
|
+
} catch {
|
|
1490
|
+
return false;
|
|
1491
|
+
}
|
|
1492
|
+
}
|
|
1493
|
+
function patchViteConfig(viteConfigPath) {
|
|
1494
|
+
try {
|
|
1495
|
+
let content = import_node_fs4.default.readFileSync(viteConfigPath, "utf-8");
|
|
1496
|
+
if (content.includes("'@'") || content.includes('"@"') || content.includes("'@/*'") || content.includes('"@/*"') || content.includes("resolve:")) return false;
|
|
1497
|
+
if (!content.includes("import path from 'path'") && !content.includes('import path from "path"')) {
|
|
1498
|
+
const importMatches = [...content.matchAll(/^import .+$/gm)];
|
|
1499
|
+
const lastImport = importMatches.at(-1);
|
|
1500
|
+
if (lastImport?.index !== void 0) {
|
|
1501
|
+
const insertAt = lastImport.index + lastImport[0].length;
|
|
1502
|
+
content = content.slice(0, insertAt) + "\nimport path from 'path'" + content.slice(insertAt);
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
const lastClose = content.lastIndexOf("\n})");
|
|
1506
|
+
if (lastClose === -1) return false;
|
|
1507
|
+
const beforeClose = content.slice(0, lastClose).trimEnd();
|
|
1508
|
+
const comma = beforeClose.endsWith(",") ? "" : ",";
|
|
1509
|
+
const resolveBlock = `${comma}
|
|
1510
|
+
resolve: {
|
|
1511
|
+
alias: { '@': path.resolve(__dirname, './src') },
|
|
1512
|
+
},`;
|
|
1513
|
+
content = content.slice(0, lastClose) + resolveBlock + content.slice(lastClose);
|
|
1514
|
+
import_node_fs4.default.writeFileSync(viteConfigPath, content, "utf-8");
|
|
1515
|
+
return true;
|
|
1516
|
+
} catch {
|
|
1517
|
+
return false;
|
|
1518
|
+
}
|
|
1519
|
+
}
|
|
1459
1520
|
function resolveAliasPath(projectRoot, alias) {
|
|
1460
1521
|
if (!alias.startsWith("@/")) return null;
|
|
1461
1522
|
const relative = alias.slice(2);
|
|
@@ -8796,9 +8857,8 @@ const PaginationRoot = React.forwardRef<HTMLElement, PaginationProps>(
|
|
|
8796
8857
|
color = 'default',
|
|
8797
8858
|
radius = 'md',
|
|
8798
8859
|
disabled = false,
|
|
8799
|
-
|
|
8800
|
-
|
|
8801
|
-
withEdges: _withEdges = false,
|
|
8860
|
+
withControls = true,
|
|
8861
|
+
withEdges = false,
|
|
8802
8862
|
loop = false,
|
|
8803
8863
|
children,
|
|
8804
8864
|
...props
|
|
@@ -8841,7 +8901,15 @@ const PaginationRoot = React.forwardRef<HTMLElement, PaginationProps>(
|
|
|
8841
8901
|
className={cn('', className)}
|
|
8842
8902
|
{...props}
|
|
8843
8903
|
>
|
|
8844
|
-
{children
|
|
8904
|
+
{children ?? (
|
|
8905
|
+
<PaginationContent>
|
|
8906
|
+
{withEdges && <PaginationItem><PaginationFirst /></PaginationItem>}
|
|
8907
|
+
{withControls && <PaginationItem><PaginationPrevious /></PaginationItem>}
|
|
8908
|
+
<PaginationItems />
|
|
8909
|
+
{withControls && <PaginationItem><PaginationNext /></PaginationItem>}
|
|
8910
|
+
{withEdges && <PaginationItem><PaginationLast /></PaginationItem>}
|
|
8911
|
+
</PaginationContent>
|
|
8912
|
+
)}
|
|
8845
8913
|
</nav>
|
|
8846
8914
|
</PaginationContext.Provider>
|
|
8847
8915
|
)
|
|
@@ -14418,7 +14486,7 @@ function showSetupHints(names) {
|
|
|
14418
14486
|
|
|
14419
14487
|
// cli/src/index.ts
|
|
14420
14488
|
var import_picocolors4 = __toESM(require_picocolors());
|
|
14421
|
-
var VERSION = "0.1.
|
|
14489
|
+
var VERSION = "0.1.7";
|
|
14422
14490
|
var HELP = `
|
|
14423
14491
|
${import_picocolors4.default.bold("7onic")} \u2014 Add 7onic design system components to your project
|
|
14424
14492
|
|
package/llms.txt
CHANGED
|
@@ -25,14 +25,15 @@ npx 7onic init --tailwind v3 --yes # Explicit v3, skip prompts
|
|
|
25
25
|
**What it does:**
|
|
26
26
|
1. Detects Tailwind version (v3: config file exists, v4: no config) — or uses `--tailwind` flag
|
|
27
27
|
2. Detects package manager (npm/pnpm/yarn/bun)
|
|
28
|
-
3.
|
|
29
|
-
4.
|
|
30
|
-
5. Creates
|
|
31
|
-
6.
|
|
28
|
+
3. **Vite projects**: auto-configures `@/` path alias — patches `tsconfig.app.json` (JSONC-safe) and `vite.config.ts` (adds `import path` + `resolve.alias`), installs `@types/node`
|
|
29
|
+
4. Installs: `@7onic-ui/tokens`, `lucide-react`, `clsx`, `tailwind-merge`, `class-variance-authority`
|
|
30
|
+
5. Creates/updates CSS file with token imports (v4: auto-injects `@import "tailwindcss"` if missing)
|
|
31
|
+
6. Creates `cn()` utility at configured path
|
|
32
|
+
7. Writes `7onic.json` config
|
|
32
33
|
|
|
33
34
|
**Requirements:**
|
|
34
35
|
- TypeScript project (tsconfig.json required)
|
|
35
|
-
- `@/` path alias configured
|
|
36
|
+
- `@/` path alias — auto-configured for Vite; Next.js handles this automatically
|
|
36
37
|
|
|
37
38
|
### add
|
|
38
39
|
|