Skip to content

Commit

Permalink
Remove MultiQC as a submodule and instead clone as prebuild (#298)
Browse files Browse the repository at this point in the history
* Remove MultiQC as a submodule and instead clone as prebuild

* Wave too

* Trailing comma

* Check .git folder

* Remove predev

* Update packages

* Gitignore

* Remove wave submodule

* Try-catch
  • Loading branch information
vladsavelyev authored Nov 20, 2024
1 parent 550bbb2 commit 6a348f4
Show file tree
Hide file tree
Showing 7 changed files with 535 additions and 465 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,7 @@ internal/tmp

# Local Netlify folder
.netlify

# OSS repo clones
multiqc_docs/multiqc_repo
wave_docs/wave_repo
6 changes: 0 additions & 6 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +0,0 @@
[submodule "wave_docs/wave_repo"]
path = wave_docs/wave_repo
url = https://github.com/seqeralabs/wave
[submodule "multiqc_docs/multiqc_repo"]
path = multiqc_docs/multiqc_repo
url = https://github.com/MultiQC/MultiQC
62 changes: 62 additions & 0 deletions internal/fetch-docs-oss.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import git from "simple-git";
import fs from "fs-extra";
import "dotenv/config";
import path from "path";
import { fileURLToPath } from "url";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

const repositories = [
{
name: 'multiqc',
url: 'https://github.com/MultiQC/MultiQC.git',
path: path.join(__dirname, "..", "multiqc_docs", "multiqc_repo")
},
{
name: 'wave',
url: 'https://github.com/seqeralabs/wave.git',
path: path.join(__dirname, "..", "wave_docs", "wave_repo")
}
];

// Function to clone or update a repository
async function cloneOrUpdateRepo({ name, url, path: repoPath }) {
const exists = await fs.pathExists(repoPath + "/.git");

try {
if (exists) {
console.log(`${name}: Cloned repo already exists, will pull latest changes`);
await git(repoPath).pull();
console.log(`✅ ${name}: Pulled latest changes`);
} else {
console.log(`${name}: Cloning into ${repoPath}`);
await git().clone(url, repoPath);
console.log(`✅ ${name}: Cloned`);
}
} catch (error) {
console.error(`❌ Error processing ${repo.name}:`);
console.error(error.message);
if (exists) {
console.error(`Try removing the directory: ${repoPath}`);
}
// Exit with error code 1 to stop any subsequent npm scripts
process.exit(1);
}

return git(repoPath);
}

// Clone/update all repositories
async function processRepositories() {
for (const repo of repositories) {
try {
await cloneOrUpdateRepo(repo);
} catch (error) {
console.error(`❌ Error processing ${repo.name}:`, error);
}
}
}

// Execute
processRepositories().catch(console.error);
1 change: 0 additions & 1 deletion multiqc_docs/multiqc_repo
Submodule multiqc_repo deleted from d66055
Loading

0 comments on commit 6a348f4

Please sign in to comment.