@eui/tools 6.3.22 → 6.3.23

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 (37) hide show
  1. package/.version.properties +1 -1
  2. package/CHANGELOG.md +9 -0
  3. package/package.json +1 -1
  4. package/scripts/csdr/audit/styles.js +28 -9
  5. package/scripts/csdr/config/register.js +0 -6
  6. package/scripts/csdr/init/init.js +0 -1
  7. package/scripts/csdr/init/packages.js +18 -7
  8. package/scripts/csdr/init/remotes/15.x/full/{src → common}/app/eui-components.ts +0 -0
  9. package/scripts/csdr/init/remotes/15.x/full/{src → common}/app/fallback.component.ts +0 -0
  10. package/scripts/csdr/init/remotes/15.x/full/{src → common}/app/module.component.ts +0 -0
  11. package/scripts/csdr/init/remotes/15.x/full/{src → common}/app/module.ts +21 -16
  12. package/scripts/csdr/init/remotes/15.x/full/{src → common}/app/reducers/custom-route-serializer.ts +0 -0
  13. package/scripts/csdr/init/remotes/15.x/full/common/app/reducers/index.ts +42 -0
  14. package/scripts/csdr/init/remotes/15.x/full/{src → common}/app/routing.module.ts +0 -0
  15. package/scripts/csdr/init/remotes/15.x/full/{src → common}/assets/.gitkeep +0 -0
  16. package/scripts/csdr/init/remotes/15.x/full/{src → common}/config/global.ts +3 -0
  17. package/scripts/csdr/init/remotes/15.x/full/{src → common}/config/index.ts +0 -0
  18. package/scripts/csdr/init/remotes/15.x/full/{src → common}/config/modules.ts +0 -0
  19. package/scripts/csdr/init/remotes/15.x/full/{src → common}/environments/environment.prod.ts +0 -0
  20. package/scripts/csdr/init/remotes/15.x/full/{src → common}/environments/environment.ts +0 -0
  21. package/scripts/csdr/init/remotes/15.x/full/{src → common}/favicon.ico +0 -0
  22. package/scripts/csdr/init/remotes/15.x/full/{src → common}/index.html +0 -0
  23. package/scripts/csdr/init/remotes/15.x/full/{src → common}/main.ts +0 -0
  24. package/scripts/csdr/init/remotes/15.x/full/{src → common}/polyfills.ts +0 -0
  25. package/scripts/csdr/init/remotes/15.x/full/{src → common}/test.ts +0 -0
  26. package/scripts/csdr/init/remotes/15.x/full/options/definitions/dynatrace.json +4 -0
  27. package/scripts/csdr/init/remotes/15.x/full/options/definitions/participant.json +3 -0
  28. package/scripts/csdr/init/remotes/15.x/full/options/definitions/user-reducers.json +3 -0
  29. package/scripts/csdr/init/remotes/15.x/full/options/definitions/zipkin.json +5 -0
  30. package/scripts/csdr/init/remotes/15.x/full/options/participant/app/module.component.ts +94 -0
  31. package/scripts/csdr/init/remotes/15.x/full/options/participant/app/routing.module.ts +26 -0
  32. package/scripts/csdr/init/remotes/15.x/full/options/participant/config/index.ts +10 -0
  33. package/scripts/csdr/init/remotes/15.x/full/{src → options/user-reducers}/app/reducers/index.ts +1 -1
  34. package/scripts/csdr/init/remotes.js +87 -21
  35. package/scripts/utils/build/package/element.js +45 -131
  36. package/scripts/utils/tools.js +14 -0
  37. package/scripts/csdr/init/remotes/15.x/full/src/app/dummy.spec.ts +0 -6
@@ -1 +1 @@
1
- 6.3.22
1
+ 6.3.23
package/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## 6.3.23 (2023-02-08)
2
+
3
+ ##### Chores
4
+
5
+ * **other:**
6
+ * updated full v15 remote generation for remote participant - MWP-9204 [MWP-9204](https://webgate.ec.europa.eu/CITnet/jira/browse/MWP-9204) ([310e9816](https://webgate.ec.europa.eu/CITnet/stash/scm/csdr/eui-tools.git/commits/310e981676ef479d3dda5b47b39a4dee92e9cde5))
7
+
8
+ * * *
9
+ * * *
1
10
  ## 6.3.22 (2023-02-08)
2
11
 
3
12
  ##### Chores
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eui/tools",
3
- "version": "6.3.22",
3
+ "version": "6.3.23",
4
4
  "tag": "latest",
5
5
  "license": "EUPL-1.1",
6
6
  "description": "eUI common tools and scripts",
@@ -9,7 +9,7 @@ const tools = require('../../utils/tools');
9
9
  const notificationUtils = require('../../utils/notification/notification-utils');
10
10
 
11
11
 
12
- const runStylesAudit = module.exports.runStylesAudit = (pkg) => {
12
+ const runStylesAudit = module.exports.runStylesAudit = (pkg, customPath) => {
13
13
 
14
14
  const generateIndicesContent = (indices, file, fileContent) => {
15
15
  let content = [];
@@ -43,7 +43,22 @@ const runStylesAudit = module.exports.runStylesAudit = (pkg) => {
43
43
 
44
44
 
45
45
 
46
- tools.logTitle(`Auditing : ${pkg.name}`);
46
+
47
+
48
+ // checking params
49
+
50
+ let srcPath;
51
+
52
+ if (customPath) {
53
+ srcPath = customPath;
54
+ tools.logTitle(`Auditing : ${customPath}`);
55
+ } else {
56
+ srcPath = pkg.paths.src;
57
+ tools.logTitle(`Auditing : ${pkg.name}`);
58
+ }
59
+
60
+
61
+ // setting default report object
47
62
 
48
63
  const report = {
49
64
  package: null,
@@ -107,14 +122,18 @@ const runStylesAudit = module.exports.runStylesAudit = (pkg) => {
107
122
  };
108
123
 
109
124
 
110
- report.package = pkg.name;
125
+ if (customPath) {
126
+ report.package = customPath;
127
+ } else {
128
+ report.package = pkg.name;
129
+ }
111
130
 
112
- let files = glob.sync('**/*.scss', { cwd: pkg.paths.src, nodir: true, follow: true, dot: true });
131
+ let files = glob.sync('**/*.scss', { cwd: srcPath, nodir: true, follow: true, dot: true });
113
132
 
114
133
  report.scssFilesCount += files.length;
115
134
 
116
135
  files.forEach(file => {
117
- const filePath = path.join(pkg.paths.src, file);
136
+ const filePath = path.join(srcPath, file);
118
137
  const fileContent = tools.getFileContent(filePath).trim();
119
138
  const linesCount = fileContent.split('\n').length;
120
139
 
@@ -184,12 +203,12 @@ const runStylesAudit = module.exports.runStylesAudit = (pkg) => {
184
203
 
185
204
 
186
205
 
187
- files = glob.sync('**/*.html', { cwd: pkg.paths.src, nodir: true, follow: true, dot: true });
206
+ files = glob.sync('**/*.html', { cwd: srcPath, nodir: true, follow: true, dot: true });
188
207
 
189
208
  report.htmlFilesCount += files.length;
190
209
 
191
210
  files.forEach(file => {
192
- const filePath = path.join(pkg.paths.src, file);
211
+ const filePath = path.join(srcPath, file);
193
212
  const fileContent = tools.getFileContent(filePath);
194
213
  const linesCount = fileContent.split('\n').length;
195
214
 
@@ -215,10 +234,10 @@ const runStylesAudit = module.exports.runStylesAudit = (pkg) => {
215
234
 
216
235
 
217
236
 
218
- files = glob.sync('**/*.ts', { cwd: pkg.paths.src, nodir: true, follow: true, dot: true });
237
+ files = glob.sync('**/*.ts', { cwd: srcPath, nodir: true, follow: true, dot: true });
219
238
 
220
239
  files.forEach(file => {
221
- const filePath = path.join(pkg.paths.src, file);
240
+ const filePath = path.join(srcPath, file);
222
241
  const fileContent = tools.getFileContent(filePath);
223
242
  const linesCount = fileContent.split('\n').length;
224
243
 
@@ -94,8 +94,6 @@ module.exports.registerCsdrPackage = (pkg, isRemote, rootPkgScope, rootPkgName,
94
94
  "build": {
95
95
  "compiledTranslations": true,
96
96
  "translationScopes": "eui,csdr,cc,mywp",
97
- "skipLint": true,
98
- "skipTest": true,
99
97
  "sonarScanner": false,
100
98
  "envTargetActive": true
101
99
  },
@@ -119,8 +117,6 @@ module.exports.registerCsdrPackage = (pkg, isRemote, rootPkgScope, rootPkgName,
119
117
  "compiledTranslations": true,
120
118
  "translationScopes": "eui,csdr,cc,mywp",
121
119
  "envTargetActive": true,
122
- "skipLint": true,
123
- "skipTest": true,
124
120
  "sonarScanner": false
125
121
  },
126
122
  "release": {
@@ -142,8 +138,6 @@ module.exports.registerCsdrPackage = (pkg, isRemote, rootPkgScope, rootPkgName,
142
138
  "compiledTranslations": true,
143
139
  "translationScopes": "eui,csdr,cc,mywp",
144
140
  "envTargetActive": true,
145
- "skipLint": true,
146
- "skipTest": true,
147
141
  "sonarScanner": false
148
142
  },
149
143
  "release": {
@@ -159,7 +159,6 @@ module.exports.init = () => {
159
159
  }
160
160
  })
161
161
 
162
-
163
162
  // Attaching app scripts to root package.json
164
163
  .then(() => {
165
164
  if (finalResponse.project) {
@@ -66,13 +66,24 @@ module.exports.importPackages = (args = {}) => {
66
66
  .then(() => {
67
67
  configUtils.angular.checkConfigFiles(args.reset);
68
68
  })
69
- .then(() => Promise.resolve().then(() => {
70
- return packages.reduce((promise, pkg) => {
71
- return promise.then(() => (
72
- importPackage(pkg, args)
73
- ));
74
- }, Promise.resolve());
75
- }))
69
+
70
+ .then(() => {
71
+ if (args.pkgOnly || args.remoteOnly) {
72
+ if (args.pkg) {
73
+ return importPackage(configUtils.packages.getPackage(args.pkg), args);
74
+ } else if (args.remote) {
75
+ return importPackage(configUtils.remotes.getRemote(args.remote), args);
76
+ }
77
+ } else {
78
+ Promise.resolve().then(() => {
79
+ return packages.reduce((promise, pkg) => {
80
+ return promise.then(() => (
81
+ importPackage(pkg, args)
82
+ ));
83
+ }, Promise.resolve());
84
+ })
85
+ }
86
+ })
76
87
 
77
88
  .then(() => {
78
89
  tools.logSuccess('OK => all packages successfully imported');
@@ -1,7 +1,7 @@
1
1
  import { NgModule, Injector, DoBootstrap, ApplicationRef } from '@angular/core';
2
2
  import { BrowserModule } from '@angular/platform-browser';
3
3
  import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
4
- import { HttpClientModule } from '@angular/common/http';
4
+ import { HttpClient, HttpClientModule, HttpHeaders } from '@angular/common/http';
5
5
  import { createCustomElement } from '@angular/elements';
6
6
 
7
7
  import { StoreModule, USER_PROVIDED_META_REDUCERS } from '@ngrx/store';
@@ -17,43 +17,50 @@ import {
17
17
  EUI_CONFIG_TOKEN,
18
18
  translateConfig,
19
19
  } from '@eui/core';
20
+ import { EUI_COMPONENTS_MODULES } from './eui-components';
20
21
  import {
21
22
  CsdrCoreModule,
22
23
  ElementStorageService,
23
24
  } from '@csdr/core';
24
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
+
25
32
  import { @root.common.module@ as RootCommonModule } from '@root.npm.pkg@';
26
33
  import {
27
34
  DEFAULT_MAPPED_PROVIDERS,
28
35
  } from '@csdr/integration/element';
36
+ import {
37
+ CONTAINER_MAPPED_PROVIDERS,
38
+ } from '@csdr/integration';
29
39
  import { RoutingModule } from './routing.module';
30
40
 
31
- import { TOKEN, reducerProvider, getMetaReducers } from './reducers/index';
32
- import { CustomSerializer } from './reducers/custom-route-serializer';
33
- import { environment } from '../environments/environment';
34
- import { appConfig } from '../config';
35
41
  import { FallbackComponent } from './fallback.component';
36
42
  import { ModuleComponent } from './module.component';
37
- import { EUI_COMPONENTS_MODULES } from './eui-components';
43
+
44
+ // IMPORTS
45
+
46
+ // DECLARATIONS
38
47
 
39
48
  @NgModule({
40
49
  imports: [
41
50
  BrowserModule,
42
51
  BrowserAnimationsModule,
43
52
  HttpClientModule,
44
- StoreRouterConnectingModule.forRoot({ stateKey: 'router', serializer: CustomSerializer }),
45
- StoreModule.forRoot(TOKEN),
46
53
  EffectsModule.forRoot([]),
47
54
  StoreDevtoolsModule.instrument({ name: appConfig.global.storeName, maxAge: 150, logOnly: environment.production }),
48
55
  TranslateModule.forRoot(translateConfig),
49
56
 
50
57
  CoreModule.forRoot(),
51
58
  CsdrCoreModule.forRoot(),
52
-
53
59
  RootCommonModule,
54
60
  RoutingModule,
55
-
56
61
  ...EUI_COMPONENTS_MODULES,
62
+
63
+ // DEFINITIONS
57
64
  ],
58
65
  declarations: [
59
66
  FallbackComponent,
@@ -65,22 +72,20 @@ import { EUI_COMPONENTS_MODULES } from './eui-components';
65
72
  ],
66
73
  providers: [
67
74
  reducerProvider,
68
- {
69
- provide: USER_PROVIDED_META_REDUCERS,
70
- deps: [CONFIG_TOKEN, ElementStorageService],
71
- useFactory: getMetaReducers,
72
- },
73
75
  {
74
76
  provide: EUI_CONFIG_TOKEN,
75
77
  useValue: { appConfig: { ...appConfig, ...environment }, environment },
76
78
  },
77
79
 
78
80
  ...DEFAULT_MAPPED_PROVIDERS,
81
+
82
+ // PROVIDERS
79
83
  ],
80
84
  })
81
85
  export class AppModule implements DoBootstrap {
82
86
 
83
- constructor(private injector: Injector) {
87
+ constructor(private injector: Injector, private http: HttpClient) {
88
+ // CONSTRUCTOR DECLARATIONS
84
89
  }
85
90
 
86
91
  ngDoBootstrap(appRef: ApplicationRef): void {
@@ -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];
@@ -52,4 +52,7 @@ export const GLOBAL: GlobalConfig = {
52
52
  storeName: '@store.name@',
53
53
  i18n: i18nConfig,
54
54
  locale: localeConfig,
55
+ eui: {
56
+ assetsBaseUrl: 'assets/elements/@remote.name@/bundles/assets',
57
+ },
55
58
  };
@@ -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
+ });
@@ -58,7 +58,7 @@ export function hydrationFactory(config: any, elementStorage: ElementStorageServ
58
58
  };
59
59
  }
60
60
 
61
- export function getMetaReducers(config: any, elementStorage: ElementStorageService): MetaReducer<AppState>[] {
61
+ export function metaReducers(config: any, elementStorage: ElementStorageService): MetaReducer<AppState>[] {
62
62
  if (!environment.production) {
63
63
  return [logger, localStorageSync, storeFreeze, hydrationFactory(config, elementStorage)];
64
64
  }
@@ -39,6 +39,22 @@ const cloneRemotesConfig = module.exports.cloneRemotesConfig = () => {
39
39
  module.exports.generateVirtualRemote = (remoteName, cloneRemote = true) => {
40
40
  tools.logTitle('Generating virtual remote');
41
41
 
42
+ // getting the remote config
43
+ const remote = configUtils.remotes.getRemote(remoteName);
44
+
45
+ if (!remote) {
46
+ throw new Error(`Remote ${remoteName} can't be found in the remotes CSDR configuration OR the remotes configs of the project`);
47
+ }
48
+
49
+ tools.logInfo('Remote config found: ')
50
+ console.log(remote);
51
+
52
+ const remotePath = path.join(process.cwd(), 'remotes', remote.name);
53
+ const remoteSrcPath = path.join(remotePath, 'src');
54
+ const remoteSkeletonRootPath = path.join(__dirname, 'remotes', remote.euiVersion);
55
+ const remoteSkeletonPath = path.join(remoteSkeletonRootPath, 'base');
56
+
57
+
42
58
  return Promise.resolve()
43
59
 
44
60
  // clone remotes config if first init
@@ -49,24 +65,12 @@ module.exports.generateVirtualRemote = (remoteName, cloneRemote = true) => {
49
65
  })
50
66
 
51
67
  .then(() => {
52
- // getting the remote config
53
- const remote = configUtils.remotes.getRemote(remoteName);
54
-
55
- if (!remote) {
56
- throw new Error(`Remote ${remoteName} can't be found in the remotes CSDR configuration OR the remotes configs of the project`);
57
- }
58
-
59
- tools.logInfo('Remote config found: ')
60
- console.log(remote);
61
-
62
- // constructing the remote folder
63
- const remotePath = path.join(process.cwd(), 'remotes', remote.name);
64
- const remoteSkeletonRootPath = path.join(__dirname, 'remotes', remote.euiVersion);
65
- const remoteSkeletonPath = path.join(remoteSkeletonRootPath, 'base');
66
- const remoteSkeletonFullPath = path.join(remoteSkeletonRootPath, 'full');
68
+ return tools.rimraf(remoteSrcPath);
69
+ })
67
70
 
71
+ .then(() => {
72
+ // copying default base sources
68
73
  tools.logInfo(`Copying base sources => ${remoteSkeletonPath} ==> ${remotePath}`);
69
-
70
74
  tools.copy(remoteSkeletonPath, remotePath);
71
75
 
72
76
  // adding the dependendies files
@@ -131,19 +135,81 @@ module.exports.generateVirtualRemote = (remoteName, cloneRemote = true) => {
131
135
 
132
136
  // initializing "full" remote sources
133
137
  if (remote.fullSkeletonSources) {
134
- tools.logInfo(`copying full sources skeleton : ${remoteSkeletonFullPath} ==> ${remotePath}`);
135
- tools.copy(remoteSkeletonFullPath, remotePath);
138
+ const fullCommonPath = path.join(remoteSkeletonRootPath, 'full', 'common');
139
+ const fullOptionsPath = path.join(remoteSkeletonRootPath, 'full', 'options');
140
+
141
+ const optionUserReducersPath = path.join(fullOptionsPath, 'user-reducers');
142
+ const optionParticipantPath = path.join(fullOptionsPath, 'participant');
143
+ const optionUserReducersDef = tools.getJsonFileContent(path.join(fullOptionsPath, 'definitions', 'user-reducers.json'));
144
+ const optionZipkinDef = tools.getJsonFileContent(path.join(fullOptionsPath, 'definitions', 'zipkin.json'));
145
+ const optionDynatraceDef = tools.getJsonFileContent(path.join(fullOptionsPath, 'definitions', 'dynatrace.json'));
146
+ const optionParticipantDef = tools.getJsonFileContent(path.join(fullOptionsPath, 'definitions', 'participant.json'));
147
+
148
+ tools.logInfo(`copying full sources skeleton : ${fullCommonPath} ==> ${remoteSrcPath}`);
149
+ tools.copy(fullCommonPath, remoteSrcPath);
150
+
151
+ // checking options
152
+ if (remote.skeletonConfig.options) {
153
+ let importsContent = [];
154
+ let definitionsContent = [];
155
+ let declarationsContent = [];
156
+ let providersContent = [];
157
+ let constructorDeclarationsContent = [];
158
+
159
+ const pushContent = (obj) => {
160
+ if (obj.imports) importsContent.push(obj.imports);
161
+ if (obj.definitions) definitionsContent.push(obj.definitions);
162
+ if (obj.declarations) declarationsContent.push(obj.declarations);
163
+ if (obj.providers) providersContent.push(obj.providers);
164
+ if (obj.constructorDeclarations) constructorDeclarationsContent.push(obj.constructorDeclarations);
165
+ }
166
+
167
+ // user-reducers specific sources
168
+ if (remote.skeletonConfig.options.userReducers) {
169
+ tools.copy(optionUserReducersPath, remoteSrcPath);
170
+ definitionsContent.push('StoreModule.forRoot(TOKEN)');
171
+ pushContent(optionUserReducersDef);
172
+ } else {
173
+ definitionsContent.push('StoreModule.forRoot(TOKEN, { metaReducers })');
174
+ }
175
+
176
+ // zipkin
177
+ if (remote.skeletonConfig.options.zipkin) {
178
+ pushContent(optionZipkinDef);
179
+ }
180
+
181
+ // dynatrace
182
+ if (remote.skeletonConfig.options.dynatrace) {
183
+ pushContent(optionDynatraceDef);
184
+ }
185
+
186
+ // participant
187
+ if (remote.skeletonConfig.options.participant) {
188
+ tools.copy(optionParticipantPath, remoteSrcPath);
189
+ pushContent(optionParticipantDef);
190
+ } else {
191
+ definitionsContent.push(`StoreRouterConnectingModule.forRoot({ stateKey: 'router', serializer: CustomSerializer })`);
192
+ }
193
+
194
+ // replace option in module.ts placeholders
195
+ const moduleTsPath = path.join(remoteSrcPath, 'app', 'module.ts');
196
+ tools.replaceInFileSync(moduleTsPath, '// IMPORTS', importsContent.join('\n'));
197
+ tools.replaceInFileSync(moduleTsPath, '// DEFINITIONS', definitionsContent.join(',\n'));
198
+ tools.replaceInFileSync(moduleTsPath, '// DECLARATIONS', declarationsContent.join('\n'));
199
+ tools.replaceInFileSync(moduleTsPath, '// PROVIDERS', providersContent.join(',\n'));
200
+ tools.replaceInFileSync(moduleTsPath, '// CONSTRUCTOR DECLARATIONS', constructorDeclarationsContent.join('\n'));
201
+ }
136
202
 
137
203
  tools.logInfo('Replacing skeleton config tokens');
138
-
139
- const remoteSrcPath = path.join(remotePath, 'src');
140
-
141
204
  tools.replaceInPath(remoteSrcPath, '@remote.name@', remote.name);
142
205
  tools.replaceInPath(remoteSrcPath, '@base.url@', remote.skeletonConfig.baseUrl);
143
206
  tools.replaceInPath(remoteSrcPath, '@element.name@', remote.skeletonConfig.elementName);
144
207
  tools.replaceInPath(remoteSrcPath, '@store.name@', remote.skeletonConfig.storeName);
145
208
  tools.replaceInPath(remoteSrcPath, '@root.common.module@', remote.skeletonConfig.rootCommonModule);
146
209
  tools.replaceInPath(remoteSrcPath, '@root.npm.pkg@', remote.skeletonConfig.rootNpmPkg);
210
+ if (remote.skeletonConfig.options.participant) {
211
+ tools.replaceInPath(remoteSrcPath, '@block.container.name@', remote.skeletonConfig.blockContainerName);
212
+ }
147
213
 
148
214
  tools.logSuccess('OK => copy done - Tokens replaced');
149
215
  }
@@ -10,169 +10,83 @@ const configUtils = require('../../../csdr/config/config-utils');
10
10
  const preBuildUtils = require('../../pre-build/pre-build-utils');
11
11
  const remotesUtils = require('../../remotes/remotes-utils');
12
12
 
13
- let {
14
- skipLint, skipTest, configuration, baseHref, watch, dryRun, maxSpaceSize, statsJson,
15
- ci, sourceMap, build
16
- } = tools.getArgs();
13
+ let { configuration, baseHref, dryRun, statsJson, sourceMap, build } = tools.getArgs();
17
14
 
18
15
 
19
16
  module.exports.build = (pkg, isMaster) => {
20
17
 
21
18
  const ng = path.resolve(pkg.paths.repoNodeModules, '@angular', 'cli', 'bin', 'ng');
22
-
23
19
  const remoteEuiVersion = configUtils.packages.getRemoteEuiVersion(pkg);
24
-
25
20
  const pkgName = pkg.name;
26
21
 
27
- return Promise.resolve()
28
-
29
- .then(() => {
30
- tools.logTitle(`Building element : ${pkgName}...`);
31
-
32
- // force skipLint and skipTest on element
33
- skipLint = true;
34
- skipTest = true;
35
- })
36
-
37
- .then(() => {
38
- return preBuildUtils.elements.preBuild(pkg);
39
- })
22
+ tools.logTitle(`Building element : ${pkgName}...`);
40
23
 
41
- .then(() => {
42
- if (!skipLint) {
43
- tools.logInfo(`TS Linting element...`);
24
+ return Promise.resolve()
25
+ .then(() => {
26
+ return preBuildUtils.elements.preBuild(pkg);
27
+ })
44
28
 
45
- const tslint = path.resolve(pkg.paths.repoNodeModules, 'tslint', 'bin', 'tslint');
29
+ .then(() => {
30
+ tools.logInfo(`Launching element build...`);
46
31
 
47
- const tsLintPath = path.join(pkg.paths.root, 'tslint.json');
48
- const tsConfigPath = path.join(pkg.paths.root, 'tsconfig.app.json');
49
- tools.logInfo(`running tslint -c ${tsLintPath} -p ${tsConfigPath}`);
50
- // return tools.runScript(`tslint -c ${tsLintPath} -p ${tsConfigPath}`);
32
+ // specific for element
33
+ const versionNumber = remoteEuiVersion.split('.')[0];
51
34
 
52
- const args = [tslint, '-c', tsLintPath, '-p', tsConfigPath];
53
- return execa('node', args, { cwd: pkg.paths.root, stdio: 'inherit' });
54
- }
55
- })
35
+ // checking configuration
36
+ if (!configuration) {
37
+ configuration = 'production';
38
+ }
56
39
 
40
+ let args;
57
41
 
58
- .then(() => {
59
- if (!skipLint) {
60
- tools.logSuccess();
61
- }
62
- if (!skipLint) {
63
- tools.logInfo(`Styles Linting element...`);
42
+ if (versionNumber <= 10) {
43
+ args = ['--max_old_space_size=8096', ng, 'build', pkgName, '--prod'];
44
+ } else {
45
+ args = ['--max_old_space_size=8096', ng, 'build', pkgName];
46
+ }
64
47
 
65
- // return tools.runScript(`stylelint ${pkg.paths.root}/src/app/**/*.scss`);
66
- const stylelint = path.resolve(pkg.paths.repoNodeModules, 'stylelint', 'bin', 'stylelint');
67
- const args = [stylelint, `${pkg.paths.root}/src/app/**/*.scss`];
48
+ if (statsJson) {
49
+ args.push(`--stats-json`);
50
+ }
68
51
 
69
- return execa('node', args, { cwd: pkg.paths.root, stdio: 'inherit' });
70
- }
71
- })
52
+ args.push(`--configuration=${configuration}`);
72
53
 
54
+ if (baseHref) {
55
+ args.push(`--base-href=${baseHref}`);
56
+ }
73
57
 
74
- .then(() => {
75
- if (!skipLint) {
76
- tools.logSuccess();
77
- }
78
- if (!skipTest) {
79
- tools.logInfo(`Launching element unit testing...`);
58
+ if (versionNumber <= 10) {
59
+ const webpackExtraFile = path.join(pkg.paths.root, 'webpack.extra.js');
60
+ if (tools.isFileExists(webpackExtraFile)) {
61
+ args.push(`--extra-webpack-config=${webpackExtraFile}`);
62
+ }
63
+ args.push(`--single-bundle=true`);
64
+ }
80
65
 
81
- let args;
66
+ args.push(`--output-hashing=none`);
82
67
 
83
- if (maxSpaceSize) {
84
- args = ['--max_old_space_size=4096', ng, 'test', pkgName];
85
- } else {
86
- args = [ng, 'test', pkgName];
68
+ if (build) {
69
+ args.push('--progress=false');
87
70
  }
88
71
 
89
- if (watch) {
90
- args.push(`--watch=true`);
91
- } else {
92
- args.push(`--watch=false`);
72
+ if (sourceMap) {
73
+ args.push('--source-map');
93
74
  }
94
75
 
95
- args.push('--code-coverage');
96
-
97
- tools.logInfo(`ng test : watching = ${watch || false}`);
76
+ tools.logInfo(`ng build for configuration : ${configuration}`);
98
77
 
99
- tools.logInfo(`running Angular TEST with args: ${args} on`);
78
+ tools.logInfo(`running Angular BUILD with args: ${args} on`);
100
79
  console.log(pkg.paths.root);
101
80
 
102
81
  if (!dryRun) {
103
82
  return execa('node', args, { cwd: pkg.paths.root, stdio: 'inherit' });
104
83
  }
105
- }
106
- })
107
-
108
-
109
- .then(() => {
110
- if (!skipTest) {
111
- tools.logSuccess();
112
- }
113
- tools.logInfo(`Launching element build...`);
114
-
115
- // specific for element
116
- const versionNumber = remoteEuiVersion.split('.')[0];
117
-
118
- // checking configuration
119
- if (!configuration) {
120
- configuration = 'production';
121
- }
122
-
123
- let args;
124
-
125
- if (versionNumber <= 10) {
126
- args = ['--max_old_space_size=8096', ng, 'build', pkgName, '--prod'];
127
- } else {
128
- args = ['--max_old_space_size=8096', ng, 'build', pkgName];
129
- }
130
-
131
- if (statsJson) {
132
- args.push(`--stats-json`);
133
- }
134
-
135
- args.push(`--configuration=${configuration}`);
136
-
137
- if (baseHref) {
138
- args.push(`--base-href=${baseHref}`);
139
- }
140
-
141
- const webpackExtraFile = path.join(pkg.paths.root, 'webpack.extra.js');
142
- if (tools.isFileExists(webpackExtraFile)) {
143
- args.push(`--extra-webpack-config=${webpackExtraFile}`);
144
- }
145
-
146
- // specific for element
147
-
148
- if (versionNumber <= 10) {
149
- args.push(`--single-bundle=true`);
150
- }
151
-
152
- args.push(`--output-hashing=none`);
153
-
154
- if (build) {
155
- args.push('--progress=false');
156
- }
157
-
158
- if (sourceMap) {
159
- args.push('--source-map');
160
- }
161
-
162
- tools.logInfo(`ng build for configuration : ${configuration}`);
163
-
164
- tools.logInfo(`running Angular BUILD with args: ${args} on`);
165
- console.log(pkg.paths.root);
166
-
167
- if (!dryRun) {
168
- return execa('node', args, { cwd: pkg.paths.root, stdio: 'inherit' });
169
- }
170
- })
84
+ })
171
85
 
172
86
 
173
- .catch((e) => {
174
- throw e;
175
- });
87
+ .catch((e) => {
88
+ throw e;
89
+ });
176
90
  }
177
91
 
178
92
 
@@ -414,6 +414,19 @@ function replaceInFile(file, fromString, toString) {
414
414
  })
415
415
  }
416
416
 
417
+ function replaceInFileSync(file, fromString, toString) {
418
+ const fromRegExp = new RegExp(fromString, 'g');
419
+
420
+ logInfo('replace in file: ' + file);
421
+
422
+ return replace.sync({
423
+ files: file,
424
+ from: fromRegExp,
425
+ to: toString,
426
+ disableGlobs: true,
427
+ });
428
+ }
429
+
417
430
  function replaceInPath(rootPath, fromString, toString) {
418
431
  const fromRegExp = new RegExp(fromString, 'g');
419
432
 
@@ -814,6 +827,7 @@ module.exports.logDebugTrace = logDebugTrace;
814
827
  module.exports.logDebugResponse = logDebugResponse;
815
828
 
816
829
  module.exports.replaceInFile = replaceInFile;
830
+ module.exports.replaceInFileSync = replaceInFileSync;
817
831
  module.exports.replaceInPath = replaceInPath;
818
832
  module.exports.sortArray = sortArray;
819
833
  module.exports.removeArrayDuplicates = removeArrayDuplicates;
@@ -1,6 +0,0 @@
1
- // Dummy test
2
- describe('Test', () => {
3
- it('should work', () => {
4
- expect(true).toBe(true);
5
- });
6
- });