slackhive 0.1.7 → 0.1.8
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/dist/commands/init.js +36 -1
- package/package.json +1 -1
package/dist/commands/init.js
CHANGED
|
@@ -149,7 +149,26 @@ async function init(opts) {
|
|
|
149
149
|
else {
|
|
150
150
|
console.log(chalk_1.default.bold.hex('#D97757')(' [3/4]') + chalk_1.default.bold(' Configure environment'));
|
|
151
151
|
console.log('');
|
|
152
|
-
|
|
152
|
+
// Check if existing .env is missing required keys
|
|
153
|
+
const envContents = (0, fs_1.existsSync)(envPath) ? require('fs').readFileSync(envPath, 'utf-8') : '';
|
|
154
|
+
const missingKeys = [];
|
|
155
|
+
if (!envContents.includes('REDIS_PASSWORD='))
|
|
156
|
+
missingKeys.push('REDIS_PASSWORD');
|
|
157
|
+
if (!envContents.includes('AUTH_SECRET='))
|
|
158
|
+
missingKeys.push('AUTH_SECRET');
|
|
159
|
+
if (missingKeys.length > 0) {
|
|
160
|
+
console.log(chalk_1.default.yellow(` ⚠ .env is missing: ${missingKeys.join(', ')} — patching...`));
|
|
161
|
+
let patch = '';
|
|
162
|
+
if (!envContents.includes('REDIS_PASSWORD='))
|
|
163
|
+
patch += `\nREDIS_PASSWORD=${randomSecret().slice(0, 16)}\n`;
|
|
164
|
+
if (!envContents.includes('AUTH_SECRET='))
|
|
165
|
+
patch += `AUTH_SECRET=${randomSecret()}\n`;
|
|
166
|
+
require('fs').appendFileSync(envPath, patch);
|
|
167
|
+
console.log(chalk_1.default.green(' ✓') + ' .env patched');
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
console.log(chalk_1.default.yellow(' ⚡ .env already exists — skipping configuration'));
|
|
171
|
+
}
|
|
153
172
|
console.log('');
|
|
154
173
|
}
|
|
155
174
|
// ── Step 4: Build & start ─────────────────────────────────────────────────
|
|
@@ -228,21 +247,37 @@ function runDockerBuild(cwd, displayDir) {
|
|
|
228
247
|
console.log(' ' + chalk_1.default.green('✓') + ' ' + trimmed.replace(/^✔\s*/, '').replace(/Container /, ''));
|
|
229
248
|
}
|
|
230
249
|
};
|
|
250
|
+
// Fallback animated spinner shown when no build lines are detected
|
|
251
|
+
const startTime = Date.now();
|
|
252
|
+
const frames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
|
|
253
|
+
let frameIdx = 0;
|
|
254
|
+
let lastActivity = Date.now();
|
|
255
|
+
const fallbackInterval = setInterval(() => {
|
|
256
|
+
const elapsed = Math.floor((Date.now() - startTime) / 1000);
|
|
257
|
+
const idle = Date.now() - lastActivity > 3000;
|
|
258
|
+
if (idle) {
|
|
259
|
+
const frame = frames[frameIdx++ % frames.length];
|
|
260
|
+
process.stdout.write(`\r\x1b[K ${chalk_1.default.hex('#D97757')(frame)} Building... ${chalk_1.default.gray(elapsed + 's elapsed')}`);
|
|
261
|
+
}
|
|
262
|
+
}, 100);
|
|
231
263
|
let stdoutBuf = '';
|
|
232
264
|
let stderrBuf = '';
|
|
233
265
|
proc.stdout.on('data', (chunk) => {
|
|
266
|
+
lastActivity = Date.now();
|
|
234
267
|
stdoutBuf += chunk.toString();
|
|
235
268
|
const lines = stdoutBuf.split('\n');
|
|
236
269
|
stdoutBuf = lines.pop() ?? '';
|
|
237
270
|
lines.forEach(processLine);
|
|
238
271
|
});
|
|
239
272
|
proc.stderr.on('data', (chunk) => {
|
|
273
|
+
lastActivity = Date.now();
|
|
240
274
|
stderrBuf += chunk.toString();
|
|
241
275
|
const lines = stderrBuf.split('\n');
|
|
242
276
|
stderrBuf = lines.pop() ?? '';
|
|
243
277
|
lines.forEach(processLine);
|
|
244
278
|
});
|
|
245
279
|
proc.on('close', (code) => {
|
|
280
|
+
clearInterval(fallbackInterval);
|
|
246
281
|
process.stdout.write('\r\x1b[K');
|
|
247
282
|
if (code === 0) {
|
|
248
283
|
console.log(' ' + chalk_1.default.green('✓') + ' All services started');
|