* feat(core): consolidate settings between workspace.json + nx.json workspace.json (and linked project.json files) now contain all project specific settings. nx.json now contains all settings that affect the whole workspace. * chore(core): fix angular unit tests w/ new config * chore(core): fix failing tests * chore(core): fix formatting * chore(core): fix more tests * chore(core): normalize-nx-json feedback * chore(core): Fix more unit tests * chore(core): fix remaining tests in workspace * chore(linter): fix remaining linter tests * chore(core): fix remaining spec + build issues * chore(core): formatting fixes * feat(core): migration script to move config options to new locations * chore(core): fix e2e tests * chore(core): run format * chore(react-native): fix failing tests Signed-off-by: AgentEnder <craigorycoppola@gmail.com> * feat(core): move properties to new location during format step Signed-off-by: AgentEnder <craigorycoppola@gmail.com> * feat(core): initial pass on ngcli-adapter for property consolidation Signed-off-by: AgentEnder <craigorycoppola@gmail.com> * chore(misc): fix tests Signed-off-by: AgentEnder <craigorycoppola@gmail.com> * docs(core): update docs with changes * chore(misc): fix tests * chore(core): code review changes updateWorkspaceJson -> updateWorkspace, no longer uses updater function Signed-off-by: AgentEnder <craigorycoppola@gmail.com> * chore(core): fix bug in ngcli impl * fix(core): fix bug in ngcli-adapter Signed-off-by: AgentEnder <craigorycoppola@gmail.com> * fix(core): fix ngcli-adapter Signed-off-by: AgentEnder <craigorycoppola@gmail.com> * chore(core): fix workspace e2e * chore(core): fix nx-plugin e2e * fix(core): move defaultProject to nx.json * chore(core): fix broken workspace test * chore(core): formatting * chore(core): fix workspace format * chore(core): add nxJson to ExecutorContext Signed-off-by: AgentEnder <craigorycoppola@gmail.com> * chore(core): remove all references ot `NxProjectConfiguration` from our code * chore(core): Review Changes * fix(core): update new config locations v13 migration
125 lines
3.1 KiB
TypeScript
125 lines
3.1 KiB
TypeScript
import { parseRunOneOptions } from './parse-run-one-options';
|
|
|
|
describe('parseRunOneOptions', () => {
|
|
const workspaceJson = {
|
|
projects: {
|
|
myproj: {
|
|
architect: { build: { defaultConfiguration: 'someDefaultConfig' } },
|
|
},
|
|
},
|
|
};
|
|
const nxJson = {};
|
|
const args = ['build', 'myproj', '--configuration=production', '--flag=true'];
|
|
|
|
it('should work', () => {
|
|
expect(parseRunOneOptions('root', workspaceJson, nxJson, args)).toEqual({
|
|
project: 'myproj',
|
|
target: 'build',
|
|
configuration: 'production',
|
|
parsedArgs: { _: [], flag: 'true' },
|
|
});
|
|
});
|
|
|
|
it('should work with --prod', () => {
|
|
expect(
|
|
parseRunOneOptions('root', workspaceJson, nxJson, [
|
|
'build',
|
|
'myproj',
|
|
'--prod',
|
|
'--flag=true',
|
|
])
|
|
).toEqual({
|
|
project: 'myproj',
|
|
target: 'build',
|
|
configuration: 'production',
|
|
parsedArgs: { _: [], flag: 'true' },
|
|
});
|
|
});
|
|
|
|
it('should override --prod with --configuration', () => {
|
|
expect(
|
|
parseRunOneOptions('root', workspaceJson, nxJson, [
|
|
'build',
|
|
'myproj',
|
|
'--prod',
|
|
'--configuration',
|
|
'dev',
|
|
'--flag=true',
|
|
])
|
|
).toEqual({
|
|
project: 'myproj',
|
|
target: 'build',
|
|
configuration: 'dev',
|
|
parsedArgs: { _: [], flag: 'true' },
|
|
});
|
|
});
|
|
|
|
it('should work with run syntax', () => {
|
|
expect(
|
|
parseRunOneOptions('root', workspaceJson, nxJson, [
|
|
'run',
|
|
'myproj:build:staging',
|
|
'--flag=true',
|
|
])
|
|
).toEqual({
|
|
project: 'myproj',
|
|
target: 'build',
|
|
configuration: 'staging',
|
|
parsedArgs: { _: [], flag: 'true' },
|
|
});
|
|
});
|
|
|
|
it('should use defaultProjectName when no provided', () => {
|
|
expect(
|
|
parseRunOneOptions(
|
|
'root',
|
|
{ ...workspaceJson },
|
|
{ cli: { defaultProjectName: 'myproj' } },
|
|
['build', '--flag=true']
|
|
)
|
|
).toEqual({
|
|
project: 'myproj',
|
|
target: 'build',
|
|
configuration: 'someDefaultConfig',
|
|
parsedArgs: { _: [], flag: 'true' },
|
|
});
|
|
});
|
|
|
|
it('should use defaultConfiguration when no provided', () => {
|
|
expect(
|
|
parseRunOneOptions('root', workspaceJson, nxJson, [
|
|
'run',
|
|
'myproj:build',
|
|
'--flag=true',
|
|
])
|
|
).toEqual({
|
|
project: 'myproj',
|
|
target: 'build',
|
|
configuration: 'someDefaultConfig',
|
|
parsedArgs: { _: [], flag: 'true' },
|
|
});
|
|
});
|
|
|
|
it('should return false when the task is not recognized', () => {
|
|
expect(parseRunOneOptions('root', {}, nxJson, args)).toBe(false);
|
|
expect(parseRunOneOptions('root', { projects: {} }, nxJson, args)).toBe(
|
|
false
|
|
);
|
|
expect(
|
|
parseRunOneOptions('root', { projects: { architect: {} } }, nxJson, args)
|
|
).toBe(false);
|
|
});
|
|
|
|
it('should return false when cannot find the right project', () => {
|
|
expect(
|
|
parseRunOneOptions('root', workspaceJson, nxJson, ['build', 'wrongproj'])
|
|
).toBe(false);
|
|
});
|
|
|
|
it('should return false when no project specified', () => {
|
|
expect(parseRunOneOptions('root', workspaceJson, nxJson, ['build'])).toBe(
|
|
false
|
|
);
|
|
});
|
|
});
|