create-asterui 0.1.4 → 0.1.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.
package/README.md CHANGED
@@ -26,6 +26,7 @@ npm create asterui my-app --js --themes all --pm pnpm
26
26
  ```
27
27
  --js Use JavaScript instead of TypeScript
28
28
  --ts Use TypeScript (default)
29
+ --prefixed Use @aster-ui/prefixed with d- prefix for daisyUI
29
30
  --themes <preset> Theme preset: light-dark, business, all
30
31
  --pm <manager> Package manager: npm, pnpm, yarn
31
32
  -h, --help Show help message
@@ -35,8 +36,9 @@ npm create asterui my-app --js --themes all --pm pnpm
35
36
 
36
37
  - Creates a new Vite + React project
37
38
  - Configures Tailwind CSS v4 and DaisyUI v5
38
- - Installs AsterUI and react-hook-form
39
+ - Installs AsterUI (or @aster-ui/prefixed with --prefixed) and react-hook-form
39
40
  - Sets up theme configuration (light/dark, business/corporate, or custom)
41
+ - Optionally configures daisyUI class prefix for avoiding conflicts
40
42
  - Supports TypeScript or JavaScript
41
43
 
42
44
  ## After scaffolding
@@ -53,15 +55,15 @@ Some AsterUI components require additional peer dependencies and use separate im
53
55
  ```bash
54
56
  # For Chart component
55
57
  npm install apexcharts
56
- import { Chart } from 'asterui/chart'
58
+ import { Chart } from 'asterui/chart' # or '@aster-ui/prefixed/chart'
57
59
 
58
60
  # For QRCode component
59
61
  npm install qrcode
60
- import { QRCode } from 'asterui/qrcode'
62
+ import { QRCode } from 'asterui/qrcode' # or '@aster-ui/prefixed/qrcode'
61
63
 
62
64
  # For VirtualList component
63
65
  npm install @tanstack/react-virtual
64
- import { VirtualList } from 'asterui/virtuallist'
66
+ import { VirtualList } from 'asterui/virtuallist' # or '@aster-ui/prefixed/virtuallist'
65
67
  ```
66
68
 
67
69
  ## Links
package/dist/index.js CHANGED
@@ -36,6 +36,9 @@ function parseArgs() {
36
36
  else if (arg === '--ts') {
37
37
  result.language = 'ts';
38
38
  }
39
+ else if (arg === '--prefixed') {
40
+ result.prefixed = true;
41
+ }
39
42
  else if (arg === '--themes' && args[i + 1]) {
40
43
  result.themes = args[++i];
41
44
  }
@@ -61,6 +64,7 @@ ${pc.bold('Usage:')}
61
64
  ${pc.bold('Options:')}
62
65
  --js Use JavaScript instead of TypeScript
63
66
  --ts Use TypeScript (default)
67
+ --prefixed Use @aster-ui/prefixed with d- prefix for daisyUI
64
68
  --themes <preset> Theme preset: light-dark, business, all
65
69
  --pm <manager> Package manager: npm, pnpm, yarn
66
70
  -h, --help Show this help message
@@ -118,6 +122,12 @@ async function main() {
118
122
  { value: 'js', label: 'JavaScript' },
119
123
  ],
120
124
  }),
125
+ prefixed: () => cliArgs.prefixed !== undefined
126
+ ? Promise.resolve(cliArgs.prefixed)
127
+ : p.confirm({
128
+ message: 'Use prefixed daisyUI classes?',
129
+ initialValue: false,
130
+ }),
121
131
  themePreset: () => cliArgs.themes && THEME_PRESETS.includes(cliArgs.themes)
122
132
  ? Promise.resolve(cliArgs.themes)
123
133
  : p.select({
@@ -152,6 +162,7 @@ async function main() {
152
162
  message: 'Optional components (require extra dependencies)',
153
163
  options: [
154
164
  { value: 'chart', label: 'Chart', hint: 'apexcharts' },
165
+ { value: 'editor', label: 'RichTextEditor', hint: '@aster-ui/icons + @tiptap/react' },
155
166
  { value: 'qrcode', label: 'QRCode', hint: 'qrcode' },
156
167
  { value: 'virtuallist', label: 'VirtualList', hint: '@tanstack/react-virtual' },
157
168
  ],
@@ -178,11 +189,12 @@ async function main() {
178
189
  // Copy template files
179
190
  copyDir(templateDir, projectDir);
180
191
  // Generate package.json
181
- const packageJson = generatePackageJson(options.projectName, options.language, options.optionalDeps, options.iconLibrary);
192
+ const prefixed = options.prefixed;
193
+ const packageJson = generatePackageJson(options.projectName, options.language, options.optionalDeps, options.iconLibrary, prefixed);
182
194
  fs.writeFileSync(path.join(projectDir, 'package.json'), JSON.stringify(packageJson, null, 2));
183
195
  // Generate index.css with theme config
184
196
  const themes = getThemes(options.themePreset, options.customThemes);
185
- const cssContent = generateCss(themes);
197
+ const cssContent = generateCss(themes, prefixed);
186
198
  fs.writeFileSync(path.join(projectDir, 'src', 'index.css'), cssContent);
187
199
  s.stop('Project created!');
188
200
  const pm = options.packageManager;
@@ -221,8 +233,9 @@ function copyDir(src, dest) {
221
233
  }
222
234
  }
223
235
  }
224
- function generatePackageJson(name, language, optionalDeps = [], iconLibrary = 'none') {
236
+ function generatePackageJson(name, language, optionalDeps = [], iconLibrary = 'none', prefixed = false) {
225
237
  const isTs = language === 'ts';
238
+ const uiPackage = prefixed ? '@aster-ui/prefixed' : 'asterui';
226
239
  const pkg = {
227
240
  name,
228
241
  private: true,
@@ -234,7 +247,7 @@ function generatePackageJson(name, language, optionalDeps = [], iconLibrary = 'n
234
247
  preview: 'vite preview',
235
248
  },
236
249
  dependencies: {
237
- asterui: '^0.12.0',
250
+ [uiPackage]: '^0.12.0',
238
251
  react: '^19.0.0',
239
252
  'react-dom': '^19.0.0',
240
253
  'react-hook-form': '^7.0.0',
@@ -250,15 +263,28 @@ function generatePackageJson(name, language, optionalDeps = [], iconLibrary = 'n
250
263
  // Add icon library
251
264
  const deps = pkg.dependencies;
252
265
  if (iconLibrary !== 'none') {
266
+ // Use prefixed icon package if using prefixed UI and selecting @aster-ui/icons
267
+ let iconPkg = iconLibrary;
268
+ if (prefixed && iconLibrary === '@aster-ui/icons') {
269
+ iconPkg = '@aster-ui/icons-prefixed';
270
+ }
253
271
  const iconLib = ICON_LIBRARIES.find(lib => lib.value === iconLibrary);
254
272
  if (iconLib && iconLib.version) {
255
- deps[iconLibrary] = iconLib.version;
273
+ deps[iconPkg] = iconLib.version;
256
274
  }
257
275
  }
258
276
  // Add optional dependencies
259
277
  if (optionalDeps.includes('chart')) {
260
278
  deps['apexcharts'] = '^5.0.0';
261
279
  }
280
+ if (optionalDeps.includes('editor')) {
281
+ deps[prefixed ? '@aster-ui/icons-prefixed' : '@aster-ui/icons'] = '^0.1.0';
282
+ deps['@tiptap/react'] = '^2.0.0';
283
+ deps['@tiptap/starter-kit'] = '^2.0.0';
284
+ deps['@tiptap/extension-link'] = '^2.0.0';
285
+ deps['@tiptap/extension-placeholder'] = '^2.0.0';
286
+ deps['@tiptap/extension-underline'] = '^2.0.0';
287
+ }
262
288
  if (optionalDeps.includes('qrcode')) {
263
289
  deps['qrcode'] = '^1.5.0';
264
290
  }
@@ -290,28 +316,32 @@ function getThemes(preset, customThemes) {
290
316
  return ['light', 'dark'];
291
317
  }
292
318
  }
293
- function generateCss(themes) {
319
+ function generateCss(themes, prefixed = false) {
320
+ const uiPackage = prefixed ? '@aster-ui/prefixed' : 'asterui';
321
+ const prefixConfig = prefixed ? '\n prefix: "d-";' : '';
294
322
  let daisyPlugin;
295
323
  if (themes.length === 0) {
296
324
  // All themes
297
- daisyPlugin = '@plugin "daisyui";';
325
+ daisyPlugin = prefixed
326
+ ? '@plugin "daisyui" {\n prefix: "d-";\n}'
327
+ : '@plugin "daisyui";';
298
328
  }
299
329
  else if (themes.length === 2 && ((themes[0] === 'light' && themes[1] === 'dark') ||
300
330
  (themes[0] === 'corporate' && themes[1] === 'business'))) {
301
331
  // Light/dark pair with prefersDark
302
- daisyPlugin = `@plugin "daisyui" {
332
+ daisyPlugin = `@plugin "daisyui" {${prefixConfig}
303
333
  themes: ${themes[0]} --default, ${themes[1]} --prefersDark;
304
334
  }`;
305
335
  }
306
336
  else {
307
337
  // Custom selection
308
- daisyPlugin = `@plugin "daisyui" {
338
+ daisyPlugin = `@plugin "daisyui" {${prefixConfig}
309
339
  themes: ${themes.join(', ')};
310
340
  }`;
311
341
  }
312
342
  return `@import "tailwindcss";
313
343
  ${daisyPlugin}
314
- @source "../node_modules/asterui";
344
+ @source "../node_modules/${uiPackage}";
315
345
  `;
316
346
  }
317
347
  main().catch(console.error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-asterui",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "Create a new AsterUI project",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,23 +1,40 @@
1
- import { Navbar, ThemeController } from 'asterui'
1
+ import { Button, useTheme, ThemeController, Hero, Space } from 'asterui'
2
2
 
3
- function App() {
3
+ function Logo() {
4
+ const { colors } = useTheme()
4
5
  return (
5
- <>
6
- <Navbar
7
- className="bg-base-100 shadow-lg"
8
- start={<a className="text-xl font-bold">AsterUI App</a>}
9
- end={<ThemeController.Swap className="scale-75" />}
10
- />
6
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 40" className="h-12 w-auto">
7
+ <text
8
+ x="100"
9
+ y="30"
10
+ textAnchor="middle"
11
+ fontFamily="system-ui, -apple-system, sans-serif"
12
+ fontSize="28"
13
+ fontWeight="700"
14
+ >
15
+ <tspan fill={colors.primary}>Aster</tspan>
16
+ <tspan fill={colors.foreground}>UI</tspan>
17
+ </text>
18
+ </svg>
19
+ )
20
+ }
11
21
 
12
- <div className="p-6">
13
- <div className="max-w-4xl mx-auto">
14
- <h1 className="text-4xl font-bold mb-4">Welcome to AsterUI</h1>
15
- <p className="text-base-content/70">
16
- Start building your app by editing <code className="bg-base-300 px-1 rounded">src/App.jsx</code>
17
- </p>
18
- </div>
22
+ function App() {
23
+ return (
24
+ <Hero className="min-h-screen bg-base-200 relative">
25
+ <div className="absolute top-4 right-4">
26
+ <ThemeController.Swap />
19
27
  </div>
20
- </>
28
+ <Space direction="vertical" size="lg" align="center">
29
+ <Logo />
30
+ <p className="text-base-content/70">
31
+ 100+ React components built with DaisyUI and Tailwind CSS
32
+ </p>
33
+ <Button color="primary" href="https://asterui.com">
34
+ View Documentation
35
+ </Button>
36
+ </Space>
37
+ </Hero>
21
38
  )
22
39
  }
23
40
 
@@ -1,10 +1,13 @@
1
1
  import { StrictMode } from 'react'
2
2
  import { createRoot } from 'react-dom/client'
3
+ import { ThemeProvider } from 'asterui'
3
4
  import './index.css'
4
5
  import App from './App'
5
6
 
6
7
  createRoot(document.getElementById('root')).render(
7
8
  <StrictMode>
8
- <App />
9
+ <ThemeProvider defaultTheme="system">
10
+ <App />
11
+ </ThemeProvider>
9
12
  </StrictMode>,
10
13
  )
@@ -1,23 +1,40 @@
1
- import { Navbar, ThemeController } from 'asterui'
1
+ import { Button, useTheme, ThemeController, Hero, Space } from 'asterui'
2
2
 
3
- function App() {
3
+ function Logo() {
4
+ const { colors } = useTheme()
4
5
  return (
5
- <>
6
- <Navbar
7
- className="bg-base-100 shadow-lg"
8
- start={<a className="text-xl font-bold">AsterUI App</a>}
9
- end={<ThemeController.Swap className="scale-75" />}
10
- />
6
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 40" className="h-12 w-auto">
7
+ <text
8
+ x="100"
9
+ y="30"
10
+ textAnchor="middle"
11
+ fontFamily="system-ui, -apple-system, sans-serif"
12
+ fontSize="28"
13
+ fontWeight="700"
14
+ >
15
+ <tspan fill={colors.primary}>Aster</tspan>
16
+ <tspan fill={colors.foreground}>UI</tspan>
17
+ </text>
18
+ </svg>
19
+ )
20
+ }
11
21
 
12
- <div className="p-6">
13
- <div className="max-w-4xl mx-auto">
14
- <h1 className="text-4xl font-bold mb-4">Welcome to AsterUI</h1>
15
- <p className="text-base-content/70">
16
- Start building your app by editing <code className="bg-base-300 px-1 rounded">src/App.tsx</code>
17
- </p>
18
- </div>
22
+ function App() {
23
+ return (
24
+ <Hero className="min-h-screen bg-base-200 relative">
25
+ <div className="absolute top-4 right-4">
26
+ <ThemeController.Swap />
19
27
  </div>
20
- </>
28
+ <Space direction="vertical" size="lg" align="center">
29
+ <Logo />
30
+ <p className="text-base-content/70">
31
+ 100+ React components built with DaisyUI and Tailwind CSS
32
+ </p>
33
+ <Button color="primary" href="https://asterui.com">
34
+ View Documentation
35
+ </Button>
36
+ </Space>
37
+ </Hero>
21
38
  )
22
39
  }
23
40
 
@@ -1,10 +1,13 @@
1
1
  import { StrictMode } from 'react'
2
2
  import { createRoot } from 'react-dom/client'
3
+ import { ThemeProvider } from 'asterui'
3
4
  import './index.css'
4
5
  import App from './App'
5
6
 
6
7
  createRoot(document.getElementById('root')!).render(
7
8
  <StrictMode>
8
- <App />
9
+ <ThemeProvider defaultTheme="system">
10
+ <App />
11
+ </ThemeProvider>
9
12
  </StrictMode>,
10
13
  )