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

To help you get started, we’ve selected a few @instructure/pkg-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 / ui-scripts / lib / publish-package.js View on Github external
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * 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 { getPackageJSON } = require('@instructure/pkg-utils')

const { publishPackage } = require('./utils/release')
const { error } = require('./utils/logger')
const { getConfig } = require('./utils/get-config')

try {
  const pkgJSON = getPackageJSON()
  // optional version argument
  // ui-scripts --publish-package 5.12.2
  publishPackage(pkgJSON.name, pkgJSON.version, process.argv[3] || pkgJSON.version, getConfig(pkgJSON))
} catch (err) {
  error(err)
  process.exit(1)
}
github instructure / instructure-ui / packages / ui-scripts / lib / publish.js View on Github external
createNPMRCFile
} = require('./utils/npm')
const {
  checkIfGitTagExists,
  checkIfCommitIsReviewed,
  isReleaseCommit
} = require('./utils/git')
const { postGerritReview } = require('./utils/gerrit')
const {
  setupGit,
  checkWorkingDirectory
} = require('./utils/git')
const { getConfig } = require('./utils/config')

try {
  const pkgJSON = getPackageJSON()
  // optional version argument:
  // e.g. ui-scripts --publish alpha
  publish(pkgJSON.name, pkgJSON.version, process.argv[3], getConfig(pkgJSON))
} catch (err) {
  error(err)
  process.exit(1)
}

async function publish (packageName, currentVersion, preidAndTag, config = {}) {
  setupGit()
  createNPMRCFile(config)
  checkWorkingDirectory()

  let versionToRelease, tag

  if (isReleaseCommit(currentVersion)) {
github instructure / instructure-ui / packages / ui-scripts / lib / tag.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 { getPackageJSON, getPackages } = require('@instructure/pkg-utils')
const { runCommandAsync, error, info } = require('@instructure/command-utils')

const { createNPMRCFile } = require('./utils/npm')
const { getConfig } = require('./utils/config')

try {
  // optional fix version argument:
  // e.g. ui-scripts --tag add 5.11.0 rc
  // e.g. ui-scripts --tag rm 5.11.0 latest
  const pkgJSON = getPackageJSON()
  const command = process.argv[3] || 'add'
  const versionToTag = process.argv[4] || pkgJSON.version
  const tag = process.argv[5] || 'latest'

  distTag(command, versionToTag, tag, getConfig(pkgJSON))
} catch (err) {
  error(err)
  process.exit(1)
}

async function distTag (command, versionToTag, tag, config) {
  createNPMRCFile(config)

  info(`📦  Version to tag as ${tag}: ${versionToTag}`)
  const reply = await confirm('Continue? [y/n]\n')
  if (!['Y', 'y'].includes(reply.trim())) {
github instructure / instructure-ui / packages / ui-scripts / lib / bump.js View on Github external
*/
const { getPackageJSON } = require('@instructure/pkg-utils')
const { error, info } = require('@instructure/command-utils')

const { getConfig } = require('./utils/config')
const {
  commitVersionBump,
  setupGit,
  checkWorkingDirectory
} = require('./utils/git')
const {
  bumpPackages
} = require('./utils/npm')

try {
  const pkgJSON = getPackageJSON()
  // optional release type/version argument: major, minor, patch, [version]
  // e.g. ui-scripts --bump major
  bump(pkgJSON.name, pkgJSON.version, process.argv[3], getConfig(pkgJSON))
} catch (err) {
  error(err)
  process.exit(1)
}

async function bump (packageName, currentVersion, requestedVersion, config = {}) {
  setupGit()
  checkWorkingDirectory()

  let releaseVersion

  try {
    releaseVersion = await bumpPackages(packageName, requestedVersion)
github instructure / instructure-ui / packages / ui-scripts / lib / deprecate.js View on Github external
* 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 { getPackageJSON, getPackages } = require('@instructure/pkg-utils')
const { runCommandAsync, error, info, confirm } = require('@instructure/commmand-utils')

const { createNPMRCFile } = require('./utils/npm')
const { getConfig } = require('./utils/config')

try {
  // optional version and fix version arguments:
  // e.g. ui-scripts --deprecate 5.11.0 5.11.1
  const pkgJSON = getPackageJSON()
  const versionToDeprecate = process.argv[3] || pkgJSON.version
  const fixVersion = process.argv[4]

  deprecate(versionToDeprecate, fixVersion, getConfig(pkgJSON))
} catch (err) {
  error(err)
  process.exit(1)
}

async function deprecate (versionToDeprecate, fixVersion, config) {
  const message = fixVersion ? `A critical bug was fixed in ${fixVersion}` : ''
  createNPMRCFile(config)

  info(`📦  Version to deprecate: ${versionToDeprecate}`)
  const reply = await confirm('Continue? [y/n]\n')
  if (!['Y', 'y'].includes(reply.trim())) {
github instructure / instructure-ui / packages / cz-lerna-changelog / lib / index.js View on Github external
return function (cz, commit) {
    const scope = '@instructure'
    const allPackages = getPackages()
    const changedPackages = getChangedPackages('--cached', allPackages).map(pkg => pkg.name.replace(`${scope}/`, ''))
    const packageNames = allPackages.map(pkg => pkg.name.replace(`${scope}/`, ''))
    const questions = makeDefaultQuestions(packageNames, changedPackages)

    // eslint-disable-next-line no-console
    console.info('\n\nLine 1 will be cropped at 100 characters. All other lines will be wrapped after 100 characters.\n')

    cz.registerPrompt('autocomplete', autocomplete)

    cz.prompt(autocompleteQuestions(questions))
      .then((answers) => {
        const {
          body,
          footer,
          ...rest
        } = answers
github instructure / instructure-ui / packages / cz-lerna-changelog / lib / index.js View on Github external
return function (cz, commit) {
    const scope = '@instructure'
    const allPackages = getPackages()
    const changedPackages = getChangedPackages('--cached', allPackages).map(pkg => pkg.name.replace(`${scope}/`, ''))
    const packageNames = allPackages.map(pkg => pkg.name.replace(`${scope}/`, ''))
    const questions = makeDefaultQuestions(packageNames, changedPackages)

    // eslint-disable-next-line no-console
    console.info('\n\nLine 1 will be cropped at 100 characters. All other lines will be wrapped after 100 characters.\n')

    cz.registerPrompt('autocomplete', autocomplete)

    cz.prompt(autocompleteQuestions(questions))
      .then((answers) => {
        const {
          body,
          footer,
          ...rest
        } = answers
github instructure / instructure-ui / packages / eslint-plugin-instructure-ui / lib / rules / no-relative-package-imports.js View on Github external
function findNamedPackage (filePath) {
      const found = readPackage({cwd: filePath})
      // console.log(found)
      if (found.package && !found.package.name) {
        return findNamedPackage(path.join(found.path, '../..'))
      }
      return found
    }
github instructure / instructure-ui / packages / ui-scripts / lib / utils / config.js View on Github external
exports.getConfig = function getConfig (pkgJSON) {
  pkgJSON = pkgJSON || getPackageJSON() // eslint-disable-line no-param-reassign
  return (pkgJSON.config && pkgJSON.config['ui-scripts']) ? pkgJSON.config['ui-scripts'] : {}
}
github instructure / instructure-ui / packages / ui-scripts / lib / utils / npm.js View on Github external
async function syncRootPackageVersion (useProjectVersion) {
  const project = new Project(process.cwd())
  const rootPkg = getPackage()

  let projectVersion

  if (project.isIndependent() || useProjectVersion) {
    projectVersion = project.version
  } else {
    // unfortunately lerna doesn't update lerna.json for canary releases,
    // so we have to do this:
    const pkgs = getChangedPackages()
    projectVersion = pkgs[0].get('version')
  }

  if (projectVersion !== rootPkg.get('version')) {
    rootPkg.set('version', projectVersion)
    await rootPkg.serialize()
  }

@instructure/pkg-utils

Utilities for managing node packages in a monorepo.

MIT
Latest version published 3 months ago

Package Health Score

84 / 100
Full package analysis

Similar packages