From 5c6919bf279c7023f1b6b526cbfa0ff1fa6cb9a6 Mon Sep 17 00:00:00 2001 From: "Patrik J. Braun" Date: Sun, 22 Dec 2019 00:04:52 +0100 Subject: [PATCH] adding switch to force optDeps for docker --- .github/workflows/blank.yml | 2 +- gulpfile.ts | 16 ++++++++-- .../model/diagnostics/ConfigDiagnostics.ts | 31 ++++++++++++------- 3 files changed, 33 insertions(+), 16 deletions(-) diff --git a/.github/workflows/blank.yml b/.github/workflows/blank.yml index b9b6d688..99984538 100644 --- a/.github/workflows/blank.yml +++ b/.github/workflows/blank.yml @@ -22,7 +22,7 @@ jobs: run: npm install --unsafe-perm - name: Create Release - run: npm run create-release -- --skip-opt-packages=ffmpeg,ffprobe + run: npm run create-release -- --skip-opt-packages=ffmpeg,ffprobe --force-opt-packages - uses: actions/upload-artifact@v1 with: name: pigallery2-release diff --git a/gulpfile.ts b/gulpfile.ts index 8e1b94b2..7b612945 100644 --- a/gulpfile.ts +++ b/gulpfile.ts @@ -12,14 +12,17 @@ const translationFolder = 'translate'; const tsBackendProject = ts.createProject('tsconfig.json'); declare var process: NodeJS.Process; -const getSwitch = (name: string, def: string = null) => { +const getSwitch = (name: string, def: string = null): string => { name = '--' + name; for (let i = 0; i < process.argv.length; i++) { if (process.argv[i].startsWith(name + '=')) { return process.argv[i].replace(name + '=', '').trim(); } - if (process.argv[i].startsWith(name) && i + 1 < process.argv.length) { - return process.argv[i + 1].trim(); + if (process.argv[i].startsWith(name)) { + if (i + 1 < process.argv.length) { + return process.argv[i + 1].trim(); + } + return 'true'; } } return def; @@ -129,6 +132,13 @@ gulp.task('copy-package', function () { } } } + + if (!!getSwitch('force-opt-packages')) { + for (const key of Object.keys(json.optionalDependencies)) { + json.dependencies[key] = json.optionalDependencies[key]; + } + delete json.optionalDependencies; + } return json; })) .pipe(gulp.dest('./release')); diff --git a/src/backend/model/diagnostics/ConfigDiagnostics.ts b/src/backend/model/diagnostics/ConfigDiagnostics.ts index b91699a6..3f20bd17 100644 --- a/src/backend/model/diagnostics/ConfigDiagnostics.ts +++ b/src/backend/model/diagnostics/ConfigDiagnostics.ts @@ -81,22 +81,30 @@ export class ConfigDiagnostics { } } + static async testSharp() { + const sharp = require('sharp'); + sharp(); + } + + static async testGM() { + const gm = require('gm'); + await new Promise((resolve, reject) => { + gm(ProjectPath.FrontendFolder + '/assets/icon.png').size((err: Error) => { + if (err) { + return reject(err.toString()); + } + return resolve(); + }); + }); + } + static async testThumbnailLib(processingLibrary: ServerConfig.PhotoProcessingLib) { switch (processingLibrary) { case ServerConfig.PhotoProcessingLib.sharp: - const sharp = require('sharp'); - sharp(); + await this.testSharp(); break; case ServerConfig.PhotoProcessingLib.gm: - const gm = require('gm'); - await new Promise((resolve, reject) => { - gm(ProjectPath.FrontendFolder + '/assets/icon.png').size((err: Error) => { - if (err) { - return reject(err.toString()); - } - return resolve(); - }); - }); + await this.testGM(); break; } } @@ -120,7 +128,6 @@ export class ConfigDiagnostics { } - static async testServerPhotoConfig(server: ServerConfig.PhotoConfig) { }