|
6 | 6 | * found in the LICENSE file at https://angular.dev/license |
7 | 7 | */ |
8 | 8 |
|
9 | | -import { rm, symlink } from 'node:fs/promises'; |
10 | 9 | import { executeLibraryBuilder } from '../../builder'; |
11 | 10 | import { BASE_OPTIONS, LIBRARY_BUILDER_INFO, describeLibraryBuilder } from '../setup'; |
12 | 11 |
|
@@ -54,143 +53,5 @@ describeLibraryBuilder(executeLibraryBuilder, LIBRARY_BUILDER_INFO, (harness) => |
54 | 53 |
|
55 | 54 | expect(harness.readFile('dist/lib/docs/README.md')).toBe('# Library Docs'); |
56 | 55 | }); |
57 | | - |
58 | | - it('should allow user assets to override default README.md without duplicate emission', async () => { |
59 | | - await harness.writeFiles({ |
60 | | - 'projects/lib/README.md': '# Default Library README', |
61 | | - 'projects/lib/docs/README.md': '# Custom Library README', |
62 | | - }); |
63 | | - |
64 | | - harness.useTarget('build', { |
65 | | - ...BASE_OPTIONS, |
66 | | - assets: [ |
67 | | - { |
68 | | - glob: 'README.md', |
69 | | - input: 'projects/lib/docs', |
70 | | - output: '.', |
71 | | - }, |
72 | | - ], |
73 | | - }); |
74 | | - |
75 | | - const { result } = await harness.executeOnce(); |
76 | | - expect(result?.success).toBeTrue(); |
77 | | - expect(harness.readFile('dist/lib/README.md')).toBe('# Custom Library README'); |
78 | | - }); |
79 | | - |
80 | | - it('should not emit symlinked assets in watch mode when followSymlinks is false', async () => { |
81 | | - await harness.writeFiles({ |
82 | | - 'projects/lib/assets-dir/real.txt': 'real-initial', |
83 | | - 'projects/lib/external.txt': 'external-content', |
84 | | - }); |
85 | | - |
86 | | - harness.useTarget('build', { |
87 | | - ...BASE_OPTIONS, |
88 | | - assets: [ |
89 | | - { |
90 | | - glob: '**/*.txt', |
91 | | - input: 'projects/lib/assets-dir', |
92 | | - output: 'assets', |
93 | | - followSymlinks: false, |
94 | | - }, |
95 | | - ], |
96 | | - watch: true, |
97 | | - }); |
98 | | - |
99 | | - await harness.executeWithCases([ |
100 | | - async ({ result }) => { |
101 | | - expect(result?.success).toBeTrue(); |
102 | | - expect(harness.readFile('dist/lib/assets/real.txt')).toBe('real-initial'); |
103 | | - |
104 | | - await symlink( |
105 | | - harness.resolvePath('projects/lib/external.txt'), |
106 | | - harness.resolvePath('projects/lib/assets-dir/linked.txt'), |
107 | | - ); |
108 | | - await harness.writeFile('projects/lib/assets-dir/real.txt', 'real-updated'); |
109 | | - }, |
110 | | - ({ result }) => { |
111 | | - expect(result?.success).toBeTrue(); |
112 | | - expect(harness.readFile('dist/lib/assets/real.txt')).toBe('real-updated'); |
113 | | - expect(harness.hasFile('dist/lib/assets/linked.txt')).toBeFalse(); |
114 | | - }, |
115 | | - ]); |
116 | | - }); |
117 | | - |
118 | | - it('should respect directory ignore patterns in watch mode', async () => { |
119 | | - await harness.writeFiles({ |
120 | | - 'projects/lib/assets-dir/keep.txt': 'keep', |
121 | | - 'projects/lib/assets-dir/ignored-dir/initial.txt': 'ignored-initial', |
122 | | - }); |
123 | | - |
124 | | - harness.useTarget('build', { |
125 | | - ...BASE_OPTIONS, |
126 | | - assets: [ |
127 | | - { |
128 | | - glob: '**/*.txt', |
129 | | - input: 'projects/lib/assets-dir', |
130 | | - output: 'assets', |
131 | | - ignore: ['ignored-dir'], |
132 | | - }, |
133 | | - ], |
134 | | - watch: true, |
135 | | - }); |
136 | | - |
137 | | - await harness.executeWithCases([ |
138 | | - async ({ result }) => { |
139 | | - expect(result?.success).toBeTrue(); |
140 | | - expect(harness.readFile('dist/lib/assets/keep.txt')).toBe('keep'); |
141 | | - expect(harness.hasFile('dist/lib/assets/ignored-dir/initial.txt')).toBeFalse(); |
142 | | - |
143 | | - await harness.writeFiles({ |
144 | | - 'projects/lib/assets-dir/ignored-dir/added.txt': 'ignored-added', |
145 | | - 'projects/lib/assets-dir/allowed-dir/added.txt': 'allowed-added', |
146 | | - }); |
147 | | - }, |
148 | | - ({ result }) => { |
149 | | - expect(result?.success).toBeTrue(); |
150 | | - expect(harness.readFile('dist/lib/assets/allowed-dir/added.txt')).toBe('allowed-added'); |
151 | | - expect(harness.hasFile('dist/lib/assets/ignored-dir/added.txt')).toBeFalse(); |
152 | | - }, |
153 | | - ]); |
154 | | - }); |
155 | | - |
156 | | - it('should delete emitted assets when a subdirectory is deleted in watch mode', async () => { |
157 | | - await harness.writeFiles({ |
158 | | - 'projects/lib/assets-dir/keep.txt': 'keep', |
159 | | - 'projects/lib/assets-dir/nested/a.txt': 'nested-a', |
160 | | - 'projects/lib/assets-dir/nested/b.txt': 'nested-b', |
161 | | - }); |
162 | | - |
163 | | - harness.useTarget('build', { |
164 | | - ...BASE_OPTIONS, |
165 | | - assets: [ |
166 | | - { |
167 | | - glob: '**/*.txt', |
168 | | - input: 'projects/lib/assets-dir', |
169 | | - output: 'assets', |
170 | | - }, |
171 | | - ], |
172 | | - watch: true, |
173 | | - }); |
174 | | - |
175 | | - await harness.executeWithCases([ |
176 | | - async ({ result }) => { |
177 | | - expect(result?.success).toBeTrue(); |
178 | | - expect(harness.readFile('dist/lib/assets/keep.txt')).toBe('keep'); |
179 | | - expect(harness.readFile('dist/lib/assets/nested/a.txt')).toBe('nested-a'); |
180 | | - expect(harness.readFile('dist/lib/assets/nested/b.txt')).toBe('nested-b'); |
181 | | - |
182 | | - await rm(harness.resolvePath('projects/lib/assets-dir/nested'), { |
183 | | - recursive: true, |
184 | | - force: true, |
185 | | - }); |
186 | | - }, |
187 | | - ({ result }) => { |
188 | | - expect(result?.success).toBeTrue(); |
189 | | - expect(harness.readFile('dist/lib/assets/keep.txt')).toBe('keep'); |
190 | | - expect(harness.hasFile('dist/lib/assets/nested/a.txt')).toBeFalse(); |
191 | | - expect(harness.hasFile('dist/lib/assets/nested/b.txt')).toBeFalse(); |
192 | | - }, |
193 | | - ]); |
194 | | - }); |
195 | 56 | }); |
196 | 57 | }); |
0 commit comments