File tree 3 files changed +40
-1
lines changed 3 files changed +40
-1
lines changed Original file line number Diff line number Diff line change @@ -59,4 +59,39 @@ describe('apply command', function () {
59
59
} ) ;
60
60
} ) ;
61
61
} ) ;
62
+ describe ( 'apply component changes on existing workspace' , ( ) => {
63
+ let output : string ;
64
+ before ( ( ) => {
65
+ helper . scopeHelper . setNewLocalAndRemoteScopes ( ) ;
66
+ helper . fixtures . populateComponents ( 1 ) ;
67
+ helper . command . tagAllWithoutBuild ( ) ;
68
+ helper . command . export ( ) ;
69
+
70
+ const data = [
71
+ {
72
+ componentId : `${ helper . scopes . remote } /comp1` ,
73
+ message : `msg for first comp` ,
74
+ files : [
75
+ {
76
+ path : 'index.js' ,
77
+ content : "require('test-dummy-package')" ,
78
+ } ,
79
+ ] ,
80
+ } ,
81
+ ] ;
82
+ // console.log('command', `bit apply '${JSON.stringify(data)}'`);
83
+ output = helper . command . apply ( data ) ;
84
+ } ) ;
85
+ it ( 'should modify the component correctly' , ( ) => {
86
+ const indexFile = helper . fs . readFile ( 'comp1/index.js' ) ;
87
+ expect ( indexFile ) . to . have . string ( "require('test-dummy-package')" ) ;
88
+ } ) ;
89
+ it ( 'should leave the component as modified in bit-status' , ( ) => {
90
+ const status = helper . command . statusJson ( ) ;
91
+ expect ( status . modifiedComponents ) . to . have . lengthOf ( 1 ) ;
92
+ } ) ;
93
+ it ( 'should install the new packages according to the added import statement' , ( ) => {
94
+ expect ( output ) . to . have . string ( '+ test-dummy-package' ) ;
95
+ } ) ;
96
+ } ) ;
62
97
} ) ;
Original file line number Diff line number Diff line change @@ -271,7 +271,7 @@ export class ApplyMain {
271
271
const newIds : ComponentID [ ] = [ ] ;
272
272
const updatedIds : ComponentID [ ] = [ ] ;
273
273
await pMapSeries ( snapDataPerComp , async ( snapData ) => {
274
- const existing = this . workspace . bitMap . getBitmapEntryIfExist ( snapData . componentId ) ;
274
+ const existing = this . workspace . bitMap . getBitmapEntryIfExist ( snapData . componentId , { ignoreVersion : true } ) ;
275
275
if ( existing && snapData . isNew ) {
276
276
throw new Error (
277
277
`component "${ snapData . componentId . toString ( ) } " already exists in the workspace. please remove the "isNew" prop`
@@ -310,6 +310,9 @@ export class ApplyMain {
310
310
}
311
311
} ) ;
312
312
313
+ // without this, when adding new import statements to a component, the installation doesn't pick them up
314
+ await this . workspace . clearCache ( ) ;
315
+
313
316
await this . install . install ( undefined , {
314
317
dedupe : true ,
315
318
import : false ,
Original file line number Diff line number Diff line change @@ -837,6 +837,7 @@ export default class CommandHelper {
837
837
}
838
838
} ) ;
839
839
} ) ;
840
+ // console.log('apply command', `bit apply '${JSON.stringify(data)}' ${options}`);
840
841
return this . runCmd ( `bit apply '${ JSON . stringify ( data ) } ' ${ options } ` ) ;
841
842
}
842
843
diff ( id = '' ) {
You can’t perform that action at this time.
0 commit comments