Skip to content

Commit

Permalink
Update prebuild.js
Browse files Browse the repository at this point in the history
  • Loading branch information
aabhinavg1 authored Dec 27, 2024
1 parent ac4013c commit 62eca9d
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions prebuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ if (!PAT_TOKEN) {
throw new Error('PAT_TOKEN is not set or empty!');
}

console.log(`Using PAT_TOKEN: ${PAT_TOKEN}`);
console.log('Using PAT_TOKEN securely');

// Construct the repository URL using the PAT_TOKEN
// Construct the repository URL (with token embedded for authentication)
const REPO_URL = `https://${PAT_TOKEN}@github.com/aabhinavg1/newletter_modal.git`; // Correct repository name
const CLONE_DIR = path.resolve(__dirname, 'src/pages/newsletter_modal_updated');

Expand All @@ -34,7 +34,7 @@ const deleteDirectory = (dirPath) => {
// Delete the directory if it exists
deleteDirectory(CLONE_DIR);

// Clone the private repository
// Clone the private repository with the PAT token embedded in the URL
console.log('Cloning the private repository...');
try {
execSync(`git clone ${REPO_URL} ${CLONE_DIR}`, { stdio: 'inherit' });
Expand All @@ -43,4 +43,11 @@ try {
throw new Error('Failed to clone the repository. Check if the PAT is correct and has the necessary permissions.');
}

console.log('Repository cloned and files copied successfully.');
// Cleanup: Delete .git/config file containing PAT_TOKEN
const gitConfigPath = path.join(CLONE_DIR, '.git', 'config');
if (fs.existsSync(gitConfigPath)) {
console.log('Removing .git/config to delete PAT_TOKEN');
fs.rmSync(gitConfigPath);
}

console.log('Repository cloned and sensitive data cleaned up successfully.');

0 comments on commit 62eca9d

Please sign in to comment.