@factiii/stack 0.1.184 → 0.1.186
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/LICENSE +21 -21
- package/README.md +441 -441
- package/bin/stack +300 -300
- package/dist/cli/dev-sync.js +16 -16
- package/dist/cli/init.d.ts.map +1 -1
- package/dist/cli/init.js +9 -1
- package/dist/cli/init.js.map +1 -1
- package/dist/plugins/addons/auth/index.js +7 -7
- package/dist/plugins/addons/vercel/index.js +9 -9
- package/dist/plugins/addons/vercel/scanfix/config.js +10 -10
- package/dist/plugins/addons/vercel/scanfix/token.js +15 -15
- package/dist/plugins/approved.json +13 -13
- package/dist/plugins/pipelines/aws/index.js +12 -12
- package/dist/plugins/pipelines/aws/policies/bootstrap-policy.json +135 -135
- package/dist/plugins/pipelines/aws/prod.js +1 -1
- package/dist/plugins/pipelines/aws/scanfix/credentials.d.ts.map +1 -1
- package/dist/plugins/pipelines/aws/scanfix/credentials.js +11 -4
- package/dist/plugins/pipelines/aws/scanfix/credentials.js.map +1 -1
- package/dist/plugins/pipelines/factiii/prod.js +21 -21
- package/dist/plugins/pipelines/factiii/scanfix/bootstrap.d.ts.map +1 -1
- package/dist/plugins/pipelines/factiii/scanfix/bootstrap.js +10 -2
- package/dist/plugins/pipelines/factiii/scanfix/bootstrap.js.map +1 -1
- package/dist/plugins/pipelines/factiii/staging.js +23 -23
- package/dist/plugins/pipelines/factiii/workflows/stack-ci.yml +75 -75
- package/dist/plugins/pipelines/factiii/workflows/stack-cicd-prod.yml +73 -73
- package/dist/plugins/servers/amazon-linux/index.js +16 -16
- package/dist/plugins/servers/mac/index.js +12 -12
- package/dist/plugins/servers/mac/staging.js +2 -2
- package/dist/plugins/servers/ubuntu/index.js +23 -23
- package/dist/plugins/servers/windows/index.js +15 -15
- package/dist/scripts/generate-all.js +73 -73
- package/dist/utils/deployment-report.js +2 -2
- package/dist/utils/secret-prompts.js +34 -34
- package/dist/utils/ssh-helper.d.ts.map +1 -1
- package/dist/utils/ssh-helper.js +153 -25
- package/dist/utils/ssh-helper.js.map +1 -1
- package/dist/utils/template-generator.js +74 -74
- package/package.json +100 -93
|
@@ -138,16 +138,16 @@ class MacPlugin {
|
|
|
138
138
|
return Object.keys(config).length === 0;
|
|
139
139
|
}
|
|
140
140
|
static helpText = {
|
|
141
|
-
SSH: `
|
|
142
|
-
SSH private key for accessing the server.
|
|
143
|
-
|
|
144
|
-
Step 1: Generate a new SSH key pair (if needed):
|
|
145
|
-
ssh-keygen -t ed25519 -C "deploy-key" -f ~/.ssh/deploy_key
|
|
146
|
-
|
|
147
|
-
Step 2: Add PUBLIC key to server:
|
|
148
|
-
ssh-copy-id -i ~/.ssh/deploy_key.pub ubuntu@YOUR_HOST
|
|
149
|
-
|
|
150
|
-
Step 3: Paste the PRIVATE key below (multi-line, end with blank line):
|
|
141
|
+
SSH: `
|
|
142
|
+
SSH private key for accessing the server.
|
|
143
|
+
|
|
144
|
+
Step 1: Generate a new SSH key pair (if needed):
|
|
145
|
+
ssh-keygen -t ed25519 -C "deploy-key" -f ~/.ssh/deploy_key
|
|
146
|
+
|
|
147
|
+
Step 2: Add PUBLIC key to server:
|
|
148
|
+
ssh-copy-id -i ~/.ssh/deploy_key.pub ubuntu@YOUR_HOST
|
|
149
|
+
|
|
150
|
+
Step 3: Paste the PRIVATE key below (multi-line, end with blank line):
|
|
151
151
|
cat ~/.ssh/deploy_key`,
|
|
152
152
|
};
|
|
153
153
|
// ============================================================
|
|
@@ -238,8 +238,8 @@ class MacPlugin {
|
|
|
238
238
|
}
|
|
239
239
|
try {
|
|
240
240
|
const repoName = config.name ?? 'app';
|
|
241
|
-
await MacPlugin.sshExec(envConfig, `
|
|
242
|
-
cd ~/.factiii && docker compose stop ${repoName}-staging
|
|
241
|
+
await MacPlugin.sshExec(envConfig, `
|
|
242
|
+
cd ~/.factiii && docker compose stop ${repoName}-staging
|
|
243
243
|
`);
|
|
244
244
|
return { success: true, message: 'Staging containers stopped' };
|
|
245
245
|
}
|
|
@@ -291,7 +291,7 @@ async function writeEnvFile(envConfig, repoDir, environment, envVarsString) {
|
|
|
291
291
|
const escapedContent = envFileContent
|
|
292
292
|
.replace(/'/g, "'\\''")
|
|
293
293
|
.replace(/\n/g, '\\n');
|
|
294
|
-
await sshExecCommand(envConfig, `cat > ${repoDir}/${envFileName} << 'ENVEOF'
|
|
294
|
+
await sshExecCommand(envConfig, `cat > ${repoDir}/${envFileName} << 'ENVEOF'
|
|
295
295
|
${envFileContent}ENVEOF`);
|
|
296
296
|
}
|
|
297
297
|
}
|
|
@@ -347,7 +347,7 @@ async function createEnvFromStaging(envConfig, repoDir) {
|
|
|
347
347
|
console.log(' 📝 Created .env from .env.staging (with host port replacement)');
|
|
348
348
|
}
|
|
349
349
|
else {
|
|
350
|
-
await sshExecCommand(envConfig, `cat > ${envPath} << 'ENVEOF'
|
|
350
|
+
await sshExecCommand(envConfig, `cat > ${envPath} << 'ENVEOF'
|
|
351
351
|
${updatedContent}ENVEOF`);
|
|
352
352
|
console.log(' 📝 Created .env from .env.staging on remote server (with host port replacement)');
|
|
353
353
|
}
|
|
@@ -99,16 +99,16 @@ class UbuntuPlugin {
|
|
|
99
99
|
return false;
|
|
100
100
|
}
|
|
101
101
|
static helpText = {
|
|
102
|
-
SSH: `
|
|
103
|
-
SSH private key for accessing the Ubuntu server.
|
|
104
|
-
|
|
105
|
-
Step 1: Generate a new SSH key pair (if needed):
|
|
106
|
-
ssh-keygen -t ed25519 -C "deploy-key" -f ~/.ssh/deploy_key
|
|
107
|
-
|
|
108
|
-
Step 2: Add PUBLIC key to server:
|
|
109
|
-
ssh-copy-id -i ~/.ssh/deploy_key.pub ubuntu@YOUR_HOST
|
|
110
|
-
|
|
111
|
-
Step 3: Paste the PRIVATE key below (multi-line, end with blank line):
|
|
102
|
+
SSH: `
|
|
103
|
+
SSH private key for accessing the Ubuntu server.
|
|
104
|
+
|
|
105
|
+
Step 1: Generate a new SSH key pair (if needed):
|
|
106
|
+
ssh-keygen -t ed25519 -C "deploy-key" -f ~/.ssh/deploy_key
|
|
107
|
+
|
|
108
|
+
Step 2: Add PUBLIC key to server:
|
|
109
|
+
ssh-copy-id -i ~/.ssh/deploy_key.pub ubuntu@YOUR_HOST
|
|
110
|
+
|
|
111
|
+
Step 3: Paste the PRIVATE key below (multi-line, end with blank line):
|
|
112
112
|
cat ~/.ssh/deploy_key`,
|
|
113
113
|
};
|
|
114
114
|
// ============================================================
|
|
@@ -155,25 +155,25 @@ class UbuntuPlugin {
|
|
|
155
155
|
* Get the command to install Docker on Ubuntu
|
|
156
156
|
*/
|
|
157
157
|
static getDockerInstallCommand() {
|
|
158
|
-
return `
|
|
159
|
-
sudo apt-get update && \
|
|
160
|
-
sudo apt-get install -y ca-certificates curl gnupg && \
|
|
161
|
-
sudo install -m 0755 -d /etc/apt/keyrings && \
|
|
162
|
-
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg && \
|
|
163
|
-
sudo chmod a+r /etc/apt/keyrings/docker.gpg && \
|
|
164
|
-
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null && \
|
|
165
|
-
sudo apt-get update && \
|
|
166
|
-
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin && \
|
|
167
|
-
sudo usermod -aG docker $USER
|
|
158
|
+
return `
|
|
159
|
+
sudo apt-get update && \
|
|
160
|
+
sudo apt-get install -y ca-certificates curl gnupg && \
|
|
161
|
+
sudo install -m 0755 -d /etc/apt/keyrings && \
|
|
162
|
+
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg && \
|
|
163
|
+
sudo chmod a+r /etc/apt/keyrings/docker.gpg && \
|
|
164
|
+
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null && \
|
|
165
|
+
sudo apt-get update && \
|
|
166
|
+
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin && \
|
|
167
|
+
sudo usermod -aG docker $USER
|
|
168
168
|
`;
|
|
169
169
|
}
|
|
170
170
|
/**
|
|
171
171
|
* Get the command to install Node.js on Ubuntu
|
|
172
172
|
*/
|
|
173
173
|
static getNodeInstallCommand() {
|
|
174
|
-
return `
|
|
175
|
-
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash - && \
|
|
176
|
-
sudo apt-get install -y nodejs
|
|
174
|
+
return `
|
|
175
|
+
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash - && \
|
|
176
|
+
sudo apt-get install -y nodejs
|
|
177
177
|
`;
|
|
178
178
|
}
|
|
179
179
|
/**
|
|
@@ -99,12 +99,12 @@ class WindowsPlugin {
|
|
|
99
99
|
return false;
|
|
100
100
|
}
|
|
101
101
|
static helpText = {
|
|
102
|
-
SSH: `
|
|
103
|
-
SSH/RDP credentials for accessing the Windows server.
|
|
104
|
-
|
|
105
|
-
For SSH access, ensure OpenSSH Server is installed on Windows:
|
|
106
|
-
- Settings > Apps > Optional Features > Add a feature > OpenSSH Server
|
|
107
|
-
|
|
102
|
+
SSH: `
|
|
103
|
+
SSH/RDP credentials for accessing the Windows server.
|
|
104
|
+
|
|
105
|
+
For SSH access, ensure OpenSSH Server is installed on Windows:
|
|
106
|
+
- Settings > Apps > Optional Features > Add a feature > OpenSSH Server
|
|
107
|
+
|
|
108
108
|
For RDP access, use Remote Desktop Connection.`,
|
|
109
109
|
};
|
|
110
110
|
// ============================================================
|
|
@@ -182,11 +182,11 @@ class WindowsPlugin {
|
|
|
182
182
|
* Requires Docker Desktop or WSL2 with Docker
|
|
183
183
|
*/
|
|
184
184
|
static getDockerInstallCommand() {
|
|
185
|
-
return `
|
|
186
|
-
# Install Docker Desktop via Chocolatey
|
|
187
|
-
choco install docker-desktop -y
|
|
188
|
-
# Or install via winget
|
|
189
|
-
# winget install Docker.DockerDesktop
|
|
185
|
+
return `
|
|
186
|
+
# Install Docker Desktop via Chocolatey
|
|
187
|
+
choco install docker-desktop -y
|
|
188
|
+
# Or install via winget
|
|
189
|
+
# winget install Docker.DockerDesktop
|
|
190
190
|
`;
|
|
191
191
|
}
|
|
192
192
|
/**
|
|
@@ -205,10 +205,10 @@ class WindowsPlugin {
|
|
|
205
205
|
* Get the command to install Chocolatey (package manager)
|
|
206
206
|
*/
|
|
207
207
|
static getChocoInstallCommand() {
|
|
208
|
-
return `
|
|
209
|
-
Set-ExecutionPolicy Bypass -Scope Process -Force
|
|
210
|
-
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
|
|
211
|
-
iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
|
|
208
|
+
return `
|
|
209
|
+
Set-ExecutionPolicy Bypass -Scope Process -Force
|
|
210
|
+
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
|
|
211
|
+
iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
|
|
212
212
|
`;
|
|
213
213
|
}
|
|
214
214
|
// ============================================================
|
|
@@ -271,31 +271,31 @@ function generateNginx(allConfigs) {
|
|
|
271
271
|
return 0;
|
|
272
272
|
}
|
|
273
273
|
// Generate nginx config
|
|
274
|
-
let nginxConf = `# Auto-generated nginx configuration
|
|
275
|
-
# Generated by: npx stack (generate-all)
|
|
276
|
-
# Do not edit directly - modify stack.yml files and run: npx stack deploy
|
|
277
|
-
|
|
278
|
-
events {
|
|
279
|
-
worker_connections 1024;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
http {
|
|
283
|
-
include /etc/nginx/mime.types;
|
|
284
|
-
default_type application/octet-stream;
|
|
285
|
-
|
|
286
|
-
sendfile on;
|
|
287
|
-
keepalive_timeout 65;
|
|
288
|
-
client_max_body_size 100M;
|
|
289
|
-
|
|
290
|
-
# Logging
|
|
291
|
-
access_log /var/log/nginx/access.log;
|
|
292
|
-
error_log /var/log/nginx/error.log;
|
|
293
|
-
|
|
294
|
-
# Gzip
|
|
295
|
-
gzip on;
|
|
296
|
-
gzip_vary on;
|
|
297
|
-
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
|
|
298
|
-
|
|
274
|
+
let nginxConf = `# Auto-generated nginx configuration
|
|
275
|
+
# Generated by: npx stack (generate-all)
|
|
276
|
+
# Do not edit directly - modify stack.yml files and run: npx stack deploy
|
|
277
|
+
|
|
278
|
+
events {
|
|
279
|
+
worker_connections 1024;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
http {
|
|
283
|
+
include /etc/nginx/mime.types;
|
|
284
|
+
default_type application/octet-stream;
|
|
285
|
+
|
|
286
|
+
sendfile on;
|
|
287
|
+
keepalive_timeout 65;
|
|
288
|
+
client_max_body_size 100M;
|
|
289
|
+
|
|
290
|
+
# Logging
|
|
291
|
+
access_log /var/log/nginx/access.log;
|
|
292
|
+
error_log /var/log/nginx/error.log;
|
|
293
|
+
|
|
294
|
+
# Gzip
|
|
295
|
+
gzip on;
|
|
296
|
+
gzip_vary on;
|
|
297
|
+
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
|
|
298
|
+
|
|
299
299
|
`;
|
|
300
300
|
// ============================================================
|
|
301
301
|
// CRITICAL: HTTPS Certificate Paths
|
|
@@ -308,54 +308,54 @@ http {
|
|
|
308
308
|
for (const { domain, service, port } of routes) {
|
|
309
309
|
// Always generate HTTPS-capable config
|
|
310
310
|
// Certificates must exist before nginx can start (obtained via: npx stack fix --staging/--prod)
|
|
311
|
-
nginxConf += `
|
|
312
|
-
# ${service} - ${domain}
|
|
313
|
-
|
|
314
|
-
# HTTP - ACME challenge + redirect to HTTPS
|
|
315
|
-
server {
|
|
316
|
-
listen 80;
|
|
317
|
-
server_name ${domain};
|
|
318
|
-
|
|
319
|
-
# Allow certbot ACME challenge (for renewals)
|
|
320
|
-
location /.well-known/acme-challenge/ {
|
|
321
|
-
root /var/www/certbot;
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
# Redirect all other traffic to HTTPS
|
|
325
|
-
location / {
|
|
326
|
-
return 301 https://$server_name$request_uri;
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
# HTTPS - main server block
|
|
331
|
-
server {
|
|
332
|
-
listen 443 ssl;
|
|
333
|
-
http2 on;
|
|
334
|
-
server_name ${domain};
|
|
335
|
-
|
|
336
|
-
# SSL certificate paths (Let's Encrypt)
|
|
337
|
-
ssl_certificate /etc/letsencrypt/live/${domain}/fullchain.pem;
|
|
338
|
-
ssl_certificate_key /etc/letsencrypt/live/${domain}/privkey.pem;
|
|
339
|
-
|
|
340
|
-
# SSL security settings
|
|
341
|
-
ssl_protocols TLSv1.2 TLSv1.3;
|
|
342
|
-
ssl_prefer_server_ciphers on;
|
|
343
|
-
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256;
|
|
344
|
-
ssl_session_cache shared:SSL:10m;
|
|
345
|
-
ssl_session_timeout 10m;
|
|
346
|
-
|
|
347
|
-
location / {
|
|
348
|
-
proxy_pass http://${service}:${port};
|
|
349
|
-
proxy_http_version 1.1;
|
|
350
|
-
proxy_set_header Upgrade $http_upgrade;
|
|
351
|
-
proxy_set_header Connection 'upgrade';
|
|
352
|
-
proxy_set_header Host $host;
|
|
353
|
-
proxy_cache_bypass $http_upgrade;
|
|
354
|
-
proxy_set_header X-Real-IP $remote_addr;
|
|
355
|
-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
356
|
-
proxy_set_header X-Forwarded-Proto $scheme;
|
|
357
|
-
}
|
|
358
|
-
}
|
|
311
|
+
nginxConf += `
|
|
312
|
+
# ${service} - ${domain}
|
|
313
|
+
|
|
314
|
+
# HTTP - ACME challenge + redirect to HTTPS
|
|
315
|
+
server {
|
|
316
|
+
listen 80;
|
|
317
|
+
server_name ${domain};
|
|
318
|
+
|
|
319
|
+
# Allow certbot ACME challenge (for renewals)
|
|
320
|
+
location /.well-known/acme-challenge/ {
|
|
321
|
+
root /var/www/certbot;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
# Redirect all other traffic to HTTPS
|
|
325
|
+
location / {
|
|
326
|
+
return 301 https://$server_name$request_uri;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
# HTTPS - main server block
|
|
331
|
+
server {
|
|
332
|
+
listen 443 ssl;
|
|
333
|
+
http2 on;
|
|
334
|
+
server_name ${domain};
|
|
335
|
+
|
|
336
|
+
# SSL certificate paths (Let's Encrypt)
|
|
337
|
+
ssl_certificate /etc/letsencrypt/live/${domain}/fullchain.pem;
|
|
338
|
+
ssl_certificate_key /etc/letsencrypt/live/${domain}/privkey.pem;
|
|
339
|
+
|
|
340
|
+
# SSL security settings
|
|
341
|
+
ssl_protocols TLSv1.2 TLSv1.3;
|
|
342
|
+
ssl_prefer_server_ciphers on;
|
|
343
|
+
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256;
|
|
344
|
+
ssl_session_cache shared:SSL:10m;
|
|
345
|
+
ssl_session_timeout 10m;
|
|
346
|
+
|
|
347
|
+
location / {
|
|
348
|
+
proxy_pass http://${service}:${port};
|
|
349
|
+
proxy_http_version 1.1;
|
|
350
|
+
proxy_set_header Upgrade $http_upgrade;
|
|
351
|
+
proxy_set_header Connection 'upgrade';
|
|
352
|
+
proxy_set_header Host $host;
|
|
353
|
+
proxy_cache_bypass $http_upgrade;
|
|
354
|
+
proxy_set_header X-Real-IP $remote_addr;
|
|
355
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
356
|
+
proxy_set_header X-Forwarded-Proto $scheme;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
359
|
`;
|
|
360
360
|
}
|
|
361
361
|
nginxConf += `}\n`;
|
|
@@ -154,8 +154,8 @@ function formatDeploymentReport(data) {
|
|
|
154
154
|
function formatWorkflowSummary(data) {
|
|
155
155
|
const report = formatDeploymentReport(data);
|
|
156
156
|
// Workflow summaries support markdown, so we can enhance it
|
|
157
|
-
return `\`\`\`
|
|
158
|
-
${report}
|
|
157
|
+
return `\`\`\`
|
|
158
|
+
${report}
|
|
159
159
|
\`\`\``;
|
|
160
160
|
}
|
|
161
161
|
/**
|
|
@@ -64,16 +64,16 @@ const SECRET_METADATA = {
|
|
|
64
64
|
STAGING_SSH: {
|
|
65
65
|
type: 'ssh_key',
|
|
66
66
|
description: 'SSH private key for accessing staging server',
|
|
67
|
-
helpText: `
|
|
68
|
-
Step 1: Generate a new SSH key pair:
|
|
69
|
-
ssh-keygen -t ed25519 -C "staging-deploy" -f ~/.ssh/staging_deploy
|
|
70
|
-
|
|
71
|
-
Step 2: Add PUBLIC key to your staging server:
|
|
72
|
-
ssh-copy-id -i ~/.ssh/staging_deploy.pub ubuntu@YOUR_HOST
|
|
73
|
-
|
|
74
|
-
(HOST is configured in stack.yml → environments.staging.host)
|
|
75
|
-
|
|
76
|
-
Step 3: Paste the PRIVATE key below (multi-line, end with blank line):
|
|
67
|
+
helpText: `
|
|
68
|
+
Step 1: Generate a new SSH key pair:
|
|
69
|
+
ssh-keygen -t ed25519 -C "staging-deploy" -f ~/.ssh/staging_deploy
|
|
70
|
+
|
|
71
|
+
Step 2: Add PUBLIC key to your staging server:
|
|
72
|
+
ssh-copy-id -i ~/.ssh/staging_deploy.pub ubuntu@YOUR_HOST
|
|
73
|
+
|
|
74
|
+
(HOST is configured in stack.yml → environments.staging.host)
|
|
75
|
+
|
|
76
|
+
Step 3: Paste the PRIVATE key below (multi-line, end with blank line):
|
|
77
77
|
cat ~/.ssh/staging_deploy`,
|
|
78
78
|
validation: (value) => {
|
|
79
79
|
if (!value || value.trim().length === 0) {
|
|
@@ -91,16 +91,16 @@ const SECRET_METADATA = {
|
|
|
91
91
|
PROD_SSH: {
|
|
92
92
|
type: 'ssh_key',
|
|
93
93
|
description: 'SSH private key for accessing production server',
|
|
94
|
-
helpText: `
|
|
95
|
-
Step 1: Generate a new SSH key pair:
|
|
96
|
-
ssh-keygen -t ed25519 -C "production-deploy" -f ~/.ssh/prod_deploy
|
|
97
|
-
|
|
98
|
-
Step 2: Add PUBLIC key to your production server:
|
|
99
|
-
ssh-copy-id -i ~/.ssh/prod_deploy.pub ubuntu@YOUR_HOST
|
|
100
|
-
|
|
101
|
-
(HOST is configured in stack.yml → environments.production.host)
|
|
102
|
-
|
|
103
|
-
Step 3: Paste the PRIVATE key below (multi-line, end with blank line):
|
|
94
|
+
helpText: `
|
|
95
|
+
Step 1: Generate a new SSH key pair:
|
|
96
|
+
ssh-keygen -t ed25519 -C "production-deploy" -f ~/.ssh/prod_deploy
|
|
97
|
+
|
|
98
|
+
Step 2: Add PUBLIC key to your production server:
|
|
99
|
+
ssh-copy-id -i ~/.ssh/prod_deploy.pub ubuntu@YOUR_HOST
|
|
100
|
+
|
|
101
|
+
(HOST is configured in stack.yml → environments.production.host)
|
|
102
|
+
|
|
103
|
+
Step 3: Paste the PRIVATE key below (multi-line, end with blank line):
|
|
104
104
|
cat ~/.ssh/prod_deploy`,
|
|
105
105
|
validation: (value) => {
|
|
106
106
|
if (!value || value.trim().length === 0) {
|
|
@@ -118,14 +118,14 @@ const SECRET_METADATA = {
|
|
|
118
118
|
AWS_SECRET_ACCESS_KEY: {
|
|
119
119
|
type: 'aws_secret',
|
|
120
120
|
description: 'AWS Secret Access Key (the only secret AWS value)',
|
|
121
|
-
helpText: `
|
|
122
|
-
Get from AWS Console: IAM → Users → Security credentials
|
|
123
|
-
|
|
124
|
-
This is shown only once when you create the key.
|
|
125
|
-
If lost, you must create a new key pair.
|
|
126
|
-
|
|
127
|
-
Note: AWS_ACCESS_KEY_ID and AWS_REGION go in stack.yml (not secrets)
|
|
128
|
-
|
|
121
|
+
helpText: `
|
|
122
|
+
Get from AWS Console: IAM → Users → Security credentials
|
|
123
|
+
|
|
124
|
+
This is shown only once when you create the key.
|
|
125
|
+
If lost, you must create a new key pair.
|
|
126
|
+
|
|
127
|
+
Note: AWS_ACCESS_KEY_ID and AWS_REGION go in stack.yml (not secrets)
|
|
128
|
+
|
|
129
129
|
Enter AWS Secret Access Key:`,
|
|
130
130
|
validation: (value) => {
|
|
131
131
|
if (!value || value.trim().length === 0) {
|
|
@@ -143,12 +143,12 @@ const SECRET_METADATA = {
|
|
|
143
143
|
VERCEL_TOKEN: {
|
|
144
144
|
type: 'api_token',
|
|
145
145
|
description: 'Vercel API Token for deployments',
|
|
146
|
-
helpText: `
|
|
147
|
-
Get your token from: https://vercel.com/account/tokens
|
|
148
|
-
Create a new token with:
|
|
149
|
-
- Scope: Full Account (or specific team)
|
|
150
|
-
- Expiration: No Expiration (or custom)
|
|
151
|
-
|
|
146
|
+
helpText: `
|
|
147
|
+
Get your token from: https://vercel.com/account/tokens
|
|
148
|
+
Create a new token with:
|
|
149
|
+
- Scope: Full Account (or specific team)
|
|
150
|
+
- Expiration: No Expiration (or custom)
|
|
151
|
+
|
|
152
152
|
Enter Vercel API Token:`,
|
|
153
153
|
validation: (value) => {
|
|
154
154
|
if (!value || value.trim().length === 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ssh-helper.d.ts","sourceRoot":"","sources":["../../src/utils/ssh-helper.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAKjF;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,CAU5E;AA+BD;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAS9E;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CA4BlF;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,aAAa,GACpB,iBAAiB,GAAG,IAAI,CAc1B;
|
|
1
|
+
{"version":3,"file":"ssh-helper.d.ts","sourceRoot":"","sources":["../../src/utils/ssh-helper.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAKjF;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,CAU5E;AA+BD;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAS9E;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CA4BlF;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,aAAa,GACpB,iBAAiB,GAAG,IAAI,CAc1B;AA+aD;;;;;;;;;;;;;GAaG;AACH,wBAAsB,uBAAuB,CAC3C,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAswB/D;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,OAAO,CAC3B,SAAS,EAAE,iBAAiB,EAC5B,OAAO,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,KAAK,EACb,MAAM,CAAC,EAAE,aAAa,EACtB,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,CAAC,CAqMjB"}
|
package/dist/utils/ssh-helper.js
CHANGED
|
@@ -305,25 +305,54 @@ async function autoSetupSshKey(stage, host, user, config, rootDir) {
|
|
|
305
305
|
}
|
|
306
306
|
// Copy public key to server
|
|
307
307
|
console.log(' Copying public key to ' + user + '@' + host + '...');
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
308
|
+
if (process.platform === 'win32') {
|
|
309
|
+
// Windows: ssh-copy-id is not available — use SSH to pipe the public key
|
|
310
|
+
console.log(' Enter password when prompted by SSH:');
|
|
311
|
+
console.log('');
|
|
312
|
+
try {
|
|
313
|
+
const pubKeyContent = fs.readFileSync(pubKeyPath, 'utf8').trim();
|
|
314
|
+
const addKeyCmd = 'mkdir -p ~/.ssh && chmod 700 ~/.ssh && echo "' + pubKeyContent + '" >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys && sort -u -o ~/.ssh/authorized_keys ~/.ssh/authorized_keys';
|
|
315
|
+
const copyResult = (0, child_process_1.spawnSync)('ssh', [
|
|
316
|
+
'-o', 'StrictHostKeyChecking=no',
|
|
317
|
+
'-o', 'ConnectTimeout=10',
|
|
318
|
+
user + '@' + host,
|
|
319
|
+
addKeyCmd,
|
|
320
|
+
], {
|
|
321
|
+
stdio: 'inherit',
|
|
322
|
+
timeout: 60000,
|
|
323
|
+
});
|
|
324
|
+
if (copyResult.status !== 0) {
|
|
325
|
+
console.log(' [!] Failed to copy public key to server');
|
|
326
|
+
return null;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
catch (e) {
|
|
330
|
+
console.log(' [!] Failed to copy public key: ' + (e instanceof Error ? e.message : String(e)));
|
|
321
331
|
return null;
|
|
322
332
|
}
|
|
323
333
|
}
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
334
|
+
else {
|
|
335
|
+
// Linux/Mac: use ssh-copy-id
|
|
336
|
+
console.log(' Enter password when prompted:');
|
|
337
|
+
console.log('');
|
|
338
|
+
try {
|
|
339
|
+
const copyResult = (0, child_process_1.spawnSync)('ssh-copy-id', [
|
|
340
|
+
'-i', pubKeyPath,
|
|
341
|
+
'-o', 'StrictHostKeyChecking=no',
|
|
342
|
+
user + '@' + host,
|
|
343
|
+
], {
|
|
344
|
+
stdio: 'inherit',
|
|
345
|
+
timeout: 60000,
|
|
346
|
+
});
|
|
347
|
+
if (copyResult.status !== 0) {
|
|
348
|
+
console.log(' [!] ssh-copy-id failed');
|
|
349
|
+
return null;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
catch (e) {
|
|
353
|
+
console.log(' [!] ssh-copy-id failed: ' + (e instanceof Error ? e.message : String(e)));
|
|
354
|
+
return null;
|
|
355
|
+
}
|
|
327
356
|
}
|
|
328
357
|
// Fix remote permissions
|
|
329
358
|
try {
|
|
@@ -822,15 +851,32 @@ async function sshRemoteFactiiiCommand(stage, config, command, rootDir) {
|
|
|
822
851
|
}
|
|
823
852
|
console.log(' SSH (password): ' + user + '@' + host + ' → npx stack ' + command);
|
|
824
853
|
const pwStart = Date.now();
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
'
|
|
829
|
-
'
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
854
|
+
let pwResult;
|
|
855
|
+
if (process.platform === 'win32') {
|
|
856
|
+
// Windows: no sshpass — use interactive SSH so user types password
|
|
857
|
+
console.log(' You will be prompted for the password by SSH:');
|
|
858
|
+
console.log('');
|
|
859
|
+
pwResult = (0, child_process_1.spawnSync)('ssh', [
|
|
860
|
+
'-tt',
|
|
861
|
+
'-o', 'StrictHostKeyChecking=no',
|
|
862
|
+
'-o', 'ConnectTimeout=10',
|
|
863
|
+
'-o', 'ServerAliveInterval=60',
|
|
864
|
+
'-o', 'ServerAliveCountMax=5',
|
|
865
|
+
user + '@' + host,
|
|
866
|
+
pwRemoteCommand,
|
|
867
|
+
], { encoding: 'utf8', stdio: 'inherit', timeout: 600000 });
|
|
868
|
+
}
|
|
869
|
+
else {
|
|
870
|
+
pwResult = (0, child_process_1.spawnSync)('sshpass', [
|
|
871
|
+
'-p', password, 'ssh', '-tt',
|
|
872
|
+
'-o', 'StrictHostKeyChecking=no',
|
|
873
|
+
'-o', 'ConnectTimeout=10',
|
|
874
|
+
'-o', 'ServerAliveInterval=60',
|
|
875
|
+
'-o', 'ServerAliveCountMax=5',
|
|
876
|
+
user + '@' + host,
|
|
877
|
+
pwRemoteCommand,
|
|
878
|
+
], { encoding: 'utf8', stdio: 'inherit', timeout: 600000 });
|
|
879
|
+
}
|
|
834
880
|
console.log(' SSH completed in ' + Math.floor((Date.now() - pwStart) / 1000) + 's');
|
|
835
881
|
return {
|
|
836
882
|
success: pwResult.status === 0,
|
|
@@ -1054,6 +1100,68 @@ async function sshRemoteFactiiiCommand(stage, config, command, rootDir) {
|
|
|
1054
1100
|
console.log(' Falling back to SSH password auth...');
|
|
1055
1101
|
console.log(' SSH (password): ' + user + '@' + host + ' → npx stack ' + command);
|
|
1056
1102
|
const startTime = Date.now();
|
|
1103
|
+
// On Windows, sshpass is not available — use interactive SSH so user types password
|
|
1104
|
+
if (process.platform === 'win32') {
|
|
1105
|
+
console.log(' You will be prompted for the password by SSH:');
|
|
1106
|
+
console.log('');
|
|
1107
|
+
const result = (0, child_process_1.spawnSync)('ssh', [
|
|
1108
|
+
'-tt',
|
|
1109
|
+
'-o', 'StrictHostKeyChecking=no',
|
|
1110
|
+
'-o', 'ConnectTimeout=10',
|
|
1111
|
+
'-o', 'ServerAliveInterval=60',
|
|
1112
|
+
'-o', 'ServerAliveCountMax=5',
|
|
1113
|
+
user + '@' + host,
|
|
1114
|
+
remoteCommand,
|
|
1115
|
+
], {
|
|
1116
|
+
encoding: 'utf8',
|
|
1117
|
+
stdio: 'inherit',
|
|
1118
|
+
timeout: 600000,
|
|
1119
|
+
});
|
|
1120
|
+
const elapsed = Math.floor((Date.now() - startTime) / 1000);
|
|
1121
|
+
console.log(' SSH completed in ' + elapsed + 's');
|
|
1122
|
+
if (result.status === 0) {
|
|
1123
|
+
// Connection worked — set up SSH key for future so password isn't needed again
|
|
1124
|
+
console.log(' Setting up SSH key for future connections...');
|
|
1125
|
+
await autoSetupSshKey(stage, host, user, config, rootDir);
|
|
1126
|
+
return { success: true, stdout: '', stderr: '' };
|
|
1127
|
+
}
|
|
1128
|
+
// Interactive SSH failed — try auto key setup as last resort
|
|
1129
|
+
console.log(' [!] SSH connection failed');
|
|
1130
|
+
console.log(' Setting up SSH key auth for future connections...');
|
|
1131
|
+
const autoKeyResult = await autoSetupSshKey(stage, host, user, config, rootDir);
|
|
1132
|
+
if (autoKeyResult) {
|
|
1133
|
+
console.log(' Retrying command with SSH key...');
|
|
1134
|
+
console.log(' SSH (key): ' + user + '@' + host + ' → npx stack ' + command);
|
|
1135
|
+
const retryStart = Date.now();
|
|
1136
|
+
const retryResult = (0, child_process_1.spawnSync)('ssh', [
|
|
1137
|
+
'-tt',
|
|
1138
|
+
'-i', autoKeyResult,
|
|
1139
|
+
'-o', 'StrictHostKeyChecking=no',
|
|
1140
|
+
'-o', 'ConnectTimeout=10',
|
|
1141
|
+
'-o', 'ServerAliveInterval=60',
|
|
1142
|
+
'-o', 'ServerAliveCountMax=5',
|
|
1143
|
+
user + '@' + host,
|
|
1144
|
+
remoteCommand,
|
|
1145
|
+
], {
|
|
1146
|
+
encoding: 'utf8',
|
|
1147
|
+
stdio: 'inherit',
|
|
1148
|
+
timeout: 600000,
|
|
1149
|
+
});
|
|
1150
|
+
const retryElapsed = Math.floor((Date.now() - retryStart) / 1000);
|
|
1151
|
+
console.log(' SSH completed in ' + retryElapsed + 's');
|
|
1152
|
+
return {
|
|
1153
|
+
success: retryResult.status === 0,
|
|
1154
|
+
stdout: '',
|
|
1155
|
+
stderr: retryResult.status !== 0 ? 'SSH command exited with code ' + retryResult.status : '',
|
|
1156
|
+
};
|
|
1157
|
+
}
|
|
1158
|
+
return {
|
|
1159
|
+
success: false,
|
|
1160
|
+
stdout: '',
|
|
1161
|
+
stderr: 'SSH connection failed. Check password and server accessibility.',
|
|
1162
|
+
};
|
|
1163
|
+
}
|
|
1164
|
+
// Linux/Mac: use sshpass for non-interactive password auth
|
|
1057
1165
|
const result = (0, child_process_1.spawnSync)('sshpass', [
|
|
1058
1166
|
'-p', password,
|
|
1059
1167
|
'ssh',
|
|
@@ -1298,6 +1406,26 @@ async function sshExec(envConfig, command, stage, config, rootDir) {
|
|
|
1298
1406
|
}
|
|
1299
1407
|
}
|
|
1300
1408
|
if (password) {
|
|
1409
|
+
if (process.platform === 'win32') {
|
|
1410
|
+
// Windows: no sshpass — use interactive SSH (stdio: 'inherit' so user can type password)
|
|
1411
|
+
const result = (0, child_process_1.spawnSync)('ssh', [
|
|
1412
|
+
'-tt',
|
|
1413
|
+
'-o', 'StrictHostKeyChecking=no',
|
|
1414
|
+
'-o', 'ConnectTimeout=10',
|
|
1415
|
+
'-o', 'ServerAliveInterval=60',
|
|
1416
|
+
'-o', 'ServerAliveCountMax=5',
|
|
1417
|
+
user + '@' + host,
|
|
1418
|
+
command,
|
|
1419
|
+
], {
|
|
1420
|
+
encoding: 'utf8',
|
|
1421
|
+
stdio: 'inherit',
|
|
1422
|
+
});
|
|
1423
|
+
if (result.status !== 0) {
|
|
1424
|
+
throw new Error('SSH command failed with exit code ' + result.status);
|
|
1425
|
+
}
|
|
1426
|
+
return '';
|
|
1427
|
+
}
|
|
1428
|
+
// Linux/Mac: use sshpass
|
|
1301
1429
|
const result = (0, child_process_1.spawnSync)('sshpass', [
|
|
1302
1430
|
'-p', password,
|
|
1303
1431
|
'ssh',
|