* First run of script * Get the app running --- ish * Get NextJS working * Remove `node:` * Get more tests passing in unit directory * Update FailBot test to use nock * Update test.yml * Update Dockerfile * tests/content fixes * Update page.js * Update build-changelog.js * updating tests/routing * Update orphan-tests.js * updating tests/rendering * Update .eslintrc.js * Update .eslintrc.js * Install jest/globals * "linting" tests * staging update to server.mjs * Change '.github/allowed-actions.js' to a ESM export * Lint * Fixes for the main package.json * Move Jest to be last in the npm test command so we can pass args * Just use 'npm run lint' in the npm test command * update algolia label script * update openapi script * update require on openapi * Update enterprise-algolia-label.js * forgot JSON.parse * Update lunr-search-index.js * Always explicitly include process.cwd() for JSON file reads pathed from project root * update graphql/update-files.js script * Update other npm scripts using jest to pass ESM NODE_OPTIONS * Update check-for-enterprise-issues-by-label.js for ESM * Update create-enterprise-issue.js for ESM * Import jest global for browser tests * Convert 'script/deploy' to ESM Co-authored-by: Grace Park <gracepark@github.com> Co-authored-by: James M. Greene <jamesmgreene@github.com>
65 lines
2.0 KiB
JavaScript
Executable File
65 lines
2.0 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
import fs from 'fs'
|
|
import xMkdirp from 'mkdirp'
|
|
import path from 'path'
|
|
import program from 'commander'
|
|
import allVersions from '../../lib/all-versions.js'
|
|
|
|
const mkdirp = xMkdirp.sync
|
|
const payloadsDir = 'lib/webhooks/static'
|
|
|
|
// [start-readme]
|
|
//
|
|
// This script creates new static webhook payload files for a new version.
|
|
//
|
|
// [end-readme]
|
|
|
|
program
|
|
.description('Create new payload files in lib/webhooks/static/<new_version> based on an existing version.')
|
|
.option('-n, --newVersion <version>', 'The version to copy the payloads to. Must be in <plan@release> format.')
|
|
.option('-o, --oldVersion <version>', 'The version to copy the payloads from. Must be in <plan@release> format.')
|
|
.parse(process.argv)
|
|
|
|
const newVersion = program.opts().newVersion
|
|
const oldVersion = program.opts().oldVersion
|
|
|
|
if (!(newVersion && oldVersion)) {
|
|
console.log('Error! You must provide --newVersion and --oldVersion.')
|
|
process.exit(1)
|
|
}
|
|
|
|
if (!(Object.keys(allVersions).includes(newVersion) && Object.keys(allVersions).includes(oldVersion))) {
|
|
console.log('Error! You must provide the full name of a currently supported version, e.g., enterprise-server@2.22.')
|
|
process.exit(1)
|
|
}
|
|
|
|
const newVersionDirName = allVersions[newVersion].miscVersionName
|
|
const oldVersionDirName = allVersions[oldVersion].miscVersionName
|
|
|
|
const srcDir = path.join(payloadsDir, oldVersionDirName)
|
|
const destDir = path.join(payloadsDir, newVersionDirName)
|
|
|
|
// create the new directory
|
|
mkdirp(destDir)
|
|
|
|
// copy the files
|
|
fs.readdirSync(srcDir).forEach(file => {
|
|
const srcFile = path.join(srcDir, file)
|
|
const destFile = path.join(destDir, file)
|
|
fs.copyFileSync(srcFile, destFile)
|
|
})
|
|
|
|
// check that it worked
|
|
if (!fs.existsSync(destDir)) {
|
|
console.log(`Error! A new directory was not successfully created at ${destDir}.`)
|
|
process.exit(1)
|
|
}
|
|
|
|
if (!fs.readdirSync(destDir).length) {
|
|
console.log(`Error! The directory created at ${destDir} is empty.`)
|
|
process.exit(1)
|
|
}
|
|
|
|
// print success message
|
|
console.log(`Done! Copied ${srcDir} to ${destDir}.`)
|