📁 Create fileManager for Temporary Project Setup 🗄
📝 Description
Develop a fileManager utility to create and clean up temporary Rust projects for compilation and testing. This utility will generate a Cargo.toml and src/lib.rs in a temporary directory, ensuring each request is isolated. It will also handle cleanup to prevent disk space issues. This modular approach enhances maintainability and supports secure execution by isolating user code.
🎯 Objective
Create a TypeScript utility in apps/backend/src/utils/ to manage temporary Rust project directories and files.
🗂 Structure
- Directory:
apps/backend/src/utils/
- Files:
apps/backend/src/utils/fileManager.ts
- Expected structure:
apps/backend/
├── src/
│ ├── utils/
│ │ └── fileManager.ts
✅ Requirements
- Create
fileManager.ts with two functions:
setupProject(tempDir: string, code: string): Promise<void>: Creates a Rust project with Cargo.toml and src/lib.rs.
cleanupProject(tempDir: string): Promise<void>: Deletes the temporary directory.
- Use
fs.promises for asynchronous file operations.
- Include a default
Cargo.toml with soroban-sdk = "21.2.0".
- Ensure
tempDir is unique (e.g., temp/project_${Date.now()}).
- Test file creation and cleanup with a sample directory.
- Commit changes with a message like
feat: create file manager utility.
- Push changes to the GitHub repository.
🏆 Expected Outcomes
fileManager creates temporary Rust projects with correct Cargo.toml and src/lib.rs.
- Cleanup function deletes directories without errors.
- Utility is reusable and handles errors gracefully.
- Changes are committed and pushed to GitHub.
🔗 References
📋 Notes
- Use
sanitize-filename (from a later issue) for safe directory names.
- Ensure cleanup is idempotent to handle partial failures.
📁 Create fileManager for Temporary Project Setup 🗄
📝 Description
Develop a
fileManagerutility to create and clean up temporary Rust projects for compilation and testing. This utility will generate aCargo.tomlandsrc/lib.rsin a temporary directory, ensuring each request is isolated. It will also handle cleanup to prevent disk space issues. This modular approach enhances maintainability and supports secure execution by isolating user code.🎯 Objective
Create a TypeScript utility in
apps/backend/src/utils/to manage temporary Rust project directories and files.🗂 Structure
apps/backend/src/utils/apps/backend/src/utils/fileManager.ts✅ Requirements
fileManager.tswith two functions:setupProject(tempDir: string, code: string): Promise<void>: Creates a Rust project withCargo.tomlandsrc/lib.rs.cleanupProject(tempDir: string): Promise<void>: Deletes the temporary directory.fs.promisesfor asynchronous file operations.Cargo.tomlwithsoroban-sdk = "21.2.0".tempDiris unique (e.g.,temp/project_${Date.now()}).feat: create file manager utility.🏆 Expected Outcomes
fileManagercreates temporary Rust projects with correctCargo.tomlandsrc/lib.rs.🔗 References
📋 Notes
sanitize-filename(from a later issue) for safe directory names.