mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-27 07:14:56 +00:00
Optimize setup script to skip if packages already exist
Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com>
This commit is contained in:
1
package-lock.json
generated
1
package-lock.json
generated
@@ -7,6 +7,7 @@
|
||||
"": {
|
||||
"name": "spark-template",
|
||||
"version": "0.0.0",
|
||||
"hasInstallScript": true,
|
||||
"dependencies": {
|
||||
"@github/spark": ">=0.43.1 <1",
|
||||
"@heroicons/react": "^2.2.0",
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Setup script for creating the packages folder structure
|
||||
* This creates placeholder files for all packages referenced in package-glue.ts
|
||||
@@ -50,6 +52,30 @@ const packages = [
|
||||
}
|
||||
];
|
||||
|
||||
// Check if all packages already exist (optimization for postinstall)
|
||||
function allPackagesExist() {
|
||||
if (!fs.existsSync(packagesDir)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (const pkg of packages) {
|
||||
const componentsPath = path.join(packagesDir, pkg.id, 'seed', 'components.json');
|
||||
const metadataPath = path.join(packagesDir, pkg.id, 'seed', 'metadata.json');
|
||||
|
||||
if (!fs.existsSync(componentsPath) || !fs.existsSync(metadataPath)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Skip if everything is already set up
|
||||
if (allPackagesExist()) {
|
||||
console.log('✓ Packages folder already exists with all required packages.');
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
console.log('Setting up packages folder...\n');
|
||||
|
||||
// Create packages directory if it doesn't exist
|
||||
|
||||
Reference in New Issue
Block a user