@hubspot/cms-lib
Advanced tools
Comparing version 2.1.1-beta.8 to 2.1.1-beta.9
@@ -209,2 +209,17 @@ const fs = require('fs-extra'); | ||
/** | ||
* Moves file from srcPath to destPath | ||
* | ||
* @async | ||
* @param {number} portalId | ||
* @param {string} srcPath | ||
* @param {string} destPath | ||
* @returns {Promise} | ||
*/ | ||
async function moveFile(portalId, srcPath, destPath) { | ||
return http.put(portalId, { | ||
uri: `${FILE_MAPPER_API_PATH}/rename/${srcPath}?path=${destPath}`, | ||
}); | ||
} | ||
/** | ||
* Get directory contents | ||
@@ -232,3 +247,4 @@ * | ||
createFileMapperNodeFromStreamResponse, | ||
moveFile, | ||
getDirectoryContentsByPath, | ||
}; |
@@ -98,2 +98,4 @@ const ENVIRONMENTS = { | ||
const FOLDER_DOT_EXTENSIONS = ['functions', 'module']; | ||
module.exports = { | ||
@@ -119,2 +121,3 @@ Mode, | ||
MARKETPLACE_FOLDER, | ||
FOLDER_DOT_EXTENSIONS, | ||
}; |
const moment = require('moment'); | ||
const util = require('util'); | ||
const { logger } = require('../logger'); | ||
const formatCompactOutput = func => { | ||
return `${func.method}\t/${func.route}`; | ||
const getFunctionArrays = resp => { | ||
return resp.objects.map(func => { | ||
const { route, method, created, updated, secretNames } = func; | ||
return [ | ||
route, | ||
method, | ||
secretNames.join(', '), | ||
moment(created).format(), | ||
moment(updated).format(), | ||
]; | ||
}); | ||
}; | ||
const formatFullOutput = func => { | ||
return `/${func.route}\nMethod: ${func.method}\nSecrets: ${util.inspect( | ||
func.secretNames, | ||
{ | ||
colors: true, | ||
compact: true, | ||
depth: 'Infinity', | ||
} | ||
)}\nCreated: ${func.created} (${moment(func.created).format()})\nUpdated: ${ | ||
func.updated | ||
} (${moment(func.updated).format()})\n`; | ||
}; | ||
const formatFunctionOutput = (func, options) => { | ||
if (options.compact) { | ||
return formatCompactOutput(func); | ||
} | ||
return formatFullOutput(func); | ||
}; | ||
const processFunction = (func, options) => { | ||
try { | ||
return formatFunctionOutput(func, options); | ||
} catch (e) { | ||
logger.error(`Unable to process log ${JSON.stringify(func)}`); | ||
} | ||
}; | ||
const processOutput = (resp, options) => { | ||
if (!resp || (resp.objects && !resp.objects.length)) { | ||
return 'No functions found.'; | ||
} else if (resp.objects && resp.objects.length) { | ||
return resp.objects | ||
.map(func => { | ||
return processFunction(func, options); | ||
}) | ||
.join('\n'); | ||
} | ||
return processFunction(resp, options); | ||
}; | ||
const outputFunctions = (resp, options) => { | ||
if (options.json) { | ||
return logger.log(resp.objects); | ||
} | ||
return logger.log(processOutput(resp, options)); | ||
}; | ||
module.exports = { | ||
outputFunctions, | ||
getFunctionArrays, | ||
}; |
{ | ||
"name": "@hubspot/cms-lib", | ||
"version": "2.1.1-beta.8", | ||
"version": "2.1.1-beta.9", | ||
"description": "Library for working with the HubSpot CMS", | ||
@@ -34,3 +34,3 @@ "license": "Apache-2.0", | ||
}, | ||
"gitHead": "f47853ac23af22419e88e373f856f86b5a37ee85" | ||
"gitHead": "ce313232e636e55ae57debccb46462d522c2b679" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
276587
8880