How to use the danger.danger.utils function in danger

To help you get started, we’ve selected a few danger 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 artsy / metaphysics / peril / upstreamSchemaValidator.ts View on Github external
upstreamSchema
    )

    // Create a new copy of the service, with the breaking changes added
    if (breakingChanges.length) {
      servicesWithBreakingChanges[serviceName] = {
        ...service,
        breakingChanges,
      }
    }
  }

  // Reporting back to the PR - offer a single message for all of the potentially
  // failed services,
  const failedServiceNames = Object.keys(servicesWithBreakingChanges)
  const failedServicesSentence = danger.utils.sentence(failedServiceNames)

  if (failedServiceNames.length === 0) {
    console.log(`No breaking changes for ${failedServicesSentence}`)
    return
  }

  const version = isProductionDeployPR ? "staging" : "production"
  const message = isProductionDeployPR ? fail : warn
  const s = failedServiceNames.length === 1 ? "" : "s"
  const are = failedServiceNames.length === 1 ? "is" : "are"

  message(`
    There ${are} a breaking difference${s} between the **${version}** deployed 
    schema${s} for **${failedServiceNames}**. 
    
    The changes you have made  to the local schema${s} in metaphysics are 
github springload / draftail / dangerfile.js View on Github external
schedule(async () => {
  const packageDiff = await danger.git.JSONDiffForFile("package.json");

  if (packageDiff.dependencies) {
    const { added, removed } = packageDiff.dependencies;

    if (added.length) {
      const deps = danger.utils.sentence(added.map((d) => linkDep(d)));
      message(`Adding new dependencies: ${deps}`);
    }

    if (removed.length) {
      const deps = danger.utils.sentence(removed.map((d) => linkDep(d)));
      message(`:tada:, removing dependencies: ${deps}`);
    }

    if (added.includes("draft-js")) {
      warn(
        ":scream: this PR updates Draft.js! Please make sure to review the [upgrade considerations](https://github.com/springload/draftail/tree/master/docs#upgrade-considerations).",
      );
    }
  }
});
github springload / draftail / dangerfile.js View on Github external
const linkDep = (dep) =>
  danger.utils.href(`https://www.npmjs.com/package/${dep}`, dep);
github thibaudcolas / draftjs-filters / dangerfile.js View on Github external
const linkDep = (dep) =>
  danger.utils.href(`https://www.npmjs.com/package/${dep}`, dep)
github thibaudcolas / draftjs-conductor / dangerfile.js View on Github external
const linkDep = (dep) =>
  danger.utils.href(`https://www.npmjs.com/package/${dep}`, dep);
github thibaudcolas / draftjs-filters / dangerfile.js View on Github external
schedule(async () => {
  const packageDiff = await danger.git.JSONDiffForFile("package.json")

  if (packageDiff.dependencies) {
    const added = packageDiff.dependencies.added
    const removed = packageDiff.dependencies.removed

    if (added.length) {
      const deps = danger.utils.sentence(added.map((d) => linkDep(d)))
      message(`Adding new dependencies: ${deps}`)
    }

    if (removed.length) {
      const deps = danger.utils.sentence(removed.map((d) => linkDep(d)))
      message(`:tada:, removing dependencies: ${deps}`)
    }

    if (added.includes("draft-js")) {
      warn(
        ":scream: this PR updates Draft.js! Please make sure to review the Draft.js CHANGELOG.",
      )
    }
  }
})
github thibaudcolas / draftjs-conductor / dangerfile.js View on Github external
schedule(async () => {
  const packageDiff = await danger.git.JSONDiffForFile("package.json");

  if (packageDiff.dependencies) {
    const added = packageDiff.dependencies.added;
    const removed = packageDiff.dependencies.removed;

    if (added.length) {
      const deps = danger.utils.sentence(added.map((d) => linkDep(d)));
      message(`Adding new dependencies: ${deps}`);
    }

    if (removed.length) {
      const deps = danger.utils.sentence(removed.map((d) => linkDep(d)));
      message(`:tada:, removing dependencies: ${deps}`);
    }

    if (added.includes("draft-js")) {
      warn(
        ":scream: this PR updates Draft.js! Please make sure to review the Draft.js CHANGELOG.",
      );
    }
  }
});
github opengaming / osgameclones / dangerfile.js View on Github external
onGameAdded(game)
        } else if (namesBefore.includes(game.name) && !stringsBefore.includes(JSON.stringify(game))) {
          onGameChanged(game)
        }
      })
    })
    if (unknownLanguageDetected) message(`Known languages are ${knownLanguages}.`)
    if (unknownFrameworkDetected) message(`Known frameworks are ${knownFrameworks}.`)
    if (namesAdded.length > 0) {
      message(`Game(s) added: ${danger.utils.sentence(namesAdded)} 🎊`)
    }
    if (namesChanged.length > 0) {
      message(`Game(s) updated: ${danger.utils.sentence(namesChanged)} 👏`)
    }
    if (namesRemoved.length > 0) {
      message(`Game(s) removed: ${danger.utils.sentence(namesRemoved)} 😿`)
    }
  })
}