1
0
mirror of https://github.com/bpatrik/pigallery2.git synced 2024-11-21 17:56:45 +02:00

updating node to v16 and angular to v12

This commit is contained in:
Patrik J. Braun 2022-03-30 22:18:02 +02:00
parent 0e4063fe39
commit a2e576ec27
26 changed files with 15829 additions and 18031 deletions

View File

@ -16,7 +16,7 @@ jobs:
strategy:
matrix:
node-version: [14.x]
node-version: [16.x]
services:
mariadb:

View File

@ -1,7 +1,7 @@
dist: xenial
language: node_js
node_js:
- '14'
- '16'
env:
- PORT=35000 MYSQL_HOST='localhost' MYSQL_PASSWORD='' MYSQL_USERNAME='root' MYSQL_DATABASE='pigallery2_test'
services:

View File

@ -83,7 +83,7 @@
}
],
"styles": [
"bootstrap/dist/css/bootstrap.min.css",
"bootstrap/dist/css/bootstrap.css",
"ngx-bootstrap/datepicker/bs-datepicker.css",
"open-iconic/font/css/open-iconic-bootstrap.css",
"ngx-toastr/toastr.css",
@ -93,7 +93,7 @@
"src/frontend/styles.css"
],
"scripts": [
"node_modules/marked/lib/marked.js"
"node_modules/marked/marked.min.js"
],
"i18nMissingTranslation": "warning"
},

View File

@ -1,6 +1,6 @@
#-----------------BUILDER-----------------
#-----------------------------------------
FROM node:14-alpine3.15 AS builder
FROM node:16-alpine3.15 AS builder
RUN apk add --update-cache --repository https://alpine.global.ssl.fastly.net/alpine/v3.15/community/ \
python3 build-base sqlite-dev sqlite-libs vips-dev fftw-dev gcc g++ make libc6-compat && ln -snf /usr/bin/python3 /usr/bin/python
COPY pigallery2-release /app
@ -14,7 +14,7 @@ RUN mkdir -p /app/data/config && \
#-----------------MAIN--------------------
#-----------------------------------------
FROM node:14-alpine3.15 AS main
FROM node:16-alpine3.15 AS main
WORKDIR /app
ENV NODE_ENV=production \
# overrides only the default value of the settings (the actualy value can be overwritten through config.json)

View File

@ -1,6 +1,6 @@
#-----------------BUILDER-----------------
#-----------------------------------------
FROM node:14-bullseye AS builder
FROM node:16-bullseye AS builder
COPY pigallery2-release /app
WORKDIR /app
RUN npm install --unsafe-perm
@ -12,7 +12,7 @@ RUN mkdir -p /app/data/config && \
#-----------------MAIN--------------------
#-----------------------------------------
FROM node:14-bullseye-slim AS main
FROM node:16-bullseye-slim AS main
WORKDIR /app
ENV NODE_ENV=production \
# overrides only the default value of the settings (the actualy value can be overwritten through config.json)

View File

@ -1,6 +1,6 @@
#-----------------BUILDER-----------------
#-----------------------------------------
FROM node:14-buster AS builder
FROM node:16-buster AS builder
COPY pigallery2-release /app
WORKDIR /app
RUN npm install --unsafe-perm
@ -12,7 +12,7 @@ RUN mkdir -p /app/data/config && \
#-----------------MAIN--------------------
#-----------------------------------------
FROM node:14-buster-slim AS main
FROM node:16-buster-slim AS main
WORKDIR /app
ENV NODE_ENV=production \
# overrides only the default value of the settings (the actualy value can be overwritten through config.json)

View File

@ -1,6 +1,6 @@
#-----------------BUILDER-----------------
#-----------------------------------------
FROM node:14-buster AS builder
FROM node:16-buster AS builder
# LABEL maintainer="Patrik J. Braun"
# copying only package{-lock}.json to make node_modules cachable
RUN git clone https://github.com/bpatrik/pigallery2.git /build
@ -16,7 +16,7 @@ RUN npm install --unsafe-perm \
#-----------------MAIN--------------------
#-----------------------------------------
FROM node:14-buster-slim AS main
FROM node:16-buster-slim AS main
WORKDIR /app
ENV NODE_ENV=production \
# overrides only the default value of the settings (the actualy value can be overwritten through config.json)

33731
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -55,7 +55,7 @@
},
"devDependencies": {
"@angular-devkit/build-angular": "12.2.16",
"@angular-devkit/build-optimizer": "0.1102.17",
"@angular-devkit/build-optimizer": "0.1202.16",
"@angular/animations": "12.2.16",
"@angular/cli": "12.2.16",
"@angular/common": "12.2.16",
@ -94,7 +94,7 @@
"@types/sharp": "0.30.0",
"@types/winston": "2.4.4",
"@types/xml2js": "0.4.9",
"bootstrap": "5.1.3",
"bootstrap": "4.6.1",
"chai": "4.3.6",
"chai-http": "4.3.0",
"codelyzer": "6.0.2",
@ -124,10 +124,10 @@
"mocha": "9.2.2",
"ngx-bootstrap": "6.2.0",
"ngx-clipboard": "14.0.2",
"ngx-cookie-service": "11.0.2",
"ngx-markdown": "11.2.0",
"ngx-cookie-service": "12.0.3",
"ngx-markdown": "12.1.0",
"ngx-device-detector": "3.0.0",
"ngx-toastr": "13.2.1",
"ngx-toastr": "12.1.0",
"nyc": "15.1.0",
"open-iconic": "1.1.1",
"protractor": "7.0.0",
@ -152,6 +152,6 @@
"mysql": "2.18.1"
},
"engines": {
"node": ">=14.14 <15.0"
"node": ">=16 <17.0"
}
}
}

View File

@ -1,10 +1,10 @@
import * as cluster from 'cluster';
import {Server} from './server';
import {Worker} from './model/threading/Worker';
if (cluster.isMaster) {
const Server = require('./server').Server;
if ((cluster as any).isMaster) {
// tslint:disable-next-line:no-unused-expression
new Server();
} else {
const Worker = require('./model/threading/Worker').Worker;
Worker.process();
}

View File

@ -1,8 +1,9 @@
import {SharingDTO} from '../../../../common/entities/SharingDTO';
import {IObjectManager} from './IObjectManager';
import {FindOptionsWhere} from 'typeorm';
export interface ISharingManager extends IObjectManager {
findOne(filter: any): Promise<SharingDTO>;
findOne(filter: FindOptionsWhere<SharingDTO>): Promise<SharingDTO>;
createSharing(sharing: SharingDTO): Promise<SharingDTO>;

View File

@ -1,10 +1,11 @@
import {UserDTO, UserRoles} from '../../../../common/entities/UserDTO';
import {IObjectManager} from './IObjectManager';
import {FindOptionsWhere} from 'typeorm';
export interface IUserManager extends IObjectManager {
findOne(filter: any): Promise<UserDTO>;
findOne(filter: FindOptionsWhere<UserDTO>): Promise<UserDTO>;
find(filter: any): Promise<UserDTO[]>;
find(filter: FindOptionsWhere<UserDTO>): Promise<UserDTO[]>;
createUser(user: UserDTO): Promise<UserDTO>;

View File

@ -36,7 +36,7 @@ export class AlbumManager implements IAlbumManager {
public async addIfNotExistSavedSearch(name: string, searchQuery: SearchQueryDTO, lockedAlbum: boolean): Promise<void> {
const connection = await SQLConnection.getConnection();
const album = await connection.getRepository(SavedSearchEntity)
.findOne({name, searchQuery});
.findOneBy({name, searchQuery});
if (album) {
return;
}
@ -53,7 +53,7 @@ export class AlbumManager implements IAlbumManager {
const connection = await SQLConnection.getConnection();
if (await connection.getRepository(AlbumBaseEntity)
.count({id, locked: false}) !== 1) {
.countBy({id, locked: false}) !== 1) {
throw new Error('Could not delete album, id:' + id);
}

View File

@ -1,5 +1,5 @@
import 'reflect-metadata';
import {Connection, ConnectionOptions, createConnection, getConnection} from 'typeorm';
import {Connection, DataSourceOptions, createConnection, getConnection} from 'typeorm';
import {UserEntity} from './enitites/UserEntity';
import {UserRoles} from '../../../../common/entities/UserDTO';
import {PhotoEntity} from './enitites/PhotoEntity';
@ -104,7 +104,7 @@ export class SQLConnection {
if (Array.isArray(Config.Server.Database.enforcedUsers) &&
Config.Server.Database.enforcedUsers.length > 0) {
for (const uc of Config.Server.Database.enforcedUsers) {
const user = await userRepository.findOne({name: uc.name});
const user = await userRepository.findOneBy({name: uc.name});
if (!user) {
Logger.info(LOG_TAG, 'Saving enforced user: ' + uc.name);
const a = new UserEntity();
@ -123,7 +123,7 @@ export class SQLConnection {
}
// Add dummy Admin to the db
const admins = await userRepository.find({role: UserRoles.Admin});
const admins = await userRepository.findBy({role: UserRoles.Admin});
if (admins.length === 0) {
const a = new UserEntity();
a.name = 'admin';
@ -132,7 +132,7 @@ export class SQLConnection {
await userRepository.save(a);
}
const defAdmin = await userRepository.findOne({name: 'admin', role: UserRoles.Admin});
const defAdmin = await userRepository.findOneBy({name: 'admin', role: UserRoles.Admin});
if (defAdmin && PasswordHelper.comparePassword('admin', defAdmin.password)) {
NotificationManager.error('Using default admin user!', 'You are using the default admin/admin user/password, please change or remove it.');
}
@ -155,7 +155,7 @@ export class SQLConnection {
return path.join(ProjectPath.getAbsolutePath(config.dbFolder), 'sqlite.db');
}
private static async createConnection(options: ConnectionOptions): Promise<Connection> {
private static async createConnection(options: DataSourceOptions): Promise<Connection> {
if (options.type === 'sqlite' || options.type === 'better-sqlite3') {
return await createConnection(options);
}
@ -179,7 +179,7 @@ export class SQLConnection {
private static async schemeSync(connection: Connection): Promise<void> {
let version = null;
try {
version = await connection.getRepository(VersionEntity).findOne();
version = (await connection.getRepository(VersionEntity).find())[0];
} catch (ex) {
}
if (version && version.version === DataStructureVersion) {
@ -209,8 +209,8 @@ export class SQLConnection {
}
}
private static getDriver(config: ServerDataBaseConfig): ConnectionOptions {
let driver: ConnectionOptions = null;
private static getDriver(config: ServerDataBaseConfig): DataSourceOptions {
let driver: DataSourceOptions = null;
if (config.type === DatabaseType.mysql) {
driver = {
type: 'mysql',

View File

@ -4,7 +4,7 @@ import {SQLConnection} from './SQLConnection';
import {SharingEntity} from './enitites/SharingEntity';
import {Config} from '../../../../common/config/private/Config';
import {PasswordHelper} from '../../PasswordHelper';
import {DeleteResult} from 'typeorm';
import {DeleteResult, FindOptionsWhere} from 'typeorm';
export class SharingManager implements ISharingManager {
@ -20,7 +20,7 @@ export class SharingManager implements ISharingManager {
async deleteSharing(sharingKey: string): Promise<void> {
const connection = await SQLConnection.getConnection();
const sharing = await connection.getRepository(SharingEntity).findOne({sharingKey});
const sharing = await connection.getRepository(SharingEntity).findOneBy({sharingKey});
await connection.getRepository(SharingEntity).remove(sharing);
}
@ -32,10 +32,10 @@ export class SharingManager implements ISharingManager {
.leftJoinAndSelect('share.creator', 'creator').getMany();
}
async findOne(filter: any): Promise<SharingDTO> {
async findOne(filter: FindOptionsWhere<SharingDTO>): Promise<SharingDTO> {
await SharingManager.removeExpiredLink();
const connection = await SQLConnection.getConnection();
return await connection.getRepository(SharingEntity).findOne(filter);
return await connection.getRepository(SharingEntity).findOneBy(filter);
}
async createSharing(sharing: SharingDTO): Promise<SharingDTO> {
@ -50,7 +50,7 @@ export class SharingManager implements ISharingManager {
async updateSharing(inSharing: SharingDTO, forceUpdate: boolean): Promise<SharingDTO> {
const connection = await SQLConnection.getConnection();
const sharing = await connection.getRepository(SharingEntity).findOne({
const sharing = await connection.getRepository(SharingEntity).findOneBy({
id: inSharing.id,
creator: inSharing.creator.id as any,
path: inSharing.path

View File

@ -3,6 +3,7 @@ import {IUserManager} from '../interfaces/IUserManager';
import {UserEntity} from './enitites/UserEntity';
import {SQLConnection} from './SQLConnection';
import {PasswordHelper} from '../../PasswordHelper';
import {FindOptionsWhere} from 'typeorm';
export class UserManager implements IUserManager {
@ -11,11 +12,11 @@ export class UserManager implements IUserManager {
}
public async findOne(filter: any): Promise<any> {
public async findOne(filter: FindOptionsWhere<UserEntity>): Promise<any> {
const connection = await SQLConnection.getConnection();
const pass = filter.password;
const pass = filter.password as string;
delete filter.password;
const user = (await connection.getRepository(UserEntity).findOne(filter));
const user = (await connection.getRepository(UserEntity).findOneBy(filter));
if (pass && !PasswordHelper.comparePassword(pass, user.password)) {
throw new Error('No entry found');
@ -37,7 +38,7 @@ export class UserManager implements IUserManager {
public async deleteUser(id: number): Promise<any> {
const connection = await SQLConnection.getConnection();
const user = await connection.getRepository(UserEntity).findOne({id});
const user = await connection.getRepository(UserEntity).findOneBy({id});
return await connection.getRepository(UserEntity).remove(user);
}
@ -45,7 +46,7 @@ export class UserManager implements IUserManager {
const connection = await SQLConnection.getConnection();
const userRepository = connection.getRepository(UserEntity);
const user = await userRepository.findOne({id});
const user = await userRepository.findOneBy({id});
user.role = newRole;
return userRepository.save(user);

View File

@ -14,8 +14,6 @@ import {backendTexts} from '../../../../common/BackendTexts';
import {ProjectPath} from '../../../ProjectPath';
import {DatabaseType} from '../../../../common/config/private/PrivateConfig';
declare var global: NodeJS.Global;
const LOG_TAG = '[FileJob]';

View File

@ -1,4 +1,5 @@
import * as cluster from 'cluster';
import {Worker} from 'cluster';
import {Logger} from '../../Logger';
import {DiskManagerTask, ThumbnailTask, WorkerMessage, WorkerTask, WorkerTaskTypes} from './Worker';
import {ParentDirectoryDTO} from '../../../common/entities/DirectoryDTO';
@ -9,7 +10,7 @@ import {DirectoryScanSettings} from './DiskMangerWorker';
interface WorkerWrapper<O> {
worker: cluster.Worker;
worker: Worker;
poolTask: TaskQueEntry<WorkerTask, O>;
}
@ -58,7 +59,7 @@ export class ThreadPool<O> {
}
private startWorker(): void {
const worker = {poolTask: null, worker: cluster.fork()} as WorkerWrapper<O>;
const worker = {poolTask: null, worker: (cluster as any).fork()} as WorkerWrapper<O>;
this.workers.push(worker);
worker.worker.on('online', (): void => {
ThreadPool.WorkerCount++;

View File

@ -6,7 +6,6 @@ import {MediaDTO} from '../../../common/entities/MediaDTO';
import {ParentDirectoryDTO} from '../../../common/entities/DirectoryDTO';
declare var process: NodeJS.Process;
declare var global: NodeJS.Global;
const LOG_TAG = '[Worker]';
export class Worker {

View File

@ -20,10 +20,11 @@ export class LoggerRouter {
}
req.logged = true;
const end = res.end;
res.end = (a?: any, b?: any, c?: any): void => {
res.end = (a?: any, b?: any, c?: any) => {
res.end = end;
res.end(a, b, c);
loggerFn(req.method, req.url, res.statusCode, (Date.now() - req._startTime) + 'ms');
return res;
};
}

View File

@ -10,9 +10,9 @@
<meta name="theme-color" content="#000000" />
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="apple-touch-icon" href="assets/icon.png">
<link rel="manifest" crossorigin="use-credentials" href="manifest.json">
<link rel="stylesheet"
@ -23,7 +23,10 @@
var ServerInject = {user: <%- JSON.stringify(user); %>, ConfigInject: <%- JSON.stringify(Config); %>}
</script>
<%- customHTMLHead %>
<script>
<%- customHTMLHead %>
</script>
</head>
<body style="overflow-y: scroll; padding-right: 0 !important;">

View File

@ -4,7 +4,7 @@
"compilerOptions": {
"outDir": "../../out-tsc/app",
"types": [],
"target": "es2015",
"target": "es2017",
"module": "es2020",
"lib": [
"es2018",

View File

@ -104,14 +104,14 @@ describe('Typeorm integration', () => {
a.role = UserRoles.Admin;
await conn.getRepository(UserEntity).save(a);
const version = await conn.getRepository(VersionEntity).findOne();
const version = (await conn.getRepository(VersionEntity).find())[0];
version.version--;
await conn.getRepository(VersionEntity).save(version);
await SQLConnection.close();
const conn2 = await SQLConnection.getConnection();
const admins = await conn2.getRepository(UserEntity).find({name: 'migrated admin'});
const admins = await conn2.getRepository(UserEntity).findBy({name: 'migrated admin'});
expect(admins.length).to.be.equal(1);
});

View File

@ -247,7 +247,8 @@ describe('PreviewManager', (sqlHelper: DBTestHelper) => {
const conn = await SQLConnection.getConnection();
const selectDir = async () => {
return await conn.getRepository(DirectoryEntity).findOne({id: subDir.id}, {
return await conn.getRepository(DirectoryEntity).findOne({
where: {id: subDir.id},
join: {
alias: 'dir',
leftJoinAndSelect: {preview: 'dir.preview'}

View File

@ -1,7 +1,7 @@
import {ProjectPath} from '../../src/backend/ProjectPath';
import {promises as fsp} from 'fs';
const chai = require('chai');
import path = require('path');
import * as path from 'path';
const {expect} = chai;
// to help WebStorm to handle the test cases

View File

@ -8,9 +8,10 @@
"downlevelIteration": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es2020",
"module": "commonjs",
"target": "es2017",
"module": "CommonJS",
"lib": [
"es2018",
"dom"
]
},