1
0
mirror of https://github.com/bpatrik/pigallery2.git synced 2025-04-17 12:06:38 +02:00

Fixing missing frontend release build and cleaning up package.json

This commit is contained in:
Patrik J. Braun 2021-04-18 16:54:34 +02:00
parent 5ad9a65a01
commit ab19dc577f
2 changed files with 53 additions and 61 deletions

View File

@ -35,16 +35,14 @@ const getSwitch = (name: string, def: string = null): string => {
return def; return def;
}; };
gulp.task('build-backend', function(): any { gulp.task('build-backend', (): any =>
return gulp.src([ gulp.src([
'src/common/**/*.ts', 'src/common/**/*.ts',
'src/backend/**/*.ts', 'src/backend/**/*.ts',
'benchmark/**/*.ts'], {base: '.'}) 'benchmark/**/*.ts'], {base: '.'})
.pipe(tsBackendProject()) .pipe(tsBackendProject())
.js .js
.pipe(gulp.dest('./release')); .pipe(gulp.dest('./release')));
});
const createDynamicTranslationFile = async (language: string): Promise<void> => { const createDynamicTranslationFile = async (language: string): Promise<void> => {
@ -137,69 +135,70 @@ const getLanguages = (): any[] | string[] => {
gulp.task('build-frontend', ((): any => { gulp.task('build-frontend', ((): any => {
const tasks = []; const tasks = [];
createFrontendTask('build-frontend-release default', 'all', createFrontendTask('build-frontend-release default', 'all',
'ng build --prod --no-progress'); 'ng build --prod --no-progress --output-path=./release/dist');
tasks.push('build-frontend-release default'); tasks.push('build-frontend-release default');
return gulp.series(...tasks); return gulp.series(...tasks);
})()); })());
gulp.task('copy-static', function(): any { gulp.task('copy-static', (): any => gulp.src([
return gulp.src([ 'src/backend/model/diagnostics/blank.jpg',
'src/backend/model/diagnostics/blank.jpg', 'README.md',
'README.md', // 'package-lock.json', should not add, it keeps optional packages optional even with --force-opt-packages.
// 'package-lock.json', should not add, it keeps optional packages optional even with --force-opt-packages. 'LICENSE'], {base: '.'})
'LICENSE'], {base: '.'}) .pipe(gulp.dest('./release')));
.pipe(gulp.dest('./release'));
});
gulp.task('copy-package', function(): any { gulp.task('copy-package', (): any => gulp.src([
return gulp.src([ 'package.json'], {base: '.'})
'package.json'], {base: '.'}) .pipe(jeditor((json: {
.pipe(jeditor((json: { devDependencies: { [key: string]: string },
devDependencies: { [key: string]: string }, scripts: { [key: string]: string },
scripts: { [key: string]: string }, dependencies: { [key: string]: string },
dependencies: { [key: string]: string }, optionalDependencies: { [key: string]: string },
optionalDependencies: { [key: string]: string }, buildTime: string,
buildTime: string, buildCommitHash: string
buildCommitHash: string }): {
}): { devDependencies: { [p: string]: string }; scripts: { [p: string]: string }; dependencies: { [p: string]: string }; optionalDependencies: { [p: string]: string }; buildTime: string; buildCommitHash: string } => { devDependencies: { [p: string]: string };
delete json.devDependencies; scripts: { [p: string]: string };
json.scripts = {start: 'node ./src/backend/index.js'}; dependencies: { [p: string]: string };
optionalDependencies: { [p: string]: string };
buildTime: string; buildCommitHash: string
} => {
delete json.devDependencies;
json.scripts = {start: 'node ./src/backend/index.js'};
if (getSwitch('skip-opt-packages')) { if (getSwitch('skip-opt-packages')) {
const skipPackages = getSwitch('skip-opt-packages').split(','); const skipPackages = getSwitch('skip-opt-packages').split(',');
for (const pkg of skipPackages) { for (const pkg of skipPackages) {
for (const key of Object.keys(json.optionalDependencies)) { for (const key of Object.keys(json.optionalDependencies)) {
if (key.indexOf(pkg) !== -1) { if (key.indexOf(pkg) !== -1) {
delete json.optionalDependencies[key]; delete json.optionalDependencies[key];
}
} }
} }
} }
}
if (!!getSwitch('force-opt-packages')) { if (!!getSwitch('force-opt-packages')) {
for (const key of Object.keys(json.optionalDependencies)) { for (const key of Object.keys(json.optionalDependencies)) {
json.dependencies[key] = json.optionalDependencies[key]; json.dependencies[key] = json.optionalDependencies[key];
}
delete json.optionalDependencies;
} }
json.buildTime = (new Date()).toISOString(); delete json.optionalDependencies;
}
json.buildTime = (new Date()).toISOString();
try { try {
json.buildCommitHash = require('child_process').execSync('git rev-parse HEAD').toString().trim(); json.buildCommitHash = require('child_process').execSync('git rev-parse HEAD').toString().trim();
} catch (e) { } catch (e) {
} }
return json; return json;
})) }))
.pipe(gulp.dest('./release')); .pipe(gulp.dest('./release')));
});
gulp.task('zip-release', function(): any { gulp.task('zip-release', (): any =>
return gulp.src(['release/**/*'], {base: './release'}) gulp.src(['release/**/*'], {base: './release'})
.pipe(zip('pigallery2.zip')) .pipe(zip('pigallery2.zip'))
.pipe(gulp.dest('.')); .pipe(gulp.dest('.')));
});
gulp.task('create-release', gulp.series('build-frontend', 'build-backend', 'copy-static', 'copy-package', 'zip-release')); gulp.task('create-release', gulp.series('build-frontend', 'build-backend', 'copy-static', 'copy-package', 'zip-release'));
@ -277,10 +276,10 @@ const merge = async (list: any[], cb: (err?: any) => void): Promise<void> => {
} }
}; };
gulp.task('update-translation-only', function(cb): void { gulp.task('update-translation-only', (cb): void => {
translate(getLanguages(), cb).catch(console.error); translate(getLanguages(), cb).catch(console.error);
}); });
gulp.task('merge-translation-only', function(cb): void { gulp.task('merge-translation-only', (cb): void => {
merge(getLanguages(), cb).catch(console.error); merge(getLanguages(), cb).catch(console.error);
}); });

View File

@ -133,7 +133,6 @@
"remap-istanbul": "0.13.0", "remap-istanbul": "0.13.0",
"rxjs": "6.6.7", "rxjs": "6.6.7",
"rxjs-compat": "6.6.7", "rxjs-compat": "6.6.7",
"terser": "5.6.1",
"ts-helpers": "1.1.2", "ts-helpers": "1.1.2",
"ts-node": "9.1.1", "ts-node": "9.1.1",
"tslint": "6.1.3", "tslint": "6.1.3",
@ -142,12 +141,6 @@
"xml2js": "0.4.23", "xml2js": "0.4.23",
"zone.js": "0.11.4" "zone.js": "0.11.4"
}, },
"//": [
"TODO: remove terser version lock once webpack is fixed"
],
"resolutions": {
"natives": "1.1.3"
},
"optionalDependencies": { "optionalDependencies": {
"@ffmpeg-installer/ffmpeg": "1.0.20", "@ffmpeg-installer/ffmpeg": "1.0.20",
"@ffprobe-installer/ffprobe": "1.1.0", "@ffprobe-installer/ffprobe": "1.1.0",