feat(gradle): add help metadata (#26810)
<!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> <!-- If this is a particularly complex change or feature addition, you can request a dedicated Nx release for this pull request branch. Mention someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they will confirm if the PR warrants its own release for testing purposes, and generate it for you if appropriate. --> ## Current Behavior <!-- This is the behavior we have today --> ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #
This commit is contained in:
parent
638647d77c
commit
fc1c04918b
@ -74,9 +74,9 @@ export default function TargetConfigurationDetails({
|
|||||||
getDisplayHeaderFromTargetConfiguration(targetConfiguration);
|
getDisplayHeaderFromTargetConfiguration(targetConfiguration);
|
||||||
const configurations = targetConfiguration.configurations;
|
const configurations = targetConfiguration.configurations;
|
||||||
|
|
||||||
const shouldRenderOptions =
|
const shouldRenderOptions: boolean =
|
||||||
options &&
|
options &&
|
||||||
(typeof options === 'object' ? Object.keys(options).length : true);
|
(typeof options === 'object' ? Object.keys(options).length > 0 : true);
|
||||||
|
|
||||||
const shouldRenderConfigurations =
|
const shouldRenderConfigurations =
|
||||||
configurations &&
|
configurations &&
|
||||||
@ -137,7 +137,7 @@ export default function TargetConfigurationDetails({
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{shouldRenderOptions ? (
|
{shouldRenderOptions || targetConfiguration.metadata?.help ? (
|
||||||
<>
|
<>
|
||||||
<h4 className="mb-4">
|
<h4 className="mb-4">
|
||||||
<Tooltip
|
<Tooltip
|
||||||
@ -149,32 +149,34 @@ export default function TargetConfigurationDetails({
|
|||||||
</span>
|
</span>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</h4>
|
</h4>
|
||||||
<div className="mb-4">
|
{shouldRenderOptions ? (
|
||||||
<FadingCollapsible>
|
<div className="mb-4">
|
||||||
<JsonCodeBlock
|
<FadingCollapsible>
|
||||||
data={options}
|
<JsonCodeBlock
|
||||||
copyTooltipText="Copy Options"
|
data={options}
|
||||||
renderSource={(propertyName: string) => (
|
copyTooltipText="Copy Options"
|
||||||
<TargetSourceInfo
|
renderSource={(propertyName: string) => (
|
||||||
className="flex min-w-0 pl-4"
|
<TargetSourceInfo
|
||||||
propertyKey={`targets.${targetName}.options.${propertyName}`}
|
className="flex min-w-0 pl-4"
|
||||||
sourceMap={sourceMap}
|
propertyKey={`targets.${targetName}.options.${propertyName}`}
|
||||||
/>
|
sourceMap={sourceMap}
|
||||||
)}
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</FadingCollapsible>
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
|
{targetConfiguration.metadata?.help && (
|
||||||
|
<div className="mb-4">
|
||||||
|
<ShowOptionsHelp
|
||||||
|
targetConfiguration={targetConfiguration}
|
||||||
|
projectName={projectName}
|
||||||
|
targetName={targetName}
|
||||||
/>
|
/>
|
||||||
</FadingCollapsible>
|
</div>
|
||||||
</div>
|
)}
|
||||||
<div className="mb-4">
|
|
||||||
<ShowOptionsHelp
|
|
||||||
targetConfiguration={targetConfiguration}
|
|
||||||
projectName={projectName}
|
|
||||||
targetName={targetName}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</>
|
</>
|
||||||
) : (
|
) : null}
|
||||||
''
|
|
||||||
)}
|
|
||||||
|
|
||||||
{targetConfiguration.inputs && (
|
{targetConfiguration.inputs && (
|
||||||
<div className="group">
|
<div className="group">
|
||||||
|
|||||||
@ -98,6 +98,16 @@ describe('@nx/gradle/plugin', () => {
|
|||||||
"^production",
|
"^production",
|
||||||
],
|
],
|
||||||
"metadata": {
|
"metadata": {
|
||||||
|
"help": {
|
||||||
|
"command": "./gradlew help --task proj:test",
|
||||||
|
"example": {
|
||||||
|
"options": {
|
||||||
|
"args": [
|
||||||
|
"--rerun",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
"technologies": [
|
"technologies": [
|
||||||
"gradle",
|
"gradle",
|
||||||
],
|
],
|
||||||
@ -168,6 +178,16 @@ describe('@nx/gradle/plugin', () => {
|
|||||||
"^production",
|
"^production",
|
||||||
],
|
],
|
||||||
"metadata": {
|
"metadata": {
|
||||||
|
"help": {
|
||||||
|
"command": "./gradlew help --task proj:test",
|
||||||
|
"example": {
|
||||||
|
"options": {
|
||||||
|
"args": [
|
||||||
|
"--rerun",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
"technologies": [
|
"technologies": [
|
||||||
"gradle",
|
"gradle",
|
||||||
],
|
],
|
||||||
@ -256,6 +276,16 @@ describe('@nx/gradle/plugin', () => {
|
|||||||
"^production",
|
"^production",
|
||||||
],
|
],
|
||||||
"metadata": {
|
"metadata": {
|
||||||
|
"help": {
|
||||||
|
"command": "./gradlew help --task proj:test",
|
||||||
|
"example": {
|
||||||
|
"options": {
|
||||||
|
"args": [
|
||||||
|
"--rerun",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
"technologies": [
|
"technologies": [
|
||||||
"gradle",
|
"gradle",
|
||||||
],
|
],
|
||||||
@ -282,6 +312,16 @@ describe('@nx/gradle/plugin', () => {
|
|||||||
],
|
],
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"description": "Runs Gradle Tests in CI",
|
"description": "Runs Gradle Tests in CI",
|
||||||
|
"help": {
|
||||||
|
"command": "./gradlew help --task proj:test",
|
||||||
|
"example": {
|
||||||
|
"options": {
|
||||||
|
"args": [
|
||||||
|
"--rerun",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
"nonAtomizedTarget": "test",
|
"nonAtomizedTarget": "test",
|
||||||
"technologies": [
|
"technologies": [
|
||||||
"gradle",
|
"gradle",
|
||||||
@ -300,6 +340,16 @@ describe('@nx/gradle/plugin', () => {
|
|||||||
],
|
],
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"description": "Runs Gradle test nested/nested/proj/src/test/java/test/test.java in CI",
|
"description": "Runs Gradle test nested/nested/proj/src/test/java/test/test.java in CI",
|
||||||
|
"help": {
|
||||||
|
"command": "./gradlew help --task proj:test",
|
||||||
|
"example": {
|
||||||
|
"options": {
|
||||||
|
"args": [
|
||||||
|
"--rerun",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
"technologies": [
|
"technologies": [
|
||||||
"gradle",
|
"gradle",
|
||||||
],
|
],
|
||||||
@ -317,6 +367,16 @@ describe('@nx/gradle/plugin', () => {
|
|||||||
],
|
],
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"description": "Runs Gradle test nested/nested/proj/src/test/java/test/test1.java in CI",
|
"description": "Runs Gradle test nested/nested/proj/src/test/java/test/test1.java in CI",
|
||||||
|
"help": {
|
||||||
|
"command": "./gradlew help --task proj:test",
|
||||||
|
"example": {
|
||||||
|
"options": {
|
||||||
|
"args": [
|
||||||
|
"--rerun",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
"technologies": [
|
"technologies": [
|
||||||
"gradle",
|
"gradle",
|
||||||
],
|
],
|
||||||
|
|||||||
@ -275,6 +275,14 @@ async function createGradleTargets(
|
|||||||
dependsOn: dependsOnMap[task.name],
|
dependsOn: dependsOnMap[task.name],
|
||||||
metadata: {
|
metadata: {
|
||||||
technologies: ['gradle'],
|
technologies: ['gradle'],
|
||||||
|
help: {
|
||||||
|
command: `${getGradleExecFile()} help --task ${taskCommandToRun}`,
|
||||||
|
example: {
|
||||||
|
options: {
|
||||||
|
args: ['--rerun'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
...(outputs && outputs.length ? { outputs } : {}),
|
...(outputs && outputs.length ? { outputs } : {}),
|
||||||
};
|
};
|
||||||
@ -335,6 +343,14 @@ function getTestCiTargets(
|
|||||||
metadata: {
|
metadata: {
|
||||||
technologies: ['gradle'],
|
technologies: ['gradle'],
|
||||||
description: `Runs Gradle test ${testFile} in CI`,
|
description: `Runs Gradle test ${testFile} in CI`,
|
||||||
|
help: {
|
||||||
|
command: `${getGradleExecFile()} help --task ${taskCommandToRun}`,
|
||||||
|
example: {
|
||||||
|
options: {
|
||||||
|
args: ['--rerun'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
...(outputs && outputs.length > 0 ? { outputs } : {}),
|
...(outputs && outputs.length > 0 ? { outputs } : {}),
|
||||||
};
|
};
|
||||||
@ -356,6 +372,14 @@ function getTestCiTargets(
|
|||||||
technologies: ['gradle'],
|
technologies: ['gradle'],
|
||||||
description: 'Runs Gradle Tests in CI',
|
description: 'Runs Gradle Tests in CI',
|
||||||
nonAtomizedTarget: testTargetName,
|
nonAtomizedTarget: testTargetName,
|
||||||
|
help: {
|
||||||
|
command: `${getGradleExecFile()} help --task ${taskCommandToRun}`,
|
||||||
|
example: {
|
||||||
|
options: {
|
||||||
|
args: ['--rerun'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
targetGroups[targetGroupName].push(ciTargetName);
|
targetGroups[targetGroupName].push(ciTargetName);
|
||||||
|
|||||||
@ -1220,6 +1220,6 @@ function getHelpTextFromTarget(
|
|||||||
throw new Error(`No help command found for ${projectName}:${targetName}`);
|
throw new Error(`No help command found for ${projectName}:${targetName}`);
|
||||||
|
|
||||||
return execSync(command, {
|
return execSync(command, {
|
||||||
cwd: join(workspaceRoot, project.data.root),
|
cwd: target.options?.cwd ?? workspaceRoot,
|
||||||
}).toString();
|
}).toString();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user