Add config files in any components folder (#1878)

* add config files in any components folder
* all test run option ft and option to skip build and run only test
This commit is contained in:
Eugenio Romano
2017-05-14 10:04:44 +01:00
committed by Eugenio Romano
parent 130c2e4428
commit af82f83669
199 changed files with 8193 additions and 298 deletions

View File

@@ -0,0 +1,16 @@
/*!
* @license
* Copyright 2016 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

View File

@@ -0,0 +1,14 @@
@license
Copyright 2016 Alfresco Software, Ltd.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@@ -0,0 +1,118 @@
{
"rules": {
"align": [
true,
"parameters",
"statements"
],
"ban": false,
"class-name": true,
"comment-format": [
true,
"check-space"
],
"curly": true,
"eofline": true,
"forin": true,
"indent": [
true,
"spaces"
],
"interface-name": false,
"jsdoc-format": true,
"label-position": true,
"max-line-length": [
true,
180
],
"member-ordering": [
true,
"static-before-instance",
"variables-before-functions"
],
"no-any": false,
"no-arg": true,
"no-bitwise": false,
"no-conditional-assignment": true,
"no-consecutive-blank-lines": true,
"no-console": [
true,
"debug",
"info",
"time",
"timeEnd",
"trace"
],
"no-construct": true,
"no-constructor-vars": false,
"no-debugger": true,
"no-duplicate-variable": true,
"no-empty": false,
"no-eval": true,
"no-inferrable-types": false,
"no-internal-module": true,
"no-require-imports": false,
"no-shadowed-variable": true,
"no-switch-case-fall-through": true,
"no-trailing-whitespace": true,
"no-unused-expression": true,
"no-unused-variable": true,
"no-use-before-declare": true,
"no-var-keyword": true,
"no-var-requires": true,
"object-literal-sort-keys": false,
"one-line": [
true,
"check-open-brace",
"check-catch",
"check-else",
"check-whitespace"
],
"quotemark": [
true,
"single",
"avoid-escape"
],
"radix": true,
"semicolon": true,
"switch-default": true,
"trailing-comma": [
true,
{
"multiline": "never",
"singleline": "never"
}
],
"triple-equals": [
true,
"allow-null-check"
],
"typedef": false,
"typedef-whitespace": [
true,
{
"call-signature": "nospace",
"index-signature": "nospace",
"parameter": "nospace",
"property-declaration": "nospace",
"variable-declaration": "nospace"
}
],
"use-strict": false,
"variable-name": [
true,
"check-format",
"allow-leading-underscore",
"ban-keywords"
],
"whitespace": [
true,
"check-branch",
"check-operator",
"check-separator",
"check-type",
"check-module",
"check-decl"
]
}
}

View File

@@ -0,0 +1,70 @@
var path = require('path');
var loaderUtils = require('loader-utils');
module.exports = function(content) {
this.cacheable && this.cacheable();
if(!this.emitFile) throw new Error('emitFile is required from module system');
var query = loaderUtils.getOptions(this) || {};
var configKey = query.config || 'multiFileLoader';
var options = this.options[configKey] || {};
var config = {
publicPath: false,
useRelativePath: false,
name: '[hash].[ext]'
};
// options takes precedence over config
Object.keys(options).forEach(function(attr) {
config[attr] = options[attr];
});
// query takes precedence over config and options
Object.keys(query).forEach(function(attr) {
config[attr] = query[attr];
});
var context = config.context || this.options.context;
var url = loaderUtils.interpolateName(this, config.name, {
context: context,
content: content,
regExp: config.regExp
});
var path = loaderUtils.interpolateName(this, '[path]', {
context: context,
content: content,
regExp: config.regExp
});
var outputPath = '';
if (config.outputPath) {
outputPath = (
typeof config.outputPath === 'function'
? config.outputPath(url, path)
: config.outputPath + url
);
} else {
outputPath = url;
}
var publicPath = JSON.stringify(url);
if (config.publicPath) {
publicPath = JSON.stringify(
typeof config.publicPath === 'function'
? config.publicPath(url, path)
: config.publicPath + url
);
}
publicPath = '__webpack_public_path__ + ' + publicPath;
if (query.emitFile === undefined || query.emitFile) {
this.emitFile(outputPath, content);
}
return 'module.exports = ' + publicPath + ';';
};
module.exports.raw = true;

View File

@@ -0,0 +1,67 @@
var path = require('path');
var loaderUtils = require('loader-utils');
var fs = require('fs');
var licenseFileUtf8Store = undefined;
function readLicenseHeaderFile(licenseFilePath) {
if (licenseFileUtf8Store) {
return licenseFileUtf8Store;
}
if (fs.existsSync(licenseFilePath)) {
licenseFileUtf8Store = fs.readFileSync(licenseFilePath, 'utf8').split(/\r?\n/);
return licenseFileUtf8Store;
}
throw new Error('The license header file path is wrong ' + licenseFilePath);
}
function isFileEmpty(fileContents) {
return fileContents.toString('utf8').trim() === '';
}
function readCurrentFile(fileContent) {
return fileContent.toString('utf8').split(/\r?\n/);
}
function isLicenseHeaderPresent(currentFileContent, licenseFilePath) {
if (!isFileEmpty(currentFileContent)) {
var currentFileUtf8 = readCurrentFile(currentFileContent),
licenseFileUtf8 = readLicenseHeaderFile(licenseFilePath);
skipStrict = 0;
if(currentFileUtf8[0] === '"use strict";' ) {
skipStrict = 1;
}
for (var i = skipStrict; i < licenseFileUtf8.length; i++) {
if (currentFileUtf8[i + skipStrict] !== licenseFileUtf8[i]) {
return false;
}
}
}
return true;
}
function report(hasHeader, emitter, filename) {
if (hasHeader) return;
emitter('Missing license header file : ' + filename);
}
function licenseCheck(webpackInstance, input, options) {
var isLicensePresent = isLicenseHeaderPresent(input, options.licenseFile);
var emitter = options.emitErrors ? webpackInstance.emitError : webpackInstance.emitWarning;
report(isLicensePresent, emitter, webpackInstance.resourcePath);
}
module.exports = function(input, map) {
this.cacheable && this.cacheable();
var callback = this.async();
var options = loaderUtils.getOptions(this);
licenseCheck(this, input, options);
callback(null, input, map);
};

View File

@@ -0,0 +1,10 @@
var path = require('path');
var _root = path.resolve(__dirname, '..');
function root(args) {
args = Array.prototype.slice.call(arguments, 0);
return path.join.apply(path, [_root].concat(args));
}
exports.root = root;

View File

@@ -0,0 +1,124 @@
const webpack = require('webpack');
const helpers = require('./helpers');
const fs = require('fs');
const path = require('path');
module.exports = {
resolveLoader: {
alias: {
"file-multi-loader": path.resolve(__dirname, "./custom-loaders/file-loader-multi"),
"license-check": path.resolve(__dirname, "./custom-loaders/license-check")
}
},
// require those dependencies but don't bundle them
externals: [
/^\@angular\//,
/^rxjs\//,
'moment',
'raphael',
'ng2-charts',
'alfresco-js-api',
'ng2-alfresco-core',
'ng2-alfresco-datatable',
'ng2-activiti-analytics',
'ng2-activiti-diagrams',
'ng2-activiti-form',
"ng2-activiti-tasklist",
'ng2-alfresco-documentlist'
],
module: {
rules: [
{
enforce: 'pre',
test: /\.js$/,
loader: 'source-map-loader',
exclude: [/node_modules/, /bundles/, /dist/, /demo/]
},
{
enforce: 'pre',
test: /\.ts$/,
use: 'source-map-loader',
exclude: [/node_modules/, /bundles/, /dist/, /demo/]
},
{
enforce: 'pre',
test: /\.ts$/,
loader: 'tslint-loader',
options: {
emitErrors: true,
configFile: path.resolve(__dirname, './assets/tslint.json')
},
exclude: [/node_modules/, /bundles/, /dist/, /demo/]
},
{
test: /\.ts$/,
use: ['ts-loader', 'angular2-template-loader'],
exclude: [/node_modules/, /bundles/, /dist/, /demo/]
},
{
test: /\.html$/,
loader: 'html-loader',
exclude: [/node_modules/, /bundles/, /dist/, /demo/]
},
{
test: /\.css$/,
loader: ['to-string-loader', 'css-loader'],
exclude: [/node_modules/, /bundles/, /dist/, /demo/]
},{
enforce: 'pre',
test: /\.ts$/,
loader: 'license-check',
options: {
emitErrors: true,
licenseFile: path.resolve(__dirname, './assets/license_header.txt')
},
exclude: [/node_modules/, /bundles/, /dist/, /demo/, /rendering-queue.services.ts/ ],
},
{
test: /\.(png|jpe?g|gif|svg|woff|woff2|ttf|eot|ico)$/,
loader: 'file-multi-loader',
query: {
name: '[name].[hash].[ext]',
outputPath: (url, resourcePath)=> {
return resourcePath.replace('src', 'bundles') + url;
},
publicPath: (url, resourcePath)=> {
var component = resourcePath.substring(0, resourcePath.indexOf('src'));
var path = resourcePath.replace(component, '').replace('src', 'bundles');
return './' + path + url;
}
}
}
]
},
resolve: {
extensions: ['.ts', '.js'],
symlinks: false,
modules: [
'../ng2-components', 'node_modules'
]
},
plugins: [
new webpack.NoEmitOnErrorsPlugin(),
new webpack.BannerPlugin(fs.readFileSync(path.resolve(__dirname, './assets/license_header_add.txt'), 'utf8')),
new webpack.ContextReplacementPlugin(
/angular(\\|\/)core(\\|\/)@angular/,
helpers.root('./src'),
{}
)
],
devtool: 'cheap-module-source-map',
node: {
fs: 'empty',
module: false
}
};

View File

@@ -0,0 +1,85 @@
const webpack = require('webpack');
const helpers = require('./helpers');
const ENV = process.env.NODE_ENV = process.env.ENV = 'production';
module.exports = {
devtool: 'inline-source-map',
resolve: {
extensions: ['.ts', '.js'],
symlinks: false,
modules: [helpers.root('../ng2-components'), helpers.root('node_modules')]
},
module: {
rules: [
{
enforce: 'pre',
test: /\.js$/,
loader: 'source-map-loader',
exclude: [/node_modules/, /bundles/, /dist/, /demo/]
},
{
test: /\.ts$/,
loaders: ['ts-loader?' + JSON.stringify({ transpileOnly: true}), 'angular2-template-loader'],
exclude: [/node_modules/, /bundles/, /dist/, /demo/]
},
{
test: /\.html$/,
loader: 'html-loader',
exclude: [/node_modules/, /bundles/, /dist/, /demo/]
},
{
test: /\.css$/,
loader: ['to-string-loader', 'css-loader'],
exclude: [/node_modules/, /bundles/, /dist/, /demo/]
},
{
test: /\.(png|jpe?g|gif|svg|woff|woff2|ttf|eot|ico|pdf)$/,
loader: 'file-loader',
query: {
name: '[path][name].[ext]',
outputPath: (url)=> {
return url.replace('src', 'dist');
}
}
},
{
enforce: 'post',
test: /\.ts$/,
loader: 'istanbul-instrumenter-loader',
exclude: [
/node_modules/,
/test/
]
}
]
},
plugins: [
new webpack.NoEmitOnErrorsPlugin(),
new webpack.ContextReplacementPlugin(
/angular(\\|\/)core(\\|\/)@angular/,
helpers.root('./src'),
{}
),
new webpack.DefinePlugin({
'process.env': {
'ENV': JSON.stringify(ENV)
}
}),
new webpack.LoaderOptionsPlugin({
htmlLoader: {
minimize: false // workaround for ng2
}
})
],
node: {
fs: 'empty',
module: false
}
};

View File

@@ -21,11 +21,6 @@ module.exports = function (config) {
{pattern: './node_modules/md-date-time-picker/**/*.js', included: false, served: true, watched: false},
{pattern: './node_modules/moment/**/*.js', included: false, served: true, watched: false},
// pdf-js
'./node_modules/pdfjs-dist/build/pdf.js',
'./node_modules/pdfjs-dist/build/pdf.worker.js',
'./node_modules/pdfjs-dist/web/pdf_viewer.js',
{pattern: 'karma-test-shim.js', watched: false},
{pattern: './src/assets/**/*.*', included: false, served: true, watched: false},
{pattern: './src/i18n/**/*.*', included: false, served: true, watched: false},

View File

@@ -98,14 +98,5 @@
"webscript",
"alfresco-component"
],
"license-check-config": {
"src": [
"./src/**/*.ts"
],
"path": "assets/license_header.txt",
"blocking": true,
"logInfo": false,
"logError": true
},
"license": "Apache-2.0"
}

View File

@@ -1,6 +1,6 @@
const webpack = require("webpack");
const webpack = require('webpack');
const webpackMerge = require('webpack-merge');
const commonConfig = require('../config/webpack.common.js');
const commonConfig = require('./config/webpack.common.js');
module.exports = webpackMerge(commonConfig, {

View File

@@ -1,6 +1,6 @@
const webpack = require('webpack');
const webpackMerge = require('webpack-merge');
const testConfig = require('../config/webpack.test.js');
const testConfig = require('./config/webpack.test.js');
module.exports = webpackMerge(testConfig, {