From 997058c975abf72726195b45b749237f28d8a5c3 Mon Sep 17 00:00:00 2001 From: Austin Fahsl Date: Thu, 5 Sep 2024 16:35:33 -0600 Subject: [PATCH 1/3] fix(release): allow string array for gitCommitArgs --- packages/nx/src/command-line/release/command-object.ts | 2 +- packages/nx/src/command-line/release/utils/git.ts | 8 ++++++-- packages/nx/src/command-line/release/utils/shared.ts | 2 +- packages/nx/src/config/nx-json.ts | 4 ++-- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/nx/src/command-line/release/command-object.ts b/packages/nx/src/command-line/release/command-object.ts index f58774ad4f051..6434746be68bf 100644 --- a/packages/nx/src/command-line/release/command-object.ts +++ b/packages/nx/src/command-line/release/command-object.ts @@ -30,7 +30,7 @@ interface GitCommitAndTagOptions { stageChanges?: boolean; gitCommit?: boolean; gitCommitMessage?: string; - gitCommitArgs?: string; + gitCommitArgs?: string | string[]; gitTag?: boolean; gitTagMessage?: string; gitTagArgs?: string; diff --git a/packages/nx/src/command-line/release/utils/git.ts b/packages/nx/src/command-line/release/utils/git.ts index c10a3692a63f8..ed72cbcf2530c 100644 --- a/packages/nx/src/command-line/release/utils/git.ts +++ b/packages/nx/src/command-line/release/utils/git.ts @@ -248,7 +248,7 @@ export async function gitCommit({ logFn, }: { messages: string[]; - additionalArgs?: string; + additionalArgs?: string | string[]; dryRun?: boolean; verbose?: boolean; logFn?: (message: string) => void; @@ -260,7 +260,11 @@ export async function gitCommit({ commandArgs.push('--message', message); } if (additionalArgs) { - commandArgs.push(...additionalArgs.split(' ')); + if (Array.isArray(additionalArgs)) { + commandArgs.push(...additionalArgs); + } else { + commandArgs.push(...additionalArgs.split(' ')); + } } if (verbose) { diff --git a/packages/nx/src/command-line/release/utils/shared.ts b/packages/nx/src/command-line/release/utils/shared.ts index f83327862072a..1eb598482cc79 100644 --- a/packages/nx/src/command-line/release/utils/shared.ts +++ b/packages/nx/src/command-line/release/utils/shared.ts @@ -88,7 +88,7 @@ export async function commitChanges({ isDryRun?: boolean; isVerbose?: boolean; gitCommitMessages?: string[]; - gitCommitArgs?: string; + gitCommitArgs?: string | string[]; }) { if (!changedFiles?.length && !deletedFiles?.length) { throw new Error('Error: No changed files to commit'); diff --git a/packages/nx/src/config/nx-json.ts b/packages/nx/src/config/nx-json.ts index d91140661c33f..1899b5be35701 100644 --- a/packages/nx/src/config/nx-json.ts +++ b/packages/nx/src/config/nx-json.ts @@ -123,9 +123,9 @@ export interface NxReleaseGitConfiguration { */ commitMessage?: string; /** - * Additional arguments (added after the --message argument, which may or may not be customized with --git-commit-message) to pass to the `git commit` command invoked behind the scenes + * Additional arguments (added after the --message argument, which may or may not be customized with --git-commit-message) to pass to the `git commit` command invoked behind the scenes. May be a string or array of strings. */ - commitArgs?: string; + commitArgs?: string | string[]; /** * Whether or not to stage the changes made by this command. Always treated as true if commit is true. */ From e3f761db2d18ff7f76c51f4cf79de225c4a5be52 Mon Sep 17 00:00:00 2001 From: Austin Fahsl Date: Fri, 6 Sep 2024 15:59:24 -0600 Subject: [PATCH 2/3] chore(release): update json schema --- packages/nx/schemas/nx-schema.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nx/schemas/nx-schema.json b/packages/nx/schemas/nx-schema.json index 23998fc4d10fe..2db02429b6b65 100644 --- a/packages/nx/schemas/nx-schema.json +++ b/packages/nx/schemas/nx-schema.json @@ -634,7 +634,7 @@ "description": "Custom git commit message to use when committing the changes made by this command" }, "commitArgs": { - "type": "string", + "type": ["string", "array"], "description": "Additional arguments (added after the --message argument, which may or may not be customized with --git-commit-message) to pass to the `git commit` command invoked behind the scenes" }, "stageChanges": { From 9d3ea29ace372d73ac924404956404b9d90b8f50 Mon Sep 17 00:00:00 2001 From: Austin Fahsl Date: Mon, 16 Sep 2024 18:22:38 -0600 Subject: [PATCH 3/3] feat(release): allow string[] for tag args --- packages/nx/schemas/nx-schema.json | 2 +- packages/nx/src/command-line/release/command-object.ts | 2 +- packages/nx/src/command-line/release/utils/git.ts | 8 ++++++-- packages/nx/src/config/nx-json.ts | 4 ++-- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/nx/schemas/nx-schema.json b/packages/nx/schemas/nx-schema.json index 2db02429b6b65..6860662ef0686 100644 --- a/packages/nx/schemas/nx-schema.json +++ b/packages/nx/schemas/nx-schema.json @@ -650,7 +650,7 @@ "description": "Custom git tag message to use when tagging the changes made by this command. This defaults to be the same value as the tag itself." }, "tagArgs": { - "type": "string", + "type": ["string", "array"], "description": "Additional arguments to pass to the `git tag` command invoked behind the scenes" } } diff --git a/packages/nx/src/command-line/release/command-object.ts b/packages/nx/src/command-line/release/command-object.ts index 6434746be68bf..a9f048710db07 100644 --- a/packages/nx/src/command-line/release/command-object.ts +++ b/packages/nx/src/command-line/release/command-object.ts @@ -33,7 +33,7 @@ interface GitCommitAndTagOptions { gitCommitArgs?: string | string[]; gitTag?: boolean; gitTagMessage?: string; - gitTagArgs?: string; + gitTagArgs?: string | string[]; } export type VersionOptions = NxReleaseArgs & diff --git a/packages/nx/src/command-line/release/utils/git.ts b/packages/nx/src/command-line/release/utils/git.ts index f2385cafde648..1ce8acf7e184e 100644 --- a/packages/nx/src/command-line/release/utils/git.ts +++ b/packages/nx/src/command-line/release/utils/git.ts @@ -309,7 +309,7 @@ export async function gitTag({ }: { tag: string; message?: string; - additionalArgs?: string; + additionalArgs?: string | string[]; dryRun?: boolean; verbose?: boolean; logFn?: (message: string) => void; @@ -325,7 +325,11 @@ export async function gitTag({ message || tag, ]; if (additionalArgs) { - commandArgs.push(...additionalArgs.split(' ')); + if (Array.isArray(additionalArgs)) { + commandArgs.push(...additionalArgs); + } else { + commandArgs.push(...additionalArgs.split(' ')); + } } if (verbose) { diff --git a/packages/nx/src/config/nx-json.ts b/packages/nx/src/config/nx-json.ts index 1899b5be35701..7aa0a244a16a1 100644 --- a/packages/nx/src/config/nx-json.ts +++ b/packages/nx/src/config/nx-json.ts @@ -139,9 +139,9 @@ export interface NxReleaseGitConfiguration { */ tagMessage?: string; /** - * Additional arguments to pass to the `git tag` command invoked behind the scenes + * Additional arguments to pass to the `git tag` command invoked behind the scenes. . May be a string or array of strings. */ - tagArgs?: string; + tagArgs?: string | string[]; } export interface NxReleaseConventionalCommitsConfiguration {