How to use @instructure/command-utils - 10 common examples

To help you get started, we’ve selected a few @instructure/command-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github instructure / instructure-ui / packages / pkg-utils / lib / get-changed-packages.js View on Github external
module.exports = function getChangedPackages (commitIsh = 'HEAD^1', allPackages) {
  allPackages = allPackages || getPackages() // eslint-disable-line no-param-reassign

  const result = runCommandSync('git', ['diff', commitIsh, '--name-only'], [], { stdio: 'pipe' }).stdout
  const changedFiles = result.split('\n')

  return allPackages
    .filter((pkg) => {
      const relativePath = path.relative('.', pkg.location) + path.sep
      return changedFiles
        .findIndex(changedFile => changedFile.startsWith(relativePath)) >= 0
    })
}
github instructure / instructure-ui / packages / ui-scripts / lib / build / babel.js View on Github external
let modules = ['es', 'cjs']

if (args.includes('--modules')) {
  //  eslint-disable-next-line no-unused-vars
  const [_, arg] = args.splice(args.indexOf('--modules'), 2)
  if (!arg) {
    throw new Error('Missing --modules argument')
  }
  modules = arg.split(',')
  if (modules.some(mod => !['es', 'cjs'].includes(mod))) {
    throw new Error(`Invalid --modules argument: '${arg}'`)
  }
}

const commands = {
  es: getCommand('babel', [...babelArgs, '--out-dir', 'es'], [...envVars, 'ES_MODULES=1']),
  cjs: getCommand('babel', [...babelArgs, '--out-dir', 'lib'], [...envVars, 'TRANSFORM_IMPORTS=1'])
}

const commandsToRun = modules.reduce((obj, key) => ({ ...obj, [key]: commands[key] }), {})

process.exit(runCommandsConcurrently(commandsToRun).status)
github instructure / instructure-ui / packages / ui-scripts / lib / server.js View on Github external
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
const { runCommandsConcurrently, getCommand } = require('@instructure/command-utils')

// ui-scripts --server -p 8080
const args = process.argv.slice(2)
const portIndex = args.findIndex(arg => arg === '-p')
let port = '8080'
if (portIndex > 0) {
  port = args[portIndex + 1]
}

process.exit(runCommandsConcurrently({
  // http-server __build__ -p 8001
  server: getCommand('http-server', ['__build__', '-p', port], [])
}).status)
github instructure / instructure-ui / packages / ui-scripts / lib / build / babel.js View on Github external
if (args.includes('--modules')) {
  //  eslint-disable-next-line no-unused-vars
  const [_, arg] = args.splice(args.indexOf('--modules'), 2)
  if (!arg) {
    throw new Error('Missing --modules argument')
  }
  modules = arg.split(',')
  if (modules.some(mod => !['es', 'cjs'].includes(mod))) {
    throw new Error(`Invalid --modules argument: '${arg}'`)
  }
}

const commands = {
  es: getCommand('babel', [...babelArgs, '--out-dir', 'es'], [...envVars, 'ES_MODULES=1']),
  cjs: getCommand('babel', [...babelArgs, '--out-dir', 'lib'], [...envVars, 'TRANSFORM_IMPORTS=1'])
}

const commandsToRun = modules.reduce((obj, key) => ({ ...obj, [key]: commands[key] }), {})

process.exit(runCommandsConcurrently(commandsToRun).status)
github instructure / instructure-ui / packages / ui-scripts / lib / server.js View on Github external
* 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 { runCommandsConcurrently, getCommand } = require('@instructure/command-utils')

// ui-scripts --server -p 8080
const args = process.argv.slice(2)
const portIndex = args.findIndex(arg => arg === '-p')
let port = '8080'
if (portIndex > 0) {
  port = args[portIndex + 1]
}

process.exit(runCommandsConcurrently({
  // http-server __build__ -p 8001
  server: getCommand('http-server', ['__build__', '-p', port], [])
}).status)
github instructure / instructure-ui / packages / ui-scripts / lib / utils / jira.js View on Github external
} catch (e) {
    error(`An error occured creating Jira Release version: ${jiraVersionName}!`)
    error(e)
  }

  // result = {
  //   "self":"https://instructure.atlassian.net/rest/api/2/version/46639",
  //   "id":"46639",
  //   "name":"instructure-ui v5.10.0",
  //   "archived":false,
  //   "released":true,
  //   "projectId":17900
  // }

  if (result && result.id) {
    info(`Created ${result.name}:`, JSON.stringify(result))

    return {
      ...result,
      url: `https://${config.jira_host}/projects/${config.jira_project_key}/versions/${result.id}`
    }
  }
}
exports.createJiraVersion = createJiraVersion
github instructure / instructure-ui / packages / ui-scripts / lib / utils / npm.js View on Github external
const {
   NPM_TOKEN,
   NPM_EMAIL,
   NPM_USERNAME
  } = process.env

  // Only write an npmrc file if these are defined, otherwise assume the system is properly configured
  if (NPM_TOKEN) {
    fs.writeFileSync(
      path.resolve(process.cwd(), '.npmrc'),
      `//registry.npmjs.org/:_authToken=${NPM_TOKEN}\n${config.npm_scope}\nemail=${NPM_EMAIL}\nname=${NPM_USERNAME}`
    )
  }

  try  {
    runCommandSync('npm', ['whoami'])
  } catch (e) {
    error(`Could not determine if NPM auth was successful: ${e}`)
  }
}
exports.createNPMRCFile = createNPMRCFile
github instructure / instructure-ui / packages / ui-scripts / lib / deploy-docs.js View on Github external
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.`)
  }
}
github instructure / instructure-ui / packages / ui-scripts / lib / publish.js View on Github external
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)
    }
  }
}
github instructure / instructure-ui / packages / ui-scripts / lib / lint-commit.js View on Github external
* 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)
  }
}

@instructure/command-utils

Node CLI utilities made by Instructure Inc.

MIT
Latest version published 2 days ago

Package Health Score

84 / 100
Full package analysis

Similar packages