@astralkit/cli 3.0.2 → 3.0.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astralkit/cli",
3
- "version": "3.0.2",
3
+ "version": "3.0.3",
4
4
  "description": "AstralKit CLI — Install and manage UI components in your project",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "bin": {
@@ -85,28 +85,37 @@ async function initCommand(options) {
85
85
  const response = await apiRequest('/api/cli/sdk');
86
86
  const data = await response.json();
87
87
 
88
- // Create node_modules/astralkit/ directory structure
88
+ // Install runtime dependencies FIRST (clsx + tailwind-merge)
89
+ // Must happen before writing astralkit files, because npm prunes
90
+ // extraneous folders from node_modules during install.
91
+ const pm = detectPackageManager();
92
+ const depsCmd = pm === 'yarn' ? 'yarn add clsx tailwind-merge'
93
+ : pm === 'pnpm' ? 'pnpm add clsx tailwind-merge'
94
+ : pm === 'bun' ? 'bun add clsx tailwind-merge'
95
+ : 'npm install clsx tailwind-merge';
96
+ execSync(depsCmd, { stdio: 'pipe', cwd: process.cwd() });
97
+
98
+ // Now write astralkit token files to node_modules/astralkit/
99
+ // (after npm install so they don't get pruned)
89
100
  const sdkDir = path.join(process.cwd(), 'node_modules', 'astralkit');
90
101
  const libDir = path.join(sdkDir, 'lib');
91
102
  fs.mkdirSync(libDir, { recursive: true });
92
103
 
93
- // Write all files
94
- for (const [filePath, content] of Object.entries(data.files)) {
104
+ let filesWritten = 0;
105
+ for (const [filePath, content] of Object.entries(data.files || {})) {
95
106
  const fullPath = path.join(sdkDir, filePath);
96
107
  const dir = path.dirname(fullPath);
97
108
  if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
98
109
  fs.writeFileSync(fullPath, content, 'utf-8');
110
+ filesWritten++;
99
111
  }
100
112
 
101
- // Also install the runtime dependencies (clsx + tailwind-merge)
102
- const pm = detectPackageManager();
103
- const depsCmd = pm === 'yarn' ? 'yarn add clsx tailwind-merge'
104
- : pm === 'pnpm' ? 'pnpm add clsx tailwind-merge'
105
- : pm === 'bun' ? 'bun add clsx tailwind-merge'
106
- : 'npm install clsx tailwind-merge';
107
- execSync(depsCmd, { stdio: 'pipe', cwd: process.cwd() });
108
-
109
- spinner.succeed('Installed astralkit design tokens');
113
+ if (filesWritten === 0) {
114
+ spinner.fail('No token files received from API');
115
+ console.log(chalk.yellow('Try again — the API may be updating.'));
116
+ } else {
117
+ spinner.succeed(`Installed astralkit design tokens (${filesWritten} files)`);
118
+ }
110
119
  } catch (err) {
111
120
  spinner.fail('Failed to install astralkit');
112
121
  if (err.message?.includes('Authentication')) {
@@ -141,12 +150,18 @@ async function initCommand(options) {
141
150
  console.log(chalk.gray(' CSS imports already present'));
142
151
  }
143
152
  } else {
153
+ // No CSS entry found — create one with AstralKit imports
154
+ const defaultCssPath = framework === 'html'
155
+ ? path.join(process.cwd(), 'styles.css')
156
+ : path.join(process.cwd(), 'src', 'app', 'globals.css');
157
+ const defaultCssRelative = path.relative(process.cwd(), defaultCssPath);
158
+
144
159
  console.log();
145
- console.log(chalk.yellow('No CSS entry file found.'));
146
- console.log(chalk.gray('Add these imports to your main CSS file:'));
147
- for (const imp of REQUIRED_CSS_IMPORTS) {
148
- console.log(chalk.cyan(` ${imp}`));
149
- }
160
+ const cssContent = REQUIRED_CSS_IMPORTS.join('\n') + '\n';
161
+ const cssDir = path.dirname(defaultCssPath);
162
+ if (!fs.existsSync(cssDir)) fs.mkdirSync(cssDir, { recursive: true });
163
+ fs.writeFileSync(defaultCssPath, cssContent, 'utf-8');
164
+ console.log(chalk.green(' Created'), chalk.cyan(defaultCssRelative), chalk.green('with AstralKit imports'));
150
165
  }
151
166
 
152
167
  // ─── Step 3: Write config ──────────────────────────────