ramm 0.0.7 → 0.0.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/ramm.js +29 -2
- package/dist/types/files.d.ts +1 -1
- package/dist/types/path.d.ts +1 -0
- package/dist/types/ramm.d.ts +1 -0
- package/package.json +1 -1
package/dist/ramm.js
CHANGED
|
@@ -217,7 +217,20 @@ var addNftPodmanRule = async () => {
|
|
|
217
217
|
await execCommand(`nft add rule inet ramm forward iifname != @podman_interfaces jump ${localNftChainName}`);
|
|
218
218
|
};
|
|
219
219
|
// src/files.ts
|
|
220
|
-
import { appendFile } from "fs/promises";
|
|
220
|
+
import { appendFile, exists } from "fs/promises";
|
|
221
|
+
|
|
222
|
+
// src/path.ts
|
|
223
|
+
import { homedir } from "os";
|
|
224
|
+
import { join } from "path";
|
|
225
|
+
function normalizePath(rawFilePath) {
|
|
226
|
+
let finalFilePath = rawFilePath.trim();
|
|
227
|
+
if (finalFilePath.startsWith("~/")) {
|
|
228
|
+
finalFilePath = join(homedir(), finalFilePath.slice(2));
|
|
229
|
+
}
|
|
230
|
+
return finalFilePath;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// src/files.ts
|
|
221
234
|
var finalizeWithNewline = (str) => {
|
|
222
235
|
if (str.at(-1) !== `
|
|
223
236
|
`) {
|
|
@@ -226,6 +239,14 @@ var finalizeWithNewline = (str) => {
|
|
|
226
239
|
}
|
|
227
240
|
return str;
|
|
228
241
|
};
|
|
242
|
+
var createDir = async (str) => {
|
|
243
|
+
const dirname = str.split("/").slice(0, -1).join("/");
|
|
244
|
+
const exist = await exists(dirname);
|
|
245
|
+
if (exist) {
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
await execCommand(`mkdir -p ${dirname}`);
|
|
249
|
+
};
|
|
229
250
|
var checkStrInFile = async (filePath, str) => {
|
|
230
251
|
const file = Bun.file(filePath);
|
|
231
252
|
if (!await file.exists()) {
|
|
@@ -237,10 +258,15 @@ var checkStrInFile = async (filePath, str) => {
|
|
|
237
258
|
}
|
|
238
259
|
return false;
|
|
239
260
|
};
|
|
240
|
-
var writeIfNew = async (
|
|
261
|
+
var writeIfNew = async (rawFilePath, str) => {
|
|
262
|
+
const filePath = normalizePath(rawFilePath);
|
|
263
|
+
await createDir(filePath);
|
|
241
264
|
if (await checkStrInFile(filePath, str)) {
|
|
242
265
|
return;
|
|
243
266
|
}
|
|
267
|
+
if (!await Bun.file(filePath).exists()) {
|
|
268
|
+
await execCommand(`touch ${filePath}`);
|
|
269
|
+
}
|
|
244
270
|
await appendFile(filePath, finalizeWithNewline(str));
|
|
245
271
|
};
|
|
246
272
|
// src/ssh.ts
|
|
@@ -288,6 +314,7 @@ export {
|
|
|
288
314
|
runPodmanContainerService,
|
|
289
315
|
runPodmanContainer,
|
|
290
316
|
restartSystemdService,
|
|
317
|
+
normalizePath,
|
|
291
318
|
installSystemPackage,
|
|
292
319
|
installPodman,
|
|
293
320
|
installBun,
|
package/dist/types/files.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const writeIfNew: (
|
|
1
|
+
export declare const writeIfNew: (rawFilePath: string, str: string) => Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function normalizePath(rawFilePath: string): string;
|
package/dist/types/ramm.d.ts
CHANGED
package/package.json
CHANGED