@ng-zen/cli 0.0.1-alpha.1 → 19.0.0-alpha.1

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 (71) hide show
  1. package/LICENSE +24 -24
  2. package/README.md +46 -39
  3. package/package.json +12 -13
  4. package/schematics/collection.json +16 -16
  5. package/schematics/components/components-generator.js.map +1 -1
  6. package/schematics/components/components-generator.ts +5 -0
  7. package/schematics/components/files/avatar/avatar.component.scss +23 -23
  8. package/schematics/components/files/avatar/avatar.component.spec.ts +22 -22
  9. package/schematics/components/files/avatar/avatar.component.ts +66 -60
  10. package/schematics/components/files/avatar/avatar.stories.ts +38 -0
  11. package/schematics/components/files/avatar/index.ts +1 -1
  12. package/schematics/components/files/button/button.component.scss +42 -42
  13. package/schematics/components/files/button/button.component.spec.ts +22 -22
  14. package/schematics/components/files/button/button.component.ts +25 -11
  15. package/schematics/components/files/button/button.stories.ts +19 -0
  16. package/schematics/components/files/button/index.ts +1 -10
  17. package/schematics/components/index.js +4 -14
  18. package/schematics/components/index.js.map +1 -1
  19. package/schematics/components/index.ts +10 -0
  20. package/schematics/components/schema.json +30 -25
  21. package/schematics/components/templates/README.md.template +40 -41
  22. package/schematics/ng-add/index.js +3 -4
  23. package/schematics/ng-add/index.js.map +1 -1
  24. package/schematics/ng-add/index.ts +14 -0
  25. package/schematics/ng-add/ng-zen-generator.js.map +1 -1
  26. package/schematics/ng-add/ng-zen-generator.ts +3 -0
  27. package/schematics/ng-add/schema.json +15 -15
  28. package/types/generator-schema-base.interface.js +3 -0
  29. package/types/generator-schema-base.interface.js.map +1 -0
  30. package/types/generator-schema-base.interface.ts +4 -0
  31. package/types/index.js +5 -0
  32. package/types/index.js.map +1 -0
  33. package/types/index.ts +1 -0
  34. package/{schematics/utils → utils}/add-path-to-tsconfig.util.js +2 -3
  35. package/utils/add-path-to-tsconfig.util.js.map +1 -0
  36. package/utils/add-path-to-tsconfig.util.ts +50 -0
  37. package/utils/apply-file-template.util.js +23 -0
  38. package/utils/apply-file-template.util.js.map +1 -0
  39. package/utils/apply-file-template.util.ts +28 -0
  40. package/utils/index.js +6 -0
  41. package/utils/index.js.map +1 -0
  42. package/utils/index.ts +2 -0
  43. package/CHANGELOG.md +0 -28
  44. package/schematics/components/components-generator.d.ts +0 -5
  45. package/schematics/components/components-generator.d.ts.map +0 -1
  46. package/schematics/components/files/badge/badge.component.scss +0 -70
  47. package/schematics/components/files/badge/badge.component.spec.ts +0 -22
  48. package/schematics/components/files/badge/badge.component.ts +0 -52
  49. package/schematics/components/files/badge/index.ts +0 -1
  50. package/schematics/components/files/pin/index.ts +0 -1
  51. package/schematics/components/files/pin/pin.component.scss +0 -29
  52. package/schematics/components/files/pin/pin.component.spec.ts +0 -22
  53. package/schematics/components/files/pin/pin.component.ts +0 -46
  54. package/schematics/components/files/switch/index.ts +0 -10
  55. package/schematics/components/files/switch/zen-switch.component.html +0 -11
  56. package/schematics/components/files/switch/zen-switch.component.scss +0 -62
  57. package/schematics/components/files/switch/zen-switch.component.spec.ts +0 -22
  58. package/schematics/components/files/switch/zen-switch.component.ts +0 -123
  59. package/schematics/components/files/tag/index.ts +0 -10
  60. package/schematics/components/files/tag/tag.component.scss +0 -9
  61. package/schematics/components/files/tag/tag.component.spec.ts +0 -22
  62. package/schematics/components/files/tag/tag.component.ts +0 -26
  63. package/schematics/components/index.d.ts +0 -4
  64. package/schematics/components/index.d.ts.map +0 -1
  65. package/schematics/ng-add/index.d.ts +0 -4
  66. package/schematics/ng-add/index.d.ts.map +0 -1
  67. package/schematics/ng-add/ng-zen-generator.d.ts +0 -4
  68. package/schematics/ng-add/ng-zen-generator.d.ts.map +0 -1
  69. package/schematics/utils/add-path-to-tsconfig.util.d.ts +0 -3
  70. package/schematics/utils/add-path-to-tsconfig.util.d.ts.map +0 -1
  71. package/schematics/utils/add-path-to-tsconfig.util.js.map +0 -1
@@ -1,70 +0,0 @@
1
- :root {
2
- --zen-badge-offset: unset;
3
- --zen-badge-offset-x: unset;
4
- --zen-badge-offset-y: unset;
5
- }
6
-
7
- zen-badge,
8
- [zenBadge] {
9
- display: inline-flex;
10
- position: relative;
11
-
12
- [topLeft],
13
- [top],
14
- [topRight],
15
- [right],
16
- [bottomRight],
17
- [bottom],
18
- [bottomLeft],
19
- [left] {
20
- position: absolute;
21
- }
22
-
23
- [topLeft] {
24
- top: var(--zen-badge-offset-y, calc(var(--zen-badge-offset, 0px) * -1));
25
- left: var(--zen-badge-offset-x, calc(var(--zen-badge-offset, 0px) * -1));
26
- transform: translateY(-50%) translateX(-50%);
27
- }
28
-
29
- [top] {
30
- top: var(--zen-badge-offset-y, calc(var(--zen-badge-offset, 0px) * -1));
31
- left: 50%;
32
- transform: translateY(-50%) translateX(-50%);
33
- }
34
-
35
- [topRight] {
36
- top: var(--zen-badge-offset-y, calc(var(--zen-badge-offset, 0px) * -1));
37
- right: var(--zen-badge-offset-x, calc(var(--zen-badge-offset, 0px) * -1));
38
- transform: translateY(-50%) translateX(50%);
39
- }
40
-
41
- [right] {
42
- right: var(--zen-badge-offset-x, calc(var(--zen-badge-offset, 0px) * -1));
43
- top: 50%;
44
- transform: translateY(-50%) translateX(50%);
45
- }
46
-
47
- [bottomRight] {
48
- bottom: var(--zen-badge-offset-y, calc(var(--zen-badge-offset, 0px) * -1));
49
- right: var(--zen-badge-offset-x, calc(var(--zen-badge-offset, 0px) * -1));
50
- transform: translateY(50%) translateX(50%);
51
- }
52
-
53
- [bottom] {
54
- bottom: var(--zen-badge-offset-y, calc(var(--zen-badge-offset, 0px) * -1));
55
- left: 50%;
56
- transform: translateY(50%) translateX(-50%);
57
- }
58
-
59
- [bottomLeft] {
60
- bottom: var(--zen-badge-offset-y, calc(var(--zen-badge-offset, 0px) * -1));
61
- left: var(--zen-badge-offset-x, calc(var(--zen-badge-offset, 0px) * -1));
62
- transform: translateY(50%) translateX(-50%);
63
- }
64
-
65
- [left] {
66
- left: var(--zen-badge-offset-x, calc(var(--zen-badge-offset, 0px) * -1));
67
- top: 50%;
68
- transform: translateY(-50%) translateX(-50%);
69
- }
70
- }
@@ -1,22 +0,0 @@
1
- import { ComponentFixture, TestBed } from '@angular/core/testing';
2
-
3
- import { ZenBadgeComponent } from './badge.component';
4
-
5
- describe('BadgeComponent', () => {
6
- let component: ZenBadgeComponent;
7
- let fixture: ComponentFixture<ZenBadgeComponent>;
8
-
9
- beforeEach(async () => {
10
- await TestBed.configureTestingModule({
11
- imports: [ZenBadgeComponent],
12
- }).compileComponents();
13
-
14
- fixture = TestBed.createComponent(ZenBadgeComponent);
15
- component = fixture.componentInstance;
16
- fixture.detectChanges();
17
- });
18
-
19
- it('should create', () => {
20
- expect(component).toBeTruthy();
21
- });
22
- });
@@ -1,52 +0,0 @@
1
- import {
2
- ChangeDetectionStrategy,
3
- Component,
4
- ViewEncapsulation,
5
- } from '@angular/core';
6
-
7
- /**
8
- * ZenBadgeComponent is a versatile Angular component used to display badges or indicators
9
- * in various positions within its parent container. It allows for flexible placement
10
- * of badge content such as icons, text, or other elements in the top-left, top,
11
- * top-right, left, right, bottom-left, bottom, and bottom-right positions.
12
- *
13
- * This component offers standalone usage and is highly customizable through its
14
- * template and styling. It leverages Angular's change detection strategy 'OnPush'
15
- * for optimal performance.
16
- *
17
- * Additionally, it provides support for CSS variables to customize badge positioning
18
- *
19
- * ```css
20
- * --zen-badge-offset: unset; // Controls the overall offset of the badge
21
- * --zen-badge-offset-x: unset; // Controls the horizontal offset of the badge.
22
- * --zen-badge-offset-y: unset; // Controls the vertical offset of the badge.
23
- * ```
24
- *
25
- * @example <zen-badge> Text <span bottom>🦆</span></zen-badge>
26
- *
27
- * @component
28
- * @selector `zen-badge`,`[zenBadge]`
29
- *
30
- * @license BSD-2-Clause
31
- * @author Konrad Stępień <kord.stp@gmail.com>
32
- * @link https://github.com/Kordrad/ng-zen
33
- */
34
- @Component({
35
- selector: 'zen-badge,[zenBadge]',
36
- standalone: true,
37
- template: `
38
- <ng-content />
39
- <ng-content select="[topLeft]" />
40
- <ng-content select="[top]" />
41
- <ng-content select="[topRight]" />
42
- <ng-content select="[left]" />
43
- <ng-content select="[right]" />
44
- <ng-content select="[bottomLeft]" />
45
- <ng-content select="[bottom]" />
46
- <ng-content select="[bottomRight]" />
47
- `,
48
- styleUrl: './badge.component.scss',
49
- encapsulation: ViewEncapsulation.None,
50
- changeDetection: ChangeDetectionStrategy.OnPush,
51
- })
52
- export class ZenBadgeComponent {}
@@ -1 +0,0 @@
1
- export * from './badge.component';
@@ -1 +0,0 @@
1
- export * from './pin.component';
@@ -1,29 +0,0 @@
1
- zen-pin,
2
- zen-pin.stream::before {
3
- display: block;
4
- height: 8px;
5
- width: 8px;
6
- border-radius: 50%;
7
- background-color: #6b7280;
8
- }
9
-
10
- zen-pin {
11
- position: relative;
12
-
13
- &.stream::before {
14
- content: '';
15
- position: absolute;
16
- top: 50%;
17
- left: 50%;
18
- translate: -50% -50%;
19
- animation: stream 1s ease-in-out infinite;
20
- }
21
- }
22
-
23
- @keyframes stream {
24
- 75%,
25
- 100% {
26
- transform: scale(2);
27
- opacity: 0;
28
- }
29
- }
@@ -1,22 +0,0 @@
1
- import { ComponentFixture, TestBed } from '@angular/core/testing';
2
-
3
- import { ZenPinComponent } from './pin.component';
4
-
5
- describe('PinComponent', () => {
6
- let component: ZenPinComponent;
7
- let fixture: ComponentFixture<ZenPinComponent>;
8
-
9
- beforeEach(async () => {
10
- await TestBed.configureTestingModule({
11
- imports: [ZenPinComponent],
12
- }).compileComponents();
13
-
14
- fixture = TestBed.createComponent(ZenPinComponent);
15
- component = fixture.componentInstance;
16
- fixture.detectChanges();
17
- });
18
-
19
- it('should create', () => {
20
- expect(component).toBeTruthy();
21
- });
22
- });
@@ -1,46 +0,0 @@
1
- import {
2
- booleanAttribute,
3
- ChangeDetectionStrategy,
4
- Component,
5
- HostBinding,
6
- input,
7
- ViewEncapsulation,
8
- } from '@angular/core';
9
-
10
- /**
11
- * The ZenPinComponent represents a simple visual pin with a circular shape.
12
- *
13
- * ```html
14
- * <zen-pin />
15
- * ```
16
- *
17
- * @example <zen-pin />
18
- * @component
19
- * @selector `zen-pin`
20
- *
21
- * @license BSD-2-Clause
22
- * @author Konrad Stępień <kord.stp@gmail.com>
23
- * @link https://github.com/Kordrad/ng-zen
24
- */
25
- @Component({
26
- selector: 'zen-pin',
27
- standalone: true,
28
- imports: [],
29
- template: ``,
30
- styleUrl: './pin.component.scss',
31
- encapsulation: ViewEncapsulation.None,
32
- changeDetection: ChangeDetectionStrategy.OnPush,
33
- })
34
- export class ZenPinComponent {
35
- /**
36
- * Displays waving stream animation
37
- */
38
- readonly stream = input<boolean, boolean | 'true' | 'false' | ''>(false, {
39
- transform: booleanAttribute,
40
- });
41
-
42
- @HostBinding('class.stream')
43
- get classStream() {
44
- return this.stream();
45
- }
46
- }
@@ -1,10 +0,0 @@
1
- import { NgModule } from '@angular/core';
2
-
3
- import { ZenSwitchComponent } from './zen-switch.component';
4
-
5
- @NgModule({
6
- imports: [ZenSwitchComponent],
7
- exports: [ZenSwitchComponent],
8
- })
9
- export class ZenSwitchModule {}
10
- export * from './zen-switch.component';
@@ -1,11 +0,0 @@
1
- <button
2
- class="switch"
3
- [attr.aria-checked]="checked()"
4
- [attr.aria-disabled]="disabled()"
5
- [disabled]="disabled()"
6
- (click)="onToggle()"
7
- (keydown)="onKeyDown($event)"
8
- role="switch"
9
- >
10
- <span class="slider"></span>
11
- </button>
@@ -1,62 +0,0 @@
1
- // Define SCSS variables for better maintainability
2
- $switch-width: 36px;
3
- $switch-height: 22px;
4
- $slider-size: 16px;
5
- $transition-duration: 0.4s;
6
- $switch-bg-color: grey;
7
- $switch-checked-bg-color: green;
8
- $switch-disabled-bg-color: lightgrey;
9
- $slider-bg-color: white;
10
-
11
- // Other
12
- $slider-padding: calc(($switch-height - $slider-size) / 2);
13
- $slider-transform-distance: calc(
14
- $switch-width - $slider-size - $slider-padding * 2
15
- );
16
-
17
- /* Switch container */
18
- .switch {
19
- position: relative;
20
- display: inline-block;
21
- width: $switch-width;
22
- height: $switch-height;
23
- background-color: $switch-bg-color;
24
- border: none;
25
- border-radius: 99999px; // force perfectly rounded
26
- cursor: pointer;
27
- transition: background-color $transition-duration;
28
-
29
- /*
30
- outline: none;
31
- &:focus {
32
- box-shadow: 0 0 3px 2px rgba(21, 156, 228, 0.4);
33
- }
34
- */
35
- }
36
-
37
- /* Slider */
38
- .slider {
39
- position: absolute;
40
- top: $slider-padding;
41
- left: $slider-padding;
42
- height: $slider-size;
43
- width: $slider-size;
44
- background-color: $slider-bg-color;
45
- transition: transform $transition-duration;
46
- border-radius: 50%;
47
- }
48
-
49
- /* Styles when the button is checked */
50
- .switch[aria-checked='true'] {
51
- background-color: $switch-checked-bg-color;
52
-
53
- .slider {
54
- transform: translateX($slider-transform-distance);
55
- }
56
- }
57
-
58
- /* Styles when the button is disabled */
59
- .switch[aria-disabled='true'] {
60
- background-color: $switch-disabled-bg-color;
61
- cursor: not-allowed;
62
- }
@@ -1,22 +0,0 @@
1
- import { ComponentFixture, TestBed } from '@angular/core/testing';
2
-
3
- import { ZenSwitchComponent } from './zen-switch.component';
4
-
5
- describe('SwitchComponent', () => {
6
- let component: ZenSwitchComponent;
7
- let fixture: ComponentFixture<ZenSwitchComponent>;
8
-
9
- beforeEach(async () => {
10
- await TestBed.configureTestingModule({
11
- imports: [ZenSwitchComponent],
12
- }).compileComponents();
13
-
14
- fixture = TestBed.createComponent(ZenSwitchComponent);
15
- component = fixture.componentInstance;
16
- fixture.detectChanges();
17
- });
18
-
19
- it('should create', () => {
20
- expect(component).toBeTruthy();
21
- });
22
- });
@@ -1,123 +0,0 @@
1
- import { NgIf } from '@angular/common';
2
- import {
3
- ChangeDetectionStrategy,
4
- Component,
5
- forwardRef,
6
- model,
7
- } from '@angular/core';
8
- import {
9
- ControlValueAccessor,
10
- FormsModule,
11
- NG_VALUE_ACCESSOR,
12
- } from '@angular/forms';
13
-
14
- type OnChangeFn = (value: boolean) => void;
15
- type OnTouchedFn = () => void;
16
-
17
- /**
18
- * ZenSwitchComponent is a custom switch component that implements ControlValueAccessor to work seamlessly with Angular forms.
19
- *
20
- * @example <zen-switch />
21
- *
22
- * @export
23
- * @class ZenSwitchComponent
24
- * @implements {ControlValueAccessor}
25
- *
26
- * @license BSD-2-Clause
27
- * @author Konrad Stępień <kord.stp@gmail.com>
28
- * @link https://github.com/Kordrad/ng-zen
29
- */
30
- @Component({
31
- selector: 'zen-switch',
32
- standalone: true,
33
- templateUrl: './zen-switch.component.html',
34
- styleUrl: './zen-switch.component.scss',
35
- changeDetection: ChangeDetectionStrategy.OnPush,
36
- providers: [
37
- {
38
- provide: NG_VALUE_ACCESSOR,
39
- useExisting: forwardRef(() => ZenSwitchComponent),
40
- multi: true,
41
- },
42
- ],
43
- imports: [FormsModule, NgIf],
44
- })
45
- export class ZenSwitchComponent implements ControlValueAccessor {
46
- /** Model for the checked state of the switch. */
47
- checked = model<boolean>(false);
48
-
49
- /** Model for the disabled state of the switch. */
50
- disabled = model<boolean>(false);
51
-
52
- /** @ignore */
53
- private onChange: OnChangeFn = () => {};
54
- /** @ignore */
55
- private onTouched: OnTouchedFn = () => {};
56
-
57
- /**
58
- * Writes a new value to the component.
59
- * @ignore
60
- */
61
- writeValue(value: boolean): void {
62
- this.checked.set(value);
63
- }
64
-
65
- /**
66
- * Registers a function to be called when the value changes.
67
- * @ignore
68
- */
69
- registerOnChange(fn: OnChangeFn): void {
70
- this.onChange = fn;
71
- }
72
-
73
- /**
74
- * Registers a function to be called when the component is touched.
75
- * @ignore
76
- */
77
- registerOnTouched(fn: OnTouchedFn): void {
78
- this.onTouched = fn;
79
- }
80
-
81
- /**
82
- * Sets the disabled state of the component.
83
- * @ignore
84
- */
85
- setDisabledState(isDisabled: boolean): void {
86
- this.disabled.set(isDisabled);
87
- }
88
-
89
- /**
90
- * Toggles the switch value and notifies the change.
91
- */
92
- onToggle(check?: boolean): void {
93
- if (this.disabled()) return;
94
-
95
- const value = check ?? !this.checked();
96
-
97
- this.checked.set(value);
98
- this.onChange(value);
99
- this.onTouched();
100
- }
101
-
102
- /**
103
- * Handles keyboard events for accessibility.
104
- */
105
- onKeyDown(event: KeyboardEvent): void {
106
- switch (event.code) {
107
- case 'Enter':
108
- case 'Space': {
109
- event.preventDefault();
110
- this.onToggle();
111
- break;
112
- }
113
- case 'ArrowRight': {
114
- this.onToggle(true);
115
- break;
116
- }
117
- case 'ArrowLeft': {
118
- this.onToggle(false);
119
- break;
120
- }
121
- }
122
- }
123
- }
@@ -1,10 +0,0 @@
1
- import { NgModule } from '@angular/core';
2
-
3
- import { ZenTagComponent } from './tag.component';
4
-
5
- @NgModule({
6
- imports: [ZenTagComponent],
7
- exports: [ZenTagComponent],
8
- })
9
- export class ZenTagModule {}
10
- export * from './tag.component';
@@ -1,9 +0,0 @@
1
- :host {
2
- border-radius: 9999999px;
3
- background-color: lightgray;
4
- padding: 2px 8px;
5
- line-height: 20px;
6
- font-size: 12px;
7
- color: #343434;
8
- font-weight: bold;
9
- }
@@ -1,22 +0,0 @@
1
- import { ComponentFixture, TestBed } from '@angular/core/testing';
2
-
3
- import { ZenTagComponent } from './tag.component';
4
-
5
- describe('ZenTagComponent', () => {
6
- let component: ZenTagComponent;
7
- let fixture: ComponentFixture<ZenTagComponent>;
8
-
9
- beforeEach(async () => {
10
- await TestBed.configureTestingModule({
11
- imports: [ZenTagComponent],
12
- }).compileComponents();
13
-
14
- fixture = TestBed.createComponent(ZenTagComponent);
15
- component = fixture.componentInstance;
16
- fixture.detectChanges();
17
- });
18
-
19
- it('should create', () => {
20
- expect(component).toBeTruthy();
21
- });
22
- });
@@ -1,26 +0,0 @@
1
- import { ChangeDetectionStrategy, Component } from '@angular/core';
2
-
3
- /**
4
- * The `ZenTagComponent` is a reusable UI component designed to display a tag or label.
5
- * It allows for custom content to be projected inside the tag.
6
- *
7
- * ```html
8
- * <zen-tag>...</zen-tag>
9
- * ```
10
- *
11
- * @example <zen-tag>Simple tag</zen-tag>
12
- * @component
13
- * @selector `zen-tag`
14
- *
15
- * @license BSD-2-Clause
16
- * @author Konrad Stępień <kord.stp@gmail.com>
17
- * @link https://github.com/Kordrad/ng-zen
18
- */
19
- @Component({
20
- selector: 'zen-tag',
21
- standalone: true,
22
- template: `<ng-content />`,
23
- styleUrl: './tag.component.scss',
24
- changeDetection: ChangeDetectionStrategy.OnPush,
25
- })
26
- export class ZenTagComponent {}
@@ -1,4 +0,0 @@
1
- import { Rule } from '@angular-devkit/schematics';
2
- import { ComponentGeneratorSchema } from './components-generator';
3
- export declare function componentGenerator(options: ComponentGeneratorSchema): Rule;
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../projects/cli/schematics/components/index.ts"],"names":[],"mappings":"AACA,OAAO,EAML,IAAI,EAEL,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAElE,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,wBAAwB,GAAG,IAAI,CAoB1E"}
@@ -1,4 +0,0 @@
1
- import { Rule } from '@angular-devkit/schematics';
2
- import { NgZenGeneratorSchema } from './ng-zen-generator';
3
- export declare function ngAdd(options: NgZenGeneratorSchema): Rule;
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../projects/cli/schematics/ng-add/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAA0B,MAAM,4BAA4B,CAAC;AAG1E,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE1D,wBAAgB,KAAK,CAAC,OAAO,EAAE,oBAAoB,GAAG,IAAI,CAQzD"}
@@ -1,4 +0,0 @@
1
- export interface NgZenGeneratorSchema {
2
- path: string;
3
- }
4
- //# sourceMappingURL=ng-zen-generator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ng-zen-generator.d.ts","sourceRoot":"","sources":["../../../../../projects/cli/schematics/ng-add/ng-zen-generator.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;CACd"}
@@ -1,3 +0,0 @@
1
- import { Tree } from '@angular-devkit/schematics';
2
- export declare function addPathToTsconfigUtil(tree: Tree, key: string, value: string[]): void;
3
- //# sourceMappingURL=add-path-to-tsconfig.util.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"add-path-to-tsconfig.util.d.ts","sourceRoot":"","sources":["../../../../../projects/cli/schematics/utils/add-path-to-tsconfig.util.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAElD,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,IAAI,EACV,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,EAAE,GACd,IAAI,CA+CN"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"add-path-to-tsconfig.util.js","sourceRoot":"","sources":["../../../../../projects/cli/schematics/utils/add-path-to-tsconfig.util.ts"],"names":[],"mappings":";;;AAAA,2DAAiE;AAGjE,SAAgB,qBAAqB,CACnC,IAAU,EACV,GAAW,EACX,KAAe;IAEf,MAAM,YAAY,GAAG,eAAe,CAAC;IAErC,gCAAgC;IAChC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC;QAC/B,MAAM,IAAI,gCAAmB,CAAC,8BAA8B,CAAC,CAAC;IAChE,CAAC;IAED,uCAAuC;IACvC,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC/C,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,MAAM,IAAI,gCAAmB,CAAC,8BAA8B,CAAC,CAAC;IAChE,CAAC;IACD,IAAI,eAAe,GAAG,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAEvD,mCAAmC;IACnC,MAAM,YAAY,GAAG,eAAe,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;IAC/D,MAAM,OAAO,GAAG,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAEpD,4CAA4C;IAC5C,eAAe,GAAG,eAAe,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IAEvD,8BAA8B;IAC9B,IAAI,QAAQ,CAAC;IACb,IAAI,CAAC;QACH,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;IACzC,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,MAAM,IAAI,gCAAmB,CAAC,+BAA+B,CAAC,CAAC;IACjE,CAAC;IAED,uDAAuD;IACvD,IAAI,CAAC,QAAQ,CAAC,eAAe,EAAE,CAAC;QAC9B,QAAQ,CAAC,eAAe,GAAG,EAAE,CAAC;IAChC,CAAC;IACD,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;QACpC,QAAQ,CAAC,eAAe,CAAC,KAAK,GAAG,EAAE,CAAC;IACtC,CAAC;IACD,QAAQ,CAAC,eAAe,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IAE5C,uCAAuC;IACvC,eAAe,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAEpD,+DAA+D;IAC/D,eAAe,GAAG,GAAG,OAAO,KAAK,eAAe,EAAE,CAAC;IAEnD,8BAA8B;IAC9B,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,eAAe,CAAC,CAAC;AAChD,CAAC;AAnDD,sDAmDC","sourcesContent":["import { SchematicsException } from '@angular-devkit/schematics';\r\nimport { Tree } from '@angular-devkit/schematics';\r\n\r\nexport function addPathToTsconfigUtil(\r\n tree: Tree,\r\n key: string,\r\n value: string[]\r\n): void {\r\n const tsconfigPath = 'tsconfig.json';\r\n\r\n // Check if tsconfig.json exists\r\n if (!tree.exists(tsconfigPath)) {\r\n throw new SchematicsException('tsconfig.json does not exist');\r\n }\r\n\r\n // Read tsconfig.json content as string\r\n const tsconfigBuffer = tree.read(tsconfigPath);\r\n if (!tsconfigBuffer) {\r\n throw new SchematicsException('Failed to read tsconfig.json');\r\n }\r\n let tsconfigContent = tsconfigBuffer.toString('utf-8');\r\n\r\n // Extract and preserve the comment\r\n const commentMatch = tsconfigContent.match(/\\/\\*[\\s\\S]*?\\*\\//);\r\n const comment = commentMatch ? commentMatch[0] : '';\r\n\r\n // Remove comment from content to parse JSON\r\n tsconfigContent = tsconfigContent.replace(comment, '');\r\n\r\n // Parse tsconfig.json content\r\n let tsconfig;\r\n try {\r\n tsconfig = JSON.parse(tsconfigContent);\r\n } catch (e) {\r\n throw new SchematicsException('Failed to parse tsconfig.json');\r\n }\r\n\r\n // Modify compilerOptions.paths to add your new mapping\r\n if (!tsconfig.compilerOptions) {\r\n tsconfig.compilerOptions = {};\r\n }\r\n if (!tsconfig.compilerOptions.paths) {\r\n tsconfig.compilerOptions.paths = {};\r\n }\r\n tsconfig.compilerOptions.paths[key] = value;\r\n\r\n // Convert tsconfig back to JSON string\r\n tsconfigContent = JSON.stringify(tsconfig, null, 2);\r\n\r\n // Ensure the preserved comment is prepended to the JSON string\r\n tsconfigContent = `${comment}\\n${tsconfigContent}`;\r\n\r\n // Write back to tsconfig.json\r\n tree.overwrite(tsconfigPath, tsconfigContent);\r\n}\r\n"]}