@edenapp/genesis 0.4.1 → 0.5.1
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/README.md +4 -4
- package/dist/bundler.d.ts +26 -73
- package/dist/bundler.d.ts.map +1 -1
- package/dist/bundler.js +453 -500
- package/dist/bundler.js.map +1 -1
- package/dist/bundler.test.js +30 -41
- package/dist/bundler.test.js.map +1 -1
- package/dist/cli.js +22 -28
- package/dist/cli.js.map +1 -1
- package/dist/compression.js +9 -19
- package/dist/compression.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/bundler.js
CHANGED
|
@@ -15,564 +15,517 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) ||
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
35
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
27
|
};
|
|
38
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
const
|
|
29
|
+
exports.executeBuild = executeBuild;
|
|
30
|
+
exports.validateManifest = validateManifest;
|
|
31
|
+
exports.verifyFiles = verifyFiles;
|
|
32
|
+
exports.bundle = bundle;
|
|
33
|
+
exports.getInfo = getInfo;
|
|
34
|
+
exports.extract = extract;
|
|
35
|
+
const node_child_process_1 = require("node:child_process");
|
|
36
|
+
const crypto = __importStar(require("node:crypto"));
|
|
37
|
+
const node_fs_1 = require("node:fs");
|
|
38
|
+
const fs = __importStar(require("node:fs/promises"));
|
|
39
|
+
const path = __importStar(require("node:path"));
|
|
40
|
+
const node_util_1 = require("node:util");
|
|
47
41
|
const cli_progress_1 = __importDefault(require("cli-progress"));
|
|
42
|
+
const tar = __importStar(require("tar"));
|
|
48
43
|
const compression_1 = require("./compression");
|
|
49
|
-
const execAsync = (0,
|
|
44
|
+
const execAsync = (0, node_util_1.promisify)(node_child_process_1.exec);
|
|
50
45
|
// Archive format version for forward compatibility
|
|
51
46
|
const ARCHIVE_FORMAT_VERSION = 1;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
47
|
+
const compressor = compression_1.DEFAULT_COMPRESSOR;
|
|
48
|
+
let isInitialized = false;
|
|
49
|
+
async function initCompressor() {
|
|
50
|
+
if (isInitialized)
|
|
51
|
+
return;
|
|
52
|
+
await compressor.initialize();
|
|
53
|
+
isInitialized = true;
|
|
54
|
+
}
|
|
55
|
+
function isRemoteEntry(entry) {
|
|
56
|
+
return !!entry && /^https?:\/\//i.test(entry);
|
|
57
|
+
}
|
|
58
|
+
function calculateChecksum(data) {
|
|
59
|
+
return crypto.createHash("sha256").update(data).digest("hex");
|
|
60
|
+
}
|
|
61
|
+
async function executeBuild(appDirectory, manifest, verbose) {
|
|
62
|
+
if (!manifest.build?.command) {
|
|
63
|
+
return { success: true }; // No build command defined, skip
|
|
65
64
|
}
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
try {
|
|
66
|
+
const buildCwd = manifest.build.cwd
|
|
67
|
+
? path.join(appDirectory, manifest.build.cwd)
|
|
68
|
+
: appDirectory;
|
|
69
|
+
if (verbose) {
|
|
70
|
+
console.log(`🔨 Running build command: ${manifest.build.command}`);
|
|
71
|
+
console.log(` Working directory: ${buildCwd}`);
|
|
72
|
+
}
|
|
73
|
+
const { stdout, stderr } = await execAsync(manifest.build.command, {
|
|
74
|
+
cwd: buildCwd,
|
|
75
|
+
env: { ...process.env },
|
|
76
|
+
});
|
|
77
|
+
if (verbose && stdout) {
|
|
78
|
+
console.log(` ${stdout.trim()}`);
|
|
79
|
+
}
|
|
80
|
+
if (stderr && verbose) {
|
|
81
|
+
console.log(` ${stderr.trim()}`);
|
|
82
|
+
}
|
|
83
|
+
if (verbose) {
|
|
84
|
+
console.log("✓ Build completed successfully");
|
|
85
|
+
}
|
|
86
|
+
return { success: true };
|
|
68
87
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
88
|
+
catch (error) {
|
|
89
|
+
return {
|
|
90
|
+
success: false,
|
|
91
|
+
error: `Build failed: ${error.message}`,
|
|
92
|
+
};
|
|
74
93
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
94
|
+
}
|
|
95
|
+
async function validateManifest(manifestPath) {
|
|
96
|
+
const errors = [];
|
|
97
|
+
try {
|
|
98
|
+
const content = await fs.readFile(manifestPath, "utf-8");
|
|
99
|
+
const manifest = JSON.parse(content);
|
|
100
|
+
// Required fields
|
|
101
|
+
if (!manifest.id)
|
|
102
|
+
errors.push("Missing required field: id");
|
|
103
|
+
if (!manifest.name)
|
|
104
|
+
errors.push("Missing required field: name");
|
|
105
|
+
if (!manifest.version)
|
|
106
|
+
errors.push("Missing required field: version");
|
|
107
|
+
// Validate ID format
|
|
108
|
+
if (manifest.id && !/^[a-z0-9.-]+$/.test(manifest.id)) {
|
|
109
|
+
errors.push("Invalid ID format. Use lowercase letters, numbers, dots, and hyphens only.");
|
|
110
|
+
}
|
|
111
|
+
// Backend validation (optional, but ensure entry if provided)
|
|
112
|
+
if (manifest.backend && !manifest.backend.entry) {
|
|
113
|
+
errors.push("Missing required field: backend.entry");
|
|
114
|
+
}
|
|
115
|
+
// Frontend validation (optional, but entry required if frontend exists)
|
|
116
|
+
if (manifest.frontend && !manifest.frontend.entry) {
|
|
117
|
+
errors.push("Missing required field: frontend.entry");
|
|
81
118
|
}
|
|
119
|
+
else if (manifest.frontend &&
|
|
120
|
+
!isRemoteEntry(manifest.frontend.entry) &&
|
|
121
|
+
manifest.frontend.entry.startsWith("http")) {
|
|
122
|
+
errors.push("Invalid frontend.entry URL");
|
|
123
|
+
}
|
|
124
|
+
// Must have at least frontend or backend
|
|
125
|
+
if (!manifest.frontend && !manifest.backend) {
|
|
126
|
+
errors.push("App must have at least a frontend or backend entry");
|
|
127
|
+
}
|
|
128
|
+
return {
|
|
129
|
+
valid: errors.length === 0,
|
|
130
|
+
errors,
|
|
131
|
+
manifest: errors.length === 0 ? manifest : undefined,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
catch (error) {
|
|
135
|
+
errors.push(`Failed to read/parse manifest: ${error.message}`);
|
|
136
|
+
return { valid: false, errors };
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
async function verifyFiles(appDirectory, manifest) {
|
|
140
|
+
const errors = [];
|
|
141
|
+
// Check backend entry if defined
|
|
142
|
+
if (manifest.backend?.entry) {
|
|
143
|
+
const backendPath = path.join(appDirectory, manifest.backend.entry);
|
|
82
144
|
try {
|
|
83
|
-
|
|
84
|
-
? path.join(appDirectory, manifest.build.cwd)
|
|
85
|
-
: appDirectory;
|
|
86
|
-
if (verbose) {
|
|
87
|
-
console.log(`🔨 Running build command: ${manifest.build.command}`);
|
|
88
|
-
console.log(` Working directory: ${buildCwd}`);
|
|
89
|
-
}
|
|
90
|
-
const { stdout, stderr } = await execAsync(manifest.build.command, {
|
|
91
|
-
cwd: buildCwd,
|
|
92
|
-
env: { ...process.env },
|
|
93
|
-
});
|
|
94
|
-
if (verbose && stdout) {
|
|
95
|
-
console.log(` ${stdout.trim()}`);
|
|
96
|
-
}
|
|
97
|
-
if (stderr && verbose) {
|
|
98
|
-
console.log(` ${stderr.trim()}`);
|
|
99
|
-
}
|
|
100
|
-
if (verbose) {
|
|
101
|
-
console.log("✓ Build completed successfully");
|
|
102
|
-
}
|
|
103
|
-
return { success: true };
|
|
145
|
+
await fs.access(backendPath);
|
|
104
146
|
}
|
|
105
|
-
catch
|
|
106
|
-
|
|
107
|
-
success: false,
|
|
108
|
-
error: `Build failed: ${error.message}`,
|
|
109
|
-
};
|
|
147
|
+
catch {
|
|
148
|
+
errors.push(`Backend entry file not found: ${manifest.backend.entry}`);
|
|
110
149
|
}
|
|
111
150
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
static async validateManifest(manifestPath) {
|
|
116
|
-
const errors = [];
|
|
151
|
+
// Check frontend entry if defined and not a remote URL
|
|
152
|
+
if (manifest.frontend?.entry && !isRemoteEntry(manifest.frontend.entry)) {
|
|
153
|
+
const frontendPath = path.join(appDirectory, manifest.frontend.entry);
|
|
117
154
|
try {
|
|
118
|
-
|
|
119
|
-
const manifest = JSON.parse(content);
|
|
120
|
-
// Required fields
|
|
121
|
-
if (!manifest.id)
|
|
122
|
-
errors.push("Missing required field: id");
|
|
123
|
-
if (!manifest.name)
|
|
124
|
-
errors.push("Missing required field: name");
|
|
125
|
-
if (!manifest.version)
|
|
126
|
-
errors.push("Missing required field: version");
|
|
127
|
-
// Validate ID format
|
|
128
|
-
if (manifest.id && !/^[a-z0-9\.\-]+$/.test(manifest.id)) {
|
|
129
|
-
errors.push("Invalid ID format. Use lowercase letters, numbers, dots, and hyphens only.");
|
|
130
|
-
}
|
|
131
|
-
// Backend validation (optional, but ensure entry if provided)
|
|
132
|
-
if (manifest.backend && !manifest.backend.entry) {
|
|
133
|
-
errors.push("Missing required field: backend.entry");
|
|
134
|
-
}
|
|
135
|
-
// Frontend validation (optional, but entry required if frontend exists)
|
|
136
|
-
if (manifest.frontend && !manifest.frontend.entry) {
|
|
137
|
-
errors.push("Missing required field: frontend.entry");
|
|
138
|
-
}
|
|
139
|
-
else if (manifest.frontend &&
|
|
140
|
-
!this.isRemoteEntry(manifest.frontend.entry) &&
|
|
141
|
-
manifest.frontend.entry.startsWith("http")) {
|
|
142
|
-
errors.push("Invalid frontend.entry URL");
|
|
143
|
-
}
|
|
144
|
-
// Must have at least frontend or backend
|
|
145
|
-
if (!manifest.frontend && !manifest.backend) {
|
|
146
|
-
errors.push("App must have at least a frontend or backend entry");
|
|
147
|
-
}
|
|
148
|
-
return {
|
|
149
|
-
valid: errors.length === 0,
|
|
150
|
-
errors,
|
|
151
|
-
manifest: errors.length === 0 ? manifest : undefined,
|
|
152
|
-
};
|
|
155
|
+
await fs.access(frontendPath);
|
|
153
156
|
}
|
|
154
|
-
catch
|
|
155
|
-
errors.push(`
|
|
156
|
-
return { valid: false, errors };
|
|
157
|
+
catch {
|
|
158
|
+
errors.push(`Frontend entry file not found: ${manifest.frontend.entry}`);
|
|
157
159
|
}
|
|
158
160
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
// Check backend entry if defined
|
|
165
|
-
if (manifest.backend?.entry) {
|
|
166
|
-
const backendPath = path.join(appDirectory, manifest.backend.entry);
|
|
167
|
-
try {
|
|
168
|
-
await fs.access(backendPath);
|
|
169
|
-
}
|
|
170
|
-
catch {
|
|
171
|
-
errors.push(`Backend entry file not found: ${manifest.backend.entry}`);
|
|
172
|
-
}
|
|
161
|
+
// Check icon if specified (warn but don't fail)
|
|
162
|
+
if (manifest.icon) {
|
|
163
|
+
const iconPath = path.join(appDirectory, manifest.icon);
|
|
164
|
+
try {
|
|
165
|
+
await fs.access(iconPath);
|
|
173
166
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
const frontendPath = path.join(appDirectory, manifest.frontend.entry);
|
|
178
|
-
try {
|
|
179
|
-
await fs.access(frontendPath);
|
|
180
|
-
}
|
|
181
|
-
catch {
|
|
182
|
-
errors.push(`Frontend entry file not found: ${manifest.frontend.entry}`);
|
|
183
|
-
}
|
|
167
|
+
catch {
|
|
168
|
+
// Icon is optional, so just warn in verbose mode
|
|
169
|
+
// Don't add to errors array
|
|
184
170
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
171
|
+
}
|
|
172
|
+
return { valid: errors.length === 0, errors };
|
|
173
|
+
}
|
|
174
|
+
function shouldExcludeFile(filePath, manifest) {
|
|
175
|
+
// Check if this path is explicitly included via manifest
|
|
176
|
+
if (manifest?.include) {
|
|
177
|
+
for (const includePath of manifest.include) {
|
|
178
|
+
// Normalize paths for comparison
|
|
179
|
+
const normalizedInclude = includePath.replace(/\\/g, "/");
|
|
180
|
+
const normalizedFile = filePath.replace(/\\/g, "/");
|
|
181
|
+
// Check if the file path starts with or equals the include path
|
|
182
|
+
if (normalizedFile === normalizedInclude ||
|
|
183
|
+
normalizedFile.startsWith(`${normalizedInclude}/`)) {
|
|
184
|
+
return false; // Don't exclude - explicitly included
|
|
194
185
|
}
|
|
195
186
|
}
|
|
196
|
-
return { valid: errors.length === 0, errors };
|
|
197
187
|
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
//
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
188
|
+
const excludePatterns = [
|
|
189
|
+
// Dependencies
|
|
190
|
+
/^node_modules\//,
|
|
191
|
+
/^node_modules$/,
|
|
192
|
+
// Source files (we only want the built output)
|
|
193
|
+
/^src\//,
|
|
194
|
+
/^src$/,
|
|
195
|
+
// Config files
|
|
196
|
+
/^tsconfig\.json$/,
|
|
197
|
+
/^tsconfig\..+\.json$/,
|
|
198
|
+
/^vite\.config\..+$/,
|
|
199
|
+
/^\.eslintrc/,
|
|
200
|
+
/^\.prettierrc/,
|
|
201
|
+
/^\.gitignore$/,
|
|
202
|
+
/^\.git\//,
|
|
203
|
+
/^\.DS_Store$/,
|
|
204
|
+
// Lock files
|
|
205
|
+
/^package-lock\.json$/,
|
|
206
|
+
/^pnpm-lock\.yaml$/,
|
|
207
|
+
/^yarn\.lock$/,
|
|
208
|
+
// Build artifacts that shouldn't be included
|
|
209
|
+
/^\.vite\//,
|
|
210
|
+
/^\.cache\//,
|
|
211
|
+
// Test files
|
|
212
|
+
/^__tests__\//,
|
|
213
|
+
/\.test\.[jt]sx?$/,
|
|
214
|
+
/\.spec\.[jt]sx?$/,
|
|
215
|
+
];
|
|
216
|
+
return excludePatterns.some((pattern) => pattern.test(filePath));
|
|
217
|
+
}
|
|
218
|
+
async function extractToDirectory(appDirectory, targetDir, manifest, verbose) {
|
|
219
|
+
const resolvedTarget = path.resolve(targetDir);
|
|
220
|
+
if (verbose)
|
|
221
|
+
console.log(`📁 Copying files to: ${resolvedTarget}`);
|
|
222
|
+
// Ensure target directory exists
|
|
223
|
+
await fs.mkdir(resolvedTarget, { recursive: true });
|
|
224
|
+
// Copy all files from the app directory (excluding development files)
|
|
225
|
+
const files = await fs.readdir(appDirectory, { recursive: true });
|
|
226
|
+
let copiedCount = 0;
|
|
227
|
+
let skippedCount = 0;
|
|
228
|
+
for (const file of files) {
|
|
229
|
+
const fileStr = file;
|
|
230
|
+
// Skip excluded files
|
|
231
|
+
if (shouldExcludeFile(fileStr, manifest)) {
|
|
232
|
+
skippedCount++;
|
|
233
|
+
continue;
|
|
234
|
+
}
|
|
235
|
+
const sourcePath = path.join(appDirectory, fileStr);
|
|
236
|
+
const stat = await fs.stat(sourcePath);
|
|
237
|
+
if (stat.isFile()) {
|
|
238
|
+
const targetPath = path.join(resolvedTarget, fileStr);
|
|
239
|
+
const targetFileDir = path.dirname(targetPath);
|
|
240
|
+
// Ensure subdirectory exists
|
|
241
|
+
await fs.mkdir(targetFileDir, { recursive: true });
|
|
242
|
+
// Copy file
|
|
243
|
+
await fs.copyFile(sourcePath, targetPath);
|
|
244
|
+
copiedCount++;
|
|
245
|
+
if (verbose)
|
|
246
|
+
console.log(` + ${fileStr}`);
|
|
214
247
|
}
|
|
215
|
-
const excludePatterns = [
|
|
216
|
-
// Dependencies
|
|
217
|
-
/^node_modules\//,
|
|
218
|
-
/^node_modules$/,
|
|
219
|
-
// Source files (we only want the built output)
|
|
220
|
-
/^src\//,
|
|
221
|
-
/^src$/,
|
|
222
|
-
// Config files
|
|
223
|
-
/^tsconfig\.json$/,
|
|
224
|
-
/^tsconfig\..+\.json$/,
|
|
225
|
-
/^vite\.config\..+$/,
|
|
226
|
-
/^\.eslintrc/,
|
|
227
|
-
/^\.prettierrc/,
|
|
228
|
-
/^\.gitignore$/,
|
|
229
|
-
/^\.git\//,
|
|
230
|
-
/^\.DS_Store$/,
|
|
231
|
-
// Lock files
|
|
232
|
-
/^package-lock\.json$/,
|
|
233
|
-
/^pnpm-lock\.yaml$/,
|
|
234
|
-
/^yarn\.lock$/,
|
|
235
|
-
// Build artifacts that shouldn't be included
|
|
236
|
-
/^\.vite\//,
|
|
237
|
-
/^\.cache\//,
|
|
238
|
-
// Test files
|
|
239
|
-
/^__tests__\//,
|
|
240
|
-
/\.test\.[jt]sx?$/,
|
|
241
|
-
/\.spec\.[jt]sx?$/,
|
|
242
|
-
];
|
|
243
|
-
return excludePatterns.some((pattern) => pattern.test(filePath));
|
|
244
248
|
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
if (stat.isFile()) {
|
|
268
|
-
const targetPath = path.join(resolvedTarget, fileStr);
|
|
269
|
-
const targetFileDir = path.dirname(targetPath);
|
|
270
|
-
// Ensure subdirectory exists
|
|
271
|
-
await fs.mkdir(targetFileDir, { recursive: true });
|
|
272
|
-
// Copy file
|
|
273
|
-
await fs.copyFile(sourcePath, targetPath);
|
|
274
|
-
copiedCount++;
|
|
275
|
-
if (verbose)
|
|
276
|
-
console.log(` + ${fileStr}`);
|
|
277
|
-
}
|
|
249
|
+
if (verbose) {
|
|
250
|
+
console.log(`✓ Files copied to: ${resolvedTarget}`);
|
|
251
|
+
console.log(` Copied: ${copiedCount} files, Skipped: ${skippedCount} (dev files)`);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
async function createArchive(appDirectory, manifest, outputPath, verbose, compressionLevel = 11) {
|
|
255
|
+
await initCompressor();
|
|
256
|
+
const finalOutputPath = outputPath ||
|
|
257
|
+
path.join(process.cwd(), `${manifest.id}-${manifest.version}.edenite`);
|
|
258
|
+
// Create temporary tar file
|
|
259
|
+
const tempTarPath = `${finalOutputPath}.tmp.tar`;
|
|
260
|
+
if (verbose)
|
|
261
|
+
console.log("📦 Creating TAR archive...");
|
|
262
|
+
let progressBar = null;
|
|
263
|
+
// Get file list for progress tracking (excluding development files)
|
|
264
|
+
const allFiles = await fs.readdir(appDirectory, { recursive: true });
|
|
265
|
+
const fileList = [];
|
|
266
|
+
for (const file of allFiles) {
|
|
267
|
+
const fileStr = file;
|
|
268
|
+
// Skip excluded files
|
|
269
|
+
if (shouldExcludeFile(fileStr, manifest)) {
|
|
270
|
+
continue;
|
|
278
271
|
}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
272
|
+
const filePath = path.join(appDirectory, fileStr);
|
|
273
|
+
const stat = await fs.stat(filePath);
|
|
274
|
+
if (stat.isFile()) {
|
|
275
|
+
fileList.push(fileStr);
|
|
282
276
|
}
|
|
283
277
|
}
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
278
|
+
if (verbose && fileList.length > 50) {
|
|
279
|
+
progressBar = new cli_progress_1.default.SingleBar({
|
|
280
|
+
format: " Progress |{bar}| {percentage}% | {value}/{total} files",
|
|
281
|
+
barCompleteChar: "\u2588",
|
|
282
|
+
barIncompleteChar: "\u2591",
|
|
283
|
+
hideCursor: true,
|
|
284
|
+
});
|
|
285
|
+
progressBar.start(fileList.length, 0);
|
|
286
|
+
}
|
|
287
|
+
let processedFiles = 0;
|
|
288
|
+
// Create TAR archive
|
|
289
|
+
await tar.create({
|
|
290
|
+
file: tempTarPath,
|
|
291
|
+
cwd: appDirectory,
|
|
292
|
+
gzip: false,
|
|
293
|
+
portable: true,
|
|
294
|
+
filter: (entryPath, stat) => {
|
|
295
|
+
if (verbose && progressBar) {
|
|
296
|
+
processedFiles++;
|
|
297
|
+
progressBar.update(processedFiles);
|
|
304
298
|
}
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
if (stat.isFile()) {
|
|
308
|
-
fileList.push(fileStr);
|
|
299
|
+
else if (verbose) {
|
|
300
|
+
console.log(` + ${entryPath}`);
|
|
309
301
|
}
|
|
302
|
+
return true;
|
|
303
|
+
},
|
|
304
|
+
}, fileList);
|
|
305
|
+
if (progressBar) {
|
|
306
|
+
progressBar.stop();
|
|
307
|
+
}
|
|
308
|
+
if (verbose)
|
|
309
|
+
console.log("🗜️ Compressing with Zstandard...");
|
|
310
|
+
// Create temporary file for compressed output
|
|
311
|
+
const tempCompressedPath = `${tempTarPath}.zst`;
|
|
312
|
+
// Compress with configured compressor using streaming to disk
|
|
313
|
+
const { checksum } = await compressor.compressFileStreaming(tempTarPath, tempCompressedPath, compressionLevel);
|
|
314
|
+
// Create metadata
|
|
315
|
+
const metadata = {
|
|
316
|
+
version: ARCHIVE_FORMAT_VERSION,
|
|
317
|
+
checksum,
|
|
318
|
+
created: new Date().toISOString(),
|
|
319
|
+
manifest,
|
|
320
|
+
};
|
|
321
|
+
// Combine metadata + compressed data
|
|
322
|
+
// Format: [4 bytes metadata length][metadata JSON][compressed stream]
|
|
323
|
+
const metadataJson = JSON.stringify(metadata);
|
|
324
|
+
const metadataBuffer = Buffer.from(metadataJson, "utf-8");
|
|
325
|
+
const metadataLength = Buffer.alloc(4);
|
|
326
|
+
metadataLength.writeUInt32BE(metadataBuffer.length, 0);
|
|
327
|
+
const finalWriteStream = (0, node_fs_1.createWriteStream)(finalOutputPath);
|
|
328
|
+
// Write metadata length and buffer
|
|
329
|
+
finalWriteStream.write(metadataLength);
|
|
330
|
+
finalWriteStream.write(metadataBuffer);
|
|
331
|
+
// Stream compressed content to final file
|
|
332
|
+
const compressedReadStream = (0, node_fs_1.createReadStream)(tempCompressedPath);
|
|
333
|
+
await new Promise((resolve, reject) => {
|
|
334
|
+
compressedReadStream.pipe(finalWriteStream);
|
|
335
|
+
compressedReadStream.on("error", reject);
|
|
336
|
+
finalWriteStream.on("error", reject);
|
|
337
|
+
finalWriteStream.on("finish", resolve);
|
|
338
|
+
});
|
|
339
|
+
// Get stats for logging
|
|
340
|
+
const tarStats = await fs.stat(tempTarPath);
|
|
341
|
+
const finalStats = await fs.stat(finalOutputPath);
|
|
342
|
+
// Clean up temp files
|
|
343
|
+
await fs.unlink(tempTarPath);
|
|
344
|
+
await fs.unlink(tempCompressedPath);
|
|
345
|
+
if (verbose) {
|
|
346
|
+
const originalSize = tarStats.size;
|
|
347
|
+
const finalSize = finalStats.size;
|
|
348
|
+
const metadataSize = metadataLength.length + metadataBuffer.length;
|
|
349
|
+
const compressedSize = finalSize - metadataSize; // Approximate
|
|
350
|
+
console.log(`✓ Archive created: ${finalOutputPath}`);
|
|
351
|
+
console.log(` Original size: ${(originalSize / 1024).toFixed(2)} KB`);
|
|
352
|
+
console.log(` Compressed size: ${(compressedSize / 1024).toFixed(2)} KB`);
|
|
353
|
+
console.log(` Compression ratio: ${((1 - compressedSize / originalSize) * 100).toFixed(1)}%`);
|
|
354
|
+
console.log(` SHA256: ${checksum}`);
|
|
355
|
+
}
|
|
356
|
+
return {
|
|
357
|
+
path: finalOutputPath,
|
|
358
|
+
checksum,
|
|
359
|
+
size: finalStats.size,
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
async function bundle(options) {
|
|
363
|
+
const { appDirectory, outputPath, extractToDirectory: extractTarget, verbose, dryRun = false, compressionLevel = 11, } = options;
|
|
364
|
+
try {
|
|
365
|
+
// Initialize compressor
|
|
366
|
+
await initCompressor();
|
|
367
|
+
if (verbose)
|
|
368
|
+
console.log(`📦 Bundling app from: ${appDirectory}`);
|
|
369
|
+
// Check if directory exists
|
|
370
|
+
try {
|
|
371
|
+
await fs.access(appDirectory);
|
|
310
372
|
}
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
hideCursor: true,
|
|
317
|
-
});
|
|
318
|
-
progressBar.start(fileList.length, 0);
|
|
373
|
+
catch {
|
|
374
|
+
return {
|
|
375
|
+
success: false,
|
|
376
|
+
error: `App directory not found: ${appDirectory}`,
|
|
377
|
+
};
|
|
319
378
|
}
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
await
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
if (verbose && progressBar) {
|
|
329
|
-
processedFiles++;
|
|
330
|
-
progressBar.update(processedFiles);
|
|
331
|
-
}
|
|
332
|
-
else if (verbose) {
|
|
333
|
-
console.log(` + ${path}`);
|
|
334
|
-
}
|
|
335
|
-
return true;
|
|
336
|
-
},
|
|
337
|
-
}, fileList);
|
|
338
|
-
if (progressBar) {
|
|
339
|
-
progressBar.stop();
|
|
379
|
+
// Read and validate manifest
|
|
380
|
+
const manifestPath = path.join(appDirectory, "manifest.json");
|
|
381
|
+
const validation = await validateManifest(manifestPath);
|
|
382
|
+
if (!validation.valid) {
|
|
383
|
+
return {
|
|
384
|
+
success: false,
|
|
385
|
+
error: `Invalid manifest:\n${validation.errors.join("\n")}`,
|
|
386
|
+
};
|
|
340
387
|
}
|
|
341
|
-
|
|
342
|
-
console.log("🗜️ Compressing with Zstandard...");
|
|
343
|
-
// Create temporary file for compressed output
|
|
344
|
-
const tempCompressedPath = `${tempTarPath}.zst`;
|
|
345
|
-
// Compress with configured compressor using streaming to disk
|
|
346
|
-
const { checksum } = await this.compressor.compressFileStreaming(tempTarPath, tempCompressedPath, compressionLevel);
|
|
347
|
-
// Create metadata
|
|
348
|
-
const metadata = {
|
|
349
|
-
version: ARCHIVE_FORMAT_VERSION,
|
|
350
|
-
checksum,
|
|
351
|
-
created: new Date().toISOString(),
|
|
352
|
-
manifest,
|
|
353
|
-
};
|
|
354
|
-
// Combine metadata + compressed data
|
|
355
|
-
// Format: [4 bytes metadata length][metadata JSON][compressed stream]
|
|
356
|
-
const metadataJson = JSON.stringify(metadata);
|
|
357
|
-
const metadataBuffer = Buffer.from(metadataJson, "utf-8");
|
|
358
|
-
const metadataLength = Buffer.alloc(4);
|
|
359
|
-
metadataLength.writeUInt32BE(metadataBuffer.length, 0);
|
|
360
|
-
const finalWriteStream = (0, fs_1.createWriteStream)(finalOutputPath);
|
|
361
|
-
// Write metadata length and buffer
|
|
362
|
-
finalWriteStream.write(metadataLength);
|
|
363
|
-
finalWriteStream.write(metadataBuffer);
|
|
364
|
-
// Stream compressed content to final file
|
|
365
|
-
const compressedReadStream = (0, fs_1.createReadStream)(tempCompressedPath);
|
|
366
|
-
await new Promise((resolve, reject) => {
|
|
367
|
-
compressedReadStream.pipe(finalWriteStream);
|
|
368
|
-
compressedReadStream.on("error", reject);
|
|
369
|
-
finalWriteStream.on("error", reject);
|
|
370
|
-
finalWriteStream.on("finish", resolve);
|
|
371
|
-
});
|
|
372
|
-
// Get stats for logging
|
|
373
|
-
const tarStats = await fs.stat(tempTarPath);
|
|
374
|
-
const finalStats = await fs.stat(finalOutputPath);
|
|
375
|
-
// Clean up temp files
|
|
376
|
-
await fs.unlink(tempTarPath);
|
|
377
|
-
await fs.unlink(tempCompressedPath);
|
|
388
|
+
const manifest = validation.manifest;
|
|
378
389
|
if (verbose) {
|
|
379
|
-
|
|
380
|
-
const finalSize = finalStats.size;
|
|
381
|
-
const metadataSize = metadataLength.length + metadataBuffer.length;
|
|
382
|
-
const compressedSize = finalSize - metadataSize; // Approximate
|
|
383
|
-
console.log(`✓ Archive created: ${finalOutputPath}`);
|
|
384
|
-
console.log(` Original size: ${(originalSize / 1024).toFixed(2)} KB`);
|
|
385
|
-
console.log(` Compressed size: ${(compressedSize / 1024).toFixed(2)} KB`);
|
|
386
|
-
console.log(` Compression ratio: ${((1 - compressedSize / originalSize) *
|
|
387
|
-
100).toFixed(1)}%`);
|
|
388
|
-
console.log(` SHA256: ${checksum}`);
|
|
390
|
+
console.log(`✓ Manifest valid: ${manifest.name} v${manifest.version}`);
|
|
389
391
|
}
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
checksum,
|
|
393
|
-
size: finalStats.size,
|
|
394
|
-
};
|
|
395
|
-
}
|
|
396
|
-
/**
|
|
397
|
-
* Bundle an app into .edenite format or extract to directory
|
|
398
|
-
*/
|
|
399
|
-
static async bundle(options) {
|
|
400
|
-
const { appDirectory, outputPath, extractToDirectory, verbose, dryRun = false, compressionLevel = 11, } = options;
|
|
401
|
-
try {
|
|
402
|
-
// Initialize compressor
|
|
403
|
-
await this.initCompressor();
|
|
404
|
-
if (verbose)
|
|
405
|
-
console.log(`📦 Bundling app from: ${appDirectory}`);
|
|
406
|
-
// Check if directory exists
|
|
407
|
-
try {
|
|
408
|
-
await fs.access(appDirectory);
|
|
409
|
-
}
|
|
410
|
-
catch {
|
|
411
|
-
return {
|
|
412
|
-
success: false,
|
|
413
|
-
error: `App directory not found: ${appDirectory}`,
|
|
414
|
-
};
|
|
415
|
-
}
|
|
416
|
-
// Read and validate manifest
|
|
417
|
-
const manifestPath = path.join(appDirectory, "manifest.json");
|
|
418
|
-
const validation = await this.validateManifest(manifestPath);
|
|
419
|
-
if (!validation.valid) {
|
|
420
|
-
return {
|
|
421
|
-
success: false,
|
|
422
|
-
error: `Invalid manifest:\n${validation.errors.join("\n")}`,
|
|
423
|
-
};
|
|
424
|
-
}
|
|
425
|
-
const manifest = validation.manifest;
|
|
426
|
-
if (verbose) {
|
|
427
|
-
console.log(`✓ Manifest valid: ${manifest.name} v${manifest.version}`);
|
|
428
|
-
}
|
|
429
|
-
// If dry run, stop here
|
|
430
|
-
if (dryRun) {
|
|
431
|
-
if (verbose)
|
|
432
|
-
console.log("✓ Dry run successful - no files created");
|
|
433
|
-
return {
|
|
434
|
-
success: true,
|
|
435
|
-
manifest,
|
|
436
|
-
};
|
|
437
|
-
}
|
|
438
|
-
// Execute build command if defined (before verifying files, as build may create them)
|
|
439
|
-
const buildResult = await this.executeBuild(appDirectory, manifest, verbose);
|
|
440
|
-
if (!buildResult.success) {
|
|
441
|
-
return {
|
|
442
|
-
success: false,
|
|
443
|
-
error: buildResult.error,
|
|
444
|
-
};
|
|
445
|
-
}
|
|
446
|
-
// Verify required files exist (after build)
|
|
447
|
-
const fileCheck = await this.verifyFiles(appDirectory, manifest);
|
|
448
|
-
if (!fileCheck.valid) {
|
|
449
|
-
return {
|
|
450
|
-
success: false,
|
|
451
|
-
error: `Missing files:\n${fileCheck.errors.join("\n")}`,
|
|
452
|
-
};
|
|
453
|
-
}
|
|
392
|
+
// If dry run, stop here
|
|
393
|
+
if (dryRun) {
|
|
454
394
|
if (verbose)
|
|
455
|
-
console.log("✓
|
|
456
|
-
// If extractToDirectory is provided, copy files directly
|
|
457
|
-
if (extractToDirectory) {
|
|
458
|
-
await this.extractToDirectory(appDirectory, extractToDirectory, manifest, verbose);
|
|
459
|
-
return {
|
|
460
|
-
success: true,
|
|
461
|
-
outputPath: path.resolve(extractToDirectory),
|
|
462
|
-
manifest,
|
|
463
|
-
};
|
|
464
|
-
}
|
|
465
|
-
// Otherwise, create compressed archive
|
|
466
|
-
const result = await this.createArchive(appDirectory, manifest, outputPath, verbose, compressionLevel);
|
|
395
|
+
console.log("✓ Dry run successful - no files created");
|
|
467
396
|
return {
|
|
468
397
|
success: true,
|
|
469
|
-
outputPath: result.path,
|
|
470
398
|
manifest,
|
|
471
|
-
checksum: result.checksum,
|
|
472
|
-
size: result.size,
|
|
473
399
|
};
|
|
474
400
|
}
|
|
475
|
-
|
|
401
|
+
// Execute build command if defined (before verifying files, as build may create them)
|
|
402
|
+
const buildResult = await executeBuild(appDirectory, manifest, verbose);
|
|
403
|
+
if (!buildResult.success) {
|
|
476
404
|
return {
|
|
477
405
|
success: false,
|
|
478
|
-
error:
|
|
406
|
+
error: buildResult.error,
|
|
479
407
|
};
|
|
480
408
|
}
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
*/
|
|
485
|
-
static async getInfo(edenitePath) {
|
|
486
|
-
try {
|
|
487
|
-
await this.initCompressor();
|
|
488
|
-
// Read the .edenite file
|
|
489
|
-
const data = await fs.readFile(edenitePath);
|
|
490
|
-
// Read metadata length (first 4 bytes)
|
|
491
|
-
const metadataLength = data.readUInt32BE(0);
|
|
492
|
-
// Read metadata
|
|
493
|
-
const metadataBuffer = data.subarray(4, 4 + metadataLength);
|
|
494
|
-
const metadata = JSON.parse(metadataBuffer.toString("utf-8"));
|
|
409
|
+
// Verify required files exist (after build)
|
|
410
|
+
const fileCheck = await verifyFiles(appDirectory, manifest);
|
|
411
|
+
if (!fileCheck.valid) {
|
|
495
412
|
return {
|
|
496
|
-
success:
|
|
497
|
-
|
|
498
|
-
checksum: metadata.checksum,
|
|
413
|
+
success: false,
|
|
414
|
+
error: `Missing files:\n${fileCheck.errors.join("\n")}`,
|
|
499
415
|
};
|
|
500
416
|
}
|
|
501
|
-
|
|
417
|
+
if (verbose)
|
|
418
|
+
console.log("✓ All required files present");
|
|
419
|
+
// If extractToDirectory is provided, copy files directly
|
|
420
|
+
if (extractTarget) {
|
|
421
|
+
await extractToDirectory(appDirectory, extractTarget, manifest, verbose);
|
|
502
422
|
return {
|
|
503
|
-
success:
|
|
504
|
-
|
|
423
|
+
success: true,
|
|
424
|
+
outputPath: path.resolve(extractTarget),
|
|
425
|
+
manifest,
|
|
505
426
|
};
|
|
506
427
|
}
|
|
428
|
+
// Otherwise, create compressed archive
|
|
429
|
+
const result = await createArchive(appDirectory, manifest, outputPath, verbose, compressionLevel);
|
|
430
|
+
return {
|
|
431
|
+
success: true,
|
|
432
|
+
outputPath: result.path,
|
|
433
|
+
manifest,
|
|
434
|
+
checksum: result.checksum,
|
|
435
|
+
size: result.size,
|
|
436
|
+
};
|
|
507
437
|
}
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
438
|
+
catch (error) {
|
|
439
|
+
return {
|
|
440
|
+
success: false,
|
|
441
|
+
error: `Bundle failed: ${error.message}`,
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
async function getInfo(edenitePath) {
|
|
446
|
+
try {
|
|
447
|
+
await initCompressor();
|
|
448
|
+
// Read the .edenite file
|
|
449
|
+
const data = await fs.readFile(edenitePath);
|
|
450
|
+
// Read metadata length (first 4 bytes)
|
|
451
|
+
const metadataLength = data.readUInt32BE(0);
|
|
452
|
+
// Read metadata
|
|
453
|
+
const metadataBuffer = data.subarray(4, 4 + metadataLength);
|
|
454
|
+
const metadata = JSON.parse(metadataBuffer.toString("utf-8"));
|
|
455
|
+
return {
|
|
456
|
+
success: true,
|
|
457
|
+
manifest: metadata.manifest,
|
|
458
|
+
checksum: metadata.checksum,
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
catch (error) {
|
|
462
|
+
return {
|
|
463
|
+
success: false,
|
|
464
|
+
error: `Failed to read archive: ${error.message}`,
|
|
465
|
+
};
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
async function extract(options) {
|
|
469
|
+
const { edenitePath, outputDirectory, verbose, verifyChecksum = true, } = options;
|
|
470
|
+
try {
|
|
471
|
+
await initCompressor();
|
|
472
|
+
if (verbose)
|
|
473
|
+
console.log(`📂 Extracting: ${edenitePath}`);
|
|
474
|
+
// Read the .edenite file
|
|
475
|
+
const data = await fs.readFile(edenitePath);
|
|
476
|
+
// Read metadata length (first 4 bytes)
|
|
477
|
+
const metadataLength = data.readUInt32BE(0);
|
|
478
|
+
// Read metadata
|
|
479
|
+
const metadataBuffer = data.subarray(4, 4 + metadataLength);
|
|
480
|
+
const metadata = JSON.parse(metadataBuffer.toString("utf-8"));
|
|
481
|
+
if (verbose) {
|
|
482
|
+
console.log(`✓ Archive format version: ${metadata.version}`);
|
|
483
|
+
console.log(`✓ Created: ${metadata.created}`);
|
|
484
|
+
}
|
|
485
|
+
// Read compressed data
|
|
486
|
+
const compressedData = data.subarray(4 + metadataLength);
|
|
487
|
+
// Verify checksum if requested
|
|
488
|
+
if (verifyChecksum) {
|
|
489
|
+
const actualChecksum = calculateChecksum(Buffer.from(compressedData));
|
|
490
|
+
if (actualChecksum !== metadata.checksum) {
|
|
491
|
+
return {
|
|
492
|
+
success: false,
|
|
493
|
+
error: `Checksum mismatch! Archive may be corrupted.\nExpected: ${metadata.checksum}\nActual: ${actualChecksum}`,
|
|
494
|
+
};
|
|
541
495
|
}
|
|
542
496
|
if (verbose)
|
|
543
|
-
console.log("
|
|
544
|
-
// Decompress with configured compressor
|
|
545
|
-
const decompressedBuffer = await this.compressor.decompress(Buffer.from(compressedData));
|
|
546
|
-
// Write to temporary tar file
|
|
547
|
-
const tempTarPath = path.join(outputDirectory, `temp-${Date.now()}.tar`);
|
|
548
|
-
await fs.mkdir(outputDirectory, { recursive: true });
|
|
549
|
-
await fs.writeFile(tempTarPath, decompressedBuffer);
|
|
550
|
-
if (verbose)
|
|
551
|
-
console.log("📦 Extracting TAR archive...");
|
|
552
|
-
// Extract TAR
|
|
553
|
-
await tar.extract({
|
|
554
|
-
file: tempTarPath,
|
|
555
|
-
cwd: outputDirectory,
|
|
556
|
-
});
|
|
557
|
-
// Clean up temp tar file
|
|
558
|
-
await fs.unlink(tempTarPath);
|
|
559
|
-
if (verbose) {
|
|
560
|
-
console.log(`✓ Extracted to: ${outputDirectory}`);
|
|
561
|
-
}
|
|
562
|
-
return {
|
|
563
|
-
success: true,
|
|
564
|
-
manifest: metadata.manifest,
|
|
565
|
-
};
|
|
497
|
+
console.log("✓ Checksum verified");
|
|
566
498
|
}
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
499
|
+
if (verbose)
|
|
500
|
+
console.log("🗜️ Decompressing...");
|
|
501
|
+
// Decompress with configured compressor
|
|
502
|
+
const decompressedBuffer = await compressor.decompress(Buffer.from(compressedData));
|
|
503
|
+
// Write to temporary tar file
|
|
504
|
+
const tempTarPath = path.join(outputDirectory, `temp-${Date.now()}.tar`);
|
|
505
|
+
await fs.mkdir(outputDirectory, { recursive: true });
|
|
506
|
+
await fs.writeFile(tempTarPath, decompressedBuffer);
|
|
507
|
+
if (verbose)
|
|
508
|
+
console.log("📦 Extracting TAR archive...");
|
|
509
|
+
// Extract TAR
|
|
510
|
+
await tar.extract({
|
|
511
|
+
file: tempTarPath,
|
|
512
|
+
cwd: outputDirectory,
|
|
513
|
+
});
|
|
514
|
+
// Clean up temp tar file
|
|
515
|
+
await fs.unlink(tempTarPath);
|
|
516
|
+
if (verbose) {
|
|
517
|
+
console.log(`✓ Extracted to: ${outputDirectory}`);
|
|
572
518
|
}
|
|
519
|
+
return {
|
|
520
|
+
success: true,
|
|
521
|
+
manifest: metadata.manifest,
|
|
522
|
+
};
|
|
523
|
+
}
|
|
524
|
+
catch (error) {
|
|
525
|
+
return {
|
|
526
|
+
success: false,
|
|
527
|
+
error: `Extraction failed: ${error.message}`,
|
|
528
|
+
};
|
|
573
529
|
}
|
|
574
530
|
}
|
|
575
|
-
exports.GenesisBundler = GenesisBundler;
|
|
576
|
-
GenesisBundler.compressor = compression_1.DEFAULT_COMPRESSOR;
|
|
577
|
-
GenesisBundler.isInitialized = false;
|
|
578
531
|
//# sourceMappingURL=bundler.js.map
|