From c8de6f1b6f679682f3e74677c6c141c85f5e0a59 Mon Sep 17 00:00:00 2001 From: Jason Jean Date: Fri, 23 Sep 2022 15:18:04 -0400 Subject: [PATCH] Revert "Revert "fix(misc): move library without given importPath should default to contain slashes (#11869)"" This reverts commit 33c0f944e0c85cc43fad2e9fde183b1f07903cdd. --- .../src/generators/move/lib/update-module-name.spec.ts | 8 ++++---- .../src/generators/move/lib/normalize-schema.spec.ts | 2 +- .../workspace/src/generators/move/lib/normalize-schema.ts | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/angular/src/generators/move/lib/update-module-name.spec.ts b/packages/angular/src/generators/move/lib/update-module-name.spec.ts index d3d145efdf4e0..cf31b7d9f8876 100644 --- a/packages/angular/src/generators/move/lib/update-module-name.spec.ts +++ b/packages/angular/src/generators/move/lib/update-module-name.spec.ts @@ -1,11 +1,11 @@ import { Tree } from '@nrwl/devkit'; import { createTreeWithEmptyV1Workspace } from '@nrwl/devkit/testing'; +import { Linter } from '@nrwl/linter'; import { moveGenerator } from '@nrwl/workspace/generators'; +import { UnitTestRunner } from '../../../utils/test-runners'; +import libraryGenerator from '../../library/library'; import { Schema } from '../schema'; import { updateModuleName } from './update-module-name'; -import libraryGenerator from '../../library/library'; -import { Linter } from '@nrwl/linter'; -import { UnitTestRunner } from '../../../utils/test-runners'; describe('updateModuleName Rule', () => { let tree: Tree; @@ -132,7 +132,7 @@ describe('updateModuleName Rule', () => { const importerFile = tree.read(secondModulePath).toString('utf-8'); expect(importerFile).toContain( - `import { SharedMyFirstModule } from '@proj/shared-my-first';` + `import { SharedMyFirstModule } from '@proj/shared/my-first';` ); expect(importerFile).toContain( `export class MySecondModule extends SharedMyFirstModule {}` diff --git a/packages/workspace/src/generators/move/lib/normalize-schema.spec.ts b/packages/workspace/src/generators/move/lib/normalize-schema.spec.ts index 9cfafa0e81e7e..8c0d506a3bb73 100644 --- a/packages/workspace/src/generators/move/lib/normalize-schema.spec.ts +++ b/packages/workspace/src/generators/move/lib/normalize-schema.spec.ts @@ -34,7 +34,7 @@ describe('normalizeSchema', () => { it('should calculate importPath, projectName and relativeToRootDestination correctly', () => { const expected: NormalizedSchema = { destination: 'my/library', - importPath: '@proj/my-library', + importPath: '@proj/my/library', newProjectName: 'my-library', projectName: 'my-library', relativeToRootDestination: 'libs/my/library', diff --git a/packages/workspace/src/generators/move/lib/normalize-schema.ts b/packages/workspace/src/generators/move/lib/normalize-schema.ts index f4ef1f1a631cc..ce128e78af1fc 100644 --- a/packages/workspace/src/generators/move/lib/normalize-schema.ts +++ b/packages/workspace/src/generators/move/lib/normalize-schema.ts @@ -1,4 +1,4 @@ -import { ProjectConfiguration, Tree, getWorkspaceLayout } from '@nrwl/devkit'; +import { getWorkspaceLayout, ProjectConfiguration, Tree } from '@nrwl/devkit'; import { getImportPath } from 'nx/src/utils/path'; import type { NormalizedSchema, Schema } from '../schema'; import { getDestination, getNewProjectName, normalizeSlashes } from './utils'; @@ -19,7 +19,7 @@ export function normalizeSchema( destination, importPath: schema.importPath ?? - normalizeSlashes(getImportPath(npmScope, newProjectName)), + normalizeSlashes(getImportPath(npmScope, destination)), newProjectName, relativeToRootDestination: getDestination( tree,