@helloleo/plugins 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/dist/index.js +258 -0
- package/package.json +1 -1
- package/src/index.ts +1 -1
- package/src/tools/scaffold.ts +2 -0
package/dist/index.js
CHANGED
|
@@ -12541,7 +12541,265 @@ var RemovePlugin = async () => {
|
|
|
12541
12541
|
tool: { remove }
|
|
12542
12542
|
};
|
|
12543
12543
|
};
|
|
12544
|
+
// src/tools/scaffold.ts
|
|
12545
|
+
import { mkdir } from "fs/promises";
|
|
12546
|
+
import path2 from "path";
|
|
12547
|
+
function packageJson(name) {
|
|
12548
|
+
return JSON.stringify({
|
|
12549
|
+
name,
|
|
12550
|
+
private: true,
|
|
12551
|
+
version: "0.0.0",
|
|
12552
|
+
type: "module",
|
|
12553
|
+
scripts: {
|
|
12554
|
+
dev: "vite",
|
|
12555
|
+
start: "vite",
|
|
12556
|
+
build: "vite build",
|
|
12557
|
+
preview: "vite preview"
|
|
12558
|
+
},
|
|
12559
|
+
dependencies: {
|
|
12560
|
+
react: "^18.3.1",
|
|
12561
|
+
"react-dom": "^18.3.1",
|
|
12562
|
+
clsx: "^2.1.1",
|
|
12563
|
+
"tailwind-merge": "^2.6.0",
|
|
12564
|
+
"lucide-react": "^1.14.0"
|
|
12565
|
+
},
|
|
12566
|
+
devDependencies: {
|
|
12567
|
+
"@types/react": "^18.3.12",
|
|
12568
|
+
"@types/react-dom": "^18.3.1",
|
|
12569
|
+
"@vitejs/plugin-react": "^4.3.4",
|
|
12570
|
+
autoprefixer: "^10.4.20",
|
|
12571
|
+
postcss: "^8.4.49",
|
|
12572
|
+
tailwindcss: "^3.4.17",
|
|
12573
|
+
typescript: "^5.6.3",
|
|
12574
|
+
vite: "^6.0.5"
|
|
12575
|
+
}
|
|
12576
|
+
}, null, 2);
|
|
12577
|
+
}
|
|
12578
|
+
function indexHtml(fontFamily) {
|
|
12579
|
+
const fontParam = fontFamily.replace(/\s+/g, "+");
|
|
12580
|
+
return `<!DOCTYPE html>
|
|
12581
|
+
<html lang="en">
|
|
12582
|
+
<head>
|
|
12583
|
+
<meta charset="UTF-8" />
|
|
12584
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
12585
|
+
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
12586
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
12587
|
+
<link href="https://fonts.googleapis.com/css2?family=${fontParam}:wght@400;500;600;700&display=swap" rel="stylesheet">
|
|
12588
|
+
<title>App</title>
|
|
12589
|
+
</head>
|
|
12590
|
+
<body>
|
|
12591
|
+
<div id="root"></div>
|
|
12592
|
+
<script type="module" src="/src/main.tsx"></script>
|
|
12593
|
+
</body>
|
|
12594
|
+
</html>`;
|
|
12595
|
+
}
|
|
12596
|
+
function viteConfig() {
|
|
12597
|
+
return `import { defineConfig } from 'vite'
|
|
12598
|
+
import react from '@vitejs/plugin-react'
|
|
12599
|
+
import path from 'path'
|
|
12600
|
+
|
|
12601
|
+
export default defineConfig({
|
|
12602
|
+
plugins: [react()],
|
|
12603
|
+
server: {
|
|
12604
|
+
allowedHosts: true,
|
|
12605
|
+
},
|
|
12606
|
+
resolve: {
|
|
12607
|
+
alias: {
|
|
12608
|
+
'@': path.resolve(__dirname, './src'),
|
|
12609
|
+
},
|
|
12610
|
+
},
|
|
12611
|
+
})`;
|
|
12612
|
+
}
|
|
12613
|
+
function tailwindConfig() {
|
|
12614
|
+
return `export default {
|
|
12615
|
+
darkMode: ["class"],
|
|
12616
|
+
content: ["./index.html", "./src/**/*.{js,ts,jsx,tsx}"],
|
|
12617
|
+
theme: {
|
|
12618
|
+
extend: {
|
|
12619
|
+
colors: {
|
|
12620
|
+
background: "hsl(var(--background))",
|
|
12621
|
+
foreground: "hsl(var(--foreground))",
|
|
12622
|
+
card: { DEFAULT: "hsl(var(--card))", foreground: "hsl(var(--card-foreground))" },
|
|
12623
|
+
primary: { DEFAULT: "hsl(var(--primary))", foreground: "hsl(var(--primary-foreground))" },
|
|
12624
|
+
secondary: { DEFAULT: "hsl(var(--secondary))", foreground: "hsl(var(--secondary-foreground))" },
|
|
12625
|
+
muted: { DEFAULT: "hsl(var(--muted))", foreground: "hsl(var(--muted-foreground))" },
|
|
12626
|
+
accent: { DEFAULT: "hsl(var(--accent))", foreground: "hsl(var(--accent-foreground))" },
|
|
12627
|
+
destructive: { DEFAULT: "hsl(var(--destructive))", foreground: "hsl(var(--destructive-foreground))" },
|
|
12628
|
+
success: { DEFAULT: "hsl(var(--success))", foreground: "hsl(var(--success-foreground))" },
|
|
12629
|
+
warning: { DEFAULT: "hsl(var(--warning))", foreground: "hsl(var(--warning-foreground))" },
|
|
12630
|
+
border: "hsl(var(--border))",
|
|
12631
|
+
input: "hsl(var(--input))",
|
|
12632
|
+
ring: "hsl(var(--ring))",
|
|
12633
|
+
},
|
|
12634
|
+
fontFamily: {
|
|
12635
|
+
sans: "var(--font-sans)",
|
|
12636
|
+
heading: "var(--font-heading)",
|
|
12637
|
+
},
|
|
12638
|
+
borderRadius: {
|
|
12639
|
+
lg: "var(--radius)",
|
|
12640
|
+
md: "calc(var(--radius) - 2px)",
|
|
12641
|
+
sm: "calc(var(--radius) - 4px)",
|
|
12642
|
+
},
|
|
12643
|
+
borderWidth: {
|
|
12644
|
+
DEFAULT: "var(--border-width)",
|
|
12645
|
+
},
|
|
12646
|
+
boxShadow: {
|
|
12647
|
+
DEFAULT: "var(--shadow)",
|
|
12648
|
+
lg: "var(--shadow-lg)",
|
|
12649
|
+
},
|
|
12650
|
+
},
|
|
12651
|
+
},
|
|
12652
|
+
plugins: [],
|
|
12653
|
+
}`;
|
|
12654
|
+
}
|
|
12655
|
+
function postcssConfig() {
|
|
12656
|
+
return `export default {
|
|
12657
|
+
plugins: {
|
|
12658
|
+
tailwindcss: {},
|
|
12659
|
+
autoprefixer: {},
|
|
12660
|
+
},
|
|
12661
|
+
}`;
|
|
12662
|
+
}
|
|
12663
|
+
function indexCss(primaryColor, fontFamily, borderRadius) {
|
|
12664
|
+
const fontValue = `'${fontFamily}', ui-sans-serif, system-ui, sans-serif`;
|
|
12665
|
+
return `@tailwind base;
|
|
12666
|
+
@tailwind components;
|
|
12667
|
+
@tailwind utilities;
|
|
12668
|
+
|
|
12669
|
+
@layer base {
|
|
12670
|
+
:root {
|
|
12671
|
+
--background: 0 0% 100%;
|
|
12672
|
+
--foreground: 222.2 84% 4.9%;
|
|
12673
|
+
--card: 0 0% 100%;
|
|
12674
|
+
--card-foreground: 222.2 84% 4.9%;
|
|
12675
|
+
--primary: ${primaryColor};
|
|
12676
|
+
--primary-foreground: 210 40% 98%;
|
|
12677
|
+
--secondary: 210 40% 96.1%;
|
|
12678
|
+
--secondary-foreground: 222.2 47.4% 11.2%;
|
|
12679
|
+
--muted: 210 40% 96.1%;
|
|
12680
|
+
--muted-foreground: 215.4 16.3% 46.9%;
|
|
12681
|
+
--accent: 210 40% 96.1%;
|
|
12682
|
+
--accent-foreground: 222.2 47.4% 11.2%;
|
|
12683
|
+
--destructive: 0 84.2% 60.2%;
|
|
12684
|
+
--destructive-foreground: 210 40% 98%;
|
|
12685
|
+
--success: 142 76% 36%;
|
|
12686
|
+
--success-foreground: 210 40% 98%;
|
|
12687
|
+
--warning: 38 92% 50%;
|
|
12688
|
+
--warning-foreground: 222.2 47.4% 11.2%;
|
|
12689
|
+
--border: 214.3 31.8% 91.4%;
|
|
12690
|
+
--input: 214.3 31.8% 91.4%;
|
|
12691
|
+
--ring: 221.2 83.2% 53.3%;
|
|
12692
|
+
--radius: ${borderRadius};
|
|
12693
|
+
--border-width: 1px;
|
|
12694
|
+
--shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
|
|
12695
|
+
--shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
|
|
12696
|
+
--font-sans: ${fontValue};
|
|
12697
|
+
--font-heading: ${fontValue};
|
|
12698
|
+
}
|
|
12699
|
+
|
|
12700
|
+
.dark {
|
|
12701
|
+
--background: 222.2 84% 4.9%;
|
|
12702
|
+
--foreground: 210 40% 98%;
|
|
12703
|
+
--card: 222.2 84% 4.9%;
|
|
12704
|
+
--card-foreground: 210 40% 98%;
|
|
12705
|
+
--primary: 217.2 91.2% 59.8%;
|
|
12706
|
+
--primary-foreground: 222.2 47.4% 11.2%;
|
|
12707
|
+
--secondary: 217.2 32.6% 17.5%;
|
|
12708
|
+
--secondary-foreground: 210 40% 98%;
|
|
12709
|
+
--muted: 217.2 32.6% 17.5%;
|
|
12710
|
+
--muted-foreground: 215 20.2% 65.1%;
|
|
12711
|
+
--accent: 217.2 32.6% 17.5%;
|
|
12712
|
+
--accent-foreground: 210 40% 98%;
|
|
12713
|
+
--destructive: 0 62.8% 30.6%;
|
|
12714
|
+
--destructive-foreground: 210 40% 98%;
|
|
12715
|
+
--success: 142 76% 36%;
|
|
12716
|
+
--success-foreground: 210 40% 98%;
|
|
12717
|
+
--warning: 38 92% 50%;
|
|
12718
|
+
--warning-foreground: 222.2 47.4% 11.2%;
|
|
12719
|
+
--border: 217.2 32.6% 17.5%;
|
|
12720
|
+
--input: 217.2 32.6% 17.5%;
|
|
12721
|
+
--ring: 224.3 76.3% 48%;
|
|
12722
|
+
--border-width: 1px;
|
|
12723
|
+
--shadow: 0 1px 3px 0 rgb(0 0 0 / 0.3), 0 1px 2px -1px rgb(0 0 0 / 0.3);
|
|
12724
|
+
--shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.3), 0 4px 6px -4px rgb(0 0 0 / 0.3);
|
|
12725
|
+
--font-sans: ${fontValue};
|
|
12726
|
+
--font-heading: ${fontValue};
|
|
12727
|
+
}
|
|
12728
|
+
}
|
|
12729
|
+
|
|
12730
|
+
body {
|
|
12731
|
+
@apply bg-background text-foreground font-sans;
|
|
12732
|
+
}`;
|
|
12733
|
+
}
|
|
12734
|
+
function utilsTs() {
|
|
12735
|
+
return `import { clsx, type ClassValue } from 'clsx'
|
|
12736
|
+
import { twMerge } from 'tailwind-merge'
|
|
12737
|
+
|
|
12738
|
+
export function cn(...inputs: ClassValue[]) {
|
|
12739
|
+
return twMerge(clsx(inputs))
|
|
12740
|
+
}`;
|
|
12741
|
+
}
|
|
12742
|
+
function mainTsx() {
|
|
12743
|
+
return `import React from 'react'
|
|
12744
|
+
import ReactDOM from 'react-dom/client'
|
|
12745
|
+
import App from './App'
|
|
12746
|
+
import './index.css'
|
|
12747
|
+
|
|
12748
|
+
ReactDOM.createRoot(document.getElementById('root')!).render(
|
|
12749
|
+
<React.StrictMode>
|
|
12750
|
+
<App />
|
|
12751
|
+
</React.StrictMode>,
|
|
12752
|
+
)`;
|
|
12753
|
+
}
|
|
12754
|
+
var scaffold = tool({
|
|
12755
|
+
description: "Scaffold a new React + Vite + Tailwind CSS project with the HelloLeo design system. " + "Creates all mandatory boilerplate: package.json, index.html (with Google Fonts), " + "vite.config.js, tailwind.config.js, postcss.config.js, src/index.css (CSS variables " + "light+dark), src/lib/utils.ts (cn helper), and src/main.tsx. " + "Call this FIRST for any new project before writing App.tsx and components.",
|
|
12756
|
+
args: {
|
|
12757
|
+
name: tool.schema.string().optional().describe("Project name for package.json (default: leo-project)"),
|
|
12758
|
+
primaryColor: tool.schema.string().optional().describe('HSL values for primary color, e.g. "221.2 83.2% 53.3%" (default: blue)'),
|
|
12759
|
+
fontFamily: tool.schema.string().optional().describe('Google Font family name, e.g. "Inter", "Poppins" (default: Inter)'),
|
|
12760
|
+
borderRadius: tool.schema.string().optional().describe('Base border radius, e.g. "0.5rem", "0.75rem" (default: 0.5rem)')
|
|
12761
|
+
},
|
|
12762
|
+
async execute(args, context) {
|
|
12763
|
+
const dir = context.directory;
|
|
12764
|
+
const name = args.name ?? "leo-project";
|
|
12765
|
+
const primary = args.primaryColor ?? "221.2 83.2% 53.3%";
|
|
12766
|
+
const font = args.fontFamily ?? "Inter";
|
|
12767
|
+
const radius = args.borderRadius ?? "0.5rem";
|
|
12768
|
+
await mkdir(path2.join(dir, "src", "lib"), { recursive: true });
|
|
12769
|
+
const files = [
|
|
12770
|
+
["package.json", packageJson(name)],
|
|
12771
|
+
["index.html", indexHtml(font)],
|
|
12772
|
+
["vite.config.js", viteConfig()],
|
|
12773
|
+
["tailwind.config.js", tailwindConfig()],
|
|
12774
|
+
["postcss.config.js", postcssConfig()],
|
|
12775
|
+
[path2.join("src", "index.css"), indexCss(primary, font, radius)],
|
|
12776
|
+
[path2.join("src", "lib", "utils.ts"), utilsTs()],
|
|
12777
|
+
[path2.join("src", "main.tsx"), mainTsx()]
|
|
12778
|
+
];
|
|
12779
|
+
const created = [];
|
|
12780
|
+
for (const [filePath, content] of files) {
|
|
12781
|
+
await Bun.write(path2.join(dir, filePath), content);
|
|
12782
|
+
created.push(filePath);
|
|
12783
|
+
}
|
|
12784
|
+
return [
|
|
12785
|
+
`Scaffolded ${created.length} files:`,
|
|
12786
|
+
...created.map((f) => ` - ${f}`),
|
|
12787
|
+
"",
|
|
12788
|
+
"Next: create src/App.tsx with your application code.",
|
|
12789
|
+
"The design system is ready -- use design tokens (bg-primary, text-foreground, etc.)",
|
|
12790
|
+
"and create UI components in src/components/ui/.",
|
|
12791
|
+
"Make sure to update package.json with all packages you need after scaffolding."
|
|
12792
|
+
].join(`
|
|
12793
|
+
`);
|
|
12794
|
+
}
|
|
12795
|
+
});
|
|
12796
|
+
var ScaffoldPlugin = async () => {
|
|
12797
|
+
return {
|
|
12798
|
+
tool: { scaffold }
|
|
12799
|
+
};
|
|
12800
|
+
};
|
|
12544
12801
|
export {
|
|
12802
|
+
ScaffoldPlugin,
|
|
12545
12803
|
RemovePlugin,
|
|
12546
12804
|
InspectHttpPlugin
|
|
12547
12805
|
};
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { InspectHttpPlugin } from "./tools/inspect-http.ts";
|
|
2
2
|
export { RemovePlugin } from "./tools/remove.ts";
|
|
3
|
-
|
|
3
|
+
export { ScaffoldPlugin } from "./tools/scaffold.ts";
|
|
4
4
|
// export { CreatePlanPlugin } from "./tools/create-plan.ts";
|
|
5
5
|
// export { ListPlansPlugin } from "./tools/list-plans.ts";
|
|
6
6
|
// export { ModifyPlanPlugin } from "./tools/modify-plan.ts";
|
package/src/tools/scaffold.ts
CHANGED
|
@@ -21,6 +21,7 @@ function packageJson(name: string) {
|
|
|
21
21
|
"react-dom": "^18.3.1",
|
|
22
22
|
clsx: "^2.1.1",
|
|
23
23
|
"tailwind-merge": "^2.6.0",
|
|
24
|
+
"lucide-react": "^1.14.0",
|
|
24
25
|
},
|
|
25
26
|
devDependencies: {
|
|
26
27
|
"@types/react": "^18.3.12",
|
|
@@ -289,6 +290,7 @@ export const scaffold = tool({
|
|
|
289
290
|
"Next: create src/App.tsx with your application code.",
|
|
290
291
|
"The design system is ready -- use design tokens (bg-primary, text-foreground, etc.)",
|
|
291
292
|
"and create UI components in src/components/ui/.",
|
|
293
|
+
"Make sure to update package.json with all packages you need after scaffolding.",
|
|
292
294
|
].join("\n");
|
|
293
295
|
},
|
|
294
296
|
});
|