3
3
import fs from 'fs' ;
4
4
import chalk from 'chalk' ;
5
5
import execa from 'execa' ;
6
- // @ts -ignore Not typed
7
6
import editJsonFile from 'edit-json-file' ;
8
7
import { prompt } from 'enquirer' ;
9
8
import { Path } from '@beemo/core' ;
@@ -28,8 +27,8 @@ async function copyAndInstallDepsFromModule(
28
27
isYarn : boolean ,
29
28
isMonorepo : boolean ,
30
29
) {
31
- const pkg = require ( `${ moduleName } /package.json` ) ;
32
- const deps = Object . keys ( pkg . dependencies ) . filter (
30
+ const pkg : NimbusPackage = require ( `${ moduleName } /package.json` ) ;
31
+ const deps = Object . keys ( pkg . dependencies || { } ) . filter (
33
32
( dep ) => ! dep . includes ( '@beemo' ) && ! dep . includes ( '@airbnb/nimbus' ) ,
34
33
) ;
35
34
@@ -75,7 +74,7 @@ function migrateDotfiles() {
75
74
76
75
function migratePackageScripts ( nimbus : NimbusPackage [ 'nimbus' ] ) {
77
76
const pkg = editJsonFile ( pkgPath ) ;
78
- const scripts = pkg . get ( 'scripts' ) || { } ;
77
+ const scripts = pkg . get < NimbusPackage [ 'scripts' ] > ( 'scripts' ) ?? { } ;
79
78
const srcFolder = nimbus . settings . srcFolder || 'src' ;
80
79
const testFolder = nimbus . settings . testFolder || 'test' ;
81
80
@@ -142,7 +141,7 @@ function migrateEslint() {
142
141
143
142
function migrateJest ( ) {
144
143
const configPath = Path . resolve ( 'jest.config.js' ) . path ( ) ;
145
- const config = require ( configPath ) ;
144
+ const config : { [ key : string ] : unknown } = require ( configPath ) ;
146
145
147
146
delete config . moduleNameMapper ;
148
147
delete config . setupFiles ;
@@ -184,7 +183,7 @@ export async function eject() {
184
183
console . log ( BANNER ) ;
185
184
console . log ( `${ chalk . cyan ( '[1/5]' ) } Ejecting Nimbus` ) ;
186
185
187
- const nimbus = editJsonFile ( pkgPath ) . get ( 'nimbus' ) ;
186
+ const nimbus = editJsonFile ( pkgPath ) . get < NimbusPackage [ 'nimbus' ] > ( 'nimbus' ) ;
188
187
189
188
if ( ! nimbus ) {
190
189
throw new Error ( "Project isn't Nimbus enabled." ) ;
0 commit comments