@mndrk/agx 1.4.22 → 1.4.23
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/index.js +5 -2
- package/lib/cli/runCli.js +21 -7
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -7191,8 +7191,11 @@ async function checkOnboarding() {
|
|
|
7191
7191
|
const setCrontab = (content) => {
|
|
7192
7192
|
const tmp = path.join(os.tmpdir(), `agx-crontab-${Date.now()}`);
|
|
7193
7193
|
fs.writeFileSync(tmp, content);
|
|
7194
|
-
|
|
7195
|
-
|
|
7194
|
+
try {
|
|
7195
|
+
execSync(`crontab ${tmp}`, { timeout: 5000 });
|
|
7196
|
+
} finally {
|
|
7197
|
+
try { fs.unlinkSync(tmp); } catch {}
|
|
7198
|
+
}
|
|
7196
7199
|
};
|
|
7197
7200
|
|
|
7198
7201
|
// Check if auto-update is enabled
|
package/lib/cli/runCli.js
CHANGED
|
@@ -2299,8 +2299,11 @@ async function checkOnboarding() {
|
|
|
2299
2299
|
const setCrontab = (content) => {
|
|
2300
2300
|
const tmp = path.join(os.tmpdir(), `agx-crontab-${Date.now()}`);
|
|
2301
2301
|
fs.writeFileSync(tmp, content);
|
|
2302
|
-
|
|
2303
|
-
|
|
2302
|
+
try {
|
|
2303
|
+
execSync(`crontab ${tmp}`, { timeout: 5000 });
|
|
2304
|
+
} finally {
|
|
2305
|
+
try { fs.unlinkSync(tmp); } catch {}
|
|
2306
|
+
}
|
|
2304
2307
|
};
|
|
2305
2308
|
|
|
2306
2309
|
// Check if auto-update is enabled
|
|
@@ -2321,9 +2324,15 @@ async function checkOnboarding() {
|
|
|
2321
2324
|
}
|
|
2322
2325
|
const crontab = getCrontab();
|
|
2323
2326
|
const newLine = `${CRON_SCHEDULE} ${CRON_CMD} ${CRON_MARKER}\n`;
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
+
try {
|
|
2328
|
+
setCrontab(crontab + newLine);
|
|
2329
|
+
console.log(`${c.green}✓${c.reset} Auto-update enabled (daily at 3am)`);
|
|
2330
|
+
console.log(` ${c.dim}To disable: agx update --off${c.reset}`);
|
|
2331
|
+
} catch (err) {
|
|
2332
|
+
console.log(`${c.yellow}⚠${c.reset} Could not modify crontab automatically.`);
|
|
2333
|
+
console.log(`\n Add this line to your crontab (${c.cyan}crontab -e${c.reset}):\n`);
|
|
2334
|
+
console.log(` ${c.dim}${CRON_SCHEDULE} ${CRON_CMD}${c.reset}\n`);
|
|
2335
|
+
}
|
|
2327
2336
|
process.exit(0);
|
|
2328
2337
|
}
|
|
2329
2338
|
|
|
@@ -2334,8 +2343,13 @@ async function checkOnboarding() {
|
|
|
2334
2343
|
process.exit(0);
|
|
2335
2344
|
}
|
|
2336
2345
|
const lines = crontab.split('\n').filter(l => !l.includes(CRON_MARKER));
|
|
2337
|
-
|
|
2338
|
-
|
|
2346
|
+
try {
|
|
2347
|
+
setCrontab(lines.join('\n'));
|
|
2348
|
+
console.log(`${c.green}✓${c.reset} Auto-update disabled`);
|
|
2349
|
+
} catch (err) {
|
|
2350
|
+
console.log(`${c.yellow}⚠${c.reset} Could not modify crontab automatically.`);
|
|
2351
|
+
console.log(`\n Remove the agx-auto-update line from your crontab (${c.cyan}crontab -e${c.reset})\n`);
|
|
2352
|
+
}
|
|
2339
2353
|
process.exit(0);
|
|
2340
2354
|
}
|
|
2341
2355
|
|