Skip to content

Commit

Permalink
chore(repo): more comprehensive nuke script (#4870)
Browse files Browse the repository at this point in the history
  • Loading branch information
jacekradko authored Jan 13, 2025
1 parent fae1133 commit 9a0fe7c
Show file tree
Hide file tree
Showing 7 changed files with 1,405 additions and 1,488 deletions.
2 changes: 2 additions & 0 deletions .changeset/flat-knives-impress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"lint:attw": "FORCE_COLOR=1 turbo lint:attw",
"lint:fix": "FORCE_COLOR=1 turbo lint -- --fix",
"lint:publint": "FORCE_COLOR=1 turbo lint:publint",
"nuke": "./scripts/nuke.sh",
"nuke": "node ./scripts/nuke.mjs",
"prepare": "husky install",
"release": "changeset publish && git push --follow-tags",
"release:canary": "changeset publish --tag canary --no-git-tag",
Expand Down Expand Up @@ -107,7 +107,7 @@
"verdaccio": "^5.26.3",
"vitest": "2.1.4",
"yalc": "1.0.0-pre.53",
"zx": "^7.2.3"
"zx": "catalog:repo"
},
"packageManager": "pnpm@9.13.0+sha512.beb9e2a803db336c10c9af682b58ad7181ca0fbd0d4119f2b33d5f2582e96d6c0d93c85b23869295b765170fbdaa92890c0da6ada457415039769edf3c959efe",
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/theme-builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@
"eslint-config-next": "14.2.7",
"postcss": "^8.4.49",
"tailwindcss": "^3.4.17",
"zx": "^8.1.9"
"zx": "catalog:repo"
}
}
2,806 changes: 1,334 additions & 1,472 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ catalogs:
tslib: 2.4.1
tsup: 8.3.5
typescript: 5.6.3
zx: 8.3.0
65 changes: 65 additions & 0 deletions scripts/nuke.mjs
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'));
13 changes: 0 additions & 13 deletions scripts/nuke.sh

This file was deleted.

0 comments on commit 9a0fe7c

Please sign in to comment.