Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating the setup script to handle sample data import for Docker #2691

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
30adcd8
Updating the setup script to handle sample data import for Docker
Suyash878 Nov 18, 2024
eab9d94
Coderabbitai suggestion for improved syntax and error handling
Suyash878 Nov 18, 2024
41c9aac
Apply suggestions from code review
Suyash878 Nov 18, 2024
6144664
Moving the os module import to the top.
Suyash878 Nov 18, 2024
124127b
Merge branch 'develop' into issue#2270
Suyash878 Nov 19, 2024
0146c7f
Adding suggestions from coderabbit
Suyash878 Nov 19, 2024
49b4d2f
Merge branch 'develop' into issue#2270
Suyash878 Nov 22, 2024
6210573
Merge branch 'develop' into issue#2270
Suyash878 Nov 24, 2024
270e7fa
Improving the setup script prompts for the sample-data import for doc…
Nov 26, 2024
b7fbd06
Apply suggestions from code review
Suyash878 Nov 26, 2024
bd04520
Merge branch 'develop' into issue#2270
Suyash878 Nov 26, 2024
5443eb3
Fixing formatting issues
Nov 26, 2024
b31922f
Merge branch 'issue#2270' of https://github.com/Suyash878/talawa-api …
Nov 26, 2024
27df373
Adding suggestions from coderabbit
Suyash878 Dec 1, 2024
18fd631
fixing lint error
Suyash878 Dec 1, 2024
ee6b384
fixing formatting error
Suyash878 Dec 1, 2024
9b96d01
Improving error handling
Suyash878 Dec 4, 2024
3c10f42
Fixing linting and formatting errors
Suyash878 Dec 4, 2024
1962ba2
Apply suggestions from code review
Suyash878 Dec 4, 2024
cef2e14
Adding suggestions from coderabbit
Suyash878 Dec 5, 2024
4b71e18
Applying suggestions from coderabbit
Suyash878 Dec 5, 2024
1c56ca1
resolving the flaky test
Suyash878 Dec 8, 2024
6ff5257
Merge branch 'develop' into issue#2270
Suyash878 Dec 8, 2024
94bbaa5
Apply suggestions from code review
Suyash878 Dec 9, 2024
d706bbd
Update setup.ts
Suyash878 Dec 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

#!/bin/bash

npm run import:sample-data
Suyash878 marked this conversation as resolved.
Show resolved Hide resolved

51 changes: 51 additions & 0 deletions setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1181,6 +1181,57 @@ async function main(): Promise<void> {
console.log(
"\nCongratulations! Talawa API has been successfully setup! 🥂🎉",
);

/* Performing the sample data import for docker */

if (isDockerInstallation) {
console.log("Starting the sample data import for docker now...");

const entryPointScript = `#!/bin/bash
npm run import:sample-data
Suyash878 marked this conversation as resolved.
Show resolved Hide resolved
`;

const scriptPath = path.join(os.tmpdir(), `entrypoint-${Date.now()}.sh`);
```

Note: For this change to work, the `os` module would need to be imported at the top of the file if it's not already imported:
```typescript
import * as os from 'os';

Suyash878 marked this conversation as resolved.
Show resolved Hide resolved
try {
// Create script with proper permissions
fs.writeFileSync(scriptPath, entryPointScript, { mode: 0o755 });

// Execute script
exec(scriptPath, { timeout: 60000 }, (error, stdout, stderr) => {
// Clean up script file
fs.unlinkSync(scriptPath);

if (error) {
console.error("Error importing sample data:");
console.error(`Exit code: ${error.code}`);
console.error(`Error message: ${error.message}`);
return;
}

if (stderr) {
console.warn("Sample data import warnings:");
console.warn(stderr.trim());
}

if (stdout) {
console.log("Sample data import output:");
console.log(stdout.trim());
}
console.log("Sample data import complete.");
});
} catch (err) {
console.error("Failed to setup sample data import:", err);
if (fs.existsSync(scriptPath)) {
fs.unlinkSync(scriptPath);
}
}
}
}

main();
Loading