@@ -85,56 +85,57 @@ runInEachFileSystem(() => {
8585 const COMMON_PACKAGE_PATH = _ ( '/node_modules/@angular/common/package.json' ) ;
8686 const fs = getFileSystem ( ) ;
8787 const pkgUpdater = new DirectPackageJsonUpdater ( fs ) ;
88- let pkg = JSON . parse ( fs . readFile ( COMMON_PACKAGE_PATH ) ) ;
88+ // TODO: Determine the correct/best type for the `pkg` type.
89+ let pkg = JSON . parse ( fs . readFile ( COMMON_PACKAGE_PATH ) ) as EntryPointPackageJson ;
8990 expect ( pkg . __processed_by_ivy_ngcc__ ) . toBeUndefined ( ) ;
9091 expect ( pkg . scripts ) . toBeUndefined ( ) ;
9192
9293 markAsProcessed ( pkgUpdater , pkg , COMMON_PACKAGE_PATH , [ 'fesm2015' , 'fesm5' ] ) ;
93- pkg = JSON . parse ( fs . readFile ( COMMON_PACKAGE_PATH ) ) ;
94- expect ( pkg . __processed_by_ivy_ngcc__ . fesm2015 ) . toBe ( '0.0.0-PLACEHOLDER' ) ;
95- expect ( pkg . __processed_by_ivy_ngcc__ . fesm5 ) . toBe ( '0.0.0-PLACEHOLDER' ) ;
96- expect ( pkg . __processed_by_ivy_ngcc__ . esm2015 ) . toBeUndefined ( ) ;
97- expect ( pkg . __processed_by_ivy_ngcc__ . esm5 ) . toBeUndefined ( ) ;
98- expect ( pkg . scripts . prepublishOnly ) . toBeDefined ( ) ;
94+ pkg = JSON . parse ( fs . readFile ( COMMON_PACKAGE_PATH ) ) as EntryPointPackageJson ;
95+ expect ( pkg . __processed_by_ivy_ngcc__ ! . fesm2015 ) . toBe ( '0.0.0-PLACEHOLDER' ) ;
96+ expect ( pkg . __processed_by_ivy_ngcc__ ! . fesm5 ) . toBe ( '0.0.0-PLACEHOLDER' ) ;
97+ expect ( pkg . __processed_by_ivy_ngcc__ ! . esm2015 ) . toBeUndefined ( ) ;
98+ expect ( pkg . __processed_by_ivy_ngcc__ ! . esm5 ) . toBeUndefined ( ) ;
99+ expect ( pkg . scripts ! . prepublishOnly ) . toBeDefined ( ) ;
99100
100101 markAsProcessed ( pkgUpdater , pkg , COMMON_PACKAGE_PATH , [ 'esm2015' , 'esm5' ] ) ;
101- pkg = JSON . parse ( fs . readFile ( COMMON_PACKAGE_PATH ) ) ;
102- expect ( pkg . __processed_by_ivy_ngcc__ . fesm2015 ) . toBe ( '0.0.0-PLACEHOLDER' ) ;
103- expect ( pkg . __processed_by_ivy_ngcc__ . fesm5 ) . toBe ( '0.0.0-PLACEHOLDER' ) ;
104- expect ( pkg . __processed_by_ivy_ngcc__ . esm2015 ) . toBe ( '0.0.0-PLACEHOLDER' ) ;
105- expect ( pkg . __processed_by_ivy_ngcc__ . esm5 ) . toBe ( '0.0.0-PLACEHOLDER' ) ;
106- expect ( pkg . scripts . prepublishOnly ) . toBeDefined ( ) ;
102+ pkg = JSON . parse ( fs . readFile ( COMMON_PACKAGE_PATH ) ) as EntryPointPackageJson ;
103+ expect ( pkg . __processed_by_ivy_ngcc__ ! . fesm2015 ) . toBe ( '0.0.0-PLACEHOLDER' ) ;
104+ expect ( pkg . __processed_by_ivy_ngcc__ ! . fesm5 ) . toBe ( '0.0.0-PLACEHOLDER' ) ;
105+ expect ( pkg . __processed_by_ivy_ngcc__ ! . esm2015 ) . toBe ( '0.0.0-PLACEHOLDER' ) ;
106+ expect ( pkg . __processed_by_ivy_ngcc__ ! . esm5 ) . toBe ( '0.0.0-PLACEHOLDER' ) ;
107+ expect ( pkg . scripts ! . prepublishOnly ) . toBeDefined ( ) ;
107108 } ) ;
108109
109110 it ( 'should update the packageJson object in-place' , ( ) => {
110111 const COMMON_PACKAGE_PATH = _ ( '/node_modules/@angular/common/package.json' ) ;
111112 const fs = getFileSystem ( ) ;
112113 const pkgUpdater = new DirectPackageJsonUpdater ( fs ) ;
113- const pkg = JSON . parse ( fs . readFile ( COMMON_PACKAGE_PATH ) ) ;
114+ const pkg = JSON . parse ( fs . readFile ( COMMON_PACKAGE_PATH ) ) as EntryPointPackageJson ;
114115 expect ( pkg . __processed_by_ivy_ngcc__ ) . toBeUndefined ( ) ;
115116 expect ( pkg . scripts ) . toBeUndefined ( ) ;
116117
117118 markAsProcessed ( pkgUpdater , pkg , COMMON_PACKAGE_PATH , [ 'fesm2015' , 'fesm5' ] ) ;
118- expect ( pkg . __processed_by_ivy_ngcc__ . fesm2015 ) . toBe ( '0.0.0-PLACEHOLDER' ) ;
119- expect ( pkg . __processed_by_ivy_ngcc__ . fesm5 ) . toBe ( '0.0.0-PLACEHOLDER' ) ;
120- expect ( pkg . __processed_by_ivy_ngcc__ . esm2015 ) . toBeUndefined ( ) ;
121- expect ( pkg . __processed_by_ivy_ngcc__ . esm5 ) . toBeUndefined ( ) ;
122- expect ( pkg . scripts . prepublishOnly ) . toBeDefined ( ) ;
119+ expect ( pkg . __processed_by_ivy_ngcc__ ! . fesm2015 ) . toBe ( '0.0.0-PLACEHOLDER' ) ;
120+ expect ( pkg . __processed_by_ivy_ngcc__ ! . fesm5 ) . toBe ( '0.0.0-PLACEHOLDER' ) ;
121+ expect ( pkg . __processed_by_ivy_ngcc__ ! . esm2015 ) . toBeUndefined ( ) ;
122+ expect ( pkg . __processed_by_ivy_ngcc__ ! . esm5 ) . toBeUndefined ( ) ;
123+ expect ( pkg . scripts ! . prepublishOnly ) . toBeDefined ( ) ;
123124
124125 markAsProcessed ( pkgUpdater , pkg , COMMON_PACKAGE_PATH , [ 'esm2015' , 'esm5' ] ) ;
125- expect ( pkg . __processed_by_ivy_ngcc__ . fesm2015 ) . toBe ( '0.0.0-PLACEHOLDER' ) ;
126- expect ( pkg . __processed_by_ivy_ngcc__ . fesm5 ) . toBe ( '0.0.0-PLACEHOLDER' ) ;
127- expect ( pkg . __processed_by_ivy_ngcc__ . esm2015 ) . toBe ( '0.0.0-PLACEHOLDER' ) ;
128- expect ( pkg . __processed_by_ivy_ngcc__ . esm5 ) . toBe ( '0.0.0-PLACEHOLDER' ) ;
129- expect ( pkg . scripts . prepublishOnly ) . toBeDefined ( ) ;
126+ expect ( pkg . __processed_by_ivy_ngcc__ ! . fesm2015 ) . toBe ( '0.0.0-PLACEHOLDER' ) ;
127+ expect ( pkg . __processed_by_ivy_ngcc__ ! . fesm5 ) . toBe ( '0.0.0-PLACEHOLDER' ) ;
128+ expect ( pkg . __processed_by_ivy_ngcc__ ! . esm2015 ) . toBe ( '0.0.0-PLACEHOLDER' ) ;
129+ expect ( pkg . __processed_by_ivy_ngcc__ ! . esm5 ) . toBe ( '0.0.0-PLACEHOLDER' ) ;
130+ expect ( pkg . scripts ! . prepublishOnly ) . toBeDefined ( ) ;
130131 } ) ;
131132
132133 it ( 'should one perform one write operation for all updated properties' , ( ) => {
133134 const COMMON_PACKAGE_PATH = _ ( '/node_modules/@angular/common/package.json' ) ;
134135 const fs = getFileSystem ( ) ;
135136 const pkgUpdater = new DirectPackageJsonUpdater ( fs ) ;
136137 const writeFileSpy = spyOn ( fs , 'writeFile' ) ;
137- let pkg = JSON . parse ( fs . readFile ( COMMON_PACKAGE_PATH ) ) ;
138+ let pkg = JSON . parse ( fs . readFile ( COMMON_PACKAGE_PATH ) ) as EntryPointPackageJson ;
138139
139140 markAsProcessed (
140141 pkgUpdater , pkg , COMMON_PACKAGE_PATH , [ 'fesm2015' , 'fesm5' , 'esm2015' , 'esm5' ] ) ;
@@ -146,34 +147,34 @@ runInEachFileSystem(() => {
146147 const fs = getFileSystem ( ) ;
147148 const pkgUpdater = new DirectPackageJsonUpdater ( fs ) ;
148149 const prepublishOnly = 'existing script' ;
149- let pkg = JSON . parse ( fs . readFile ( COMMON_PACKAGE_PATH ) ) ;
150+ let pkg = JSON . parse ( fs . readFile ( COMMON_PACKAGE_PATH ) ) as EntryPointPackageJson ;
150151 pkg . scripts = { prepublishOnly} ;
151152
152153 markAsProcessed ( pkgUpdater , pkg , COMMON_PACKAGE_PATH , [ 'fesm2015' ] ) ;
153- pkg = JSON . parse ( fs . readFile ( COMMON_PACKAGE_PATH ) ) ;
154- expect ( pkg . scripts . prepublishOnly ) . toContain ( 'This is not allowed' ) ;
155- expect ( pkg . scripts . prepublishOnly__ivy_ngcc_bak ) . toBe ( prepublishOnly ) ;
154+ pkg = JSON . parse ( fs . readFile ( COMMON_PACKAGE_PATH ) ) as EntryPointPackageJson ;
155+ expect ( pkg . scripts ! . prepublishOnly ) . toContain ( 'This is not allowed' ) ;
156+ expect ( pkg . scripts ! . prepublishOnly__ivy_ngcc_bak ) . toBe ( prepublishOnly ) ;
156157 } ) ;
157158
158159 it ( `should not keep backup of overwritten 'prepublishOnly' script` , ( ) => {
159160 const COMMON_PACKAGE_PATH = _ ( '/node_modules/@angular/common/package.json' ) ;
160161 const fs = getFileSystem ( ) ;
161162 const pkgUpdater = new DirectPackageJsonUpdater ( fs ) ;
162- let pkg = JSON . parse ( fs . readFile ( COMMON_PACKAGE_PATH ) ) ;
163+ let pkg = JSON . parse ( fs . readFile ( COMMON_PACKAGE_PATH ) ) as EntryPointPackageJson ;
163164
164165 markAsProcessed ( pkgUpdater , pkg , COMMON_PACKAGE_PATH , [ 'fesm2015' ] ) ;
165166
166- pkg = JSON . parse ( fs . readFile ( COMMON_PACKAGE_PATH ) ) ;
167- expect ( pkg . scripts . prepublishOnly ) . toContain ( 'This is not allowed' ) ;
168- expect ( pkg . scripts . prepublishOnly__ivy_ngcc_bak ) . toBeUndefined ( ) ;
167+ pkg = JSON . parse ( fs . readFile ( COMMON_PACKAGE_PATH ) ) as EntryPointPackageJson ;
168+ expect ( pkg . scripts ! . prepublishOnly ) . toContain ( 'This is not allowed' ) ;
169+ expect ( pkg . scripts ! . prepublishOnly__ivy_ngcc_bak ) . toBeUndefined ( ) ;
169170
170171 // Running again, now that there is `prepublishOnly` script (created by `ngcc`), it should
171172 // still not back it up as `prepublishOnly__ivy_ngcc_bak`.
172173 markAsProcessed ( pkgUpdater , pkg , COMMON_PACKAGE_PATH , [ 'fesm2015' ] ) ;
173174
174- pkg = JSON . parse ( fs . readFile ( COMMON_PACKAGE_PATH ) ) ;
175- expect ( pkg . scripts . prepublishOnly ) . toContain ( 'This is not allowed' ) ;
176- expect ( pkg . scripts . prepublishOnly__ivy_ngcc_bak ) . toBeUndefined ( ) ;
175+ pkg = JSON . parse ( fs . readFile ( COMMON_PACKAGE_PATH ) ) as EntryPointPackageJson ;
176+ expect ( pkg . scripts ! . prepublishOnly ) . toContain ( 'This is not allowed' ) ;
177+ expect ( pkg . scripts ! . prepublishOnly__ivy_ngcc_bak ) . toBeUndefined ( ) ;
177178 } ) ;
178179 } ) ;
179180
0 commit comments