Skip to content

Commit d4b26ce

Browse files
authored
feat(#351 | create hypergraph): buildout create-hypergraph cli tool to scaffold a Hypergraph-enabled app (#364)
1 parent e241fe1 commit d4b26ce

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+2745
-442
lines changed

.changeset/shaggy-cups-scream.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"create-hypergraph": patch
3+
---
4+
5+
Add CHANGELOG.md to publishable dist folder
6+

.github/workflows/tests-and-checks.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ jobs:
2424
run: pnpm build
2525
- name: Generate Prisma Types
2626
run: cd apps/server && pnpm prisma generate
27+
- name: Configure Git for tests
28+
run: |
29+
git config --global user.email "[email protected]"
30+
git config --global user.name "Test User"
2731
- name: Typecheck
2832
run: pnpm check
2933
- name: Linting & Formatting

CONTRIBUTING.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ cd apps/typesync
4747
pnpm dev:client
4848
```
4949

50+
To develop the create-hypergraph, run:
51+
52+
```sh
53+
cd apps/create-hypergraph
54+
pnpm run dev
55+
```
56+
5057
You can run the Next example app with:
5158

5259
```sh

apps/connect/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"@tanstack/react-router-devtools": "^1.122.0",
2525
"@xstate/store": "^3.5.1",
2626
"clsx": "^2.1.1",
27-
"effect": "^3.16.16",
27+
"effect": "^3.17.0",
2828
"framer-motion": "^12.10.1",
2929
"graphql-request": "^7.2.0",
3030
"lucide-react": "^0.508.0",
@@ -37,7 +37,7 @@
3737
"devDependencies": {
3838
"@tailwindcss/vite": "^4.1.10",
3939
"@tanstack/router-plugin": "^1.120.2",
40-
"@types/node": "^22.15.15",
40+
"@types/node": "^24.1.0",
4141
"@types/react": "^19.1.3",
4242
"@types/react-dom": "^19.1.3",
4343
"@vitejs/plugin-react": "^4.4.1",

apps/create-hypergraph-app/README.md

Lines changed: 0 additions & 42 deletions
This file was deleted.

apps/create-hypergraph-app/package.json

Lines changed: 0 additions & 39 deletions
This file was deleted.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# create-hypergraph
2+
3+
## 0.0.2
4+
### Patch Changes
5+
6+
- 2d3814e: better check for access to template directory
7+
- 97894a1: test suite for Cli tool
8+
- f54e72a: create llms.txt for create-hypergraph usage
9+
- 4446ffe: resolve inputs from passed in options or prompts
10+
- f40426b: fix typo
11+
- ba47d53: rename package.json bin to create-hypergraph
12+
- 447cdb4: rename to create-hypergraph (drop app)
13+
- bd88912: handle sigint of user killing cli with a log line instead of error message
14+
- deee18d: add create-hypergraph-app tests to root workspace
15+
- 39beee4: fixes. updates from testing
16+
- 68a79db: rebase main. sort order import
17+
- 64d196d: buildout ability scaffold app, install deps, initialize git
18+
- 8ea798f: bump @types/node to latest
19+
- a004e4f: use prompts instead of options
20+
- 5a4c193: working on building create-hypergraph-app cli tool

apps/create-hypergraph/README.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# @graphprotocol/create-hypergraph-app
2+
3+
CLI toolchain to scaffold a [Hypergraph-enabled](https://github.com/graphprotocol/hypergraph) application with a given template.
4+
5+
Inspiration takes from the `vite`, `nextjs`, and `effect` create app command tools.
6+
7+
## Scaffolding a hypergraph app
8+
9+
With NPM:
10+
11+
```bash
12+
npm create hypergraph@latest
13+
```
14+
15+
With Yarn:
16+
17+
```bash
18+
yarn create hypergraph
19+
```
20+
21+
With PNPM:
22+
23+
```bash
24+
pnpm create hypergraph@latest
25+
```
26+
27+
With Bun:
28+
29+
```bash
30+
bun create hypergraph
31+
```
32+
33+
Then follow the given prompts.
34+
35+
### Args
36+
37+
- `app-name` -> if provided, used as the name of the app, as well as the directory the app is scaffolded in to
38+
39+
### Params
40+
41+
- `--template` -> if provided, uses the provided template
42+
- options:
43+
- vite-react
44+
- `--package-manager` -> if provided, uses the provided package manager
45+
- options:
46+
- pnpm
47+
- bun
48+
- npm
49+
- yarn
50+
- `--skip-install-deps` -> if flag provided, the deps will not be install in the scaffolded app
51+
- default: false
52+
- `--skip-initialize-git` -> if flag provided, git will not be initialized in the scaffolded app
53+
- default: false
54+
55+
```bash
56+
# fully configured
57+
pnpm create hypergraph@latest --template vite-react --package-manager pnpm my-hypergraph-app
58+
```
59+
60+
### Currently Supported Templates
61+
62+
- vite + react
63+
64+
## References
65+
66+
- [create vite app](https://github.com/vitejs/vite/tree/main/packages/create-vite)
67+
- [create effect app](https://effect.website/docs/getting-started/create-effect-app/)

apps/create-hypergraph/llms.txt

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
# create-hypergraph
2+
3+
A command-line tool for scaffolding Hypergraph-enabled applications.
4+
5+
## What is Hypergraph?
6+
7+
Hypergraph is a local-first framework for building web3 consumer applications. It enables developers to build performant, privacy-preserving apps where:
8+
9+
- Data is stored locally on the user's device with zero network latency
10+
- All private data is end-to-end encrypted
11+
- Changes sync automatically across devices when online
12+
- Users own their data and can take it between apps
13+
- No traditional backend infrastructure is needed
14+
15+
## When to Use Hypergraph
16+
17+
Use Hypergraph when building:
18+
- **Collaborative Applications**: Real-time document editing, shared workspaces, team tools
19+
- **Social Applications**: Messaging apps, social networks, community platforms
20+
- **Knowledge Management**: Note-taking apps, personal wikis, research tools
21+
- **Privacy-First Apps**: Any application requiring end-to-end encryption
22+
- **Offline-First Apps**: Applications that must work without internet connectivity
23+
24+
Hypergraph is ideal when you need:
25+
- Instant UI updates without loading spinners
26+
- Real-time collaboration features
27+
- User-owned, portable data
28+
- Privacy through encryption
29+
- To avoid managing servers and databases
30+
31+
## Installation and Usage
32+
33+
This tool is published to npm and can be run using:
34+
```bash
35+
pnpm create hypergraph
36+
# or
37+
npm create hypergraph
38+
# or
39+
yarn create hypergraph
40+
# or
41+
bun create hypergraph
42+
```
43+
44+
Alternatively, you can use the shorthand:
45+
```bash
46+
pnpx ch
47+
```
48+
49+
## Purpose
50+
51+
create-hypergraph is a CLI tool that scaffolds new Hypergraph-enabled applications with pre-configured templates. It streamlines the process of setting up a new project with The Graph Protocol's Hypergraph framework.
52+
53+
## Command-Line Options
54+
55+
### Positional Arguments
56+
57+
- `app-name` (optional): The name of your application. This will also be the folder name where your app is scaffolded. If not provided, the tool will prompt for it interactively.
58+
59+
### Options
60+
61+
- `--template, -t` (optional): Template to scaffold
62+
- Available values: `vite-react`
63+
- Default: prompts user to select
64+
- Currently only supports `vite-react` which scaffolds a Vite + React app using @tanstack/react-router
65+
66+
- `--package-manager, -p` (optional): The package manager to use for installing dependencies
67+
- Available values: `pnpm`, `bun`, `yarn`, `npm`
68+
- Default: prompts user to select
69+
70+
- `--skip-install-deps`: Skip installing dependencies after scaffolding
71+
- Default: false (dependencies will be installed)
72+
73+
- `--skip-initialize-git`: Skip initializing a git repository in the scaffolded app
74+
- Default: false (git repository will be initialized with an initial commit)
75+
76+
## Examples
77+
78+
### Interactive Mode (Recommended)
79+
```bash
80+
pnpm create hypergraph
81+
```
82+
This will prompt you for all necessary information.
83+
84+
### Fully Specified
85+
```bash
86+
pnpm create hypergraph my-app --template vite-react --package-manager pnpm
87+
```
88+
89+
### Skip Optional Steps
90+
```bash
91+
pnpm create hypergraph my-app --skip-install-deps --skip-initialize-git
92+
```
93+
94+
## Workflow
95+
96+
1. **Validates app name**: Ensures the provided name is a valid project name
97+
2. **Checks target directory**: Verifies the directory doesn't exist or is empty
98+
3. **Copies template files**: Scaffolds the selected template into the target directory
99+
4. **Updates package.json**: Sets the correct package name in the scaffolded app
100+
5. **Initializes git** (optional): Creates a git repository with initial commit
101+
6. **Installs dependencies** (optional): Runs the package manager install command
102+
103+
## Template Details
104+
105+
### vite-react
106+
- Modern React application using Vite as the build tool
107+
- Configured with @tanstack/react-router for routing
108+
- Hypergraph integration pre-configured
109+
- TypeScript enabled
110+
- Development server with HMR
111+
112+
## Error Handling
113+
114+
The tool will fail gracefully if:
115+
- The target directory exists and is not empty
116+
- The selected template doesn't exist
117+
- Git initialization fails
118+
- Dependency installation fails
119+
120+
## Requirements
121+
122+
- Node.js >= 20
123+
- One of the supported package managers (pnpm, npm, yarn, or bun)
124+
125+
## Post-Scaffolding
126+
127+
After successful scaffolding, navigate to your app directory and start development:
128+
```bash
129+
cd <app-name>
130+
pnpm run dev # or npm/yarn/bun run dev
131+
```

0 commit comments

Comments
 (0)