-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(core): support import detection of packages installed from git re…
…mote URL (#27569)
- Loading branch information
Showing
2 changed files
with
96 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -479,7 +479,7 @@ describe('TargetProjectLocator', () => { | |
expect(proj5).toEqual('proj5'); | ||
}); | ||
|
||
it('should be able to resolve packages alises', () => { | ||
it('should be able to resolve packages aliases', () => { | ||
const lodash = targetProjectLocator.findProjectFromImport( | ||
'lodash', | ||
'libs/proj/index.ts' | ||
|
@@ -899,6 +899,85 @@ describe('TargetProjectLocator', () => { | |
expect(result).toEqual('npm:@json2csv/plainjs'); | ||
}); | ||
}); | ||
|
||
describe('findNpmProjectFromImport', () => { | ||
it('should resolve external node when the version does not match its own package.json (i.e. git remote) ', () => { | ||
const projects = { | ||
proj: { | ||
name: 'proj', | ||
type: 'lib' as const, | ||
data: { | ||
root: 'proj', | ||
}, | ||
}, | ||
}; | ||
const npmProjects = { | ||
'npm:foo': { | ||
name: 'npm:foo' as const, | ||
type: 'npm' as const, | ||
data: { | ||
version: | ||
'git+ssh://[email protected]/example/foo.git#6f4b450fc642abba540535f0755c990b42a16026', | ||
packageName: 'foo', | ||
}, | ||
}, | ||
}; | ||
|
||
const targetProjectLocator = new TargetProjectLocator( | ||
projects, | ||
npmProjects, | ||
new Map() | ||
); | ||
targetProjectLocator['readPackageJson'] = () => ({ | ||
name: 'foo', | ||
version: '0.0.1', | ||
}); | ||
const result = targetProjectLocator.findNpmProjectFromImport( | ||
'lodash', | ||
'proj/index.ts' | ||
); | ||
|
||
expect(result).toEqual('npm:foo'); | ||
}); | ||
|
||
it('should resolve a specific version of external node', () => { | ||
const projects = { | ||
proj: { | ||
name: 'proj', | ||
type: 'lib' as const, | ||
data: { | ||
root: 'proj', | ||
}, | ||
}, | ||
}; | ||
const npmProjects = { | ||
'npm:[email protected]': { | ||
name: 'npm:[email protected]' as const, | ||
type: 'npm' as const, | ||
data: { | ||
version: '0.0.1', | ||
packageName: 'foo', | ||
}, | ||
}, | ||
}; | ||
|
||
const targetProjectLocator = new TargetProjectLocator( | ||
projects, | ||
npmProjects, | ||
new Map() | ||
); | ||
targetProjectLocator['readPackageJson'] = () => ({ | ||
name: 'foo', | ||
version: '0.0.1', | ||
}); | ||
const result = targetProjectLocator.findNpmProjectFromImport( | ||
'lodash', | ||
'proj/index.ts' | ||
); | ||
|
||
expect(result).toEqual('npm:[email protected]'); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('isBuiltinModuleImport()', () => { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters