MOBILE-3320 core: Refactor folders structure

main
Noel De Martin 2020-11-19 12:40:18 +01:00
parent e1db269cd1
commit 7d1dcd3c23
291 changed files with 197 additions and 240 deletions

View File

@ -93,7 +93,8 @@
"options": {
"lintFilePatterns": [
"src/**/*.ts",
"src/app/**/*.html"
"src/core/**/*.html",
"src/addons/**/*.html"
]
}
},

View File

@ -18,15 +18,14 @@ const { resolve } = require('path');
module.exports = config => {
config.resolve.alias['@'] = resolve('src');
config.resolve.alias['@addon'] = resolve('src/app/addon');
config.resolve.alias['@app'] = resolve('src/app');
config.resolve.alias['@classes'] = resolve('src/app/classes');
config.resolve.alias['@components'] = resolve('src/app/components');
config.resolve.alias['@core'] = resolve('src/app/core');
config.resolve.alias['@directives'] = resolve('src/app/directives');
config.resolve.alias['@pipes'] = resolve('src/app/pipes');
config.resolve.alias['@services'] = resolve('src/app/services');
config.resolve.alias['@singletons'] = resolve('src/app/singletons');
config.resolve.alias['@classes'] = resolve('src/core/classes');
config.resolve.alias['@components'] = resolve('src/core/components');
config.resolve.alias['@directives'] = resolve('src/core/directives');
config.resolve.alias['@features'] = resolve('src/core/features');
config.resolve.alias['@guards'] = resolve('src/core/guards');
config.resolve.alias['@pipes'] = resolve('src/core/pipes');
config.resolve.alias['@services'] = resolve('src/core/services');
config.resolve.alias['@singletons'] = resolve('src/core/singletons');
config.plugins.push(
new webpack.DefinePlugin({

View File

@ -136,48 +136,36 @@ class BuildLangTask {
treatMergedData(data) {
const merged = {};
const mergedOrdered = {};
const getPrefix = (path) => {
const folders = path.split(/[\/\\]/);
switch (folders[0]) {
case 'core':
switch (folders[1]) {
case 'lang':
return 'core.';
case 'features':
return `core.${folders[2]}.`;
}
break;
case 'addons':
return `addon.${folders.slice(1, -2).join('_')}.`;
case 'assets':
return `assets.${folders[1]}.`;
}
return null;
}
for (let filepath in data) {
const pathSplit = filepath.split(/[\/\\]/);
let prefix;
pathSplit.pop();
switch (pathSplit[0]) {
case 'lang':
prefix = 'core';
break;
case 'core':
if (pathSplit[1] == 'lang') {
// Not used right now.
prefix = 'core';
} else {
prefix = 'core.' + pathSplit[1];
}
break;
case 'addon':
// Remove final item 'lang'.
pathSplit.pop();
// Remove first item 'addon'.
pathSplit.shift();
// For subplugins. We'll use plugin_subfolder_subfolder2_...
// E.g. 'mod_assign_feedback_comments'.
prefix = 'addon.' + pathSplit.join('_');
break;
case 'assets':
prefix = 'assets.' + pathSplit[1];
break;
}
const prefix = getPrefix(filepath);
if (prefix) {
this.addProperties(merged, data[filepath], prefix + '.');
this.addProperties(merged, data[filepath], prefix);
}
}
// Force ordering by string key.
Object.keys(merged).sort().forEach((key) => {
mergedOrdered[key] = merged[key];

View File

@ -19,13 +19,12 @@ const gulp = require('gulp');
const paths = {
lang: [
'./src/app/lang/',
'./src/app/core/**/lang/',
'./src/app/addon/**/lang/',
'./src/app/**/**/lang/',
'./src/addons/**/lang/',
'./src/assets/countries/',
'./src/assets/mimetypes/'
]
'./src/assets/mimetypes/',
'./src/core/features/**/lang/',
'./src/core/lang/',
],
};
const args = Utils.getCommandLineArguments();

View File

@ -3,11 +3,11 @@ const { compilerOptions } = require('./tsconfig');
module.exports = {
preset: 'jest-preset-angular',
setupFilesAfterEnv: ['<rootDir>/src/tests/setup.ts'],
setupFilesAfterEnv: ['<rootDir>/src/testing/setup.ts'],
testMatch: ['**/?(*.)test.ts'],
collectCoverageFrom: [
'src/**/*.{ts,html}',
'!src/tests/**/*',
'!src/testing/**/*',
],
transform: {
'^.+\\.(ts|html)$': 'ts-jest',

View File

@ -29,9 +29,9 @@ import {
AddonPrivateFilesFile,
AddonPrivateFilesGetUserInfoWSResult,
AddonPrivateFilesGetFilesWSParams,
} from '@addon/privatefiles/services/privatefiles';
import { AddonPrivateFilesHelper } from '@addon/privatefiles/services/privatefiles.helper';
import { CoreUtils } from '@/app/services/utils/utils';
} from '@/addons/privatefiles/services/privatefiles';
import { AddonPrivateFilesHelper } from '@/addons/privatefiles/services/privatefiles.helper';
import { CoreUtils } from '@services/utils/utils';
/**
* Page that displays the list of files.

View File

@ -15,14 +15,14 @@
import { NgModule } from '@angular/core';
import { Routes } from '@angular/router';
import { CoreMainMenuDelegate } from '@core/mainmenu/services/mainmenu.delegate';
import { CoreMainMenuRoutingModule } from '@core/mainmenu/mainmenu-routing.module';
import { CoreMainMenuDelegate } from '@features/mainmenu/services/mainmenu.delegate';
import { CoreMainMenuRoutingModule } from '@features/mainmenu/mainmenu-routing.module';
import { AddonPrivateFilesMainMenuHandler } from './services/handlers/mainmenu';
const routes: Routes = [
{
path: 'addon-privatefiles',
loadChildren: () => import('@addon/privatefiles/privatefiles.module').then(m => m.AddonPrivateFilesModule),
loadChildren: () => import('@/addons/privatefiles/privatefiles.module').then(m => m.AddonPrivateFilesModule),
},
];

View File

@ -14,8 +14,8 @@
import { Injectable } from '@angular/core';
import { CoreMainMenuHandler, CoreMainMenuHandlerData } from '@core/mainmenu/services/mainmenu.delegate';
import { AddonPrivateFiles } from '@addon/privatefiles/services/privatefiles';
import { CoreMainMenuHandler, CoreMainMenuHandlerData } from '@features/mainmenu/services/mainmenu.delegate';
import { AddonPrivateFiles } from '@/addons/privatefiles/services/privatefiles';
/**
* Handler to inject an option into main menu.

View File

@ -16,7 +16,7 @@ import { Injectable } from '@angular/core';
import { CoreSites } from '@services/sites';
import { CoreDomUtils } from '@services/utils/dom';
import { CoreFileUploaderHelper } from '@core/fileuploader/services/fileuploader.helper';
import { CoreFileUploaderHelper } from '@features/fileuploader/services/fileuploader.helper';
import { AddonPrivateFiles, AddonPrivateFilesGetUserInfoWSResult } from './privatefiles';
import { CoreError } from '@classes/errors/error';
import { makeSingleton, Translate } from '@singletons/core.singletons';

View File

@ -20,15 +20,15 @@ import { AuthGuard } from '@guards/auth.guard';
const routes: Routes = [
{
path: 'login',
loadChildren: () => import('./core/login/login.module').then( m => m.CoreLoginModule),
loadChildren: () => import('@features/login/login.module').then( m => m.CoreLoginModule),
},
{
path: 'settings',
loadChildren: () => import('./core/settings/settings.module').then( m => m.CoreSettingsModule),
loadChildren: () => import('@features/settings/settings.module').then( m => m.CoreSettingsModule),
},
{
path: '',
loadChildren: () => import('./core/mainmenu/mainmenu.module').then( m => m.CoreMainMenuModule),
loadChildren: () => import('@features/mainmenu/mainmenu.module').then( m => m.CoreMainMenuModule),
canActivate: [AuthGuard],
canLoad: [AuthGuard],
},

View File

@ -15,12 +15,12 @@
import { Observable } from 'rxjs';
import { NavController } from '@ionic/angular';
import { AppComponent } from '@app/app.component';
import { AppComponent } from '@/app/app.component';
import { CoreEvents } from '@singletons/events';
import { CoreLangProvider } from '@services/lang';
import { Network, Platform, NgZone } from '@singletons/core.singletons';
import { mock, mockSingleton, renderComponent, RenderConfig } from '@/tests/utils';
import { mock, mockSingleton, renderComponent, RenderConfig } from '@/testing/utils';
describe('AppComponent', () => {

View File

@ -16,7 +16,7 @@ import { Component, OnInit } from '@angular/core';
import { NavController } from '@ionic/angular';
import { CoreLangProvider } from '@services/lang';
import { CoreLoginHelperProvider } from '@core/login/services/login.helper';
import { CoreLoginHelperProvider } from '@features/login/services/login.helper';
import { CoreEvents, CoreEventSessionExpiredData } from '@singletons/events';
import { Network, NgZone, Platform } from '@singletons/core.singletons';
import { CoreApp } from '@services/app';

View File

@ -54,17 +54,17 @@ import { CoreUtilsProvider } from '@services/utils/utils';
import { initCoreFilepoolDB } from '@services/filepool.db';
import { initCoreSitesDB } from '@services/sites.db';
import { initCoreSyncDB } from '@services/sync.db';
import { initCoreSearchHistoryDB } from '@core/search/services/search.history.db';
import { initCoreSearchHistoryDB } from '@features/search/services/search.history.db';
// Import core modules.
import { CoreEmulatorModule } from '@core/emulator/emulator.module';
import { CoreLoginModule } from '@core/login/login.module';
import { CoreCoursesModule } from '@core/courses/courses.module';
import { CoreSettingsInitModule } from '@core/settings/settings-init.module';
import { CoreFileUploaderInitModule } from '@core/fileuploader/fileuploader-init.module';
import { CoreEmulatorModule } from '@features/emulator/emulator.module';
import { CoreLoginModule } from '@features/login/login.module';
import { CoreCoursesModule } from '@features/courses/courses.module';
import { CoreSettingsInitModule } from '@features/settings/settings-init.module';
import { CoreFileUploaderInitModule } from '@features/fileuploader/fileuploader-init.module';
// Import addons init modules.
import { AddonPrivateFilesInitModule } from '@addon/privatefiles/privatefiles-init.module';
import { AddonPrivateFilesInitModule } from '@/addons/privatefiles/privatefiles-init.module';
import { setSingletonsInjector } from '@singletons/core.singletons';

View File

@ -13,7 +13,7 @@
// limitations under the License.
import { BehaviorSubject, Subject } from 'rxjs';
import { CoreEvents } from '../singletons/events';
import { CoreEvents } from '@singletons/events';
import { CoreDelegate, CoreDelegateDisplayHandler, CoreDelegateToDisplay } from './delegate';
/**
@ -101,4 +101,3 @@ export class CoreSortedDelegate<
}
}

View File

@ -38,7 +38,7 @@ describe('CoreError', () => {
expect(error!.name).toEqual('CoreError');
expect(error!.message).toEqual(message);
expect(error!.stack).not.toBeNull();
expect(error!.stack).toContain('src/app/classes/error.test.ts');
expect(error!.stack).toContain('src/core/classes/error.test.ts');
});
it('can be subclassed', () => {
@ -70,7 +70,7 @@ describe('CoreError', () => {
expect(error!.name).toEqual('CustomCoreError');
expect(error!.message).toEqual(`Custom message: ${message}`);
expect(error!.stack).not.toBeNull();
expect(error!.stack).toContain('src/app/classes/error.test.ts');
expect(error!.stack).toContain('src/core/classes/error.test.ts');
});
});

View File

@ -32,7 +32,7 @@ import { CoreTextUtils } from '@services/utils/text';
import { CoreTimeUtils } from '@services/utils/time';
import { CoreUrlUtils, CoreUrlParams } from '@services/utils/url';
import { CoreUtils, PromiseDefer } from '@services/utils/utils';
import { CoreConstants } from '@core/constants';
import { CoreConstants } from '@/core/constants';
import { SQLiteDB } from '@classes/sqlitedb';
import { CoreError } from '@classes/errors/error';
import { CoreWSError } from '@classes/errors/wserror';

View File

@ -31,8 +31,8 @@ import { CoreShowPasswordComponent } from './show-password/show-password';
import { CoreEmptyBoxComponent } from './empty-box/empty-box';
import { CoreTabsComponent } from './tabs/tabs';
import { CoreDirectivesModule } from '@app/directives/directives.module';
import { CorePipesModule } from '@app/pipes/pipes.module';
import { CoreDirectivesModule } from '@directives/directives.module';
import { CorePipesModule } from '@pipes/pipes.module';
@NgModule({
declarations: [

View File

@ -13,7 +13,7 @@
// limitations under the License.
import { Component, Input, Output, EventEmitter } from '@angular/core';
import { CoreConstants } from '@core/constants';
import { CoreConstants } from '@/core/constants';
/**
* Component to show a download button with refresh option, the spinner and the status of it.

View File

@ -23,9 +23,9 @@ import { CoreMimetypeUtils } from '@services/utils/mimetype';
import { CoreUrlUtils } from '@services/utils/url';
import { CoreUtils } from '@services/utils/utils';
import { CoreTextUtils } from '@services/utils/text';
import { CoreConstants } from '@core/constants';
import { CoreConstants } from '@/core/constants';
import { CoreEventObserver, CoreEvents } from '@singletons/events';
import { CoreWSExternalFile } from '@/app/services/ws';
import { CoreWSExternalFile } from '@services/ws';
/**
* Component to handle a remote file. Shows the file name, icon (depending on mimetype) and a button

View File

@ -29,8 +29,8 @@ import { TranslateService } from '@ngx-translate/core';
import { Subscription } from 'rxjs';
import { CoreApp } from '@services/app';
import { CoreConfig } from '@services/config';
import { CoreConstants } from '@core/constants';
import { CoreUtils } from '@/app/services/utils/utils';
import { CoreConstants } from '@/core/constants';
import { CoreUtils } from '@services/utils/utils';
import { NavigationOptions } from '@ionic/angular/providers/nav-controller';
import { Params } from '@angular/router';

View File

@ -14,7 +14,7 @@
import { CoreIconComponent } from '@components/icon/icon';
import { renderWrapperComponent } from '@/tests/utils';
import { renderWrapperComponent } from '@/testing/utils';
describe('CoreIconComponent', () => {

View File

@ -15,7 +15,7 @@
import { Directive, ElementRef, Input, OnChanges, SimpleChange } from '@angular/core';
import { CoreLogger } from '@singletons/logger';
import { Http } from '@singletons/core.singletons';
import { CoreConstants } from '@core/constants';
import { CoreConstants } from '@/core/constants';
/**
* Directive to enable font-awesome 5 as ionicons.

View File

@ -21,7 +21,7 @@ import { CoreDomUtils } from '@services/utils/dom';
import { CoreUrlUtils } from '@services/utils/url';
import { CoreUtils } from '@services/utils/utils';
import { CoreTextUtils } from '@services/utils/text';
import { CoreConstants } from '@core/constants';
import { CoreConstants } from '@/core/constants';
/**
* Directive to open a link in external browser or in the app.

View File

@ -27,7 +27,7 @@ import { CoreUrlUtils, CoreUrlUtilsProvider } from '@services/utils/url';
import { CoreUtils, CoreUtilsProvider } from '@services/utils/utils';
import { Platform } from '@singletons/core.singletons';
import { mock, mockSingleton, RenderConfig, renderWrapperComponent } from '@/tests/utils';
import { mock, mockSingleton, RenderConfig, renderWrapperComponent } from '@/testing/utils';
describe('CoreFormatTextDirective', () => {

View File

@ -14,7 +14,7 @@
import { CoreLinkDirective } from '@directives/link';
import { renderTemplate } from '@/tests/utils';
import { renderTemplate } from '@/testing/utils';
describe('CoreLinkDirective', () => {

View File

@ -16,7 +16,7 @@ import { CoreContentLinksAction } from '../services/contentlinks.delegate';
import { CoreContentLinksHandlerBase } from './base-handler';
import { CoreSites } from '@services/sites';
import { CoreDomUtils } from '@services/utils/dom';
// import { CoreCourseHelperProvider } from '@core/course/providers/helper';
// import { CoreCourseHelperProvider } from '@features/course/providers/helper';
import { Params } from '@angular/router';
/**

View File

@ -14,7 +14,7 @@
import { CoreContentLinksHelper } from '../services/contentlinks.helper';
import { CoreContentLinksHandlerBase } from './base-handler';
import { Translate } from '@/app/singletons/core.singletons';
import { Translate } from '@singletons/core.singletons';
import { Params } from '@angular/router';
import { CoreContentLinksAction } from '../services/contentlinks.delegate';

View File

@ -17,7 +17,7 @@ import { NavController } from '@ionic/angular';
import { CoreSiteBasicInfo, CoreSites } from '@services/sites';
import { CoreDomUtils } from '@services/utils/dom';
import { Translate } from '@singletons/core.singletons';
import { CoreLoginHelper } from '@core/login/services/login.helper';
import { CoreLoginHelper } from '@features/login/services/login.helper';
import { CoreContentLinksAction } from '../../services/contentlinks.delegate';
import { CoreContentLinksHelper } from '../../services/contentlinks.helper';
import { ActivatedRoute } from '@angular/router';

View File

@ -17,10 +17,10 @@ import { NavController } from '@ionic/angular';
import { CoreSites } from '@services/sites';
import { CoreDomUtils } from '@services/utils/dom';
import { CoreUtils } from '@services/utils/utils';
import { CoreLoginHelper } from '@core/login/services/login.helper';
import { CoreLoginHelper } from '@features/login/services/login.helper';
import { CoreContentLinksDelegate, CoreContentLinksAction } from './contentlinks.delegate';
import { CoreSite } from '@classes/site';
import { CoreMainMenu } from '@core/mainmenu/services/mainmenu';
import { CoreMainMenu } from '@features/mainmenu/services/mainmenu';
import { makeSingleton, NgZone, Translate } from '@singletons/core.singletons';
import { Params } from '@angular/router';

View File

@ -22,7 +22,7 @@ const routes: Routes = [
{
path: 'dashboard',
loadChildren: () =>
import('@core/courses/pages/dashboard/dashboard.page.module').then(m => m.CoreCoursesDashboardPageModule),
import('@features/courses/pages/dashboard/dashboard.page.module').then(m => m.CoreCoursesDashboardPageModule),
},
];

Some files were not shown because too many files have changed in this diff Show More