Compare commits
	
		
			10 Commits
		
	
	
		
			4a1fa615de
			...
			users/eric
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | 096b500552 | ||
|   | 59bb2dd7cd | ||
|   | 093dbebc2e | ||
|   | d79ea53307 | ||
|   | 0fa906a067 | ||
|   | 0b63af4c8c | ||
|   | 31d9a4bd37 | ||
|   | 154a05918b | ||
|   | 7a2b445a4b | ||
|   | eed20d30d5 | 
							
								
								
									
										206
									
								
								dist/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										206
									
								
								dist/index.js
									
									
									
									
										vendored
									
									
								
							| @@ -8358,7 +8358,6 @@ const core = __importStar(__webpack_require__(470)); | |||||||
| const exec = __importStar(__webpack_require__(986)); | const exec = __importStar(__webpack_require__(986)); | ||||||
| const fs = __importStar(__webpack_require__(747)); | const fs = __importStar(__webpack_require__(747)); | ||||||
| const github = __importStar(__webpack_require__(469)); | const github = __importStar(__webpack_require__(469)); | ||||||
| const https = __importStar(__webpack_require__(211)); |  | ||||||
| const io = __importStar(__webpack_require__(1)); | const io = __importStar(__webpack_require__(1)); | ||||||
| const path = __importStar(__webpack_require__(622)); | const path = __importStar(__webpack_require__(622)); | ||||||
| const refHelper = __importStar(__webpack_require__(227)); | const refHelper = __importStar(__webpack_require__(227)); | ||||||
| @@ -8371,63 +8370,49 @@ function downloadRepository(accessToken, owner, repo, ref, commit, repositoryPat | |||||||
|         const runnerTemp = process.env['RUNNER_TEMP']; |         const runnerTemp = process.env['RUNNER_TEMP']; | ||||||
|         assert.ok(runnerTemp, 'RUNNER_TEMP not defined'); |         assert.ok(runnerTemp, 'RUNNER_TEMP not defined'); | ||||||
|         const archivePath = path.join(runnerTemp, 'checkout.tar.gz'); |         const archivePath = path.join(runnerTemp, 'checkout.tar.gz'); | ||||||
|         // await fs.promises.writeFile(archivePath, raw) |         // Ensure file does not exist | ||||||
|         // Get the archive URL using the REST API |         core.debug(`Ensuring archive file does not exist: ${archivePath}`); | ||||||
|         yield retryHelper.execute(() => __awaiter(this, void 0, void 0, function* () { |         yield io.rmRF(archivePath); | ||||||
|             // Prepare the archive stream |         // Download the archive | ||||||
|             core.debug(`Preparing the archive stream: ${archivePath}`); |         let archiveData = yield retryHelper.execute(() => __awaiter(this, void 0, void 0, function* () { | ||||||
|             yield io.rmRF(archivePath); |             core.info('Downloading the archive using the REST API'); | ||||||
|             const fileStream = fs.createWriteStream(archivePath); |             return yield downloadArchive(accessToken, owner, repo, ref, commit); | ||||||
|             const fileStreamClosed = getFileClosedPromise(fileStream); |  | ||||||
|             try { |  | ||||||
|                 // Get the archive URL using the GitHub REST API |  | ||||||
|                 core.info('Getting archive URL from GitHub REST API'); |  | ||||||
|                 const octokit = new github.GitHub(accessToken); |  | ||||||
|                 const params = { |  | ||||||
|                     method: 'HEAD', |  | ||||||
|                     archive_format: IS_WINDOWS ? 'zipball' : 'tarball', |  | ||||||
|                     owner: owner, |  | ||||||
|                     repo: repo, |  | ||||||
|                     ref: refHelper.getDownloadRef(ref, commit) |  | ||||||
|                 }; |  | ||||||
|                 const response = yield octokit.repos.getArchiveLink(params); |  | ||||||
|                 console.log('GOT THE RESPONSE'); |  | ||||||
|                 if (response.status != 302) { |  | ||||||
|                     throw new Error(`Unexpected response from GitHub API. Status: '${response.status}'`); |  | ||||||
|                 } |  | ||||||
|                 console.log('GETTING THE LOCATION'); |  | ||||||
|                 const archiveUrl = response.headers['Location']; // Do not print the archive URL because it has an embedded token |  | ||||||
|                 assert.ok(archiveUrl, `Expected GitHub API response to contain 'Location' header`); |  | ||||||
|                 // Download the archive |  | ||||||
|                 core.info('Downloading the archive'); // Do not print the archive URL because it has an embedded token |  | ||||||
|                 yield downloadFile(archiveUrl, fileStream); |  | ||||||
|             } |  | ||||||
|             finally { |  | ||||||
|                 yield fileStreamClosed; |  | ||||||
|             } |  | ||||||
|             // return Buffer.from(response.data) // response.data is ArrayBuffer |  | ||||||
|         })); |         })); | ||||||
|         // // Download the archive |         // Write archive to disk | ||||||
|         // core.info('Downloading the archive') // Do not print the URL since it contains a token to download the archive |         core.info('Writing archive to disk'); | ||||||
|         // await downloadFile(archiveUrl, archivePath) |         yield fs.promises.writeFile(archivePath, archiveData); | ||||||
|         // // console.log(`status=${response.status}`) |         archiveData = Buffer.from(''); // Free memory | ||||||
|         // // console.log(`headers=${JSON.stringify(response.headers)}`) |         // // Get the archive URL using the REST API | ||||||
|         // // console.log(`data=${response.data}`) |         // await retryHelper.execute(async () => { | ||||||
|         // // console.log(`data=${JSON.stringify(response.data)}`) |         //   // Prepare the archive stream | ||||||
|         // // for (const key of Object.keys(response.data)) { |         //   core.debug(`Preparing the archive stream: ${archivePath}`) | ||||||
|         // //   console.log(`data['${key}']=${response.data[key]}`) |         //   await io.rmRF(archivePath) | ||||||
|         // // } |         //   const fileStream = fs.createWriteStream(archivePath) | ||||||
|         // // Write archive to file |         //   const fileStreamClosed = getFileClosedPromise(fileStream) | ||||||
|         // const runnerTemp = process.env['RUNNER_TEMP'] as string |         //   try { | ||||||
|         // assert.ok(runnerTemp, 'RUNNER_TEMP not defined') |         //     // Get the archive URL | ||||||
|         // const archivePath = path.join(runnerTemp, 'checkout.tar.gz') |         //     core.info('Getting archive URL') | ||||||
|         // await io.rmRF(archivePath) |         //     const archiveUrl = await getArchiveUrl( | ||||||
|  |         //       accessToken, | ||||||
|  |         //       owner, | ||||||
|  |         //       repo, | ||||||
|  |         //       ref, | ||||||
|  |         //       commit | ||||||
|  |         //     ) | ||||||
|  |         //     // Download the archive | ||||||
|  |         //     core.info('Downloading the archive') // Do not print the archive URL because it has an embedded token | ||||||
|  |         //     await downloadFile(archiveUrl, fileStream) | ||||||
|  |         //   } finally { | ||||||
|  |         //     fileStream.end() | ||||||
|  |         //     await fileStreamClosed | ||||||
|  |         //   } | ||||||
|  |         // }) | ||||||
|         // await fs.promises.writeFile(archivePath, raw) |         // await fs.promises.writeFile(archivePath, raw) | ||||||
|         // // await exec.exec(`ls -la "${archiveFile}"`, [], { |         // // await exec.exec(`ls -la "${archiveFile}"`, [], { | ||||||
|         // //   cwd: repositoryPath |         // //   cwd: repositoryPath | ||||||
|         // // } as ExecOptions) |         // // } as ExecOptions) | ||||||
|         // Extract archive |         // Extract archive | ||||||
|         const extractPath = path.join(runnerTemp, `checkout-archive${IS_WINDOWS ? '.zip' : '.tar.gz'}`); |         const extractPath = path.join(runnerTemp, `checkout`); | ||||||
|         yield io.rmRF(extractPath); |         yield io.rmRF(extractPath); | ||||||
|         yield io.mkdirP(extractPath); |         yield io.mkdirP(extractPath); | ||||||
|         if (IS_WINDOWS) { |         if (IS_WINDOWS) { | ||||||
| @@ -8457,42 +8442,93 @@ function downloadRepository(accessToken, owner, repo, ref, commit, repositoryPat | |||||||
|     }); |     }); | ||||||
| } | } | ||||||
| exports.downloadRepository = downloadRepository; | exports.downloadRepository = downloadRepository; | ||||||
| function downloadFile(url, fileStream) { | function downloadArchive(accessToken, owner, repo, ref, commit) { | ||||||
|     return new Promise((resolve, reject) => { |     return __awaiter(this, void 0, void 0, function* () { | ||||||
|         try { |         const octokit = new github.GitHub(accessToken); | ||||||
|             https.get(url, (response) => { |         const params = { | ||||||
|                 if (response.statusCode != 200) { |             owner: owner, | ||||||
|                     reject(`Request failed with status '${response.statusCode}'`); |             repo: repo, | ||||||
|                     response.resume(); // Consume response data to free up memory |             archive_format: IS_WINDOWS ? 'zipball' : 'tarball', | ||||||
|                     return; |             ref: refHelper.getDownloadRef(ref, commit) | ||||||
|                 } |         }; | ||||||
|                 response.on('data', chunk => { |         const response = yield octokit.repos.getArchiveLink(params); | ||||||
|                     fileStream.write(chunk); |         console.log('GOT THE RESPONSE'); | ||||||
|                 }); |         console.log(`status=${response.status}`); | ||||||
|                 response.on('end', () => { |         console.log(`headers=${JSON.stringify(response.headers)}`); | ||||||
|                     resolve(); |         console.log(`data=${JSON.stringify(response.data)}`); | ||||||
|                 }); |         if (response.status != 200) { | ||||||
|                 response.on('error', err => { |             throw new Error(`Unexpected response from GitHub API. Status: '${response.status}'`); | ||||||
|                     reject(err); |  | ||||||
|                 }); |  | ||||||
|                 // response.pipe(fileStream) |  | ||||||
|             }); |  | ||||||
|         } |  | ||||||
|         catch (err) { |  | ||||||
|             reject(err); |  | ||||||
|         } |         } | ||||||
|  |         return Buffer.from(response.data); // response.data is ArrayBuffer | ||||||
|     }); |     }); | ||||||
| } | } | ||||||
| function getFileClosedPromise(stream) { | // async function getArchiveUrl( | ||||||
|     return new Promise((resolve, reject) => { | //   accessToken: string, | ||||||
|         stream.on('error', err => { | //   owner: string, | ||||||
|             reject(err); | //   repo: string, | ||||||
|         }); | //   ref: string, | ||||||
|         stream.on('finish', () => { | //   commit: string | ||||||
|             resolve(); | // ): Promise<string> { | ||||||
|         }); | //   const octokit = new github.GitHub(accessToken) | ||||||
|     }); | //   const params: RequestOptions & ReposGetArchiveLinkParams = { | ||||||
| } | //     method: 'HEAD', | ||||||
|  | //     owner: owner, | ||||||
|  | //     repo: repo, | ||||||
|  | //     archive_format: IS_WINDOWS ? 'zipball' : 'tarball', | ||||||
|  | //     ref: refHelper.getDownloadRef(ref, commit) | ||||||
|  | //   } | ||||||
|  | //   const response = await octokit.repos.getArchiveLink(params) | ||||||
|  | //   console.log('GOT THE RESPONSE') | ||||||
|  | //   console.log(`status=${response.status}`) | ||||||
|  | //   console.log(`headers=${JSON.stringify(response.headers)}`) | ||||||
|  | //   console.log(`data=${JSON.stringify(response.data)}`) | ||||||
|  | //   if (response.status != 200) { | ||||||
|  | //     throw new Error( | ||||||
|  | //       `Unexpected response from GitHub API. Status: '${response.status}'` | ||||||
|  | //     ) | ||||||
|  | //   } | ||||||
|  | //   console.log('GETTING THE LOCATION') | ||||||
|  | //   const archiveUrl = response.headers['Location'] // Do not print the archive URL because it has an embedded token | ||||||
|  | //   assert.ok( | ||||||
|  | //     archiveUrl, | ||||||
|  | //     `Expected GitHub API response to contain 'Location' header` | ||||||
|  | //   ) | ||||||
|  | //   return archiveUrl | ||||||
|  | // } | ||||||
|  | // function downloadFile(url: string, fileStream: WriteStream): Promise<void> { | ||||||
|  | //   return new Promise((resolve, reject) => { | ||||||
|  | //     try { | ||||||
|  | //       https.get(url, (response: IncomingMessage) => { | ||||||
|  | //         if (response.statusCode != 200) { | ||||||
|  | //           reject(`Request failed with status '${response.statusCode}'`) | ||||||
|  | //           response.resume() // Consume response data to free up memory | ||||||
|  | //           return | ||||||
|  | //         } | ||||||
|  | //         response.on('data', chunk => { | ||||||
|  | //           fileStream.write(chunk) | ||||||
|  | //         }) | ||||||
|  | //         response.on('end', () => { | ||||||
|  | //           resolve() | ||||||
|  | //         }) | ||||||
|  | //         response.on('error', err => { | ||||||
|  | //           reject(err) | ||||||
|  | //         }) | ||||||
|  | //       }) | ||||||
|  | //     } catch (err) { | ||||||
|  | //       reject(err) | ||||||
|  | //     } | ||||||
|  | //   }) | ||||||
|  | // } | ||||||
|  | // function getFileClosedPromise(stream: WriteStream): Promise<void> { | ||||||
|  | //   return new Promise((resolve, reject) => { | ||||||
|  | //     stream.on('error', err => { | ||||||
|  | //       reject(err) | ||||||
|  | //     }) | ||||||
|  | //     stream.on('finish', () => { | ||||||
|  | //       resolve() | ||||||
|  | //     }) | ||||||
|  | //   }) | ||||||
|  | // } | ||||||
|  |  | ||||||
|  |  | ||||||
| /***/ }), | /***/ }), | ||||||
|   | |||||||
| @@ -11,8 +11,7 @@ import * as retryHelper from './retry-helper' | |||||||
| import * as toolCache from '@actions/tool-cache' | import * as toolCache from '@actions/tool-cache' | ||||||
| import {ExecOptions} from '@actions/exec/lib/interfaces' | import {ExecOptions} from '@actions/exec/lib/interfaces' | ||||||
| import {IncomingMessage} from 'http' | import {IncomingMessage} from 'http' | ||||||
| import {ReposGetArchiveLinkParams} from '@octokit/rest' | import {RequestOptions, ReposGetArchiveLinkParams} from '@octokit/rest' | ||||||
| import {RequestOptions} from 'https' |  | ||||||
| import {WriteStream} from 'fs' | import {WriteStream} from 'fs' | ||||||
|  |  | ||||||
| const IS_WINDOWS = process.platform === 'win32' | const IS_WINDOWS = process.platform === 'win32' | ||||||
| @@ -29,78 +28,52 @@ export async function downloadRepository( | |||||||
|   const runnerTemp = process.env['RUNNER_TEMP'] as string |   const runnerTemp = process.env['RUNNER_TEMP'] as string | ||||||
|   assert.ok(runnerTemp, 'RUNNER_TEMP not defined') |   assert.ok(runnerTemp, 'RUNNER_TEMP not defined') | ||||||
|   const archivePath = path.join(runnerTemp, 'checkout.tar.gz') |   const archivePath = path.join(runnerTemp, 'checkout.tar.gz') | ||||||
|   // await fs.promises.writeFile(archivePath, raw) |  | ||||||
|  |  | ||||||
|   // Get the archive URL using the REST API |   // Ensure file does not exist | ||||||
|   await retryHelper.execute(async () => { |   core.debug(`Ensuring archive file does not exist: ${archivePath}`) | ||||||
|     // Prepare the archive stream |   await io.rmRF(archivePath) | ||||||
|     core.debug(`Preparing the archive stream: ${archivePath}`) |  | ||||||
|     await io.rmRF(archivePath) |  | ||||||
|     const fileStream = fs.createWriteStream(archivePath) |  | ||||||
|     const fileStreamClosed = getFileClosedPromise(fileStream) |  | ||||||
|  |  | ||||||
|     try { |   // Download the archive | ||||||
|       // Get the archive URL using the GitHub REST API |   let archiveData = await retryHelper.execute(async () => { | ||||||
|       core.info('Getting archive URL from GitHub REST API') |     core.info('Downloading the archive using the REST API') | ||||||
|       const octokit = new github.GitHub(accessToken) |     return await downloadArchive(accessToken, owner, repo, ref, commit) | ||||||
|       const params: RequestOptions & ReposGetArchiveLinkParams = { |  | ||||||
|         method: 'HEAD', |  | ||||||
|         archive_format: IS_WINDOWS ? 'zipball' : 'tarball', |  | ||||||
|         owner: owner, |  | ||||||
|         repo: repo, |  | ||||||
|         ref: refHelper.getDownloadRef(ref, commit) |  | ||||||
|       } |  | ||||||
|       const response = await octokit.repos.getArchiveLink(params) |  | ||||||
|       console.log('GOT THE RESPONSE') |  | ||||||
|       if (response.status != 302) { |  | ||||||
|         throw new Error( |  | ||||||
|           `Unexpected response from GitHub API. Status: '${response.status}'` |  | ||||||
|         ) |  | ||||||
|       } |  | ||||||
|       console.log('GETTING THE LOCATION') |  | ||||||
|       const archiveUrl = response.headers['Location'] // Do not print the archive URL because it has an embedded token |  | ||||||
|       assert.ok( |  | ||||||
|         archiveUrl, |  | ||||||
|         `Expected GitHub API response to contain 'Location' header` |  | ||||||
|       ) |  | ||||||
|  |  | ||||||
|       // Download the archive |  | ||||||
|       core.info('Downloading the archive') // Do not print the archive URL because it has an embedded token |  | ||||||
|       await downloadFile(archiveUrl, fileStream) |  | ||||||
|     } finally { |  | ||||||
|       await fileStreamClosed |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     // return Buffer.from(response.data) // response.data is ArrayBuffer |  | ||||||
|   }) |   }) | ||||||
|  |  | ||||||
|   // // Download the archive |   // Write archive to disk | ||||||
|   // core.info('Downloading the archive') // Do not print the URL since it contains a token to download the archive |   core.info('Writing archive to disk') | ||||||
|   // await downloadFile(archiveUrl, archivePath) |   await fs.promises.writeFile(archivePath, archiveData) | ||||||
|  |   archiveData = Buffer.from('') // Free memory | ||||||
|  |  | ||||||
|   // // console.log(`status=${response.status}`) |   // // Get the archive URL using the REST API | ||||||
|   // // console.log(`headers=${JSON.stringify(response.headers)}`) |   // await retryHelper.execute(async () => { | ||||||
|   // // console.log(`data=${response.data}`) |   //   // Prepare the archive stream | ||||||
|   // // console.log(`data=${JSON.stringify(response.data)}`) |   //   core.debug(`Preparing the archive stream: ${archivePath}`) | ||||||
|   // // for (const key of Object.keys(response.data)) { |   //   await io.rmRF(archivePath) | ||||||
|   // //   console.log(`data['${key}']=${response.data[key]}`) |   //   const fileStream = fs.createWriteStream(archivePath) | ||||||
|   // // } |   //   const fileStreamClosed = getFileClosedPromise(fileStream) | ||||||
|  |  | ||||||
|   // // Write archive to file |   //   try { | ||||||
|   // const runnerTemp = process.env['RUNNER_TEMP'] as string |   //     // Get the archive URL | ||||||
|   // assert.ok(runnerTemp, 'RUNNER_TEMP not defined') |   //     core.info('Getting archive URL') | ||||||
|   // const archivePath = path.join(runnerTemp, 'checkout.tar.gz') |   //     const archiveUrl = await getArchiveUrl( | ||||||
|   // await io.rmRF(archivePath) |   //       accessToken, | ||||||
|   // await fs.promises.writeFile(archivePath, raw) |   //       owner, | ||||||
|   // // await exec.exec(`ls -la "${archiveFile}"`, [], { |   //       repo, | ||||||
|   // //   cwd: repositoryPath |   //       ref, | ||||||
|   // // } as ExecOptions) |   //       commit | ||||||
|  |   //     ) | ||||||
|  |  | ||||||
|  |   //     // Download the archive | ||||||
|  |   //     core.info('Downloading the archive') // Do not print the archive URL because it has an embedded token | ||||||
|  |   //     await downloadFile(archiveUrl, fileStream) | ||||||
|  |   //   } finally { | ||||||
|  |   //     fileStream.end() | ||||||
|  |   //     await fileStreamClosed | ||||||
|  |   //   } | ||||||
|  |   // }) | ||||||
|  |  | ||||||
|   // Extract archive |   // Extract archive | ||||||
|   const extractPath = path.join( |   const extractPath = path.join(runnerTemp, `checkout`) | ||||||
|     runnerTemp, |  | ||||||
|     `checkout-archive${IS_WINDOWS ? '.zip' : '.tar.gz'}` |  | ||||||
|   ) |  | ||||||
|   await io.rmRF(extractPath) |   await io.rmRF(extractPath) | ||||||
|   await io.mkdirP(extractPath) |   await io.mkdirP(extractPath) | ||||||
|   if (IS_WINDOWS) { |   if (IS_WINDOWS) { | ||||||
| @@ -108,9 +81,6 @@ export async function downloadRepository( | |||||||
|   } else { |   } else { | ||||||
|     await toolCache.extractTar(archivePath, extractPath) |     await toolCache.extractTar(archivePath, extractPath) | ||||||
|   } |   } | ||||||
|   // await exec.exec(`tar -xzf "${archiveFile}"`, [], { |  | ||||||
|   //   cwd: extractPath |  | ||||||
|   // } as ExecOptions) |  | ||||||
|  |  | ||||||
|   // Determine the real directory to copy (ignore extra dir at root of the archive) |   // Determine the real directory to copy (ignore extra dir at root of the archive) | ||||||
|   const archiveFileNames = await fs.promises.readdir(extractPath) |   const archiveFileNames = await fs.promises.readdir(extractPath) | ||||||
| @@ -134,40 +104,101 @@ export async function downloadRepository( | |||||||
|   } as ExecOptions) |   } as ExecOptions) | ||||||
| } | } | ||||||
|  |  | ||||||
| function downloadFile(url: string, fileStream: WriteStream): Promise<void> { | async function downloadArchive( | ||||||
|   return new Promise((resolve, reject) => { |   accessToken: string, | ||||||
|     try { |   owner: string, | ||||||
|       https.get(url, (response: IncomingMessage) => { |   repo: string, | ||||||
|         if (response.statusCode != 200) { |   ref: string, | ||||||
|           reject(`Request failed with status '${response.statusCode}'`) |   commit: string | ||||||
|           response.resume() // Consume response data to free up memory | ): Promise<Buffer> { | ||||||
|           return |   const octokit = new github.GitHub(accessToken) | ||||||
|         } |   const params: ReposGetArchiveLinkParams = { | ||||||
|  |     owner: owner, | ||||||
|  |     repo: repo, | ||||||
|  |     archive_format: IS_WINDOWS ? 'zipball' : 'tarball', | ||||||
|  |     ref: refHelper.getDownloadRef(ref, commit) | ||||||
|  |   } | ||||||
|  |   const response = await octokit.repos.getArchiveLink(params) | ||||||
|  |   console.log('GOT THE RESPONSE') | ||||||
|  |   console.log(`status=${response.status}`) | ||||||
|  |   console.log(`headers=${JSON.stringify(response.headers)}`) | ||||||
|  |   console.log(`data=${JSON.stringify(response.data)}`) | ||||||
|  |   if (response.status != 200) { | ||||||
|  |     throw new Error( | ||||||
|  |       `Unexpected response from GitHub API. Status: '${response.status}'` | ||||||
|  |     ) | ||||||
|  |   } | ||||||
|  |  | ||||||
|         response.on('data', chunk => { |   return Buffer.from(response.data) // response.data is ArrayBuffer | ||||||
|           fileStream.write(chunk) |  | ||||||
|         }) |  | ||||||
|         response.on('end', () => { |  | ||||||
|           resolve() |  | ||||||
|         }) |  | ||||||
|         response.on('error', err => { |  | ||||||
|           reject(err) |  | ||||||
|         }) |  | ||||||
|         // response.pipe(fileStream) |  | ||||||
|       }) |  | ||||||
|     } catch (err) { |  | ||||||
|       reject(err) |  | ||||||
|     } |  | ||||||
|   }) |  | ||||||
| } | } | ||||||
|  |  | ||||||
| function getFileClosedPromise(stream: WriteStream): Promise<void> { | // async function getArchiveUrl( | ||||||
|   return new Promise((resolve, reject) => { | //   accessToken: string, | ||||||
|     stream.on('error', err => { | //   owner: string, | ||||||
|       reject(err) | //   repo: string, | ||||||
|     }) | //   ref: string, | ||||||
|     stream.on('finish', () => { | //   commit: string | ||||||
|       resolve() | // ): Promise<string> { | ||||||
|     }) | //   const octokit = new github.GitHub(accessToken) | ||||||
|   }) | //   const params: RequestOptions & ReposGetArchiveLinkParams = { | ||||||
| } | //     method: 'HEAD', | ||||||
|  | //     owner: owner, | ||||||
|  | //     repo: repo, | ||||||
|  | //     archive_format: IS_WINDOWS ? 'zipball' : 'tarball', | ||||||
|  | //     ref: refHelper.getDownloadRef(ref, commit) | ||||||
|  | //   } | ||||||
|  | //   const response = await octokit.repos.getArchiveLink(params) | ||||||
|  | //   console.log('GOT THE RESPONSE') | ||||||
|  | //   console.log(`status=${response.status}`) | ||||||
|  | //   console.log(`headers=${JSON.stringify(response.headers)}`) | ||||||
|  | //   console.log(`data=${JSON.stringify(response.data)}`) | ||||||
|  | //   if (response.status != 200) { | ||||||
|  | //     throw new Error( | ||||||
|  | //       `Unexpected response from GitHub API. Status: '${response.status}'` | ||||||
|  | //     ) | ||||||
|  | //   } | ||||||
|  | //   console.log('GETTING THE LOCATION') | ||||||
|  | //   const archiveUrl = response.headers['Location'] // Do not print the archive URL because it has an embedded token | ||||||
|  | //   assert.ok( | ||||||
|  | //     archiveUrl, | ||||||
|  | //     `Expected GitHub API response to contain 'Location' header` | ||||||
|  | //   ) | ||||||
|  | //   return archiveUrl | ||||||
|  | // } | ||||||
|  |  | ||||||
|  | // function downloadFile(url: string, fileStream: WriteStream): Promise<void> { | ||||||
|  | //   return new Promise((resolve, reject) => { | ||||||
|  | //     try { | ||||||
|  | //       https.get(url, (response: IncomingMessage) => { | ||||||
|  | //         if (response.statusCode != 200) { | ||||||
|  | //           reject(`Request failed with status '${response.statusCode}'`) | ||||||
|  | //           response.resume() // Consume response data to free up memory | ||||||
|  | //           return | ||||||
|  | //         } | ||||||
|  |  | ||||||
|  | //         response.on('data', chunk => { | ||||||
|  | //           fileStream.write(chunk) | ||||||
|  | //         }) | ||||||
|  | //         response.on('end', () => { | ||||||
|  | //           resolve() | ||||||
|  | //         }) | ||||||
|  | //         response.on('error', err => { | ||||||
|  | //           reject(err) | ||||||
|  | //         }) | ||||||
|  | //       }) | ||||||
|  | //     } catch (err) { | ||||||
|  | //       reject(err) | ||||||
|  | //     } | ||||||
|  | //   }) | ||||||
|  | // } | ||||||
|  |  | ||||||
|  | // function getFileClosedPromise(stream: WriteStream): Promise<void> { | ||||||
|  | //   return new Promise((resolve, reject) => { | ||||||
|  | //     stream.on('error', err => { | ||||||
|  | //       reject(err) | ||||||
|  | //     }) | ||||||
|  | //     stream.on('finish', () => { | ||||||
|  | //       resolve() | ||||||
|  | //     }) | ||||||
|  | //   }) | ||||||
|  | // } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user