@astralkit/cli 4.2.1 → 4.2.2

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/CHANGELOG.md ADDED
@@ -0,0 +1,37 @@
1
+ # Changelog
2
+
3
+ All notable changes to the `@astralkit/cli` package.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [4.2.2] — 2026-04-18
9
+
10
+ ### Fixed
11
+ - **CSS import ordering.** When `init` ran against a project with an existing `@import "tailwindcss";` line, it was prepending the astralkit imports *before* tailwindcss — the opposite of the recommended order (Tailwind v4 docs + our own main app put tailwindcss first, then `@theme` customizations). Now the astralkit imports are inserted on the line after the last tailwind-related line, matching the canonical order.
12
+ - **Tailwind version parsing** handles more real-world `package.json` version specifiers. Previous logic used `.replace(/[^0-9]/, '')` (no `g` flag, strips only first non-digit), which produced misleading numbers for values like `"^4.0.0-beta"`. New logic strips all leading non-digits before parsing and returns `null` for non-parseable values like `"latest"` or `"file:..."` instead of guessing.
13
+ - **Tailwind v3 plugin registration regex** now matches more formatting variants of the `plugins: [...]` array — including no-space (`plugins:[`) and newline-before-bracket formats. Previously only matched `plugins: [` (one space).
14
+ - **Package manager detection** now walks up parent directories looking for a lockfile, instead of checking only `cwd`. This correctly picks up pnpm/yarn/bun in monorepo subpackages where the lockfile lives at the workspace root.
15
+
16
+ ### Changed
17
+ - No user-facing API changes. All three fixes improve detection robustness during `init`.
18
+
19
+ ## [4.2.1] — 2026-04-18
20
+
21
+ ### Fixed
22
+ - **README example slugs.** Replaced three non-existent slugs (`pricing-table`, `sidebar-light`, `auth-system`) with real catalog slugs (`button-variants`, `sidebar-expanded-light`, `authentication-system`). Copy-pasting from the README now produces working commands.
23
+ - **`init` success message** no longer points at `pricing-table`. Now shows `astralkit add button-variants`.
24
+
25
+ ### Changed
26
+ - **Plans table in README** rewritten to reflect the actual four tiers (Free, Pro, Plus, Lifetime) documented on the pricing page. Previous table only showed Free/Pro and incorrectly claimed Free tier gets React/Next.js output (it's HTML-only via the website).
27
+ - **Environment variable documentation** expanded. Added `ASTRALKIT_TOKEN` (session JWT from browser login), tightened descriptions for `ASTRALKIT_API_KEY`, `ASTRALKIT_API_URL` (https-only-except-localhost note), and `ASTRALKIT_LOGIN_PORT` (valid range).
28
+
29
+ ### Added
30
+ - **"Discover what's available" section** in README. Points users at `astralkit list` and the showcase URLs rather than a hardcoded catalog list that would go stale.
31
+ - **Boosters / workflows roadmap note.** Makes clear they're rolling out through 2026 and that components (156 of them) are available now.
32
+
33
+ ## [4.2.0] — 2026-04-02
34
+
35
+ ### Previous public release.
36
+
37
+ Commands available: `init`, `add`, `remove`, `login`, `logout`, `whoami`, `list`, `search`, `diff`, `update`. Smart content detection across components/boosters/workflows registries. Framework detection (Next.js/React), Tailwind version detection (v3/v4), TypeScript detection, package manager detection (npm/pnpm/yarn/bun).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astralkit/cli",
3
- "version": "4.2.1",
3
+ "version": "4.2.2",
4
4
  "description": "AstralKit CLI — Install and manage UI components in your project",
5
5
  "type": "module",
6
6
  "bin": {
@@ -9,7 +9,8 @@
9
9
  "files": [
10
10
  "bin",
11
11
  "src",
12
- "LICENSE"
12
+ "LICENSE",
13
+ "CHANGELOG.md"
13
14
  ],
14
15
  "engines": {
15
16
  "node": ">=18.0.0"
@@ -147,17 +147,26 @@ export async function initCommand(options) {
147
147
  // Insert the plugin require into the plugins array
148
148
  const pluginLine = "require('astralkit/tailwind.cjs')";
149
149
 
150
- if (configContent.includes('plugins: [')) {
151
- // plugins array exists — add to it
150
+ // Match `plugins` followed by optional whitespace/newlines and an
151
+ // opening bracket. Covers:
152
+ // plugins: [ (current format)
153
+ // plugins:[ (no space)
154
+ // plugins: \n [ (newline before bracket)
155
+ // plugins = [ (variable assignment style, rare)
156
+ const arrayOpenRe = /plugins\s*[:=]\s*\[/;
157
+
158
+ if (arrayOpenRe.test(configContent)) {
159
+ // plugins array exists — inject after the opening bracket, preserving
160
+ // the user's indentation style as best we can
152
161
  const updated = configContent.replace(
153
- /plugins:\s*\[/,
154
- `plugins: [\n ${pluginLine},`
162
+ arrayOpenRe,
163
+ (match) => `${match}\n ${pluginLine},`
155
164
  );
156
165
  fs.writeFileSync(configFile, updated, 'utf8');
157
166
  p.log.success(`Added AstralKit plugin to ${pc.cyan(path.relative(process.cwd(), configFile))}`);
158
- } else if (configContent.includes('plugins:')) {
159
- // plugins exists but not as array — warn
160
- p.log.warn('Could not auto-add plugin to tailwind config.');
167
+ } else if (/plugins\s*[:=]/.test(configContent)) {
168
+ // plugins key exists but not as an array — warn
169
+ p.log.warn('Could not auto-add plugin to tailwind config (plugins is not an array literal).');
161
170
  p.log.info(`Add manually: ${pc.cyan(pluginLine)} to your plugins array.`);
162
171
  } else {
163
172
  p.log.warn('No plugins array found in tailwind config.');
package/src/lib/config.js CHANGED
@@ -45,7 +45,15 @@ export function detectTailwindVersion(dir = process.cwd()) {
45
45
  const allDeps = { ...pkg.dependencies, ...pkg.devDependencies };
46
46
  const ver = allDeps['tailwindcss'];
47
47
  if (!ver) return null;
48
- const major = parseInt(ver.replace(/[^0-9]/, ''), 10);
48
+ // Handle: "^4.0.0", "~4.1.2", "4.0.0-beta.1", ">=3.4.0", "file:...", "latest", "next".
49
+ // Strip only the leading non-digits (^ ~ >= etc.) then parse. Anything
50
+ // that doesn't start with a digit after stripping (file:..., latest, next,
51
+ // workspace:*) returns NaN from parseInt and falls through to null —
52
+ // better to return null than guess wrong.
53
+ const match = ver.match(/^\D*(\d+)/);
54
+ if (!match) return null;
55
+ const major = parseInt(match[1], 10);
56
+ if (Number.isNaN(major)) return null;
49
57
  if (major >= 4) return 4;
50
58
  if (major >= 3) return 3;
51
59
  return null;
@@ -124,27 +132,33 @@ export function getMissingCssImports(cssFilePath, tailwindVersion) {
124
132
 
125
133
  export function addCssImports(cssFilePath, imports) {
126
134
  const existing = fs.existsSync(cssFilePath) ? fs.readFileSync(cssFilePath, 'utf8') : '';
127
-
128
- // Separate Tailwind directives from AstralKit imports
129
- const tailwindDirectives = imports.filter(i => i.startsWith('@tailwind') || i === '@import "tailwindcss";');
130
135
  const astralkitImports = imports.filter(i => i.includes('astralkit'));
131
136
 
132
- // For v3: if @tailwind directives already exist, add astralkit imports AFTER them
133
- if (existing.includes('@tailwind utilities')) {
134
- // Find the last @tailwind line and insert after it
137
+ // If Tailwind is already imported/directive'd in the file (v3 @tailwind
138
+ // directives OR v4 @import "tailwindcss"), insert astralkit imports AFTER
139
+ // the last Tailwind-related line. This preserves the recommended ordering
140
+ // (tailwindcss first, astralkit after) instead of prepending astralkit
141
+ // imports before tailwindcss in the file.
142
+ const tailwindImportRe = /^@import\s+["']tailwindcss["']/;
143
+ const hasTailwind = existing.includes('@tailwind utilities') || tailwindImportRe.test(existing);
144
+
145
+ if (hasTailwind && astralkitImports.length > 0) {
135
146
  const lines = existing.split('\n');
136
147
  let lastTailwindIdx = -1;
137
148
  for (let i = 0; i < lines.length; i++) {
138
- if (lines[i].trim().startsWith('@tailwind')) lastTailwindIdx = i;
149
+ const trimmed = lines[i].trim();
150
+ if (trimmed.startsWith('@tailwind') || tailwindImportRe.test(trimmed)) {
151
+ lastTailwindIdx = i;
152
+ }
139
153
  }
140
- if (lastTailwindIdx >= 0 && astralkitImports.length > 0) {
154
+ if (lastTailwindIdx >= 0) {
141
155
  lines.splice(lastTailwindIdx + 1, 0, '', ...astralkitImports);
142
156
  fs.writeFileSync(cssFilePath, lines.join('\n'));
143
157
  return;
144
158
  }
145
159
  }
146
160
 
147
- // Default: prepend everything (v4 or fresh file)
161
+ // Default: prepend everything (fresh file with no Tailwind yet)
148
162
  fs.writeFileSync(cssFilePath, imports.join('\n') + '\n\n' + existing);
149
163
  }
150
164
 
@@ -3,9 +3,24 @@ import path from 'path';
3
3
  import { execa } from 'execa';
4
4
 
5
5
  export function detectPackageManager(dir = process.cwd()) {
6
- if (fs.existsSync(path.join(dir, 'bun.lockb')) || fs.existsSync(path.join(dir, 'bun.lock'))) return 'bun';
7
- if (fs.existsSync(path.join(dir, 'pnpm-lock.yaml'))) return 'pnpm';
8
- if (fs.existsSync(path.join(dir, 'yarn.lock'))) return 'yarn';
6
+ // Walk up from `dir` to the filesystem root, stopping at the first lockfile
7
+ // found. Handles monorepos where the lockfile lives at the workspace root
8
+ // (e.g., running `astralkit init` inside `packages/my-app/` of a pnpm repo).
9
+ let current = path.resolve(dir);
10
+ const { root } = path.parse(current);
11
+
12
+ while (true) {
13
+ if (fs.existsSync(path.join(current, 'bun.lockb')) || fs.existsSync(path.join(current, 'bun.lock'))) return 'bun';
14
+ if (fs.existsSync(path.join(current, 'pnpm-lock.yaml'))) return 'pnpm';
15
+ if (fs.existsSync(path.join(current, 'yarn.lock'))) return 'yarn';
16
+ if (fs.existsSync(path.join(current, 'package-lock.json'))) return 'npm';
17
+
18
+ if (current === root) break;
19
+ const parent = path.dirname(current);
20
+ if (parent === current) break; // belt-and-suspenders against infinite loops
21
+ current = parent;
22
+ }
23
+
9
24
  return 'npm';
10
25
  }
11
26