ante-erp-cli 1.6.6 → 1.6.7
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/package.json +1 -1
- package/src/commands/install.js +3 -2
- package/src/commands/set-domain.js +49 -11
package/package.json
CHANGED
package/src/commands/install.js
CHANGED
|
@@ -557,7 +557,8 @@ Support: support@ante.ph
|
|
|
557
557
|
const composeFile = join(config.installDir, 'docker-compose.yml');
|
|
558
558
|
|
|
559
559
|
try {
|
|
560
|
-
// Run seed command in the backend container
|
|
560
|
+
// Run production seed command in the backend container
|
|
561
|
+
// Uses seed:prod which compiles TypeScript and runs with node (production-safe)
|
|
561
562
|
await execa('docker', [
|
|
562
563
|
'compose',
|
|
563
564
|
'-f', composeFile,
|
|
@@ -566,7 +567,7 @@ Support: support@ante.ph
|
|
|
566
567
|
'backend',
|
|
567
568
|
'npm',
|
|
568
569
|
'run',
|
|
569
|
-
'seed'
|
|
570
|
+
'seed:prod'
|
|
570
571
|
]);
|
|
571
572
|
} catch (error) {
|
|
572
573
|
// Seeding is optional, just log warning
|
|
@@ -9,7 +9,7 @@ import { configureNginx, requiresNginx } from '../utils/nginx.js';
|
|
|
9
9
|
import { pullImages, stopServices, startServices, waitForServiceHealthy } from '../utils/docker.js';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
* Validate URL format
|
|
12
|
+
* Validate URL format with proper hostname and protocol checking
|
|
13
13
|
* @param {string} url - URL to validate
|
|
14
14
|
* @returns {boolean|string} True if valid, error message if invalid
|
|
15
15
|
*/
|
|
@@ -19,16 +19,49 @@ function validateUrl(url) {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
try {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
const parsed = new URL(url);
|
|
23
|
+
|
|
24
|
+
// Check protocol
|
|
25
|
+
if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {
|
|
26
|
+
return 'URL must use http:// or https:// protocol';
|
|
25
27
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
|
|
29
|
+
// Check hostname exists and is not empty
|
|
30
|
+
if (!parsed.hostname || parsed.hostname.trim() === '') {
|
|
31
|
+
return 'URL must have a valid hostname (e.g., staging-api.ante.ph or 143.198.91.153)';
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Check for common mistakes (triple slashes)
|
|
35
|
+
if (url.includes('///') && !url.match(/^https?:\/\/[^/]/)) {
|
|
36
|
+
return 'URL has invalid format - check for extra slashes after protocol';
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return true;
|
|
40
|
+
} catch (error) {
|
|
41
|
+
return `Invalid URL format: ${error.message}`;
|
|
29
42
|
}
|
|
30
43
|
}
|
|
31
44
|
|
|
45
|
+
/**
|
|
46
|
+
* Sanitize URL by normalizing common formatting issues
|
|
47
|
+
* @param {string} url - URL to sanitize
|
|
48
|
+
* @returns {string} Sanitized URL
|
|
49
|
+
*/
|
|
50
|
+
function sanitizeUrl(url) {
|
|
51
|
+
if (!url) return url;
|
|
52
|
+
|
|
53
|
+
// Normalize protocol slashes (https:/// -> https://)
|
|
54
|
+
url = url.replace(/^(https?):\/\/+/, '$1://');
|
|
55
|
+
|
|
56
|
+
// Remove trailing slashes from the URL
|
|
57
|
+
url = url.replace(/\/+$/, '');
|
|
58
|
+
|
|
59
|
+
// Remove any accidental leading slashes before hostname
|
|
60
|
+
url = url.replace(/^(https?:\/\/)\/+/, '$1');
|
|
61
|
+
|
|
62
|
+
return url;
|
|
63
|
+
}
|
|
64
|
+
|
|
32
65
|
/**
|
|
33
66
|
* Read current value from .env file
|
|
34
67
|
* @param {string} envPath - Path to .env file
|
|
@@ -189,21 +222,22 @@ export async function setDomain(options) {
|
|
|
189
222
|
{
|
|
190
223
|
type: 'input',
|
|
191
224
|
name: 'frontendUrl',
|
|
192
|
-
message: 'Frontend
|
|
225
|
+
message: 'Frontend URL:\n Examples: https://staging.ante.ph or http://143.198.91.153:8080\n Enter URL',
|
|
193
226
|
default: currentFrontendUrl || 'http://localhost:8080',
|
|
194
227
|
validate: validateUrl
|
|
195
228
|
},
|
|
196
229
|
{
|
|
197
230
|
type: 'input',
|
|
198
231
|
name: 'apiUrl',
|
|
199
|
-
message: 'API
|
|
232
|
+
message: 'Backend API URL:\n Examples: https://staging-api.ante.ph or http://143.198.91.153:3001\n Enter URL',
|
|
200
233
|
default: currentApiUrl || 'http://localhost:3001',
|
|
201
234
|
validate: validateUrl
|
|
202
235
|
}
|
|
203
236
|
]);
|
|
204
237
|
|
|
205
|
-
|
|
206
|
-
|
|
238
|
+
// Sanitize URLs to fix common formatting issues
|
|
239
|
+
frontendUrl = sanitizeUrl(answers.frontendUrl);
|
|
240
|
+
apiUrl = sanitizeUrl(answers.apiUrl);
|
|
207
241
|
}
|
|
208
242
|
} else {
|
|
209
243
|
// Non-interactive mode
|
|
@@ -215,6 +249,10 @@ export async function setDomain(options) {
|
|
|
215
249
|
process.exit(1);
|
|
216
250
|
}
|
|
217
251
|
|
|
252
|
+
// Sanitize URLs to fix common formatting issues
|
|
253
|
+
frontendUrl = sanitizeUrl(frontendUrl);
|
|
254
|
+
apiUrl = sanitizeUrl(apiUrl);
|
|
255
|
+
|
|
218
256
|
const frontendValidation = validateUrl(frontendUrl);
|
|
219
257
|
const apiValidation = validateUrl(apiUrl);
|
|
220
258
|
|