@octopusdeploy/api-client
Advanced tools
Comparing version
@@ -171,2 +171,35 @@ "use strict"; | ||
}); }); | ||
test("Can create with unexpected characters", function () { return __awaiter(void 0, void 0, void 0, function () { | ||
var tmpFolder, packageBuilder, expectedPackageFile, zip, entry; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
tmpFolder = os_1.default.tmpdir(); | ||
fs_1.default.writeFileSync(path_1.default.join(tmpFolder, "NuGetPackagingTestæøå.txt"), "Some test content to add to the zip archive æøå"); | ||
packageBuilder = new nugetPackageBuilder_1.NuGetPackageBuilder(); | ||
return [4 /*yield*/, packageBuilder.pack({ | ||
packageId: "TestNuGetPackageWithOddCharacters", | ||
version: "2.0.1", | ||
basePath: tmpFolder, | ||
inputFilePatterns: ["NuGetPackagingTestæøå.txt"], | ||
outputFolder: tmpFolder, | ||
overwrite: true, | ||
logger: logger, | ||
nuspecArgs: { | ||
description: "This is a test NuGet Package", | ||
authors: ["Test AuthorA", "Test AuthorB"], | ||
}, | ||
})]; | ||
case 1: | ||
_a.sent(); | ||
expectedPackageFile = path_1.default.join(tmpFolder, "TestNuGetPackageWithOddCharacters.2.0.1.nupkg"); | ||
expect(fs_1.default.existsSync(expectedPackageFile)).toBe(true); | ||
zip = new adm_zip_1.default(expectedPackageFile); | ||
entry = zip.getEntry("NuGetPackagingTestæøå.txt"); | ||
expect(entry).not.toBeNull(); | ||
expect(entry === null || entry === void 0 ? void 0 : entry.getData().toString()).toBe("Some test content to add to the zip archive æøå"); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); }); | ||
}); |
@@ -198,2 +198,44 @@ "use strict"; | ||
}); }); | ||
test("Re-creating a zip with overwrite set to false does not replace the existing archive", function () { return __awaiter(void 0, void 0, void 0, function () { | ||
var tmpFolder, zipPackageBuilder, zipPackageBuilderReplace, expectedPackageFile, zip, entry; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
tmpFolder = os_1.default.tmpdir(); | ||
fs_1.default.writeFileSync(path_1.default.join(tmpFolder, "ZipPackagingTest.txt"), "Some test content to add to the zip archive"); | ||
zipPackageBuilder = new zipPackageBuilder_1.ZipPackageBuilder(); | ||
return [4 /*yield*/, zipPackageBuilder.pack({ | ||
packageId: "TestPackage", | ||
version: "1.0.1", | ||
basePath: tmpFolder, | ||
inputFilePatterns: ["ZipPackagingTest.txt"], | ||
outputFolder: tmpFolder, | ||
overwrite: true, | ||
logger: logger, | ||
})]; | ||
case 1: | ||
_a.sent(); | ||
fs_1.default.writeFileSync(path_1.default.join(tmpFolder, "ZipPackagingTest.txt"), "Updated Content"); | ||
zipPackageBuilderReplace = new zipPackageBuilder_1.ZipPackageBuilder(); | ||
return [4 /*yield*/, zipPackageBuilderReplace.pack({ | ||
packageId: "TestPackage", | ||
version: "1.0.1", | ||
basePath: tmpFolder, | ||
inputFilePatterns: ["ZipPackagingTest.txt"], | ||
outputFolder: tmpFolder, | ||
overwrite: false, | ||
logger: logger, | ||
})]; | ||
case 2: | ||
_a.sent(); | ||
expectedPackageFile = path_1.default.join(tmpFolder, "TestPackage.1.0.1.zip"); | ||
expect(fs_1.default.existsSync(expectedPackageFile)).toBe(true); | ||
zip = new adm_zip_1.default(expectedPackageFile); | ||
entry = zip.getEntry("ZipPackagingTest.txt"); | ||
expect(entry).not.toBeNull(); | ||
expect(entry === null || entry === void 0 ? void 0 : entry.getData().toString()).toBe("Some test content to add to the zip archive"); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); }); | ||
}); |
@@ -72,8 +72,8 @@ "use strict"; | ||
function doZip(basePath, inputFilePatterns, outputFolder, zipFilename, logger, compressionLevel, overwrite) { | ||
var _a, _b, _c; | ||
var _a, _b, _c, _d; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var archivePath, initialWorkingDirectory, zip, files, files_1, files_1_1, file, dirName; | ||
var e_1, _d; | ||
return __generator(this, function (_e) { | ||
switch (_e.label) { | ||
var e_1, _e; | ||
return __generator(this, function (_f) { | ||
switch (_f.label) { | ||
case 0: | ||
@@ -87,3 +87,3 @@ archivePath = path_1.default.resolve(outputFolder, zipFilename); | ||
case 1: | ||
files = _e.sent(); | ||
files = _f.sent(); | ||
try { | ||
@@ -105,3 +105,3 @@ for (files_1 = __values(files), files_1_1 = files_1.next(); !files_1_1.done; files_1_1 = files_1.next()) { | ||
try { | ||
if (files_1_1 && !files_1_1.done && (_d = files_1.return)) _d.call(files_1); | ||
if (files_1_1 && !files_1_1.done && (_e = files_1.return)) _e.call(files_1); | ||
} | ||
@@ -115,6 +115,7 @@ finally { if (e_1) throw e_1.error; } | ||
process.chdir(initialWorkingDirectory); | ||
return [4 /*yield*/, zip.writeZipPromise(archivePath, { overwrite: overwrite || true })]; | ||
case 2: | ||
_e.sent(); | ||
return [2 /*return*/]; | ||
if (fs_1.default.existsSync(archivePath) && overwrite === false) { | ||
(_d = logger.info) === null || _d === void 0 ? void 0 : _d.call(logger, "Found an existing archive at ".concat(archivePath, " and overwrite is disabled. The existing archive will not be overwritten.")); | ||
return [2 /*return*/]; | ||
} | ||
return [2 /*return*/, zip.writeZip(archivePath, function () { })]; | ||
} | ||
@@ -121,0 +122,0 @@ }); |
@@ -78,3 +78,3 @@ { | ||
"types": "dist/index.d.ts", | ||
"version": "3.2.0", | ||
"version": "3.3.0", | ||
"jest-junit": { | ||
@@ -81,0 +81,0 @@ "outputDirectory": "reports", |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
413107
1.17%8331
0.92%0
-100%