@@ -88,6 +88,9 @@ describe("addWranglerToGitIgnore", () => {
8888 # wrangler files
8989 .wrangler
9090 .dev.vars*
91+ !.dev.vars.example
92+ .env*
93+ !.env.example
9194 "
9295 ` ) ;
9396 } ) ;
@@ -97,7 +100,10 @@ describe("addWranglerToGitIgnore", () => {
97100 "my-project/.gitignore" ,
98101 `
99102 node_modules
100- .dev.vars
103+ .dev.vars*
104+ !.dev.vars.example
105+ .env*
106+ !.env.example
101107 .vscode
102108 .wrangler
103109 ` ,
@@ -116,7 +122,10 @@ describe("addWranglerToGitIgnore", () => {
116122 `
117123 node_modules
118124 .wrangler # This is for wrangler
119- .dev.vars # this is for wrangler and getPlatformProxy
125+ .dev.vars* # this is for wrangler and getPlatformProxy
126+ !.dev.vars.example # more comments
127+ .env* # even more
128+ !.env.example # and a final one
120129 .vscode
121130 ` ,
122131 ) ;
@@ -128,12 +137,68 @@ describe("addWranglerToGitIgnore", () => {
128137 expect ( appendFileResults . content ) . toBeUndefined ( ) ;
129138 } ) ;
130139
131- test ( "should append to the gitignore file the missing wrangler files when some is already present (without including the section heading)" , ( ) => {
140+ test ( "should append to the gitignore file the missing wrangler files when some are already present (should add the section heading if including .wrangler and some others )" , ( ) => {
132141 mockGitIgnore (
133142 "my-project/.gitignore" ,
134143 `
135144 node_modules
136- .dev.vars
145+ .dev.vars*
146+ .vscode` ,
147+ ) ;
148+ addWranglerToGitIgnore ( {
149+ project : { path : "my-project" } ,
150+ } as unknown as C3Context ) ;
151+
152+ expect ( appendFileResults . file ) . toMatchInlineSnapshot (
153+ `"my-project/.gitignore"` ,
154+ ) ;
155+ expect ( appendFileResults . content ) . toMatchInlineSnapshot ( `
156+ "
157+
158+ # wrangler files
159+ .wrangler
160+ !.dev.vars.example
161+ .env*
162+ !.env.example
163+ "
164+ ` ) ;
165+ } ) ;
166+
167+ test ( "should append to the gitignore file the missing wrangler files when some are already present (should not add the section heading if .wrangler already exists)" , ( ) => {
168+ mockGitIgnore (
169+ "my-project/.gitignore" ,
170+ `
171+ node_modules
172+ .wrangler
173+ .dev.vars*
174+ .vscode` ,
175+ ) ;
176+ addWranglerToGitIgnore ( {
177+ project : { path : "my-project" } ,
178+ } as unknown as C3Context ) ;
179+
180+ expect ( appendFileResults . file ) . toMatchInlineSnapshot (
181+ `"my-project/.gitignore"` ,
182+ ) ;
183+ expect ( appendFileResults . content ) . toMatchInlineSnapshot ( `
184+ "
185+
186+ !.dev.vars.example
187+ .env*
188+ !.env.example
189+ "
190+ ` ) ;
191+ } ) ;
192+
193+ test ( "should append to the gitignore file the missing wrangler files when some are already present (should not add the section heading if only adding .wrangler)" , ( ) => {
194+ mockGitIgnore (
195+ "my-project/.gitignore" ,
196+ `
197+ node_modules
198+ .dev.vars*
199+ !.dev.vars.example
200+ .env*
201+ !.env.example
137202 .vscode` ,
138203 ) ;
139204 addWranglerToGitIgnore ( {
@@ -156,7 +221,10 @@ describe("addWranglerToGitIgnore", () => {
156221 "my-project/.gitignore" ,
157222 `
158223 node_modules
159- .dev.vars
224+ .dev.vars*
225+ !.dev.vars.example
226+ .env*
227+ !.env.example
160228 .vscode
161229
162230 ` ,
@@ -203,6 +271,9 @@ describe("addWranglerToGitIgnore", () => {
203271 # wrangler files
204272 .wrangler
205273 .dev.vars*
274+ !.dev.vars.example
275+ .env*
276+ !.env.example
206277 "
207278 ` ) ;
208279 } ) ;
@@ -221,6 +292,34 @@ describe("addWranglerToGitIgnore", () => {
221292 expect ( writeFileResults . content ) . toBeUndefined ( ) ;
222293 } ) ;
223294
295+ test ( "should add the wildcard .dev.vars* entry even if a .dev.vars is already included" , ( ) => {
296+ mockGitIgnore (
297+ "my-project/.gitignore" ,
298+ `
299+ node_modules
300+ .dev.vars
301+ .vscode
302+ ` ,
303+ ) ;
304+ addWranglerToGitIgnore ( {
305+ project : { path : "my-project" } ,
306+ } as unknown as C3Context ) ;
307+
308+ expect ( appendFileResults . file ) . toMatchInlineSnapshot (
309+ `"my-project/.gitignore"` ,
310+ ) ;
311+ expect ( appendFileResults . content ) . toMatchInlineSnapshot ( `
312+ "
313+ # wrangler files
314+ .wrangler
315+ .dev.vars*
316+ !.dev.vars.example
317+ .env*
318+ !.env.example
319+ "
320+ ` ) ;
321+ } ) ;
322+
224323 test ( "should not add the .wrangler entry if a .wrangler/ is already included)" , ( ) => {
225324 mockGitIgnore (
226325 "my-project/.gitignore" ,
@@ -240,6 +339,9 @@ describe("addWranglerToGitIgnore", () => {
240339 expect ( appendFileResults . content ) . toMatchInlineSnapshot ( `
241340 "
242341 .dev.vars*
342+ !.dev.vars.example
343+ .env*
344+ !.env.example
243345 "
244346 ` ) ;
245347 } ) ;
0 commit comments