@csszyx/cli 0.9.4 → 0.9.6

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 (2) hide show
  1. package/dist/index.mjs +52 -1
  2. package/package.json +3 -3
package/dist/index.mjs CHANGED
@@ -1271,7 +1271,10 @@ async function init(options = {}) {
1271
1271
  }
1272
1272
  const spin = spinner.start("Installing csszyx...");
1273
1273
  try {
1274
- await execa(projectInfo.packageManager, ["add", "csszyx"], { cwd });
1274
+ await execa(projectInfo.packageManager, ["add", "csszyx", "@csszyx/runtime"], { cwd });
1275
+ if (projectInfo.hasTypeScript) {
1276
+ await execa(projectInfo.packageManager, ["add", "-D", "@csszyx/types"], { cwd });
1277
+ }
1275
1278
  if (config.installTailwind) {
1276
1279
  const twPackage = VITE_FRAMEWORKS.has(projectInfo.framework) ? "@tailwindcss/vite" : "@tailwindcss/postcss";
1277
1280
  await execa(projectInfo.packageManager, ["add", "-D", "tailwindcss", twPackage], {
@@ -1311,6 +1314,9 @@ async function init(options = {}) {
1311
1314
  if (config.setupTsconfig) {
1312
1315
  await setupTsconfig(cwd);
1313
1316
  }
1317
+ if (projectInfo.hasTypeScript) {
1318
+ await setupSzTypes(cwd);
1319
+ }
1314
1320
  spinner.succeed(spin2, "Created configuration files");
1315
1321
  } catch (error) {
1316
1322
  spinner.fail(spin2, "Failed to create config files");
@@ -1322,6 +1328,9 @@ async function init(options = {}) {
1322
1328
  console.log();
1323
1329
  printInfo("Next steps:");
1324
1330
  console.log(` \u2022 Run '${projectInfo.packageManager} run dev' to start`);
1331
+ if (projectInfo.hasTypeScript) {
1332
+ console.log(" \u2022 The `sz` prop is typed via csszyx-env.d.ts");
1333
+ }
1325
1334
  console.log(" \u2022 Check the docs at https://csszyx.dev");
1326
1335
  }
1327
1336
  async function setupTailwindCss(cwd, framework) {
@@ -1473,6 +1482,48 @@ async function setupTsconfig(cwd) {
1473
1482
  await fs.writeFile(tsconfigPath, content);
1474
1483
  }
1475
1484
  }
1485
+ async function setupSzTypes(cwd) {
1486
+ const envPath = path__default.join(cwd, "csszyx-env.d.ts");
1487
+ const reference = '/// <reference types="@csszyx/types/jsx" />';
1488
+ const existing = await readFileOrNull(envPath);
1489
+ if (existing === null) {
1490
+ await fs.writeFile(
1491
+ envPath,
1492
+ `// Generated by csszyx. Enables the \`sz\` JSX prop types.
1493
+ ${reference}
1494
+ `
1495
+ );
1496
+ printInfo("Created csszyx-env.d.ts (sz prop types)");
1497
+ } else if (!existing.includes("@csszyx/types/jsx")) {
1498
+ await fs.writeFile(envPath, `${existing.trimEnd()}
1499
+ ${reference}
1500
+ `);
1501
+ printInfo("Added the sz type reference to csszyx-env.d.ts");
1502
+ }
1503
+ await ensureTsconfigInclude(cwd, "csszyx-env.d.ts");
1504
+ }
1505
+ async function ensureTsconfigInclude(cwd, entry) {
1506
+ for (const name of ["tsconfig.json", "tsconfig.app.json"]) {
1507
+ const tsconfigPath = path__default.join(cwd, name);
1508
+ const content = await readFileOrNull(tsconfigPath);
1509
+ if (content === null) {
1510
+ continue;
1511
+ }
1512
+ if (content.includes(entry)) {
1513
+ return;
1514
+ }
1515
+ const includeMatch = content.match(/"include"\s*:\s*\[/);
1516
+ if (includeMatch && includeMatch.index !== void 0) {
1517
+ const insertPos = includeMatch.index + includeMatch[0].length;
1518
+ await fs.writeFile(
1519
+ tsconfigPath,
1520
+ `${content.slice(0, insertPos)}
1521
+ "${entry}",${content.slice(insertPos)}`
1522
+ );
1523
+ }
1524
+ return;
1525
+ }
1526
+ }
1476
1527
  function generateConfigFile(config) {
1477
1528
  return `import type { CsszyxConfig } from 'csszyx';
1478
1529
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@csszyx/cli",
3
- "version": "0.9.4",
3
+ "version": "0.9.6",
4
4
  "description": "Command-line tools for csszyx",
5
5
  "keywords": [
6
6
  "csszyx",
@@ -49,8 +49,8 @@
49
49
  "picocolors": "^1.0.0",
50
50
  "prompts": "^2.4.2",
51
51
  "tailwindcss": "^3.4.1",
52
- "@csszyx/unplugin": "0.9.4",
53
- "@csszyx/types": "0.9.4"
52
+ "@csszyx/types": "0.9.6",
53
+ "@csszyx/unplugin": "0.9.6"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@types/fs-extra": "^11.0.4",