create-slotkit-app 0.1.0 → 0.1.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/dist/index.js CHANGED
@@ -4,7 +4,7 @@
4
4
  */
5
5
  import { Command } from 'commander';
6
6
  import { spawn } from 'child_process';
7
- import { existsSync, readFileSync, writeFileSync, mkdirSync, unlinkSync } from 'fs';
7
+ import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'fs';
8
8
  import { resolve, join } from 'path';
9
9
  const program = new Command();
10
10
  /**
@@ -32,13 +32,16 @@ function execCommand(command, args, cwd) {
32
32
  * Create SlotKit-specific files
33
33
  */
34
34
  function createSlotKitFiles(projectDir) {
35
- // Create src/app directory
35
+ // Replace Vite's default App.tsx with SlotKit App
36
+ // This way we don't need to modify main.tsx
37
+ const appFilePath = join(projectDir, 'src', 'App.tsx');
38
+ // Create src/app directory for AppLayout
36
39
  const appDir = join(projectDir, 'src', 'app');
37
40
  mkdirSync(appDir, { recursive: true });
38
- // Create App.tsx
41
+ // Create App.tsx (replaces Vite's default)
39
42
  const appTsx = `import React, { useEffect, useState } from 'react'
40
- import { AppLayout } from './AppLayout'
41
- import { pluginRegistry, pluginLoader } from '@slotkitjs/core/core'
43
+ import { AppLayout } from './app/AppLayout'
44
+ import { pluginRegistry, pluginLoader } from '@slotkitjs/core'
42
45
 
43
46
  /**
44
47
  * Load all plugins
@@ -124,7 +127,7 @@ export const App: React.FC = () => {
124
127
  )
125
128
  }
126
129
  `;
127
- writeFileSync(join(appDir, 'App.tsx'), appTsx, 'utf-8');
130
+ writeFileSync(appFilePath, appTsx, 'utf-8');
128
131
  // Create AppLayout.tsx
129
132
  const appLayoutTsx = `import React from 'react'
130
133
  import { Slot } from '@slotkitjs/react'
@@ -225,38 +228,8 @@ export const AppLayout: React.FC = () => {
225
228
  }
226
229
  `;
227
230
  writeFileSync(join(appDir, 'AppLayout.css'), appLayoutCss, 'utf-8');
228
- // Update main.tsx or main.ts to use SlotKit App
229
- // Check for both .tsx and .ts extensions, and rename .ts to .tsx if needed
230
- const mainTsxPath = join(projectDir, 'src', 'main.tsx');
231
- const mainTsPath = join(projectDir, 'src', 'main.ts');
232
- let mainPath = mainTsxPath;
233
- if (existsSync(mainTsPath)) {
234
- // If main.ts exists, we need to rename it to .tsx since it will contain JSX
235
- // But first check if main.tsx already exists
236
- if (!existsSync(mainTsxPath)) {
237
- // Rename main.ts to main.tsx
238
- const mainTsContent = readFileSync(mainTsPath, 'utf-8');
239
- writeFileSync(mainTsxPath, mainTsContent, 'utf-8');
240
- // Delete the old main.ts
241
- unlinkSync(mainTsPath);
242
- }
243
- mainPath = mainTsxPath;
244
- }
245
- if (existsSync(mainPath)) {
246
- // Update existing main file
247
- const mainContent = `import React from 'react'
248
- import ReactDOM from 'react-dom/client'
249
- import { App } from './app/App'
250
- import './style.css'
251
-
252
- ReactDOM.createRoot(document.getElementById('root')!).render(
253
- <React.StrictMode>
254
- <App />
255
- </React.StrictMode>,
256
- )
257
- `;
258
- writeFileSync(mainPath, mainContent, 'utf-8');
259
- }
231
+ // No need to modify main.tsx - Vite's default already imports './App'
232
+ // We replaced src/App.tsx above, so it will automatically work
260
233
  // Create slotkit.config.ts
261
234
  const slotkitConfig = `import { defineConfig } from '@slotkitjs/core'
262
235
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-slotkit-app",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "type": "module",
5
5
  "description": "Create a new SlotKit application",
6
6
  "bin": {
@@ -29,4 +29,3 @@
29
29
  "typescript": "~5.9.3"
30
30
  }
31
31
  }
32
-
package/dist/index.d.ts DELETED
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * create-slotkit-app - Initialize a new SlotKit project using Vite
4
- */
5
- export {};