create-asterui 0.1.3 → 0.1.5

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 (3) hide show
  1. package/README.md +6 -4
  2. package/dist/index.js +60 -10
  3. package/package.json +1 -1
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
@@ -14,6 +14,14 @@ const DAISYUI_THEMES = [
14
14
  'night', 'coffee', 'winter', 'dim', 'nord', 'sunset'
15
15
  ];
16
16
  const THEME_PRESETS = ['light-dark', 'business', 'all'];
17
+ const ICON_LIBRARIES = [
18
+ { value: '@aster-ui/icons', label: '@aster-ui/icons', hint: 'Heroicons with size tokens', version: '^0.1.0' },
19
+ { value: '@heroicons/react', label: 'Heroicons', hint: '300+ icons, outline/solid', version: '^2.2.0' },
20
+ { value: 'lucide-react', label: 'Lucide', hint: 'popular, 1400+ icons', version: '^0.500.0' },
21
+ { value: 'react-icons', label: 'React Icons', hint: 'multiple icon sets', version: '^5.4.0' },
22
+ { value: '@phosphor-icons/react', label: 'Phosphor', hint: '9000+ icons, 6 weights', version: '^2.1.0' },
23
+ { value: 'none', label: 'None', hint: 'skip icon library' },
24
+ ];
17
25
  function parseArgs() {
18
26
  const args = process.argv.slice(2);
19
27
  const result = {};
@@ -28,6 +36,9 @@ function parseArgs() {
28
36
  else if (arg === '--ts') {
29
37
  result.language = 'ts';
30
38
  }
39
+ else if (arg === '--prefixed') {
40
+ result.prefixed = true;
41
+ }
31
42
  else if (arg === '--themes' && args[i + 1]) {
32
43
  result.themes = args[++i];
33
44
  }
@@ -53,6 +64,7 @@ ${pc.bold('Usage:')}
53
64
  ${pc.bold('Options:')}
54
65
  --js Use JavaScript instead of TypeScript
55
66
  --ts Use TypeScript (default)
67
+ --prefixed Use @aster-ui/prefixed with d- prefix for daisyUI
56
68
  --themes <preset> Theme preset: light-dark, business, all
57
69
  --pm <manager> Package manager: npm, pnpm, yarn
58
70
  -h, --help Show this help message
@@ -110,6 +122,12 @@ async function main() {
110
122
  { value: 'js', label: 'JavaScript' },
111
123
  ],
112
124
  }),
125
+ prefixed: () => cliArgs.prefixed !== undefined
126
+ ? Promise.resolve(cliArgs.prefixed)
127
+ : p.confirm({
128
+ message: 'Use prefixed daisyUI classes?',
129
+ initialValue: false,
130
+ }),
113
131
  themePreset: () => cliArgs.themes && THEME_PRESETS.includes(cliArgs.themes)
114
132
  ? Promise.resolve(cliArgs.themes)
115
133
  : p.select({
@@ -144,11 +162,17 @@ async function main() {
144
162
  message: 'Optional components (require extra dependencies)',
145
163
  options: [
146
164
  { value: 'chart', label: 'Chart', hint: 'apexcharts' },
165
+ { value: 'editor', label: 'RichTextEditor', hint: '@aster-ui/icons + @tiptap/react' },
147
166
  { value: 'qrcode', label: 'QRCode', hint: 'qrcode' },
148
167
  { value: 'virtuallist', label: 'VirtualList', hint: '@tanstack/react-virtual' },
149
168
  ],
150
169
  required: false,
151
170
  }),
171
+ iconLibrary: () => p.select({
172
+ message: 'Icon library',
173
+ initialValue: '@aster-ui/icons',
174
+ options: ICON_LIBRARIES,
175
+ }),
152
176
  }, {
153
177
  onCancel: () => {
154
178
  p.cancel('Operation cancelled.');
@@ -165,11 +189,12 @@ async function main() {
165
189
  // Copy template files
166
190
  copyDir(templateDir, projectDir);
167
191
  // Generate package.json
168
- const packageJson = generatePackageJson(options.projectName, options.language, options.optionalDeps);
192
+ const prefixed = options.prefixed;
193
+ const packageJson = generatePackageJson(options.projectName, options.language, options.optionalDeps, options.iconLibrary, prefixed);
169
194
  fs.writeFileSync(path.join(projectDir, 'package.json'), JSON.stringify(packageJson, null, 2));
170
195
  // Generate index.css with theme config
171
196
  const themes = getThemes(options.themePreset, options.customThemes);
172
- const cssContent = generateCss(themes);
197
+ const cssContent = generateCss(themes, prefixed);
173
198
  fs.writeFileSync(path.join(projectDir, 'src', 'index.css'), cssContent);
174
199
  s.stop('Project created!');
175
200
  const pm = options.packageManager;
@@ -208,8 +233,9 @@ function copyDir(src, dest) {
208
233
  }
209
234
  }
210
235
  }
211
- function generatePackageJson(name, language, optionalDeps = []) {
236
+ function generatePackageJson(name, language, optionalDeps = [], iconLibrary = 'none', prefixed = false) {
212
237
  const isTs = language === 'ts';
238
+ const uiPackage = prefixed ? '@aster-ui/prefixed' : 'asterui';
213
239
  const pkg = {
214
240
  name,
215
241
  private: true,
@@ -221,7 +247,7 @@ function generatePackageJson(name, language, optionalDeps = []) {
221
247
  preview: 'vite preview',
222
248
  },
223
249
  dependencies: {
224
- asterui: '^0.12.0',
250
+ [uiPackage]: '^0.12.0',
225
251
  react: '^19.0.0',
226
252
  'react-dom': '^19.0.0',
227
253
  'react-hook-form': '^7.0.0',
@@ -234,11 +260,31 @@ function generatePackageJson(name, language, optionalDeps = []) {
234
260
  vite: '^7.0.0',
235
261
  },
236
262
  };
237
- // Add optional dependencies
263
+ // Add icon library
238
264
  const deps = pkg.dependencies;
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
+ }
271
+ const iconLib = ICON_LIBRARIES.find(lib => lib.value === iconLibrary);
272
+ if (iconLib && iconLib.version) {
273
+ deps[iconPkg] = iconLib.version;
274
+ }
275
+ }
276
+ // Add optional dependencies
239
277
  if (optionalDeps.includes('chart')) {
240
278
  deps['apexcharts'] = '^5.0.0';
241
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
+ }
242
288
  if (optionalDeps.includes('qrcode')) {
243
289
  deps['qrcode'] = '^1.5.0';
244
290
  }
@@ -270,28 +316,32 @@ function getThemes(preset, customThemes) {
270
316
  return ['light', 'dark'];
271
317
  }
272
318
  }
273
- function generateCss(themes) {
319
+ function generateCss(themes, prefixed = false) {
320
+ const uiPackage = prefixed ? '@aster-ui/prefixed' : 'asterui';
321
+ const prefixConfig = prefixed ? '\n prefix: "d-";' : '';
274
322
  let daisyPlugin;
275
323
  if (themes.length === 0) {
276
324
  // All themes
277
- daisyPlugin = '@plugin "daisyui";';
325
+ daisyPlugin = prefixed
326
+ ? '@plugin "daisyui" {\n prefix: "d-";\n}'
327
+ : '@plugin "daisyui";';
278
328
  }
279
329
  else if (themes.length === 2 && ((themes[0] === 'light' && themes[1] === 'dark') ||
280
330
  (themes[0] === 'corporate' && themes[1] === 'business'))) {
281
331
  // Light/dark pair with prefersDark
282
- daisyPlugin = `@plugin "daisyui" {
332
+ daisyPlugin = `@plugin "daisyui" {${prefixConfig}
283
333
  themes: ${themes[0]} --default, ${themes[1]} --prefersDark;
284
334
  }`;
285
335
  }
286
336
  else {
287
337
  // Custom selection
288
- daisyPlugin = `@plugin "daisyui" {
338
+ daisyPlugin = `@plugin "daisyui" {${prefixConfig}
289
339
  themes: ${themes.join(', ')};
290
340
  }`;
291
341
  }
292
342
  return `@import "tailwindcss";
293
343
  ${daisyPlugin}
294
- @source "../node_modules/asterui";
344
+ @source "../node_modules/${uiPackage}";
295
345
  `;
296
346
  }
297
347
  main().catch(console.error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-asterui",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "Create a new AsterUI project",
5
5
  "type": "module",
6
6
  "bin": {