Skip to content

Commit

Permalink
fix(misc): remove segments from repo name that contain numerals when …
Browse files Browse the repository at this point in the history
…creating a workspace

Closes: #16360
  • Loading branch information
AgentEnder committed May 3, 2023
1 parent c2e8bf7 commit 4aabf92
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
6 changes: 3 additions & 3 deletions docs/generated/devkit/nx_devkit.md
Original file line number Diff line number Diff line change
Expand Up @@ -992,9 +992,9 @@ Use this to expose a compatible Angular Builder

#### Parameters

| Name | Type |
| :--------- | :-------------------------------------------------------------- |
| `executor` | [`Executor`](../../devkit/documents/nx_devkit#executor)<`any`\> |
| Name | Type |
| :--------- | :------------------------------------------------------ |
| `executor` | [`Executor`](../../devkit/documents/nx_devkit#executor) |

#### Returns

Expand Down
6 changes: 3 additions & 3 deletions docs/generated/packages/devkit/documents/nx_devkit.md
Original file line number Diff line number Diff line change
Expand Up @@ -992,9 +992,9 @@ Use this to expose a compatible Angular Builder

#### Parameters

| Name | Type |
| :--------- | :-------------------------------------------------------------- |
| `executor` | [`Executor`](../../devkit/documents/nx_devkit#executor)<`any`\> |
| Name | Type |
| :--------- | :------------------------------------------------------ |
| `executor` | [`Executor`](../../devkit/documents/nx_devkit#executor) |

#### Returns

Expand Down
10 changes: 9 additions & 1 deletion packages/workspace/src/generators/new/new.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,19 @@ function normalizeOptions(options: Schema): NormalizedSchema {
...options,
};

normalized.name = names(options.name).fileName;
if (!options.directory) {
normalized.directory = options.name;
}

// Repository name is the filename, but removes segments with numbers.
// This prevents errors where the path becomes the npm scope which is
// used as things like the selector for angular components, which are
// only allowed to start with a letter.
normalized.name = names(options.name)
.fileName.split('-')
.filter((segment) => /^[A-z]+$/.test(segment))
.join('-');

const parsed = parsePresetName(options.preset);

normalized.preset = parsed.package;
Expand Down

0 comments on commit 4aabf92

Please sign in to comment.