1
1
'use strict' ;
2
- import { compress } from '@fakoua/zip-ts' ;
2
+
3
+ import { tgz } from "jsr:@deno-library/compress" ;
3
4
import { parse , stringify as toYaml } from '@std/yaml' ;
4
5
import { getSemaphore } from '@henrygd/semaphore' ;
5
6
@@ -13,7 +14,7 @@ const cfRuntimeTypes = {
13
14
14
15
const timestamp = new Date ( ) . getTime ( ) ;
15
16
const dirPath = `./codefresh-support-${ timestamp } ` ;
16
- const supportPackageZip = `./codefresh-support-package-${ timestamp } .zip ` ;
17
+ const supportPackageZip = `./codefresh-support-package-${ timestamp } .tar.gz ` ;
17
18
const numOfProcesses = 5 ;
18
19
19
20
// ##############################
@@ -190,7 +191,7 @@ async function getAccountRuntimes(cfConfig) {
190
191
async function runTestPipeline ( cfConfig , runtimeName ) {
191
192
let selection = String (
192
193
prompt (
193
- '\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): ' ,
194
+ '\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): ' ,
194
195
) ,
195
196
) ;
196
197
while ( selection !== 'y' && selection !== 'n' ) {
@@ -206,7 +207,7 @@ async function runTestPipeline(cfConfig, runtimeName) {
206
207
const projectName = 'CODEFRESH-SUPPORT-PACKAGE' ;
207
208
const pipelineName = 'TEST-PIPELINE-FOR-SUPPORT' ;
208
209
const pipelineYaml =
209
- '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"' ;
210
+ '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"' ;
210
211
211
212
const project = JSON . stringify ( {
212
213
projectName : projectName ,
@@ -240,8 +241,6 @@ async function runTestPipeline(cfConfig, runtimeName) {
240
241
const projectStatus = await createProjectResponse . json ( ) ;
241
242
242
243
if ( ! createProjectResponse . ok ) {
243
- console . error ( 'Error creating project:' , createProjectResponse . statusText ) ;
244
- console . error ( projectStatus ) ;
245
244
const getProjectID = await fetch ( `${ cfConfig . baseUrl } /projects/name/${ projectName } ` , {
246
245
method : 'GET' ,
247
246
headers : cfConfig . headers ,
@@ -263,8 +262,6 @@ async function runTestPipeline(cfConfig, runtimeName) {
263
262
264
263
if ( ! createPipelineResponse . ok ) {
265
264
try {
266
- console . error ( 'Error creating pipeline:' , createPipelineResponse . statusText ) ;
267
- console . error ( pipelineStatus ) ;
268
265
const getPipelineID = await fetch ( `${ cfConfig . baseUrl } /pipelines/${ projectName } %2f${ pipelineName } ` , {
269
266
method : 'GET' ,
270
267
headers : cfConfig . headers ,
@@ -316,27 +313,6 @@ async function runTestPipeline(cfConfig, runtimeName) {
316
313
return { pipelineID : pipelineStatus . metadata . id , projectID : projectStatus . id , buildID : runPipelineStatus } ;
317
314
}
318
315
319
- async function deleteTestPipeline ( cfConfig , pipelineID , projectID ) {
320
- const deletePipelineResponse = await fetch ( `${ cfConfig . baseUrl } /pipelines/${ pipelineID } ` , {
321
- method : 'DELETE' ,
322
- headers : cfConfig . headers ,
323
- } ) ;
324
-
325
- if ( ! deletePipelineResponse . ok ) {
326
- throw new Error ( 'Error deleting pipeline:' , await deletePipelineResponse . text ( ) ) ;
327
- }
328
-
329
- const deleteProjectResponse = await fetch ( `${ cfConfig . baseUrl } /projects/${ projectID } ` , {
330
- method : 'DELETE' ,
331
- headers : cfConfig . headers ,
332
- } ) ;
333
-
334
- if ( ! deleteProjectResponse . ok ) {
335
- throw new Error ( 'Error deleting project:' , await deleteProjectResponse . text ( ) ) ;
336
- }
337
-
338
- console . log ( 'Demo pipeline and project deleted successfully.' ) ;
339
- }
340
316
341
317
async function gatherPipelinesRuntime ( cfConfig ) {
342
318
try {
@@ -382,7 +358,6 @@ async function gatherPipelinesRuntime(cfConfig) {
382
358
383
359
if ( pipelineExecutionOutput ) {
384
360
await Deno . writeTextFile ( `${ dirPath } /testPipelineBuildId.txt` , pipelineExecutionOutput . buildID ) ;
385
- await deleteTestPipeline ( cfConfig , pipelineExecutionOutput . pipelineID , pipelineExecutionOutput . projectID ) ;
386
361
}
387
362
388
363
await prepareAndCleanup ( ) ;
@@ -498,7 +473,7 @@ async function writeGetApiCalls(resources, k8sType) {
498
473
499
474
async function prepareAndCleanup ( ) {
500
475
console . log ( `Saving data to ${ supportPackageZip } ` ) ;
501
- await compress ( dirPath , ` ${ supportPackageZip } ` , { overwrite : true } ) ;
476
+ await tgz . compress ( dirPath , supportPackageZip ) ;
502
477
503
478
console . log ( 'Cleaning up temp directory' ) ;
504
479
await Deno . remove ( dirPath , { recursive : true } ) ;
0 commit comments