easy-devops 0.2.6 → 1.0.0
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 +87 -44
- package/cli/index.js +27 -5
- package/cli/managers/domain-manager.js +204 -34
- package/cli/managers/nginx-manager.js +60 -20
- package/cli/managers/ssl-manager.js +441 -579
- package/cli/menus/settings.js +27 -8
- package/core/config.js +5 -2
- package/core/detector.js +50 -87
- package/core/nginx-conf-generator.js +100 -63
- package/core/platform.js +61 -0
- package/core/shell.js +2 -2
- package/core/validators.js +96 -0
- package/dashboard/lib/cert-reader.js +5 -5
- package/dashboard/lib/nginx-service.js +47 -77
- package/dashboard/public/img/icon.png +0 -0
- package/dashboard/public/img/icon_b.png +0 -0
- package/dashboard/public/js/app.js +257 -20
- package/dashboard/routes/domains.js +110 -72
- package/dashboard/routes/settings.js +19 -11
- package/dashboard/routes/ssl.js +235 -59
- package/dashboard/views/index.ejs +481 -260
- package/dashboard/views/partials/domain-form.ejs +332 -228
- package/dashboard/views/partials/domains-panel.ejs +100 -62
- package/dashboard/views/partials/login.ejs +157 -40
- package/dashboard/views/partials/nginx-panel.ejs +126 -84
- package/dashboard/views/partials/overview.ejs +124 -49
- package/dashboard/views/partials/settings-panel.ejs +66 -35
- package/dashboard/views/partials/sidebar.ejs +84 -33
- package/dashboard/views/partials/ssl-panel.ejs +174 -51
- package/install.sh +8 -9
- package/lib/installer/nvm-bootstrap.sh +8 -8
- package/lib/installer/picker.sh +32 -15
- package/package.json +4 -2
package/core/platform.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* core/platform.js
|
|
3
|
+
*
|
|
4
|
+
* Shared platform constants and nginx command-building helpers.
|
|
5
|
+
* Used by CLI managers, dashboard routes, and dashboard lib.
|
|
6
|
+
* Centralises the isWindows guard and nginx shell invocations so they
|
|
7
|
+
* are defined exactly once and behave identically everywhere.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export const isWindows = process.platform === 'win32';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Returns the nginx binary invocation string suitable for use in shell commands.
|
|
14
|
+
* On Windows returns `& "path\nginx.exe"` (PowerShell call operator + quoted path).
|
|
15
|
+
* On Linux/macOS returns the plain `nginx` command (assumed to be on PATH).
|
|
16
|
+
* @param {string} nginxDir
|
|
17
|
+
* @returns {string}
|
|
18
|
+
*/
|
|
19
|
+
export function getNginxExe(nginxDir) {
|
|
20
|
+
if (isWindows) {
|
|
21
|
+
return `& "${nginxDir}\\nginx.exe"`;
|
|
22
|
+
}
|
|
23
|
+
return 'nginx';
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Builds the nginx config-test command for the given nginx directory.
|
|
28
|
+
* On Windows passes an explicit -c flag with the full conf path to avoid
|
|
29
|
+
* working-directory issues when nginx.exe is invoked from an arbitrary cwd.
|
|
30
|
+
* @param {string} nginxDir
|
|
31
|
+
* @returns {string}
|
|
32
|
+
*/
|
|
33
|
+
export function nginxTestCmd(nginxDir) {
|
|
34
|
+
if (isWindows) {
|
|
35
|
+
const confPath = `${nginxDir}\\conf\\nginx.conf`;
|
|
36
|
+
return `& "${nginxDir}\\nginx.exe" -c "${confPath}" -t`;
|
|
37
|
+
}
|
|
38
|
+
return 'nginx -t';
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Builds the nginx graceful-reload command.
|
|
43
|
+
* @param {string} nginxDir
|
|
44
|
+
* @returns {string}
|
|
45
|
+
*/
|
|
46
|
+
export function nginxReloadCmd(nginxDir) {
|
|
47
|
+
if (isWindows) {
|
|
48
|
+
return `& "${nginxDir}\\nginx.exe" -s reload`;
|
|
49
|
+
}
|
|
50
|
+
return 'nginx -s reload';
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Merges stdout and stderr from a shell result into a single trimmed string.
|
|
55
|
+
* Useful for surfacing nginx output that may come from either stream.
|
|
56
|
+
* @param {{ stdout: string, stderr: string }} result
|
|
57
|
+
* @returns {string}
|
|
58
|
+
*/
|
|
59
|
+
export function combineOutput(result) {
|
|
60
|
+
return [result.stdout, result.stderr].filter(Boolean).join('\n').trim();
|
|
61
|
+
}
|
package/core/shell.js
CHANGED
|
@@ -121,7 +121,7 @@ export function run(cmd, options = {}) {
|
|
|
121
121
|
* @returns {Promise<number|null>}
|
|
122
122
|
*/
|
|
123
123
|
export function runLive(cmd, options = {}) {
|
|
124
|
-
const { timeout = 30000, cwd = process.cwd() } = options;
|
|
124
|
+
const { timeout = 30000, cwd = process.cwd(), stdin = 'ignore' } = options;
|
|
125
125
|
const { shell, flag } = getShell();
|
|
126
126
|
|
|
127
127
|
return new Promise((resolve) => {
|
|
@@ -131,7 +131,7 @@ export function runLive(cmd, options = {}) {
|
|
|
131
131
|
const child = spawn(shell, [flag, cmd], {
|
|
132
132
|
cwd,
|
|
133
133
|
signal: ac.signal,
|
|
134
|
-
stdio: [
|
|
134
|
+
stdio: [stdin, 'inherit', 'inherit'],
|
|
135
135
|
windowsHide: true,
|
|
136
136
|
});
|
|
137
137
|
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* core/validators.js
|
|
3
|
+
*
|
|
4
|
+
* Shared input validation helpers used by dashboard API routes and CLI prompts.
|
|
5
|
+
* Each function returns a human-readable error string on failure, or null on success.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Validates a domain name.
|
|
10
|
+
* Accepts multi-level subdomains (a.b.c.example.com) and wildcards (*.example.com).
|
|
11
|
+
* The *. prefix is stripped before validation so the bare domain is checked.
|
|
12
|
+
* @param {string} name
|
|
13
|
+
* @returns {string|null} Error message, or null if valid
|
|
14
|
+
*/
|
|
15
|
+
export function validateDomainName(name) {
|
|
16
|
+
if (!name || typeof name !== 'string') {
|
|
17
|
+
return 'name is required';
|
|
18
|
+
}
|
|
19
|
+
// Strip *. prefix defensively — the system adds it; users should not type it
|
|
20
|
+
const bare = name.startsWith('*.') ? name.slice(2) : name;
|
|
21
|
+
// Each label: starts and ends with alphanumeric, hyphens allowed in middle
|
|
22
|
+
const labelPattern = /^[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?$/;
|
|
23
|
+
const labels = bare.split('.');
|
|
24
|
+
if (labels.length < 2) {
|
|
25
|
+
return 'Domain must have at least two labels (e.g. example.com)';
|
|
26
|
+
}
|
|
27
|
+
for (const label of labels) {
|
|
28
|
+
if (!label) return 'Invalid domain name format: empty label';
|
|
29
|
+
if (!labelPattern.test(label)) return 'Invalid domain name format';
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Validates that a port number is a valid TCP port (1–65535).
|
|
36
|
+
* @param {number|string} port
|
|
37
|
+
* @returns {string|null}
|
|
38
|
+
*/
|
|
39
|
+
export function validatePort(port) {
|
|
40
|
+
const portNum = Number(port);
|
|
41
|
+
if (!Number.isInteger(portNum) || portNum < 1 || portNum > 65535) {
|
|
42
|
+
return 'Invalid port: must be 1–65535';
|
|
43
|
+
}
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Validates an email address (basic format check).
|
|
49
|
+
* An empty string is allowed — pass a non-empty email to require one.
|
|
50
|
+
* @param {string} email
|
|
51
|
+
* @returns {string|null}
|
|
52
|
+
*/
|
|
53
|
+
export function validateEmail(email) {
|
|
54
|
+
if (email === undefined || email === null || email === '') return null;
|
|
55
|
+
if (typeof email !== 'string' || !email.includes('@') || email.trim() !== email) {
|
|
56
|
+
return 'Invalid email address';
|
|
57
|
+
}
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Validates that upstreamType is one of the accepted values.
|
|
63
|
+
* @param {string} type
|
|
64
|
+
* @returns {string|null}
|
|
65
|
+
*/
|
|
66
|
+
export function validateUpstreamType(type) {
|
|
67
|
+
if (type && !['http', 'https', 'ws'].includes(type)) {
|
|
68
|
+
return 'Invalid upstreamType: must be http, https, or ws';
|
|
69
|
+
}
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Validates the nginx client_max_body_size format (e.g. 10m, 1g, 512k).
|
|
75
|
+
* @param {string} size
|
|
76
|
+
* @returns {string|null}
|
|
77
|
+
*/
|
|
78
|
+
export function validateMaxBodySize(size) {
|
|
79
|
+
if (size && !/^\d+[kmgKMG]?$/.test(size)) {
|
|
80
|
+
return 'Invalid maxBodySize format (e.g., 10m, 1g)';
|
|
81
|
+
}
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Validates that a value is a positive integer.
|
|
87
|
+
* @param {number|string} val
|
|
88
|
+
* @param {string} field Human-readable field name for the error message
|
|
89
|
+
* @returns {string|null}
|
|
90
|
+
*/
|
|
91
|
+
export function validatePositiveInteger(val, field) {
|
|
92
|
+
if (val !== undefined && (!Number.isInteger(Number(val)) || Number(val) < 1)) {
|
|
93
|
+
return `Invalid ${field}: must be a positive integer`;
|
|
94
|
+
}
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
@@ -4,8 +4,8 @@ import { run } from '../../core/shell.js';
|
|
|
4
4
|
import { loadConfig } from '../../core/config.js';
|
|
5
5
|
|
|
6
6
|
export async function listAllCerts() {
|
|
7
|
-
const {
|
|
8
|
-
const liveDir =
|
|
7
|
+
const { sslDir } = loadConfig();
|
|
8
|
+
const liveDir = sslDir;
|
|
9
9
|
let entries;
|
|
10
10
|
try {
|
|
11
11
|
entries = await fs.readdir(liveDir, { withFileTypes: true });
|
|
@@ -13,7 +13,7 @@ export async function listAllCerts() {
|
|
|
13
13
|
if (err.code === 'ENOENT') return [];
|
|
14
14
|
throw err;
|
|
15
15
|
}
|
|
16
|
-
const dirs = entries.filter(e => e.isDirectory());
|
|
16
|
+
const dirs = entries.filter(e => e.isDirectory() && !e.name.startsWith('.'));
|
|
17
17
|
const certs = [];
|
|
18
18
|
for (const dir of dirs) {
|
|
19
19
|
const { expiry, daysLeft } = await getCertExpiry(dir.name);
|
|
@@ -33,8 +33,8 @@ export async function listAllCerts() {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
export async function getCertExpiry(name) {
|
|
36
|
-
const {
|
|
37
|
-
const certPath = path.join(
|
|
36
|
+
const { sslDir } = loadConfig();
|
|
37
|
+
const certPath = path.join(sslDir, name, 'fullchain.pem');
|
|
38
38
|
|
|
39
39
|
const result = await run(`openssl x509 -enddate -noout -in "${certPath}"`);
|
|
40
40
|
|
|
@@ -2,7 +2,8 @@ import fs from 'fs/promises';
|
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { run } from '../../core/shell.js';
|
|
4
4
|
import { loadConfig } from '../../core/config.js';
|
|
5
|
-
import { ensureNginxInclude } from '../../core/nginx-conf-generator.js';
|
|
5
|
+
import { ensureNginxInclude, getConfDDir } from '../../core/nginx-conf-generator.js';
|
|
6
|
+
import { isWindows, getNginxExe, nginxTestCmd, combineOutput } from '../../core/platform.js';
|
|
6
7
|
|
|
7
8
|
// ─── Error Types ──────────────────────────────────────────────────────────────
|
|
8
9
|
|
|
@@ -24,30 +25,6 @@ function getNginxDir() {
|
|
|
24
25
|
return nginxDir;
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
function getConfDDir(nginxDir) {
|
|
28
|
-
return process.platform === 'win32'
|
|
29
|
-
? path.join(nginxDir, 'conf', 'conf.d')
|
|
30
|
-
: path.join(nginxDir, 'conf.d');
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Returns the PS-safe invocation string for the nginx binary.
|
|
35
|
-
* On Windows: checks PATH first, then falls back to configured nginxDir.
|
|
36
|
-
* On Linux: always returns 'nginx'.
|
|
37
|
-
*/
|
|
38
|
-
function getNginxExe() {
|
|
39
|
-
const nginxDir = getNginxDir();
|
|
40
|
-
if (process.platform === 'win32') {
|
|
41
|
-
const exe = path.join(nginxDir, 'nginx.exe');
|
|
42
|
-
return `& "${exe}"`;
|
|
43
|
-
}
|
|
44
|
-
return 'nginx';
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function combineOutput(result) {
|
|
48
|
-
return [result.stdout, result.stderr].filter(Boolean).join('\n').trim();
|
|
49
|
-
}
|
|
50
|
-
|
|
51
28
|
export function validateFilename(filename) {
|
|
52
29
|
if (
|
|
53
30
|
filename.includes('..') ||
|
|
@@ -64,10 +41,19 @@ export function validateFilename(filename) {
|
|
|
64
41
|
}
|
|
65
42
|
}
|
|
66
43
|
|
|
44
|
+
/** Checks if nginx is installed and throws NginxNotFoundError if not. */
|
|
45
|
+
async function assertNginxInstalled(nginxExe) {
|
|
46
|
+
const versionResult = await run(`${nginxExe} -v`);
|
|
47
|
+
if (!versionResult.success && !versionResult.stderr.includes('nginx/')) {
|
|
48
|
+
throw new NginxNotFoundError('nginx binary not found');
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
67
52
|
// ─── US1: Status ──────────────────────────────────────────────────────────────
|
|
68
53
|
|
|
69
54
|
export async function getStatus() {
|
|
70
|
-
const
|
|
55
|
+
const nginxDir = getNginxDir();
|
|
56
|
+
const nginxExe = getNginxExe(nginxDir);
|
|
71
57
|
const versionResult = await run(`${nginxExe} -v`);
|
|
72
58
|
|
|
73
59
|
if (!versionResult.success && !versionResult.stderr.includes('nginx/')) {
|
|
@@ -80,7 +66,7 @@ export async function getStatus() {
|
|
|
80
66
|
let running = false;
|
|
81
67
|
let pid = null;
|
|
82
68
|
|
|
83
|
-
if (
|
|
69
|
+
if (isWindows) {
|
|
84
70
|
const result = await run('tasklist /FI "IMAGENAME eq nginx.exe" /NH');
|
|
85
71
|
const output = combineOutput(result);
|
|
86
72
|
running = output.toLowerCase().includes('nginx.exe');
|
|
@@ -103,29 +89,28 @@ export async function getStatus() {
|
|
|
103
89
|
// ─── US2: Control ─────────────────────────────────────────────────────────────
|
|
104
90
|
|
|
105
91
|
export async function reload() {
|
|
106
|
-
const
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
throw new NginxNotFoundError('nginx binary not found');
|
|
110
|
-
}
|
|
92
|
+
const nginxDir = getNginxDir();
|
|
93
|
+
const nginxExe = getNginxExe(nginxDir);
|
|
94
|
+
await assertNginxInstalled(nginxExe);
|
|
111
95
|
|
|
112
|
-
const result =
|
|
113
|
-
? await run(`${nginxExe} -s reload
|
|
96
|
+
const result = isWindows
|
|
97
|
+
? await run(`${nginxExe} -s reload`, { cwd: nginxDir, timeout: 15000 })
|
|
114
98
|
: await run('nginx -s reload');
|
|
115
99
|
return { success: result.success, output: combineOutput(result) };
|
|
116
100
|
}
|
|
117
101
|
|
|
118
102
|
export async function restart() {
|
|
119
|
-
const
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
throw new NginxNotFoundError('nginx binary not found');
|
|
123
|
-
}
|
|
103
|
+
const nginxDir = getNginxDir();
|
|
104
|
+
const nginxExe = getNginxExe(nginxDir);
|
|
105
|
+
await assertNginxInstalled(nginxExe);
|
|
124
106
|
|
|
125
|
-
const stopResult =
|
|
107
|
+
const stopResult = isWindows
|
|
126
108
|
? await run('taskkill /f /IM nginx.exe')
|
|
127
109
|
: await run('nginx -s stop');
|
|
128
|
-
|
|
110
|
+
|
|
111
|
+
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
112
|
+
|
|
113
|
+
const startResult = await run(nginxExe, { cwd: nginxDir, timeout: 15000 });
|
|
129
114
|
const output = [combineOutput(stopResult), combineOutput(startResult)]
|
|
130
115
|
.filter(Boolean)
|
|
131
116
|
.join('\n')
|
|
@@ -134,34 +119,28 @@ export async function restart() {
|
|
|
134
119
|
}
|
|
135
120
|
|
|
136
121
|
export async function start() {
|
|
137
|
-
const nginxExe = getNginxExe();
|
|
138
122
|
const nginxDir = getNginxDir();
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
throw new NginxNotFoundError('nginx binary not found');
|
|
142
|
-
}
|
|
123
|
+
const nginxExe = getNginxExe(nginxDir);
|
|
124
|
+
await assertNginxInstalled(nginxExe);
|
|
143
125
|
|
|
144
126
|
// Ensure required directories exist on Windows
|
|
145
|
-
if (
|
|
127
|
+
if (isWindows) {
|
|
146
128
|
await fs.mkdir(path.join(nginxDir, 'logs'), { recursive: true });
|
|
147
129
|
await fs.mkdir(path.join(nginxDir, 'temp'), { recursive: true });
|
|
148
130
|
}
|
|
149
131
|
|
|
150
|
-
// Test config before starting
|
|
132
|
+
// Test config before starting
|
|
151
133
|
await ensureNginxInclude(nginxDir);
|
|
152
|
-
const
|
|
153
|
-
? `${nginxExe} -c "${path.join(nginxDir, 'conf', 'nginx.conf')}" -t`
|
|
154
|
-
: `${nginxExe} -t`;
|
|
155
|
-
const testResult = await run(testCmd);
|
|
134
|
+
const testResult = await run(nginxTestCmd(nginxDir), { cwd: nginxDir });
|
|
156
135
|
if (!testResult.success) {
|
|
157
136
|
return { success: false, output: combineOutput(testResult) };
|
|
158
137
|
}
|
|
159
138
|
|
|
160
|
-
// Start nginx
|
|
161
|
-
if (
|
|
139
|
+
// Start nginx
|
|
140
|
+
if (isWindows) {
|
|
162
141
|
const confPath = path.join(nginxDir, 'conf', 'nginx.conf');
|
|
163
142
|
const startCmd = `Start-Process -FilePath "${path.join(nginxDir, 'nginx.exe')}" -ArgumentList '-c','"${confPath}"' -WorkingDirectory "${nginxDir}" -WindowStyle Hidden`;
|
|
164
|
-
await run(startCmd, { timeout: 10000 });
|
|
143
|
+
await run(startCmd, { cwd: nginxDir, timeout: 10000 });
|
|
165
144
|
} else {
|
|
166
145
|
const result = await run('nginx', { cwd: nginxDir, timeout: 15000 });
|
|
167
146
|
if (!result.success) {
|
|
@@ -173,7 +152,7 @@ export async function start() {
|
|
|
173
152
|
await new Promise(r => setTimeout(r, 1500));
|
|
174
153
|
|
|
175
154
|
let running = false;
|
|
176
|
-
if (
|
|
155
|
+
if (isWindows) {
|
|
177
156
|
const check = await run('tasklist /FI "IMAGENAME eq nginx.exe" /NH');
|
|
178
157
|
running = check.success && check.stdout.toLowerCase().includes('nginx.exe');
|
|
179
158
|
} else {
|
|
@@ -185,11 +164,11 @@ export async function start() {
|
|
|
185
164
|
return { success: true, output: 'nginx started successfully' };
|
|
186
165
|
}
|
|
187
166
|
|
|
188
|
-
// Didn't start
|
|
189
|
-
const logPath =
|
|
167
|
+
// Didn't start — surface error log
|
|
168
|
+
const logPath = isWindows
|
|
190
169
|
? path.join(nginxDir, 'logs', 'error.log')
|
|
191
170
|
: '/var/log/nginx/error.log';
|
|
192
|
-
const logCmd =
|
|
171
|
+
const logCmd = isWindows
|
|
193
172
|
? `Get-Content -Tail 20 "${logPath}" -ErrorAction SilentlyContinue`
|
|
194
173
|
: `tail -n 20 "${logPath}" 2>/dev/null`;
|
|
195
174
|
const logResult = await run(logCmd);
|
|
@@ -201,13 +180,11 @@ export async function start() {
|
|
|
201
180
|
}
|
|
202
181
|
|
|
203
182
|
export async function stop() {
|
|
204
|
-
const
|
|
205
|
-
const
|
|
206
|
-
|
|
207
|
-
throw new NginxNotFoundError('nginx binary not found');
|
|
208
|
-
}
|
|
183
|
+
const nginxDir = getNginxDir();
|
|
184
|
+
const nginxExe = getNginxExe(nginxDir);
|
|
185
|
+
await assertNginxInstalled(nginxExe);
|
|
209
186
|
|
|
210
|
-
const result =
|
|
187
|
+
const result = isWindows
|
|
211
188
|
? await run('taskkill /f /IM nginx.exe')
|
|
212
189
|
: await run('nginx -s stop');
|
|
213
190
|
|
|
@@ -217,19 +194,12 @@ export async function stop() {
|
|
|
217
194
|
// ─── US3: Test Config ─────────────────────────────────────────────────────────
|
|
218
195
|
|
|
219
196
|
export async function test() {
|
|
220
|
-
const nginxExe = getNginxExe();
|
|
221
197
|
const nginxDir = getNginxDir();
|
|
222
|
-
const
|
|
223
|
-
|
|
224
|
-
throw new NginxNotFoundError('nginx binary not found');
|
|
225
|
-
}
|
|
198
|
+
const nginxExe = getNginxExe(nginxDir);
|
|
199
|
+
await assertNginxInstalled(nginxExe);
|
|
226
200
|
|
|
227
201
|
await ensureNginxInclude(nginxDir);
|
|
228
|
-
|
|
229
|
-
const testCmd = process.platform === 'win32'
|
|
230
|
-
? `${nginxExe} -c "${path.join(nginxDir, 'conf', 'nginx.conf')}" -t`
|
|
231
|
-
: `${nginxExe} -t`;
|
|
232
|
-
const result = await run(testCmd);
|
|
202
|
+
const result = await run(nginxTestCmd(nginxDir), { cwd: nginxDir });
|
|
233
203
|
return { success: result.success, output: combineOutput(result) };
|
|
234
204
|
}
|
|
235
205
|
|
|
@@ -274,9 +244,9 @@ export async function saveConfig(filename, content) {
|
|
|
274
244
|
await fs.mkdir(path.dirname(confPath), { recursive: true });
|
|
275
245
|
await fs.writeFile(confPath, content, 'utf8');
|
|
276
246
|
|
|
277
|
-
const nginxExe = getNginxExe();
|
|
247
|
+
const nginxExe = getNginxExe(nginxDir);
|
|
278
248
|
await ensureNginxInclude(nginxDir);
|
|
279
|
-
const result = await run(
|
|
249
|
+
const result = await run(nginxTestCmd(nginxDir), { cwd: nginxDir });
|
|
280
250
|
if (!result.success) {
|
|
281
251
|
if (hasBackup) {
|
|
282
252
|
await fs.copyFile(backupPath, confPath);
|
|
Binary file
|
|
Binary file
|