@eui/tools 6.3.32 → 6.3.34

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.
Files changed (38) hide show
  1. package/.version.properties +1 -1
  2. package/CHANGELOG.md +18 -0
  3. package/package.json +1 -1
  4. package/sandbox.js +21 -6
  5. package/scripts/csdr/config/packages.js +5 -3
  6. package/scripts/csdr/config/projects.js +0 -2
  7. package/scripts/csdr/config/remotes.js +27 -3
  8. package/scripts/csdr/init/remotes/10.x/base/angular.json +0 -1
  9. package/scripts/csdr/init/remotes/10.x/full/common/app/eui-components.ts +11 -0
  10. package/scripts/csdr/init/remotes/10.x/full/common/app/fallback.component.ts +11 -0
  11. package/scripts/csdr/init/remotes/10.x/full/common/app/module.component.ts +91 -0
  12. package/scripts/csdr/init/remotes/10.x/full/common/app/module.ts +96 -0
  13. package/scripts/csdr/init/remotes/10.x/full/common/app/reducers/custom-route-serializer.ts +28 -0
  14. package/scripts/csdr/init/remotes/10.x/full/common/app/reducers/index.ts +42 -0
  15. package/scripts/csdr/init/remotes/10.x/full/common/app/routing.module.ts +34 -0
  16. package/scripts/csdr/init/remotes/10.x/full/common/assets/.gitkeep +0 -0
  17. package/scripts/csdr/init/remotes/10.x/full/common/config/global.ts +55 -0
  18. package/scripts/csdr/init/remotes/10.x/full/common/config/index.ts +20 -0
  19. package/scripts/csdr/init/remotes/10.x/full/common/config/modules.ts +3 -0
  20. package/scripts/csdr/init/remotes/10.x/full/common/environments/environment.prod.ts +3 -0
  21. package/scripts/csdr/init/remotes/10.x/full/common/environments/environment.ts +3 -0
  22. package/scripts/csdr/init/remotes/10.x/full/common/favicon.ico +0 -0
  23. package/scripts/csdr/init/remotes/10.x/full/common/index.html +10 -0
  24. package/scripts/csdr/init/remotes/10.x/full/common/main.ts +11 -0
  25. package/scripts/csdr/init/remotes/10.x/full/common/polyfills.ts +87 -0
  26. package/scripts/csdr/init/remotes/10.x/full/common/test.ts +20 -0
  27. package/scripts/csdr/init/remotes/10.x/full/options/definitions/dynatrace.json +4 -0
  28. package/scripts/csdr/init/remotes/10.x/full/options/definitions/participant.json +3 -0
  29. package/scripts/csdr/init/remotes/10.x/full/options/definitions/user-reducers.json +3 -0
  30. package/scripts/csdr/init/remotes/10.x/full/options/definitions/zipkin.json +5 -0
  31. package/scripts/csdr/init/remotes/10.x/full/options/participant/app/module.component.ts +94 -0
  32. package/scripts/csdr/init/remotes/10.x/full/options/participant/app/routing.module.ts +26 -0
  33. package/scripts/csdr/init/remotes/10.x/full/options/participant/config/index.ts +10 -0
  34. package/scripts/csdr/init/remotes/10.x/full/options/user-reducers/app/reducers/index.ts +66 -0
  35. package/scripts/csdr/install/projects.js +4 -4
  36. package/scripts/utils/build/package/element.js +7 -1
  37. package/scripts/utils/remotes/remotes-utils.js +35 -0
  38. package/scripts/utils/tools.js +1 -0
@@ -1 +1 @@
1
- 6.3.32
1
+ 6.3.34
package/CHANGELOG.md CHANGED
@@ -1,3 +1,21 @@
1
+ ## 6.3.34 (2023-02-14)
2
+
3
+ ##### Chores
4
+
5
+ * **other:**
6
+ * add 10.x full skeleton sources injection for SEDIA v10 remotes - MWP-9204 [MWP-9204](https://webgate.ec.europa.eu/CITnet/jira/browse/MWP-9204) ([030d3696](https://webgate.ec.europa.eu/CITnet/stash/scm/csdr/eui-tools.git/commits/030d3696107e6bf7f4e73f6b59dfa28665069848))
7
+
8
+ * * *
9
+ * * *
10
+ ## 6.3.33 (2023-02-14)
11
+
12
+ ##### Chores
13
+
14
+ * **other:**
15
+ * adapted post-build operation for remote v15 - cleanup unused assets - testing remotes imports for MWP playground devX - MWP-9204 [MWP-9204](https://webgate.ec.europa.eu/CITnet/jira/browse/MWP-9204) ([f11ffff8](https://webgate.ec.europa.eu/CITnet/stash/scm/csdr/eui-tools.git/commits/f11ffff88b66a3a78591d847151ce9edb946c70f))
16
+
17
+ * * *
18
+ * * *
1
19
  ## 6.3.32 (2023-02-14)
2
20
 
3
21
  ##### Chores
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eui/tools",
3
- "version": "6.3.32",
3
+ "version": "6.3.34",
4
4
  "tag": "latest",
5
5
  "license": "EUPL-1.1",
6
6
  "description": "eUI common tools and scripts",
package/sandbox.js CHANGED
@@ -1134,12 +1134,17 @@ const versionUtils = require('./scripts/csdr/version/version-utils');
1134
1134
  // console.log(e);
1135
1135
  // })
1136
1136
 
1137
- Promise.resolve()
1138
- .then(() => {
1139
- // const remotes = configUtils.remotes.getRemotes();
1140
- // console.log(remotes);
1141
- return installUtils.remotes.installDeps();
1142
- })
1137
+ // const prj = configUtils.projects.getCsdrProject('my-workplace-host-playground');
1138
+
1139
+ // Promise.resolve()
1140
+ // .then(() => {
1141
+ // return installUtils.projects.getLocalProjectRemoteDeps(prj);
1142
+ // })
1143
+ // .then((deps) => {
1144
+ // return installUtils.projects.importLocalProjectRemotes(prj, deps);
1145
+ // })
1146
+ // .then(() => {
1147
+ // })
1143
1148
 
1144
1149
 
1145
1150
  // Promise.resolve()
@@ -1152,4 +1157,14 @@ Promise.resolve()
1152
1157
  // })
1153
1158
 
1154
1159
 
1160
+ Promise.resolve()
1161
+ .then(() => {
1162
+ const remote = configUtils.remotes.getRemote('cc-task-centre-eui15-remote-el-ui');
1163
+ return buildPackageUtils.element.postBuild(remote, '1.0.0');
1164
+ })
1165
+ .then(() => {
1166
+ console.log('ok');
1167
+ })
1168
+
1169
+
1155
1170
 
@@ -72,9 +72,11 @@ module.exports.getPackageByNpmPkg = (npmPkg, fromCsdrConfig) => {
72
72
  }
73
73
 
74
74
  module.exports.isLocalPackage = (npmPkg) => {
75
- return getPackages().filter((p) => {
76
- return p.npmPkg === npmPkg
77
- })[0] !== null;
75
+ tools.logInfo(`Checking if ${npmPkg} is localled installed`);
76
+
77
+ const packagesFound = getPackages().filter(p => p.npmPkg === npmPkg);
78
+
79
+ return packagesFound.length > 0;
78
80
  }
79
81
 
80
82
 
@@ -60,10 +60,8 @@ const getProjectPaths = (prj) => {
60
60
 
61
61
  // locate and find the TSLint or ESLint configuration files
62
62
  if(tools.isFileExists(path.join(rootPath, 'src', 'tslint.json'))) {
63
- tools.logWarning('TSLint is deprecated and will be removed in the future. Consider migrating to ESLint')
64
63
  paths.tslintPath = path.join(rootPath, 'src', 'tslint.json');
65
64
  } else if(tools.isFileExists(path.join(rootPath, '.tslint.json'))) {
66
- tools.logWarning('TSLint is deprecated and will be removed in the future. Consider migrating to ESLint')
67
65
  paths.tslintPath = path.join(rootPath, '.tslint.json');
68
66
  } else if(tools.isFileExists(path.join(rootPath, 'src', '.eslintrc.json'))) {
69
67
  paths.eslintPath = path.join(rootPath, 'src', '.eslintrc.json');
@@ -19,8 +19,6 @@ module.exports.getRemote = (remoteName) => {
19
19
  remoteName = tools.getArgs().root;
20
20
  }
21
21
 
22
- tools.logInfo(`Getting remote config for ${remoteName}`);
23
-
24
22
  const remotesConfig = require(path.join(process.cwd(), '.csdr', '.euirc-csdr-remotes.json'));
25
23
  const remoteConfig = remotesConfig[remoteName];
26
24
 
@@ -83,7 +81,14 @@ module.exports.getCsdrRemotes = (hostName, euiVersion) => {
83
81
  }
84
82
  }
85
83
 
86
- tools.logInfo(`Getting remotes for host: ${hostName} - euiVersion: ${euiVersion}`);
84
+ tools.logInfo(`Getting remotes`);
85
+
86
+ if (hostName) {
87
+ tools.logInfo(`--- for host: ${hostName}`);
88
+ }
89
+ if (euiVersion) {
90
+ tools.logInfo(`--- for euiVersion: ${euiVersion}`);
91
+ }
87
92
 
88
93
  const remotesConfig = require(path.join(process.cwd(), '.csdr', '.euirc-csdr-remotes.json'));
89
94
  const remotesArray = Object.keys(remotesConfig).map((r) => {
@@ -115,3 +120,22 @@ module.exports.getRemotes = () => {
115
120
  })
116
121
  return outputRemotes;
117
122
  }
123
+
124
+ module.exports.getRemoteByNpmPkg = (npmPkg, fromCsdrConfig) => {
125
+ let remotes;
126
+
127
+ if (fromCsdrConfig) {
128
+ remotes = this.getCsdrRemotes();
129
+
130
+ } else {
131
+ remotes = this.getRemotes();
132
+ }
133
+
134
+ return remotes.filter((r) => {
135
+ return r.npmPkg === npmPkg;
136
+ })[0];
137
+ }
138
+
139
+ module.exports.isLocalRemote = (npmPkg) => {
140
+ return this.getRemoteByNpmPkg(npmPkg) !== undefined;
141
+ }
@@ -30,7 +30,6 @@
30
30
  "./node_modules/@eui/styles/dist/styles/eui.css",
31
31
  "./node_modules/@eui/styles/dist/styles/eui-next.css",
32
32
  "./node_modules/@eui/styles/dist/styles/eui-components.css",
33
- "./node_modules/prismjs/plugins/line-numbers/prism-line-numbers.css",
34
33
  "./node_modules/@eui/styles/dist/assets/fonts/font-awesome/font-awesome.min.css",
35
34
  "./node_modules/@eui/styles/dist/assets/fonts/flag-icons/css/flag-icon.min.css"
36
35
  ]
@@ -0,0 +1,11 @@
1
+ import {
2
+ EuiBlockContentComponentModule,
3
+ EuiButtonModule,
4
+ EuiLabelModule,
5
+ } from '@eui/components-next';
6
+
7
+ export const EUI_COMPONENTS_MODULES = [
8
+ EuiBlockContentComponentModule,
9
+ EuiButtonModule,
10
+ EuiLabelModule,
11
+ ];
@@ -0,0 +1,11 @@
1
+ import { Component } from '@angular/core';
2
+
3
+ @Component({
4
+ template: `
5
+ <eui-block-content [isBlocked]="true">
6
+ <div style="height: 100%"></div>
7
+ </eui-block-content>
8
+ `,
9
+ })
10
+ export class FallbackComponent {
11
+ }
@@ -0,0 +1,91 @@
1
+ import { Component, OnInit, Inject, ElementRef, OnDestroy } from '@angular/core';
2
+
3
+ import { take } from 'rxjs/operators';
4
+
5
+ import { CONFIG_TOKEN } from '@eui/core';
6
+ import { ElementSetupService, ElementLifeCycleService } from '@csdr/integration/element';
7
+
8
+ enum ElementStatus {
9
+ Loading = 'loading',
10
+ Loaded = 'loaded',
11
+ Error = 'error',
12
+ }
13
+
14
+ @Component({
15
+ template: `
16
+ <eui-block-content *ngIf="moduleStatus === ElementStatus.Loading" [isBlocked]="true">
17
+ <div style="height: 100%"></div>
18
+ </eui-block-content>
19
+ <ng-container *ngIf="moduleStatus === ElementStatus.Loaded">
20
+ <router-outlet></router-outlet>
21
+ </ng-container>
22
+ <ng-container *ngIf="moduleStatus === ElementStatus.Error">
23
+ <div class="error-container">
24
+ <div>
25
+ <h1>Translations or user data for this module failed to load.</h1>
26
+ <p>Do you want to try again?</p>
27
+ <button euiButton euiPrimary (click)="loadData()">
28
+ <span euiLabel>{{ 'global.RELOAD' | translate }}</span>
29
+ </button>
30
+ </div>
31
+ </div>
32
+ </ng-container>
33
+ `,
34
+ styles: [`
35
+ .error-container {
36
+ width: 50vw;
37
+ height: 50vh;
38
+ position: absolute;
39
+ top: 50%;
40
+ left: 50%;
41
+ transform: translate(-50%, -50%);
42
+ }
43
+
44
+ .error-container div {
45
+ text-align: center
46
+ }
47
+ `],
48
+ })
49
+ export class ModuleComponent implements OnInit, OnDestroy {
50
+ ElementStatus = ElementStatus;
51
+ moduleStatus: ElementStatus;
52
+
53
+ constructor(private elRef: ElementRef,
54
+ @Inject(CONFIG_TOKEN) public config: any,
55
+ private elementLifeCycleService: ElementLifeCycleService,
56
+ private elementSetupService: ElementSetupService) {
57
+ }
58
+
59
+ ngOnInit() {
60
+ const elementData = this.elementLifeCycleService.getElementData(this.elRef);
61
+ this.elementLifeCycleService.setup(elementData);
62
+ this.loadData();
63
+ }
64
+
65
+ ngOnDestroy(): void {
66
+ this.elementLifeCycleService.cleanup();
67
+ }
68
+
69
+ private loadData() {
70
+ this.setStatus(ElementStatus.Loading);
71
+ try {
72
+ this.elementSetupService.init()
73
+ .pipe(take(1))
74
+ .subscribe((loadStatus: { success: boolean; error?: string }) => {
75
+ if (!loadStatus.success) {
76
+ this.setStatus(ElementStatus.Error);
77
+ console.error(`[ELEMENT: ${this.config.global.elementName}] `, loadStatus.error);
78
+ } else {
79
+ this.setStatus(ElementStatus.Loaded);
80
+ }
81
+ });
82
+ } catch (e) {
83
+ console.log(e);
84
+ this.setStatus(ElementStatus.Error);
85
+ }
86
+ }
87
+
88
+ private setStatus(status: ElementStatus) {
89
+ this.moduleStatus = status;
90
+ }
91
+ }
@@ -0,0 +1,96 @@
1
+ import { NgModule, Injector, DoBootstrap, ApplicationRef } from '@angular/core';
2
+ import { BrowserModule } from '@angular/platform-browser';
3
+ import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
4
+ import { HttpClient, HttpClientModule, HttpHeaders } from '@angular/common/http';
5
+ import { createCustomElement } from '@angular/elements';
6
+
7
+ import { StoreModule, USER_PROVIDED_META_REDUCERS } from '@ngrx/store';
8
+ import { EffectsModule } from '@ngrx/effects';
9
+ import { StoreRouterConnectingModule } from '@ngrx/router-store';
10
+ import { StoreDevtoolsModule } from '@ngrx/store-devtools';
11
+
12
+ import { TranslateModule } from '@ngx-translate/core';
13
+
14
+ import {
15
+ CoreModule,
16
+ CONFIG_TOKEN,
17
+ EUI_CONFIG_TOKEN,
18
+ translateConfig,
19
+ } from '@eui/core';
20
+ import { EUI_COMPONENTS_MODULES } from './eui-components';
21
+ import {
22
+ CsdrCoreModule,
23
+ ElementStorageService,
24
+ } from '@csdr/core';
25
+
26
+ import { TOKEN, reducerProvider, metaReducers } from './reducers/index';
27
+ import { CustomSerializer } from './reducers/custom-route-serializer';
28
+
29
+ import { environment } from '../environments/environment';
30
+ import { appConfig } from '../config';
31
+
32
+ import { @root.common.module@ as RootCommonModule } from '@root.npm.pkg@';
33
+ import {
34
+ DEFAULT_MAPPED_PROVIDERS,
35
+ } from '@csdr/integration/element';
36
+ import { RoutingModule } from './routing.module';
37
+
38
+ import { FallbackComponent } from './fallback.component';
39
+ import { ModuleComponent } from './module.component';
40
+
41
+ // IMPORTS
42
+
43
+ // DECLARATIONS
44
+
45
+ @NgModule({
46
+ imports: [
47
+ BrowserModule,
48
+ BrowserAnimationsModule,
49
+ HttpClientModule,
50
+ EffectsModule.forRoot([]),
51
+ StoreDevtoolsModule.instrument({ name: appConfig.global.storeName, maxAge: 150, logOnly: environment.production }),
52
+ TranslateModule.forRoot(translateConfig),
53
+
54
+ CoreModule.forRoot(),
55
+ CsdrCoreModule.forRoot(),
56
+ RootCommonModule,
57
+ RoutingModule,
58
+ ...EUI_COMPONENTS_MODULES,
59
+
60
+ // DEFINITIONS
61
+ ],
62
+ declarations: [
63
+ FallbackComponent,
64
+ ModuleComponent,
65
+ ],
66
+ entryComponents: [
67
+ FallbackComponent,
68
+ ModuleComponent,
69
+ ],
70
+ providers: [
71
+ reducerProvider,
72
+ {
73
+ provide: EUI_CONFIG_TOKEN,
74
+ useValue: { appConfig: { ...appConfig, ...environment }, environment },
75
+ },
76
+
77
+ ...DEFAULT_MAPPED_PROVIDERS,
78
+
79
+ // PROVIDERS
80
+ ],
81
+ })
82
+ export class AppModule implements DoBootstrap {
83
+
84
+ constructor(private injector: Injector, private http: HttpClient) {
85
+ // CONSTRUCTOR DECLARATIONS
86
+ }
87
+
88
+ ngDoBootstrap(appRef: ApplicationRef): void {
89
+ const elementSampleEui = createCustomElement(ModuleComponent, { injector: this.injector });
90
+ try {
91
+ customElements.define(appConfig.global.elementName, elementSampleEui);
92
+ } catch (e) {
93
+ console.log(e);
94
+ }
95
+ }
96
+ }
@@ -0,0 +1,28 @@
1
+ import { Params, RouterStateSnapshot } from '@angular/router';
2
+ import { RouterStateSerializer } from '@ngrx/router-store';
3
+
4
+ export interface RouterStateUrl {
5
+ url: string;
6
+ params: Params;
7
+ queryParams: Params;
8
+ }
9
+
10
+ export class CustomSerializer implements RouterStateSerializer<RouterStateUrl> {
11
+ serialize(routerState: RouterStateSnapshot): RouterStateUrl {
12
+ let route = routerState.root;
13
+
14
+ while (route.firstChild) {
15
+ route = route.firstChild;
16
+ }
17
+
18
+ const {
19
+ url,
20
+ root: { queryParams },
21
+ } = routerState;
22
+ const { params } = route;
23
+
24
+ // Only return an object including the URL, params and query params
25
+ // instead of the entire snapshot
26
+ return { url, params, queryParams };
27
+ }
28
+ }
@@ -0,0 +1,42 @@
1
+ import { InjectionToken } from '@angular/core';
2
+ import { ActionReducer, ActionReducerMap, MetaReducer } from '@ngrx/store';
3
+ import * as fromRouter from '@ngrx/router-store';
4
+ import { storeFreeze } from 'ngrx-store-freeze';
5
+ import { reducers as coreReducers, CoreState, localStorageSync } from '@eui/core';
6
+
7
+ import { environment } from '../../environments/environment';
8
+
9
+ export interface AppState extends CoreState {
10
+ router: fromRouter.RouterReducerState<any>;
11
+ }
12
+
13
+ // -----------------
14
+ // ------------ AOT
15
+ export const TOKEN = new InjectionToken<any>('AppReducers');
16
+
17
+ export function getReducers(): ActionReducerMap<AppState, any> {
18
+ return {
19
+ router: fromRouter.routerReducer,
20
+ ...coreReducers,
21
+ };
22
+ }
23
+
24
+ export const reducerProvider = [
25
+ { provide: TOKEN, useFactory: getReducers },
26
+ ];
27
+
28
+ // console.log all actions
29
+ export function logger(reducer: ActionReducer<AppState>): ActionReducer<AppState> {
30
+ return (state, action) => {
31
+ const result = reducer(state, action);
32
+ console.groupCollapsed(action.type);
33
+ console.log('prev state', state);
34
+ console.log('action', action);
35
+ console.log('next state', result);
36
+ console.groupEnd();
37
+
38
+ return result;
39
+ };
40
+ }
41
+
42
+ export const metaReducers: MetaReducer<AppState>[] = !environment.production ? [logger, localStorageSync, storeFreeze] : [localStorageSync];
@@ -0,0 +1,34 @@
1
+ import { NgModule } from '@angular/core';
2
+ import { RouterModule, Routes } from '@angular/router';
3
+
4
+ import { ELEMENT_ROUTES_TOKEN } from '@csdr/integration/element';
5
+
6
+ import { routes } from '@root.npm.pkg@';
7
+ // DON'T PAY ATTENTION TO IMPORT ERRORS HERE, those files are injected at serve/build time
8
+ import { appConfig } from '../config/index';
9
+ import { FallbackComponent } from './fallback.component';
10
+ import { ModuleComponent } from './module.component';
11
+
12
+ const elementRoutes: Routes = [
13
+ { path: '', component: ModuleComponent },
14
+ {
15
+ path: appConfig.global.baseUrl,
16
+ children: routes,
17
+ },
18
+ { path: '**', component: FallbackComponent },
19
+ ];
20
+
21
+ // @dynamic
22
+ @NgModule({
23
+ imports: [
24
+ RouterModule.forRoot(elementRoutes),
25
+ ],
26
+ providers: [
27
+ { provide: ELEMENT_ROUTES_TOKEN, useValue: elementRoutes },
28
+ ],
29
+ exports: [
30
+ RouterModule,
31
+ ],
32
+ })
33
+ export class RoutingModule {
34
+ }
@@ -0,0 +1,55 @@
1
+ import { registerLocaleData } from '@angular/common';
2
+
3
+ import localeEn from '@angular/common/locales/en';
4
+ import localeEnExtra from '@angular/common/locales/extra/en';
5
+ import localeFr from '@angular/common/locales/fr';
6
+ import localeFrExtra from '@angular/common/locales/extra/fr';
7
+
8
+ import { GlobalConfig, I18nConfig, LocaleServiceConfig } from '@eui/core';
9
+
10
+ /**
11
+ * import and register locales (currently MWP uses only French and English)
12
+ */
13
+ registerLocaleData(localeEn, 'en', localeEnExtra);
14
+ registerLocaleData(localeFr, 'fr', localeFrExtra);
15
+
16
+ /**
17
+ * Internationalization Configuration
18
+ */
19
+ const i18nConfig: I18nConfig = {
20
+ i18nLoader: {
21
+ i18nFolders: ['elements/@remote.name@/bundles/assets/i18n-compiled'],
22
+ i18nResources: [{
23
+ prefix: 'assets/i18n-eui/',
24
+ suffix: '.json',
25
+ }],
26
+ },
27
+ i18nService: {
28
+ languages: ['en', 'fr'],
29
+ defaultLanguage: 'en',
30
+ },
31
+ };
32
+
33
+ /**
34
+ * Locale Configuration
35
+ */
36
+ const localeConfig: LocaleServiceConfig = {
37
+ id: 'en',
38
+ available: ['en', 'fr'],
39
+ bindWithTranslate: true,
40
+ affectGlobalLocale: true,
41
+ };
42
+
43
+ /**
44
+ * Global Configuration
45
+ */
46
+ export const GLOBAL: GlobalConfig = {
47
+ /* URL that needs to be used in the appRouting of the MWP */
48
+ baseUrl: '@base.url@',
49
+ /* Element tag name that needs to be unique - make sure it doesn't collide with any other MWP element */
50
+ elementName: '@element.name@',
51
+ /* in case you are using NgRx give it a unique name (mostly for debugging) */
52
+ storeName: '@store.name@',
53
+ i18n: i18nConfig,
54
+ locale: localeConfig,
55
+ };
@@ -0,0 +1,20 @@
1
+ import { GLOBAL } from './global';
2
+ import { MODULES } from './modules';
3
+ import { EuiAppConfig, LogLevel, ConsoleAppender, LogConfig } from '@eui/core';
4
+
5
+ /**
6
+ * Log Configuration
7
+ */
8
+ const logConfig: LogConfig = {
9
+ logLevel: LogLevel.ALL,
10
+ logAppenders: [{
11
+ type: ConsoleAppender,
12
+ prefixFormat: '[{level}]',
13
+ }],
14
+ };
15
+
16
+ export const appConfig: EuiAppConfig = {
17
+ global: GLOBAL,
18
+ modules: MODULES,
19
+ log: logConfig,
20
+ };
@@ -0,0 +1,3 @@
1
+ import { ModulesConfig } from '@eui/core';
2
+
3
+ export const MODULES: ModulesConfig = {};
@@ -0,0 +1,3 @@
1
+ export const environment = {
2
+ production: true,
3
+ };
@@ -0,0 +1,3 @@
1
+ export const environment = {
2
+ production: false,
3
+ };
@@ -0,0 +1,10 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <base href="/">
6
+ </head>
7
+ <body>
8
+ dummy index.html
9
+ </body>
10
+ </html>
@@ -0,0 +1,11 @@
1
+ import { enableProdMode } from '@angular/core';
2
+ import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
3
+ import { AppModule } from './app/module';
4
+ import { environment } from './environments/environment';
5
+ if (environment.production) {
6
+ enableProdMode();
7
+ }
8
+
9
+ platformBrowserDynamic()
10
+ .bootstrapModule(AppModule)
11
+ .catch(err => console.log(err));
@@ -0,0 +1,87 @@
1
+ /* eslint-disable */
2
+ /**
3
+ * This file includes polyfills needed by Angular and is loaded before the app.
4
+ * You can add your own extra polyfills to this file.
5
+ *
6
+ * This file is divided into 2 sections:
7
+ * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
8
+ * 2. Application imports. Files imported after ZoneJS that should be loaded before your main
9
+ * file.
10
+ *
11
+ * The current setup is for so-called "evergreen" browsers; the last versions of browsers that
12
+ * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
13
+ * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
14
+ *
15
+ * Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html
16
+ */
17
+
18
+ /***************************************************************************************************
19
+ * BROWSER POLYFILLS
20
+ */
21
+
22
+ /** IE9, IE10 and IE11 requires all of the following polyfills. **/
23
+ // import 'core-js/es6/symbol';
24
+ // import 'core-js/es6/object';
25
+ // import 'core-js/es6/function';
26
+ // import 'core-js/es6/parse-int';
27
+ // import 'core-js/es6/parse-float';
28
+ // import 'core-js/es6/number';
29
+ // import 'core-js/es6/math';
30
+ // import 'core-js/es6/string';
31
+ // import 'core-js/es6/date';
32
+ // import 'core-js/es6/array';
33
+ // import 'core-js/es6/regexp';
34
+ // import 'core-js/es6/map';
35
+ // import 'core-js/es6/weak-map';
36
+ // import 'core-js/es6/set';
37
+
38
+ /** IE10 and IE11 requires the following for NgClass support on SVG elements */
39
+ // import 'classlist.js'; // Run `npm install --save classlist.js`.
40
+
41
+ /** IE10 and IE11 requires the following for the Reflect API. */
42
+ // import 'core-js/es6/reflect';
43
+
44
+ /** Evergreen browsers require these. **/
45
+ // Used for reflect-metadata in JIT. If you use AOT (and only Angular decorators), you can remove.
46
+ // import 'core-js/es7/reflect';
47
+
48
+ /**
49
+ * Web Animations `@angular/platform-browser/animations`
50
+ * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
51
+ * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
52
+ **/
53
+ // import 'web-animations-js'; // Run `npm install --save web-animations-js`.
54
+
55
+ /**
56
+ * By default, zone.js will patch all possible macroTask and DomEvents
57
+ * user can disable parts of macroTask/DomEvents patch by setting following flags
58
+ */
59
+
60
+ // (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
61
+ // (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
62
+ // (window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
63
+
64
+ /*
65
+ * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
66
+ * with the following flag, it will bypass `zone.js` patch for IE/Edge
67
+ */
68
+ // (window as any).__Zone_enable_cross_context_check = true;
69
+
70
+ /***************************************************************************************************
71
+ * Zone JS is required by default for Angular itself.
72
+ */
73
+ import 'zone.js/dist/zone'; // Included with Angular CLI.
74
+
75
+ /***************************************************************************************************
76
+ * APPLICATION IMPORTS
77
+ */
78
+
79
+ /**
80
+ * Date, currency, decimal and percent pipes.
81
+ * Needed for: All but Chrome, Firefox, Edge, IE11 and Safari 10
82
+ */
83
+ // import 'intl'; // Run `npm install --save intl`.
84
+ /**
85
+ * Need to import at least one locale-data with intl.
86
+ */
87
+ // import 'intl/locale-data/jsonp/en';
@@ -0,0 +1,20 @@
1
+ // This file is required by karma.conf.js and loads recursively all the .spec and framework files
2
+
3
+ import 'zone.js/dist/zone-testing';
4
+ import { getTestBed } from '@angular/core/testing';
5
+ import {
6
+ BrowserDynamicTestingModule,
7
+ platformBrowserDynamicTesting,
8
+ } from '@angular/platform-browser-dynamic/testing';
9
+
10
+ declare const require: any;
11
+
12
+ // First, initialize the Angular testing environment.
13
+ getTestBed().initTestEnvironment(
14
+ BrowserDynamicTestingModule,
15
+ platformBrowserDynamicTesting(),
16
+ );
17
+ // Then we find all the tests.
18
+ const context = require.context('./', true, /\.spec\.ts$/);
19
+ // And load the modules.
20
+ context.keys().map(context);
@@ -0,0 +1,4 @@
1
+ {
2
+ "declarations": "declare const window: { dT_: { initAngularNg?: any } | undefined };",
3
+ "constructorDeclarations": "if (window?.dT_?.initAngularNg) { window.dT_.initAngularNg(http, HttpHeaders); }"
4
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "providers": "...CONTAINER_MAPPED_PROVIDERS"
3
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "providers": "{ provide: USER_PROVIDED_META_REDUCERS, deps: [CONFIG_TOKEN, ElementStorageService], useFactory: metaReducers }"
3
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "imports": "import { getZipkinConfig, TRACE_MODULE_CONFIGURATION, ZipkinModule } from '@csdr/zipkin-tracing';",
3
+ "definitions": "ZipkinModule.forRoot()",
4
+ "providers": "{ provide: TRACE_MODULE_CONFIGURATION, useFactory: getZipkinConfig, deps: [CONFIG_TOKEN] }"
5
+ }
@@ -0,0 +1,94 @@
1
+ import { Component, OnInit, Inject, ElementRef, OnDestroy } from '@angular/core';
2
+
3
+ import { take } from 'rxjs/operators';
4
+
5
+ import { CONFIG_TOKEN } from '@eui/core';
6
+ import { ElementSetupService, ElementLifeCycleService } from '@csdr/integration/element';
7
+
8
+ enum ElementStatus {
9
+ Loading = 'loading',
10
+ Loaded = 'loaded',
11
+ Error = 'error',
12
+ }
13
+
14
+ @Component({
15
+ template: `
16
+ <eui-block-content *ngIf="moduleStatus === ElementStatus.Loading" [isBlocked]="true">
17
+ <div style="height: 100%"></div>
18
+ </eui-block-content>
19
+ <ng-container *ngIf="moduleStatus === ElementStatus.Loaded">
20
+ <@block.container.name@ [block]="block"></@block.container.name@>
21
+ </ng-container>
22
+ <ng-container *ngIf="moduleStatus === ElementStatus.Error">
23
+ <div class="error-container">
24
+ <div>
25
+ <h1>Translations or user data for this module failed to load.</h1>
26
+ <p>Do you want to try again?</p>
27
+ <button euiButton euiPrimary (click)="loadData()">
28
+ <span euiLabel>{{ "global.RELOAD" | translate }}</span>
29
+ </button>
30
+ </div>
31
+ </div>
32
+ </ng-container>
33
+ `,
34
+ styles: [`
35
+ .error-container {
36
+ width: 50vw;
37
+ height: 50vh;
38
+ position: absolute;
39
+ top: 50%;
40
+ left: 50%;
41
+ transform: translate(-50%, -50%);
42
+ }
43
+
44
+ .error-container div {
45
+ text-align: center
46
+ }
47
+ `],
48
+ })
49
+ export class ModuleComponent implements OnInit, OnDestroy {
50
+ ElementStatus = ElementStatus;
51
+ moduleStatus: ElementStatus;
52
+
53
+ block: any;
54
+
55
+ constructor(private elRef: ElementRef,
56
+ @Inject(CONFIG_TOKEN) public config: any,
57
+ private elementLifeCycleService: ElementLifeCycleService,
58
+ private elementSetupService: ElementSetupService) {
59
+ }
60
+
61
+ ngOnInit() {
62
+ this.block = this.elRef.nativeElement.block;
63
+ const elementData = this.elementLifeCycleService.getElementData(this.elRef);
64
+ this.elementLifeCycleService.setup(elementData);
65
+ this.loadData();
66
+ }
67
+
68
+ ngOnDestroy(): void {
69
+ this.elementLifeCycleService.cleanup();
70
+ }
71
+
72
+ private loadData() {
73
+ this.setStatus(ElementStatus.Loading);
74
+ try {
75
+ this.elementSetupService.init()
76
+ .pipe(take(1))
77
+ .subscribe((loadStatus: { success: boolean, error?: string }) => {
78
+ if (!loadStatus.success) {
79
+ this.setStatus(ElementStatus.Error);
80
+ console.error(`[ELEMENT: ${this.config.global.elementName}] `, loadStatus.error);
81
+ } else {
82
+ this.setStatus(ElementStatus.Loaded);
83
+ }
84
+ });
85
+ } catch (e) {
86
+ console.log(e);
87
+ this.setStatus(ElementStatus.Error);
88
+ }
89
+ }
90
+
91
+ private setStatus(status: ElementStatus) {
92
+ this.moduleStatus = status;
93
+ }
94
+ }
@@ -0,0 +1,26 @@
1
+ import { NgModule } from '@angular/core';
2
+ import { RouterModule, Routes } from '@angular/router';
3
+
4
+ import { ELEMENT_ROUTES_TOKEN } from '@csdr/integration/element';
5
+
6
+ import { appConfig } from '../config/index'; // tslint:disable-line
7
+ import { FallbackComponent } from './fallback.component'; // tslint:disable-line
8
+ import { ModuleComponent } from './module.component';
9
+
10
+ const elementRoutes: Routes = [
11
+ { path: '**', component: ModuleComponent },
12
+ ];
13
+
14
+ @NgModule({
15
+ imports: [
16
+ RouterModule.forRoot(elementRoutes),
17
+ ],
18
+ providers: [
19
+ { provide: ELEMENT_ROUTES_TOKEN, useValue: elementRoutes },
20
+ ],
21
+ exports: [
22
+ RouterModule,
23
+ ],
24
+ })
25
+ export class RoutingModule {
26
+ }
@@ -0,0 +1,10 @@
1
+ import { GLOBAL } from './global';
2
+ import { MODULES } from './modules';
3
+
4
+ import { EuiAppConfig } from '@eui/core';
5
+ import { configMapping } from '@csdr/integration/element';
6
+
7
+ export const appConfig: EuiAppConfig = configMapping({
8
+ global: GLOBAL,
9
+ modules: MODULES,
10
+ });
@@ -0,0 +1,66 @@
1
+ import { InjectionToken } from '@angular/core';
2
+ import { ActionReducer, ActionReducerMap, MetaReducer, INIT } from '@ngrx/store';
3
+ import * as fromRouter from '@ngrx/router-store';
4
+ import { storeFreeze } from 'ngrx-store-freeze';
5
+
6
+ import { reducers as coreReducers, CoreState, localStorageSync } from '@eui/core';
7
+ import { ElementStorageService } from '@csdr/core';
8
+
9
+ import { environment } from '../../environments/environment';
10
+
11
+ export interface AppState extends CoreState {
12
+ router: fromRouter.RouterReducerState<any>;
13
+ }
14
+
15
+ // -----------------
16
+ // ------------ AOT
17
+ export const TOKEN = new InjectionToken<any>('AppReducers');
18
+
19
+ export function getReducers(): ActionReducerMap<AppState, any> {
20
+ return {
21
+ router: fromRouter.routerReducer,
22
+ ...coreReducers,
23
+ };
24
+ }
25
+
26
+ export const reducerProvider = [
27
+ { provide: TOKEN, useFactory: getReducers },
28
+ ];
29
+
30
+ // console.log all actions
31
+ export function logger(reducer: ActionReducer<AppState>): ActionReducer<AppState> {
32
+ return (state, action) => {
33
+ const result = reducer(state, action);
34
+ console.groupCollapsed(action.type);
35
+ console.log('prev state', state);
36
+ console.log('action', action);
37
+ console.log('next state', result);
38
+ console.groupEnd();
39
+
40
+ return result;
41
+ };
42
+ }
43
+
44
+ export function hydrationFactory(config: any, elementStorage: ElementStorageService): MetaReducer<AppState> {
45
+ return (reducer: ActionReducer<AppState>): ActionReducer<any> => {
46
+ return (state, action) => {
47
+ const key = `NgRx store: ${config.global.elementName}`;
48
+ if (action.type === INIT && elementStorage.hasData(key)) {
49
+ const cachedState = elementStorage.getData(key);
50
+ const nextStateFromCache = reducer(cachedState as AppState, action);
51
+ elementStorage.setData(key, nextStateFromCache);
52
+ return nextStateFromCache;
53
+ }
54
+ const nextState = reducer(state, action);
55
+ elementStorage.setData(key, nextState);
56
+ return nextState;
57
+ };
58
+ };
59
+ }
60
+
61
+ export function metaReducers(config: any, elementStorage: ElementStorageService): MetaReducer<AppState>[] {
62
+ if (!environment.production) {
63
+ return [logger, localStorageSync, storeFreeze, hydrationFactory(config, elementStorage)];
64
+ }
65
+ return [localStorageSync, hydrationFactory(config, elementStorage)];
66
+ }
@@ -243,15 +243,15 @@ module.exports.importLocalProjectRemotes = (prj, remoteDeps) => {
243
243
  tools.logInfo(`Initializing ${remoteDeps.length} remotes`);
244
244
 
245
245
  remoteDeps.forEach((remoteNpmPkg) => {
246
- tools.logInfo(`Checking import for : ${remoteNpmPkg}`);
246
+ tools.logInfo(`\nChecking import for : ${remoteNpmPkg}`);
247
247
 
248
248
  // check if package has been installed locally
249
- if (configUtils.packages.isLocalPackage(remoteNpmPkg)) {
249
+ if (configUtils.remotes.isLocalRemote(remoteNpmPkg)) {
250
250
  tools.logInfo('remote is installed locally...skipping import');
251
251
 
252
252
  } else {
253
- const pkg = configUtils.packages.getPackageByNpmPkg(remoteNpmPkg, true);
254
- const projectElementsPath = path.join(process.cwd(), prj.folder, 'src', 'assets', 'elements', pkg.name, 'bundles');
253
+ const remote = configUtils.remotes.getRemoteByNpmPkg(remoteNpmPkg, true);
254
+ const projectElementsPath = path.join(process.cwd(), prj.folder, 'src', 'assets', 'elements', remote.name, 'bundles');
255
255
 
256
256
  const npmPkgScope = remoteNpmPkg.substr(0, remoteNpmPkg.indexOf('/'));
257
257
  const npmPkgName = remoteNpmPkg.substr(remoteNpmPkg.indexOf('/') + 1);
@@ -92,11 +92,13 @@ module.exports.build = (pkg, isMaster) => {
92
92
 
93
93
 
94
94
  module.exports.postBuild = (pkg, version) => {
95
- tools.logInfo('Executing element post-build...');
95
+ tools.logTitle('Executing element post-build...');
96
96
 
97
97
  const remoteEuiVersion = configUtils.packages.getPackageEuiVersion(pkg);
98
98
  const euiVersionNumber = remoteEuiVersion.split('.')[0];
99
99
 
100
+ tools.logInfo(`remote: ${pkg.name} - eUI version : ${remoteEuiVersion}`);
101
+
100
102
  if (dryRun) {
101
103
  tools.logInfo('DRY-RUN...skipping');
102
104
  return;
@@ -127,6 +129,10 @@ module.exports.postBuild = (pkg, version) => {
127
129
  return remotesUtils.emptyIndexHtml(path.join(pkg.paths.dist, 'bundles'));
128
130
  })
129
131
 
132
+ .then(() => {
133
+ return remotesUtils.cleanupUnusedAssets(path.join(pkg.paths.dist, 'bundles', 'assets'), euiVersionNumber);
134
+ })
135
+
130
136
  .catch((e) => {
131
137
  throw e;
132
138
  })
@@ -78,3 +78,38 @@ module.exports.emptyIndexHtml = (destPath) => {
78
78
  throw e;
79
79
  })
80
80
  }
81
+
82
+
83
+ module.exports.cleanupUnusedAssets = (assetsPath, euiVersionNumber = 10) => {
84
+ tools.logInfo(`Cleanup unused assets for version : ${euiVersionNumber} in ${assetsPath}`);
85
+
86
+ if (euiVersionNumber > 10) {
87
+
88
+ return Promise.resolve()
89
+ .then(() => {
90
+ return tools.rimraf(path.join(assetsPath, 'ecl'));
91
+ })
92
+ .then(() => {
93
+ return tools.rimraf(path.join(assetsPath, 'icons', 'ionicons'));
94
+ })
95
+ .then(() => {
96
+ return tools.rimraf(path.join(assetsPath, 'icons', 'svg'));
97
+ })
98
+ .then(() => {
99
+ return tools.rimraf(path.join(assetsPath, 'icons', 'svg-src'));
100
+ })
101
+ .then(() => {
102
+ return tools.rimraf(path.join(assetsPath, 'icons', 'flags'));
103
+ })
104
+ .then(() => {
105
+ return tools.rimraf(path.join(assetsPath, 'fonts'));
106
+ })
107
+ .then(() => {
108
+ return tools.rimraf(path.join(assetsPath, 'i18n-eui'));
109
+ })
110
+
111
+ .catch((e) => {
112
+ throw e;
113
+ })
114
+ }
115
+ }
@@ -181,6 +181,7 @@ function rmdir(path) {
181
181
  }
182
182
 
183
183
  function rimraf(inputPath) {
184
+ this.logInfo(`Removing ${inputPath}...`);
184
185
  let exec = path.resolve(process.cwd(), 'node_modules', 'rimraf', 'bin.js');
185
186
  if (!isFileExists(exec)) {
186
187
  // special location when used within eUI CLI