Skip to content
This repository was archived by the owner on Oct 1, 2021. It is now read-only.

Commit 20d7e77

Browse files
committed
fix: update add command
1 parent 6996b6f commit 20d7e77

File tree

2 files changed

+2
-36
lines changed

2 files changed

+2
-36
lines changed

src/commands.js

+1-16
Original file line numberDiff line numberDiff line change
@@ -88,21 +88,11 @@ async function status ({ repoPath, migrations }) {
8888
return `${statusString}\nCurrent repo version: ${version}\nLatest migration version: ${lastMigrationVersion}`
8989
}
9090

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-
10191
async function add ({ empty }) {
10292
const newMigrationVersion = migrator.getLatestMigrationVersion() + 1
10393
const newMigrationFolder = path.join(__dirname, '..', 'migrations', 'migration-' + newMigrationVersion)
10494

105-
const migrationsImport = migrations.map((migration) => migration.empty ? ` Object.assign({version: ${migration.version}}, emptyMigration),` : ` require('./migration-${migration.version}'),`)
95+
const migrationsImport = migrations.map((migration) => migration.empty ? ` Object.assign({version: ${parseInt(migration.version)}}, emptyMigration),` : ` require('./migration-${parseInt(migration.version)}'),`)
10696
if (empty) {
10797
migrationsImport.push(` Object.assign({version: ${newMigrationVersion}}, emptyMigration),`)
10898
} else {
@@ -116,11 +106,6 @@ async function add ({ empty }) {
116106

117107
await mkdir(newMigrationFolder)
118108

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-
124109
const indexJsContent = templates.indexJs
125110
.replace(/{{version}}/gi, newMigrationVersion)
126111
await writeFile(path.join(newMigrationFolder, 'index.js'), indexJsContent)

src/migration-templates.js

+1-20
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,6 @@
11
'use strict'
22

33
module.exports = {
4-
packageJson: `{
5-
"name": "ipfs-repo-migration-{{version}}",
6-
"version": "0.1.0",
7-
"description": "Migration",
8-
"author": "{{author}}",
9-
"main": "index.js",
10-
"files": [
11-
"index.js",
12-
"node_modules"
13-
],
14-
"engines": {
15-
"node": ">=10.0.0",
16-
"npm": ">=3.0.0"
17-
},
18-
"dependencies": {
19-
},
20-
"license": "MIT"
21-
}`,
22-
234
indexJs: `'use strict'
245
256
const Datastore = require('datastore-fs')
@@ -41,7 +22,7 @@ async function revert(repoPath, options, isBrowser) {
4122
store.open()
4223
4324
try {
44-
// Your reversion of migration (if supported)
25+
// Your reversion of migration (if supported, if not delete this function!!!)
4526
} finally {
4627
await store.close()
4728
}

0 commit comments

Comments
 (0)