Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions docs/src/content/docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -686,8 +688,8 @@ changelog:
| `changelog.filePath` | Path to changelog file. Defaults to `<workspace>/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
Expand Down
24 changes: 20 additions & 4 deletions src/__tests__/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ describe('validateConfiguration', () => {
includePaths: ['apps/cli-docs'],
unownedPaths: 'own',
},
workspaces: { 'packages/cli': {} },
};

expect(validateConfiguration(data)).toEqual(data);
Expand Down Expand Up @@ -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', () => {
Expand Down
20 changes: 16 additions & 4 deletions src/schemas/project_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<typeof CraftProjectConfigSchema>;
Loading