@@ -4,6 +4,7 @@ import * as path from "path";
44import filetype from "file-type" ;
55import fs from "fs" ;
66import fsExtra from "fs-extra" ;
7+ import { readdir } from "fs/promises" ;
78import { getAuthInfo } from "../../client-utils/auth-manager.js" ;
89import { ApiError , ApiValidationExternalApIsController , ApiValidationSummary } from "@apimatic/sdk" ;
910import { LoginCredentials , SpecFile } from "../../types/portal/quickstart.js" ;
@@ -114,19 +115,18 @@ export class PortalQuickstartController {
114115 } else {
115116 specPath = path . normalize ( specPath ) ;
116117 const fileType = await filetype . fromFile ( specPath ) ;
118+ filePath = tempSpecDir ;
117119
118120 if ( fileType ?. ext === "zip" ) {
119- filePath = tempSpecDir ;
120121 await unzipFile ( fs . createReadStream ( specPath ) , tempSpecDir ) ;
121122 } else {
122123 const destinationPath = path . join ( tempSpecDir , path . basename ( specPath ) ) ;
123- filePath = destinationPath ;
124124 await fsExtra . copy ( specPath , destinationPath ) ;
125125 }
126126 }
127127 }
128128
129- return { filePath, url : this . specUrl } ;
129+ return { localPath : filePath , url : this . specUrl } ;
130130 }
131131
132132 async getSpecValidationSummary (
@@ -135,7 +135,7 @@ export class PortalQuickstartController {
135135 apiValidationController : ApiValidationExternalApIsController
136136 ) : Promise < ApiValidationSummary > {
137137 const validationFlags : GetValidationParams = {
138- file : specFile . filePath ,
138+ file : specFile . localPath ,
139139 url : specFile . url
140140 } ;
141141
@@ -248,9 +248,16 @@ export class PortalQuickstartController {
248248 await clearDirectory ( path . join ( targetFolder , ".git" ) ) ;
249249 await clearDirectory ( path . join ( targetFolder , ".github" ) ) ;
250250
251- if ( specFile . filePath && validationSummary . success ) {
252- await deleteFile ( path . join ( targetFolder , "spec" , "Apimatic-Calculator.json" ) ) ;
253- fsExtra . copy ( specFile . filePath , path . join ( targetFolder , "spec" , path . basename ( specFile . filePath ) ) ) ;
251+ if ( specFile . localPath && validationSummary . success ) {
252+ const specFolder = path . join ( targetFolder , "spec" ) ;
253+ await deleteFile ( path . join ( specFolder , "Apimatic-Calculator.json" ) ) ;
254+
255+ const files = await readdir ( specFile . localPath ) ;
256+ for ( const file of files ) {
257+ const srcPath = path . join ( specFile . localPath , file ) ;
258+ const destPath = path . join ( specFolder , file ) ;
259+ await fsExtra . copy ( srcPath , destPath ) ;
260+ }
254261 }
255262
256263 const buildFilePath = path . join ( targetFolder , "APIMATIC-BUILD.json" ) ;
0 commit comments