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.
Files changed (36) hide show
  1. package/Readme.md +66 -266
  2. package/{dist/index.js → index.js} +472 -245
  3. package/package.json +21 -39
  4. package/bun.lock +0 -80
  5. package/dist/Readme.md +0 -112
  6. package/dist/package.json +0 -21
  7. package/form-fields-example.md +0 -310
  8. package/instructions.md +0 -31
  9. package/postbuild.js +0 -17
  10. package/src/commands/init.ts +0 -462
  11. package/src/generators/index.ts +0 -238
  12. package/src/generators/templates/config-js.ts +0 -35
  13. package/src/generators/templates/config.ts +0 -59
  14. package/src/generators/templates/form-file.ts +0 -360
  15. package/src/generators/templates/get-media-js.ts +0 -97
  16. package/src/generators/templates/get-media-ts.ts +0 -61
  17. package/src/generators/templates/get-metadata-js.ts +0 -180
  18. package/src/generators/templates/get-metadata-ts.ts +0 -92
  19. package/src/generators/templates/http-client-js.ts +0 -65
  20. package/src/generators/templates/http-client-ts.ts +0 -65
  21. package/src/generators/templates/index-files.ts +0 -159
  22. package/src/generators/templates/public-form-file.ts +0 -870
  23. package/src/generators/templates/siteon-core-js.ts +0 -341
  24. package/src/generators/templates/siteon-core-static.ts +0 -156
  25. package/src/generators/templates/siteon-core-ts.ts +0 -240
  26. package/src/generators/templates/static.ts +0 -206
  27. package/src/generators/templates/types-ts.ts +0 -125
  28. package/src/generators/type-mapper.ts +0 -134
  29. package/src/index.ts +0 -21
  30. package/src/types.ts +0 -173
  31. package/src/utils/api.ts +0 -157
  32. package/src/utils/dependencies.ts +0 -88
  33. package/src/utils/files.ts +0 -139
  34. package/src/utils/prompts.ts +0 -220
  35. package/src/utils/version.ts +0 -5
  36. package/tsconfig.json +0 -17
package/Readme.md CHANGED
@@ -1,312 +1,112 @@
1
- # Siteon Registry CLI
1
+ # SiteOn
2
2
 
3
- A CLI tool to generate type-safe API clients for Siteon workspaces. Similar to shadcn/ui, this tool generates code directly into your project that you own and can customize.
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
- Since this is a private GitHub repository, you can run the CLI directly using:
16
+ ### Quick Start with npx (Recommended)
8
17
 
9
- 1. Using npx
18
+ Run SiteOn without installing:
10
19
 
11
20
  ```bash
12
- npx https://github.com/compitcomds/siteon-registry init
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 https://github.com/compitcomds/siteon-registry init
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 init
29
+ bunx siteon
33
30
  ```
34
31
 
35
- You'll be prompted for:
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
- ## Generated Structure
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
- ## Generated Code Example
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
- ## Usage in Your App
40
+ Then run:
118
41
 
119
- ### Basic Usage
42
+ ```bash
43
+ siteon
44
+ ```
120
45
 
121
- ```typescript
122
- import { getAllPortfolio, getPortfolioBySlug } from "@/siteon";
46
+ ## Usage
123
47
 
124
- // Fetch all portfolio items
125
- const { data, pagination } = await getAllPortfolio();
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
- // Fetch with filters and ordering
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
- // Fetch with resolved relations
138
- const { data } = await getAllPortfolio({ resolveRelations: true });
61
+ **Automatic Code Generation** - Generates production-ready code based on your workspace
139
62
 
140
- // Fetch single item by slug
141
- const portfolio = await getPortfolioBySlug("my-project");
63
+ 🔍 **Workspace Detection** - Intelligently analyzes your project structure
142
64
 
143
- // Fetch single item by slug with resolved relations
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
- ### Filtering by Relation
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
- ### With Media Resolution
69
+ **Fast & Lightweight** - Minimal dependencies, maximum efficiency
175
70
 
176
- ```typescript
177
- import { getAllPortfolio, getMediaByIds } from "@/siteon";
71
+ ## Generated Code
178
72
 
179
- const { data } = await getAllPortfolio();
73
+ SiteOn generates:
180
74
 
181
- // Resolve media IDs to URLs
182
- for (const item of data) {
183
- const images = await getMediaByIds(item.data.featured_image);
184
- console.log(images[0]?.url);
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
- ### Filter Operators
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
- ## Static Sites (Vanilla JS)
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
- ## Configuration
246
-
247
- The `siteon.config.json` file stores your configuration:
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
- ## Environment Variables
266
-
267
- If you chose to use environment variables, they are stored in `.env`:
89
+ ## How It Works
268
90
 
269
- ```env
270
- # Next.js
271
- NEXT_PUBLIC_SITEON_BASE_URL=https://api.compitcom.in
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
- # Vite/Vue
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
- ## Field Type Mapping
97
+ MIT
284
98
 
285
- | Form Field Type | TypeScript Type |
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
- ## Development
101
+ If you encounter any issues or have questions:
298
102
 
299
- ```bash
300
- # Install dependencies
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
- # Build
304
- bun run build
106
+ ## Author
305
107
 
306
- # Watch mode
307
- bun run dev
308
- ```
108
+ Created with ❤️ by the SiteOn team
309
109
 
310
- ## License
110
+ ---
311
111
 
312
- Private - Compitcom
112
+ **Happy Coding!** 🎉