Skip to content

Commit

Permalink
Merge pull request #3 from AtidaTech/release-0.1.1
Browse files Browse the repository at this point in the history
Release 0.1.1
  • Loading branch information
fciacchi authored Jun 7, 2023
2 parents 9857530 + 70fe6b5 commit 3f77288
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 26 deletions.
48 changes: 25 additions & 23 deletions contentful-cli-migrations.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,6 @@ const DEFAULT_FIRST_MIGRATION = '0001-create-counter-content-type.cjs'
latestMigrationNumber,
migrationArray
)

if (parsedArguments?.shouldInitialise) {
await createCounterEntry(environmentSingleton)
}
} catch (error) {
console.error('@@/ERROR:', error)
}
Expand Down Expand Up @@ -447,7 +443,9 @@ async function parseMigrationsToRun(parsedArguments, latestMigrationNumber) {
const fileSystem = await import('fs')
const folderMigrationScript = parsedArguments?.rootDestinationFolder

let files = fileSystem.readdirSync(folderMigrationScript)
const allFiles = fileSystem.readdirSync(folderMigrationScript)
const files = allFiles.filter(item => !/(^|\/)\.[^/.]/g.test(item))

let migrationArray = []
let indexObject = []
let arrayLength = files.length
Expand Down Expand Up @@ -558,24 +556,28 @@ async function performMigrations(
.then(async () => {
console.log('##/INFO: Migration ' + migrationScript + ' Done!')

// Update counter value
latestMigrationNumber++

// Write new Count into Entry
const fieldId = parsedArguments?.counterFieldId
const fieldLocale = parsedArguments?.counterLocale
const entrySavingCounter = await environmentSingleton.getEntry(
parsedArguments?.counterEntryId
)

entrySavingCounter.fields[fieldId][
fieldLocale
] = `${latestMigrationNumber}`

entrySavingCounter
.update()
.then(callback())
.catch(e => console.error('@@/ERROR: ' + e))
if (!parsedArguments?.shouldInitialise) {
// Update counter value
latestMigrationNumber++

// Write new Count into Entry
const fieldId = parsedArguments?.counterFieldId
const fieldLocale = parsedArguments?.counterLocale
const entrySavingCounter = await environmentSingleton.getEntry(
parsedArguments?.counterEntryId
)

entrySavingCounter.fields[fieldId][
fieldLocale
] = `${latestMigrationNumber}`

entrySavingCounter
.update()
.then(callback())
.catch(e => console.error('@@/ERROR: ' + e))
} else {
await createCounterEntry(environmentSingleton)
}
})
.catch(e =>
console.error(
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "contentful-cli-migrations",
"version": "0.1.0",
"version": "0.1.1",
"type": "module",
"description": "Contentful CLI Migration Tool",
"homepage": "https://github.com/AtidaTech/contentful-cli-migrations",
Expand Down

0 comments on commit 3f77288

Please sign in to comment.