Skip to content

Commit

Permalink
feat: infer the outputPath option from the options.outputPath of …
Browse files Browse the repository at this point in the history
…the specified `buildTarget`

closes TheUnderScorer#52
  • Loading branch information
tinesoft committed Mar 27, 2023
1 parent e3d31d1 commit e68c9b9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ $ nx semantic-release app-c --repositoryUrl "https://github.com/TheUnderScorer/n
| git | boolean | true | no | Whether to create git commit and tag. See more in [@semantic-release/git](https://github.com/semantic-release/git). |
| github | boolean | true | no | Whether to create github release. |
| buildTarget | string | | no | The target of the build command. If your package is public and you want to release it to npm as part of release, you have to provide it. Plugin will use it to build your package and set version in package.json before releasing it to npm registry. |
| outputPath | string | | no | The path to the output directory. Provide that if your package is public and you want to publish it into npm. |
| outputPath | string | ${WORKSPACE_DIR}/<`outputPath` from `options` of the specified `buildTarget`> | no | The path to the output directory. Provide that if your package is public and you want to publish it into npm. |
| commitMessage | string | chore(release): ${nextRelease.version} [skip ci]\\n\\n${nextRelease.notes} | no | The commit message to use when committing the release. You can refer to [@semantic-release/git](https://github.com/semantic-release/git#options). |
| gitAssets | string[] | | no | Path to additional assets that will be commited to git with current release. |
| plugins | PluginSpec[] | | no | Additional plugins for semantic-release. Note: these plugins will be added before @semantic-release/git, which means that you can assets generated by them to git as well. Supports the same format as [semantic-release](https://github.com/semantic-release/semantic-release/blob/master/docs/usage/configuration.md#plugins) |
Expand Down Expand Up @@ -171,6 +171,8 @@ You may see other tokens like `${nextRelease.version}`, those are tokens that ar
By setting `buildTarget` option plugin will run your build executor as part of the release, which is useful if ex. you
want to publish released package to npm registry.
Setting this option, will also automatically infer the `outputPath`, from the `options.outputPath` of the specified `build`target, so you that have to specify it too.
## Skipping commits
You can skip commits for given projects using `[skip $PROJECT_NAME]` in its body. Ex:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import { ExecutorOptions } from '../../types';
import { unwrapExecutorOptions } from '../../utils/executor';
import { applyTokensToSemanticReleaseOptions } from '../../config/apply-tokens';
import { getDefaultProjectRoot, GetProjectContext } from '../../common/project';
import { createProjectGraphAsync } from '@nrwl/workspace/src/core/project-graph';
import { createProjectGraphAsync, readCachedProjectConfiguration } from '@nrwl/workspace/src/core/project-graph';
import { join } from 'path';

export type SemanticReleaseOptions = Omit<
BaseSemanticReleaseOptions,
Expand Down Expand Up @@ -72,6 +73,9 @@ export async function semanticRelease(
);
}
}

const projectConfig = readCachedProjectConfiguration(params.project);
resolvedOptions.outputPath = resolvedOptions.outputPath ?? join(workspaceRoot, projectConfig.targets?.[params.target]?.options?.outputPath);
}

setExecutorContext(context);
Expand Down

0 comments on commit e68c9b9

Please sign in to comment.