@butterbase/cli 0.1.0

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 (59) hide show
  1. package/README.md +255 -0
  2. package/bin/butterbase.ts +137 -0
  3. package/dist/bin/butterbase.d.ts +3 -0
  4. package/dist/bin/butterbase.d.ts.map +1 -0
  5. package/dist/bin/butterbase.js +112 -0
  6. package/dist/bin/butterbase.js.map +1 -0
  7. package/dist/src/commands/apps.d.ts +5 -0
  8. package/dist/src/commands/apps.d.ts.map +1 -0
  9. package/dist/src/commands/apps.js +113 -0
  10. package/dist/src/commands/apps.js.map +1 -0
  11. package/dist/src/commands/config.d.ts +5 -0
  12. package/dist/src/commands/config.d.ts.map +1 -0
  13. package/dist/src/commands/config.js +43 -0
  14. package/dist/src/commands/config.js.map +1 -0
  15. package/dist/src/commands/functions.d.ts +15 -0
  16. package/dist/src/commands/functions.d.ts.map +1 -0
  17. package/dist/src/commands/functions.js +94 -0
  18. package/dist/src/commands/functions.js.map +1 -0
  19. package/dist/src/commands/init.d.ts +2 -0
  20. package/dist/src/commands/init.d.ts.map +1 -0
  21. package/dist/src/commands/init.js +118 -0
  22. package/dist/src/commands/init.js.map +1 -0
  23. package/dist/src/commands/schema.d.ts +10 -0
  24. package/dist/src/commands/schema.d.ts.map +1 -0
  25. package/dist/src/commands/schema.js +69 -0
  26. package/dist/src/commands/schema.js.map +1 -0
  27. package/dist/src/commands/storage.d.ts +10 -0
  28. package/dist/src/commands/storage.d.ts.map +1 -0
  29. package/dist/src/commands/storage.js +105 -0
  30. package/dist/src/commands/storage.js.map +1 -0
  31. package/dist/src/lib/api-client.d.ts +44 -0
  32. package/dist/src/lib/api-client.d.ts.map +1 -0
  33. package/dist/src/lib/api-client.js +129 -0
  34. package/dist/src/lib/api-client.js.map +1 -0
  35. package/dist/src/lib/config.d.ts +47 -0
  36. package/dist/src/lib/config.d.ts.map +1 -0
  37. package/dist/src/lib/config.js +87 -0
  38. package/dist/src/lib/config.js.map +1 -0
  39. package/package.json +35 -0
  40. package/src/commands/apps.ts +130 -0
  41. package/src/commands/config.ts +50 -0
  42. package/src/commands/functions.ts +116 -0
  43. package/src/commands/init.ts +151 -0
  44. package/src/commands/schema.ts +78 -0
  45. package/src/commands/storage.ts +117 -0
  46. package/src/lib/api-client.ts +176 -0
  47. package/src/lib/config.ts +112 -0
  48. package/templates/react-vite/.env.example +2 -0
  49. package/templates/react-vite/README.md +38 -0
  50. package/templates/react-vite/index.html +13 -0
  51. package/templates/react-vite/package.json +25 -0
  52. package/templates/react-vite/src/App.css +33 -0
  53. package/templates/react-vite/src/App.tsx +77 -0
  54. package/templates/react-vite/src/index.css +8 -0
  55. package/templates/react-vite/src/lib.ts +6 -0
  56. package/templates/react-vite/src/main.tsx +10 -0
  57. package/templates/react-vite/tsconfig.json +21 -0
  58. package/templates/react-vite/vite.config.ts +6 -0
  59. package/tsconfig.json +20 -0
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "{{PROJECT_NAME}}",
3
+ "private": true,
4
+ "version": "0.0.0",
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "vite",
8
+ "build": "tsc -b && vite build",
9
+ "lint": "eslint .",
10
+ "preview": "vite preview"
11
+ },
12
+ "dependencies": {
13
+ "@butterbase/sdk": "^0.1.0",
14
+ "react": "^19.2.4",
15
+ "react-dom": "^19.2.4",
16
+ "react-router-dom": "^7.13.2"
17
+ },
18
+ "devDependencies": {
19
+ "@types/react": "^19.2.14",
20
+ "@types/react-dom": "^19.2.3",
21
+ "@vitejs/plugin-react": "^6.0.1",
22
+ "typescript": "~5.9.3",
23
+ "vite": "^8.0.1"
24
+ }
25
+ }
@@ -0,0 +1,33 @@
1
+ :root {
2
+ font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
3
+ line-height: 1.5;
4
+ font-weight: 400;
5
+ }
6
+
7
+ body {
8
+ margin: 0;
9
+ display: flex;
10
+ place-items: center;
11
+ min-width: 320px;
12
+ min-height: 100vh;
13
+ }
14
+
15
+ .App {
16
+ max-width: 1280px;
17
+ margin: 0 auto;
18
+ padding: 2rem;
19
+ text-align: center;
20
+ }
21
+
22
+ input {
23
+ margin: 0.5rem;
24
+ padding: 0.5rem;
25
+ font-size: 1rem;
26
+ }
27
+
28
+ button {
29
+ margin: 0.5rem;
30
+ padding: 0.5rem 1rem;
31
+ font-size: 1rem;
32
+ cursor: pointer;
33
+ }
@@ -0,0 +1,77 @@
1
+ import { useState, useEffect } from 'react';
2
+ import { butterbase } from './lib';
3
+ import './App.css';
4
+
5
+ function App() {
6
+ const [user, setUser] = useState<any>(null);
7
+ const [loading, setLoading] = useState(true);
8
+
9
+ useEffect(() => {
10
+ checkAuth();
11
+ }, []);
12
+
13
+ async function checkAuth() {
14
+ const { data } = await butterbase.auth.getUser();
15
+ setUser(data);
16
+ setLoading(false);
17
+ }
18
+
19
+ async function handleSignUp(email: string, password: string) {
20
+ const { data, error } = await butterbase.auth.signUp({ email, password });
21
+ if (error) {
22
+ alert(error.message);
23
+ } else {
24
+ setUser(data?.user);
25
+ }
26
+ }
27
+
28
+ async function handleSignIn(email: string, password: string) {
29
+ const { data, error } = await butterbase.auth.signIn({ email, password });
30
+ if (error) {
31
+ alert(error.message);
32
+ } else {
33
+ setUser(data?.user);
34
+ }
35
+ }
36
+
37
+ async function handleSignOut() {
38
+ await butterbase.auth.signOut();
39
+ setUser(null);
40
+ }
41
+
42
+ if (loading) {
43
+ return <div>Loading...</div>;
44
+ }
45
+
46
+ if (!user) {
47
+ return (
48
+ <div className="App">
49
+ <h1>Welcome to {{PROJECT_NAME}}</h1>
50
+ <p>Powered by Butterbase</p>
51
+ <div>
52
+ <h2>Sign In</h2>
53
+ <form onSubmit={(e) => {
54
+ e.preventDefault();
55
+ const form = e.target as HTMLFormElement;
56
+ const email = (form.elements.namedItem('email') as HTMLInputElement).value;
57
+ const password = (form.elements.namedItem('password') as HTMLInputElement).value;
58
+ handleSignIn(email, password);
59
+ }}>
60
+ <input name="email" type="email" placeholder="Email" required />
61
+ <input name="password" type="password" placeholder="Password" required />
62
+ <button type="submit">Sign In</button>
63
+ </form>
64
+ </div>
65
+ </div>
66
+ );
67
+ }
68
+
69
+ return (
70
+ <div className="App">
71
+ <h1>Welcome, {user.email}!</h1>
72
+ <button onClick={handleSignOut}>Sign Out</button>
73
+ </div>
74
+ );
75
+ }
76
+
77
+ export default App;
@@ -0,0 +1,8 @@
1
+ body {
2
+ margin: 0;
3
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
4
+ 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
5
+ sans-serif;
6
+ -webkit-font-smoothing: antialiased;
7
+ -moz-osx-font-smoothing: grayscale;
8
+ }
@@ -0,0 +1,6 @@
1
+ import { createClient } from '@butterbase/sdk';
2
+
3
+ export const butterbase = createClient({
4
+ appId: import.meta.env.VITE_APP_ID,
5
+ apiUrl: import.meta.env.VITE_API_URL,
6
+ });
@@ -0,0 +1,10 @@
1
+ import { StrictMode } from 'react';
2
+ import { createRoot } from 'react-dom/client';
3
+ import App from './App.tsx';
4
+ import './index.css';
5
+
6
+ createRoot(document.getElementById('root')!).render(
7
+ <StrictMode>
8
+ <App />
9
+ </StrictMode>,
10
+ );
@@ -0,0 +1,21 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "useDefineForClassFields": true,
5
+ "lib": ["ES2020", "DOM", "DOM.Iterable"],
6
+ "module": "ESNext",
7
+ "skipLibCheck": true,
8
+ "moduleResolution": "bundler",
9
+ "allowImportingTsExtensions": true,
10
+ "isolatedModules": true,
11
+ "moduleDetection": "force",
12
+ "noEmit": true,
13
+ "jsx": "react-jsx",
14
+ "strict": true,
15
+ "noUnusedLocals": true,
16
+ "noUnusedParameters": true,
17
+ "noFallthroughCasesInSwitch": true,
18
+ "noUncheckedSideEffectImports": true
19
+ },
20
+ "include": ["src"]
21
+ }
@@ -0,0 +1,6 @@
1
+ import { defineConfig } from 'vite';
2
+ import react from '@vitejs/plugin-react';
3
+
4
+ export default defineConfig({
5
+ plugins: [react()],
6
+ });
package/tsconfig.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "outDir": "./dist",
5
+ "rootDir": ".",
6
+ "declaration": true,
7
+ "declarationMap": true,
8
+ "sourceMap": true,
9
+ "lib": ["ES2022", "DOM"],
10
+ "target": "ES2022",
11
+ "module": "ES2022",
12
+ "moduleResolution": "bundler",
13
+ "esModuleInterop": true,
14
+ "skipLibCheck": true,
15
+ "strict": true,
16
+ "resolveJsonModule": true
17
+ },
18
+ "include": ["src/**/*", "bin/**/*"],
19
+ "exclude": ["node_modules", "dist", "**/*.test.ts"]
20
+ }