domma-js 0.13.1 → 0.13.2

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
@@ -33,8 +33,14 @@ Get a complete project structure with development server in seconds:
33
33
  ```bash
34
34
  npm init -y
35
35
  npm install domma-js
36
- npx domma init # Creates project structure
37
- npx domma serve # Starts development server with live reload
36
+ npx domma init # Creates project structure (prompts to start server)
37
+ ```
38
+
39
+ **Or manually start the server:**
40
+ ```bash
41
+ npm start # Starts on port 3000
42
+ npm run serve # Same as npm start
43
+ npm run serve:8080 # Custom port
38
44
  ```
39
45
 
40
46
  This creates:
@@ -43,6 +49,7 @@ This creates:
43
49
  - ✅ JSON configuration (`domma.config.json`)
44
50
  - ✅ Navbar and footer (configured via JSON)
45
51
  - ✅ Theme system with 16+ themes
52
+ - ✅ npm scripts (`start`, `serve`) in package.json
46
53
  - ✅ Development server with live reload
47
54
  - ✅ All features ready to use
48
55
 
@@ -50,12 +57,36 @@ This creates:
50
57
 
51
58
  Start the built-in development server with live reload:
52
59
 
60
+ **Using npm scripts (recommended):**
61
+ ```bash
62
+ npm start # Start on port 3096
63
+ npm run serve # Same as npm start
64
+ npm run serve:3096 # Explicit port 3096
65
+ ```
66
+
67
+ **Using CLI directly:**
53
68
  ```bash
54
69
  npx domma serve # Start server (auto-detects MPA/SPA)
55
- npx domma serve --port 8080 # Custom port
70
+ npx domma serve --port 3096 # Custom port
56
71
  ```
57
72
 
58
- The server auto-detects your project type and serves from the correct directory with live reload enabled.
73
+ The server auto-detects your project type (MPA/SPA) and serves from the correct directory with live reload enabled.
74
+
75
+ **Full Development Workflow:**
76
+ ```bash
77
+ # 1. Create project
78
+ npm install domma-js
79
+ npx domma init
80
+
81
+ # 2. Start developing (auto-starts server or run manually)
82
+ npm start # Opens http://localhost:3096
83
+
84
+ # 3. Make changes → browser auto-reloads
85
+
86
+ # 4. Stop server: Ctrl+C
87
+
88
+ # 5. Restart anytime: npm start
89
+ ```
59
90
 
60
91
  ### Via npm (Manual Setup)
61
92
 
package/bin/domma-cli.js CHANGED
@@ -203,6 +203,46 @@ async function handleInit() {
203
203
  console.log(` ✓ Copied themes/`);
204
204
  }
205
205
 
206
+ // Create or update package.json with scripts
207
+ const packageJsonPath = join(process.cwd(), 'package.json');
208
+ let packageJson;
209
+
210
+ if (existsSync(packageJsonPath)) {
211
+ // Update existing package.json
212
+ packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
213
+ console.log(`\n Updating package.json with serve scripts...`);
214
+ } else {
215
+ // Create new package.json
216
+ packageJson = {
217
+ name: projectName,
218
+ version: '1.0.0',
219
+ description: `${projectName} - Powered by Domma`,
220
+ main: 'index.js',
221
+ type: 'module'
222
+ };
223
+ console.log(`\n Creating package.json...`);
224
+ }
225
+
226
+ // Add/update scripts
227
+ if (!packageJson.scripts) {
228
+ packageJson.scripts = {};
229
+ }
230
+
231
+ packageJson.scripts.start = 'domma serve';
232
+ packageJson.scripts.serve = 'domma serve';
233
+ packageJson.scripts['serve:3096'] = 'domma serve --port 3096';
234
+
235
+ // Ensure domma-js is in dependencies
236
+ if (!packageJson.dependencies) {
237
+ packageJson.dependencies = {};
238
+ }
239
+ if (!packageJson.dependencies['domma-js']) {
240
+ packageJson.dependencies['domma-js'] = `^${VERSION}`;
241
+ }
242
+
243
+ writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2), 'utf-8');
244
+ console.log(` ✓ Added npm scripts: start, serve`);
245
+
206
246
  console.log(`\n ✓ Done! Your ${projectMode.toUpperCase()} project "${projectName}" is ready.\n`);
207
247
 
208
248
  // Prompt to start development server
@@ -217,12 +257,12 @@ async function handleInit() {
217
257
  console.log(`\n Next steps:`);
218
258
 
219
259
  if (projectMode === 'spa') {
220
- console.log(` 1. Start server: npx domma serve`);
260
+ console.log(` 1. Start server: npm start (or: npm run serve)`);
221
261
  console.log(` 2. Edit domma.config.json to customise routes and navbar`);
222
262
  console.log(` 3. Add new views: npx domma add view <name>`);
223
263
  console.log(` 4. Edit views in frontend/js/views/`);
224
264
  } else {
225
- console.log(` 1. Start server: npx domma serve`);
265
+ console.log(` 1. Start server: npm start (or: npm run serve)`);
226
266
  console.log(` 2. Edit domma.config.json to customise`);
227
267
  console.log(` 3. Add new pages: npx domma add page <name>`);
228
268
  }
@@ -572,7 +612,12 @@ function copyTemplatesRecursive(srcDir, destDir, vars) {
572
612
  * Handle serve command
573
613
  */
574
614
  async function handleServe() {
575
- const configPath = join(process.cwd(), 'domma.config.json');
615
+ // Check for domma.config.json at root (MPA) or in frontend/ (SPA)
616
+ let configPath = join(process.cwd(), 'domma.config.json');
617
+
618
+ if (!existsSync(configPath)) {
619
+ configPath = join(process.cwd(), 'frontend', 'domma.config.json');
620
+ }
576
621
 
577
622
  if (!existsSync(configPath)) {
578
623
  console.error('\n ✗ Not in a Domma project directory');
@@ -622,7 +667,7 @@ async function handleServe() {
622
667
  const config = JSON.parse(readFileSync(configPath, 'utf-8'));
623
668
  const isSpa = config.spa?.enabled === true;
624
669
  const portIndex = args.indexOf('--port');
625
- const port = portIndex !== -1 ? parseInt(args[portIndex + 1]) : 3000;
670
+ const port = portIndex !== -1 ? parseInt(args[portIndex + 1]) : 3096;
626
671
  const servePath = isSpa ? 'frontend' : 'frontend/pages';
627
672
 
628
673
  console.log(`
@@ -758,7 +803,7 @@ Commands:
758
803
  npx domma-js add view <name> Add a new view (SPA only)
759
804
  npx domma-js setup-ai Add AI assistance files to existing project
760
805
  npx domma-js serve Start development server with live reload
761
- --port <number> Custom port (default: 3000)
806
+ --port <number> Custom port (default: 3096)
762
807
 
763
808
  Options:
764
809
  --help, -h Show this help message
@@ -781,9 +826,13 @@ Examples:
781
826
  npx domma-js add view profile # Creates profile view with route
782
827
 
783
828
  # Development server:
784
- npx domma-js serve # Start server (auto-detects MPA/SPA)
785
- npx domma-js serve --port 8080 # Start on custom port
786
-
787
- Note: Paths are automatically calculated based on folder depth
829
+ npm start # Start server (uses scripts from package.json)
830
+ npm run serve # Same as npm start
831
+ npm run serve:3096 # Start on port 3096 (explicit)
832
+ npx domma-js serve # Direct CLI usage
833
+ npx domma-js serve --port 3096 # Custom port
834
+
835
+ Note: After 'npx domma init', use 'npm start' to run the server.
836
+ Paths are automatically calculated based on folder depth.
788
837
  `);
789
838
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "domma-js",
3
- "version": "0.13.1",
3
+ "version": "0.13.2",
4
4
  "description": "Dynamic Object Manipulation & Modeling API - A complete front-end toolkit.",
5
5
  "main": "public/dist/domma.min.js",
6
6
  "module": "public/dist/domma.esm.js",
@@ -31,6 +31,9 @@
31
31
  "type": "module",
32
32
  "scripts": {
33
33
  "postinstall": "node bin/postinstall.js",
34
+ "start": "node bin/domma-cli.js serve",
35
+ "serve": "node bin/domma-cli.js serve",
36
+ "serve:3096": "node bin/domma-cli.js serve --port 3096",
34
37
  "dev": "NODE_ENV=development npm run generate:bundles && rollup -c && node scripts/build-info.js && npm run build:metadata && npm run copy:themes && npm run build:css && npm run build:miniapps && live-server public --port=3001 --open=/index.html",
35
38
  "dev:watch": "NODE_ENV=development npm run generate:bundles && rollup -c && node scripts/build-info.js && npm run build:metadata && npm run copy:themes && npm run build:css && npm run build:miniapps && npm run watch:miniapps",
36
39
  "build": "npm run generate:bundles && rollup -c && node scripts/build-info.js && npm run build:metadata && npm run copy:themes && npm run build:css && npm run build:css-bundles && npm run build:archives && npm run build:kickstart && npm run build:miniapps",