@@ -122,7 +122,7 @@ describe('Template Init', () => {
122
122
expect ( existsSync ( templateDir ) ) . toBe ( true )
123
123
124
124
// Verify files were created in the template directory
125
- const expectedFiles = getExpectedFiles ( 'typescript' )
125
+ const expectedFiles = getExpectedFiles ( Language . TypeScript )
126
126
for ( const file of expectedFiles ) {
127
127
expect ( existsSync ( path . join ( templateDir , file ) ) ) . toBe ( true )
128
128
}
@@ -171,13 +171,72 @@ describe('Template Init', () => {
171
171
expect ( existsSync ( templateDir ) ) . toBe ( true )
172
172
173
173
// Verify files were created in the template directory
174
- const expectedFiles = getExpectedFiles ( 'typescript' )
174
+ const expectedFiles = getExpectedFiles ( Language . TypeScript )
175
175
for ( const file of expectedFiles ) {
176
176
expect ( existsSync ( path . join ( templateDir , file ) ) ) . toBe ( true )
177
177
}
178
178
179
- // Verify package.json was not created in the template directory
180
- expect ( existsSync ( path . join ( templateDir , 'package.json' ) ) ) . toBe ( false )
179
+ // Verify package.json was created in the template directory
180
+ const createdPackageJSON = JSON . parse (
181
+ await fs . readFile ( path . join ( templateDir , 'package.json' ) , 'utf8' )
182
+ )
183
+
184
+ expect ( createdPackageJSON . scripts ) . toHaveProperty ( 'e2b:build:dev' )
185
+ expect ( createdPackageJSON . scripts ) . toHaveProperty ( 'e2b:build:prod' )
186
+ } )
187
+ } )
188
+
189
+ describe ( 'Makefile Integration' , ( ) => {
190
+ test ( 'should add scripts to existing Makefile' , async ( ) => {
191
+ // Create a Makefile file in the parent directory
192
+ const makefile = `
193
+ .PHONY: build
194
+ build/%:
195
+ \tCGO_ENABLED=1 go build
196
+ `
197
+ const makefilePath = path . join ( testDir , 'Makefile' )
198
+ await fs . writeFile ( makefilePath , makefile )
199
+
200
+ // Run init command
201
+ execSync (
202
+ `node "${ cliPath } " template init-v2 --name "test-template" --language "python-sync" --path "${ testDir } "` ,
203
+ { stdio : 'inherit' }
204
+ )
205
+
206
+ // Verify Makefile was updated (it should remain in the parent directory)
207
+ const updatedMakefile = await fs . readFile ( makefilePath , 'utf8' )
208
+
209
+ expect ( updatedMakefile ) . toContain ( 'e2b:build:dev' )
210
+ expect ( updatedMakefile ) . toContain ( 'e2b:build:prod' )
211
+ expect ( updatedMakefile ) . toContain ( `.PHONY: build
212
+ build/%:
213
+ \tCGO_ENABLED=1 go build` ) // existing script preserved
214
+ } )
215
+
216
+ test ( 'should work without Makefile' , async ( ) => {
217
+ // Run init command without Makefile
218
+ execSync (
219
+ `node "${ cliPath } " template init-v2 --name "test-template" --language "python-sync" --path "${ testDir } "` ,
220
+ { stdio : 'inherit' }
221
+ )
222
+
223
+ // Verify template directory was created
224
+ const templateDir = path . join ( testDir , 'test-template' )
225
+ expect ( existsSync ( templateDir ) ) . toBe ( true )
226
+
227
+ // Verify files were created in the template directory
228
+ const expectedFiles = getExpectedFiles ( Language . PythonSync )
229
+ for ( const file of expectedFiles ) {
230
+ expect ( existsSync ( path . join ( templateDir , file ) ) ) . toBe ( true )
231
+ }
232
+
233
+ // Verify Makefile was created in the template directory
234
+ const createdMakefile = await fs . readFile (
235
+ path . join ( templateDir , 'Makefile' ) ,
236
+ 'utf8'
237
+ )
238
+ expect ( createdMakefile ) . toContain ( 'e2b:build:dev' )
239
+ expect ( createdMakefile ) . toContain ( 'e2b:build:prod' )
181
240
} )
182
241
} )
183
242
@@ -266,10 +325,12 @@ describe('Template Init', () => {
266
325
} )
267
326
268
327
// Helper functions
269
- function getExpectedFiles ( language : string ) : string [ ] {
270
- const extension = language === 'typescript' ? '.ts' : '.py'
271
- const buildDevName = language === 'typescript' ? 'build.dev' : 'build_dev'
272
- const buildProdName = language === 'typescript' ? 'build.prod' : 'build_prod'
328
+ function getExpectedFiles ( language : Language ) : string [ ] {
329
+ const extension = language === Language . TypeScript ? '.ts' : '.py'
330
+ const buildDevName =
331
+ language === Language . TypeScript ? 'build.dev' : 'build_dev'
332
+ const buildProdName =
333
+ language === Language . TypeScript ? 'build.prod' : 'build_prod'
273
334
274
335
return [
275
336
`template${ extension } ` ,
@@ -280,12 +341,14 @@ function getExpectedFiles(language: string): string[] {
280
341
281
342
async function verifyTemplateNameInBuildFiles (
282
343
testDir : string ,
283
- language : string ,
344
+ language : Language ,
284
345
templateName : string
285
346
) : Promise < void > {
286
- const extension = language === 'typescript' ? '.ts' : '.py'
287
- const buildDevName = language === 'typescript' ? 'build.dev' : 'build_dev'
288
- const buildProdName = language === 'typescript' ? 'build.prod' : 'build_prod'
347
+ const extension = language === Language . TypeScript ? '.ts' : '.py'
348
+ const buildDevName =
349
+ language === Language . TypeScript ? 'build.dev' : 'build_dev'
350
+ const buildProdName =
351
+ language === Language . TypeScript ? 'build.prod' : 'build_prod'
289
352
290
353
// Check dev build file contains template name with -dev suffix
291
354
const devContent = await fs . readFile (
0 commit comments