From 4aabf92a04f024e85ebf31f3370d75f9ccb6ba41 Mon Sep 17 00:00:00 2001 From: AgentEnder Date: Wed, 3 May 2023 14:38:15 -0400 Subject: [PATCH] fix(misc): remove segments from repo name that contain numerals when creating a workspace Closes: #16360 --- docs/generated/devkit/nx_devkit.md | 6 +++--- docs/generated/packages/devkit/documents/nx_devkit.md | 6 +++--- packages/workspace/src/generators/new/new.ts | 10 +++++++++- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/docs/generated/devkit/nx_devkit.md b/docs/generated/devkit/nx_devkit.md index bb34792585efdb..701054a8d1e6a0 100644 --- a/docs/generated/devkit/nx_devkit.md +++ b/docs/generated/devkit/nx_devkit.md @@ -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 diff --git a/docs/generated/packages/devkit/documents/nx_devkit.md b/docs/generated/packages/devkit/documents/nx_devkit.md index bb34792585efdb..701054a8d1e6a0 100644 --- a/docs/generated/packages/devkit/documents/nx_devkit.md +++ b/docs/generated/packages/devkit/documents/nx_devkit.md @@ -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 diff --git a/packages/workspace/src/generators/new/new.ts b/packages/workspace/src/generators/new/new.ts index 9c83395d3a5e7b..76e2877cdf109a 100644 --- a/packages/workspace/src/generators/new/new.ts +++ b/packages/workspace/src/generators/new/new.ts @@ -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;