mirror of
https://github.com/bpatrik/pigallery2.git
synced 2024-12-23 01:27:14 +02:00
making full build during test. fixes broken tests. #591
This commit is contained in:
parent
66d663b8bc
commit
87d6346c7a
45
gulpfile.ts
45
gulpfile.ts
@ -1,6 +1,6 @@
|
|||||||
import * as gulp from 'gulp';
|
import * as gulp from 'gulp';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import { promises as fsp } from 'fs';
|
import {promises as fsp} from 'fs';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as util from 'util';
|
import * as util from 'util';
|
||||||
import * as zip from 'gulp-zip';
|
import * as zip from 'gulp-zip';
|
||||||
@ -10,9 +10,9 @@ import * as child_process from 'child_process';
|
|||||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import * as jeditor from 'gulp-json-editor';
|
import * as jeditor from 'gulp-json-editor';
|
||||||
import { XLIFF } from 'xlf-google-translate';
|
import {XLIFF} from 'xlf-google-translate';
|
||||||
import { PrivateConfigClass } from './src/common/config/private/Config';
|
import {PrivateConfigClass} from './src/common/config/private/Config';
|
||||||
import { ConfigClassBuilder } from 'typeconfig/src/decorators/builders/ConfigClassBuilder';
|
import {ConfigClassBuilder} from 'typeconfig/src/decorators/builders/ConfigClassBuilder';
|
||||||
|
|
||||||
const execPr = util.promisify(child_process.exec);
|
const execPr = util.promisify(child_process.exec);
|
||||||
|
|
||||||
@ -106,12 +106,11 @@ const resetAppModule = async (language: string): Promise<void> => {
|
|||||||
|
|
||||||
const createFrontendTask = (
|
const createFrontendTask = (
|
||||||
type: string,
|
type: string,
|
||||||
language: string,
|
|
||||||
script: string
|
script: string
|
||||||
): void => {
|
): void => {
|
||||||
gulp.task(type, async (cb): Promise<void> => {
|
gulp.task(type, async (cb): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
const { stdout, stderr } = await execPr(script);
|
const {stdout, stderr} = await execPr(script);
|
||||||
console.log(stdout);
|
console.log(stdout);
|
||||||
console.error(stderr);
|
console.error(stderr);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -154,7 +153,6 @@ gulp.task(
|
|||||||
const tasks = [];
|
const tasks = [];
|
||||||
createFrontendTask(
|
createFrontendTask(
|
||||||
'build-frontend-release default',
|
'build-frontend-release default',
|
||||||
'all',
|
|
||||||
'ng build --prod --no-progress --output-path=./release/dist'
|
'ng build --prod --no-progress --output-path=./release/dist'
|
||||||
);
|
);
|
||||||
tasks.push('build-frontend-release default');
|
tasks.push('build-frontend-release default');
|
||||||
@ -171,14 +169,14 @@ gulp.task('copy-static', (): any =>
|
|||||||
// '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',
|
'LICENSE',
|
||||||
],
|
],
|
||||||
{ base: '.' }
|
{base: '.'}
|
||||||
)
|
)
|
||||||
.pipe(gulp.dest('./release'))
|
.pipe(gulp.dest('./release'))
|
||||||
);
|
);
|
||||||
|
|
||||||
gulp.task('copy-package', (): any =>
|
gulp.task('copy-package', (): any =>
|
||||||
gulp
|
gulp
|
||||||
.src(['package.json'], { base: '.' })
|
.src(['package.json'], {base: '.'})
|
||||||
.pipe(
|
.pipe(
|
||||||
jeditor(
|
jeditor(
|
||||||
(json: {
|
(json: {
|
||||||
@ -197,7 +195,7 @@ gulp.task('copy-package', (): any =>
|
|||||||
buildCommitHash: string;
|
buildCommitHash: string;
|
||||||
} => {
|
} => {
|
||||||
delete json.devDependencies;
|
delete json.devDependencies;
|
||||||
json.scripts = { start: 'node ./src/backend/index.js' };
|
json.scripts = {start: 'node ./src/backend/index.js'};
|
||||||
|
|
||||||
if (getSwitch('skip-opt-packages')) {
|
if (getSwitch('skip-opt-packages')) {
|
||||||
const skipPackages = getSwitch('skip-opt-packages')
|
const skipPackages = getSwitch('skip-opt-packages')
|
||||||
@ -227,7 +225,8 @@ gulp.task('copy-package', (): any =>
|
|||||||
.toString()
|
.toString()
|
||||||
.trim();
|
.trim();
|
||||||
// eslint-disable-next-line no-empty
|
// eslint-disable-next-line no-empty
|
||||||
} catch (e) {}
|
} catch (e) {
|
||||||
|
}
|
||||||
|
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
@ -238,7 +237,7 @@ gulp.task('copy-package', (): any =>
|
|||||||
|
|
||||||
gulp.task('zip-release', (): any =>
|
gulp.task('zip-release', (): any =>
|
||||||
gulp
|
gulp
|
||||||
.src(['release/**/*'], { base: './release' })
|
.src(['release/**/*'], {base: './release'})
|
||||||
.pipe(zip('pigallery2.zip'))
|
.pipe(zip('pigallery2.zip'))
|
||||||
.pipe(gulp.dest('.'))
|
.pipe(gulp.dest('.'))
|
||||||
);
|
);
|
||||||
@ -260,15 +259,7 @@ const simpleBuild = (isProd: boolean): any => {
|
|||||||
if (isProd) {
|
if (isProd) {
|
||||||
cmd += ' --prod --no-extract-licenses ';
|
cmd += ' --prod --no-extract-licenses ';
|
||||||
}
|
}
|
||||||
if (!process.env['CI']) {
|
createFrontendTask('build-frontend default', cmd);
|
||||||
createFrontendTask('build-frontend default', 'all', cmd);
|
|
||||||
} else {
|
|
||||||
createFrontendTask(
|
|
||||||
'build-frontend default',
|
|
||||||
'all',
|
|
||||||
cmd + '--localize=false'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
tasks.push('build-frontend default');
|
tasks.push('build-frontend default');
|
||||||
return gulp.series(...tasks);
|
return gulp.series(...tasks);
|
||||||
};
|
};
|
||||||
@ -277,9 +268,9 @@ gulp.task('extract-locale', async (cb): Promise<any> => {
|
|||||||
console.log('creating source translation file: locale.source.xlf');
|
console.log('creating source translation file: locale.source.xlf');
|
||||||
try {
|
try {
|
||||||
{
|
{
|
||||||
const { stdout, stderr } = await execPr(
|
const {stdout, stderr} = await execPr(
|
||||||
'ng extract-i18n --out-file=locale.source.xlf --format=xlf',
|
'ng extract-i18n --out-file=locale.source.xlf --format=xlf',
|
||||||
{ maxBuffer: 1024 * 1024 }
|
{maxBuffer: 1024 * 1024}
|
||||||
);
|
);
|
||||||
console.log(stdout);
|
console.log(stdout);
|
||||||
console.error(stderr);
|
console.error(stderr);
|
||||||
@ -297,7 +288,7 @@ const translate = async (
|
|||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
const localsStr = '"[\\"' + list.join('\\",\\"') + '\\"]"';
|
const localsStr = '"[\\"' + list.join('\\",\\"') + '\\"]"';
|
||||||
const { stdout, stderr } = await execPr(
|
const {stdout, stderr} = await execPr(
|
||||||
'xlf-google-translate ' +
|
'xlf-google-translate ' +
|
||||||
'--source-lang="en" ' +
|
'--source-lang="en" ' +
|
||||||
'--source-file="./locale.source.xlf" ' +
|
'--source-file="./locale.source.xlf" ' +
|
||||||
@ -330,7 +321,7 @@ const merge = async (list: any[], cb: (err?: any) => void): Promise<void> => {
|
|||||||
'--destination-languages=' +
|
'--destination-languages=' +
|
||||||
localsStr;
|
localsStr;
|
||||||
console.log(command);
|
console.log(command);
|
||||||
const { stdout, stderr } = await execPr(command);
|
const {stdout, stderr} = await execPr(command);
|
||||||
console.log(stdout);
|
console.log(stdout);
|
||||||
console.error(stderr);
|
console.error(stderr);
|
||||||
cb();
|
cb();
|
||||||
@ -367,13 +358,13 @@ gulp.task('add-translation-only', (cb): any => {
|
|||||||
}
|
}
|
||||||
if (lng == null) {
|
if (lng == null) {
|
||||||
console.error(
|
console.error(
|
||||||
"Error: set language with '--' e.g: npm run add-translation -- --en"
|
'Error: set language with \'--\' e.g: npm run add-translation -- --en'
|
||||||
);
|
);
|
||||||
return cb();
|
return cb();
|
||||||
}
|
}
|
||||||
if (languages.indexOf(lng) !== -1) {
|
if (languages.indexOf(lng) !== -1) {
|
||||||
console.error(
|
console.error(
|
||||||
"Error: language already exists, can't add. These language(s) already exist(s): " +
|
'Error: language already exists, can\'t add. These language(s) already exist(s): ' +
|
||||||
languages
|
languages
|
||||||
);
|
);
|
||||||
return cb();
|
return cb();
|
||||||
|
Loading…
Reference in New Issue
Block a user