From 04bb40e55e543c272c4c524cdbab0bf7c9b16397 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leosvel=20P=C3=A9rez=20Espinosa?= Date: Wed, 8 May 2024 15:33:47 +0200 Subject: [PATCH] fix(misc): create workspaces and default app with the name as provided (#23196) ## Current Behavior ## Expected Behavior ## Related Issue(s) Fixes #19253 (cherry picked from commit 4cc3dc6960f63b0f31d5b93201c1a22da0af9314) --- .../create-nx-workspace/src/create-empty-workspace.ts | 2 -- .../src/utils/string-utils.spec.ts | 11 ----------- .../create-nx-workspace/src/utils/string-utils.ts | 7 ------- packages/workspace/src/generators/new/new.ts | 2 -- packages/workspace/src/generators/preset/preset.ts | 6 ------ 5 files changed, 28 deletions(-) delete mode 100644 packages/create-nx-workspace/src/utils/string-utils.spec.ts diff --git a/packages/create-nx-workspace/src/create-empty-workspace.ts b/packages/create-nx-workspace/src/create-empty-workspace.ts index d007af4ed4f5d..3db1c54b78219 100644 --- a/packages/create-nx-workspace/src/create-empty-workspace.ts +++ b/packages/create-nx-workspace/src/create-empty-workspace.ts @@ -9,7 +9,6 @@ import { getPackageManagerVersion, PackageManager, } from './utils/package-manager'; -import { getFileName } from './utils/string-utils'; import { unparse } from './utils/unparse'; /** @@ -32,7 +31,6 @@ export async function createEmptyWorkspace( options.packageManager = packageManager; } - options.name = getFileName(name); const directory = options.name; const args = unparse({ diff --git a/packages/create-nx-workspace/src/utils/string-utils.spec.ts b/packages/create-nx-workspace/src/utils/string-utils.spec.ts deleted file mode 100644 index ded2285d4767f..0000000000000 --- a/packages/create-nx-workspace/src/utils/string-utils.spec.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { getFileName } from './string-utils'; - -describe('utils', () => { - describe('getFileName', () => { - it('should return nrwl-org given NrwlORG', () => { - let name = 'NrwlORG'; - expect(getFileName(name)).toEqual('nrwl-org'); - expect(name).toEqual('NrwlORG'); - }); - }); -}); diff --git a/packages/create-nx-workspace/src/utils/string-utils.ts b/packages/create-nx-workspace/src/utils/string-utils.ts index e4de827f90f02..c455fe1b2eed0 100644 --- a/packages/create-nx-workspace/src/utils/string-utils.ts +++ b/packages/create-nx-workspace/src/utils/string-utils.ts @@ -1,10 +1,3 @@ export function stringifyCollection(items: string[]): string { return items.map((item) => `"${item}"`).join(', '); } - -export function getFileName(name: string) { - return name - .replace(/([a-z\d])([A-Z])/g, '$1_$2') - .toLowerCase() - .replace(/[ _]/g, '-'); -} diff --git a/packages/workspace/src/generators/new/new.ts b/packages/workspace/src/generators/new/new.ts index 5213dd162ba1e..9200d4a965248 100644 --- a/packages/workspace/src/generators/new/new.ts +++ b/packages/workspace/src/generators/new/new.ts @@ -2,7 +2,6 @@ import { getPackageManagerCommand, installPackagesTask, joinPathFragments, - names, PackageManager, Tree, } from '@nx/devkit'; @@ -131,7 +130,6 @@ function normalizeOptions(options: Schema): NormalizedSchema { ...options, }; - normalized.name = names(options.name).fileName; if (!options.directory) { normalized.directory = normalized.name; } diff --git a/packages/workspace/src/generators/preset/preset.ts b/packages/workspace/src/generators/preset/preset.ts index c59e8eb5dfdb1..fe57e9240e23a 100644 --- a/packages/workspace/src/generators/preset/preset.ts +++ b/packages/workspace/src/generators/preset/preset.ts @@ -4,7 +4,6 @@ import { Preset } from '../utils/presets'; import { join } from 'path'; export async function presetGenerator(tree: Tree, options: Schema) { - options = normalizeOptions(options); const presetTask = await createPreset(tree, options); return async () => { installPackagesTask(tree); @@ -314,8 +313,3 @@ async function createPreset(tree: Tree, options: Schema) { throw new Error(`Invalid preset ${options.preset}`); } } - -function normalizeOptions(options: Schema): Schema { - options.name = names(options.name).fileName; - return options; -}