1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
#!/usr/bin/env node
const fs = require("fs");
const path = require("path");
function getAllFiles(dirPath, basePath = dirPath) {
let entries = fs.readdirSync(dirPath, { withFileTypes: true });
let files = [];
for (let entry of entries) {
const fullPath = path.join(dirPath, entry.name);
if (entry.isDirectory()) {
files = files.concat(getAllFiles(fullPath, basePath));
} else {
files.push(path.relative(basePath, fullPath));
}
}
return files;
}
function pack(inputPath, outputPath, options = {}) {
const stats = fs.statSync(inputPath);
const archive = {
type: "marcwel",
version: "v0.69.420",
compressionRatio: "∞:1",
createdAt: new Date().toISOString(),
files: [],
};
if (!inputPath) {
throw new Error("❌ Input path is required. Skill Issue.");
}
if (!outputPath) {
const defaultName = path.basename(inputPath).replace(/\.[^/.]+$/, "");
outputPath = `${defaultName}.marcwel`;
}
if (stats.isFile()) {
const content = fs.readFileSync(inputPath);
archive.files.push({
path: path.basename(inputPath),
content: content.toString("base64"),
});
console.log(`📦 Marcweled file: ${inputPath}`);
} else if (stats.isDirectory()) {
const files = getAllFiles(inputPath);
for (let file of files) {
const filePath = path.join(inputPath, file);
const content = fs.readFileSync(filePath);
archive.files.push({
path: file,
content: content.toString("base64"),
});
}
console.log(
`📦 Marcweled folder: ${inputPath} (${archive.files.length} files)`
);
} else {
throw new Error("❌ Input must be a file or folder. Skill Issue.");
}
if (options.inflate) {
const { blob, inflateKB } = generateBloat();
archive.SuperVeryImportantData = blob;
console.log(`💣 Injected ${inflateKB}KB of lorem bloat into the archive`);
}
const json = JSON.stringify(archive, null, 2);
fs.writeFileSync(outputPath, json);
console.log(`✅ Marcweled into ${outputPath}`);
}
function unpack(archivePath, outputFolder) {
if (!archivePath) {
throw new Error("❌ Archive path is required. Skill Issue.");
}
const data = fs.readFileSync(archivePath, "utf-8");
const archive = JSON.parse(data);
if (archive.type !== "marcwel") {
throw new Error("❌ Not a valid file. Skill Issue.");
}
if (!outputFolder) {
const defaultName = path.basename(archivePath).replace(/\.[^/.]+$/, "");
const isSingleFile =
archive.files.length === 1 && !archive.files[0].path.includes("/");
outputFolder = isSingleFile ? "." : `./${defaultName}`;
}
for (let file of archive.files) {
const outputPath = path.join(outputFolder, file.path);
fs.mkdirSync(path.dirname(outputPath), { recursive: true });
fs.writeFileSync(outputPath, Buffer.from(file.content, "base64"));
}
console.log(
`✅ Unmarcweled ${archive.files.length} files to ${outputFolder}`
);
}
function generateBloat(minKB = 5, maxKB = 500) {
const inflateKB = Math.floor(Math.random() * (maxKB - minKB + 1)) + minKB;
const inflateSize = inflateKB * 1024;
const lorem =
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. ".repeat(100);
const blob = {};
while (Buffer.byteLength(JSON.stringify(blob)) < inflateSize) {
const key = "data_" + Math.random().toString(36).slice(2, 10);
blob[key] = lorem + Math.random().toString(36).repeat(50);
}
return { blob, inflateKB };
}
const args = process.argv.slice(2);
const command = args[0];
const input = args[1];
const output = args[2];
const flags = args.slice(3);
const shouldInflate = flags.includes("--inflate");
try {
if (command === "pack") {
pack(input, output, { inflate: shouldInflate });
} else if (command === "unpack") {
unpack(input, output);
} else if (command === "version") {
console.log("MarcwelArchive Version v0.69.420");
} else {
console.log("Usage:");
console.log(" marcwel version");
console.log(" marcwel pack <folder> <output.marcwel> [--inflate]");
console.log(" marcwel unpack <archive.marcwel> <output-folder>");
}
} catch (err) {
console.error("❌ Skill Issue");
process.exit(1);
}
|