-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(core): allow configuration in inflix
- Loading branch information
Showing
5 changed files
with
198 additions
and
30 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
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 |
---|---|---|
@@ -0,0 +1,137 @@ | ||
import type { ProjectGraph } from '../../config/project-graph'; | ||
import { parseRunOneOptions } from './run-one'; | ||
|
||
describe('parseRunOneOptions', () => { | ||
const projectGraph: ProjectGraph = { | ||
nodes: { | ||
project: { | ||
name: 'project', | ||
data: { | ||
root: '', | ||
targets: { | ||
target: { | ||
configurations: { | ||
dev: {}, | ||
}, | ||
}, | ||
'target:target': { | ||
configurations: { | ||
dev: {}, | ||
}, | ||
}, | ||
'hello:world': {}, | ||
}, | ||
}, | ||
type: 'app', | ||
}, | ||
}, | ||
dependencies: {}, | ||
}; | ||
|
||
it('should split format project:target:configuration', () => { | ||
expect( | ||
parseRunOneOptions( | ||
'', | ||
{ | ||
'project:target:configuration': 'project:target:configuration', | ||
}, | ||
projectGraph, | ||
{} | ||
) | ||
).toEqual({ | ||
configuration: 'configuration', | ||
parsedArgs: {}, | ||
project: 'project', | ||
target: 'target', | ||
}); | ||
|
||
expect( | ||
parseRunOneOptions( | ||
'', | ||
{ | ||
'project:target:configuration': 'project:target', | ||
}, | ||
projectGraph, | ||
{} | ||
) | ||
).toEqual({ | ||
parsedArgs: {}, | ||
project: 'project', | ||
target: 'target', | ||
}); | ||
}); | ||
|
||
it('should split format target:configuration for default project', () => { | ||
expect( | ||
parseRunOneOptions( | ||
'', | ||
{ | ||
'project:target:configuration': 'target', | ||
}, | ||
projectGraph, | ||
{ defaultProject: 'project' } | ||
) | ||
).toEqual({ | ||
parsedArgs: {}, | ||
project: 'project', | ||
target: 'target', | ||
}); | ||
}); | ||
|
||
it('should parse options with project and target specified', () => { | ||
expect( | ||
parseRunOneOptions( | ||
'', | ||
{ | ||
project: 'project', | ||
target: 'target', | ||
}, | ||
projectGraph, | ||
{ defaultProject: 'project' } | ||
) | ||
).toEqual({ | ||
parsedArgs: { | ||
target: 'target', | ||
}, | ||
project: 'project', | ||
target: 'target', | ||
}); | ||
|
||
expect( | ||
parseRunOneOptions( | ||
'', | ||
{ | ||
project: 'project', | ||
target: 'target:configuration', | ||
}, | ||
projectGraph, | ||
{ defaultProject: 'project' } | ||
) | ||
).toEqual({ | ||
parsedArgs: { | ||
target: 'target:configuration', | ||
}, | ||
project: 'project', | ||
target: 'target', | ||
configuration: 'configuration', | ||
}); | ||
|
||
expect( | ||
parseRunOneOptions( | ||
'', | ||
{ | ||
project: 'project', | ||
target: 'target:target', | ||
}, | ||
projectGraph, | ||
{ defaultProject: 'project' } | ||
) | ||
).toEqual({ | ||
parsedArgs: { | ||
target: 'target:target', | ||
}, | ||
project: 'project', | ||
target: 'target:target', | ||
}); | ||
}); | ||
}); |
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
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
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 |
---|---|---|
@@ -1,64 +1,84 @@ | ||
import { ProjectGraph } from '../config/project-graph'; | ||
import { ProjectGraphBuilder } from '../project-graph/project-graph-builder'; | ||
import type { ProjectGraph } from '../config/project-graph'; | ||
import { splitTarget } from './split-target'; | ||
|
||
let projectGraph: ProjectGraph; | ||
|
||
describe('splitTarget', () => { | ||
beforeAll(() => { | ||
let builder = new ProjectGraphBuilder(); | ||
builder.addNode({ | ||
name: 'project', | ||
data: { | ||
root: '', | ||
targets: { | ||
target: {}, | ||
'target:target': {}, | ||
projectGraph = { | ||
nodes: { | ||
project: { | ||
name: 'project', | ||
data: { | ||
root: '', | ||
targets: { | ||
target: {}, | ||
'target:target': {}, | ||
}, | ||
}, | ||
type: 'app', | ||
}, | ||
}, | ||
type: 'app', | ||
}); | ||
|
||
projectGraph = builder.getUpdatedProjectGraph(); | ||
dependencies: {}, | ||
}; | ||
}); | ||
|
||
it('should support only project', () => { | ||
expect(splitTarget('project', projectGraph)).toEqual(['project']); | ||
expect(splitTarget('random', projectGraph)).toEqual(['random']); // return the project name as is | ||
}); | ||
|
||
it('should project:target', () => { | ||
it('should split format project:target', () => { | ||
expect(splitTarget('project:target', projectGraph)).toEqual([ | ||
'project', | ||
'target', | ||
]); | ||
|
||
expect(splitTarget('project:random', projectGraph)).toEqual([ | ||
'project', | ||
'random', | ||
]); // return the target name as is | ||
}); | ||
|
||
it('should project:target:configuration', () => { | ||
it('should split format project:target:configuration', () => { | ||
expect(splitTarget('project:target:configuration', projectGraph)).toEqual([ | ||
'project', | ||
'target', | ||
'configuration', | ||
]); | ||
|
||
expect(splitTarget('project:random:configuration', projectGraph)).toEqual([ | ||
'project', | ||
'random', | ||
'configuration', | ||
]); // return the target name as is | ||
|
||
expect(splitTarget('project:random:random', projectGraph)).toEqual([ | ||
'project', | ||
'random', | ||
'random', | ||
]); // return the target and configuration name as is | ||
}); | ||
|
||
it('should targets that contain colons when present in the graph', () => { | ||
it('should identify targets that contain colons when present in the graph', () => { | ||
expect( | ||
splitTarget('project:target:target:configuration', projectGraph) | ||
).toEqual(['project', 'target:target', 'configuration']); | ||
|
||
expect(splitTarget('project:target:target', projectGraph)).toEqual([ | ||
'project', | ||
'target:target', | ||
]); | ||
}); | ||
|
||
it('should targets that contain colons when not present in the graph but surrounded by quotes', () => { | ||
it('should identify targets that contain colons when not present in the graph but surrounded by quotes', () => { | ||
expect( | ||
splitTarget('project:"other:other":configuration', projectGraph) | ||
).toEqual(['project', 'other:other', 'configuration']); | ||
}); | ||
|
||
it('should targets that contain colons when not provided graph but surrounded by quotes', () => { | ||
expect( | ||
splitTarget('project:"other:other":configuration', { | ||
nodes: {}, | ||
dependencies: {}, | ||
} as ProjectGraph) | ||
).toEqual(['project', 'other:other', 'configuration']); | ||
expect(splitTarget('project:"other:other"', projectGraph)).toEqual([ | ||
'project', | ||
'other:other', | ||
]); | ||
}); | ||
}); |