@@ -8,7 +8,6 @@ const util = require('util')
88
99const writeFile = util . promisify ( fs . writeFile )
1010const mkdir = util . promisify ( fs . mkdir )
11- const exec = util . promisify ( require ( 'child_process' ) . exec )
1211
1312const chalk = require ( 'chalk' )
1413
@@ -88,21 +87,11 @@ async function status ({ repoPath, migrations }) {
8887 return `${ statusString } \nCurrent repo version: ${ version } \nLatest migration version: ${ lastMigrationVersion } `
8988}
9089
91- async function getAuthor ( ) {
92- try {
93- const name = ( await exec ( 'git config --get user.name' ) ) . stdout
94- const email = ( await exec ( 'git config --get user.email' ) ) . stdout
95- return `${ name . replace ( '\n' , '' ) } <${ email . replace ( '\n' , '' ) } >`
96- } catch ( e ) {
97- return ''
98- }
99- }
100-
10190async function add ( { empty } ) {
10291 const newMigrationVersion = migrator . getLatestMigrationVersion ( ) + 1
10392 const newMigrationFolder = path . join ( __dirname , '..' , 'migrations' , 'migration-' + newMigrationVersion )
10493
105- const migrationsImport = migrations . map ( ( migration ) => migration . empty ? ` Object.assign({version: ${ migration . version } }, emptyMigration),` : ` require('./migration-${ migration . version } '),` )
94+ const migrationsImport = migrations . map ( ( migration ) => migration . empty ? ` Object.assign({version: ${ parseInt ( migration . version ) } }, emptyMigration),` : ` require('./migration-${ parseInt ( migration . version ) } '),` )
10695 if ( empty ) {
10796 migrationsImport . push ( ` Object.assign({version: ${ newMigrationVersion } }, emptyMigration),` )
10897 } else {
@@ -116,11 +105,6 @@ async function add ({ empty }) {
116105
117106 await mkdir ( newMigrationFolder )
118107
119- const packageJsonContent = templates . packageJson
120- . replace ( / { { version} } / gi, newMigrationVersion )
121- . replace ( / { { author} } / gi, await getAuthor ( ) )
122- await writeFile ( path . join ( newMigrationFolder , 'package.json' ) , packageJsonContent )
123-
124108 const indexJsContent = templates . indexJs
125109 . replace ( / { { version} } / gi, newMigrationVersion )
126110 await writeFile ( path . join ( newMigrationFolder , 'index.js' ) , indexJsContent )
0 commit comments