Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: Update commander.js dependency #1255

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,20 @@
"test:watch": "jest --watch",
"lint": "eslint \"source/*.ts\" \"source/**/*.ts\"",
"lint:fix": "yarn --silent lint --fix",
"prepublishOnly": "yarn build && yarn jest && yarn declarations && yarn build:flow-types && yarn build:pretty-types",
"build": "shx rm -rf ./distribution && tsc -p tsconfig.production.json && madge ./distribution --circular",
"prepublishOnly": "set -e; yarn build; yarn jest; yarn declarations; yarn build:flow-types; yarn build:pretty-types",
"build": "set -e; shx rm -rf ./distribution; tsc -p tsconfig.production.json; madge ./distribution --circular",
"build:fast": "tsc -p tsconfig.production.json",
"build:flow-types": "cp source/danger.d.ts source/_danger.d.ts && sed -ie 's/api: GitHub/api: any/g' source/_danger.d.ts && npx [email protected] source/_danger.d.ts -o distribution/danger.js.flow && node scripts/update_flow_types.js",
"build:schemas": "typescript-json-schema tsconfig.json DangerJSON > source/danger-incoming-process-schema.json; typescript-json-schema tsconfig.json DangerResults > source/danger-outgoing-process-schema.json; yarn prettier --write source/danger-outgoing-process-schema.json source/danger-incoming-process-schema.json",
"build:pretty-types": "yarn prettier --write distribution/danger.d.ts; yarn prettier --parser flow distribution/danger.js.flow --write",
"build:flow-types": "set -e; cp source/danger.d.ts source/_danger.d.ts; sed -ie 's/api: GitHub/api: any/g' source/_danger.d.ts; npx [email protected] source/_danger.d.ts -o distribution/danger.js.flow; node scripts/update_flow_types.js",
"build:schemas": "set -e; typescript-json-schema tsconfig.json DangerJSON > source/danger-incoming-process-schema.json; typescript-json-schema tsconfig.json DangerResults > source/danger-outgoing-process-schema.json; yarn prettier --write source/danger-outgoing-process-schema.json source/danger-incoming-process-schema.json",
"build:pretty-types": "set -e; yarn prettier --write distribution/danger.d.ts; yarn prettier --parser flow distribution/danger.js.flow --write",
"build:watch": "tsc -w",
"link": "yarn run build && chmod +x distribution/commands/danger.js && yarn link",
"package": "yarn run pkg . --output brew-distribution/danger; zip -j brew-distribution/danger-macos.zip brew-distribution/danger; shasum -a 256 brew-distribution/danger-macos.zip",
"link": "set -e; yarn run build; chmod +x distribution/commands/danger.js; yarn link",
"package": "set -e; yarn run pkg . --output brew-distribution/danger; zip -j brew-distribution/danger-macos.zip brew-distribution/danger; shasum -a 256 brew-distribution/danger-macos.zip",
"declarations": "ts-node ./scripts/create-danger-dts.ts",
"docs:cp_defs": "mkdir docs/docs_generate; cp source/danger.d.ts docs/docs_generate; cp node_modules/@octokit/rest/index.d.ts docs/docs_generate/github.d.ts",
"docs": "yarn run docs:cp_defs; yarn typedoc --ignoreCompilerErrors --mode modules --json docs/js_ref_dsl_docs.json --includeDeclarations source",
"dts-lint": "yarn run declarations && yarn dtslint types",
"danger:prepush": "yarn build:fast; yarn test:fixtures; node distribution/commands/danger.js local --base main --dangerfile dangerfile.lite.ts"
"docs:cp_defs": "set -e; mkdir docs/docs_generate; cp source/danger.d.ts docs/docs_generate; cp node_modules/@octokit/rest/index.d.ts docs/docs_generate/github.d.ts",
"docs": "set -e; yarn run docs:cp_defs; yarn typedoc --ignoreCompilerErrors --mode modules --json docs/js_ref_dsl_docs.json --includeDeclarations source",
"dts-lint": "set -e; yarn run declarations; yarn dtslint types",
"danger:prepush": "set -e; yarn build:fast; yarn test:fixtures; node distribution/commands/danger.js local --base main --dangerfile dangerfile.lite.ts"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -148,7 +148,7 @@
"@octokit/rest": "^18.12.0",
"async-retry": "1.2.3",
"chalk": "^2.3.0",
"commander": "^2.18.0",
"commander": "^9.0.0",
"debug": "^4.1.1",
"fast-json-patch": "^3.0.0-1",
"get-stdin": "^6.0.0",
Expand Down Expand Up @@ -185,7 +185,7 @@
"husky": {
"hooks": {
"pre-commit": "lint-staged",
"pre-push": "yarn build; yarn danger:prepush"
"pre-push": "set -e; yarn build; yarn danger:prepush"
}
}
}
6 changes: 3 additions & 3 deletions source/commands/utils/sharedDangerfileArgs.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import program from "commander"
import { Command } from "commander"
import chalk from "chalk"

process.on("unhandledRejection", function(reason: string, _p: any) {
process.on("unhandledRejection", function (reason: string, _p: any) {
console.log(chalk.red("Error: "), reason)
process.exitCode = 1
})

export interface SharedCLI extends program.CommanderStatic {
export interface SharedCLI extends Command {
/** Should we be posting as much info as possible? */
verbose: boolean
/** Output to STDOUT instead of leaving a comment */
Expand Down
6 changes: 3 additions & 3 deletions source/runner/dslGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { DangerDSLJSONType } from "../dsl/DangerDSL"
import { CliArgs } from "../dsl/cli-args"
import { CISource } from "../ci_source/ci_source"
import { emptyGitJSON } from "../platforms/github/GitHubGit"
import { CommanderStatic } from "commander"
import { Command } from "commander"

export const jsonDSLGenerator = async (
platform: Platform,
source: CISource,
program: CommanderStatic
program: Command
): Promise<DangerDSLJSONType> => {
const useSimpleDSL = platform.getPlatformReviewSimpleRepresentation && source.useEventDSL

Expand All @@ -27,7 +27,7 @@ export const jsonDSLGenerator = async (
id: program.id,
textOnly: program.textOnly,
verbose: program.verbose,
staging: program.staging
staging: program.staging,
}

const dslPlatformName = jsonDSLPlatformName(platform)
Expand Down
10 changes: 3 additions & 7 deletions source/runner/jsonToContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { jsonToDSL } from "./jsonToDSL"
import { contextForDanger, DangerContext } from "./Dangerfile"
import { DangerDSLJSON } from "./dangerDSLJSON"
import { CISource } from "../ci_source/ci_source"
import { CommanderStatic } from "commander"
import { Command } from "commander"

/**
* Reads in the JSON string converts to a dsl object and gets the change context
Expand All @@ -12,12 +12,8 @@ import { CommanderStatic } from "commander"
* @param program {any} commander
* @returns {Promise<DangerContext>} context for danger
*/
export async function jsonToContext(
JSONString: string,
program: CommanderStatic,
source: CISource
): Promise<DangerContext> {
const dslJSON = { danger: new DangerDSLJSON(JSONString, (program as any) as CliArgs) }
export async function jsonToContext(JSONString: string, program: Command, source: CISource): Promise<DangerContext> {
const dslJSON = { danger: new DangerDSLJSON(JSONString, program as any as CliArgs) }
const dsl = await jsonToDSL(dslJSON.danger, source)
return contextForDanger(dsl)
}
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2468,11 +2468,6 @@ commander@^2.14.1, commander@^2.15.1:
resolved "https://registry.yarnpkg.com/commander/-/commander-2.15.1.tgz#df46e867d0fc2aec66a34662b406a9ccafff5b0f"
integrity sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==

commander@^2.18.0:
version "2.19.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.19.0.tgz#f6198aa84e5b83c46054b94ddedbfed5ee9ff12a"
integrity sha512-6tvAOO+D6OENvRAh524Dh9jcfKTYDQAqvqezbCW82xj5X0pSrcpxtvRKHLG0yBY6SD7PSDrJaj+0AiOcKVd1Xg==

commander@^2.6.0:
version "2.13.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.13.0.tgz#6964bca67685df7c1f1430c584f07d7597885b9c"
Expand All @@ -2485,6 +2480,11 @@ commander@^2.8.1, commander@^2.9.0:
dependencies:
graceful-readlink ">= 1.0.0"

commander@^9.0.0:
version "9.0.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-9.0.0.tgz#86d58f24ee98126568936bd1d3574e0308a99a40"
integrity sha512-JJfP2saEKbQqvW+FI93OYUB4ByV5cizMpFMiiJI8xDbBvQvSkIk0VvQdn1CZ8mqAO8Loq2h0gYTYtDFUZUeERw==

commander@~2.17.1:
version "2.17.1"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.17.1.tgz#bd77ab7de6de94205ceacc72f1716d29f20a77bf"
Expand Down