@malloy-publisher/server 0.0.170 → 0.0.171
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/server.js
CHANGED
|
@@ -222427,7 +222427,7 @@ class PackageController {
|
|
|
222427
222427
|
} else if (packageLocation.startsWith("gs://")) {
|
|
222428
222428
|
await this.projectStore.downloadGcsDirectory(packageLocation, projectName, absoluteTargetPath, isCompressedFile);
|
|
222429
222429
|
} else if (packageLocation.startsWith("s3://")) {
|
|
222430
|
-
await this.projectStore.downloadS3Directory(packageLocation, projectName, absoluteTargetPath);
|
|
222430
|
+
await this.projectStore.downloadS3Directory(packageLocation, projectName, absoluteTargetPath, isCompressedFile);
|
|
222431
222431
|
}
|
|
222432
222432
|
if (packageLocation.startsWith("/")) {
|
|
222433
222433
|
await this.projectStore.mountLocalDirectory(packageLocation, absoluteTargetPath, projectName, packageName);
|
|
@@ -231020,7 +231020,7 @@ class ProjectStore {
|
|
|
231020
231020
|
if (this.isS3URL(location)) {
|
|
231021
231021
|
try {
|
|
231022
231022
|
logger.info(`Downloading S3 directory from "${location}" to "${targetPath}"`);
|
|
231023
|
-
await this.downloadS3Directory(location, projectName, targetPath);
|
|
231023
|
+
await this.downloadS3Directory(location, projectName, targetPath, isCompressedFile);
|
|
231024
231024
|
return;
|
|
231025
231025
|
} catch (error) {
|
|
231026
231026
|
const errorData = this.extractErrorDataFromError(error);
|
|
@@ -231097,10 +231097,33 @@ class ProjectStore {
|
|
|
231097
231097
|
}
|
|
231098
231098
|
logger.info(`Downloaded GCS directory ${gcsPath} to ${absoluteDirPath}`);
|
|
231099
231099
|
}
|
|
231100
|
-
async downloadS3Directory(s3Path, projectName, absoluteDirPath) {
|
|
231100
|
+
async downloadS3Directory(s3Path, projectName, absoluteDirPath, isCompressedFile = false) {
|
|
231101
231101
|
const trimmedPath = s3Path.slice(5);
|
|
231102
231102
|
const [bucketName, ...prefixParts] = trimmedPath.split("/");
|
|
231103
231103
|
const prefix = prefixParts.join("/");
|
|
231104
|
+
if (isCompressedFile) {
|
|
231105
|
+
const zipFilePath = `${absoluteDirPath}.zip`;
|
|
231106
|
+
await fs7.promises.mkdir(path8.dirname(zipFilePath), {
|
|
231107
|
+
recursive: true
|
|
231108
|
+
});
|
|
231109
|
+
const command = new import_client_s32.GetObjectCommand({
|
|
231110
|
+
Bucket: bucketName,
|
|
231111
|
+
Key: prefix
|
|
231112
|
+
});
|
|
231113
|
+
const item = await this.s3Client.send(command);
|
|
231114
|
+
if (!item.Body) {
|
|
231115
|
+
throw new ProjectNotFoundError(`Project ${projectName} not found in ${s3Path}`);
|
|
231116
|
+
}
|
|
231117
|
+
const file = fs7.createWriteStream(zipFilePath);
|
|
231118
|
+
item.Body.transformToWebStream().pipeTo(import_stream5.Writable.toWeb(file));
|
|
231119
|
+
await new Promise((resolve3, reject) => {
|
|
231120
|
+
file.on("error", reject);
|
|
231121
|
+
file.on("finish", resolve3);
|
|
231122
|
+
});
|
|
231123
|
+
await this.unzipProject(zipFilePath);
|
|
231124
|
+
logger.info(`Downloaded S3 zip file ${s3Path} to ${absoluteDirPath}`);
|
|
231125
|
+
return;
|
|
231126
|
+
}
|
|
231104
231127
|
const objects = await this.s3Client.listObjectsV2({
|
|
231105
231128
|
Bucket: bucketName,
|
|
231106
231129
|
Prefix: prefix
|
|
@@ -231138,6 +231161,7 @@ class ProjectStore {
|
|
|
231138
231161
|
file.on("finish", resolve3);
|
|
231139
231162
|
});
|
|
231140
231163
|
}));
|
|
231164
|
+
logger.info(`Downloaded S3 directory ${s3Path} to ${absoluteDirPath}`);
|
|
231141
231165
|
}
|
|
231142
231166
|
parseGitHubUrl(githubUrl) {
|
|
231143
231167
|
const httpsRegex = /github\.com\/(?<owner>[^/]+)\/(?<repoName>[^/]+)(?<packagePath>\/[^/]+)*/;
|
package/package.json
CHANGED
|
@@ -1112,7 +1112,12 @@ export class ProjectStore {
|
|
|
1112
1112
|
logger.info(
|
|
1113
1113
|
`Downloading S3 directory from "${location}" to "${targetPath}"`,
|
|
1114
1114
|
);
|
|
1115
|
-
await this.downloadS3Directory(
|
|
1115
|
+
await this.downloadS3Directory(
|
|
1116
|
+
location,
|
|
1117
|
+
projectName,
|
|
1118
|
+
targetPath,
|
|
1119
|
+
isCompressedFile,
|
|
1120
|
+
);
|
|
1116
1121
|
return;
|
|
1117
1122
|
} catch (error) {
|
|
1118
1123
|
const errorData = this.extractErrorDataFromError(error);
|
|
@@ -1242,10 +1247,43 @@ export class ProjectStore {
|
|
|
1242
1247
|
s3Path: string,
|
|
1243
1248
|
projectName: string,
|
|
1244
1249
|
absoluteDirPath: string,
|
|
1250
|
+
isCompressedFile: boolean = false,
|
|
1245
1251
|
) {
|
|
1246
1252
|
const trimmedPath = s3Path.slice(5);
|
|
1247
1253
|
const [bucketName, ...prefixParts] = trimmedPath.split("/");
|
|
1248
1254
|
const prefix = prefixParts.join("/");
|
|
1255
|
+
|
|
1256
|
+
if (isCompressedFile) {
|
|
1257
|
+
// Download the single zip file
|
|
1258
|
+
const zipFilePath = `${absoluteDirPath}.zip`;
|
|
1259
|
+
await fs.promises.mkdir(path.dirname(zipFilePath), {
|
|
1260
|
+
recursive: true,
|
|
1261
|
+
});
|
|
1262
|
+
|
|
1263
|
+
const command = new GetObjectCommand({
|
|
1264
|
+
Bucket: bucketName,
|
|
1265
|
+
Key: prefix,
|
|
1266
|
+
});
|
|
1267
|
+
const item = await this.s3Client.send(command);
|
|
1268
|
+
if (!item.Body) {
|
|
1269
|
+
throw new ProjectNotFoundError(
|
|
1270
|
+
`Project ${projectName} not found in ${s3Path}`,
|
|
1271
|
+
);
|
|
1272
|
+
}
|
|
1273
|
+
const file = fs.createWriteStream(zipFilePath);
|
|
1274
|
+
item.Body.transformToWebStream().pipeTo(Writable.toWeb(file));
|
|
1275
|
+
await new Promise<void>((resolve, reject) => {
|
|
1276
|
+
file.on("error", reject);
|
|
1277
|
+
file.on("finish", resolve);
|
|
1278
|
+
});
|
|
1279
|
+
|
|
1280
|
+
// Extract the zip file
|
|
1281
|
+
await this.unzipProject(zipFilePath);
|
|
1282
|
+
logger.info(`Downloaded S3 zip file ${s3Path} to ${absoluteDirPath}`);
|
|
1283
|
+
return;
|
|
1284
|
+
}
|
|
1285
|
+
|
|
1286
|
+
// Original behavior: download directory contents
|
|
1249
1287
|
const objects = await this.s3Client.listObjectsV2({
|
|
1250
1288
|
Bucket: bucketName,
|
|
1251
1289
|
Prefix: prefix,
|
|
@@ -1291,6 +1329,7 @@ export class ProjectStore {
|
|
|
1291
1329
|
});
|
|
1292
1330
|
}),
|
|
1293
1331
|
);
|
|
1332
|
+
logger.info(`Downloaded S3 directory ${s3Path} to ${absoluteDirPath}`);
|
|
1294
1333
|
}
|
|
1295
1334
|
|
|
1296
1335
|
private parseGitHubUrl(
|