rizzo-css 0.0.4 → 0.0.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.
package/README.md CHANGED
@@ -12,7 +12,7 @@ pnpm add rizzo-css
12
12
  yarn add rizzo-css
13
13
  ```
14
14
 
15
- **Quick start (no install):** `npx rizzo-css init` scaffolds a project. Choose **Vanilla JS** (yellow in the CLI), **Astro** (orange), or **Svelte** (orange-red). All options get the **same CSS and component styles**. Vanilla JS gets an example page with theme switcher and sample components; Astro/Svelte can optionally add component files. To use the **official Svelte or Astro scaffold** plus Rizzo CSS, create the app with their CLI first, then add our CSS:
15
+ **Quick start (no install):** `npx rizzo-css init` first choose **add to existing project** or **create new**. Existing: framework (auto-detect), themes, optional components. New: scaffold (Vanilla example, default Astro app, or default Svelte app; CLI colors: Vanilla = yellow, Astro = orange, Svelte = orange-red). All get the **same CSS and component styles**. To use the **official Svelte or Astro scaffold** plus Rizzo CSS, create the app with their CLI first, then run `npx rizzo-css add`:
16
16
 
17
17
  ```bash
18
18
  npm create svelte@latest my-app && cd my-app && npx rizzo-css add
package/bin/rizzo-css.js CHANGED
@@ -259,7 +259,7 @@ Usage:
259
259
  npx rizzo-css <command> [options]
260
260
 
261
261
  Commands:
262
- init Scaffold a minimal project (menus: location, framework, themes, components)
262
+ init Add Rizzo to existing project or scaffold new one (first menu: existing vs new)
263
263
  add Copy Rizzo CSS into the current project (auto-detects Svelte/Astro)
264
264
  theme List all available themes (use in init or set data-theme on <html>)
265
265
  help Show this help
@@ -363,6 +363,14 @@ function getScaffoldVanillaIndex() {
363
363
  return join(getPackageRoot(), 'scaffold', 'vanilla', 'index.html');
364
364
  }
365
365
 
366
+ function getScaffoldAstroAppDir() {
367
+ return join(getPackageRoot(), 'scaffold', 'astro-app');
368
+ }
369
+
370
+ function getScaffoldSvelteAppDir() {
371
+ return join(getPackageRoot(), 'scaffold', 'svelte-app');
372
+ }
373
+
366
374
  function copyDirRecursive(src, dest) {
367
375
  mkdirSync(dest, { recursive: true });
368
376
  const entries = readdirSync(src, { withFileTypes: true });
@@ -377,6 +385,31 @@ function copyDirRecursive(src, dest) {
377
385
  }
378
386
  }
379
387
 
388
+ /** Copy directory recursively; in text files (utf-8), replace each key in replacements with its value. */
389
+ function copyDirRecursiveWithReplacements(src, dest, replacements) {
390
+ mkdirSync(dest, { recursive: true });
391
+ const entries = readdirSync(src, { withFileTypes: true });
392
+ const textExtensions = new Set(['.html', '.astro', '.svelte', '.ts', '.js', '.mjs', '.json', '.css', '.md']);
393
+ for (const e of entries) {
394
+ const srcPath = join(src, e.name);
395
+ const destPath = join(dest, e.name);
396
+ if (e.isDirectory()) {
397
+ copyDirRecursiveWithReplacements(srcPath, destPath, replacements);
398
+ } else {
399
+ const ext = srcPath.slice(srcPath.lastIndexOf('.'));
400
+ if (textExtensions.has(ext)) {
401
+ let content = readFileSync(srcPath, 'utf8');
402
+ for (const [key, value] of Object.entries(replacements)) {
403
+ content = content.split(key).join(value);
404
+ }
405
+ writeFileSync(destPath, content, 'utf8');
406
+ } else {
407
+ copyFileSync(srcPath, destPath);
408
+ }
409
+ }
410
+ }
411
+ }
412
+
380
413
  function copySvelteComponents(projectDir, selectedNames) {
381
414
  const scaffoldDir = getScaffoldSvelteDir();
382
415
  if (!existsSync(scaffoldDir)) {
@@ -441,7 +474,104 @@ function copyAstroComponents(projectDir, selectedNames) {
441
474
  }
442
475
  }
443
476
 
477
+ /** Add Rizzo CSS (and optional components) to an existing project in cwd. */
478
+ async function runAddToExisting() {
479
+ const cwd = process.cwd();
480
+ const detected = detectFramework(cwd);
481
+ const frameworkOptions = [
482
+ { value: 'vanilla', label: 'Vanilla JS (HTML + CSS)', color: C.vanilla },
483
+ { value: 'astro', label: 'Astro', color: C.astro },
484
+ { value: 'svelte', label: 'Svelte', color: C.svelte },
485
+ ];
486
+ let frameworkPrompt = '? Framework';
487
+ if (detected) {
488
+ frameworkPrompt += ' (detected: ' + detected + ' — pick to confirm or choose another)';
489
+ }
490
+ const framework = await selectMenu(frameworkOptions, frameworkPrompt);
491
+
492
+ const selectedThemes = await multiSelectMenu(
493
+ THEMES.map((t) => ({ value: t, label: t })),
494
+ '? Themes (Space to toggle, Enter to confirm) — we\'ll suggest the first as default data-theme'
495
+ );
496
+ const themeList = selectedThemes.length > 0 ? selectedThemes : [THEMES[0]];
497
+ const suggestedTheme = THEMES.includes(themeList[0]) ? themeList[0] : THEMES[0];
498
+
499
+ let selectedComponents = [];
500
+ const componentList = framework === 'svelte' ? SVELTE_COMPONENTS : framework === 'astro' ? ASTRO_COMPONENTS : [];
501
+ if (componentList.length > 0) {
502
+ const includeLabel = framework === 'svelte' ? 'Svelte' : 'Astro';
503
+ const includeChoice = await selectMenu(
504
+ [
505
+ { value: 'none', label: 'None' },
506
+ { value: 'pick', label: 'Yes, pick ' + includeLabel + ' components' },
507
+ ],
508
+ '? Include ' + includeLabel + ' components?'
509
+ );
510
+ if (includeChoice === 'pick') {
511
+ selectedComponents = await multiSelectMenu(
512
+ componentList.map((c) => ({ value: c, label: c })),
513
+ '? Components (Space to toggle, Enter to confirm)'
514
+ );
515
+ }
516
+ }
517
+
518
+ const cssSource = getCssPath();
519
+ if (!existsSync(cssSource)) {
520
+ console.error('Error: Rizzo CSS build not found. Run from repo root: pnpm build:css');
521
+ process.exit(1);
522
+ }
523
+
524
+ const paths = getFrameworkCssPaths(framework);
525
+ const targetDir = join(cwd, paths.targetDir);
526
+ const cssTarget = join(targetDir, 'rizzo.min.css');
527
+ mkdirSync(targetDir, { recursive: true });
528
+ copyFileSync(cssSource, cssTarget);
529
+
530
+ if (framework === 'svelte' && selectedComponents.length > 0) {
531
+ copySvelteComponents(cwd, selectedComponents);
532
+ } else if (framework === 'astro' && selectedComponents.length > 0) {
533
+ copyAstroComponents(cwd, selectedComponents);
534
+ }
535
+
536
+ const linkHref = paths.linkHref;
537
+ console.log('\n✓ Rizzo CSS added to your existing project');
538
+ console.log(' - ' + cssTarget);
539
+ if (framework === 'svelte') {
540
+ console.log('\nAdd to your root layout (e.g. src/app.html):');
541
+ console.log(' <link rel="stylesheet" href="' + linkHref + '" />');
542
+ console.log('\nSet a theme on <html>: data-theme="' + suggestedTheme + '" (see: npx rizzo-css theme)');
543
+ if (selectedComponents.length > 0) {
544
+ console.log(' Components are in src/lib/rizzo — import from \'$lib/rizzo\'.');
545
+ }
546
+ } else if (framework === 'astro') {
547
+ console.log('\nAdd to your layout (e.g. src/layouts/Layout.astro):');
548
+ console.log(' <link rel="stylesheet" href="' + linkHref + '" />');
549
+ console.log('\nSet a theme on <html>: data-theme="' + suggestedTheme + '" (see: npx rizzo-css theme)');
550
+ if (selectedComponents.length > 0) {
551
+ console.log(' Components are in src/components/rizzo — import from there.');
552
+ }
553
+ } else {
554
+ console.log('\nAdd to your HTML or layout:');
555
+ console.log(' <link rel="stylesheet" href="' + linkHref + '" />');
556
+ console.log('\nSet a theme on <html>: data-theme="' + suggestedTheme + '" (see: npx rizzo-css theme)');
557
+ }
558
+ console.log('\nDocs: https://rizzo-css.vercel.app\n');
559
+ }
560
+
444
561
  async function cmdInit() {
562
+ const initMode = await selectMenu(
563
+ [
564
+ { value: 'existing', label: 'Add to existing project (current directory)' },
565
+ { value: 'new', label: 'Create new project (scaffold)' },
566
+ ],
567
+ '? Are you using an existing project or creating a new one?'
568
+ );
569
+
570
+ if (initMode === 'existing') {
571
+ await runAddToExisting();
572
+ return;
573
+ }
574
+
445
575
  const projectChoice = await selectMenu(
446
576
  [
447
577
  { value: 'cwd', label: 'Current directory' },
@@ -487,8 +617,6 @@ async function cmdInit() {
487
617
  }
488
618
 
489
619
  const projectDir = name ? join(process.cwd(), name) : process.cwd();
490
- const cssDir = framework === 'astro' ? join(projectDir, 'public', 'css') : join(projectDir, 'css');
491
- const cssTarget = join(cssDir, 'rizzo.min.css');
492
620
  const cssSource = getCssPath();
493
621
 
494
622
  if (!existsSync(cssSource)) {
@@ -496,25 +624,62 @@ async function cmdInit() {
496
624
  process.exit(1);
497
625
  }
498
626
 
499
- mkdirSync(cssDir, { recursive: true });
500
- copyFileSync(cssSource, cssTarget);
501
-
502
- const linkHref = framework === 'astro' ? '/css/rizzo.min.css' : 'css/rizzo.min.css';
503
627
  const themeComment = themeList.length > 0
504
628
  ? '\n <!-- Selected themes: ' + themeList.join(', ') + ' -->'
505
629
  : '';
506
- const indexPath = join(projectDir, 'index.html');
507
- const vanillaScaffoldPath = getScaffoldVanillaIndex();
508
- if (framework === 'vanilla' && existsSync(vanillaScaffoldPath)) {
509
- let indexHtml = readFileSync(vanillaScaffoldPath, 'utf8');
510
- indexHtml = indexHtml
511
- .replace(/\{\{DATA_THEME\}\}/g, theme)
512
- .replace(/\{\{THEME_LIST_COMMENT\}\}/g, themeComment)
513
- .replace(/\{\{TITLE\}\}/g, name || 'App')
514
- .replace(/\{\{LINK_HREF\}\}/g, linkHref);
515
- writeFileSync(indexPath, indexHtml, 'utf8');
630
+ const projectNamePkg = name
631
+ ? name.replace(/\s+/g, '-').toLowerCase()
632
+ : (framework === 'astro' ? 'my-astro-app' : framework === 'svelte' ? 'my-svelte-app' : 'my-app');
633
+ const replacements = {
634
+ '{{DATA_THEME}}': theme,
635
+ '{{THEME_LIST_COMMENT}}': themeComment,
636
+ '{{TITLE}}': name || 'App',
637
+ '{{PROJECT_NAME}}': projectNamePkg,
638
+ };
639
+
640
+ const astroAppDir = getScaffoldAstroAppDir();
641
+ const svelteAppDir = getScaffoldSvelteAppDir();
642
+
643
+ let cssTarget;
644
+ let indexPath;
645
+
646
+ if (framework === 'astro' && existsSync(astroAppDir)) {
647
+ mkdirSync(projectDir, { recursive: true });
648
+ copyDirRecursiveWithReplacements(astroAppDir, projectDir, replacements);
649
+ mkdirSync(join(projectDir, 'public', 'css'), { recursive: true });
650
+ cssTarget = join(projectDir, 'public', 'css', 'rizzo.min.css');
651
+ copyFileSync(cssSource, cssTarget);
652
+ if (selectedComponents.length > 0) {
653
+ copyAstroComponents(projectDir, selectedComponents);
654
+ }
655
+ } else if (framework === 'svelte' && existsSync(svelteAppDir)) {
656
+ mkdirSync(projectDir, { recursive: true });
657
+ copyDirRecursiveWithReplacements(svelteAppDir, projectDir, replacements);
658
+ mkdirSync(join(projectDir, 'static', 'css'), { recursive: true });
659
+ cssTarget = join(projectDir, 'static', 'css', 'rizzo.min.css');
660
+ copyFileSync(cssSource, cssTarget);
661
+ if (selectedComponents.length > 0) {
662
+ copySvelteComponents(projectDir, selectedComponents);
663
+ }
516
664
  } else {
517
- const indexHtml = `<!DOCTYPE html>
665
+ const cssDir = framework === 'astro' ? join(projectDir, 'public', 'css') : join(projectDir, 'css');
666
+ cssTarget = join(cssDir, 'rizzo.min.css');
667
+ const linkHref = framework === 'astro' ? '/css/rizzo.min.css' : 'css/rizzo.min.css';
668
+ mkdirSync(cssDir, { recursive: true });
669
+ copyFileSync(cssSource, cssTarget);
670
+
671
+ const vanillaScaffoldPath = getScaffoldVanillaIndex();
672
+ indexPath = join(projectDir, 'index.html');
673
+ if (framework === 'vanilla' && existsSync(vanillaScaffoldPath)) {
674
+ let indexHtml = readFileSync(vanillaScaffoldPath, 'utf8');
675
+ indexHtml = indexHtml
676
+ .replace(/\{\{DATA_THEME\}\}/g, theme)
677
+ .replace(/\{\{THEME_LIST_COMMENT\}\}/g, themeComment)
678
+ .replace(/\{\{TITLE\}\}/g, name || 'App')
679
+ .replace(/\{\{LINK_HREF\}\}/g, linkHref);
680
+ writeFileSync(indexPath, indexHtml, 'utf8');
681
+ } else {
682
+ const indexHtml = `<!DOCTYPE html>
518
683
  <html lang="en" data-theme="${theme}">${themeComment}
519
684
  <head>
520
685
  <meta charset="UTF-8" />
@@ -528,26 +693,32 @@ async function cmdInit() {
528
693
  </body>
529
694
  </html>
530
695
  `;
531
- writeFileSync(indexPath, indexHtml, 'utf8');
532
- }
533
-
534
- if (framework === 'svelte' && selectedComponents.length > 0) {
535
- copySvelteComponents(projectDir, selectedComponents);
536
- } else if (framework === 'astro' && selectedComponents.length > 0) {
537
- copyAstroComponents(projectDir, selectedComponents);
696
+ writeFileSync(indexPath, indexHtml, 'utf8');
697
+ }
698
+ if (framework === 'svelte' && selectedComponents.length > 0) {
699
+ copySvelteComponents(projectDir, selectedComponents);
700
+ } else if (framework === 'astro' && selectedComponents.length > 0) {
701
+ copyAstroComponents(projectDir, selectedComponents);
702
+ }
538
703
  }
539
704
 
540
705
  console.log('\n✓ Project ready at ' + projectDir);
541
706
  console.log(' - ' + cssTarget);
542
- console.log(' - ' + indexPath);
707
+ if (indexPath) console.log(' - ' + indexPath);
543
708
  if (framework === 'vanilla') {
544
- console.log(' - Vanilla JS: same CSS and component styles as Astro/Svelte; index includes theme switcher and sample components.');
709
+ console.log(' - Vanilla JS: same CSS and component styles; index includes theme switcher and sample components.');
710
+ }
711
+ if (framework === 'astro' && existsSync(astroAppDir)) {
712
+ console.log(' - Default Astro project with Rizzo CSS. Run: pnpm install && pnpm dev');
713
+ }
714
+ if (framework === 'svelte' && existsSync(svelteAppDir)) {
715
+ console.log(' - Default SvelteKit project with Rizzo CSS. Run: pnpm install && pnpm dev');
545
716
  }
546
- if (framework === 'svelte' || framework === 'astro') {
717
+ if ((framework === 'svelte' || framework === 'astro') && !existsSync(framework === 'astro' ? astroAppDir : svelteAppDir)) {
547
718
  const fw = framework === 'svelte' ? 'Svelte' : 'Astro';
548
- console.log('\nTip: To use the official ' + fw + ' scaffold instead, create a project with their CLI (e.g. npm create ' + framework + '@latest my-app), then run npx rizzo-css add in that folder.');
719
+ console.log('\nTip: To use the official ' + fw + ' scaffold, create a project with their CLI (e.g. npm create ' + framework + '@latest my-app), then run npx rizzo-css add in that folder.');
549
720
  }
550
- console.log('\nRun a local server (e.g. npx serve .) or open index.html. Docs: https://rizzo-css.vercel.app\n');
721
+ console.log('\nDocs: https://rizzo-css.vercel.app\n');
551
722
  }
552
723
 
553
724
  function main() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rizzo-css",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "scripts": {
5
5
  "prepublishOnly": "cd ../.. && pnpm build:css && node scripts/copy-scaffold.js"
6
6
  },
@@ -0,0 +1,4 @@
1
+ // https://astro.build/config
2
+ import { defineConfig } from 'astro/config';
3
+
4
+ export default defineConfig({});
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "{{PROJECT_NAME}}",
3
+ "type": "module",
4
+ "version": "0.0.1",
5
+ "scripts": {
6
+ "dev": "astro dev",
7
+ "build": "astro build",
8
+ "preview": "astro preview"
9
+ },
10
+ "dependencies": {
11
+ "astro": "^5.0.0"
12
+ }
13
+ }
File without changes
@@ -0,0 +1,19 @@
1
+ ---
2
+ interface Props {
3
+ title?: string;
4
+ }
5
+
6
+ const { title = '{{TITLE}}' } = Astro.props;
7
+ ---
8
+ <!doctype html>
9
+ <html lang="en" data-theme="{{DATA_THEME}}">{{THEME_LIST_COMMENT}}
10
+ <head>
11
+ <meta charset="UTF-8" />
12
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
13
+ <link rel="stylesheet" href="/css/rizzo.min.css" />
14
+ <title>{title}</title>
15
+ </head>
16
+ <body>
17
+ <slot />
18
+ </body>
19
+ </html>
@@ -0,0 +1,13 @@
1
+ ---
2
+ import Layout from '../layouts/Layout.astro';
3
+ ---
4
+ <Layout>
5
+ <main style="padding: var(--spacing-6); max-width: 65ch;">
6
+ <h1>Hello, Rizzo CSS</h1>
7
+ <p>Your Astro project is set up with Rizzo CSS. Same styles and components as Vanilla JS and Svelte.</p>
8
+ <p>
9
+ <a href="https://rizzo-css.vercel.app/docs/components">Component docs</a>
10
+ — Set theme via <code>data-theme</code> on <code>&lt;html&gt;</code> (e.g. <code>github-dark-classic</code>). Run <code>npx rizzo-css theme</code> to list themes.
11
+ </p>
12
+ </main>
13
+ </Layout>
@@ -0,0 +1,5 @@
1
+ {
2
+ "extends": "astro/tsconfigs/strict",
3
+ "include": [".astro/types.d.ts", "**/*"],
4
+ "exclude": ["dist"]
5
+ }
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "{{PROJECT_NAME}}",
3
+ "type": "module",
4
+ "version": "0.0.1",
5
+ "scripts": {
6
+ "dev": "vite dev",
7
+ "build": "vite build",
8
+ "preview": "vite preview"
9
+ },
10
+ "devDependencies": {
11
+ "@sveltejs/adapter-auto": "^3.0.0",
12
+ "@sveltejs/kit": "^2.0.0",
13
+ "@sveltejs/vite-plugin-svelte": "^5.0.0",
14
+ "svelte": "^5.0.0",
15
+ "vite": "^6.0.0"
16
+ }
17
+ }
@@ -0,0 +1,13 @@
1
+ // See https://svelte.dev/docs/kit/types#app.d.ts
2
+ // for information about these interfaces
3
+ declare global {
4
+ namespace App {
5
+ // interface Error {}
6
+ // interface Locals {}
7
+ // interface PageData {}
8
+ // interface PageState {}
9
+ // interface Platform {}
10
+ }
11
+ }
12
+
13
+ export {};
@@ -0,0 +1,12 @@
1
+ <!doctype html>
2
+ <html lang="en" data-theme="{{DATA_THEME}}">{{THEME_LIST_COMMENT}}
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
6
+ <link rel="stylesheet" href="/css/rizzo.min.css" />
7
+ %sveltekit.head%
8
+ </head>
9
+ <body data-sveltekit-preload-data="hover">
10
+ <div style="display: contents">%sveltekit.body%</div>
11
+ </body>
12
+ </html>
@@ -0,0 +1,5 @@
1
+ <script>
2
+ // Root layout — Rizzo CSS is loaded via app.html
3
+ </script>
4
+
5
+ <slot />
@@ -0,0 +1,12 @@
1
+ <script>
2
+ // Welcome page
3
+ </script>
4
+
5
+ <main style="padding: var(--spacing-6); max-width: 65ch;">
6
+ <h1>Hello, Rizzo CSS</h1>
7
+ <p>Your SvelteKit project is set up with Rizzo CSS. Same styles and components as Vanilla JS and Astro.</p>
8
+ <p>
9
+ <a href="https://rizzo-css.vercel.app/docs/components">Component docs</a>
10
+ — Set theme via <code>data-theme</code> on <code>&lt;html&gt;</code> (e.g. <code>github-dark-classic</code>). Run <code>npx rizzo-css theme</code> to list themes.
11
+ </p>
12
+ </main>
File without changes
@@ -0,0 +1,11 @@
1
+ // @ts-check
2
+ import adapter from '@sveltejs/adapter-auto';
3
+
4
+ /** @type {import('@sveltejs/kit').Config} */
5
+ const config = {
6
+ kit: {
7
+ adapter: adapter()
8
+ }
9
+ };
10
+
11
+ export default config;
@@ -0,0 +1,15 @@
1
+ {
2
+ "extends": "./.svelte-kit/tsconfig.json",
3
+ "compilerOptions": {
4
+ "allowJs": true,
5
+ "checkJs": true,
6
+ "esModuleInterop": true,
7
+ "forceConsistentCasingInFileNames": true,
8
+ "resolveJsonModule": true,
9
+ "skipLibCheck": true,
10
+ "sourceMap": true,
11
+ "strict": true,
12
+ "module": "ESNext",
13
+ "moduleResolution": "bundler"
14
+ }
15
+ }
@@ -0,0 +1,6 @@
1
+ import { sveltekit } from '@sveltejs/kit/vite';
2
+ import { defineConfig } from 'vite';
3
+
4
+ export default defineConfig({
5
+ plugins: [sveltekit()]
6
+ });