diff --git a/README.md b/README.md index 89962b37..5fc4f931 100644 --- a/README.md +++ b/README.md @@ -138,9 +138,10 @@ $ nx semantic-release app-c --repositoryUrl "https://github.com/TheUnderScorer/n | Token | Expands into | | --------------- | --------------------------------------------------------------------------------------------- | -| ${PROJECT_DIR} | Resolves to the current project direcory (ex. `/Users/theunderscorer/nx-monorepo/apps/app-a`) | +| ${RELATIVE_PROJECT_DIR} | Resolves to the current project relative directory within the current workspace (ex. `apps/app-a`) | +| ${PROJECT_DIR} | Resolves to the current project directory (ex. `/Users/theunderscorer/nx-monorepo/apps/app-a`) | | ${PROJECT_NAME} | Resolves to the current project name (ex. `app-a`) | -| ${WORKSPACE_DIR}| Resolves to the current workspace direcory (ex. `/Users/theunderscorer/nx-monorepo`) | +| ${WORKSPACE_DIR}| Resolves to the current workspace directory (ex. `/Users/theunderscorer/nx-monorepo`) | Every available option support tokens - this included nested objects and arrays. diff --git a/packages/nx-semantic-release/src/config/apply-tokens.ts b/packages/nx-semantic-release/src/config/apply-tokens.ts index b54d0e6f..a50dfe31 100644 --- a/packages/nx-semantic-release/src/config/apply-tokens.ts +++ b/packages/nx-semantic-release/src/config/apply-tokens.ts @@ -2,6 +2,7 @@ import { SemanticReleaseOptions } from '../executors/semantic-release/semantic-r import deepMap from 'deep-map'; export interface ConfigTokensDict { + relativeProjectDir: string; projectDir: string; projectName: string; workspaceDir: string; @@ -13,6 +14,7 @@ export function applyTokensToSemanticReleaseOptions( ) { const replaceTokens = (value: string): string => { return value + .replaceAll('${RELATIVE_PROJECT_DIR}', tokens.relativeProjectDir) .replaceAll('${PROJECT_DIR}', tokens.projectDir) .replaceAll('${PROJECT_NAME}', tokens.projectName) .replaceAll('${WORKSPACE_DIR}', tokens.workspaceDir); diff --git a/packages/nx-semantic-release/src/executors/semantic-release/semantic-release.ts b/packages/nx-semantic-release/src/executors/semantic-release/semantic-release.ts index bb45db13..bcda0cd9 100644 --- a/packages/nx-semantic-release/src/executors/semantic-release/semantic-release.ts +++ b/packages/nx-semantic-release/src/executors/semantic-release/semantic-release.ts @@ -1,3 +1,4 @@ +import path from "path"; import { createProjectGraphAsync, ExecutorContext, @@ -140,6 +141,7 @@ export function resolveOptions( return applyTokensToSemanticReleaseOptions(mergedOptions, { projectName: context.projectName as string, + relativeProjectDir: path.relative(context.cwd, getDefaultProjectRoot(context)), projectDir: getDefaultProjectRoot(context), workspaceDir: workspaceRoot, }); diff --git a/packages/nx-semantic-release/src/generators/setup-project/setup-project.ts b/packages/nx-semantic-release/src/generators/setup-project/setup-project.ts index a8f6b72c..fe970c54 100644 --- a/packages/nx-semantic-release/src/generators/setup-project/setup-project.ts +++ b/packages/nx-semantic-release/src/generators/setup-project/setup-project.ts @@ -1,3 +1,4 @@ +import path from "path"; import { SemanticReleaseOptions } from '../../executors/semantic-release/semantic-release'; import { Tree, @@ -27,6 +28,7 @@ export async function setupProject( const semanticReleaseConfig = applyTokensToSemanticReleaseOptions(options, { projectName, projectDir: projectConfig.root, + relativeProjectDir: path.relative(workspaceRoot, projectConfig.root), workspaceDir: workspaceRoot, });