create-githat-app 0.1.1
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 +223 -0
- package/bin/index.js +7 -0
- package/package.json +25 -0
- package/src/cli.js +131 -0
- package/src/scaffold.js +529 -0
- package/src/templates/components.js +97 -0
- package/src/templates/index.js +172 -0
- package/src/templates/pages.js +471 -0
- package/src/templates/react.js +191 -0
package/README.md
ADDED
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
# create-githat-app
|
|
2
|
+
|
|
3
|
+
**Ship authenticated apps in seconds, not weeks.**
|
|
4
|
+
|
|
5
|
+
`create-githat-app` scaffolds a complete, production-ready application with authentication, team management, and a polished dashboard — all wired up and ready to go. One command. Zero boilerplate.
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/create-githat-app)
|
|
8
|
+
[](https://github.com/GitHat-IO/create-githat-app/blob/main/LICENSE)
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Quick Start
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npx create-githat-app my-app
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
That's it. You now have a fully functional app with sign-in, sign-up, protected routes, a dashboard, team management, API keys, and more.
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
cd my-app
|
|
22
|
+
npm run dev
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Open [http://localhost:3000](http://localhost:3000) and see it live.
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## What You Get
|
|
30
|
+
|
|
31
|
+
Every scaffolded app comes with **all of this** out of the box:
|
|
32
|
+
|
|
33
|
+
- **Authentication** — Sign in, sign up, sign out, fully wired
|
|
34
|
+
- **Forgot / Reset Password** — Complete recovery flow
|
|
35
|
+
- **Protected Routes** — Middleware (Next.js) or route guards (React)
|
|
36
|
+
- **Dashboard** — Sidebar navigation, responsive layout
|
|
37
|
+
- **Settings** — Profile editing, avatar upload, password change
|
|
38
|
+
- **Team Management** — Invite members, change roles, remove users
|
|
39
|
+
- **API Keys** — Create apps, view and copy publishable/secret keys
|
|
40
|
+
- **Email Verification** — Banner prompting unverified users
|
|
41
|
+
- **Org Switcher** — Switch between organizations seamlessly
|
|
42
|
+
- **Dark Theme** — Beautiful dark UI, responsive on all devices
|
|
43
|
+
|
|
44
|
+
No glue code. No half-baked starters. A **complete application** from the first `npm run dev`.
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## Frameworks
|
|
49
|
+
|
|
50
|
+
| Framework | Router | Styling | Dev Server |
|
|
51
|
+
|--------------------------|--------------------|-----------------------|---------------------|
|
|
52
|
+
| **Next.js** (App Router) | File-based routing | CSS Modules / globals | `next dev` on :3000 |
|
|
53
|
+
| **React** (Vite) | React Router DOM | CSS / inline styles | `vite` on :5173 |
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## CLI Options & Flags
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
npx create-githat-app [project-name] [options]
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
| Option | Description |
|
|
64
|
+
|---------------------------|------------------------------------------------------|
|
|
65
|
+
| `project-name` | Directory name for your app (prompted if omitted) |
|
|
66
|
+
| `--js` | Use JavaScript instead of TypeScript (Next.js only) |
|
|
67
|
+
| `--key <publishable_key>` | Set your GitHat publishable key upfront |
|
|
68
|
+
|
|
69
|
+
### Examples
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
# Interactive — prompts for everything
|
|
73
|
+
npx create-githat-app
|
|
74
|
+
|
|
75
|
+
# Named project with defaults
|
|
76
|
+
npx create-githat-app my-app
|
|
77
|
+
|
|
78
|
+
# JavaScript project with key pre-configured
|
|
79
|
+
npx create-githat-app my-app --js --key pk_live_abc123
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## Interactive Prompts
|
|
85
|
+
|
|
86
|
+
When you run the CLI, you'll be guided through:
|
|
87
|
+
|
|
88
|
+
1. **Project name** — if not provided as an argument
|
|
89
|
+
2. **Framework** — Next.js (App Router) or React (Vite)
|
|
90
|
+
3. **Package manager** — npm, pnpm, or yarn
|
|
91
|
+
4. **Publishable key** — optional; you can add it to `.env` later
|
|
92
|
+
5. **Features** — multi-select the pages you want:
|
|
93
|
+
- Dashboard
|
|
94
|
+
- Settings (profile, avatar, password)
|
|
95
|
+
- Team management (invites, roles)
|
|
96
|
+
- Apps (API key management)
|
|
97
|
+
- Forgot Password (recovery flow)
|
|
98
|
+
|
|
99
|
+
Select only what you need, or grab them all.
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## Project Structure
|
|
104
|
+
|
|
105
|
+
### Next.js (App Router)
|
|
106
|
+
|
|
107
|
+
```text
|
|
108
|
+
my-app/
|
|
109
|
+
├── app/
|
|
110
|
+
│ ├── layout.tsx # GitHatProvider wrapper
|
|
111
|
+
│ ├── page.tsx # Home with sign-in/up buttons
|
|
112
|
+
│ ├── globals.css
|
|
113
|
+
│ ├── middleware.ts # Auth route protection
|
|
114
|
+
│ ├── (auth)/
|
|
115
|
+
│ │ ├── sign-in/page.tsx
|
|
116
|
+
│ │ ├── sign-up/page.tsx
|
|
117
|
+
│ │ ├── forgot-password/page.tsx
|
|
118
|
+
│ │ └── reset-password/page.tsx
|
|
119
|
+
│ └── dashboard/
|
|
120
|
+
│ ├── layout.tsx # Protected layout + sidebar
|
|
121
|
+
│ ├── page.tsx
|
|
122
|
+
│ ├── settings/page.tsx
|
|
123
|
+
│ ├── team/page.tsx
|
|
124
|
+
│ └── apps/page.tsx
|
|
125
|
+
├── .env.local
|
|
126
|
+
├── .env.example
|
|
127
|
+
├── package.json
|
|
128
|
+
└── next.config.mjs
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### React (Vite)
|
|
132
|
+
|
|
133
|
+
```text
|
|
134
|
+
my-app/
|
|
135
|
+
├── src/
|
|
136
|
+
│ ├── main.jsx # BrowserRouter + GitHatProvider
|
|
137
|
+
│ ├── App.jsx # Route definitions
|
|
138
|
+
│ ├── pages/
|
|
139
|
+
│ │ ├── Home.jsx
|
|
140
|
+
│ │ ├── SignIn.jsx
|
|
141
|
+
│ │ ├── SignUp.jsx
|
|
142
|
+
│ │ ├── Dashboard.jsx
|
|
143
|
+
│ │ ├── DashboardLayout.jsx
|
|
144
|
+
│ │ ├── Settings.jsx
|
|
145
|
+
│ │ ├── Team.jsx
|
|
146
|
+
│ │ ├── Apps.jsx
|
|
147
|
+
│ │ ├── ForgotPassword.jsx
|
|
148
|
+
│ │ └── ResetPassword.jsx
|
|
149
|
+
│ └── components/
|
|
150
|
+
│ ├── Sidebar.jsx
|
|
151
|
+
│ └── VerifyEmailBanner.jsx
|
|
152
|
+
├── .env
|
|
153
|
+
├── .env.example
|
|
154
|
+
├── index.html
|
|
155
|
+
└── vite.config.js
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
## Configuration
|
|
161
|
+
|
|
162
|
+
After scaffolding, add your GitHat publishable key to the environment file:
|
|
163
|
+
|
|
164
|
+
**Next.js** — `.env.local`
|
|
165
|
+
|
|
166
|
+
```env
|
|
167
|
+
NEXT_PUBLIC_GITHAT_PUBLISHABLE_KEY=pk_live_your_key_here
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
**React (Vite)** — `.env`
|
|
171
|
+
|
|
172
|
+
```env
|
|
173
|
+
VITE_GITHAT_PUBLISHABLE_KEY=pk_live_your_key_here
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
If you passed `--key pk_live_xxx` during setup, this is already configured for you.
|
|
177
|
+
|
|
178
|
+
> A `.env.example` file is included in every project for reference.
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## Getting Your Publishable Key
|
|
183
|
+
|
|
184
|
+
1. Go to [https://githat.io](https://githat.io) and create an account
|
|
185
|
+
2. Create an organization (or use your default one)
|
|
186
|
+
3. Navigate to **Apps** in the dashboard
|
|
187
|
+
4. Create a new app and copy the **Publishable Key**
|
|
188
|
+
5. Paste it into your `.env.local` or `.env` file
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
## Dependencies
|
|
193
|
+
|
|
194
|
+
The CLI installs only what your chosen framework needs:
|
|
195
|
+
|
|
196
|
+
**Next.js projects:**
|
|
197
|
+
|
|
198
|
+
- `@githat/nextjs` — GitHat SDK (auth provider, components, hooks)
|
|
199
|
+
- `next` — Next.js framework
|
|
200
|
+
- `react` / `react-dom` — React
|
|
201
|
+
|
|
202
|
+
**React (Vite) projects:**
|
|
203
|
+
|
|
204
|
+
- `@githat/nextjs` — GitHat SDK (works with any React setup)
|
|
205
|
+
- `react` / `react-dom` — React
|
|
206
|
+
- `react-router-dom` — Client-side routing
|
|
207
|
+
- `vite` / `@vitejs/plugin-react` — Build tooling
|
|
208
|
+
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
## Links
|
|
212
|
+
|
|
213
|
+
- **GitHat Platform** — [https://githat.io](https://githat.io)
|
|
214
|
+
- **SDK Documentation** — [@githat/nextjs on npm](https://www.npmjs.com/package/@githat/nextjs)
|
|
215
|
+
- **CLI on npm** — [create-githat-app](https://www.npmjs.com/package/create-githat-app)
|
|
216
|
+
- **GitHub** — [GitHat-IO/create-githat-app](https://github.com/GitHat-IO/create-githat-app)
|
|
217
|
+
- **Report Issues** — [GitHub Issues](https://github.com/GitHat-IO/create-githat-app/issues)
|
|
218
|
+
|
|
219
|
+
---
|
|
220
|
+
|
|
221
|
+
## License
|
|
222
|
+
|
|
223
|
+
Proprietary — see [LICENSE](../../LICENSE) for details.
|
package/bin/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "create-githat-app",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Scaffold a new app with GitHat identity built in",
|
|
5
|
+
"bin": {
|
|
6
|
+
"create-githat-app": "./bin/index.js"
|
|
7
|
+
},
|
|
8
|
+
"files": ["bin", "src"],
|
|
9
|
+
"scripts": {
|
|
10
|
+
"test": "node bin/index.js --help"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"prompts": "^2.4.2"
|
|
14
|
+
},
|
|
15
|
+
"keywords": ["githat", "nextjs", "react", "vite", "create-app", "cli", "auth", "identity"],
|
|
16
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"access": "public",
|
|
19
|
+
"registry": "https://registry.npmjs.org/"
|
|
20
|
+
},
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git+https://github.com/GitHat-IO/MicroFrontEnds.git"
|
|
24
|
+
}
|
|
25
|
+
}
|
package/src/cli.js
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
const prompts = require('prompts');
|
|
2
|
+
const { scaffold } = require('./scaffold');
|
|
3
|
+
|
|
4
|
+
// ANSI color helpers (zero dependencies)
|
|
5
|
+
const c = {
|
|
6
|
+
reset: '\x1b[0m',
|
|
7
|
+
bold: '\x1b[1m',
|
|
8
|
+
dim: '\x1b[2m',
|
|
9
|
+
green: '\x1b[32m',
|
|
10
|
+
cyan: '\x1b[36m',
|
|
11
|
+
magenta: '\x1b[35m',
|
|
12
|
+
yellow: '\x1b[33m',
|
|
13
|
+
red: '\x1b[31m',
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
function banner() {
|
|
17
|
+
console.log(`
|
|
18
|
+
${c.magenta}┌─────────────────────────────────────┐${c.reset}
|
|
19
|
+
${c.magenta}│${c.reset} ${c.magenta}│${c.reset}
|
|
20
|
+
${c.magenta}│${c.reset} ${c.bold}${c.magenta}◆${c.reset} ${c.bold}create-githat-app${c.reset} ${c.magenta}│${c.reset}
|
|
21
|
+
${c.magenta}│${c.reset} ${c.dim}Identity for your application${c.reset} ${c.magenta}│${c.reset}
|
|
22
|
+
${c.magenta}│${c.reset} ${c.magenta}│${c.reset}
|
|
23
|
+
${c.magenta}└─────────────────────────────────────┘${c.reset}
|
|
24
|
+
`);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async function cli(args) {
|
|
28
|
+
let projectName = args[0];
|
|
29
|
+
|
|
30
|
+
if (args.includes('--help') || args.includes('-h')) {
|
|
31
|
+
banner();
|
|
32
|
+
console.log(` ${c.bold}Usage:${c.reset} create-githat-app ${c.cyan}[project-name]${c.reset}
|
|
33
|
+
|
|
34
|
+
Scaffold a new app with GitHat identity built in.
|
|
35
|
+
|
|
36
|
+
${c.bold}Options:${c.reset}
|
|
37
|
+
${c.cyan}--help, -h${c.reset} Show this help message
|
|
38
|
+
${c.cyan}--ts${c.reset} Use TypeScript (default)
|
|
39
|
+
${c.cyan}--js${c.reset} Use JavaScript
|
|
40
|
+
${c.cyan}--key <key>${c.reset} GitHat publishable key (pk_live_...)
|
|
41
|
+
|
|
42
|
+
${c.bold}Examples:${c.reset}
|
|
43
|
+
${c.dim}$${c.reset} npx create-githat-app my-app
|
|
44
|
+
${c.dim}$${c.reset} npx create-githat-app my-app --js
|
|
45
|
+
${c.dim}$${c.reset} npx create-githat-app my-app --key pk_live_abc123
|
|
46
|
+
|
|
47
|
+
${c.dim}Docs: https://githat.io/docs/cli${c.reset}
|
|
48
|
+
`);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
banner();
|
|
53
|
+
|
|
54
|
+
if (!projectName) {
|
|
55
|
+
const res = await prompts({
|
|
56
|
+
type: 'text',
|
|
57
|
+
name: 'name',
|
|
58
|
+
message: `${c.bold}Project name${c.reset}`,
|
|
59
|
+
initial: 'my-githat-app',
|
|
60
|
+
});
|
|
61
|
+
if (!res.name) process.exit(0);
|
|
62
|
+
projectName = res.name;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const useTS = args.includes('--js') ? false : true;
|
|
66
|
+
const keyIdx = args.indexOf('--key');
|
|
67
|
+
let publishableKey = keyIdx !== -1 ? args[keyIdx + 1] : '';
|
|
68
|
+
|
|
69
|
+
const responses = await prompts([
|
|
70
|
+
{
|
|
71
|
+
type: 'select',
|
|
72
|
+
name: 'framework',
|
|
73
|
+
message: `${c.bold}Framework${c.reset}`,
|
|
74
|
+
choices: [
|
|
75
|
+
{ title: `Next.js ${c.dim}(App Router)${c.reset}`, value: 'nextjs' },
|
|
76
|
+
{ title: `React ${c.dim}(Vite)${c.reset}`, value: 'react' },
|
|
77
|
+
],
|
|
78
|
+
initial: 0,
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
type: 'select',
|
|
82
|
+
name: 'pm',
|
|
83
|
+
message: `${c.bold}Package manager${c.reset}`,
|
|
84
|
+
choices: [
|
|
85
|
+
{ title: 'npm', value: 'npm' },
|
|
86
|
+
{ title: 'pnpm', value: 'pnpm' },
|
|
87
|
+
{ title: 'yarn', value: 'yarn' },
|
|
88
|
+
],
|
|
89
|
+
initial: 0,
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
type: publishableKey ? null : 'text',
|
|
93
|
+
name: 'key',
|
|
94
|
+
message: `${c.bold}Publishable key${c.reset} ${c.dim}(optional — get one at githat.io/dashboard/apps)${c.reset}`,
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
type: 'multiselect',
|
|
98
|
+
name: 'features',
|
|
99
|
+
message: `${c.bold}Include pages${c.reset}`,
|
|
100
|
+
choices: [
|
|
101
|
+
{ title: `Dashboard ${c.dim}(protected home)${c.reset}`, value: 'dashboard', selected: true },
|
|
102
|
+
{ title: `Settings ${c.dim}(profile, avatar, password)${c.reset}`, value: 'settings', selected: true },
|
|
103
|
+
{ title: `Team ${c.dim}(org members, invites)${c.reset}`, value: 'team', selected: true },
|
|
104
|
+
{ title: `Apps ${c.dim}(API keys)${c.reset}`, value: 'apps' },
|
|
105
|
+
{ title: `Forgot Password ${c.dim}(reset flow)${c.reset}`, value: 'forgotPassword' },
|
|
106
|
+
],
|
|
107
|
+
hint: '- Space to select. Return to submit',
|
|
108
|
+
},
|
|
109
|
+
]);
|
|
110
|
+
|
|
111
|
+
if (responses.framework === undefined) process.exit(0);
|
|
112
|
+
if (!publishableKey) publishableKey = responses.key || '';
|
|
113
|
+
|
|
114
|
+
const feat = responses.features || ['dashboard'];
|
|
115
|
+
await scaffold({
|
|
116
|
+
projectName,
|
|
117
|
+
framework: responses.framework || 'nextjs',
|
|
118
|
+
typescript: useTS,
|
|
119
|
+
packageManager: responses.pm || 'npm',
|
|
120
|
+
publishableKey,
|
|
121
|
+
features: {
|
|
122
|
+
dashboard: feat.includes('dashboard'),
|
|
123
|
+
settings: feat.includes('settings'),
|
|
124
|
+
team: feat.includes('team'),
|
|
125
|
+
apps: feat.includes('apps'),
|
|
126
|
+
forgotPassword: feat.includes('forgotPassword'),
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
module.exports = { cli };
|