diff --git a/.github/README.md b/.github/README.md index da0012a..242f76f 100644 --- a/.github/README.md +++ b/.github/README.md @@ -412,6 +412,7 @@ ass has a number of pre-made npm scripts for you to use. **All** of these script | `dev` | Chains the `build` and `compile` scripts together. | | `setup` | Starts the easy setup process. Should be run after any updates that introduce new config options. | | `metrics` | Runs the metrics script. This is a simple script that outputs basic resource statistics. | +| `purge` | Purges all uploads and data associated with them. This does **not** delete any users, however. | | `new-token` | Generates a new API token. Accepts one parameter for specifying a username, like `npm run new-token `. ass automatically detects the new token & reloads it, so there's no need to restart the server. | | `engine-check` | Ensures your environment meets the minimum Node & npm version requirements. | | `docker-logs` | Alias for `docker-compose logs -f --tail=50 --no-log-prefix ass` | diff --git a/package.json b/package.json index a71cf64..fd6c265 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "engine-check": "node dist/checkEngine.js", "prestart": "npm run engine-check", "presetup": "npm run engine-check", + "purge": "node dist/purge.js", "docker-logs": "docker-compose logs -f --tail=50 --no-log-prefix ass", "docker-update": "git pull && npm run docker-uplite", "docker-uplite": "docker-compose up --force-recreate --build -d && docker image prune -f", diff --git a/src/purge.ts b/src/purge.ts new file mode 100644 index 0000000..41f2178 --- /dev/null +++ b/src/purge.ts @@ -0,0 +1,16 @@ +import { TLog } from '@tycrek/log'; +import fs from 'fs-extra'; +import path from 'path'; + +const log = new TLog(); +const uploadsPath = path.join(process.cwd(), 'uploads/'); +const dataPath = path.join(process.cwd(), 'data.json'); + +if (fs.existsSync(uploadsPath)) { + fs.removeSync(uploadsPath); + log.success('Deleted', uploadsPath); +} +if (fs.existsSync(dataPath)) { + fs.removeSync(dataPath); + log.success('Deleted', dataPath); +}