intermediate-component-sa 1.0.4 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/README.md +1 -20
- package/build-dev.bat +2 -0
- package/build-prod-aot.bat +2 -0
- package/build-prod-rollup-aot.bat +2 -0
- package/build-prod.bat +2 -0
- package/config.ts +4 -0
- package/gulpfile.ts +172 -0
- package/index.js +10 -1
- package/karma.conf.js +124 -0
- package/package.json +340 -15
- package/postgrator-test.json +9 -0
- package/postgrator.json +9 -0
- package/src/app.server.ts +4 -0
- package/src/client/app/app.component.ts +37 -0
- package/src/client/app/app.html +6 -0
- package/src/client/app/app.module.ts +36 -0
- package/src/client/app/app.routing.ts +7 -0
- package/src/client/app/hot_loader_main.ts +14 -0
- package/src/client/app/main-aot.ts +8 -0
- package/src/client/app/main.ts +8 -0
- package/src/client/app/rxjs-operators.ts +15 -0
- package/src/client/index.html +90 -0
- package/src/client/tsconfig.json +44 -0
- package/src/server/config/app.config.ts +57 -0
- package/src/server/config/jwt.config.ts +4 -0
- package/src/server/config/logger.config.ts +161 -0
- package/src/server/config/mssql.config.ts +30 -0
- package/src/server/config/redis.config.ts +10 -0
- package/src/server/config/server.config.ts +20 -0
- package/src/server/config/templates.config.ts +41 -0
- package/src/server/crypt.ts +37 -0
- package/src/server/customRequest.ts +609 -0
- package/src/server/index.ts +231 -0
- package/src/server/interfaces/cleaner.interface.ts +3 -0
- package/src/server/interfaces/supervisor.interface.ts +3 -0
- package/src/server/routes-centralized.ts +36 -0
- package/src/server/routes.ts +6 -0
- package/src/server/services/index.ts +10 -0
- package/src/server/services/routes.service.ts +11 -0
- package/src/server/shared/file-manager.ts +1007 -0
- package/src/server/shared/http.shared.ts +49 -0
- package/src/server/shared/promises.shared.ts +13 -0
- package/src/server/shared/security.shared.ts +90 -0
- package/src/server/ssl/star_inconcertcc_com.key +28 -0
- package/src/server/ssl/star_inconcertcc_com.pem +62 -0
- package/src/server/tsconfig.json +38 -0
- package/tools/build.js.prod.ts +40 -0
- package/tools/config/project.config.ts +718 -0
- package/tools/config.ts +4 -0
- package/tools/database/SchemaZen.exe +0 -0
- package/tools/database/generate-all-data-scripts.bat +32 -0
- package/tools/database/generate-database-scripts.bat +36 -0
- package/tools/debug.ts +17 -0
- package/tools/env/base.ts +8 -0
- package/tools/env/dev.ts +9 -0
- package/tools/env/env-config.interface.ts +1 -0
- package/tools/env/prod.ts +10 -0
- package/tools/manual_typings/project/sample.package.d.ts +3 -0
- package/tools/manual_typings/seed/angular2-hot-loader.d.ts +9 -0
- package/tools/manual_typings/seed/autoprefixer.d.ts +13 -0
- package/tools/manual_typings/seed/colorguard.d.ts +15 -0
- package/tools/manual_typings/seed/connect-livereload.d.ts +5 -0
- package/tools/manual_typings/seed/cssnano.d.ts +18 -0
- package/tools/manual_typings/seed/doiuse.d.ts +16 -0
- package/tools/manual_typings/seed/express-history-api-fallback.d.ts +18 -0
- package/tools/manual_typings/seed/istream.d.ts +10 -0
- package/tools/manual_typings/seed/karma.d.ts +12 -0
- package/tools/manual_typings/seed/merge-stream.d.ts +8 -0
- package/tools/manual_typings/seed/open.d.ts +8 -0
- package/tools/manual_typings/seed/postcss-reporter.d.ts +20 -0
- package/tools/manual_typings/seed/slash.d.ts +5 -0
- package/tools/manual_typings/seed/stylelint.d.ts +16 -0
- package/tools/manual_typings/seed/systemjs-builder.d.ts +10 -0
- package/tools/manual_typings/seed/tildify.d.ts +5 -0
- package/tools/manual_typings/seed/tiny-lr.d.ts +10 -0
- package/tools/manual_typings/seed/walk.d.ts +10 -0
- package/tools/scripts/install.speech-analytic.sh +35 -0
- package/tools/tasks/build.app.server.ts +57 -0
- package/tools/tasks/build.assets.dev.ts +19 -0
- package/tools/tasks/build.assets.prod.ts +31 -0
- package/tools/tasks/build.bundles.app.aot.ts +31 -0
- package/tools/tasks/build.bundles.app.rollup.aot.ts +101 -0
- package/tools/tasks/build.bundles.app.ts +31 -0
- package/tools/tasks/build.bundles.ts +45 -0
- package/tools/tasks/build.database.scripts.runner.ts +137 -0
- package/tools/tasks/build.database.scripts.ts +27 -0
- package/tools/tasks/build.flags.ts +9 -0
- package/tools/tasks/build.fonts.ts +9 -0
- package/tools/tasks/build.html_css.ts +126 -0
- package/tools/tasks/build.index.dev.ts +68 -0
- package/tools/tasks/build.index.prod.ts +64 -0
- package/tools/tasks/build.js.dev.ts +66 -0
- package/tools/tasks/build.js.prod.aot.ts +44 -0
- package/tools/tasks/build.js.prod.rollup.aot.ts +50 -0
- package/tools/tasks/build.js.prod.ts +40 -0
- package/tools/tasks/build.packages.prod.ts +19 -0
- package/tools/tasks/build.server.dev.ts +59 -0
- package/tools/tasks/build.server.prod.ts +31 -0
- package/tools/tasks/build.server.statics.ts +24 -0
- package/tools/tasks/build.skins.ts +51 -0
- package/tools/tasks/build.sme.prod.aot.ts +6 -0
- package/tools/tasks/build.sme.prod.rollup.aot.ts +6 -0
- package/tools/tasks/build.sme.prod.ts +6 -0
- package/tools/tasks/build.tar.prod.ts +17 -0
- package/tools/tasks/build.test.database.scripts.ts +52 -0
- package/tools/tasks/clean.dev.ts +7 -0
- package/tools/tasks/clean.prod.ts +7 -0
- package/tools/tasks/compile.ahead.prod.ts +65 -0
- package/tools/tasks/copy.client.js.prod.rollup.aot.ts +33 -0
- package/tools/tasks/copy.client.js.prod.ts +18 -0
- package/tools/tasks/copy.server.assets.ts +38 -0
- package/tools/tasks/copy.server.js.prod.ts +16 -0
- package/tools/tasks/css-lint.ts +58 -0
- package/tools/tasks/e2e.ts +32 -0
- package/tools/tasks/karma.run.ts +18 -0
- package/tools/tasks/karma.watch.ts +9 -0
- package/tools/tasks/minify.server.statics.ts +52 -0
- package/tools/tasks/server.prod.ts +6 -0
- package/tools/tasks/server.start.ts +6 -0
- package/tools/tasks/test.database.ts +6 -0
- package/tools/tasks/transpile.bundles.rollup.aot.ts +43 -0
- package/tools/tasks/tslint.ts +64 -0
- package/tools/tasks/watch.file.changes.dev.ts +37 -0
- package/tools/tasks/watch.key.press.dev.ts +116 -0
- package/tools/tasks/webdriver.ts +6 -0
- package/tools/utils/project/sample_util.ts +18 -0
- package/tools/utils/project.utils.ts +4 -0
- package/tools/utils/seed/build_optimizer.ts +26 -0
- package/tools/utils/seed/clean.ts +35 -0
- package/tools/utils/seed/code_change_tools.ts +38 -0
- package/tools/utils/seed/karma.start.ts +10 -0
- package/tools/utils/seed/server.ts +43 -0
- package/tools/utils/seed/sme.ts +51 -0
- package/tools/utils/seed/tasks_tools.ts +70 -0
- package/tools/utils/seed/template_locals.ts +64 -0
- package/tools/utils/seed/tsproject.ts +25 -0
- package/tools/utils/seed.utils.ts +11 -0
- package/tools/utils.ts +5 -0
- package/tsconfig.json +33 -0
- package/tslint.json +120 -0
- package/utils.ts +5 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { join } from 'path';
|
|
2
|
+
import * as Builder from 'systemjs-builder';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
BOOTSTRAP_MODULE,
|
|
6
|
+
JS_PROD_APP_BUNDLE,
|
|
7
|
+
JS_DEST,
|
|
8
|
+
SYSTEM_JS_CONFIG_PROD,
|
|
9
|
+
TMP_CLIENT_DIR,
|
|
10
|
+
PRESERVE_SOURCE_MAPS,
|
|
11
|
+
} from '../config';
|
|
12
|
+
|
|
13
|
+
const BUNDLER_OPTIONS = {
|
|
14
|
+
format: 'cjs',
|
|
15
|
+
minify: true,
|
|
16
|
+
mangle: false,
|
|
17
|
+
sourceMaps: PRESERVE_SOURCE_MAPS,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Executes the build process, bundling the JavaScript files using the SystemJS builder.
|
|
22
|
+
*/
|
|
23
|
+
export = (done: any) => {
|
|
24
|
+
let builder = new Builder(SYSTEM_JS_CONFIG_PROD);
|
|
25
|
+
builder
|
|
26
|
+
.buildStatic(join(TMP_CLIENT_DIR, BOOTSTRAP_MODULE),
|
|
27
|
+
join(JS_DEST, JS_PROD_APP_BUNDLE),
|
|
28
|
+
BUNDLER_OPTIONS)
|
|
29
|
+
.then(() => done())
|
|
30
|
+
.catch((err: any) => done(err));
|
|
31
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import * as gulp from 'gulp';
|
|
2
|
+
import * as gulpLoadPlugins from 'gulp-load-plugins';
|
|
3
|
+
import * as merge from 'merge-stream';
|
|
4
|
+
|
|
5
|
+
import { DEPENDENCIES, JS_DEST, JS_PROD_SHIMS_BUNDLE } from '../config';
|
|
6
|
+
|
|
7
|
+
const plugins = <any>gulpLoadPlugins();
|
|
8
|
+
|
|
9
|
+
// Uso uglify-es para soportar ES6
|
|
10
|
+
var uglifyEs = require('uglify-es');
|
|
11
|
+
var composer = require('gulp-uglify/composer');
|
|
12
|
+
var minify = composer(uglifyEs, console);
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Executes the build process, bundling the shim files.
|
|
16
|
+
*/
|
|
17
|
+
export = () => merge(bundleShims());
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Returns the shim files to be injected.
|
|
21
|
+
*/
|
|
22
|
+
function getShims() {
|
|
23
|
+
let libs = DEPENDENCIES
|
|
24
|
+
.filter(d => /\.js$/.test(d.src));
|
|
25
|
+
|
|
26
|
+
return libs.filter(l => l.inject === 'shims')
|
|
27
|
+
.concat(libs.filter(l => l.inject === 'libs'))
|
|
28
|
+
.concat(libs.filter(l => l.inject === true))
|
|
29
|
+
.map(l => l.src);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Bundles the shim files.
|
|
34
|
+
*/
|
|
35
|
+
function bundleShims() {
|
|
36
|
+
return gulp.src(getShims())
|
|
37
|
+
// Strip comments and sourcemaps
|
|
38
|
+
.pipe(minify({
|
|
39
|
+
mangle: false
|
|
40
|
+
}))
|
|
41
|
+
.pipe(plugins.concat(JS_PROD_SHIMS_BUNDLE))
|
|
42
|
+
// Strip the first (global) 'use strict' added by reflect-metadata, but don't strip any others to avoid unintended scope leaks.
|
|
43
|
+
.pipe(plugins.replace(/('|")use strict\1;var Reflect;/, 'var Reflect;'))
|
|
44
|
+
.pipe(gulp.dest(JS_DEST));
|
|
45
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { APP_NAME, APP_VERSION, DIST_DIR, APP_DATABASE_SRC } from '../config';
|
|
2
|
+
//import { MSSQL_TESTING_CONFIG_CREATE, MSSQL_TESTING_CONFIG_USAGE } from '../../src/server/config/mssql.testing.config';
|
|
3
|
+
import { MSSQL_CONFIG } from '../../src/server/config/mssql.config';
|
|
4
|
+
import * as log4js from 'log4js';
|
|
5
|
+
|
|
6
|
+
// En el proyecto de speechanalytics no hay configuracion para testing
|
|
7
|
+
const MSSQL_TESTING_CONFIG_CREATE: any = MSSQL_CONFIG;
|
|
8
|
+
const MSSQL_TESTING_CONFIG_USAGE: any = MSSQL_CONFIG;
|
|
9
|
+
|
|
10
|
+
let sql = require('mssql');
|
|
11
|
+
let logger = log4js.getLogger('Sql');
|
|
12
|
+
|
|
13
|
+
export function createDataBase(): (done: () => void) => void {
|
|
14
|
+
return done => {
|
|
15
|
+
let promises: Promise<boolean>[] = [];
|
|
16
|
+
var queries = readProcessFile(APP_NAME + '_' + APP_VERSION + '_testing_database.sql');
|
|
17
|
+
queries.forEach(function(query:string){
|
|
18
|
+
if (query && query !== ' ') {
|
|
19
|
+
promises.push(makeBulk(query, true).then());
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
Promise.all(promises)
|
|
24
|
+
.then(() => {
|
|
25
|
+
logger.info('Data base creation finished with ' + promises.length + ' queries.');
|
|
26
|
+
createStructure(done);
|
|
27
|
+
}).catch(function(err) {
|
|
28
|
+
if (err.toString().includes('Database \'InconcertTesting\' already exists. Choose a different database name')) {
|
|
29
|
+
logger.info('Database already exist ...');
|
|
30
|
+
done();
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function createStructure(callback:any) {
|
|
37
|
+
let promises: Promise<boolean>[] = [];
|
|
38
|
+
logger.info('Creating Testing Tables');
|
|
39
|
+
var queries = readProcessFile(APP_NAME + '_' + APP_VERSION + '_testing_structure.sql');
|
|
40
|
+
queries.forEach(function(query:string){
|
|
41
|
+
if (query && query !== ' ') {
|
|
42
|
+
promises.push(makeBulk(query, false).then());
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
Promise.all(promises).then(() => {
|
|
47
|
+
logger.info('Data base structure finished with ' + promises.length + ' queries.');
|
|
48
|
+
createProcedures(callback);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function createProcedures(callback:any) {
|
|
53
|
+
let promises: Promise<boolean>[] = [];
|
|
54
|
+
logger.info('Creating Procedures');
|
|
55
|
+
var queries = readProcessFile(APP_NAME + '_' + APP_VERSION + '_testing_procedures.sql');
|
|
56
|
+
queries.forEach(function(query:string){
|
|
57
|
+
if (query && query !== ' ') {
|
|
58
|
+
promises.push(makeBulk(query, false).then());
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
Promise.all(promises).then(() => {
|
|
62
|
+
logger.info('Data base procedures finished with ' + promises.length + ' queries.');
|
|
63
|
+
insertData(callback);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function insertData(callback:any) {
|
|
68
|
+
let promises: Promise<boolean>[] = [];
|
|
69
|
+
logger.info('Insert Testing Data');
|
|
70
|
+
let queries: any = readProcessFile(APP_NAME + '_' + APP_VERSION + '_testing_data.sql');
|
|
71
|
+
queries.forEach(function(query:string){
|
|
72
|
+
if (query && query !== ' ') {
|
|
73
|
+
promises.push(makeBulk(query, false).then());
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
Promise.all(promises).then(() => {
|
|
77
|
+
logger.info('Data insert finished with ' + promises.length + ' queries.');
|
|
78
|
+
endDataBaseRestore(callback);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function endDataBaseRestore(callback:any) {
|
|
83
|
+
logger.info('Testing DataBase restore Finished');
|
|
84
|
+
callback();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function readProcessFile(fileName:string): any {
|
|
88
|
+
var fs = require('fs');
|
|
89
|
+
var path = require('path');
|
|
90
|
+
var filePath = path.join(DIST_DIR, fileName);
|
|
91
|
+
|
|
92
|
+
return fs.readFileSync(filePath, 'utf-8')
|
|
93
|
+
.replace(/InconcertOnline/g, MSSQL_TESTING_CONFIG_USAGE.database)
|
|
94
|
+
.replace(/USE(.*?)$\n/gm,'')
|
|
95
|
+
.replace(/SET(.*?)$\nGO/gm,'')
|
|
96
|
+
.replace(/END;/gm,'END')
|
|
97
|
+
.replace(/--(.*?)$/gm,'')
|
|
98
|
+
.replace(/(\r\n|\n|\r|\t)/gm,' ')
|
|
99
|
+
.replace(/ /gm,' ')
|
|
100
|
+
.replace(/ /gm,' ')
|
|
101
|
+
.split('GO');
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function makeBulk(query:string, create:boolean):Promise <boolean> {
|
|
105
|
+
let connection: any;
|
|
106
|
+
if (create) {
|
|
107
|
+
connection = MSSQL_TESTING_CONFIG_CREATE;
|
|
108
|
+
} else {
|
|
109
|
+
connection = MSSQL_TESTING_CONFIG_USAGE;
|
|
110
|
+
|
|
111
|
+
}
|
|
112
|
+
return new sql.connect(connection)
|
|
113
|
+
.then(
|
|
114
|
+
(result: any) => {
|
|
115
|
+
return new sql.Request(result)
|
|
116
|
+
.batch(query)
|
|
117
|
+
.then((dump: any) => {
|
|
118
|
+
result.close();
|
|
119
|
+
return Promise.resolve(true);
|
|
120
|
+
})
|
|
121
|
+
.catch((err: any) => {
|
|
122
|
+
if ( err.toString().indexOf('Choose a different database name') === 0 ) {
|
|
123
|
+
logger.error(' Execution Error: ' +err);
|
|
124
|
+
logger.error(query);
|
|
125
|
+
}
|
|
126
|
+
return Promise.reject(err);
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
).catch(
|
|
130
|
+
(err: any) => {
|
|
131
|
+
if ( err.toString().indexOf('Choose a different database name') === 0 ) {
|
|
132
|
+
logger.error('Connection Error: ' + err.message);
|
|
133
|
+
}
|
|
134
|
+
return Promise.reject(err);
|
|
135
|
+
}
|
|
136
|
+
);
|
|
137
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as gulp from 'gulp';
|
|
2
|
+
import * as gulpLoadPlugins from 'gulp-load-plugins';
|
|
3
|
+
import { resolve } from 'path';
|
|
4
|
+
|
|
5
|
+
import { APP_NAME, APP_VERSION, DIST_DIR, APP_DATABASE_SRC } from '../config';
|
|
6
|
+
|
|
7
|
+
const plugins = <any>gulpLoadPlugins();
|
|
8
|
+
|
|
9
|
+
const scripts = [
|
|
10
|
+
resolve(APP_DATABASE_SRC, 'mssql', 'database.sql'),
|
|
11
|
+
resolve(APP_DATABASE_SRC, 'mssql', 'props.sql'),
|
|
12
|
+
resolve(APP_DATABASE_SRC, 'mssql', 'schemas.sql'),
|
|
13
|
+
resolve(APP_DATABASE_SRC, 'mssql', 'users', '**'),
|
|
14
|
+
resolve(APP_DATABASE_SRC, 'mssql', 'tables', '**'),
|
|
15
|
+
resolve(APP_DATABASE_SRC, 'mssql', 'functions', '**'),
|
|
16
|
+
resolve(APP_DATABASE_SRC, 'mssql', 'procedures', '**'),
|
|
17
|
+
resolve(APP_DATABASE_SRC, 'mssql', 'data', '**'),
|
|
18
|
+
resolve(APP_DATABASE_SRC, 'mssql', 'initial', '**')
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
export = () => {
|
|
22
|
+
return gulp.src(scripts,{allowEmpty: true})
|
|
23
|
+
.pipe(plugins.count('## sql files selected for bundle'))
|
|
24
|
+
.pipe(plugins.concat(APP_NAME + '_' + APP_VERSION + '_database.sql'))
|
|
25
|
+
.pipe(plugins.replace(/CREATE OR ALTER/g, 'CREATE'))
|
|
26
|
+
.pipe(gulp.dest(resolve(DIST_DIR)));
|
|
27
|
+
};
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import * as autoprefixer from 'autoprefixer';
|
|
2
|
+
import * as cssnano from 'cssnano';
|
|
3
|
+
import * as gulp from 'gulp';
|
|
4
|
+
import * as gulpLoadPlugins from 'gulp-load-plugins';
|
|
5
|
+
import * as merge from 'merge-stream';
|
|
6
|
+
import * as log from 'fancy-log';
|
|
7
|
+
import { Chalk } from 'chalk';
|
|
8
|
+
import { join } from 'path';
|
|
9
|
+
import { noop, dummyStream } from '../utils';
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
APP_CLIENT_DEST,
|
|
13
|
+
APP_CLIENT_SRC,
|
|
14
|
+
BROWSER_LIST,
|
|
15
|
+
CSS_DEST,
|
|
16
|
+
CSS_SRC,
|
|
17
|
+
DEPENDENCIES,
|
|
18
|
+
ENV,
|
|
19
|
+
TMP_CLIENT_DIR,
|
|
20
|
+
getPluginConfig,
|
|
21
|
+
} from '../config';
|
|
22
|
+
|
|
23
|
+
// Obtengo plugins de gulp
|
|
24
|
+
const plugins = <any>gulpLoadPlugins();
|
|
25
|
+
const cleanCss = require('gulp-clean-css');
|
|
26
|
+
const gulpConcatCssConfig = getPluginConfig('gulp-concat-css');
|
|
27
|
+
const chalk: Chalk = require('chalk');
|
|
28
|
+
|
|
29
|
+
const processors = [
|
|
30
|
+
autoprefixer({
|
|
31
|
+
browsers: BROWSER_LIST
|
|
32
|
+
})
|
|
33
|
+
];
|
|
34
|
+
|
|
35
|
+
const reportPostCssError = (e: any) => log(chalk.red(e.message));
|
|
36
|
+
|
|
37
|
+
// Obtengo lag de modo producción
|
|
38
|
+
const isProd = ENV === 'prod';
|
|
39
|
+
|
|
40
|
+
if (isProd) {
|
|
41
|
+
processors.push(
|
|
42
|
+
cssnano({
|
|
43
|
+
discardComments: {removeAll: true},
|
|
44
|
+
discardUnused: false, // unsafe, see http://goo.gl/RtrzwF
|
|
45
|
+
zindex: false, // unsafe, see http://goo.gl/vZ4gbQ
|
|
46
|
+
reduceIdents: false // unsafe, see http://goo.gl/tNOPv0
|
|
47
|
+
})
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Copia todos los archivos HTML a la carpeta tmp_client
|
|
52
|
+
function CopyHtmlFilesToTmp() {
|
|
53
|
+
return gulp.src(join(APP_CLIENT_SRC, '**', '*.html'), { base: APP_CLIENT_SRC })
|
|
54
|
+
.pipe(gulp.dest(TMP_CLIENT_DIR));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Procesa y genera los archivos de estilos de componentes de la aplicación
|
|
58
|
+
function GenerateComponentsStylesheets() {
|
|
59
|
+
return gulp.src(join(APP_CLIENT_SRC, '**', '*.scss'), { base: APP_CLIENT_SRC })
|
|
60
|
+
.pipe(isProd ? plugins.cached('process-component-scss') : noop())
|
|
61
|
+
.pipe(isProd ? plugins.progeny() : noop())
|
|
62
|
+
.pipe(isProd ? noop() : plugins.sourcemaps.init())
|
|
63
|
+
.pipe(plugins.sass(getPluginConfig('gulp-sass')).on('error', plugins.sass.logError))
|
|
64
|
+
.pipe(plugins.postcss(processors))
|
|
65
|
+
.on('error', reportPostCssError)
|
|
66
|
+
.pipe(isProd ? noop() : plugins.sourcemaps.write('', {
|
|
67
|
+
sourceMappingURL: function(file) {
|
|
68
|
+
return '/dist/dev/client/' + file.relative.replace(/\\/g, '/') + '.map';
|
|
69
|
+
}
|
|
70
|
+
}))
|
|
71
|
+
.pipe(gulp.dest(isProd ? TMP_CLIENT_DIR : APP_CLIENT_DEST));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Procesa y genera los archivos de estilos main y de dependencias externas
|
|
75
|
+
function GenerateMainAndExternalStylesheets() {
|
|
76
|
+
// Obtengo la combinación de streams para CSS y SCSS y los proceso
|
|
77
|
+
return merge(GetMainScssStream(), GetExternalCssStream(), GetExternalScssStream())
|
|
78
|
+
.pipe(isProd ? plugins.concatCss(gulpConcatCssConfig.targetFile, gulpConcatCssConfig.options) : noop())
|
|
79
|
+
.pipe(plugins.postcss(processors))
|
|
80
|
+
.on('error', reportPostCssError)
|
|
81
|
+
.pipe(isProd ? cleanCss() : noop())
|
|
82
|
+
.pipe(gulp.dest(CSS_DEST));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Genera el stream de archivos SCSS para procesamiento de dependencias externas
|
|
86
|
+
function GetMainScssStream() {
|
|
87
|
+
// Devuelvo el array de los archivos, pasados por un cache
|
|
88
|
+
return gulp.src([
|
|
89
|
+
join(CSS_SRC, '**', '*.scss'),
|
|
90
|
+
'!' + join(CSS_SRC, '**', '_*.scss')
|
|
91
|
+
], { base: CSS_SRC })
|
|
92
|
+
.pipe(isProd ? plugins.cached('process-external-scss') : noop())
|
|
93
|
+
.pipe(isProd ? plugins.progeny() : noop())
|
|
94
|
+
.pipe(plugins.sass(getPluginConfig('gulp-sass')).on('error', plugins.sass.logError));
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Genera el stream de archivos CSS para procesamiento de dependencias externas
|
|
98
|
+
function GetExternalCssStream() {
|
|
99
|
+
// Armo el array de dependencias CSS a incluir
|
|
100
|
+
let globArray: string[] = DEPENDENCIES.filter(dep => /\.css$/.test(dep.src)).map(dep => dep.src);
|
|
101
|
+
// Si el array es vacío, no sigo (falla gulp)
|
|
102
|
+
if (!globArray || !globArray.length) return dummyStream();
|
|
103
|
+
// Devuelvo el array de los archivos, pasados por un cache
|
|
104
|
+
return gulp.src(globArray,{allowEmpty: true})
|
|
105
|
+
.pipe(isProd ? plugins.cached('process-external-css') : noop());
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Genera el stream de archivos SCSS para procesamiento de dependencias externas
|
|
109
|
+
function GetExternalScssStream() {
|
|
110
|
+
// Armo el array de dependencias SCSS a incluir
|
|
111
|
+
let globArray: string[] = DEPENDENCIES.filter(dep => /\.scss$/.test(dep.src)).map(dep => dep.src);
|
|
112
|
+
// Si el array es vacío, no sigo (falla gulp)
|
|
113
|
+
if (!globArray || !globArray.length) return dummyStream();
|
|
114
|
+
// Devuelvo el array de los archivos, pasados por un cache
|
|
115
|
+
return gulp.src(globArray,{allowEmpty: true})
|
|
116
|
+
.pipe(isProd ? plugins.cached('process-external-scss') : noop())
|
|
117
|
+
.pipe(isProd ? plugins.progeny() : noop())
|
|
118
|
+
.pipe(plugins.sass(getPluginConfig('gulp-sass')).on('error', plugins.sass.logError));
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Ejecuta y combina todas las tareas en un stream mergeado
|
|
122
|
+
export = () => merge(
|
|
123
|
+
CopyHtmlFilesToTmp(),
|
|
124
|
+
GenerateComponentsStylesheets(),
|
|
125
|
+
GenerateMainAndExternalStylesheets()
|
|
126
|
+
);
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import * as gulp from 'gulp';
|
|
2
|
+
import * as gulpLoadPlugins from 'gulp-load-plugins';
|
|
3
|
+
import * as merge from 'merge-stream';
|
|
4
|
+
import * as slash from 'slash';
|
|
5
|
+
import * as replace from 'gulp-replace';
|
|
6
|
+
import { join } from 'path';
|
|
7
|
+
|
|
8
|
+
import { APP_BASE, APP_CLIENT_DEST, APP_CLIENT_SRC, DEPENDENCIES, CSS_DEST, ASSETS_SRC, TEMPLATE_CONFIG } from '../config';
|
|
9
|
+
import { TemplateLocalsBuilder } from '../utils';
|
|
10
|
+
|
|
11
|
+
const plugins = <any>gulpLoadPlugins();
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
// Función para inyectar librerías y shims en index.html para caso ambiente de desarrollo
|
|
15
|
+
function buildIndex() {
|
|
16
|
+
return gulp.src(join(APP_CLIENT_SRC, 'index.html'), { base: APP_CLIENT_SRC })
|
|
17
|
+
.pipe(inject('shims'))
|
|
18
|
+
.pipe(inject('libs'))
|
|
19
|
+
.pipe(inject())
|
|
20
|
+
.pipe(plugins.template(new TemplateLocalsBuilder().withStringifiedSystemConfigDev().build(), TEMPLATE_CONFIG))
|
|
21
|
+
.pipe(gulp.dest(APP_CLIENT_DEST));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Injects the file with the given name.
|
|
26
|
+
* @param {string} name - The file to be injected.
|
|
27
|
+
*/
|
|
28
|
+
function inject(name?: string) {
|
|
29
|
+
return plugins.inject(gulp.src(getInjectablesDependenciesRef(name), { read: false }), {
|
|
30
|
+
name,
|
|
31
|
+
transform: transformPath()
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Returns the injectable dependency, mapping its filename to its path.
|
|
37
|
+
* @param {string} name - The dependency to be mapped.
|
|
38
|
+
*/
|
|
39
|
+
function getInjectablesDependenciesRef(name?: string) {
|
|
40
|
+
return DEPENDENCIES
|
|
41
|
+
.filter(dep => dep['inject'] && dep['inject'] === (name || true))
|
|
42
|
+
.map(mapPath);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Maps the path of the given dependency to its path according to the applications environment.
|
|
47
|
+
* @param {any} dep - The dependency to be mapped.
|
|
48
|
+
*/
|
|
49
|
+
function mapPath(dep: any) {
|
|
50
|
+
let envPath = dep.src;
|
|
51
|
+
if (envPath.startsWith(APP_CLIENT_SRC) && !envPath.endsWith('.scss')) {
|
|
52
|
+
envPath = join(APP_CLIENT_DEST, envPath.replace(APP_CLIENT_SRC, ''));
|
|
53
|
+
} else if (envPath.startsWith(APP_CLIENT_SRC) && envPath.endsWith('.scss')) {
|
|
54
|
+
envPath = envPath.replace(ASSETS_SRC, CSS_DEST).replace('.scss', '.css');
|
|
55
|
+
}
|
|
56
|
+
return envPath;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Transform the path of a dependency to its location within the `dist` directory according to the applications
|
|
61
|
+
* environment.
|
|
62
|
+
*/
|
|
63
|
+
function transformPath() {
|
|
64
|
+
return function (filepath: string) {
|
|
65
|
+
arguments[0] = join(APP_BASE, filepath) + `?${Date.now()}`;
|
|
66
|
+
return slash(plugins.inject.transform.apply(plugins.inject.transform, arguments));
|
|
67
|
+
};
|
|
68
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import * as gulp from 'gulp';
|
|
2
|
+
import * as gulpLoadPlugins from 'gulp-load-plugins';
|
|
3
|
+
import * as merge from 'merge-stream';
|
|
4
|
+
import * as slash from 'slash';
|
|
5
|
+
import * as replace from 'gulp-replace';
|
|
6
|
+
import { join, sep, normalize } from 'path';
|
|
7
|
+
|
|
8
|
+
import { APP_CLIENT_BASE, APP_CLIENT_DEST, APP_CLIENT_SRC, CSS_DEST, JS_DEST, JS_PROD_APP_BUNDLE, JS_PROD_SHIMS_BUNDLE, TEMPLATE_CONFIG } from '../config';
|
|
9
|
+
import { TemplateLocalsBuilder } from '../utils';
|
|
10
|
+
|
|
11
|
+
// Obtengo plugins de gulp
|
|
12
|
+
const plugins = <any>gulpLoadPlugins();
|
|
13
|
+
|
|
14
|
+
// Función para inyectar dependencias js y css en index.html para caso ambiente de prodcción
|
|
15
|
+
function buildIndex() {
|
|
16
|
+
return gulp.src(join(APP_CLIENT_SRC, 'index.html'), { base: APP_CLIENT_SRC })
|
|
17
|
+
.pipe(injectJs())
|
|
18
|
+
.pipe(injectCss())
|
|
19
|
+
.pipe(plugins.template(new TemplateLocalsBuilder().withStringifiedSystemConfigDev().build(), TEMPLATE_CONFIG))
|
|
20
|
+
.pipe(replace(/<!--.*-->/g, ''))
|
|
21
|
+
.pipe(replace(/\s+(\r\n|\r|\n)/g, '\r\n'))
|
|
22
|
+
.pipe(replace(/(\r\n|\r|\n){2,}/gm, '\r\n'))
|
|
23
|
+
.pipe(gulp.dest(APP_CLIENT_DEST));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Función para hacer inyección de un array de archivos
|
|
27
|
+
function inject(...files: Array<string>) {
|
|
28
|
+
return plugins.inject(gulp.src(files, { read: false }), {
|
|
29
|
+
files,
|
|
30
|
+
transform: transformPath()
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Inyecta los archivos JS de shims y app
|
|
35
|
+
function injectJs() {
|
|
36
|
+
return inject(join(JS_DEST, JS_PROD_SHIMS_BUNDLE), join(JS_DEST, JS_PROD_APP_BUNDLE));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Inyecta los archivos CSS existentes
|
|
40
|
+
function injectCss() {
|
|
41
|
+
return inject(
|
|
42
|
+
join(CSS_DEST, '**', '*.css'),
|
|
43
|
+
'!' + join(CSS_DEST, 'main.css'),
|
|
44
|
+
'!' + join(CSS_DEST, '**', 'skin-*.css')
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Hace la transformación del path del archivo para inyectar
|
|
49
|
+
function transformPath() {
|
|
50
|
+
return function(filepath: string) {
|
|
51
|
+
let path: Array<string> = normalize(filepath).split(sep);
|
|
52
|
+
let slice_after = path.indexOf(APP_CLIENT_DEST);
|
|
53
|
+
if (slice_after>-1) {
|
|
54
|
+
slice_after++;
|
|
55
|
+
} else {
|
|
56
|
+
slice_after = 4;
|
|
57
|
+
}
|
|
58
|
+
arguments[0] = APP_CLIENT_BASE + path.slice(slice_after, path.length).join(sep) + `?${Date.now()}`;
|
|
59
|
+
return slash(plugins.inject.transform.apply(plugins.inject.transform, arguments));
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Ejecuto todos los builds juntos
|
|
64
|
+
export = () => merge(buildIndex());
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import * as gulp from 'gulp';
|
|
2
|
+
import * as gulpLoadPlugins from 'gulp-load-plugins';
|
|
3
|
+
import * as merge from 'merge-stream';
|
|
4
|
+
import * as log from 'fancy-log';
|
|
5
|
+
import { Chalk } from 'chalk';
|
|
6
|
+
import { join } from 'path';
|
|
7
|
+
|
|
8
|
+
import { APP_CLIENT_DEST, APP_CLIENT_SRC, BOOTSTRAP_MODULE_AOT, TOOLS_DIR, TYPED_COMPILE_INTERVAL, TEMPLATE_CONFIG } from '../config';
|
|
9
|
+
import { makeTsProject, TemplateLocalsBuilder } from '../utils';
|
|
10
|
+
|
|
11
|
+
// Obtengo plugins de gulp
|
|
12
|
+
const chalk: Chalk = require('chalk');
|
|
13
|
+
const plugins = <any>gulpLoadPlugins();
|
|
14
|
+
|
|
15
|
+
// Flag de primera ejecución
|
|
16
|
+
let firstTime: boolean = true;
|
|
17
|
+
|
|
18
|
+
// Ejecuta transpile de los archivos typescript del cliente
|
|
19
|
+
export = () => {
|
|
20
|
+
// Proyecto de compilación TS
|
|
21
|
+
let tsProject: any;
|
|
22
|
+
// Archivos de typings locales
|
|
23
|
+
let typings = gulp.src([
|
|
24
|
+
TOOLS_DIR + '/manual_typings/**/*.d.ts'
|
|
25
|
+
]);
|
|
26
|
+
// Archivos a compilar
|
|
27
|
+
let projectFiles = gulp.src([
|
|
28
|
+
join(APP_CLIENT_SRC, '**/*.ts'),
|
|
29
|
+
'!' + join(APP_CLIENT_SRC, '/' + BOOTSTRAP_MODULE_AOT + '.ts'),
|
|
30
|
+
'!' + join(APP_CLIENT_SRC, '**/*.spec.ts'),
|
|
31
|
+
'!' + join(APP_CLIENT_SRC, '**/*.e2e-spec.ts'),
|
|
32
|
+
]);
|
|
33
|
+
|
|
34
|
+
// Solo uso los typings en la primer compilación
|
|
35
|
+
if (firstTime) {
|
|
36
|
+
// La primera vez ejecuto build usando los typings manuales
|
|
37
|
+
tsProject = makeTsProject({}, APP_CLIENT_SRC);
|
|
38
|
+
projectFiles = merge(typings, projectFiles);
|
|
39
|
+
} else {
|
|
40
|
+
// Las siguientes los hago typeless para acelerar
|
|
41
|
+
tsProject = makeTsProject({ /* isolatedModules: true */ }, APP_CLIENT_SRC);
|
|
42
|
+
projectFiles = projectFiles.pipe(plugins.cached());
|
|
43
|
+
log('Fastbuild ' + chalk.cyan('Ejecutando compilación typeless.'));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Actualizo flag
|
|
47
|
+
firstTime = false;
|
|
48
|
+
|
|
49
|
+
// Inicializo proyecto
|
|
50
|
+
let result: any = projectFiles
|
|
51
|
+
.pipe(plugins.plumber())
|
|
52
|
+
.pipe(plugins.sourcemaps.init())
|
|
53
|
+
.pipe(tsProject());
|
|
54
|
+
|
|
55
|
+
return result.js
|
|
56
|
+
.pipe(plugins.sourcemaps.write())
|
|
57
|
+
// Use for debugging with Webstorm/IntelliJ
|
|
58
|
+
// https://github.com/mgechev/angular-seed/issues/1220
|
|
59
|
+
// .pipe(plugins.sourcemaps.write('.', {
|
|
60
|
+
// includeContent: false,
|
|
61
|
+
// sourceRoot: (file: any) =>
|
|
62
|
+
// relative(file.path, Config.PROJECT_ROOT + '/' + Config.APP_SRC).replace(sep, '/') + '/' + Config.APP_SRC
|
|
63
|
+
// }))
|
|
64
|
+
.pipe(plugins.template(new TemplateLocalsBuilder().withStringifiedSystemConfigDev().build(), TEMPLATE_CONFIG))
|
|
65
|
+
.pipe(gulp.dest(APP_CLIENT_DEST));
|
|
66
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { readdirSync, lstatSync } from 'fs';
|
|
2
|
+
import * as gulp from 'gulp';
|
|
3
|
+
import * as gulpLoadPlugins from 'gulp-load-plugins';
|
|
4
|
+
import { join } from 'path';
|
|
5
|
+
|
|
6
|
+
import { TMP_CLIENT_DIR, TOOLS_DIR, BOOTSTRAP_DIR, BOOTSTRAP_MAIN_AOT, BOOTSTRAP_MODULE_AOT, TEMPLATE_CONFIG } from '../config';
|
|
7
|
+
import { makeTsProject, ngBuildOptimizer, TemplateLocalsBuilder } from '../utils';
|
|
8
|
+
|
|
9
|
+
const plugins = <any>gulpLoadPlugins();
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Executes the build process, transpiling the TypeScript files for the production environment.
|
|
13
|
+
*/
|
|
14
|
+
export = () => {
|
|
15
|
+
|
|
16
|
+
const tsProject = makeTsProject({}, TMP_CLIENT_DIR);
|
|
17
|
+
|
|
18
|
+
const toIgnore = readdirSync(TMP_CLIENT_DIR)
|
|
19
|
+
.filter((f: string) => lstatSync(join(TMP_CLIENT_DIR, f)).isDirectory() && f !== BOOTSTRAP_DIR)
|
|
20
|
+
.map((f: string) => '!' + join(TMP_CLIENT_DIR, f, BOOTSTRAP_MAIN_AOT + '.ts'));
|
|
21
|
+
|
|
22
|
+
const src = [
|
|
23
|
+
TOOLS_DIR + '/manual_typings/**/*.d.ts',
|
|
24
|
+
join(TMP_CLIENT_DIR, '**/*.ts'),
|
|
25
|
+
join(TMP_CLIENT_DIR, `${BOOTSTRAP_MODULE_AOT}.ts`),
|
|
26
|
+
...toIgnore
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
const result = gulp
|
|
30
|
+
.src(src)
|
|
31
|
+
.pipe(plugins.plumber())
|
|
32
|
+
.pipe(tsProject())
|
|
33
|
+
.once('error', function(e: any) {
|
|
34
|
+
this.once('finish', () => process.exit(1));
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
return result.js
|
|
38
|
+
.pipe(plugins.template(new TemplateLocalsBuilder().withStringifiedSystemConfigDev().build(), TEMPLATE_CONFIG))
|
|
39
|
+
.pipe(ngBuildOptimizer())
|
|
40
|
+
.pipe(gulp.dest(TMP_CLIENT_DIR))
|
|
41
|
+
.on('error', (e: any) => {
|
|
42
|
+
console.log(e);
|
|
43
|
+
});
|
|
44
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { readdirSync, lstatSync } from 'fs';
|
|
2
|
+
import * as gulp from 'gulp';
|
|
3
|
+
import * as gulpLoadPlugins from 'gulp-load-plugins';
|
|
4
|
+
import { join } from 'path';
|
|
5
|
+
|
|
6
|
+
import { TMP_CLIENT_DIR, TOOLS_DIR, BOOTSTRAP_DIR, BOOTSTRAP_MAIN_AOT, TEMPLATE_CONFIG } from '../config';
|
|
7
|
+
import { makeTsProject, ngBuildOptimizer, TemplateLocalsBuilder } from '../utils';
|
|
8
|
+
|
|
9
|
+
const plugins = <any>gulpLoadPlugins();
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Executes the build process, transpiling the TypeScript files for the production environment.
|
|
13
|
+
*/
|
|
14
|
+
export = () => {
|
|
15
|
+
|
|
16
|
+
const tsProject = makeTsProject(
|
|
17
|
+
{
|
|
18
|
+
target: 'es2015',
|
|
19
|
+
module: 'es2015',
|
|
20
|
+
moduleResolution: 'node'
|
|
21
|
+
},
|
|
22
|
+
TMP_CLIENT_DIR
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
const toIgnore = readdirSync(TMP_CLIENT_DIR)
|
|
26
|
+
.filter((f: string) => lstatSync(join(TMP_CLIENT_DIR, f)).isDirectory() && f !== BOOTSTRAP_DIR)
|
|
27
|
+
.map((f: string) => '!' + join(TMP_CLIENT_DIR, f, BOOTSTRAP_MAIN_AOT + '.ts'));
|
|
28
|
+
|
|
29
|
+
const src = [
|
|
30
|
+
join(TOOLS_DIR, '/manual_typings/**/*.d.ts'),
|
|
31
|
+
join(TMP_CLIENT_DIR, '**/*.ts'),
|
|
32
|
+
...toIgnore
|
|
33
|
+
];
|
|
34
|
+
|
|
35
|
+
const result = gulp
|
|
36
|
+
.src(src)
|
|
37
|
+
.pipe(plugins.plumber())
|
|
38
|
+
.pipe(tsProject())
|
|
39
|
+
.once('error', function(e: any) {
|
|
40
|
+
this.once('finish', () => process.exit(1));
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
return result.js
|
|
44
|
+
.pipe(plugins.template(new TemplateLocalsBuilder().withStringifiedSystemConfigDev().build(), TEMPLATE_CONFIG))
|
|
45
|
+
.pipe(ngBuildOptimizer())
|
|
46
|
+
.pipe(gulp.dest(TMP_CLIENT_DIR))
|
|
47
|
+
.on('error', (e: any) => {
|
|
48
|
+
console.log(e);
|
|
49
|
+
});
|
|
50
|
+
};
|