Skip to content

Commit

Permalink
updated classic release to use the new bulk deploy to CI/CD and merge…
Browse files Browse the repository at this point in the history
… to public
  • Loading branch information
barduinor committed Sep 18, 2023
1 parent 330721b commit c73e2d1
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 16 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
"prebuild:all": "yarn prebuild",
"convert": "node -e 'require(\"./src/scripts/convert.js\").convert()'",
"convert:all": "node -e 'require(\"./src/scripts/convert.js\").convertAll()'",
"x_prerelease": "yarn build",
"x_prerelease:all": "yarn build:all",
"prerelease": "yarn build:all",
"prerelease:all": "yarn build:all",
"release": "node -e 'require(\"./src/scripts/release.js\").release()'",
"release:all": "node -e 'require(\"./src/scripts/release.js\").releaseAll()'",
"build": "yarn convert",
Expand Down
31 changes: 21 additions & 10 deletions src/DeployBulk.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,34 @@
// const pmConvert = require('./PostmanCovertions')
const pmAPI = require('./postmanAPI')

const deployColectionHead = async (localCollection, remoteCollectionID) => {
const deployColectionHead = async (privateRemoteCollectionID, localCollection) => {
const collectionHead = { ...localCollection }
collectionHead.item = []
const msg = `\nDeploying collection head ${collectionHead.info.name} to ${remoteCollectionID}`
await new pmAPI.Collection(remoteCollectionID)
.update(collectionHead)
const msg = `\nDeploying collection head ${collectionHead.info.name} to ${privateRemoteCollectionID}`
console.log(msg + '...')
await new pmAPI.Collection(privateRemoteCollectionID)
.update({ collection: collectionHead })
.then(() => { console.log(msg, '-> OK\n') })
.catch((error) => {
console.log(msg, '-> FAIL')
handlePostmanAPIError(error)
})
}

const deployColectionFull = async (localCollection, remoteCollectionID) => {
const msg = `\nDeploying full collection ${localCollection.info.name} to ${remoteCollectionID}`
await new pmAPI.Collection(remoteCollectionID)
.update(localCollection)
const deployColectionFull = async (privateRemoteCollectionId, localCollection, publicRemoteCollectionId) => {
let msg = `\nDeploying full collection ${localCollection.info.name} to ${privateRemoteCollectionId}`
console.log(msg + '...')
await new pmAPI.Collection(privateRemoteCollectionId)
.update({ collection: localCollection })
.then(() => { console.log(msg, '-> OK\n') })
.catch((error) => {
console.log(msg, '-> FAIL')
handlePostmanAPIError(error)
})

msg = 'Merging to public collection'
console.log('\n' + msg + '...')
await new pmAPI.Collection(privateRemoteCollectionId).merge(publicRemoteCollectionId)
.then(() => { console.log(msg, '-> OK\n') })
.catch((error) => {
console.log(msg, '-> FAIL')
Expand All @@ -40,8 +51,8 @@ const handlePostmanAPIError = (error) => {
console.log('CAUSE:', error.cause)
}
}
const { method, url, data } = error.config
console.log('REQUEST DETAILS', { method, url, data })
// const { method, url, data } = error.config
// console.log('REQUEST DETAILS', { method, url, data })
process.exit(1)
}

Expand Down
11 changes: 7 additions & 4 deletions src/scripts/release.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
require('dotenv').config()

const fs = require('fs')
const oldDeploy = require('../OldDeployBulk')
// const oldDeploy = require('../OldDeployBulk')
const deployBulk = require('../DeployBulk')
const OUTPUT_FOLDER = './compiled'

const release = async (locale = process.argv[1]) => {
const collection = JSON.parse(fs.readFileSync(`${OUTPUT_FOLDER}/collection.${locale}.json`).toString())
// const privateRemoteCollectionID = process.env[`PRIVATE_${locale.toUpperCase()}_POSTMAN_COLLECTION_ID`]
const publicRemoteCollectionID = process.env[`PUBLIC_${locale.toUpperCase()}_POSTMAN_COLLECTION_ID`]
const privateRemoteCollectionId = process.env[`PRIVATE_${locale.toUpperCase()}_POSTMAN_COLLECTION_ID`]
const publicRemoteCollectionId = process.env[`PUBLIC_${locale.toUpperCase()}_POSTMAN_COLLECTION_ID`]

oldDeploy.oldDeployBulk(publicRemoteCollectionID, collection, publicRemoteCollectionID)
// oldDeploy.oldDeployBulk(publicRemoteCollectionID, collection, publicRemoteCollectionID)
await deployBulk.deployColectionHead(privateRemoteCollectionId, collection)
await deployBulk.deployColectionFull(privateRemoteCollectionId, collection, publicRemoteCollectionId)
}

const releaseAll = async () => {
Expand Down

0 comments on commit c73e2d1

Please sign in to comment.