ramm 0.0.14 → 0.0.15

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/ramm.js CHANGED
@@ -339,6 +339,27 @@ var createAndAddSshKey = async (pathToKey, comment, context) => {
339
339
  debug(`Key is: ${pubKey}`);
340
340
  await addSshKey(pubKey, context);
341
341
  };
342
+ // src/cron.ts
343
+ var createCron = async ({
344
+ time,
345
+ pathToFile
346
+ }) => {
347
+ const constructedLine = `${time} ${pathToFile}`;
348
+ const tempFile = `/tmp/cron_${new Date().getTime().toString()}`;
349
+ const { output: cronConfig } = await execCommand("crontab -l");
350
+ let newCronConfig = cronConfig;
351
+ if (cronConfig.includes(constructedLine)) {
352
+ return;
353
+ }
354
+ if (cronConfig.includes(pathToFile)) {
355
+ newCronConfig = cronConfig.split(`
356
+ `).filter((str) => !str.includes(pathToFile)).join(`
357
+ `);
358
+ }
359
+ await writeFile(tempFile, newCronConfig);
360
+ await execCommand(`crontab ${tempFile}`);
361
+ await execCommand(`rm ${tempFile}`);
362
+ };
342
363
  export {
343
364
  writeIfNew,
344
365
  writeFile,
@@ -354,6 +375,7 @@ export {
354
375
  execCommand,
355
376
  execBySsh,
356
377
  debugBlock,
378
+ createCron,
357
379
  createAndAddSshKey,
358
380
  copyFilesBySsh,
359
381
  addNftPodmanRule,
@@ -0,0 +1,4 @@
1
+ export declare const createCron: ({ time, pathToFile, }: {
2
+ time: string;
3
+ pathToFile: string;
4
+ }) => Promise<void>;
@@ -10,3 +10,4 @@ export { setupNftable } from "./nft.ts";
10
10
  export { writeIfNew, writeFile } from "./files.ts";
11
11
  export { createAndAddSshKey, getServerFingerprintBySsh, addKeyToHostConfig, } from "./ssh.ts";
12
12
  export { normalizePath } from "./path.ts";
13
+ export { createCron } from "./cron.ts";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ramm",
3
3
  "type": "module",
4
- "version": "0.0.14",
4
+ "version": "0.0.15",
5
5
  "scripts": {
6
6
  "build": "bun build ./src/ramm.ts --target bun --outdir ./dist && cp ./src/bun.sh ./dist/bun.sh && bun run types",
7
7
  "types": "tsc --project tsconfig.types.json"