slackhive 0.1.7 → 0.1.9
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 +43 -3
- 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,42 @@ function runDockerBuild(cwd, displayDir) {
|
|
|
228
247
|
console.log(' ' + chalk_1.default.green('✓') + ' ' + trimmed.replace(/^✔\s*/, '').replace(/Container /, ''));
|
|
229
248
|
}
|
|
230
249
|
};
|
|
250
|
+
const startTime = Date.now();
|
|
251
|
+
const frames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
|
|
252
|
+
let frameIdx = 0;
|
|
253
|
+
let currentStep = 'Building images';
|
|
254
|
+
const fallbackInterval = setInterval(() => {
|
|
255
|
+
const elapsed = Math.floor((Date.now() - startTime) / 1000);
|
|
256
|
+
const frame = frames[frameIdx++ % frames.length];
|
|
257
|
+
process.stdout.write(`\r\x1b[K ${chalk_1.default.hex('#D97757')(frame)} ${currentStep} ${chalk_1.default.gray(elapsed + 's')}`);
|
|
258
|
+
}, 80);
|
|
231
259
|
let stdoutBuf = '';
|
|
232
260
|
let stderrBuf = '';
|
|
233
261
|
proc.stdout.on('data', (chunk) => {
|
|
234
262
|
stdoutBuf += chunk.toString();
|
|
235
263
|
const lines = stdoutBuf.split('\n');
|
|
236
264
|
stdoutBuf = lines.pop() ?? '';
|
|
237
|
-
lines.forEach(
|
|
265
|
+
lines.forEach(line => {
|
|
266
|
+
processLine(line);
|
|
267
|
+
// Update current step label from build output
|
|
268
|
+
const m = /\[([^\]]+)\] (.+)/.exec(line.trim());
|
|
269
|
+
if (m)
|
|
270
|
+
currentStep = `${m[1]} — ${m[2].slice(0, 40)}`;
|
|
271
|
+
});
|
|
238
272
|
});
|
|
239
273
|
proc.stderr.on('data', (chunk) => {
|
|
240
274
|
stderrBuf += chunk.toString();
|
|
241
275
|
const lines = stderrBuf.split('\n');
|
|
242
276
|
stderrBuf = lines.pop() ?? '';
|
|
243
|
-
lines.forEach(
|
|
277
|
+
lines.forEach(line => {
|
|
278
|
+
processLine(line);
|
|
279
|
+
const m = /\[([^\]]+)\] (.+)/.exec(line.trim());
|
|
280
|
+
if (m)
|
|
281
|
+
currentStep = `${m[1]} — ${m[2].slice(0, 40)}`;
|
|
282
|
+
});
|
|
244
283
|
});
|
|
245
284
|
proc.on('close', (code) => {
|
|
285
|
+
clearInterval(fallbackInterval);
|
|
246
286
|
process.stdout.write('\r\x1b[K');
|
|
247
287
|
if (code === 0) {
|
|
248
288
|
console.log(' ' + chalk_1.default.green('✓') + ' All services started');
|