Skip to content

Commit a963152

Browse files
authored
Merge pull request #118 from Service-Soft/angular-fixes
Angular fixes
2 parents eac8255 + dbb8fe1 commit a963152

18 files changed

Lines changed: 3058 additions & 2613 deletions

cspell.words.txt

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,33 @@
1-
WORKDIR
21
stringifying
32
codepaths
43
urlset
54
outdir
6-
TRAEFIK
75
websecure
86
certresolver
97
myresolver
10-
letsencrypt
118
certificatesresolvers
129
exposedbydefault
1310
httpchallenge
1411
placeholderresolver
1512
loadbalancer
16-
adminer
1713
initdb
1814
rolname
1915
plpgsql
2016
datname
2117
psql
22-
packagr
23-
Monux
2418
redirections
2519
redirectregex
2620
wwwredirect
2721
sslresolver
2822
stringstring
2923
monux
30-
postgresql
3124
postgres
32-
TRAEFIK
33-
traefik
34-
mariadb
3525
MARIADB
3626
dts
37-
nestjs
3827
cloudflare
3928
cldr
4029
cldrjs
4130
htpasswd
42-
basicauth
4331
usersfile
4432
zibri
4533
autodocs

package-lock.json

Lines changed: 2955 additions & 2519 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "monux-cli",
3-
"version": "2.5.1",
3+
"version": "2.5.2",
44
"license": "MIT",
55
"main": "index.js",
66
"engines": {
@@ -39,26 +39,26 @@
3939
"prepublishOnly": "npm i && npm run build"
4040
},
4141
"dependencies": {
42-
"chalk": "^4.1.2",
42+
"chalk": "4.1.2",
4343
"cli-table3": "^0.6.5",
4444
"death": "^1.1.0",
45-
"figlet": "^1.7.0",
45+
"figlet": "^1.8.2",
4646
"inquirer": "^10.2.2",
4747
"js-yaml": "^4.1.0",
4848
"json5": "^2.2.3"
4949
},
5050
"devDependencies": {
51-
"@angular/common": "^18.2.13",
51+
"@angular/common": "^20.2.1",
5252
"@faker-js/faker": "^9.0.3",
53-
"@jest/globals": "^29.7.0",
54-
"@nestjs/common": "^11.0.20",
53+
"@jest/globals": "^30.0.5",
54+
"@nestjs/common": "^11.1.6",
5555
"@types/death": "^1.1.5",
56-
"@types/figlet": "^1.5.8",
56+
"@types/figlet": "^1.7.0",
5757
"@types/js-yaml": "^4.0.9",
58-
"eslint": "^9.24.0",
59-
"eslint-config-service-soft": "^2.0.8",
60-
"jest": "^29.7.0",
61-
"ngx-material-navigation": "^18.1.2",
62-
"ts-jest": "^29.2.5"
58+
"eslint": "^9.34.0",
59+
"eslint-config-service-soft": "^2.1.0",
60+
"jest": "^30.0.5",
61+
"ngx-material-navigation": "^20.0.0",
62+
"ts-jest": "^29.4.1"
6363
}
6464
}

src/__testing__/mock/file-mock.utilities.ts

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -30,30 +30,30 @@ export abstract class FileMockUtilities {
3030

3131
private static readonly mockMethodForFile: Record<
3232
keyof FileMockConstants,
33-
(mockConstants: MockConstants, entry: keyof MockConstants) => (void | Promise<void>)
33+
(mockConstants: MockConstants, entry: keyof MockConstants) => void | Promise<void>
3434
> = {
35-
DOCKER_COMPOSE_YAML: this.createEmptyFile,
36-
DEV_DOCKER_COMPOSE_YAML: this.createEmptyFile,
37-
LOCAL_DOCKER_COMPOSE_YAML: this.createEmptyFile,
38-
STAGE_DOCKER_COMPOSE_YAML: this.createEmptyFile,
39-
ANGULAR_ESLINT_CONFIG_MJS: this.createEmptyFile,
40-
ANGULAR_PACKAGE_JSON: this.createAngularPackageJson,
41-
ANGULAR_APP_COMPONENT_TS: this.createAppComponentTsFile,
42-
ANGULAR_APP_COMPONENT_HTML: this.createEmptyFile,
43-
ANGULAR_APP_ROUTES_TS: this.createAppRoutesTs,
44-
ANGULAR_ROUTES_TS: this.createEmptyFile,
45-
ANGULAR_APP_CONFIG_TS: this.createAppConfig,
46-
ANGULAR_JSON: this.createAngularJson,
47-
ANGULAR_ENVIRONMENT_MODEL: this.createEmptyFile,
48-
ANGULAR_ENVIRONMENT: this.createEmptyFile,
49-
TS_LIBRARY_PACKAGE_JSON: this.createEmptyFile,
50-
ROOT_PACKAGE_JSON: this.createRootPackageJson,
51-
ENV: this.createEnv,
52-
ENV_PUBLIC: this.createEnvPublic,
53-
GLOBAL_ENV_MODEL: this.createGlobalEnvModel,
54-
WORKSPACE_JSON: WorkspaceUtilities.createConfig,
55-
BASE_TS_CONFIG_JSON: TsConfigUtilities.createBaseTsConfig
56-
};
35+
DOCKER_COMPOSE_YAML: this.createEmptyFile,
36+
DEV_DOCKER_COMPOSE_YAML: this.createEmptyFile,
37+
LOCAL_DOCKER_COMPOSE_YAML: this.createEmptyFile,
38+
STAGE_DOCKER_COMPOSE_YAML: this.createEmptyFile,
39+
ANGULAR_ESLINT_CONFIG_MJS: this.createEmptyFile,
40+
ANGULAR_PACKAGE_JSON: this.createAngularPackageJson,
41+
ANGULAR_APP_COMPONENT_TS: this.createAppComponentTsFile,
42+
ANGULAR_APP_COMPONENT_HTML: this.createEmptyFile,
43+
ANGULAR_APP_ROUTES_TS: this.createAppRoutesTs,
44+
ANGULAR_ROUTES_TS: this.createEmptyFile,
45+
ANGULAR_APP_CONFIG_TS: this.createAppConfig,
46+
ANGULAR_JSON: this.createAngularJson,
47+
ANGULAR_ENVIRONMENT_MODEL: this.createEmptyFile,
48+
ANGULAR_ENVIRONMENT: this.createEmptyFile,
49+
TS_LIBRARY_PACKAGE_JSON: this.createEmptyFile,
50+
ROOT_PACKAGE_JSON: this.createRootPackageJson,
51+
ENV: this.createEnv,
52+
ENV_PUBLIC: this.createEnvPublic,
53+
GLOBAL_ENV_MODEL: this.createGlobalEnvModel,
54+
WORKSPACE_JSON: WorkspaceUtilities.createConfig,
55+
BASE_TS_CONFIG_JSON: TsConfigUtilities.createBaseTsConfig
56+
};
5757

5858
static async setup(
5959
mockConstants: MockConstants,
@@ -195,7 +195,7 @@ export abstract class FileMockUtilities {
195195
private static async createAppConfig(mockConstants: MockConstants): Promise<void> {
196196
await FsUtilities.createFile(mockConstants.ANGULAR_APP_CONFIG_TS, [
197197
'import { ApplicationConfig, provideZoneChangeDetection } from \'@angular/core\';',
198-
'import { provideClientHydration } from \'@angular/platform-browser\';',
198+
'import { provideClientHydration, withEventReplay } from \'@angular/platform-browser\';',
199199
'import { provideRouter } from \'@angular/router\';',
200200
'',
201201
'import { routes } from \'./app.routes\';',
@@ -204,7 +204,7 @@ export abstract class FileMockUtilities {
204204
'\tproviders: [',
205205
'\t\tprovideZoneChangeDetection({ eventCoalescing: true }),',
206206
'\t\tprovideRouter(routes),',
207-
'\t\tprovideClientHydration()',
207+
'\t\tprovideClientHydration(withEventReplay())',
208208
'\t]',
209209
'};'
210210
], true, false);

src/angular/angular-utilities.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { afterEach, beforeEach, describe, expect, jest, test } from '@jest/globa
33
import { AngularUtilities } from './angular.utilities';
44
import { fakeAddNavElementConfig, fakeTsImportDefinition, FileMockUtilities, getMockConstants, MAX_GEN_CODE_TIME, MockConstants } from '../__testing__';
55
import { CPUtilities, FsUtilities } from '../encapsulation';
6-
import { NpmUtilities } from '../npm';
6+
import { NpmPackage, NpmUtilities } from '../npm';
77
import { TsImportDefinition } from '../ts';
88
import { AddNavElementConfig } from './add-nav-element-config.model';
99
import { getPath } from '../utilities';
@@ -53,7 +53,7 @@ describe('AngularUtilities', () => {
5353
await AngularUtilities.setupNavigation(mockConstants.ANGULAR_APP_DIR, mockConstants.ANGULAR_APP_NAME);
5454

5555
expect(npmInstallMock).toHaveBeenCalledTimes(1);
56-
expect(npmInstallMock).toHaveBeenCalledWith(mockConstants.ANGULAR_APP_NAME, ['ngx-material-navigation']);
56+
expect(npmInstallMock).toHaveBeenCalledWith(mockConstants.ANGULAR_APP_NAME, [NpmPackage.NGX_MATERIAL_NAVIGATION]);
5757

5858
const htmlLines: string[] = await FsUtilities.readFileLines(mockConstants.ANGULAR_APP_COMPONENT_HTML);
5959
expect(htmlLines).toEqual([
@@ -327,7 +327,7 @@ describe('AngularUtilities', () => {
327327
expect(cpExecSyncMock).toHaveBeenCalledTimes(1);
328328
expect(cpExecSyncMock).toHaveBeenCalledWith(`cd ${mockConstants.ANGULAR_APP_DIR} && npx @angular/cli@20 add @angular/pwa@20 --skip-confirmation`);
329329
expect(npmInstallMock).toHaveBeenCalledTimes(1);
330-
expect(npmInstallMock).toHaveBeenCalledWith(mockConstants.ANGULAR_APP_NAME, ['ngx-pwa']);
330+
expect(npmInstallMock).toHaveBeenCalledWith(mockConstants.ANGULAR_APP_NAME, [NpmPackage.NGX_PWA]);
331331

332332
const htmlLines: string[] = await FsUtilities.readFileLines(mockConstants.ANGULAR_APP_COMPONENT_HTML);
333333
const tsLines: string[] = await FsUtilities.readFileLines(mockConstants.ANGULAR_APP_COMPONENT_TS);
@@ -363,7 +363,7 @@ describe('AngularUtilities', () => {
363363

364364
expect(tsLines).toEqual([
365365
'import { ApplicationConfig, provideZoneChangeDetection } from \'@angular/core\';',
366-
'import { provideClientHydration } from \'@angular/platform-browser\';',
366+
'import { provideClientHydration, withEventReplay } from \'@angular/platform-browser\';',
367367
'import { provideRouter } from \'@angular/router\';',
368368
'',
369369
'import { routes } from \'./app.routes\';',
@@ -372,7 +372,7 @@ describe('AngularUtilities', () => {
372372
' providers: [',
373373
' provideZoneChangeDetection({ eventCoalescing: true }),',
374374
' provideRouter(routes),',
375-
' provideClientHydration(),',
375+
' provideClientHydration(withEventReplay()),',
376376
' {',
377377
' provide: \'test\',',
378378
' useValue: 42',

src/angular/angular.utilities.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ type AddOptions = {
100100
/**
101101
* Possible angular cli options, narrowed down based on the provided command.
102102
*/
103-
type AngularCliOptions<T extends AngularCliCommands> =
104-
T extends CliNew ? NewOptions
103+
type AngularCliOptions<T extends AngularCliCommands>
104+
= T extends CliNew ? NewOptions
105105
: T extends CliGenerate ? GenerateOptions
106106
: T extends CliAdd ? AddOptions
107107
: never;
@@ -462,11 +462,6 @@ export abstract class AngularUtilities {
462462
* @param root - The root of the angular project to setup material for.
463463
*/
464464
static async setupMaterial(root: string): Promise<void> {
465-
await this.addProvider(
466-
root,
467-
'provideAnimations()',
468-
[{ defaultImport: false, element: 'provideAnimations', path: '@angular/platform-browser/animations' }]
469-
);
470465
await FsUtilities.updateFile(
471466
getPath(root, 'src', 'styles.css'),
472467
[
@@ -486,7 +481,7 @@ export abstract class AngularUtilities {
486481
);
487482
await FsUtilities.updateFile(
488483
getPath(root, 'src', 'styles.css'),
489-
'\'@import "@angular/material/prebuilt-themes/indigo-pink.css";\'',
484+
'@import "@angular/material/prebuilt-themes/indigo-pink.css";',
490485
'prepend'
491486
);
492487
}

src/commands/add/add-angular-library/storybook-main-ts.content.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ const config: StorybookConfig = {
2121
framework: {
2222
name: getAbsolutePath('@storybook/angular'),
2323
options: {}
24+
},
25+
core: {
26+
disableTelemetry: true
2427
}
2528
};
2629

src/commands/add/add-angular-website/add-angular-website.command.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { ModuleResolutionKind } from 'typescript';
2+
13
import { AngularUtilities, NavElementTypes } from '../../../angular';
24
import { ANGULAR_APP_COMPONENT_FILE_NAME, ANGULAR_JSON_FILE_NAME, APPS_DIRECTORY_NAME, BASE_TS_CONFIG_FILE_NAME, DOCKER_FILE_NAME, GIT_IGNORE_FILE_NAME } from '../../../constants';
35
import { DockerUtilities } from '../../../docker';
@@ -113,7 +115,7 @@ export class AddAngularWebsiteCommand extends BaseAddCommand<AddAngularWebsiteCo
113115
if (config.addTracking) {
114116
await AngularUtilities.setupTracking(config.name);
115117
}
116-
await NpmUtilities.updatePackageJson(config.name, { scripts: { start: `ng serve --port ${config.port}` } });
118+
await NpmUtilities.updatePackageJson(config.name, { scripts: { start: `ng serve --port ${config.port}` }, prettier: undefined });
117119
const app: WorkspaceProject = await WorkspaceUtilities.findProjectOrFail(config.name, getPath('.'));
118120
await EnvUtilities.buildEnvironmentFileForApp(app, true, 'dev.docker-compose.yaml', getPath('.'));
119121
}
@@ -201,7 +203,16 @@ export class AddAngularWebsiteCommand extends BaseAddCommand<AddAngularWebsiteCo
201203
private async setupTsConfig(root: string, projectName: string): Promise<void> {
202204
// eslint-disable-next-line no-console
203205
console.log('sets up tsconfig');
204-
await TsConfigUtilities.updateTsConfig(projectName, { extends: `../../${BASE_TS_CONFIG_FILE_NAME}` });
206+
await TsConfigUtilities.updateTsConfig(
207+
projectName,
208+
{
209+
extends: `../../${BASE_TS_CONFIG_FILE_NAME}`,
210+
compilerOptions: {
211+
moduleResolution: 'bundler' as unknown as ModuleResolutionKind,
212+
isolatedModules: false
213+
}
214+
}
215+
);
205216

206217
const eslintTsconfig: TsConfig = {
207218
compilerOptions: {

src/commands/add/add-angular/add-angular.command.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
/* eslint-disable no-console */
2+
import { ModuleResolutionKind } from 'typescript';
3+
24
import { AngularUtilities, NavElementTypes } from '../../../angular';
35
import { ANGULAR_APP_COMPONENT_FILE_NAME, ANGULAR_JSON_FILE_NAME, APP_CONFIG_FILE_NAME, APPS_DIRECTORY_NAME, BASE_TS_CONFIG_FILE_NAME, DOCKER_FILE_NAME, GIT_IGNORE_FILE_NAME } from '../../../constants';
46
import { DockerUtilities } from '../../../docker';
@@ -147,7 +149,7 @@ export class AddAngularCommand extends BaseAddCommand<AddAngularConfiguration> {
147149

148150
await this.createDefaultPages(root, config);
149151

150-
await NpmUtilities.updatePackageJson(config.name, { scripts: { start: `ng serve --port ${config.port}` } });
152+
await NpmUtilities.updatePackageJson(config.name, { scripts: { start: `ng serve --port ${config.port}` }, prettier: undefined });
151153

152154
const app: WorkspaceProject = await WorkspaceUtilities.findProjectOrFail(config.name, getPath('.'));
153155
await EnvUtilities.buildEnvironmentFileForApp(app, false, 'dev.docker-compose.yaml', getPath('.'));
@@ -274,7 +276,16 @@ export class AddAngularCommand extends BaseAddCommand<AddAngularConfiguration> {
274276

275277
private async setupTsConfig(root: string, projectName: string): Promise<void> {
276278
console.log('sets up tsconfig');
277-
await TsConfigUtilities.updateTsConfig(projectName, { extends: `../../${BASE_TS_CONFIG_FILE_NAME}` });
279+
await TsConfigUtilities.updateTsConfig(
280+
projectName,
281+
{
282+
extends: `../../${BASE_TS_CONFIG_FILE_NAME}`,
283+
compilerOptions: {
284+
moduleResolution: 'bundler' as unknown as ModuleResolutionKind,
285+
isolatedModules: false
286+
}
287+
}
288+
);
278289

279290
const eslintTsconfig: TsConfig = {
280291
compilerOptions: {

src/encapsulation/custom-ts.resolver.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import { NavElementTypes } from '../angular/nav-element-types.enum';
77
export type CustomTsValues = NavElementTypes
88
| 'provideZoneChangeDetection({ eventCoalescing: true })'
99
| 'provideRouter(routes)'
10-
| 'provideClientHydration()'
11-
| 'provideAnimations()'
10+
| 'provideClientHydration(withEventReplay())'
11+
| 'provideBrowserGlobalErrorListeners()'
1212
| 'NGX_LOGGER_SERVICE'
1313
| 'LoggerService'
1414
| 'ErrorHandler'
@@ -41,8 +41,8 @@ export const customTsValueToString: Record<CustomTsValues, string> = {
4141
titleWithInternalLink: 'NavElementTypes.TITLE_WITH_INTERNAL_LINK',
4242
'provideZoneChangeDetection({ eventCoalescing: true })': 'provideZoneChangeDetection({ eventCoalescing: true })',
4343
'provideRouter(routes)': 'provideRouter(routes)',
44-
'provideClientHydration()': 'provideClientHydration()',
45-
'provideAnimations()': 'provideAnimations()',
44+
'provideClientHydration(withEventReplay())': 'provideClientHydration(withEventReplay())',
45+
'provideBrowserGlobalErrorListeners()': 'provideBrowserGlobalErrorListeners()',
4646
NGX_LOGGER_SERVICE: 'NGX_LOGGER_SERVICE',
4747
LoggerService: 'LoggerService',
4848
ErrorHandler: 'ErrorHandler',
@@ -76,8 +76,8 @@ export const customTsStringToValue: Record<string, CustomTsValues> = {
7676
'NavElementTypes.TITLE_WITH_INTERNAL_LINK': NavElementTypes.TITLE_WITH_INTERNAL_LINK,
7777
'provideZoneChangeDetection({ eventCoalescing: true })': 'provideZoneChangeDetection({ eventCoalescing: true })',
7878
'provideRouter(routes)': 'provideRouter(routes)',
79-
'provideClientHydration()': 'provideClientHydration()',
80-
'provideAnimations()': 'provideAnimations()',
79+
'provideClientHydration(withEventReplay())': 'provideClientHydration(withEventReplay())',
80+
'provideBrowserGlobalErrorListeners()': 'provideBrowserGlobalErrorListeners()',
8181
NGX_LOGGER_SERVICE: 'NGX_LOGGER_SERVICE',
8282
LoggerService: 'LoggerService',
8383
ErrorHandler: 'ErrorHandler',

0 commit comments

Comments
 (0)