Skip to content

Commit

Permalink
Change git-tag-versions
Browse files Browse the repository at this point in the history
* No longer depends on npm registry
* Depends only on available git tags
  • Loading branch information
KSXGitHub committed May 11, 2018
1 parent 626d504 commit a320763
Showing 1 changed file with 19 additions and 22 deletions.
41 changes: 19 additions & 22 deletions sh/git-tag-versions.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as path from 'path'
import * as process from 'process'
import * as childProcess from 'child_process'
import * as wrkspc from 'nested-workspace-helper.private'
import {Repository} from 'git-ts'
import {listAllPackages} from 'nested-workspace-helper.private'

main().then(
code => process.exit(code),
Expand All @@ -13,30 +12,28 @@ main().then(

async function main (): Promise<number> {
const projdir = path.resolve(__dirname, '..')
const {publishables} = await wrkspc.classifyPublishability(projdir)
const pkgs = await listAllPackages(projdir)
const tagman = new Repository.Tags(projdir)
const allTags = tagman.getAllTags()

let finalStatus = 0
for (const item of publishables) {
const {name, version} = item.manifestContent
const tag = `${name}-v${version}`
console.info(`$ git tag ${tag}`)
let fails = 0
for (const {manifestContent} of pkgs) {
const {name, version, private: prv} = manifestContent
if (prv) continue
if (!name) continue

const {error, signal, status} = childProcess.spawnSync(
'git',
['tag', tag],
{
cwd: projdir,
stdio: 'inherit'
}
)
const tag = `${name}-v${version}`
if (allTags.includes(tag)) continue

if (error) throw error
console.info(`$ git tag ${tag}`)

if (status) {
console.error({signal, status})
finalStatus |= status
try {
tagman.addTag(tag)
} catch (error) {
console.error(error)
++fails
}
}

return finalStatus
return fails
}

0 comments on commit a320763

Please sign in to comment.