Skip to content

Commit

Permalink
system for publishing/unpublishing all
Browse files Browse the repository at this point in the history
  • Loading branch information
arshaw committed Mar 15, 2019
1 parent f77f237 commit 336d05f
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 4 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,3 @@ tmp
node_modules
npm-debug.log
package-lock.json

# temporary
bin/publish-release-all.sh
39 changes: 39 additions & 0 deletions bin/publish-release-all.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env node

const path = require('path')
const shell = require('shelljs')
const tsConfig = require(path.resolve(__dirname, '../tsconfig.json'))
const packagePaths = tsConfig.compilerOptions.paths
const publishScript = path.resolve(__dirname, 'publish-release.sh')

let version = process.argv[2] // first arg starts at index 2
let releaseTag = process.argv[3]
let productionStr = process.argv[4]

if (!version) {
console.log('Must enter a version')
process.exit(1)
}

if (!releaseTag) {
console.log('Must enter a release tag')
process.exit(1)
}

if (productionStr && productionStr !== '--production') {
console.log('Invalid production flag')
process.exit(1)
}

for (let packageName in packagePaths) {
let jsPath = packagePaths[packageName][0]

if (jsPath.match(/^src\//)) { // one of our lib files
let srcPath = path.dirname(jsPath)
let packageDirName = path.basename(srcPath) // :(

shell.exec(publishScript + ' ' + [
packageDirName, version, releaseTag, productionStr
].join(' '))
}
}
2 changes: 1 addition & 1 deletion bin/publish-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fi

if [[ "$release_tag" != "latest" ]] && [[ "$release_tag" != "beta" ]] && [[ "$release_tag" != "alpha" ]]
then
echo "Invalid third argument scope '$release_tag'. Aborting."
echo "Invalid third argument release tag '$release_tag'. Aborting."
exit 1
fi

Expand Down
35 changes: 35 additions & 0 deletions bin/unpublish-release-all.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env node

const path = require('path')
const shell = require('shelljs')
const tsConfig = require(path.resolve(__dirname, '../tsconfig.json'))
const packagePaths = tsConfig.compilerOptions.paths

let version = process.argv[2] // first arg starts at index 2
let productionStr = process.argv[3]
let npmRegistryStr

if (!version) {
console.log('Must enter a version')
process.exit(1)
}

if (!productionStr) {
npmRegistryStr = '--registry http://localhost:4873' // TODO: make dry. in publish-release.sh also
} else if (productionStr === '--production') {
npmRegistryStr = ''
} else {
console.log('Invalid production flag')
process.exit(1)
}

console.log('Deleting git tag...')
shell.exec('git tag -d v' + version)

for (let packageName in packagePaths) {
let jsPath = packagePaths[packageName][0]

if (jsPath.match(/^src\//)) { // one of our lib files
shell.exec('npm unpublish ' + packageName + '@' + version + ' ' + npmRegistryStr)
}
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"rollup-plugin-node-resolve": "^4.0.0",
"rollup-plugin-sourcemaps": "^0.4.2",
"rrule": "^2.6.0",
"shelljs": "^0.8.3",
"tslib": "^1.9.3",
"tslint": "^5.12.1",
"tslint-config-standard": "^7.1.0",
Expand Down

0 comments on commit 336d05f

Please sign in to comment.