siteon 1.3.4 → 1.4.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 +66 -266
- package/{dist/index.js → index.js} +472 -245
- package/package.json +21 -39
- package/bun.lock +0 -80
- package/dist/Readme.md +0 -112
- package/dist/package.json +0 -21
- package/form-fields-example.md +0 -310
- package/instructions.md +0 -31
- package/postbuild.js +0 -17
- package/src/commands/init.ts +0 -462
- package/src/generators/index.ts +0 -238
- package/src/generators/templates/config-js.ts +0 -35
- package/src/generators/templates/config.ts +0 -59
- package/src/generators/templates/form-file.ts +0 -360
- package/src/generators/templates/get-media-js.ts +0 -97
- package/src/generators/templates/get-media-ts.ts +0 -61
- package/src/generators/templates/get-metadata-js.ts +0 -180
- package/src/generators/templates/get-metadata-ts.ts +0 -92
- package/src/generators/templates/http-client-js.ts +0 -65
- package/src/generators/templates/http-client-ts.ts +0 -65
- package/src/generators/templates/index-files.ts +0 -159
- package/src/generators/templates/public-form-file.ts +0 -870
- package/src/generators/templates/siteon-core-js.ts +0 -341
- package/src/generators/templates/siteon-core-static.ts +0 -156
- package/src/generators/templates/siteon-core-ts.ts +0 -240
- package/src/generators/templates/static.ts +0 -206
- package/src/generators/templates/types-ts.ts +0 -125
- package/src/generators/type-mapper.ts +0 -134
- package/src/index.ts +0 -21
- package/src/types.ts +0 -173
- package/src/utils/api.ts +0 -157
- package/src/utils/dependencies.ts +0 -88
- package/src/utils/files.ts +0 -139
- package/src/utils/prompts.ts +0 -220
- package/src/utils/version.ts +0 -5
- package/tsconfig.json +0 -17
package/Readme.md
CHANGED
|
@@ -1,312 +1,112 @@
|
|
|
1
|
-
#
|
|
1
|
+
# SiteOn
|
|
2
2
|
|
|
3
|
-
A
|
|
3
|
+
A powerful code generation tool that automatically generates content fetching and form submission code for your workspace.
|
|
4
|
+
|
|
5
|
+
## What is SiteOn?
|
|
6
|
+
|
|
7
|
+
SiteOn streamlines your development workflow by analyzing your workspace configuration and generating ready-to-use code for:
|
|
8
|
+
|
|
9
|
+
- **Content Fetching**: Automatically generate API calls and data fetching logic based on your workspace structure
|
|
10
|
+
- **Form Submissions**: Create public form submission handlers with proper validation and error handling
|
|
11
|
+
|
|
12
|
+
No more boilerplate code – SiteOn does the heavy lifting for you.
|
|
4
13
|
|
|
5
14
|
## Installation
|
|
6
15
|
|
|
7
|
-
|
|
16
|
+
### Quick Start with npx (Recommended)
|
|
8
17
|
|
|
9
|
-
|
|
18
|
+
Run SiteOn without installing:
|
|
10
19
|
|
|
11
20
|
```bash
|
|
12
|
-
npx
|
|
13
|
-
# or
|
|
14
|
-
npx github:compitcomds/siteon-registry init
|
|
21
|
+
npx siteon
|
|
15
22
|
```
|
|
16
23
|
|
|
17
|
-
2. Using pnpm dlx
|
|
18
|
-
|
|
19
24
|
```bash
|
|
20
|
-
pnpm dlx
|
|
21
|
-
# or
|
|
22
|
-
pnpm dlx github:compitcomds/siteon-registry#main init
|
|
25
|
+
pnpm dlx siteon
|
|
23
26
|
```
|
|
24
27
|
|
|
25
|
-
## Usage
|
|
26
|
-
|
|
27
|
-
### Initialize in your project
|
|
28
|
-
|
|
29
|
-
Run the `init` command in your project root:
|
|
30
|
-
|
|
31
28
|
```bash
|
|
32
|
-
siteon
|
|
29
|
+
bunx siteon
|
|
33
30
|
```
|
|
34
31
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
1. **Workspace ID** - Your Siteon workspace ID
|
|
38
|
-
2. **Email & Password** - Your Siteon credentials (ADMIN access required)
|
|
39
|
-
3. **Output Directory** - Where to place generated files (default: `src` if exists, otherwise root)
|
|
40
|
-
4. **Project Type**:
|
|
41
|
-
- `Static` - Vanilla HTML/CSS/JS (ES modules)
|
|
42
|
-
- `Framework` - React, Next.js, Vue, Vite, etc.
|
|
43
|
-
5. **Framework** (if framework selected) - Next.js, Vite, React, Vue, or Other
|
|
44
|
-
6. **Language** (if framework) - TypeScript or JavaScript
|
|
45
|
-
7. **HTTP Client** (if framework) - Fetch (native) or Axios
|
|
46
|
-
8. **Config Storage** (if framework) - Environment variables (.env) or config file
|
|
47
|
-
9. **React Cache** (if React-based) - Use React's `cache` function for caching (React 18+)
|
|
48
|
-
10. **Form Selection** - All forms or select specific ones
|
|
32
|
+
### Global Installation
|
|
49
33
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
```
|
|
53
|
-
your-project/
|
|
54
|
-
├── siteon.config.json # CLI configuration
|
|
55
|
-
├── .env # (optional) Environment variables
|
|
56
|
-
└── src/
|
|
57
|
-
└── siteon/
|
|
58
|
-
├── index.ts # Main entry point
|
|
59
|
-
├── config.ts # Configuration (workspace ID, base URL)
|
|
60
|
-
├── types.ts # Type definitions
|
|
61
|
-
├── http-client.ts # HTTP client (axios or fetch)
|
|
62
|
-
├── get-metadata.ts # Base fetch function
|
|
63
|
-
├── get-media.ts # Media helper functions
|
|
64
|
-
└── forms/
|
|
65
|
-
├── index.ts # Re-exports all forms
|
|
66
|
-
├── portfolio.ts # Generated form file
|
|
67
|
-
└── blog-post.ts # Generated form file
|
|
68
|
-
```
|
|
34
|
+
Install globally for repeated use:
|
|
69
35
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
For each form, the CLI generates strongly typed fetchers:
|
|
73
|
-
|
|
74
|
-
```typescript
|
|
75
|
-
// TypeScript example for a "Portfolio" form
|
|
76
|
-
import { getMetaData } from "../get-metadata";
|
|
77
|
-
import type { ResponseType, ResponseDataType, QueryParams } from "../types";
|
|
78
|
-
import { cache } from "react"; // if using React cache
|
|
79
|
-
|
|
80
|
-
export type PortfolioDataType = {
|
|
81
|
-
slug: string;
|
|
82
|
-
title: string;
|
|
83
|
-
featured_image: string[];
|
|
84
|
-
category: "Web Design" | "Graphic Design" | "Video Production";
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
export type PortfolioResolvedDataType = {
|
|
88
|
-
slug: string;
|
|
89
|
-
title: string;
|
|
90
|
-
featured_image: string[];
|
|
91
|
-
category: ResolvedRelation; // When resolveRelations is true
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
export type PortfolioQueryOptions = Omit<QueryParams, "resolveRelations"> & {
|
|
95
|
-
resolveRelations?: boolean;
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
// Fetch all items with full query options
|
|
99
|
-
export async function getAllPortfolio(
|
|
100
|
-
options?: PortfolioQueryOptions & { resolveRelations?: false },
|
|
101
|
-
): Promise<ResponseType<PortfolioDataType>>;
|
|
102
|
-
export async function getAllPortfolio(
|
|
103
|
-
options: PortfolioQueryOptions & { resolveRelations: true },
|
|
104
|
-
): Promise<ResponseType<PortfolioResolvedDataType>>;
|
|
105
|
-
export async function getAllPortfolio(options: PortfolioQueryOptions = {}) {
|
|
106
|
-
// Implementation
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// Fetch by slug (with optional React cache)
|
|
110
|
-
export const getPortfolioBySlug = cache(
|
|
111
|
-
async (slug: string, options: { resolveRelations?: boolean } = {}) => {
|
|
112
|
-
// Implementation
|
|
113
|
-
},
|
|
114
|
-
);
|
|
36
|
+
```bash
|
|
37
|
+
npm install -g siteon
|
|
115
38
|
```
|
|
116
39
|
|
|
117
|
-
|
|
40
|
+
Then run:
|
|
118
41
|
|
|
119
|
-
|
|
42
|
+
```bash
|
|
43
|
+
siteon
|
|
44
|
+
```
|
|
120
45
|
|
|
121
|
-
|
|
122
|
-
import { getAllPortfolio, getPortfolioBySlug } from "@/siteon";
|
|
46
|
+
## Usage
|
|
123
47
|
|
|
124
|
-
|
|
125
|
-
|
|
48
|
+
1. Navigate to your project directory
|
|
49
|
+
2. Run the command:
|
|
50
|
+
```bash
|
|
51
|
+
npx siteon
|
|
52
|
+
```
|
|
53
|
+
3. SiteOn will:
|
|
54
|
+
- Analyze your workspace configuration
|
|
55
|
+
- Detect your content structure
|
|
56
|
+
- Generate appropriate code files
|
|
57
|
+
- Set up form submission endpoints
|
|
126
58
|
|
|
127
|
-
|
|
128
|
-
const { data } = await getAllPortfolio({
|
|
129
|
-
filters: {
|
|
130
|
-
"data.category": { equals: "Web Design" },
|
|
131
|
-
},
|
|
132
|
-
orderBy: [{ field: "order", direction: "asc" }],
|
|
133
|
-
page: 1,
|
|
134
|
-
pageSize: 10,
|
|
135
|
-
});
|
|
59
|
+
## Features
|
|
136
60
|
|
|
137
|
-
|
|
138
|
-
const { data } = await getAllPortfolio({ resolveRelations: true });
|
|
61
|
+
✨ **Automatic Code Generation** - Generates production-ready code based on your workspace
|
|
139
62
|
|
|
140
|
-
|
|
141
|
-
const portfolio = await getPortfolioBySlug("my-project");
|
|
63
|
+
🔍 **Workspace Detection** - Intelligently analyzes your project structure
|
|
142
64
|
|
|
143
|
-
|
|
144
|
-
const portfolio = await getPortfolioBySlug("my-project", {
|
|
145
|
-
resolveRelations: true,
|
|
146
|
-
});
|
|
147
|
-
```
|
|
65
|
+
📝 **Form Handlers** - Creates public form submission code with validation
|
|
148
66
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
To filter by a relation field (e.g., get all blogs in a specific category):
|
|
152
|
-
|
|
153
|
-
```typescript
|
|
154
|
-
import { getAllBlog } from "@/siteon";
|
|
155
|
-
|
|
156
|
-
// Filter by category relation ID
|
|
157
|
-
const { data } = await getAllBlog({
|
|
158
|
-
filters: {
|
|
159
|
-
"data.category": { equals: "categoryId123" },
|
|
160
|
-
},
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
// Multiple conditions
|
|
164
|
-
const { data } = await getAllBlog({
|
|
165
|
-
filters: {
|
|
166
|
-
AND: {
|
|
167
|
-
"data.category": { equals: "categoryId123" },
|
|
168
|
-
"data.published": { equals: true },
|
|
169
|
-
},
|
|
170
|
-
},
|
|
171
|
-
});
|
|
172
|
-
```
|
|
67
|
+
🚀 **Zero Configuration** - Works out of the box with sensible defaults
|
|
173
68
|
|
|
174
|
-
|
|
69
|
+
⚡ **Fast & Lightweight** - Minimal dependencies, maximum efficiency
|
|
175
70
|
|
|
176
|
-
|
|
177
|
-
import { getAllPortfolio, getMediaByIds } from "@/siteon";
|
|
71
|
+
## Generated Code
|
|
178
72
|
|
|
179
|
-
|
|
73
|
+
SiteOn generates:
|
|
180
74
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
}
|
|
186
|
-
```
|
|
75
|
+
- Content fetching functions and API clients
|
|
76
|
+
- Form submission handlers with validation
|
|
77
|
+
- Type definitions (if applicable)
|
|
78
|
+
- Configuration files for your workspace
|
|
187
79
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
Available filter operators:
|
|
191
|
-
|
|
192
|
-
- `equals`, `not`
|
|
193
|
-
- `gt`, `gte`, `lt`, `lte`
|
|
194
|
-
- `contains`, `startsWith`, `endsWith`
|
|
195
|
-
- `in`, `notIn`
|
|
196
|
-
- `has`, `hasEvery`, `hasSome`
|
|
197
|
-
- `isNull`
|
|
198
|
-
|
|
199
|
-
```typescript
|
|
200
|
-
// Complex filtering
|
|
201
|
-
const { data } = await getAllPortfolio({
|
|
202
|
-
filters: {
|
|
203
|
-
AND: {
|
|
204
|
-
"data.category": { equals: "Web Design" },
|
|
205
|
-
"data.title": { contains: "Modern" },
|
|
206
|
-
},
|
|
207
|
-
OR: [{ "data.featured": { equals: true } }, { "data.order": { lt: 5 } }],
|
|
208
|
-
},
|
|
209
|
-
});
|
|
210
|
-
```
|
|
80
|
+
## Examples
|
|
211
81
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
For static sites, use ES modules:
|
|
215
|
-
|
|
216
|
-
```html
|
|
217
|
-
<!DOCTYPE html>
|
|
218
|
-
<html>
|
|
219
|
-
<head>
|
|
220
|
-
<title>My Site</title>
|
|
221
|
-
</head>
|
|
222
|
-
<body>
|
|
223
|
-
<div id="app"></div>
|
|
224
|
-
|
|
225
|
-
<script type="module">
|
|
226
|
-
import { getAllPortfolio } from "./siteon/index.js";
|
|
227
|
-
|
|
228
|
-
const { data } = await getAllPortfolio();
|
|
229
|
-
|
|
230
|
-
const app = document.getElementById("app");
|
|
231
|
-
app.innerHTML = data
|
|
232
|
-
.map(
|
|
233
|
-
(item) => `
|
|
234
|
-
<div class="portfolio-item">
|
|
235
|
-
<h2>${item.data.title}</h2>
|
|
236
|
-
</div>
|
|
237
|
-
`,
|
|
238
|
-
)
|
|
239
|
-
.join("");
|
|
240
|
-
</script>
|
|
241
|
-
</body>
|
|
242
|
-
</html>
|
|
243
|
-
```
|
|
82
|
+
### Basic Usage
|
|
244
83
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
```json
|
|
250
|
-
{
|
|
251
|
-
"workspaceId": "your-workspace-id",
|
|
252
|
-
"baseUrl": "https://api.compitcom.in",
|
|
253
|
-
"outputDir": "src",
|
|
254
|
-
"projectType": "framework",
|
|
255
|
-
"language": "typescript",
|
|
256
|
-
"httpClient": "fetch",
|
|
257
|
-
"framework": "next",
|
|
258
|
-
"envVarLocation": "env",
|
|
259
|
-
"forms": ["portfolio", "blog-post"],
|
|
260
|
-
"createdAt": "2024-01-01T00:00:00.000Z",
|
|
261
|
-
"updatedAt": "2024-01-01T00:00:00.000Z"
|
|
262
|
-
}
|
|
84
|
+
```bash
|
|
85
|
+
# In your project directory
|
|
86
|
+
npx siteon
|
|
263
87
|
```
|
|
264
88
|
|
|
265
|
-
##
|
|
266
|
-
|
|
267
|
-
If you chose to use environment variables, they are stored in `.env`:
|
|
89
|
+
## How It Works
|
|
268
90
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
NEXT_PUBLIC_SITEON_WORKSPACE_ID=your-workspace-id
|
|
91
|
+
1. **Workspace Analysis**: SiteOn scans your workspace for content types, schemas, and configurations
|
|
92
|
+
2. **Code Generation**: Based on the analysis, it generates optimized code tailored to your needs
|
|
93
|
+
3. **File Output**: Generated code is saved to your project with clear organization
|
|
273
94
|
|
|
274
|
-
|
|
275
|
-
VITE_SITEON_BASE_URL=https://api.compitcom.in
|
|
276
|
-
VITE_SITEON_WORKSPACE_ID=your-workspace-id
|
|
277
|
-
|
|
278
|
-
# React (CRA)
|
|
279
|
-
REACT_APP_SITEON_BASE_URL=https://api.compitcom.in
|
|
280
|
-
REACT_APP_SITEON_WORKSPACE_ID=your-workspace-id
|
|
281
|
-
```
|
|
95
|
+
## License
|
|
282
96
|
|
|
283
|
-
|
|
97
|
+
MIT
|
|
284
98
|
|
|
285
|
-
|
|
286
|
-
| ------------------------------------ | ------------------------------------------- |
|
|
287
|
-
| text, email, textarea, url, richtext | `string` |
|
|
288
|
-
| date, time, datetime | `string` |
|
|
289
|
-
| int, float | `number` |
|
|
290
|
-
| select, radio | Union of options |
|
|
291
|
-
| checkbox | Array of options |
|
|
292
|
-
| media, image, video | `string[]` |
|
|
293
|
-
| relation (single) | `string \| null` (ID) or `ResolvedRelation` |
|
|
294
|
-
| relation (array) | `string[]` (IDs) or `ResolvedRelation[]` |
|
|
295
|
-
| repeator | `{ value: T }[]` |
|
|
99
|
+
## Support
|
|
296
100
|
|
|
297
|
-
|
|
101
|
+
If you encounter any issues or have questions:
|
|
298
102
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
bun install
|
|
103
|
+
- Open an issue on [GitHub](https://github.com/yourusername/siteon)
|
|
104
|
+
- Check the [documentation](https://github.com/yourusername/siteon#readme)
|
|
302
105
|
|
|
303
|
-
|
|
304
|
-
bun run build
|
|
106
|
+
## Author
|
|
305
107
|
|
|
306
|
-
|
|
307
|
-
bun run dev
|
|
308
|
-
```
|
|
108
|
+
Created with ❤️ by the SiteOn team
|
|
309
109
|
|
|
310
|
-
|
|
110
|
+
---
|
|
311
111
|
|
|
312
|
-
|
|
112
|
+
**Happy Coding!** 🎉
|