Merge branch 'tycrek:master' into quality-check

pull/238/head
Gauvino 6 months ago committed by GitHub
commit bb2bd5eaf3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,7 +1,6 @@
name: Merge Conflict Labeler
on:
push:
pull_request_target:
types: [ synchronize ]
@ -15,6 +14,6 @@ jobs:
if: ${{ github.event_name == 'push' || github.event_name == 'pull_request_target'}}
with:
dirtyLabel: 'merge conflict'
commentOnDirty: 'This pull request has merge conflicts. Please resolve the conflicts so the PR can be successfully reviewed and merged.'
commentOnClean: "Conflicts have been resolved. A maintainer will review the pull request shortly."
commentOnDirty: '**[AUTOMATED MESSAGE]** 🔴 This Pull Request has merge conflicts. Please resolve the conflicts so the PR can be successfully reviewed and merged.'
commentOnClean: '**[AUTOMATED MESSAGE]** 🟢 Conflicts have been resolved.'
repoToken: "${{ secrets.GH_TOKEN }}"

1140
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -1,6 +1,6 @@
{
"name": "ass",
"version": "0.14.6",
"version": "0.14.8",
"description": "The simple self-hosted ShareX server",
"main": "ass.js",
"engines": {
@ -42,10 +42,10 @@
"url": "https://patreon.com/tycrek"
},
"dependencies": {
"@tinycreek/postcss-font-magician": "^4.1.0",
"@tinycreek/postcss-font-magician": "^4.2.0",
"@tsconfig/node16": "^1.0.1",
"@tycrek/discord-hookr": "^0.1.0",
"@tycrek/express-postcss": "^0.4.0",
"@tycrek/express-postcss": "^0.4.1",
"@tycrek/joint": "^1.0.0-1",
"@tycrek/log": "^0.7.1",
"@tycrek/papito": "^0.3.4",
@ -53,7 +53,7 @@
"any-shell-escape": "^0.1.1",
"autoprefixer": "^10.4.16",
"aws-sdk": "^2.1467.0",
"axios": "^1.5.1",
"axios": "^1.6.0",
"bcrypt": "^5.1.1",
"chalk": "^4.1.2",
"check-node-version": "^4.2.1",
@ -74,7 +74,6 @@
"sanitize-filename": "^1.6.3",
"sharp": "^0.32.6",
"stream-to-array": "^2.3.0",
"submodule": "^1.2.1",
"tailwindcss": "^3.3.3",
"typescript": "^4.9.5",
"uuid": "^8.3.2"
@ -92,7 +91,6 @@
"@types/node-fetch": "^2.5.12",
"@types/sharp": "^0.30.2",
"@types/stream-to-array": "^2.3.0",
"@types/tailwindcss": "^3.0.9",
"@types/uuid": "^8.3.1",
"@types/ws": "^7.4.7"
}

@ -87,8 +87,7 @@ app.get('/', (req, res, next) =>
res.redirect(homepage))
// Set up custom frontend
const ASS_FRONTEND = fs.existsSync(path(`./${frontendName}/package.json`)) ? (require('submodule'), require(`../${frontendName}`)) : { enabled: false };
ASS_FRONTEND.enabled && app.use(ASS_FRONTEND.endpoint, ASS_FRONTEND.router); // skipcq: JS-0093
const ASS_FRONTEND = { enabled: false }; // ! Disabled in 0.14.7
// Upload router (has to come after custom frontends as express-busboy interferes with all POST calls)
app.use('/', ROUTERS.upload);
@ -127,7 +126,7 @@ app.use((err: ErrWrap, _req: Request, res: Response) => {
.info('Users', `${users.length}`)
.info('Files', `${data().size}`)
.info('Data engine', data().name, data().type)
.info('Frontend', ASS_FRONTEND.enabled ? ASS_FRONTEND.brand : 'disabled', `${ASS_FRONTEND.enabled ? `${getTrueHttp()}${getTrueDomain()}${ASS_FRONTEND.endpoint}` : ''}`)
.info('Frontend', 'disabled')
.info('Custom index', ASS_INDEX ?? 'disabled')
.blank()
.callback(() => app.listen(port, host, () => log.success('Ready for uploads', `Storing resources ${s3enabled ? 'in S3' : 'on disk'}`)));

@ -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))

@ -23,7 +23,7 @@ if (process.argv.length < 4) {
axios.post(`http://localhost:${port}/api/user`, { username, password, admin, meta }, { headers: { 'Authorization': cliKey } })
.then((response) => {
const user = response.data as User;
logger.info('User created', username, user.unid).callback(() => process.exit(0))
logger.info('User created', `${username} (${user.unid})`, `token: ${user.token}`).callback(() => process.exit(0))
})
.catch((err) => logger.error(err).callback(() => process.exit(1)));
}

Loading…
Cancel
Save