Skip to content

Commit

Permalink
feat: define patch path based on data/releases.json
Browse files Browse the repository at this point in the history
  • Loading branch information
DaRaFF committed Feb 22, 2023
1 parent 21366ec commit c1e67f1
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
2 changes: 1 addition & 1 deletion cli.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env node
console.log('release-notes-patch -> v1.5.9 (beautify data/releases.json)')
console.log('release-notes-patch -> v1.6.0 (define patch path based on data/releases.json)')
const argv = require('yargs')
.demandOption(['token', 'owner', 'repo', 'sha', 'tag'])
.help(false)
Expand Down
13 changes: 13 additions & 0 deletions get-release-notes-overview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const _ = require('lodash')
const getReleaseNote = require('./lib/get-release-note')
const targetOwner = 'livingdocsIO'
const targetRepo = 'documentation'

module.exports = async ({token} = {}) => {
const path = `data/releases.json`
const releaseNote = await getReleaseNote({owner: targetOwner, repo: targetRepo, path, token})

// base64 to string
const originContent = JSON.parse(Buffer.from(releaseNote.content, 'base64').toString('utf8'))
return originContent
}
14 changes: 7 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const addPatchToReleaseNote = require('./lib/add-patch-to-release-note')
const addPatchToUpcomingReleaseNote = require('./lib/add-patch-to-upcoming-release-note')
const updateContent = require('./lib/git/update-content')
const patchReleaseNotesOverview = require('./patch-release-notes-overview')
const getReleaseNotesOverview = require('./get-release-notes-overview')


const createBranchList = require('./lib/create-branch-list')
Expand All @@ -18,7 +19,6 @@ branches.push('master')

const targetOwner = 'livingdocsIO'
const targetRepo = 'documentation'
const targetBasePath = 'content/operations/releases'


// main application
Expand All @@ -28,8 +28,10 @@ module.exports = async ({token, owner, repo, sha, tag, test = false} = {}) => {
return `commit ${sha} not found in ${owner}/${repo} in the white listed release branches \n\r${branches.join('\n\r')}`
}

// 'content/operations/releases/release-2021-03.md'
const path = `${targetBasePath}/${release.branchName}.md`
// get release notes overview from documentation repo (data/releases.json)
// path = 'content/operations/releases/release-2021-03.md'
const releaseNotesOverview = await getReleaseNotesOverview({token})
const path = `content${releaseNotesOverview[release.branchName].ref}`
const releaseNote = await getReleaseNote({owner: targetOwner, repo: targetRepo, path, token})

// base64 to string
Expand Down Expand Up @@ -72,8 +74,7 @@ module.exports = async ({token, owner, repo, sha, tag, test = false} = {}) => {
path,
message: `fix(${release.branchName}): add patch to ${release.branchName}.md with tag ${tag}`,
content: patchedBase64ReleaseNotes,
sha: releaseNote.sha,
branch: branchName
sha: releaseNote.sha
})

// update release notes overview
Expand All @@ -84,8 +85,7 @@ module.exports = async ({token, owner, repo, sha, tag, test = false} = {}) => {
path: 'data/releases.json',
message: `fix(${release.branchName}): update release notes overview for ${release.branchName} for ${repo} with tag ${tag}`,
content: patchedBase64ReleaseNotesOverview,
sha: releaseNotesOverviewSha,
branch: branchName
sha: releaseNotesOverviewSha
})

return `update of release-notes with tag ${tag} at ${releaseNote.html_url} sucessfull\n\n` +
Expand Down

0 comments on commit c1e67f1

Please sign in to comment.