From e96a107cd3bfa4a2b333d3d4a9fb146b7ed498ab Mon Sep 17 00:00:00 2001 From: Max Kless Date: Tue, 13 May 2025 14:47:57 +0200 Subject: [PATCH] fix(release): adjust publish error message and version schema --- e2e/release/src/private-js-packages.test.ts | 6 +++-- packages/nx/schemas/nx-schema.json | 23 ++++++++++++++++++- .../nx/src/command-line/release/publish.ts | 4 +++- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/e2e/release/src/private-js-packages.test.ts b/e2e/release/src/private-js-packages.test.ts index f08f2048cd8d7..99f50e86c37ad 100644 --- a/e2e/release/src/private-js-packages.test.ts +++ b/e2e/release/src/private-js-packages.test.ts @@ -206,8 +206,10 @@ describe('nx release - private JS packages', () => { - {private-project-name} - This is usually caused by not having an appropriate plugin, such as "@nx/js" installed, which will add the appropriate "nx-release-publish" target for you automatically. - + This is usually caused by either + - not having an appropriate plugin, such as "@nx/js" installed, which will add the appropriate "nx-release-publish" target for you automatically + - having "private": true set in your package.json, which prevents the target from being created + Pass --verbose to see the stacktrace. diff --git a/packages/nx/schemas/nx-schema.json b/packages/nx/schemas/nx-schema.json index a3aa09e8d62ba..ff59caae1048c 100644 --- a/packages/nx/schemas/nx-schema.json +++ b/packages/nx/schemas/nx-schema.json @@ -745,7 +745,28 @@ "manifestRootsToUpdate": { "type": "array", "items": { - "type": "string" + "oneOf": [ + { + "type": "string", + "description": "Path to the directory containing manifest files to update. Supports placeholders like {projectRoot} and {projectName}." + }, + { + "type": "object", + "properties": { + "path": { + "type": "string", + "description": "Path to the directory containing manifest files to update. Supports placeholders like {projectRoot} and {projectName}." + }, + "preserveLocalDependencyProtocols": { + "type": "boolean", + "description": "Whether to preserve local dependency references using protocols like 'workspace:' or 'file:'. Set to false for dist files that need to be published.", + "default": true + } + }, + "required": ["path"], + "additionalProperties": false + } + ] }, "description": "A list of directories containing manifest files (such as package.json) to apply updates to when versioning. By default, only the project root will be used, but you could customize this to only version a manifest in a dist directory, or even version multiple manifests in different directories, such as both source and dist." }, diff --git a/packages/nx/src/command-line/release/publish.ts b/packages/nx/src/command-line/release/publish.ts index 5d72331350f9a..5bc58a68822a3 100644 --- a/packages/nx/src/command-line/release/publish.ts +++ b/packages/nx/src/command-line/release/publish.ts @@ -257,7 +257,9 @@ async function runPublishOnProjects( `Based on your config, the following projects were matched for publishing but do not have the "${requiredTargetName}" target specified:\n${[ ...projectsToRun.map((p) => `- ${p.name}`), '', - `This is usually caused by not having an appropriate plugin, such as "@nx/js" installed, which will add the appropriate "${requiredTargetName}" target for you automatically.`, + `This is usually caused by either`, + `- not having an appropriate plugin, such as "@nx/js" installed, which will add the appropriate "${requiredTargetName}" target for you automatically`, + `- having "private": true set in your package.json, which prevents the target from being created`, ].join('\n')}\n` ); }