Stijnus
commited on
Commit
·
cf90943
1
Parent(s):
2c991e4
test
Browse files- package.json +2 -1
- scripts/clean.js +45 -0
- scripts/clean.js.zip +0 -0
package.json
CHANGED
|
@@ -24,7 +24,8 @@
|
|
| 24 |
"typecheck": "tsc",
|
| 25 |
"typegen": "wrangler types",
|
| 26 |
"preview": "pnpm run build && pnpm run start",
|
| 27 |
-
"prepare": "husky"
|
|
|
|
| 28 |
},
|
| 29 |
"engines": {
|
| 30 |
"node": ">=18.18.0"
|
|
|
|
| 24 |
"typecheck": "tsc",
|
| 25 |
"typegen": "wrangler types",
|
| 26 |
"preview": "pnpm run build && pnpm run start",
|
| 27 |
+
"prepare": "husky",
|
| 28 |
+
"clean": "node scripts/clean.js"
|
| 29 |
},
|
| 30 |
"engines": {
|
| 31 |
"node": ">=18.18.0"
|
scripts/clean.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { rm, existsSync } from 'fs';
|
| 2 |
+
import { join } from 'path';
|
| 3 |
+
import { execSync } from 'child_process';
|
| 4 |
+
import { fileURLToPath } from 'url';
|
| 5 |
+
import { dirname } from 'path';
|
| 6 |
+
|
| 7 |
+
const __filename = fileURLToPath(import.meta.url);
|
| 8 |
+
const __dirname = dirname(__filename);
|
| 9 |
+
|
| 10 |
+
const dirsToRemove = ['node_modules/.vite', 'node_modules/.cache', '.cache', 'dist'];
|
| 11 |
+
|
| 12 |
+
console.log('🧹 Cleaning project...');
|
| 13 |
+
|
| 14 |
+
// Remove directories
|
| 15 |
+
for (const dir of dirsToRemove) {
|
| 16 |
+
const fullPath = join(__dirname, '..', dir);
|
| 17 |
+
|
| 18 |
+
try {
|
| 19 |
+
if (existsSync(fullPath)) {
|
| 20 |
+
console.log(`Removing ${dir}...`);
|
| 21 |
+
rm(fullPath, { recursive: true, force: true }, (err) => {
|
| 22 |
+
if (err) {
|
| 23 |
+
console.error(`Error removing ${dir}:`, err.message);
|
| 24 |
+
}
|
| 25 |
+
});
|
| 26 |
+
}
|
| 27 |
+
} catch (err) {
|
| 28 |
+
console.error(`Error removing ${dir}:`, err.message);
|
| 29 |
+
}
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
// Run pnpm commands
|
| 33 |
+
console.log('\n📦 Reinstalling dependencies...');
|
| 34 |
+
|
| 35 |
+
try {
|
| 36 |
+
execSync('pnpm install', { stdio: 'inherit' });
|
| 37 |
+
console.log('\n🗑️ Clearing pnpm cache...');
|
| 38 |
+
execSync('pnpm cache clean', { stdio: 'inherit' });
|
| 39 |
+
console.log('\n🏗️ Rebuilding project...');
|
| 40 |
+
execSync('pnpm build', { stdio: 'inherit' });
|
| 41 |
+
console.log('\n✨ Clean completed! You can now run pnpm dev');
|
| 42 |
+
} catch (err) {
|
| 43 |
+
console.error('\n❌ Error during cleanup:', err.message);
|
| 44 |
+
process.exit(1);
|
| 45 |
+
}
|
scripts/clean.js.zip
ADDED
|
Binary file (1.04 kB). View file
|
|
|