@@ -90,6 +90,52 @@ describe('CLI integration', () => {
9090 expect ( out ) . toContain ( 'generate' ) ;
9191 } ) ;
9292
93+ it ( 'generate writes docker-compose.yml when config has docker enabled' , ( ) => {
94+ const os = require ( 'os' ) ;
95+ const tempDir = path . join ( os . tmpdir ( ) , `devkit-e2e-generate-${ Date . now ( ) } ` ) ;
96+ fs . ensureDirSync ( tempDir ) ;
97+ const config = [
98+ 'name: e2e-generate' ,
99+ 'version: "1.0.0"' ,
100+ 'databases:' ,
101+ ' - type: postgresql' ,
102+ ' port: 5432' ,
103+ ' - type: redis' ,
104+ ' port: 6379' ,
105+ 'docker:' ,
106+ ' enabled: true' ,
107+ ' output_file: docker-compose.yml' ,
108+ ] . join ( '\n' ) ;
109+ fs . writeFileSync ( path . join ( tempDir , '.dev-env.yml' ) , config ) ;
110+ try {
111+ runCli ( [ 'generate' ] , tempDir ) ;
112+ const composePath = path . join ( tempDir , 'docker-compose.yml' ) ;
113+ expect ( fs . pathExistsSync ( composePath ) ) . toBe ( true ) ;
114+ const content = fs . readFileSync ( composePath , 'utf-8' ) ;
115+ expect ( content ) . toMatch ( / v e r s i o n : | s e r v i c e s : / ) ;
116+ expect ( content ) . toMatch ( / p o s t g r e s | r e d i s / ) ;
117+ } finally {
118+ fs . removeSync ( tempDir ) ;
119+ }
120+ } ) ;
121+
122+ it ( 'generate -o writes to custom path' , ( ) => {
123+ const os = require ( 'os' ) ;
124+ const tempDir = path . join ( os . tmpdir ( ) , `devkit-e2e-generate-o-${ Date . now ( ) } ` ) ;
125+ fs . ensureDirSync ( tempDir ) ;
126+ fs . writeFileSync (
127+ path . join ( tempDir , '.dev-env.yml' ) ,
128+ 'name: e2e\ndatabases:\n - type: redis\n port: 6379\ndocker:\n enabled: true'
129+ ) ;
130+ try {
131+ runCli ( [ 'generate' , '-o' , 'my-compose.yml' ] , tempDir ) ;
132+ expect ( fs . pathExistsSync ( path . join ( tempDir , 'my-compose.yml' ) ) ) . toBe ( true ) ;
133+ expect ( fs . pathExistsSync ( path . join ( tempDir , 'docker-compose.yml' ) ) ) . toBe ( false ) ;
134+ } finally {
135+ fs . removeSync ( tempDir ) ;
136+ }
137+ } ) ;
138+
93139 it ( 'setup --help shows skip and dry-run options' , ( ) => {
94140 const out = runCli ( [ 'setup' , '--help' ] ) ;
95141 expect ( out ) . toMatch ( / s k i p - d e p s | s k i p - d b | d r y - r u n / ) ;
@@ -181,4 +227,49 @@ describe('CLI integration', () => {
181227 fs . removeSync ( tempDir ) ;
182228 }
183229 } ) ;
230+
231+ it ( 'share export -o writes to custom path' , ( ) => {
232+ const os = require ( 'os' ) ;
233+ const tempDir = path . join ( os . tmpdir ( ) , `devkit-e2e-share-export-o-${ Date . now ( ) } ` ) ;
234+ fs . ensureDirSync ( tempDir ) ;
235+ fs . writeFileSync ( path . join ( tempDir , '.dev-env.yml' ) , 'name: e2e\nversion: "1.0.0"\ndatabases: []' ) ;
236+ try {
237+ runCli ( [ 'share' , 'export' , '-o' , 'custom-shared.yml' ] , tempDir ) ;
238+ expect ( fs . pathExistsSync ( path . join ( tempDir , 'custom-shared.yml' ) ) ) . toBe ( true ) ;
239+ const content = fs . readFileSync ( path . join ( tempDir , 'custom-shared.yml' ) , 'utf-8' ) ;
240+ expect ( content ) . toMatch ( / n a m e : \s * e 2 e / ) ;
241+ } finally {
242+ fs . removeSync ( tempDir ) ;
243+ }
244+ } ) ;
245+
246+ it ( 'share import -o writes to custom path' , ( ) => {
247+ const os = require ( 'os' ) ;
248+ const tempDir = path . join ( os . tmpdir ( ) , `devkit-e2e-share-import-o-${ Date . now ( ) } ` ) ;
249+ fs . ensureDirSync ( tempDir ) ;
250+ const shared = 'name: imported-via-o\nversion: "1.0.0"\ndatabases: []' ;
251+ fs . writeFileSync ( path . join ( tempDir , 'in.yml' ) , shared ) ;
252+ try {
253+ runCli ( [ 'share' , 'import' , 'in.yml' , '-o' , 'custom-config.yml' ] , tempDir ) ;
254+ expect ( fs . pathExistsSync ( path . join ( tempDir , 'custom-config.yml' ) ) ) . toBe ( true ) ;
255+ const content = fs . readFileSync ( path . join ( tempDir , 'custom-config.yml' ) , 'utf-8' ) ;
256+ expect ( content ) . toMatch ( / i m p o r t e d - v i a - o / ) ;
257+ } finally {
258+ fs . removeSync ( tempDir ) ;
259+ }
260+ } ) ;
261+
262+ it ( 'snapshot list shows created snapshot name' , ( ) => {
263+ const os = require ( 'os' ) ;
264+ const tempDir = path . join ( os . tmpdir ( ) , `devkit-e2e-list-${ Date . now ( ) } ` ) ;
265+ fs . ensureDirSync ( tempDir ) ;
266+ fs . writeFileSync ( path . join ( tempDir , '.dev-env.yml' ) , 'name: e2e\nversion: "1.0.0"' ) ;
267+ runCli ( [ 'snapshot' , 'create' , 'list-test-snap' ] , tempDir ) ;
268+ try {
269+ const out = runCli ( [ 'snapshot' , 'list' ] , tempDir ) ;
270+ expect ( out ) . toContain ( 'list-test-snap' ) ;
271+ } finally {
272+ fs . removeSync ( tempDir ) ;
273+ }
274+ } ) ;
184275} ) ;
0 commit comments