-
Notifications
You must be signed in to change notification settings - Fork 289
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(repo): more comprehensive nuke script (#4870)
- Loading branch information
1 parent
fae1133
commit 9a0fe7c
Showing
7 changed files
with
1,405 additions
and
1,488 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--- | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,4 @@ catalogs: | |
tslib: 2.4.1 | ||
tsup: 8.3.5 | ||
typescript: 5.6.3 | ||
zx: 8.3.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#!/usr/bin/env node | ||
|
||
import { access, constants, readdir } from 'node:fs/promises'; | ||
import { join, resolve } from 'node:path'; | ||
|
||
import { $ } from 'zx'; | ||
|
||
const $$ = $({ | ||
env: { NODE_ENV: 'production' }, | ||
// eslint-disable-next-line turbo/no-undeclared-env-vars | ||
verbose: !!process.env.VERBOSE, | ||
}); | ||
|
||
const DIRECTORIES_TO_CLEAN = ['.coverage', '.turbo', 'coverage', 'dist', 'node_modules']; | ||
|
||
// Iterate over `packages/*` | ||
try { | ||
const packagesDir = resolve('packages'); | ||
await access(packagesDir, constants.R_OK); | ||
|
||
try { | ||
const packages = await readdir(packagesDir); | ||
const promises = packages.map( | ||
dir => $$`rm -rf ${DIRECTORIES_TO_CLEAN.map(directory => join(join(packagesDir, dir), directory))}`, | ||
); | ||
|
||
await Promise.all(promises).then(() => void console.log(`Cleaned ${promises.length} packages`)); | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
} catch { | ||
console.log('Cannot access packages directory'); | ||
} | ||
|
||
// Iterate over `playground/*` | ||
try { | ||
const playgroundDir = resolve('playground'); | ||
await access(playgroundDir); | ||
try { | ||
const playgrounds = await readdir(playgroundDir); | ||
for (const dir of playgrounds) { | ||
try { | ||
await access(join(playgroundDir, dir, '.yalc'), constants.R_OK); | ||
$$({ | ||
cwd: join(playgroundDir, dir), | ||
})`rm -rf .yalc`.then(() => console.log('Removed .yalc from', dir)); | ||
} catch { | ||
// Ignore | ||
} | ||
} | ||
|
||
await Promise.allSettled( | ||
playgrounds.map( | ||
dir => $$`rm -rf ${DIRECTORIES_TO_CLEAN.map(directory => join(join(playgroundDir, dir), directory))}`, | ||
), | ||
).then(() => void console.log(`Cleaned playground directories`)); | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
} catch { | ||
console.log('Cannot access playground directory'); | ||
} | ||
|
||
await $$`rm -rf .turbo`.then(() => console.log('Removed root .turbo directory')); | ||
await $$`rm -rf node_modules`.then(() => console.log('Removed root node_modules')); |
This file was deleted.
Oops, something went wrong.