Răsfoiți Sursa

system for publishing/unpublishing all

Adam Shaw 7 ani în urmă
părinte
comite
336d05f2b2
5 a modificat fișierele cu 76 adăugiri și 4 ștergeri
  1. 0 3
      .gitignore
  2. 39 0
      bin/publish-release-all.js
  3. 1 1
      bin/publish-release.sh
  4. 35 0
      bin/unpublish-release-all.js
  5. 1 0
      package.json

+ 0 - 3
.gitignore

@@ -8,6 +8,3 @@ tmp
 node_modules
 npm-debug.log
 package-lock.json
-
-# temporary
-bin/publish-release-all.sh

+ 39 - 0
bin/publish-release-all.js

@@ -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(' '))
+  }
+}

+ 1 - 1
bin/publish-release.sh

@@ -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
 

+ 35 - 0
bin/unpublish-release-all.js

@@ -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 - 0
package.json

@@ -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",