diff --git a/deno.json b/deno.json index a2713eb..0dfc0d0 100644 --- a/deno.json +++ b/deno.json @@ -20,7 +20,7 @@ "compile": "deno task pre-compile && deno task compile:linux && deno task compile:windows && deno task compile:apple && deno task compile:apple_arm64" }, "imports": { - "@fakoua/zip-ts": "jsr:@fakoua/zip-ts@^1.3.1", + "@deno-library/compress": "jsr:@deno-library/compress@^0.5.5", "@henrygd/semaphore": "jsr:@henrygd/semaphore@^0.0.2", "@std/yaml": "jsr:@std/yaml@^1.0.5" } diff --git a/deno.lock b/deno.lock index eeb9d0b..dd2078e 100644 --- a/deno.lock +++ b/deno.lock @@ -1,51 +1,77 @@ { "version": "4", "specifiers": { - "jsr:@fakoua/zip-ts@^1.3.1": "1.3.1", + "jsr:@deno-library/compress@~0.5.5": "0.5.5", + "jsr:@deno-library/crc32@1.0.2": "1.0.2", "jsr:@henrygd/semaphore@^0.0.2": "0.0.2", - "jsr:@std/assert@~0.218.2": "0.218.2", - "jsr:@std/fs@0.218.2": "0.218.2", - "jsr:@std/path@0.218.2": "0.218.2", - "jsr:@std/path@~0.218.2": "0.218.2", + "jsr:@std/bytes@^1.0.2": "1.0.4", + "jsr:@std/fs@1.0.5": "1.0.5", + "jsr:@std/io@0.225.0": "0.225.0", + "jsr:@std/path@1.0.8": "1.0.8", + "jsr:@std/path@^1.0.7": "1.0.8", + "jsr:@std/streams@^1.0.7": "1.0.8", + "jsr:@std/tar@0.1.3": "0.1.3", "jsr:@std/yaml@1.0.5": "1.0.5", - "jsr:@std/yaml@^1.0.5": "1.0.5" + "jsr:@std/yaml@^1.0.5": "1.0.5", + "jsr:@zip-js/zip-js@2.7.53": "2.7.53" }, "jsr": { - "@fakoua/zip-ts@1.3.1": { - "integrity": "b66f813015a59f40143c2bac337aed9abac7827da5e39c34549108aa129f33e7", + "@deno-library/compress@0.5.5": { + "integrity": "18b651a33eac87d96ae8c941487045724a665d654e9d94120da43777393655d9", "dependencies": [ + "jsr:@deno-library/crc32", "jsr:@std/fs", - "jsr:@std/path@0.218.2" + "jsr:@std/io", + "jsr:@std/path@1.0.8", + "jsr:@std/tar", + "jsr:@zip-js/zip-js" ] }, + "@deno-library/crc32@1.0.2": { + "integrity": "d2061bfee30c87c97f285dfca0fdc4458e632dc072a33ecfc73ca5177a5a39a0" + }, "@henrygd/semaphore@0.0.2": { "integrity": "cdf678250474b9445648d4fb8d8c636fe313f54893a50de616bf8d3e14f3b51e" }, - "@std/assert@0.218.2": { - "integrity": "7f0a5a1a8cf86607cd6c2c030584096e1ffad27fc9271429a8cb48cfbdee5eaf" + "@std/bytes@1.0.4": { + "integrity": "11a0debe522707c95c7b7ef89b478c13fb1583a7cfb9a85674cd2cc2e3a28abc" }, - "@std/fs@0.218.2": { - "integrity": "dd9431453f7282e8c577cc22c9e6d036055a9a980b5549f887d6012969fabcca", + "@std/fs@1.0.5": { + "integrity": "41806ad6823d0b5f275f9849a2640d87e4ef67c51ee1b8fb02426f55e02fd44e", "dependencies": [ - "jsr:@std/assert", - "jsr:@std/path@~0.218.2" + "jsr:@std/path@^1.0.7" ] }, - "@std/path@0.218.2": { - "integrity": "b568fd923d9e53ad76d17c513e7310bda8e755a3e825e6289a0ce536404e2662", + "@std/io@0.225.0": { + "integrity": "c1db7c5e5a231629b32d64b9a53139445b2ca640d828c26bf23e1c55f8c079b3", "dependencies": [ - "jsr:@std/assert" + "jsr:@std/bytes" + ] + }, + "@std/path@1.0.8": { + "integrity": "548fa456bb6a04d3c1a1e7477986b6cffbce95102d0bb447c67c4ee70e0364be" + }, + "@std/streams@1.0.8": { + "integrity": "b41332d93d2cf6a82fe4ac2153b930adf1a859392931e2a19d9fabfb6f154fb3" + }, + "@std/tar@0.1.3": { + "integrity": "531270fc707b37ab9b5f051aa4943e7b16b86905e0398a4ebe062983b0c93115", + "dependencies": [ + "jsr:@std/streams" ] }, "@std/yaml@1.0.5": { "integrity": "71ba3d334305ee2149391931508b2c293a8490f94a337eef3a09cade1a2a2742" + }, + "@zip-js/zip-js@2.7.53": { + "integrity": "acea5bd8e01feb3fe4c242cfbde7d33dd5e006549a4eb1d15283bc0c778ed672" } }, "workspace": { "dependencies": [ - "jsr:@fakoua/zip-ts@^1.3.1", + "jsr:@deno-library/compress@~0.5.5", "jsr:@henrygd/semaphore@^0.0.2", "jsr:@std/yaml@^1.0.5" ] } -} +} \ No newline at end of file diff --git a/main.js b/main.js index f8fa3e7..b0b6cbf 100644 --- a/main.js +++ b/main.js @@ -1,5 +1,6 @@ 'use strict'; -import { compress } from '@fakoua/zip-ts'; + +import { tgz } from "jsr:@deno-library/compress"; import { parse, stringify as toYaml } from '@std/yaml'; import { getSemaphore } from '@henrygd/semaphore'; @@ -13,7 +14,7 @@ const cfRuntimeTypes = { const timestamp = new Date().getTime(); const dirPath = `./codefresh-support-${timestamp}`; -const supportPackageZip = `./codefresh-support-package-${timestamp}.zip`; +const supportPackageZip = `./codefresh-support-package-${timestamp}.tar.gz`; const numOfProcesses = 5; // ############################## @@ -190,7 +191,7 @@ async function getAccountRuntimes(cfConfig) { async function runTestPipeline(cfConfig, runtimeName) { let selection = String( prompt( - '\nTo troubleshoot, we would like to create a Demo Pipeline and run it.\nAfter creating this pipeline we will clean up the resources\n\nWould you like to proceed with the demo pipeline? (y/n): ', + '\nTo troubleshoot, we would like to create a Demo Pipeline and run it.\n\nWould you like to proceed with the demo pipeline? (y/n): ', ), ); while (selection !== 'y' && selection !== 'n') { @@ -206,7 +207,7 @@ async function runTestPipeline(cfConfig, runtimeName) { const projectName = 'CODEFRESH-SUPPORT-PACKAGE'; const pipelineName = 'TEST-PIPELINE-FOR-SUPPORT'; const pipelineYaml = - 'version: "1.0"\n\nsteps:\n\n test:\n title: Running test\n type: freestyle\n arguments:\n image: alpine\n commands:\n - echo "Hello Test"'; + 'version: "1.0"\n\nsteps:\n\n freestyle:\n title: Running test\n type: freestyle\n arguments:\n image: alpine\n commands:\n - echo "Hello Test"'; const project = JSON.stringify({ projectName: projectName, @@ -240,8 +241,6 @@ async function runTestPipeline(cfConfig, runtimeName) { const projectStatus = await createProjectResponse.json(); if (!createProjectResponse.ok) { - console.error('Error creating project:', createProjectResponse.statusText); - console.error(projectStatus); const getProjectID = await fetch(`${cfConfig.baseUrl}/projects/name/${projectName}`, { method: 'GET', headers: cfConfig.headers, @@ -263,8 +262,6 @@ async function runTestPipeline(cfConfig, runtimeName) { if (!createPipelineResponse.ok) { try { - console.error('Error creating pipeline:', createPipelineResponse.statusText); - console.error(pipelineStatus); const getPipelineID = await fetch(`${cfConfig.baseUrl}/pipelines/${projectName}%2f${pipelineName}`, { method: 'GET', headers: cfConfig.headers, @@ -316,27 +313,6 @@ async function runTestPipeline(cfConfig, runtimeName) { return { pipelineID: pipelineStatus.metadata.id, projectID: projectStatus.id, buildID: runPipelineStatus }; } -async function deleteTestPipeline(cfConfig, pipelineID, projectID) { - const deletePipelineResponse = await fetch(`${cfConfig.baseUrl}/pipelines/${pipelineID}`, { - method: 'DELETE', - headers: cfConfig.headers, - }); - - if (!deletePipelineResponse.ok) { - throw new Error('Error deleting pipeline:', await deletePipelineResponse.text()); - } - - const deleteProjectResponse = await fetch(`${cfConfig.baseUrl}/projects/${projectID}`, { - method: 'DELETE', - headers: cfConfig.headers, - }); - - if (!deleteProjectResponse.ok) { - throw new Error('Error deleting project:', await deleteProjectResponse.text()); - } - - console.log('Demo pipeline and project deleted successfully.'); -} async function gatherPipelinesRuntime(cfConfig) { try { @@ -382,7 +358,6 @@ async function gatherPipelinesRuntime(cfConfig) { if (pipelineExecutionOutput) { await Deno.writeTextFile(`${dirPath}/testPipelineBuildId.txt`, pipelineExecutionOutput.buildID); - await deleteTestPipeline(cfConfig, pipelineExecutionOutput.pipelineID, pipelineExecutionOutput.projectID); } await prepareAndCleanup(); @@ -498,7 +473,7 @@ async function writeGetApiCalls(resources, k8sType) { async function prepareAndCleanup() { console.log(`Saving data to ${supportPackageZip}`); - await compress(dirPath, `${supportPackageZip}`, { overwrite: true }); + await tgz.compress(dirPath, supportPackageZip); console.log('Cleaning up temp directory'); await Deno.remove(dirPath, { recursive: true });