@dotcms/create-app 1.2.5 → 1.2.6-next.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 CHANGED
@@ -1,238 +1,174 @@
1
- # 🚀 create-dotcms-app
1
+ # @dotcms/create-app
2
2
 
3
- > 🚧 **Beta Notice:**
4
- > This CLI is currently in **beta**. Features and APIs may change as we continue improving the tool.
3
+ CLI to scaffold a dotCMS frontend project or start a local dotCMS Docker stack.
5
4
 
6
- With a single command, you can bootstrap a fully functional frontend (Next.js, Angular, Astro, etc.) connected to dotCMS APIs — including the following:
5
+ ## Status
7
6
 
8
- - Spinning up dotCMS using Docker with intelligent pre-flight checks
9
- - Universal Visual Editor pre-configured
10
- - Generating site ID and authentication token (just copy paste them in frontend .env and enjoy)
11
- - Comprehensive validation and helpful error messages
7
+ Beta. Behavior and flags may change.
12
8
 
13
- ---
9
+ ## Requirements
14
10
 
15
- ## What is `create-dotcms-app`?
11
+ - Node.js + npm
12
+ - Git
13
+ - Docker (for `--local` or `--starter`)
14
+ - Internet access (downloads templates and docker-compose)
16
15
 
17
- `create-dotcms-app` is a command-line tool that helps developers quickly spin up headless frontends powered by **dotCMS**.
18
-
19
- It automates the tedious work of:
20
-
21
- - Setting up a framework with best practices
22
- - Connecting to dotCMS REST & GraphQL APIs
23
- - Providing content-fetching helpers
24
- - Adding example components & pages
25
- - Creating environment variable templates
26
- - Optionally setting up local dotCMS instance using Docker
27
- - Validating your environment (Docker, ports, URLs)
28
-
29
- This tool lets you focus on **building**, not configuring.
30
-
31
- ---
32
-
33
- ## 🎯 Why this project exists
34
-
35
- dotCMS is a hybrid headless CMS with powerful APIs — but initializing a frontend manually takes time.
36
-
37
- This CLI solves that by offering:
38
-
39
- - **Frictionless onboarding**
40
- - **Standardized project setup**
41
- - **Fast prototyping & demos**
42
- - **DevRel-friendly scaffolding for workshops & tutorials**
43
- - **Production-ready integration patterns**
44
-
45
- ---
46
-
47
- ## 🛠️ Installation
48
-
49
- Run using npx (recommended):
16
+ ## Quick Start
50
17
 
51
18
  ```sh
52
- npx @dotcms/create-app <project-name>
19
+ npx @dotcms/create-app my-app
53
20
  ```
54
21
 
55
- Or install cli globally
22
+ Global install:
56
23
 
57
24
  ```sh
58
25
  npm install -g @dotcms/create-app
26
+ create-dotcms-app my-app
59
27
  ```
60
28
 
61
- ## Usage
29
+ ## CLI
62
30
 
63
31
  ```sh
64
- npx @dotcms/create-app <project-name>
32
+ create-dotcms-app [projectName] [options]
65
33
  ```
66
34
 
67
- This will:
35
+ | Option | Description |
36
+ |---|---|
37
+ | `-f, --framework <framework>` | Framework: `nextjs`, `astro`, `angular`, `angular-ssr` |
38
+ | `-d, --directory <path>` | Parent or target directory |
39
+ | `--local` | Use local dotCMS with Docker |
40
+ | `--starter <url>` | Custom starter ZIP URL (local-only; sets `CUSTOM_STARTER_URL`) |
41
+ | `--url <url>` | dotCMS URL for cloud mode |
42
+ | `-u, --username <username>` | dotCMS username for cloud mode |
43
+ | `-p, --password <password>` | dotCMS password for cloud mode |
44
+ | `-V, --version` | Show CLI version |
68
45
 
69
- - Ask for the target directory
70
- - Ask which frontend framework you want (Next.js, Angular, Astro, etc.)
71
- - Ask if you're using dotCMS Cloud or Local Docker dotCMS
72
- - **For local Docker setup:**
73
- - Check if Docker is installed and running
74
- - Verify required ports are available (8082, 8443, 9200, 9600)
75
- - Provide specific error messages and solutions if issues are found
76
- - Automatically scaffold your project
77
- - Configure UVE (Edit Mode Anywhere)
78
- - Start dotCMS (if using Docker)
79
- - Print required environment variables for your frontend
46
+ Framework aliases:
80
47
 
81
- ## Env variables
48
+ - `next`, `next.js` -> `nextjs`
49
+ - `ng` -> `angular`
50
+ - `angular-server` -> `angular-ssr`
82
51
 
83
- You will get the following env variables generated by cli **just copy and replace them in the frontend of the env and enjoy dotCMS in headless mode**.
52
+ ## Behavior by Mode
84
53
 
85
- ```sh
86
- Host (site) : http://localhost:8082
87
- Site ID : 59bb8831-6706-4589-9ca0-ff74016e02b2
88
- API Token : YOUR_API_TOKEN
89
- ```
90
-
91
- ## CLI Syntax
54
+ ### 1) Cloud mode (existing dotCMS instance)
92
55
 
93
- ```sh
94
- create-dotcms-app <project-name> [options]
95
- ```
56
+ Used when you do not pass `--local` or `--starter` and choose cloud in prompts.
96
57
 
97
- | Option | Description |
98
- |--------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------|
99
- | `-f, --framework <name>` | Skip prompts and directly choose a framework. Supported: `nextjs`, `angular`, `angular-ssr`, `astro`. Case-insensitive. Aliases: `next`, `ng`, `next.js`, `angular-server` |
100
- | `-d, --directory` | Project Directory |
101
- | `--local` | Use local dotCMS instance using docker |
102
- | `-u, --username` | dotCMS instance username (skip in case of local) |
103
- | `-p, --password` | dotCMS instance password (skip in case of local) |
104
- | `--url` | dotCMS instance URL (skip in case of local). Must include protocol (http:// or https://) |
105
- | `-V, --version` | Show CLI version |
58
+ Flow:
106
59
 
107
- ### Framework Aliases
60
+ 1. Validates URL, project name, and flags.
61
+ 2. Checks dotCMS health at `/api/v1/appconfiguration`.
62
+ 3. Authenticates (up to 3 attempts).
63
+ 4. Reads `defaultSite` from `/api/v1/site/defaultSite`.
64
+ 5. Configures UVE via `/api/v1/apps/dotema-config-v2/{siteId}`.
65
+ 6. Scaffolds selected frontend and runs `npm install`.
66
+ 7. Prints framework-specific env setup instructions.
108
67
 
109
- For convenience, the CLI accepts common framework name variations (case-insensitive):
68
+ ### 2) Local mode (`--local`)
110
69
 
111
- - `next`, `next.js`, `Next.js` → `nextjs`
112
- - `ng`, `Angular` → `angular`
113
- - `angular-server` → `angular-ssr`
114
- - `angular-server` → `angular-ssr`
70
+ Flow:
115
71
 
116
- ### URL Format
72
+ 1. Validates Docker availability.
73
+ 2. Validates required ports: `8082`, `8443`, `9200`, `9600`.
74
+ 3. Downloads docker-compose from dotCMS main repo.
75
+ 4. Runs `docker compose up -d`.
76
+ 5. Waits for local health check.
77
+ 6. Authenticates with default local credentials (`admin@dotcms.com` / `admin`).
78
+ 7. Reads `defaultSite`, configures UVE, scaffolds frontend, runs `npm install`.
79
+ 8. Prints framework-specific env setup instructions.
117
80
 
118
- When using `--url`, make sure to include the full URL with protocol:
81
+ ### 3) Starter-only local mode (`--starter <url>`)
119
82
 
120
- **Valid:** `https://demo.dotcms.com`, `http://localhost:8082`
121
- ❌ **Invalid:** `demo.dotcms.com`, `localhost:8082` (missing protocol)
83
+ `--starter` implies local mode.
122
84
 
123
- ---
85
+ Flow:
124
86
 
125
- ## 🛡️ Built-in Validation & Error Handling
87
+ 1. Same Docker and port checks as local mode.
88
+ 2. Downloads docker-compose.
89
+ 3. Rewrites `CUSTOM_STARTER_URL` in `docker-compose.yml`.
90
+ 4. Also passes `CUSTOM_STARTER_URL` in compose environment at runtime.
91
+ 5. Starts containers and waits for health check.
92
+ 6. Skips frontend scaffold and dotCMS frontend settings flow (token, default site lookup, UVE setup).
126
93
 
127
- The CLI includes comprehensive validation to help you avoid common setup issues:
94
+ Use this when your starter is not compatible with the default frontend sample flow.
128
95
 
129
- ### Input Validation
130
- - **Project names:** Validates against filesystem limitations, reserved names, special characters, and path traversal
131
- - **Framework names:** Supports aliases and case-insensitive matching
132
- - **URLs:** Ensures proper protocol and format
133
- - **Conflicting parameters:** Warns when mixing `--local` with cloud parameters
96
+ ## Examples
134
97
 
135
- ### Docker Environment Checks
136
- When using local Docker setup, the CLI performs pre-flight checks:
98
+ Interactive:
137
99
 
138
- 1. **Docker Availability**
139
- - Verifies Docker is installed and running
140
- - Provides installation instructions if not found
141
- - Direct link to Docker Desktop download
100
+ ```sh
101
+ npx @dotcms/create-app my-blog
102
+ ```
142
103
 
143
- 2. **Port Availability**
144
- - Checks all required ports before starting containers
145
- - Lists which specific ports are busy
146
- - Provides platform-specific commands to identify blocking processes
147
- - Suggests `docker compose down` to stop existing containers
104
+ Local + specific framework:
148
105
 
149
- 3. **Container Health**
150
- - Monitors dotCMS startup with intelligent retries
151
- - Shows detailed diagnostics if startup fails
152
- - Displays container status and recent logs
106
+ ```sh
107
+ npx @dotcms/create-app my-blog --local --framework nextjs
108
+ ```
153
109
 
154
- ### Error Messages
155
- All error messages include:
156
- - **Clear problem description** - What went wrong
157
- - **Specific suggestions** - How to fix it
158
- - **Alternative solutions** - Other ways to proceed
159
- - **Platform-specific commands** - Commands tailored to your OS
110
+ Starter-only local:
160
111
 
161
- ### Debug Mode
162
- Run with `DEBUG=1` to see detailed stack traces:
163
112
  ```sh
164
- DEBUG=1 npx @dotcms/create-app my-project
113
+ npx @dotcms/create-app my-blog --starter https://repo.example.com/path/starter.zip
165
114
  ```
166
115
 
167
- ---
116
+ Cloud with flags:
168
117
 
169
- ## 🔧 Troubleshooting
118
+ ```sh
119
+ npx @dotcms/create-app my-blog \
120
+ --framework angular \
121
+ --url https://demo.dotcms.com \
122
+ --username admin@dotcms.com \
123
+ --password admin
124
+ ```
170
125
 
171
- ### Docker Issues
126
+ Debug errors with stack traces:
172
127
 
173
- **"Docker is not available"**
174
- - Ensure Docker Desktop is installed and running
175
- - Check the Docker icon in your system tray
176
- - Download from: https://www.docker.com/products/docker-desktop
128
+ ```sh
129
+ DEBUG=1 npx @dotcms/create-app my-blog --local
130
+ ```
177
131
 
178
- **"Required ports are already in use"**
179
- - Check what's using the ports:
180
- - macOS/Linux: `lsof -i :8082`
181
- - Windows: `netstat -ano | findstr ":8082"`
182
- - Stop existing dotCMS containers: `docker compose down`
183
- - Stop conflicting services or choose a different port mapping
132
+ ## Validation Rules
184
133
 
185
- **"dotCMS failed to start properly"**
186
- - Check container logs: `docker logs <container-name>`
187
- - Verify sufficient system resources (RAM, disk space)
188
- - Review Docker diagnostics output from the CLI
134
+ - URLs must include protocol (`http://` or `https://`).
135
+ - Project names are validated for path traversal, invalid characters, reserved Windows names, and length.
136
+ - If local mode is selected (`--local` or `--starter`), cloud flags are ignored with a warning.
137
+ - Existing non-empty target directory requires confirmation before cleanup.
189
138
 
190
- ### Validation Errors
139
+ ## Troubleshooting
191
140
 
192
- **"Invalid project name"**
193
- - Avoid special characters: `< > : " | ? *`
194
- - Don't use Windows reserved names: `CON`, `PRN`, `AUX`, `NUL`, etc.
195
- - Maximum 255 characters
196
- - No path traversal patterns (`..`)
141
+ Docker not available:
197
142
 
198
- **"Invalid URL format"**
199
- - Include protocol: `https://` or `http://`
200
- - Verify hostname is correct
201
- - For localhost, default port is 8082
143
+ - Install/start Docker Desktop, then retry.
202
144
 
203
- ---
145
+ Ports already in use:
204
146
 
205
- ## 🚀 Examples
147
+ - macOS/Linux: `lsof -i :8082`
148
+ - Windows: `netstat -ano | findstr ":8082"`
149
+ - Stop conflicting services or run `docker compose down`.
206
150
 
207
- ### Quick Start with Interactive Prompts
208
- ```sh
209
- npx @dotcms/create-app my-blog
210
- ```
151
+ `zip END header not found` during starter load:
211
152
 
212
- ### Using CLI Flags (Skip Prompts)
213
- ```sh
214
- # Local Docker setup
215
- npx @dotcms/create-app my-blog --framework nextjs --local
153
+ - Starter URL is reachable but not returning a valid ZIP payload.
154
+ - Verify artifact URL, repository permissions, and response content type/body.
216
155
 
217
- # Cloud instance
218
- npx @dotcms/create-app my-blog \
219
- --framework angular \
220
- --url https://demo.dotcms.com \
221
- --username admin@dotcms.com \
222
- --password mypassword
223
- ```
156
+ ## Development (this repo)
157
+
158
+ Build:
224
159
 
225
- ### Debug Mode
226
160
  ```sh
227
- DEBUG=1 npx @dotcms/create-app my-blog --framework nextjs --local
161
+ yarn nx build sdk-create-app --skip-nx-cache
228
162
  ```
229
163
 
230
- ---
164
+ Lint:
231
165
 
232
- ## 🔒 Security Notes
166
+ ```sh
167
+ yarn nx lint sdk-create-app
168
+ ```
233
169
 
234
- - Never commit API tokens or passwords to version control
235
- - The CLI validates all inputs to prevent injection attacks
236
- - Project names are sanitized to prevent path traversal
237
- - Shell commands are properly escaped for cross-platform safety
170
+ Dist output:
238
171
 
172
+ - `dist/libs/sdk/create-app/index.js`
173
+ - ESM Node CLI bundle with shebang in production build
174
+ - Publishable package includes JavaScript files and `README.md` only (no type declarations)