decoupled-cli 2.3.2 → 2.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/dist/commands/auth-interactive.d.ts +3 -0
- package/dist/commands/auth-interactive.d.ts.map +1 -0
- package/dist/commands/auth-interactive.js +236 -0
- package/dist/commands/auth-interactive.js.map +1 -0
- package/dist/commands/auth.d.ts.map +1 -1
- package/dist/commands/auth.js +3 -26
- package/dist/commands/auth.js.map +1 -1
- package/dist/commands/mcp.d.ts +3 -0
- package/dist/commands/mcp.d.ts.map +1 -0
- package/dist/commands/mcp.js +384 -0
- package/dist/commands/mcp.js.map +1 -0
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +18 -6
- package/examples/.cursorrules +0 -189
- package/examples/CLAUDE.md +0 -1184
- package/examples/GEMINI.md +0 -1160
package/examples/.cursorrules
DELETED
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
You are the Cursor AI working in a Next.js + Drupal monorepo. Follow these rules to deliver complete, working features end-to-end.
|
|
2
|
-
|
|
3
|
-
# Project Overview
|
|
4
|
-
- Architecture: Headless Drupal backend with Next.js frontend
|
|
5
|
-
- Backend: Drupal 11 with GraphQL Compose and DC Import API
|
|
6
|
-
- Frontend: Next.js 15 with TypeScript, Tailwind CSS, Apollo GraphQL
|
|
7
|
-
- Environment: DDEV local development
|
|
8
|
-
|
|
9
|
-
# Environment Configuration
|
|
10
|
-
- Environment variables in `.env.local`:
|
|
11
|
-
- `NEXT_PUBLIC_DRUPAL_BASE_URL` – Drupal base URL
|
|
12
|
-
- `DRUPAL_CLIENT_ID` / `DRUPAL_CLIENT_SECRET` – OAuth credentials
|
|
13
|
-
- `DRUPAL_REVALIDATE_SECRET` – On-demand revalidation secret
|
|
14
|
-
- `NODE_TLS_REJECT_UNAUTHORIZED=0` – Allow self-signed certs (dev)
|
|
15
|
-
|
|
16
|
-
# DC CLI Usage
|
|
17
|
-
**CRITICAL**: Use DC CLI instead of direct API calls.
|
|
18
|
-
|
|
19
|
-
First-time setup:
|
|
20
|
-
```bash
|
|
21
|
-
decoupled-cli auth login # Authenticate with platform
|
|
22
|
-
decoupled-cli spaces use <id> # Set default space (optional)
|
|
23
|
-
decoupled-cli spaces current # Verify setup
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
# End-to-End Workflow
|
|
27
|
-
When asked to implement a new content type (e.g., “create a product page”), complete all steps:
|
|
28
|
-
|
|
29
|
-
1) Verify CLI authentication
|
|
30
|
-
```bash
|
|
31
|
-
decoupled-cli auth status # Check if authenticated
|
|
32
|
-
decoupled-cli spaces list # List available spaces
|
|
33
|
-
decoupled-cli spaces use <id> # Set default space if needed
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
2) Plan content type
|
|
37
|
-
- Define name + machine name
|
|
38
|
-
- List fields and types
|
|
39
|
-
- Determine components, routes, display needs
|
|
40
|
-
|
|
41
|
-
3) Create DC Import JSON
|
|
42
|
-
- Get example format: `decoupled-cli spaces content-import --example`
|
|
43
|
-
- Include model definition and sample content
|
|
44
|
-
- Important: In `values`, use field ID directly, never with `field_` prefix
|
|
45
|
-
- For image fields: Use full URLs with Drupal domain from `.env.local`, not relative paths
|
|
46
|
-
|
|
47
|
-
Template:
|
|
48
|
-
```json
|
|
49
|
-
{
|
|
50
|
-
"model": [
|
|
51
|
-
{
|
|
52
|
-
"bundle": "content_type_name",
|
|
53
|
-
"description": "Description",
|
|
54
|
-
"label": "Content Type Label",
|
|
55
|
-
"body": true,
|
|
56
|
-
"fields": [
|
|
57
|
-
{ "id": "field_name", "label": "Field Label", "type": "text|string|image|datetime|bool|text[]" }
|
|
58
|
-
]
|
|
59
|
-
}
|
|
60
|
-
],
|
|
61
|
-
"content": [
|
|
62
|
-
{
|
|
63
|
-
"id": "item1",
|
|
64
|
-
"type": "node.content_type_name",
|
|
65
|
-
"path": "/content-type/item-slug",
|
|
66
|
-
"values": {
|
|
67
|
-
"title": "Item Title",
|
|
68
|
-
"body": "<p>Body content</p>",
|
|
69
|
-
"field_name": "field_value",
|
|
70
|
-
"image_field": {
|
|
71
|
-
"uri": "${DRUPAL_BASE_URL}/modules/custom/dc_import/resources/placeholder.png",
|
|
72
|
-
"alt": "Image description",
|
|
73
|
-
"title": "Image title"
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
]
|
|
78
|
-
}
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
4) Import via DC CLI
|
|
82
|
-
```bash
|
|
83
|
-
# Import content type and sample content
|
|
84
|
-
decoupled-cli spaces content-import --file content-type-import.json --preview # Preview first
|
|
85
|
-
decoupled-cli spaces content-import --file content-type-import.json # Apply changes
|
|
86
|
-
|
|
87
|
-
# Generate example if needed
|
|
88
|
-
decoupled-cli spaces content-import --example > content-type-import.json
|
|
89
|
-
```
|
|
90
|
-
- **CRITICAL**: Immediately run schema generation:
|
|
91
|
-
```bash
|
|
92
|
-
npm run generate-schema
|
|
93
|
-
```
|
|
94
|
-
- Verify: machine names, created nodes, and GraphQL schema updates
|
|
95
|
-
|
|
96
|
-
4) Implement frontend
|
|
97
|
-
- Files:
|
|
98
|
-
```
|
|
99
|
-
app/
|
|
100
|
-
components/
|
|
101
|
-
[ContentType]Card.tsx
|
|
102
|
-
[ContentType]Renderer.tsx
|
|
103
|
-
DynamicIcon.tsx (optional)
|
|
104
|
-
[content-type]/page.tsx
|
|
105
|
-
[...slug]/page.tsx (update)
|
|
106
|
-
lib/
|
|
107
|
-
queries.ts (update)
|
|
108
|
-
types.ts (update)
|
|
109
|
-
```
|
|
110
|
-
- GraphQL: add list query and update `GET_NODE_BY_PATH` cases
|
|
111
|
-
- Types: add `Drupal[ContentType]` and `[...]Data` interfaces
|
|
112
|
-
- Components: card + renderer; use `dangerouslySetInnerHTML` for processed HTML
|
|
113
|
-
- Routing: handle in dynamic route switch by `__typename`
|
|
114
|
-
- Navigation: add link in `app/components/Header.tsx`; update `navigationItems` and active detection with `pathname.startsWith('/route/')`
|
|
115
|
-
- DC GraphQL fields return simple types (`string`, `string[]`, `bool`, etc.), not `{ processed }` objects — probe schema with a quick query before typing components
|
|
116
|
-
|
|
117
|
-
5) Build and test
|
|
118
|
-
- `npm run build` → fix TypeScript/build errors
|
|
119
|
-
- `npm run dev` → verify listing and detail views
|
|
120
|
-
- Check URLs: `/[content-type]`, `/[content-type]/[slug]`
|
|
121
|
-
|
|
122
|
-
Checklist:
|
|
123
|
-
- [ ] DC import succeeds
|
|
124
|
-
- [ ] **Schema generation runs (`npm run generate-schema`)**
|
|
125
|
-
- [ ] GraphQL schema exposes fields
|
|
126
|
-
- [ ] Types compile
|
|
127
|
-
- [ ] Build passes
|
|
128
|
-
- [ ] Listing and detail pages render
|
|
129
|
-
- [ ] Navigation works, responsive design verified
|
|
130
|
-
|
|
131
|
-
# Component Architecture
|
|
132
|
-
- Per type, create `[ContentType]Card.tsx` (listing) and `[ContentType]Renderer.tsx` (detail)
|
|
133
|
-
- Cards: preview data + CTA; Renderers: full display, responsive layout
|
|
134
|
-
- Place components in `app/components/`; listing in `app/[content-type]/page.tsx`; update `app/[...slug]/page.tsx` to route by `__typename`
|
|
135
|
-
|
|
136
|
-
# Field Types Reference
|
|
137
|
-
- `text` – Rich HTML field
|
|
138
|
-
- `string` – Short text (≤255 chars)
|
|
139
|
-
- `image` – Single image upload
|
|
140
|
-
- `image[]` – Multiple image uploads
|
|
141
|
-
- `datetime` – Date/time
|
|
142
|
-
- `bool` – Boolean
|
|
143
|
-
- `text[]` – Rich HTML list
|
|
144
|
-
- `string[]` – Plain text list (recommended for features/specs)
|
|
145
|
-
|
|
146
|
-
# Common Patterns
|
|
147
|
-
- Product: `price (string)`, `product_images (image[])`, `in_stock (bool)`, `features (string[])`
|
|
148
|
-
- Image URI: `{"uri": "${DRUPAL_BASE_URL}/modules/custom/dc_import/resources/placeholder.png", "alt": "Product image", "title": "Product"}`
|
|
149
|
-
- Event: `event_date (datetime)`, `location (string)`, `speakers (string[])`
|
|
150
|
-
- Team: `position (string)`, `profile_image (image)`, `bio (text)`
|
|
151
|
-
- Image URI: `{"uri": "${DRUPAL_BASE_URL}/modules/custom/dc_import/resources/placeholder.png", "alt": "Team member photo", "title": "Profile"}`
|
|
152
|
-
- Case Study: `project_url (string)`, `technologies (string[])`, `project_images (image[])`
|
|
153
|
-
- Image URI: `{"uri": "${DRUPAL_BASE_URL}/modules/custom/dc_import/resources/placeholder.png", "alt": "Project screenshot", "title": "Interface"}`
|
|
154
|
-
|
|
155
|
-
# Troubleshooting
|
|
156
|
-
- DC import fails: check OAuth, JSON structure, no `field_` in values
|
|
157
|
-
- **Schema not updated**: ALWAYS run `npm run generate-schema` after DC imports
|
|
158
|
-
- GraphQL errors: confirm content type exists, clear GraphQL cache, regenerate schema
|
|
159
|
-
- Build errors: verify types, imports, query syntax
|
|
160
|
-
- Content not showing: confirm field names match GraphQL schema; for HTML use `dangerouslySetInnerHTML={{ __html: field.processed }}`
|
|
161
|
-
- **Field name mismatches**: DC field IDs may transform (e.g., `in_stock` → `inStock` in GraphQL)
|
|
162
|
-
|
|
163
|
-
Debug commands:
|
|
164
|
-
```bash
|
|
165
|
-
decoupled-cli auth status # Check authentication
|
|
166
|
-
decoupled-cli spaces list # List available spaces
|
|
167
|
-
decoupled-cli spaces current # Show default space
|
|
168
|
-
decoupled-cli health check # Platform status
|
|
169
|
-
decoupled-cli spaces content-import --file test.json --preview # Preview import
|
|
170
|
-
# MOST IMPORTANT: Generate fresh schema after any import
|
|
171
|
-
npm run generate-schema
|
|
172
|
-
# Check schema includes your content type
|
|
173
|
-
grep -i [content_type] schema/schema.graphql
|
|
174
|
-
```
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
# Best Practices
|
|
178
|
-
1. **ALWAYS run `npm run generate-schema` immediately after DC imports**
|
|
179
|
-
2. Create sample content for immediate testing
|
|
180
|
-
3. Prefer `string[]` for simple lists; use `text[]` only when necessary
|
|
181
|
-
4. Verify GraphQL field names against the actual schema (may differ from DC field IDs)
|
|
182
|
-
5. Handle empty/missing data gracefully
|
|
183
|
-
6. Keep TypeScript types accurate and complete
|
|
184
|
-
7. Use semantic HTML and ensure responsive design
|
|
185
|
-
8. **Navigation integration**: Update `navigationItems` array and use `.startsWith()` for active detection
|
|
186
|
-
9. **Component architecture**: Create Card + Renderer components per content type
|
|
187
|
-
|
|
188
|
-
# Success Criteria
|
|
189
|
-
- Builds without errors; routes render correctly; navigation works; responsive; proper fallbacks; follows design patterns; integrates with existing auth and routing.
|