Commit 479318df authored by Sang D NGO's avatar Sang D NGO

Merge branch 'issue-7' into 'master'

#7 clean unused things

See merge request linagora/lgs/openpaas/linagora.esn.seed!9
parents e57401a9 9d29da92
{
"extends": "linagora-esn",
"rules": {
"consistent-this": ["warn", "self"],
"no-unused-vars": ["error", { "vars": "all", "args": "after-used" }],
"no-console": ["error", { "allow": ["warn", "error"] }],
"no-process-env": "off",
"arrow-parens": ["error", "as-needed"]
"arrow-parens": ["error", "as-needed"],
"no-console": ["error", { "allow": ["warn", "error"] }]
}
}
\ No newline at end of file
}
......@@ -2,3 +2,5 @@ node_modules
frontend/components
.idea
*.log
package-lock.json
yarn.lock
'use strict';
module.exports = function(grunt) {
const CI = grunt.option('ci');
let KARMA_REPORTERS = (grunt.option('reporter') || '').split(',').filter(Boolean);
if (!KARMA_REPORTERS.length) {
KARMA_REPORTERS = CI ? ['spec', 'coverage'] : ['dots'];
}
grunt.initConfig({
concat: {
options: {
separator: ';'
}
},
splitfiles: {
options: {
chunk: 10
},
backend: {
options: {
common: ['test/unit-backend/all.js'],
target: 'mochacli:backend'
},
files: {
src: ['test/unit-backend/**/*.js']
}
},
midway: {
options: {
common: ['test/midway-backend/all.js'],
target: 'mochacli:midway'
},
files: {
src: ['test/midway-backend/**/*.js']
}
}
},
mochacli: {
options: {
require: ['chai', 'mockery'],
reporter: 'spec',
timeout: process.env.TEST_TIMEOUT || 20000,
env: {
ESN_CUSTOM_TEMPLATES_FOLDER: 'testscustom'
}
},
backend: {
options: {
files: ['test/unit-backend/all.js', grunt.option('test') || 'test/unit-backend/**/*.js']
}
},
midway: {
options: {
files: ['test/midway-backend/all.js', grunt.option('test') || 'test/midway-backend/**/*.js']
}
}
},
karma: {
unit: {
configFile: './test/config/karma.conf.js',
browsers: ['PhantomJS'],
reporters: KARMA_REPORTERS
},
all: {
configFile: './test/config/karma.conf.js',
browsers: ['PhantomJS', 'Firefox', 'Chrome'],
reporters: KARMA_REPORTERS
}
}
});
grunt.loadNpmTasks('grunt-shell');
grunt.loadNpmTasks('grunt-mocha-cli');
grunt.loadNpmTasks('grunt-karma');
grunt.loadTasks('tasks');
grunt.registerTask('test-unit-backend', 'run the backend unit tests (to be used with .only)', ['splitfiles:backend']);
grunt.registerTask('test-midway-backend', 'run midway tests (to be used with .only)', ['splitfiles:midway']);
grunt.registerTask('test-backend', 'run both the unit & midway tests', ['test-unit-backend', 'test-midway-backend']);
grunt.registerTask('test-frontend', 'run the FrontEnd tests', ['karma:unit']);
grunt.registerTask('test-frontend-all', 'run the FrontEnd tests on all possible browsers', ['karma:all']);
grunt.registerTask('test', ['linters', 'test-backend', 'test-midway-backend']);
grunt.registerTask('default', ['test']);
};
'use strict';
/* eslint-disable no-process-env */
const timeGrunt = require('time-grunt');
module.exports = function(grunt) {
......@@ -17,7 +19,7 @@ module.exports = function(grunt) {
}
},
all: {
src: ['Gruntfile.js', 'Gruntfile-tests.js', 'tasks/**/*.js', 'test/**/*.js', 'test/**/**/*.js', 'backend/**/*.js', 'frontend/app/**/*.js']
src: ['*.js', 'tasks/**/*.js', 'test/**/*.js', 'test/**/**/*.js', 'backend/**/*.js', 'frontend/app/**/*.js']
}
},
......@@ -127,15 +129,14 @@ module.exports = function(grunt) {
grunt.loadTasks('tasks');
grunt.loadNpmTasks('grunt-lint-pattern');
grunt.loadNpmTasks('@linagora/grunt-lint-pattern');
grunt.loadNpmTasks('@linagora/grunt-i18n-checker');
grunt.loadNpmTasks('grunt-eslint');
grunt.loadNpmTasks('grunt-mocha-cli');
grunt.loadNpmTasks('grunt-karma');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-eslint');
grunt.loadNpmTasks('@linagora/grunt-i18n-checker');
grunt.loadNpmTasks('grunt-puglint');
grunt.registerTask('i18n', 'Check the translation files', ['i18n_checker']);
......
......@@ -10,7 +10,7 @@ While waiting for a npm-based dependency injection handler, you have to install
**1. Clone**
```
```bash
git clone https://ci.linagora.com/linagora/lgs/openpaas/linagora.esn.seed.git
```
......@@ -22,21 +22,20 @@ There is two way to install the model in OpenPaaS, so choose one of them:
The modules must be available in the `$ESN/modules` folder:
```
cd $ESN/modules
ln -s path_to_module/linagora.esn.seed
```bash
ln -s path_to_module/linagora.esn.seed $ESN/modules/
```
- B. _Using npm link_
Go inside the module repository:
```
```bash
npm link
```
Go inside OpenPaaS ESN repository:
```
```bash
cd $ESN
npm link linagora.esn.seed
npm install
......
{
"Seed module" : "Seed module",
"My sidebar" : "My sidebar"
"Seed module" : "Mô-đun hạt mầm",
"My sidebar" : "Thanh bên của tôi"
}
......@@ -2,5 +2,6 @@
module.exports = function(dependencies, application) {
var i18n = require('../../lib/i18n')(dependencies);
application.use(i18n.init);
};
{
"name": "awesome.module.seed",
"name": "linagora.esn.seed",
"main": "index.js",
"version": "0.0.1",
"authors": [
......@@ -22,10 +22,9 @@
"test",
"tests"
],
"dependencies": {},
"devDependencies": {
"angular": "1.3.20",
"angular-component": "https://github.com/toddmotto/angular-component.git#~0.1.2",
"angular-component": "linagora/angular-component#0.1.4",
"angular-mocks": "1.3.20",
"angular-translate": "2.11.0",
"angular-translate-loader-static-files": "2.11.0",
......@@ -34,7 +33,6 @@
"dynamic-directive": "2.0.0",
"jquery": "2.1.1",
"restangular": "1.3.1",
"sinon-1.15.4": "http://sinonjs.org/releases/sinon-1.15.4.js",
"sinon-chai": "2.8.0"
}
}
(function() {
'use strict';
var MODULE_NAME = 'awesome.module.seed';
var MODULE_NAME = 'linagora.esn.seed';
var MODULE_PREFIX = 'seed';
angular.module(MODULE_NAME)
.config(seedApplicationMenu)
.config(translateProviderConfigure);
.config(seedApplicationMenu);
////////////////
function seedApplicationMenu(dynamicDirectiveServiceProvider) {
var home = new dynamicDirectiveServiceProvider.DynamicDirective(true, MODULE_PREFIX + '-application-menu');
dynamicDirectiveServiceProvider.addInjection('esn-application-menu', home);
}
function translateProviderConfigure($translateProvider) {
$translateProvider.useStaticFilesLoader({
files: [{
prefix: './' + MODULE_NAME + '/app/locales/web-',
suffix: '.json'
}]
});
$translateProvider.preferredLanguage('fr');
$translateProvider.useSanitizeValueStrategy('escape');
}
})();
// @import Styles files here
@import './seed-variables';
@import './home/seed-home';
(function() {
'use strict';
var MODULE_NAME = 'awesome.module.seed';
var MODULE_NAME = 'linagora.esn.seed';
angular.module(MODULE_NAME, [
'ui.router',
'op.dynamicDirective',
'restangular',
'pascalprecht.translate'
'restangular'
]);
})();
(function() {
'use strict';
var MODULE_NAME = 'awesome.module.seed';
var MODULE_DIR_NAME = '/awesome.module.seed';
var MODULE_NAME = 'linagora.esn.seed';
var MODULE_DIR_NAME = '/linagora.esn.seed';
angular.module(MODULE_NAME)
......
(function() {
'use strict';
var MODULE_NAME = 'awesome.module.seed';
var MODULE_NAME = 'linagora.esn.seed';
angular.module(MODULE_NAME)
.directive('seedApplicationMenu', seedApplicationMenu);
......
(function() {
'use strict';
var MODULE_NAME = 'awesome.module.seed';
var MODULE_DIR_NAME = '/awesome.module.seed';
var MODULE_NAME = 'linagora.esn.seed';
var MODULE_DIR_NAME = '/linagora.esn.seed';
angular.module(MODULE_NAME)
.factory('seedRestangular', seedRestangular);
......
(function() {
'use strict';
var MODULE_NAME = 'awesome.module.seed';
var MODULE_NAME = 'linagora.esn.seed';
angular.module(MODULE_NAME)
.controller('seedHomeController', seedHomeController);
......
......@@ -10,7 +10,7 @@ describe('the seedHomeController', function() {
beforeEach(function() {
angular.mock.module('awesome.module.seed');
angular.mock.module('linagora.esn.seed');
angular.mock.inject(function(_$rootScope_, _$controller_) {
$rootScope = _$rootScope_;
......
......@@ -19,7 +19,6 @@
padding: 5px 10px;
background: @m-white;
box-shadow: 0 1px 1px @m-black-fade-15;
}
}
}
......
(function() {
'use strict';
var MODULE_NAME = 'awesome.module.seed';
var MODULE_DIR_NAME = '/awesome.module.seed';
var MODULE_NAME = 'linagora.esn.seed';
var MODULE_DIR_NAME = '/linagora.esn.seed';
angular.module(MODULE_NAME)
.component('seedSubheader', seedSubheader());
......
{
"Seed module" : "Seed module",
"My sidebar" : "My sidebar"
}
{
"Seed module" : "Le module seed",
"My sidebar" : "Ma barre latérale"
}
/* define the common LESS variable
example:*/
@m-black-fade-15: fade(@m-black, 15%);
'use strict';
var MODULE_NAME = 'awesome.module.seed';
var MODULE_DIR_NAME = '/awesome.module.seed';
var MODULE_NAME = 'linagora.esn.seed';
var MODULE_DIR_NAME = '/linagora.esn.seed';
angular.module(MODULE_NAME)
......
.seed-button(contextual-sidebar, data-content-template="/awesome.module.seed/app/home/seed-sidebar.html")
.seed-button(contextual-sidebar, data-content-template="/linagora.esn.seed/app/home/seed-sidebar.html")
i.mdi.mdi-menu
'use strict';
var MODULE_NAME = 'awesome.module.seed';
var MODULE_DIR_NAME = '/awesome.module.seed';
var MODULE_NAME = 'linagora.esn.seed';
var MODULE_DIR_NAME = '/linagora.esn.seed';
angular.module(MODULE_NAME)
......
......@@ -5,10 +5,9 @@ const Dependency = AwesomeModule.AwesomeModuleDependency;
const path = require('path');
const glob = require('glob-all');
const FRONTEND_JS_PATH = __dirname + '/frontend/app/';
const MODULE_NAME = 'awesome.module.seed';
const MODULE_PREFIX = 'seed';
const AWESOME_MODULE_NAME = 'linagora.esn.seed';
const myAwesomeModule = new AwesomeModule(MODULE_NAME, {
const myAwesomeModule = new AwesomeModule(AWESOME_MODULE_NAME, {
dependencies: [
new Dependency(Dependency.TYPE_NAME, 'linagora.esn.core.logger', 'logger'),
new Dependency(Dependency.TYPE_NAME, 'linagora.esn.core.webserver.wrapper', 'webserver-wrapper'),
......@@ -35,28 +34,28 @@ const myAwesomeModule = new AwesomeModule(MODULE_NAME, {
deploy: function(dependencies, callback) {
// Register the webapp
const app = require('./backend/webserver/application')(dependencies, this);
// Register every exposed endpoints
app.use('/api', this.api.module);
const webserverWrapper = dependencies('webserver-wrapper');
// Register every exposed frontend scripts
const jsFiles = glob.sync([
FRONTEND_JS_PATH + MODULE_PREFIX + '.app.js',
FRONTEND_JS_PATH + '*.js',
FRONTEND_JS_PATH + '*/!(*spec).js',
FRONTEND_JS_PATH + '**/*/!(*spec).js'
]).map(function(filepath) {
const frontendJsFilesFullPath = glob.sync([
FRONTEND_JS_PATH + '**/*.module.js',
FRONTEND_JS_PATH + '**/!(*spec).js'
]);
const frontendJsFilesUri = frontendJsFilesFullPath.map(function(filepath) {
return filepath.replace(FRONTEND_JS_PATH, '');
});
webserverWrapper.injectAngularAppModules(MODULE_NAME, jsFiles, [MODULE_NAME], ['esn']);
const lessFile = path.resolve(__dirname, `./frontend/app/${MODULE_PREFIX}.styles.less`);
webserverWrapper.injectLess(MODULE_NAME, [lessFile], 'esn');
const jsResourceFiles = [
"../components/angular-translate/angular-translate.min.js",
"../components/angular-translate-loader-static-files/angular-translate-loader-static-files.min.js"
];
webserverWrapper.injectJS(MODULE_NAME, jsResourceFiles, 'esn');
webserverWrapper.addApp(MODULE_NAME, app);
const lessFile = path.join(FRONTEND_JS_PATH, 'app.less');
webserverWrapper.injectAngularAppModules(AWESOME_MODULE_NAME, frontendJsFilesUri, AWESOME_MODULE_NAME, ['esn'], {
localJsFiles: frontendJsFilesFullPath
});
webserverWrapper.injectLess(AWESOME_MODULE_NAME, [lessFile], 'esn');
webserverWrapper.addApp(AWESOME_MODULE_NAME, app);
return callback();
}
......
......@@ -5,8 +5,9 @@
"main": "index.js",
"devDependencies": {
"@linagora/grunt-i18n-checker": "2.0.5",
"@linagora/karma-ng-jade2module-preprocessor": "0.5.3",
"@linagora/grunt-lint-pattern": "0.1.4",
"@linagora/i18n-checker": "2.0.3",
"@linagora/karma-ng-jade2module-preprocessor": "0.5.3",
"chai": "3.5.0",
"chai-as-promised": "5.3.0",
"chai-shallow-deep-equal": "1.4.0",
......@@ -15,15 +16,14 @@
"eslint-config-linagora-esn": "1.0.2",
"eslint-plugin-import": "1.16.0",
"grunt": "1.0.1",
"grunt-contrib-clean": "1.0.0",
"grunt-contrib-concat": "1.0.1",
"grunt-contrib-jshint": "1.1.0",
"grunt-contrib-watch": "1.0.0",
"grunt-eslint": "19.0.0",
"grunt-karma": "2.0.0",
"grunt-lint-pattern": "0.1.4",
"grunt-mocha-cli": "3.0.0",
"grunt-puglint": "1.0.0",
"grunt-contrib-clean": "1.0.0",
"grunt-run": "0.6.0",
"karma": "1.7.1",
"karma-chrome-launcher": "2.0.0",
......@@ -46,7 +46,7 @@
},
"scripts": {
"test": "grunt test",
"postinstall": "./node_modules/bower/bin/bower install --allow-root"
"postinstall": "bower install --production --allow-root"
},
"repository": {
"type": "git",
......@@ -55,12 +55,12 @@
"author": "Linagora R&D",
"license": "AGPL-3.0",
"engines": {
"node": ">=6.5.0"
"node": ">=8"
},
"dependencies": {
"awesome-module": "1.1.0",
"async": "2.0.1",
"bower": "1.7.9",
"awesome-module": "1.1.0",
"bower": "1.8.2",
"express": "4.14.0",
"glob-all": "3.1.0",
"lodash": "4.15.0",
......
'use strict';
const MODULE_DIR_NAME = '/awesome.module.seed';
const MODULE_PREFIX = 'seed';
const MODULE_DIR_NAME = '/linagora.esn.seed';
module.exports = function(config) {
config.set({
......@@ -18,12 +17,15 @@ module.exports = function(config) {
'frontend/components/restangular/dist/restangular.min.js',
'frontend/components/lodash/dist/lodash.min.js',
'frontend/components/sinon-chai/lib/sinon-chai.js',
'frontend/components/sinon-1.15.4/index.js',
'node_modules/sinon/pkg/sinon.js',
'test/config/mocks.js',
`frontend/app/${MODULE_PREFIX}.app.js`,
'frontend/app/**/*.module.js',
'frontend/app/**/*.js',
'frontend/app/**/*.pug',
'frontend/app/*.js'
'frontend/app/**/*.pug'
],
exclude: [
'frontend/app/app.router.js',
'frontend/app/app.run.js'
],
frameworks: ['mocha'],
colors: true,
......@@ -54,7 +56,7 @@ module.exports = function(config) {
cacheIdFromPath: function(filepath) {
return filepath
.replace(/pug$/, 'html')
.replace(/^frontend/, '/seed')
.replace(/^frontend/, MODULE_DIR_NAME)
.replace(/^node_modules\/linagora-rse\/frontend/, '');
},
// setting this option will create only a single module that contains templates
......@@ -63,8 +65,10 @@ module.exports = function(config) {
basedir: require('path').resolve(__dirname, '../../node_modules/linagora-rse/frontend/views')
},
jadeRenderLocals: {
__: function(str) {
return str;
__: function(str, ...params) {
return str.replace(/(%s)/g, function() {
return params.shift();
});
}
},
moduleName: 'jadeTemplates'
......
'use strict';
/* eslint-disable no-process-env */
const DEFAULT_PORTS = {
express: 23455
};
......
......@@ -2,7 +2,7 @@
const request = require('supertest');
const expect = require('chai').expect;
const MODULE_NAME = 'awesome.module.seed';
const MODULE_NAME = 'linagora.esn.seed';
describe('The example API', function() {
let user, app;
......
'use strict';
/**
* Inject angular things globally, for use in frontend unit tests. Add your
* instance names to the INJECTIONS array and don't forget to modify linter config
*/
(function(global) {
// Define things that should be globally injected here
var INJECTIONS = ['$q'];
// The rest of the code is boilerplate
angular.module('esn.test.injector', []).run(INJECTIONS.concat([function() {
for (var i = 0, len = arguments.length; i < len; i++) {
global[INJECTIONS[i]] = arguments[i];
}
}]));
beforeEach(angular.mock.module('esn.test.injector'));
})(this);
'use strict';
/* eslint-disable */
/**
* @ngdoc service
* @name $componentController
* @description
* A service that can be used to create instances of component controllers.
* <div class="alert alert-info">
* Be aware that the controller will be instantiated and attached to the scope as specified in
* the component definition object. If you do not provide a `$scope` object in the `locals` param
* then the helper will create a new isolated scope as a child of `$rootScope`.
* </div>
* @param {string} componentName the name of the component whose controller we want to instantiate
* @param {Object} locals Injection locals for Controller.
* @param {Object=} bindings Properties to add to the controller before invoking the constructor. This is used
* to simulate the `bindToController` feature and simplify certain kinds of tests.
* @param {string=} ident Override the property name to use when attaching the controller to the scope.
* @return {Object} Instance of requested controller.
*/
angular.mock.$ComponentControllerProvider = ['$compileProvider', function($compileProvider) {
this.$get = ['$controller', '$injector', '$rootScope', function($controller, $injector, $rootScope) {
return function $componentController(componentName, locals, bindings, ident) {
// get all directives associated to the component name
var directives = $injector.get(componentName + 'Directive');
// look for those directives that are components
var candidateDirectives = directives.filter(function(directiveInfo) {
// components have controller, controllerAs and restrict:'E'
return directiveInfo.controller && directiveInfo.controllerAs && directiveInfo.restrict === 'E';
});
// check if valid directives found
if (candidateDirectives.length === 0) {
throw new Error('No component found');
}
if (candidateDirectives.length > 1) {
throw new Error('Too many components found');
}
// get the info of the component
var directiveInfo = candidateDirectives[0];
// create a scope if needed
locals = locals || {};
locals.$scope = locals.$scope || $rootScope.$new(true);
return $controller(directiveInfo.controller, locals, bindings, ident || directiveInfo.controllerAs);
};
}];
}];
angular.module('ngMock').provider({
$componentController: angular.mock.$ComponentControllerProvider
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment