Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function deployDocs (packageName, currentVersion, config = {}) {
setupGit()
if (isReleaseCommit(currentVersion)) {
checkWorkingDirectory()
info(`📖 Deploying documentation for ${currentVersion} of ${packageName}...`)
try {
publishGithubPages(config)
} catch (err) {
error(err)
process.exit(1)
}
info(`📖 Documentation for ${currentVersion} of ${packageName} was successfully deployed!`)
} else {
info(`📦 Not on a release commit--skipping documentation publish.`)
}
}
checkIfGitTagExists(currentVersion)
checkIfCommitIsReviewed()
info(`📦 Currently on release commit for ${currentVersion} of ${packageName}.`)
versionToRelease = currentVersion
tag = preidAndTag || 'latest'
} else {
info(`📦 Not on a release commit--publishing a pre-release...`)
versionToRelease = 'prerelease'
tag = preidAndTag || 'rc'
}
let releasedVersion
try {
releasedVersion = await publishPackages(packageName, versionToRelease, tag)
} catch (e) {
error(e)
process.exit(1)
}
if (GERRIT_CHANGE_NUMBER && GERRIT_PATCHSET_NUMBER) {
try {
await postGerritReview(
`${GERRIT_CHANGE_NUMBER},${GERRIT_PATCHSET_NUMBER}`,
`Successfully published ${releasedVersion} for this commit.`
)
process.exit(0)
} catch (e) {
error(e)
process.exit(1)
}
}
}
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
const { error } = require('@instructure/command-utils')
const { lintCommitMessage } = require('./utils/git')
try {
lintCommit()
} catch (err) {
error(err)
process.exit(1)
}
async function lintCommit () {
const isValid = lintCommitMessage()
if (isValid) {
process.exit(0)
} else {
error('(See https://www.npmjs.com/package/conventional-changelog-angular)')
process.exit(1)
}
}
exports.checkWorkingDirectory = function checkWorkingDirectory () {
let result
try {
result = runGitCommand(['status', '--porcelain'])
} catch (e) {
error(e)
process.exit(1)
}
if (result) {
error(`Refusing to operate on unclean working directory!`)
error(result)
process.exit(1)
}
}
async function lintCommit () {
const isValid = lintCommitMessage()
if (isValid) {
process.exit(0)
} else {
error('(See https://www.npmjs.com/package/conventional-changelog-angular)')
process.exit(1)
}
}
const executeCodemods = ({ sourcePath, configPaths, codemodName, ignore }) => {
try {
const codemodPath = require.resolve(`@instructure/ui-codemods/lib/${codemodName}`)
for (const configPath of configPaths) {
executeCodemod({ sourcePath, codemodPath, configPath, ignore })
}
} catch (err) {
error(err)
process.exit(1)
}
}
return Promise.all(getPackages().map(async pkg => {
if (pkg.private) {
info(`${pkg.name} is private.`)
} else {
const toTag = `${pkg.name}@${versionToTag}`
info(`📦 Running 'dist-tag ${command} ${toTag} ${tag}'...`)
try {
await runCommandAsync('npm', ['dist-tag', command, toTag, tag])
} catch (err) {
error(err)
}
info(`📦 ${toTag} tags were successfully updated!`)
}
}))
}
gerritClient().review(target, { message, labels }, (err) => {
if (err) {
error(`An error occured posting a gerrit review for ${target}.`)
error(err)
reject(err)
}
resolve()
})
})
'text': message + issues,
'link_names': 1
}
const req = https.request({
path: `/services/${SLACK_WEBHOOK}`,
hostname: 'hooks.slack.com',
method: 'POST'
})
req.write(JSON.stringify(payload))
req.end()
info(`💬 Posted Slack Message: "${message + issues}"`)
} else if (config.slack_channel && !SLACK_WEBHOOK) {
error(`'SLACK_WEBHOOK' env variable isn't set for ${config.slack_channel}!`)
}
}