feat(misc): dont generate defaultProject for non standalone workspaces
This commit is contained in:
parent
7c65787d5c
commit
82fbb98e7d
@ -139,11 +139,6 @@
|
|||||||
"description": "Whether to configure Tailwind CSS for the application.",
|
"description": "Whether to configure Tailwind CSS for the application.",
|
||||||
"default": false
|
"default": false
|
||||||
},
|
},
|
||||||
"skipDefaultProject": {
|
|
||||||
"description": "Skip setting the project as the default project. When `false` (the default), the project is set as the default project only if there is no default project already set.",
|
|
||||||
"type": "boolean",
|
|
||||||
"default": false
|
|
||||||
},
|
|
||||||
"standalone": {
|
"standalone": {
|
||||||
"description": "Generate an application that is setup to use standalone components.",
|
"description": "Generate an application that is setup to use standalone components.",
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
|
|||||||
@ -159,11 +159,6 @@
|
|||||||
"enum": ["babel", "swc"],
|
"enum": ["babel", "swc"],
|
||||||
"default": "babel"
|
"default": "babel"
|
||||||
},
|
},
|
||||||
"skipDefaultProject": {
|
|
||||||
"description": "Skip setting the project as the default project. When `false` (the default), the project is set as the default project only if there is no default project already set.",
|
|
||||||
"type": "boolean",
|
|
||||||
"default": false
|
|
||||||
},
|
|
||||||
"skipPackageJson": {
|
"skipPackageJson": {
|
||||||
"description": "Do not add dependencies to `package.json`.",
|
"description": "Do not add dependencies to `package.json`.",
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
|
|||||||
@ -20,7 +20,6 @@ import {
|
|||||||
enableStrictTypeChecking,
|
enableStrictTypeChecking,
|
||||||
normalizeOptions,
|
normalizeOptions,
|
||||||
setApplicationStrictDefault,
|
setApplicationStrictDefault,
|
||||||
setDefaultProject,
|
|
||||||
updateAppComponentTemplate,
|
updateAppComponentTemplate,
|
||||||
updateComponentSpec,
|
updateComponentSpec,
|
||||||
updateConfigFiles,
|
updateConfigFiles,
|
||||||
@ -109,10 +108,6 @@ export async function applicationGenerator(
|
|||||||
await addE2e(host, options);
|
await addE2e(host, options);
|
||||||
updateEditorTsConfig(host, options);
|
updateEditorTsConfig(host, options);
|
||||||
|
|
||||||
if (!options.skipDefaultProject) {
|
|
||||||
setDefaultProject(host, options);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options.backendProject) {
|
if (options.backendProject) {
|
||||||
addProxyConfig(host, options);
|
addProxyConfig(host, options);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,7 +11,6 @@ export * from './nrwl-home-tpl';
|
|||||||
export * from './remove-scaffolded-e2e';
|
export * from './remove-scaffolded-e2e';
|
||||||
export * from './root-router-config';
|
export * from './root-router-config';
|
||||||
export * from './set-app-strict-default';
|
export * from './set-app-strict-default';
|
||||||
export * from './set-default-project';
|
|
||||||
export * from './update-component-spec';
|
export * from './update-component-spec';
|
||||||
export * from './update-app-component-template';
|
export * from './update-app-component-template';
|
||||||
export * from './update-nx-component-template';
|
export * from './update-nx-component-template';
|
||||||
|
|||||||
@ -1,15 +0,0 @@
|
|||||||
import type { Tree } from '@nrwl/devkit';
|
|
||||||
import {
|
|
||||||
readWorkspaceConfiguration,
|
|
||||||
updateWorkspaceConfiguration,
|
|
||||||
} from '@nrwl/devkit';
|
|
||||||
import type { NormalizedSchema } from './normalized-schema';
|
|
||||||
|
|
||||||
export function setDefaultProject(tree: Tree, options: NormalizedSchema): void {
|
|
||||||
const workspace = readWorkspaceConfiguration(tree);
|
|
||||||
|
|
||||||
if (!workspace.defaultProject) {
|
|
||||||
workspace.defaultProject = options.name;
|
|
||||||
updateWorkspaceConfiguration(tree, workspace);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -24,7 +24,6 @@ export interface Schema {
|
|||||||
port?: number;
|
port?: number;
|
||||||
setParserOptionsProject?: boolean;
|
setParserOptionsProject?: boolean;
|
||||||
skipPackageJson?: boolean;
|
skipPackageJson?: boolean;
|
||||||
skipDefaultProject?: boolean;
|
|
||||||
standalone?: boolean;
|
standalone?: boolean;
|
||||||
rootProject?: boolean;
|
rootProject?: boolean;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -219,15 +219,6 @@ describe('app', () => {
|
|||||||
expect(appTsConfig.extends).toBe('../../tsconfig.json');
|
expect(appTsConfig.extends).toBe('../../tsconfig.json');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should set default project', async () => {
|
|
||||||
// ACT
|
|
||||||
await generateApp(appTree);
|
|
||||||
|
|
||||||
// ASSERT
|
|
||||||
const { defaultProject } = readWorkspaceConfiguration(appTree);
|
|
||||||
expect(defaultProject).toBe('my-app');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should not overwrite default project if already set', async () => {
|
it('should not overwrite default project if already set', async () => {
|
||||||
// ARRANGE
|
// ARRANGE
|
||||||
const workspace = readWorkspaceConfiguration(appTree);
|
const workspace = readWorkspaceConfiguration(appTree);
|
||||||
@ -241,15 +232,6 @@ describe('app', () => {
|
|||||||
const { defaultProject } = readWorkspaceConfiguration(appTree);
|
const { defaultProject } = readWorkspaceConfiguration(appTree);
|
||||||
expect(defaultProject).toBe('some-awesome-project');
|
expect(defaultProject).toBe('some-awesome-project');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not set default project when "--skip-default-project=true"', async () => {
|
|
||||||
// ACT
|
|
||||||
await generateApp(appTree, 'my-app', { skipDefaultProject: true });
|
|
||||||
|
|
||||||
// ASSERT
|
|
||||||
const { defaultProject } = readWorkspaceConfiguration(appTree);
|
|
||||||
expect(defaultProject).toBeUndefined();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('nested', () => {
|
describe('nested', () => {
|
||||||
|
|||||||
@ -2,7 +2,9 @@ import {
|
|||||||
formatFiles,
|
formatFiles,
|
||||||
installPackagesTask,
|
installPackagesTask,
|
||||||
moveFilesToNewDirectory,
|
moveFilesToNewDirectory,
|
||||||
|
readWorkspaceConfiguration,
|
||||||
Tree,
|
Tree,
|
||||||
|
updateWorkspaceConfiguration,
|
||||||
} from '@nrwl/devkit';
|
} from '@nrwl/devkit';
|
||||||
import { wrapAngularDevkitSchematic } from '@nrwl/devkit/ngcli-adapter';
|
import { wrapAngularDevkitSchematic } from '@nrwl/devkit/ngcli-adapter';
|
||||||
import { convertToNxProjectGenerator } from '@nrwl/workspace/generators';
|
import { convertToNxProjectGenerator } from '@nrwl/workspace/generators';
|
||||||
@ -20,7 +22,6 @@ import {
|
|||||||
enableStrictTypeChecking,
|
enableStrictTypeChecking,
|
||||||
normalizeOptions,
|
normalizeOptions,
|
||||||
setApplicationStrictDefault,
|
setApplicationStrictDefault,
|
||||||
setDefaultProject,
|
|
||||||
updateAppComponentTemplate,
|
updateAppComponentTemplate,
|
||||||
updateComponentSpec,
|
updateComponentSpec,
|
||||||
updateConfigFiles,
|
updateConfigFiles,
|
||||||
@ -121,8 +122,10 @@ export async function applicationGenerator(
|
|||||||
await addE2e(tree, options);
|
await addE2e(tree, options);
|
||||||
updateEditorTsConfig(tree, options);
|
updateEditorTsConfig(tree, options);
|
||||||
|
|
||||||
if (!options.skipDefaultProject) {
|
if (options.rootProject) {
|
||||||
setDefaultProject(tree, options);
|
const workspace = readWorkspaceConfiguration(tree);
|
||||||
|
workspace.defaultProject = options.name;
|
||||||
|
updateWorkspaceConfiguration(tree, workspace);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.backendProject) {
|
if (options.backendProject) {
|
||||||
|
|||||||
@ -214,15 +214,6 @@ describe('app', () => {
|
|||||||
expect(appTsConfig.extends).toBe('../../tsconfig.base.json');
|
expect(appTsConfig.extends).toBe('../../tsconfig.base.json');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should set default project', async () => {
|
|
||||||
// ACT
|
|
||||||
await generateApp(appTree);
|
|
||||||
|
|
||||||
// ASSERT
|
|
||||||
const { defaultProject } = readWorkspaceConfiguration(appTree);
|
|
||||||
expect(defaultProject).toBe('my-app');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should not overwrite default project if already set', async () => {
|
it('should not overwrite default project if already set', async () => {
|
||||||
// ARRANGE
|
// ARRANGE
|
||||||
const workspace = readWorkspaceConfiguration(appTree);
|
const workspace = readWorkspaceConfiguration(appTree);
|
||||||
@ -236,15 +227,6 @@ describe('app', () => {
|
|||||||
const { defaultProject } = readWorkspaceConfiguration(appTree);
|
const { defaultProject } = readWorkspaceConfiguration(appTree);
|
||||||
expect(defaultProject).toBe('some-awesome-project');
|
expect(defaultProject).toBe('some-awesome-project');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not set default project when "--skip-default-project=true"', async () => {
|
|
||||||
// ACT
|
|
||||||
await generateApp(appTree, 'my-app', { skipDefaultProject: true });
|
|
||||||
|
|
||||||
// ASSERT
|
|
||||||
const { defaultProject } = readWorkspaceConfiguration(appTree);
|
|
||||||
expect(defaultProject).toBeUndefined();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('nested', () => {
|
describe('nested', () => {
|
||||||
|
|||||||
@ -11,7 +11,6 @@ export * from './nrwl-home-tpl';
|
|||||||
export * from './remove-scaffolded-e2e';
|
export * from './remove-scaffolded-e2e';
|
||||||
export * from './root-router-config';
|
export * from './root-router-config';
|
||||||
export * from './set-app-strict-default';
|
export * from './set-app-strict-default';
|
||||||
export * from './set-default-project';
|
|
||||||
export * from './update-component-spec';
|
export * from './update-component-spec';
|
||||||
export * from './update-app-component-template';
|
export * from './update-app-component-template';
|
||||||
export * from './update-nx-component-template';
|
export * from './update-nx-component-template';
|
||||||
|
|||||||
@ -1,15 +0,0 @@
|
|||||||
import type { Tree } from '@nrwl/devkit';
|
|
||||||
import {
|
|
||||||
readWorkspaceConfiguration,
|
|
||||||
updateWorkspaceConfiguration,
|
|
||||||
} from '@nrwl/devkit';
|
|
||||||
import type { NormalizedSchema } from './normalized-schema';
|
|
||||||
|
|
||||||
export function setDefaultProject(tree: Tree, options: NormalizedSchema): void {
|
|
||||||
const workspace = readWorkspaceConfiguration(tree);
|
|
||||||
|
|
||||||
if (!workspace.defaultProject) {
|
|
||||||
workspace.defaultProject = options.name;
|
|
||||||
updateWorkspaceConfiguration(tree, workspace);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -24,7 +24,6 @@ export interface Schema {
|
|||||||
port?: number;
|
port?: number;
|
||||||
setParserOptionsProject?: boolean;
|
setParserOptionsProject?: boolean;
|
||||||
skipPackageJson?: boolean;
|
skipPackageJson?: boolean;
|
||||||
skipDefaultProject?: boolean;
|
|
||||||
standalone?: boolean;
|
standalone?: boolean;
|
||||||
rootProject?: boolean;
|
rootProject?: boolean;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -142,11 +142,6 @@
|
|||||||
"description": "Whether to configure Tailwind CSS for the application.",
|
"description": "Whether to configure Tailwind CSS for the application.",
|
||||||
"default": false
|
"default": false
|
||||||
},
|
},
|
||||||
"skipDefaultProject": {
|
|
||||||
"description": "Skip setting the project as the default project. When `false` (the default), the project is set as the default project only if there is no default project already set.",
|
|
||||||
"type": "boolean",
|
|
||||||
"default": false
|
|
||||||
},
|
|
||||||
"standalone": {
|
"standalone": {
|
||||||
"description": "Generate an application that is setup to use standalone components.",
|
"description": "Generate an application that is setup to use standalone components.",
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
|
|||||||
@ -21,7 +21,6 @@ export async function remote(tree: Tree, options: Schema) {
|
|||||||
const appInstallTask = await applicationGenerator(tree, {
|
const appInstallTask = await applicationGenerator(tree, {
|
||||||
...options,
|
...options,
|
||||||
routing: true,
|
routing: true,
|
||||||
skipDefaultProject: true,
|
|
||||||
port,
|
port,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -27,11 +27,9 @@ describe('app', () => {
|
|||||||
js: false,
|
js: false,
|
||||||
unitTestRunner: 'none',
|
unitTestRunner: 'none',
|
||||||
});
|
});
|
||||||
const workspace = readWorkspaceConfiguration(appTree);
|
|
||||||
const projects = getProjects(appTree);
|
const projects = getProjects(appTree);
|
||||||
|
|
||||||
expect(projects.get('my-app').root).toEqual('apps/my-app');
|
expect(projects.get('my-app').root).toEqual('apps/my-app');
|
||||||
expect(workspace.defaultProject).toEqual('my-app');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should update nx.json', async () => {
|
it('should update nx.json', async () => {
|
||||||
@ -105,7 +103,6 @@ describe('app', () => {
|
|||||||
const workspaceJson = readWorkspaceConfiguration(appTree);
|
const workspaceJson = readWorkspaceConfiguration(appTree);
|
||||||
const projects = getProjects(appTree);
|
const projects = getProjects(appTree);
|
||||||
expect(projects.get('my-dir-my-app').root).toEqual('apps/my-dir/my-app');
|
expect(projects.get('my-dir-my-app').root).toEqual('apps/my-dir/my-app');
|
||||||
expect(workspaceJson.defaultProject).toEqual('my-dir-my-app');
|
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
appTree.exists('apps/my-dir/my-app-e2e/.detoxrc.json')
|
appTree.exists('apps/my-dir/my-app-e2e/.detoxrc.json')
|
||||||
@ -187,7 +184,6 @@ describe('app', () => {
|
|||||||
const workspaceJson = readWorkspaceConfiguration(appTree);
|
const workspaceJson = readWorkspaceConfiguration(appTree);
|
||||||
const projects = getProjects(appTree);
|
const projects = getProjects(appTree);
|
||||||
expect(projects.get('my-app').root).toEqual('apps/my-app');
|
expect(projects.get('my-app').root).toEqual('apps/my-app');
|
||||||
expect(workspaceJson.defaultProject).toEqual('my-app');
|
|
||||||
|
|
||||||
expect(appTree.exists('apps/my-app-e2e/.detoxrc.json')).toBeTruthy();
|
expect(appTree.exists('apps/my-app-e2e/.detoxrc.json')).toBeTruthy();
|
||||||
const detoxrc = appTree.read('apps/my-app-e2e/.detoxrc.json', 'utf-8');
|
const detoxrc = appTree.read('apps/my-app-e2e/.detoxrc.json', 'utf-8');
|
||||||
@ -265,7 +261,6 @@ describe('app', () => {
|
|||||||
const workspaceJson = readWorkspaceConfiguration(appTree);
|
const workspaceJson = readWorkspaceConfiguration(appTree);
|
||||||
const projects = getProjects(appTree);
|
const projects = getProjects(appTree);
|
||||||
expect(projects.get('my-app').root).toEqual('apps/my-app');
|
expect(projects.get('my-app').root).toEqual('apps/my-app');
|
||||||
expect(workspaceJson.defaultProject).toEqual('my-app');
|
|
||||||
|
|
||||||
expect(appTree.exists('apps/my-app-e2e/.detoxrc.json')).toBeTruthy();
|
expect(appTree.exists('apps/my-app-e2e/.detoxrc.json')).toBeTruthy();
|
||||||
const detoxrc = appTree.read('apps/my-app-e2e/.detoxrc.json', 'utf-8');
|
const detoxrc = appTree.read('apps/my-app-e2e/.detoxrc.json', 'utf-8');
|
||||||
|
|||||||
@ -24,14 +24,6 @@ export function addProject(host: Tree, options: NormalizedSchema) {
|
|||||||
projectConfiguration,
|
projectConfiguration,
|
||||||
options.standaloneConfig
|
options.standaloneConfig
|
||||||
);
|
);
|
||||||
|
|
||||||
const workspace = readWorkspaceConfiguration(host);
|
|
||||||
|
|
||||||
if (!workspace.defaultProject) {
|
|
||||||
workspace.defaultProject = options.projectName;
|
|
||||||
|
|
||||||
updateWorkspaceConfiguration(host, workspace);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTargets(options: NormalizedSchema) {
|
function getTargets(options: NormalizedSchema) {
|
||||||
|
|||||||
@ -19,13 +19,10 @@ describe('app', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const workspaceJson = readJson(tree, 'workspace.json');
|
const workspaceJson = readJson(tree, 'workspace.json');
|
||||||
const nxJson = readJson<NxJsonConfiguration>(tree, 'nx.json');
|
|
||||||
|
|
||||||
expect(workspaceJson.projects['my-app'].root).toEqual('apps/my-app');
|
expect(workspaceJson.projects['my-app'].root).toEqual('apps/my-app');
|
||||||
expect(workspaceJson.projects['my-app-e2e'].root).toEqual(
|
expect(workspaceJson.projects['my-app-e2e'].root).toEqual(
|
||||||
'apps/my-app-e2e'
|
'apps/my-app-e2e'
|
||||||
);
|
);
|
||||||
expect(nxJson.defaultProject).toEqual('my-app');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should update tags and implicit dependencies', async () => {
|
it('should update tags and implicit dependencies', async () => {
|
||||||
|
|||||||
@ -9,10 +9,6 @@ import { NormalizedSchema } from './normalize-options';
|
|||||||
export function setDefaults(host: Tree, options: NormalizedSchema) {
|
export function setDefaults(host: Tree, options: NormalizedSchema) {
|
||||||
const workspace = readWorkspaceConfiguration(host);
|
const workspace = readWorkspaceConfiguration(host);
|
||||||
|
|
||||||
if (!workspace.defaultProject) {
|
|
||||||
workspace.defaultProject = options.projectName;
|
|
||||||
}
|
|
||||||
|
|
||||||
workspace.generators = workspace.generators || {};
|
workspace.generators = workspace.generators || {};
|
||||||
workspace.generators['@nrwl/next'] = workspace.generators['@nrwl/next'] || {};
|
workspace.generators['@nrwl/next'] = workspace.generators['@nrwl/next'] || {};
|
||||||
const prev = workspace.generators['@nrwl/next'];
|
const prev = workspace.generators['@nrwl/next'];
|
||||||
|
|||||||
@ -89,7 +89,6 @@ describe('app', () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
expect(workspaceJson.projects['my-node-app-e2e']).toBeUndefined();
|
expect(workspaceJson.projects['my-node-app-e2e']).toBeUndefined();
|
||||||
expect(nxJson.defaultProject).toEqual('my-node-app');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should update tags', async () => {
|
it('should update tags', async () => {
|
||||||
@ -215,7 +214,6 @@ describe('app', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
expect(workspaceJson.projects['my-dir-my-node-app-e2e']).toBeUndefined();
|
expect(workspaceJson.projects['my-dir-my-node-app-e2e']).toBeUndefined();
|
||||||
expect(nxJson.defaultProject).toEqual('my-dir-my-node-app');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should update tags', async () => {
|
it('should update tags', async () => {
|
||||||
|
|||||||
@ -107,13 +107,6 @@ function addProject(tree: Tree, options: NormalizedSchema) {
|
|||||||
project,
|
project,
|
||||||
options.standaloneConfig
|
options.standaloneConfig
|
||||||
);
|
);
|
||||||
|
|
||||||
const workspace = readWorkspaceConfiguration(tree);
|
|
||||||
|
|
||||||
if (!workspace.defaultProject) {
|
|
||||||
workspace.defaultProject = options.name;
|
|
||||||
updateWorkspaceConfiguration(tree, workspace);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function addAppFiles(tree: Tree, options: NormalizedSchema) {
|
function addAppFiles(tree: Tree, options: NormalizedSchema) {
|
||||||
|
|||||||
@ -64,9 +64,6 @@ export function createNxJsonFile(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
nxJson.defaultBase = deduceDefaultBase();
|
nxJson.defaultBase = deduceDefaultBase();
|
||||||
if (defaultProject) {
|
|
||||||
nxJson.defaultProject = defaultProject;
|
|
||||||
}
|
|
||||||
writeJsonFile(nxJsonPath, nxJson);
|
writeJsonFile(nxJsonPath, nxJson);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -25,11 +25,9 @@ describe('app', () => {
|
|||||||
e2eTestRunner: 'none',
|
e2eTestRunner: 'none',
|
||||||
install: false,
|
install: false,
|
||||||
});
|
});
|
||||||
const workspaceJson = readWorkspaceConfiguration(appTree);
|
|
||||||
const projects = getProjects(appTree);
|
const projects = getProjects(appTree);
|
||||||
|
|
||||||
expect(projects.get('my-app').root).toEqual('apps/my-app');
|
expect(projects.get('my-app').root).toEqual('apps/my-app');
|
||||||
expect(workspaceJson.defaultProject).toEqual('my-app');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should update nx.json', async () => {
|
it('should update nx.json', async () => {
|
||||||
@ -90,10 +88,8 @@ describe('app', () => {
|
|||||||
install: false,
|
install: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
const workspaceJson = readWorkspaceConfiguration(appTree);
|
|
||||||
const projects = getProjects(appTree);
|
const projects = getProjects(appTree);
|
||||||
expect(projects.get('my-dir-my-app').root).toEqual('apps/my-dir/my-app');
|
expect(projects.get('my-dir-my-app').root).toEqual('apps/my-dir/my-app');
|
||||||
expect(workspaceJson.defaultProject).toEqual('my-dir-my-app');
|
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
appTree.exists('apps/my-dir/my-app-e2e/.detoxrc.json')
|
appTree.exists('apps/my-dir/my-app-e2e/.detoxrc.json')
|
||||||
@ -146,12 +142,9 @@ describe('app', () => {
|
|||||||
install: false,
|
install: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
const workspaceJson = readWorkspaceConfiguration(appTree);
|
|
||||||
const projects = getProjects(appTree);
|
const projects = getProjects(appTree);
|
||||||
expect(projects.get('my-app').root).toEqual('apps/my-app');
|
expect(projects.get('my-app').root).toEqual('apps/my-app');
|
||||||
expect(workspaceJson.defaultProject).toEqual('my-app');
|
|
||||||
|
|
||||||
expect(appTree.exists('apps/my-app-e2e/.detoxrc.json')).toBeTruthy();
|
|
||||||
const detoxrc = appTree.read('apps/my-app-e2e/.detoxrc.json', 'utf-8');
|
const detoxrc = appTree.read('apps/my-app-e2e/.detoxrc.json', 'utf-8');
|
||||||
// Strip trailing commas
|
// Strip trailing commas
|
||||||
const detoxrcJson = JSON.parse(
|
const detoxrcJson = JSON.parse(
|
||||||
|
|||||||
@ -20,14 +20,6 @@ export function addProject(host: Tree, options: NormalizedSchema) {
|
|||||||
addProjectConfiguration(host, options.projectName, {
|
addProjectConfiguration(host, options.projectName, {
|
||||||
...project,
|
...project,
|
||||||
});
|
});
|
||||||
|
|
||||||
const workspace = readWorkspaceConfiguration(host);
|
|
||||||
|
|
||||||
if (!workspace.defaultProject) {
|
|
||||||
workspace.defaultProject = options.projectName;
|
|
||||||
|
|
||||||
updateWorkspaceConfiguration(host, workspace);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTargets(options: NormalizedSchema) {
|
function getTargets(options: NormalizedSchema) {
|
||||||
|
|||||||
@ -37,12 +37,10 @@ describe('app', () => {
|
|||||||
it('should update workspace.json', async () => {
|
it('should update workspace.json', async () => {
|
||||||
await applicationGenerator(appTree, schema);
|
await applicationGenerator(appTree, schema);
|
||||||
|
|
||||||
const workspaceJson = readWorkspaceConfiguration(appTree);
|
|
||||||
const projects = getProjects(appTree);
|
const projects = getProjects(appTree);
|
||||||
|
|
||||||
expect(projects.get('my-app').root).toEqual('apps/my-app');
|
expect(projects.get('my-app').root).toEqual('apps/my-app');
|
||||||
expect(projects.get('my-app-e2e').root).toEqual('apps/my-app-e2e');
|
expect(projects.get('my-app-e2e').root).toEqual('apps/my-app-e2e');
|
||||||
expect(workspaceJson.defaultProject).toEqual('my-app');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not overwrite default project if already set', async () => {
|
it('should not overwrite default project if already set', async () => {
|
||||||
@ -56,17 +54,6 @@ describe('app', () => {
|
|||||||
expect(defaultProject).toBe('some-awesome-project');
|
expect(defaultProject).toBe('some-awesome-project');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not set defaultProject when "--skip-default-project=true"', async () => {
|
|
||||||
await applicationGenerator(appTree, {
|
|
||||||
...schema,
|
|
||||||
skipDefaultProject: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
const { defaultProject } = readWorkspaceConfiguration(appTree);
|
|
||||||
|
|
||||||
expect(defaultProject).toBeUndefined();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should update tags and implicit dependencies', async () => {
|
it('should update tags and implicit dependencies', async () => {
|
||||||
await applicationGenerator(appTree, { ...schema, tags: 'one,two' });
|
await applicationGenerator(appTree, { ...schema, tags: 'one,two' });
|
||||||
|
|
||||||
|
|||||||
@ -12,7 +12,7 @@ export function setDefaults(host: Tree, options: NormalizedSchema) {
|
|||||||
|
|
||||||
const workspace = readWorkspaceConfiguration(host);
|
const workspace = readWorkspaceConfiguration(host);
|
||||||
|
|
||||||
if (!options.skipDefaultProject && !workspace.defaultProject) {
|
if (options.rootProject) {
|
||||||
workspace.defaultProject = options.projectName;
|
workspace.defaultProject = options.projectName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -27,7 +27,6 @@ export interface Schema {
|
|||||||
compiler?: 'babel' | 'swc';
|
compiler?: 'babel' | 'swc';
|
||||||
remotes?: string[];
|
remotes?: string[];
|
||||||
devServerPort?: number;
|
devServerPort?: number;
|
||||||
skipDefaultProject?: boolean;
|
|
||||||
skipPackageJson?: boolean;
|
skipPackageJson?: boolean;
|
||||||
rootProject?: boolean;
|
rootProject?: boolean;
|
||||||
bundler?: 'webpack' | 'vite';
|
bundler?: 'webpack' | 'vite';
|
||||||
|
|||||||
@ -165,11 +165,6 @@
|
|||||||
"enum": ["babel", "swc"],
|
"enum": ["babel", "swc"],
|
||||||
"default": "babel"
|
"default": "babel"
|
||||||
},
|
},
|
||||||
"skipDefaultProject": {
|
|
||||||
"description": "Skip setting the project as the default project. When `false` (the default), the project is set as the default project only if there is no default project already set.",
|
|
||||||
"type": "boolean",
|
|
||||||
"default": false
|
|
||||||
},
|
|
||||||
"skipPackageJson": {
|
"skipPackageJson": {
|
||||||
"description": "Do not add dependencies to `package.json`.",
|
"description": "Do not add dependencies to `package.json`.",
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
|
|||||||
@ -43,7 +43,6 @@ export async function remoteGenerator(host: Tree, schema: Schema) {
|
|||||||
const options = normalizeOptions<Schema>(host, schema);
|
const options = normalizeOptions<Schema>(host, schema);
|
||||||
const initAppTask = await applicationGenerator(host, {
|
const initAppTask = await applicationGenerator(host, {
|
||||||
...options,
|
...options,
|
||||||
skipDefaultProject: true,
|
|
||||||
// Only webpack works with module federation for now.
|
// Only webpack works with module federation for now.
|
||||||
bundler: 'webpack',
|
bundler: 'webpack',
|
||||||
});
|
});
|
||||||
|
|||||||
@ -26,13 +26,10 @@ describe('app', () => {
|
|||||||
standaloneConfig: false,
|
standaloneConfig: false,
|
||||||
});
|
});
|
||||||
const workspaceJson = readJson(tree, '/workspace.json');
|
const workspaceJson = readJson(tree, '/workspace.json');
|
||||||
const nxJson = readJson<NxJsonConfiguration>(tree, 'nx.json');
|
|
||||||
|
|
||||||
expect(workspaceJson.projects['my-app'].root).toEqual('apps/my-app');
|
expect(workspaceJson.projects['my-app'].root).toEqual('apps/my-app');
|
||||||
expect(workspaceJson.projects['my-app-e2e'].root).toEqual(
|
expect(workspaceJson.projects['my-app-e2e'].root).toEqual(
|
||||||
'apps/my-app-e2e'
|
'apps/my-app-e2e'
|
||||||
);
|
);
|
||||||
expect(nxJson.defaultProject).toEqual('my-app');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should update tags and implicit dependencies', async () => {
|
it('should update tags and implicit dependencies', async () => {
|
||||||
|
|||||||
@ -156,14 +156,6 @@ async function addProject(tree: Tree, options: NormalizedSchema) {
|
|||||||
if (options.bundler !== 'vite') {
|
if (options.bundler !== 'vite') {
|
||||||
await setupBundler(tree, options);
|
await setupBundler(tree, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
const workspace = readWorkspaceConfiguration(tree);
|
|
||||||
|
|
||||||
if (!workspace.defaultProject) {
|
|
||||||
workspace.defaultProject = options.projectName;
|
|
||||||
|
|
||||||
updateWorkspaceConfiguration(tree, workspace);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function setDefaults(tree: Tree, options: NormalizedSchema) {
|
function setDefaults(tree: Tree, options: NormalizedSchema) {
|
||||||
|
|||||||
@ -47,7 +47,6 @@ describe('update to v13 config locations', () => {
|
|||||||
expect(nxJson.generators).toEqual({});
|
expect(nxJson.generators).toEqual({});
|
||||||
expect(workspaceJson.projects.a.tags).toEqual(['test']);
|
expect(workspaceJson.projects.a.tags).toEqual(['test']);
|
||||||
expect(workspaceJson.cli).not.toBeDefined();
|
expect(workspaceJson.cli).not.toBeDefined();
|
||||||
expect(workspaceJson.defaultProject).not.toBeDefined();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('v1 workspace', () => {
|
describe('v1 workspace', () => {
|
||||||
@ -91,7 +90,6 @@ describe('update to v13 config locations', () => {
|
|||||||
});
|
});
|
||||||
expect(workspaceJson.projects.a.tags).toEqual(['test']);
|
expect(workspaceJson.projects.a.tags).toEqual(['test']);
|
||||||
expect(workspaceJson.cli).not.toBeDefined();
|
expect(workspaceJson.cli).not.toBeDefined();
|
||||||
expect(workspaceJson.defaultProject).not.toBeDefined();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user