Merge branch 'dev/0.15.0' into dev/0.15.0

x-dev-15
X 7 months ago committed by GitHub
commit a0571d7fe6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -10,14 +10,11 @@
"scripts": {
"dev": "npm run build && npm start",
"fresh": "rm -dr .ass-data/ & npm run dev",
"build": "rm -dr dist-*/ & npm run build:backend && npm run build:frontend",
"build": "rm -dr dist-*/ & npm run build:backend && npm run build:frontend && npm run build:fix-frontend",
"build:backend": "tsc -p backend/",
"build:frontend": "tsc -p frontend/",
"postbuild:frontend": "node common/fix-frontend-js.js",
"start": "node dist-backend/app.js",
"cli-setpassword": "node dist/tools/script.setpassword.js",
"cli-testpassword": "node dist/tools/script.testpassword.js",
"cli-adduser": "node dist/tools/script.adduser.js"
"build:fix-frontend": "node common/fix-frontend-js.js",
"start": "node dist-backend/app.js"
},
"repository": "github:tycrek/ass",
"keywords": [
@ -29,13 +26,13 @@
"bugs": "https://github.com/tycrek/ass/issues",
"homepage": "https://github.com/tycrek/ass#readme",
"dependencies": {
"@aws-sdk/client-s3": "^3.437.0",
"@shoelace-style/shoelace": "^2.11.2",
"@aws-sdk/client-s3": "^3.456.0",
"@shoelace-style/shoelace": "^2.12.0",
"@tinycreek/postcss-font-magician": "^4.2.0",
"@tsconfig/node20": "^20.1.2",
"@tycrek/discord-hookr": "^0.1.0",
"@tycrek/express-postcss": "^0.4.1",
"@tycrek/joint": "^1.0.0-1",
"@tycrek/joint": "1.0.0-1",
"@tycrek/log": "^0.7.5",
"@xoi/gps-metadata-remover": "^1.1.2",
"any-shell-escape": "^0.1.1",
@ -45,14 +42,14 @@
"cssnano": "^6.0.1",
"express": "^4.18.2",
"express-busboy": "^10.1.0",
"express-rate-limit": "^7.1.3",
"express-rate-limit": "^7.1.4",
"express-session": "^1.17.3",
"ffmpeg-static": "^5.2.0",
"fs-extra": "^11.1.1",
"luxon": "^3.4.3",
"luxon": "^3.4.4",
"memorystore": "^1.6.7",
"mongoose": "^8.0.0",
"mysql2": "^3.6.2",
"mysql2": "^3.6.5",
"node-vibrant": "^3.1.6",
"pg": "^8.11.3",
"pug": "^3.0.2",
@ -60,17 +57,17 @@
"shoelace-fontawesome-pug": "^6.4.3",
"shoelace-pug-loader": "^2.11.0",
"tailwindcss": "^3.3.5",
"typescript": "^5.2.2"
"typescript": "^5.3.2"
},
"devDependencies": {
"@types/bcrypt": "^5.0.1",
"@types/express": "^4.17.20",
"@types/express-busboy": "^8.0.2",
"@types/express-session": "^1.17.9",
"@types/ffmpeg-static": "^3.0.2",
"@types/fs-extra": "^11.0.3",
"@types/luxon": "^3.3.3",
"@types/node": "^20.8.9",
"@types/pg": "^8.10.7"
"@types/bcrypt": "^5.0.2",
"@types/express": "^4.17.21",
"@types/express-busboy": "^8.0.3",
"@types/express-session": "^1.17.10",
"@types/ffmpeg-static": "^3.0.3",
"@types/fs-extra": "^11.0.4",
"@types/luxon": "^3.3.5",
"@types/node": "^20.10.0",
"@types/pg": "^8.10.9"
}
}

File diff suppressed because it is too large Load Diff

@ -41,7 +41,7 @@ const migrate = (authFileName = 'auth.json'): Promise<Users> => new Promise(asyn
const oldUsers = fs.readJsonSync(authPath).users as OldUsers;
// Create a new users object
const newUsers: Users = { users: [], meta: {} };
const newUsers: Users = { users: [], meta: {}, cliKey: nanoid(32) };
newUsers.migrated = true;
// Loop through each user
@ -69,38 +69,40 @@ const migrate = (authFileName = 'auth.json'): Promise<Users> => new Promise(asyn
.catch(reject)
// Migrate the datafile (token => uploader)
.then(() => data().get())
.then((fileData: [string, FileData][]) =>
.then(() => (!data())
? (log.warn('data.json not found. This may be a new install?'), Promise.resolve())
: data().get().then((fileData: [string, FileData][]) =>
// ! A note about this block.
// I know it's gross. But using Promise.all crashes low-spec servers, so I had to do it this way. Sorry.
// Thanks to CoPilot for writing `runQueue` :D
// ! A note about this block.
// I know it's gross. But using Promise.all crashes low-spec servers, so I had to do it this way. Sorry.
// Thanks to CoPilot for writing `runQueue` :D
// Wait for all the deletions and puts to finish
new Promise((resolve, reject) => {
// Wait for all the deletions and puts to finish
new Promise((resolve, reject) => {
// Create a queue of functions to run
const queue = fileData.map(([key, file]) => async () => {
// Create a queue of functions to run
const queue = fileData.map(([key, file]) => async () => {
// We need to use `newUsers` because `users` hasn't been re-assigned yet
const user = newUsers.users.find((user) => user.token === file.token!)?.unid ?? ''; // ? This is probably fine
// We need to use `newUsers` because `users` hasn't been re-assigned yet
const user = newUsers.users.find((user) => user.token === file.token!)?.unid ?? ''; // ? This is probably fine
// Because of the stupid way I wrote papito, we need to DEL before we can PUT
await data().del(key);
// Because of the stupid way I wrote papito, we need to DEL before we can PUT
await data().del(key);
// PUT the new data
return data().put(key, { ...file, uploader: user });
});
// PUT the new data
return data().put(key, { ...file, uploader: user });
});
// Recursively run the queue, hopefully sequentially without running out of memory
const runQueue = (index: number) => {
if (index >= queue.length) return resolve(void 0);
queue[index]().then(() => runQueue(index + 1)).catch(reject);
};
runQueue(0);
}))
// Recursively run the queue, hopefully sequentially without running out of memory
const runQueue = (index: number) => {
if (index >= queue.length) return resolve(void 0);
queue[index]().then(() => runQueue(index + 1)).catch(reject);
};
runQueue(0);
}))
.catch((err: any) => log.warn(err.message))
)
// We did it hoofuckingray
.then(() => log.success('Migrated all auth & file data to new auth system'))
.then(() => resolve(newUsers))

Loading…
Cancel
Save