diff --git a/docs/src/content/docs/configuration.md b/docs/src/content/docs/configuration.md index 509760d85..8642765f1 100644 --- a/docs/src/content/docs/configuration.md +++ b/docs/src/content/docs/configuration.md @@ -588,7 +588,9 @@ workspaces: - apps/cli-docs ``` -Most workspaces need no `includePaths` setting. +Most workspaces need no `includePaths` setting. Craft rejects `includePaths` and +`unownedPaths` in configurations without `workspaces`, because there is no +workspace ownership to adjust. Files outside every workspace, such as root build files or an application that lives at the repository root, count as shared by default. Use @@ -686,8 +688,8 @@ changelog: | `changelog.filePath` | Path to changelog file. Defaults to `/CHANGELOG.md` for a directory workspace, otherwise `CHANGELOG.md`. Explicit paths take precedence. | | `changelog.policy` | Mode: `none`, `simple`, or `auto`. Default: `none` | | `changelog.scopeGrouping` | Enable scope-based grouping. Default: `true` | -| `changelog.includePaths` | Extra workspace directories to include in automatic changelogs. Default: `[]` | -| `changelog.unownedPaths` | `include`, `exclude`, or `own` files outside every workspace. Default: `include` | +| `changelog.includePaths` | Extra workspace directories to include in automatic changelogs. Release workspaces only. Default: `[]` | +| `changelog.unownedPaths` | `include`, `exclude`, or `own` files outside every workspace. Release workspaces only. Default: `include` | | `changelog.aiSummary` | Opt-in HTTP release, category, and scope summaries. Default: disabled. | ## Versioning diff --git a/src/__tests__/config.test.ts b/src/__tests__/config.test.ts index 5558f0ae9..f193be8a0 100644 --- a/src/__tests__/config.test.ts +++ b/src/__tests__/config.test.ts @@ -96,6 +96,7 @@ describe('validateConfiguration', () => { includePaths: ['apps/cli-docs'], unownedPaths: 'own', }, + workspaces: { 'packages/cli': {} }, }; expect(validateConfiguration(data)).toEqual(data); @@ -297,14 +298,29 @@ describe('validateConfiguration', () => { 'apps\\docs', ])('rejects unsafe changelog include path %s', includePath => { expect(() => - validateConfiguration({ changelog: { includePaths: [includePath] } }), - ).toThrow(/changelog/); + validateConfiguration({ + workspaces: { cli: { changelog: { includePaths: [includePath] } } }, + }), + ).toThrow(/Changelog paths must use safe relative ASCII segments/); }); test('rejects an unknown unowned paths policy', () => { expect(() => - validateConfiguration({ changelog: { unownedPaths: 'shared' } }), - ).toThrow(/changelog/); + validateConfiguration({ + workspaces: { cli: { changelog: { unownedPaths: 'shared' } } }, + }), + ).toThrow(/workspaces\.cli\.changelog/); + }); + + test.each([ + ['includePaths', ['apps/cli-docs']], + ['unownedPaths', 'exclude'], + ])('rejects changelog.%s without release workspaces', (field, value) => { + expect(() => + validateConfiguration({ changelog: { policy: 'auto', [field]: value } }), + ).toThrow( + `changelog.${field}: Only release workspaces support this setting.`, + ); }); test('includes unowned paths by default', () => { diff --git a/src/schemas/project_config.ts b/src/schemas/project_config.ts index 1060ae3bc..8bc4a0c0b 100644 --- a/src/schemas/project_config.ts +++ b/src/schemas/project_config.ts @@ -451,16 +451,28 @@ export const CraftProjectConfigSchema = z workspaces: z.record(WorkspaceNameSchema, WorkspaceSchema).optional(), }) .superRefine((config, context) => { - if ( - Object.keys(config.workspaces || {}).length > 0 && - config.github?.projectPath !== undefined - ) { + const hasWorkspaces = Object.keys(config.workspaces || {}).length > 0; + if (hasWorkspaces && config.github?.projectPath !== undefined) { context.addIssue({ code: z.ZodIssueCode.custom, message: 'Workspace configurations cannot use github.projectPath.', path: ['github', 'projectPath'], }); } + // Path ownership only exists between release workspaces, so these + // settings would otherwise be silently ignored. + if (!hasWorkspaces && typeof config.changelog === 'object') { + for (const field of ['includePaths', 'unownedPaths'] as const) { + if (config.changelog[field] !== undefined) { + context.addIssue({ + code: z.ZodIssueCode.custom, + message: + 'Only release workspaces support this setting. Define "workspaces" to use it.', + path: ['changelog', field], + }); + } + } + } }); export type CraftProjectConfig = z.infer;