Skip to content

Commit

Permalink
feat(misc): dont generate defaultProject for non standalone workspaces
Browse files Browse the repository at this point in the history
  • Loading branch information
vsavkin committed Dec 21, 2022
1 parent 7c65787 commit 82fbb98
Show file tree
Hide file tree
Showing 31 changed files with 7 additions and 175 deletions.
5 changes: 0 additions & 5 deletions docs/generated/packages/angular/generators/application.json
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,6 @@
"description": "Whether to configure Tailwind CSS for the application.",
"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": {
"description": "Generate an application that is setup to use standalone components.",
"type": "boolean",
Expand Down
5 changes: 0 additions & 5 deletions docs/generated/packages/react/generators/application.json
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,6 @@
"enum": ["babel", "swc"],
"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": {
"description": "Do not add dependencies to `package.json`.",
"type": "boolean",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import {
enableStrictTypeChecking,
normalizeOptions,
setApplicationStrictDefault,
setDefaultProject,
updateAppComponentTemplate,
updateComponentSpec,
updateConfigFiles,
Expand Down Expand Up @@ -109,10 +108,6 @@ export async function applicationGenerator(
await addE2e(host, options);
updateEditorTsConfig(host, options);

if (!options.skipDefaultProject) {
setDefaultProject(host, options);
}

if (options.backendProject) {
addProxyConfig(host, options);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export * from './nrwl-home-tpl';
export * from './remove-scaffolded-e2e';
export * from './root-router-config';
export * from './set-app-strict-default';
export * from './set-default-project';
export * from './update-component-spec';
export * from './update-app-component-template';
export * from './update-nx-component-template';
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export interface Schema {
port?: number;
setParserOptionsProject?: boolean;
skipPackageJson?: boolean;
skipDefaultProject?: boolean;
standalone?: boolean;
rootProject?: boolean;
}
18 changes: 0 additions & 18 deletions packages/angular/src/generators/application/application.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,15 +219,6 @@ describe('app', () => {
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 () => {
// ARRANGE
const workspace = readWorkspaceConfiguration(appTree);
Expand All @@ -241,15 +232,6 @@ describe('app', () => {
const { defaultProject } = readWorkspaceConfiguration(appTree);
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', () => {
Expand Down
9 changes: 6 additions & 3 deletions packages/angular/src/generators/application/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import {
formatFiles,
installPackagesTask,
moveFilesToNewDirectory,
readWorkspaceConfiguration,
Tree,
updateWorkspaceConfiguration,
} from '@nrwl/devkit';
import { wrapAngularDevkitSchematic } from '@nrwl/devkit/ngcli-adapter';
import { convertToNxProjectGenerator } from '@nrwl/workspace/generators';
Expand All @@ -20,7 +22,6 @@ import {
enableStrictTypeChecking,
normalizeOptions,
setApplicationStrictDefault,
setDefaultProject,
updateAppComponentTemplate,
updateComponentSpec,
updateConfigFiles,
Expand Down Expand Up @@ -121,8 +122,10 @@ export async function applicationGenerator(
await addE2e(tree, options);
updateEditorTsConfig(tree, options);

if (!options.skipDefaultProject) {
setDefaultProject(tree, options);
if (options.rootProject) {
const workspace = readWorkspaceConfiguration(tree);
workspace.defaultProject = options.name;
updateWorkspaceConfiguration(tree, workspace);
}

if (options.backendProject) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,15 +214,6 @@ describe('app', () => {
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 () => {
// ARRANGE
const workspace = readWorkspaceConfiguration(appTree);
Expand All @@ -236,15 +227,6 @@ describe('app', () => {
const { defaultProject } = readWorkspaceConfiguration(appTree);
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', () => {
Expand Down
1 change: 0 additions & 1 deletion packages/angular/src/generators/application/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export * from './nrwl-home-tpl';
export * from './remove-scaffolded-e2e';
export * from './root-router-config';
export * from './set-app-strict-default';
export * from './set-default-project';
export * from './update-component-spec';
export * from './update-app-component-template';
export * from './update-nx-component-template';
Expand Down

This file was deleted.

1 change: 0 additions & 1 deletion packages/angular/src/generators/application/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export interface Schema {
port?: number;
setParserOptionsProject?: boolean;
skipPackageJson?: boolean;
skipDefaultProject?: boolean;
standalone?: boolean;
rootProject?: boolean;
}
5 changes: 0 additions & 5 deletions packages/angular/src/generators/application/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,6 @@
"description": "Whether to configure Tailwind CSS for the application.",
"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": {
"description": "Generate an application that is setup to use standalone components.",
"type": "boolean",
Expand Down
1 change: 0 additions & 1 deletion packages/angular/src/generators/remote/remote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export async function remote(tree: Tree, options: Schema) {
const appInstallTask = await applicationGenerator(tree, {
...options,
routing: true,
skipDefaultProject: true,
port,
});

Expand Down
5 changes: 0 additions & 5 deletions packages/expo/src/generators/application/application.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,9 @@ describe('app', () => {
js: false,
unitTestRunner: 'none',
});
const workspace = readWorkspaceConfiguration(appTree);
const projects = getProjects(appTree);

expect(projects.get('my-app').root).toEqual('apps/my-app');
expect(workspace.defaultProject).toEqual('my-app');
});

it('should update nx.json', async () => {
Expand Down Expand Up @@ -105,7 +103,6 @@ describe('app', () => {
const workspaceJson = readWorkspaceConfiguration(appTree);
const projects = getProjects(appTree);
expect(projects.get('my-dir-my-app').root).toEqual('apps/my-dir/my-app');
expect(workspaceJson.defaultProject).toEqual('my-dir-my-app');

expect(
appTree.exists('apps/my-dir/my-app-e2e/.detoxrc.json')
Expand Down Expand Up @@ -187,7 +184,6 @@ describe('app', () => {
const workspaceJson = readWorkspaceConfiguration(appTree);
const projects = getProjects(appTree);
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');
Expand Down Expand Up @@ -265,7 +261,6 @@ describe('app', () => {
const workspaceJson = readWorkspaceConfiguration(appTree);
const projects = getProjects(appTree);
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');
Expand Down
8 changes: 0 additions & 8 deletions packages/expo/src/generators/application/lib/add-project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,6 @@ export function addProject(host: Tree, options: NormalizedSchema) {
projectConfiguration,
options.standaloneConfig
);

const workspace = readWorkspaceConfiguration(host);

if (!workspace.defaultProject) {
workspace.defaultProject = options.projectName;

updateWorkspaceConfiguration(host, workspace);
}
}

function getTargets(options: NormalizedSchema) {
Expand Down
3 changes: 0 additions & 3 deletions packages/next/src/generators/application/application.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,10 @@ describe('app', () => {
});

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-e2e'].root).toEqual(
'apps/my-app-e2e'
);
expect(nxJson.defaultProject).toEqual('my-app');
});

it('should update tags and implicit dependencies', async () => {
Expand Down
4 changes: 0 additions & 4 deletions packages/next/src/generators/application/lib/set-defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ import { NormalizedSchema } from './normalize-options';
export function setDefaults(host: Tree, options: NormalizedSchema) {
const workspace = readWorkspaceConfiguration(host);

if (!workspace.defaultProject) {
workspace.defaultProject = options.projectName;
}

workspace.generators = workspace.generators || {};
workspace.generators['@nrwl/next'] = workspace.generators['@nrwl/next'] || {};
const prev = workspace.generators['@nrwl/next'];
Expand Down
2 changes: 0 additions & 2 deletions packages/node/src/generators/application/application.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ describe('app', () => {
},
});
expect(workspaceJson.projects['my-node-app-e2e']).toBeUndefined();
expect(nxJson.defaultProject).toEqual('my-node-app');
});

it('should update tags', async () => {
Expand Down Expand Up @@ -215,7 +214,6 @@ describe('app', () => {
});

expect(workspaceJson.projects['my-dir-my-node-app-e2e']).toBeUndefined();
expect(nxJson.defaultProject).toEqual('my-dir-my-node-app');
});

it('should update tags', async () => {
Expand Down
7 changes: 0 additions & 7 deletions packages/node/src/generators/application/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,6 @@ function addProject(tree: Tree, options: NormalizedSchema) {
project,
options.standaloneConfig
);

const workspace = readWorkspaceConfiguration(tree);

if (!workspace.defaultProject) {
workspace.defaultProject = options.name;
updateWorkspaceConfiguration(tree, workspace);
}
}

function addAppFiles(tree: Tree, options: NormalizedSchema) {
Expand Down
3 changes: 0 additions & 3 deletions packages/nx/src/nx-init/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ export function createNxJsonFile(
}
}
nxJson.defaultBase = deduceDefaultBase();
if (defaultProject) {
nxJson.defaultProject = defaultProject;
}
writeJsonFile(nxJsonPath, nxJson);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,9 @@ describe('app', () => {
e2eTestRunner: 'none',
install: false,
});
const workspaceJson = readWorkspaceConfiguration(appTree);
const projects = getProjects(appTree);

expect(projects.get('my-app').root).toEqual('apps/my-app');
expect(workspaceJson.defaultProject).toEqual('my-app');
});

it('should update nx.json', async () => {
Expand Down Expand Up @@ -90,10 +88,8 @@ describe('app', () => {
install: false,
});

const workspaceJson = readWorkspaceConfiguration(appTree);
const projects = getProjects(appTree);
expect(projects.get('my-dir-my-app').root).toEqual('apps/my-dir/my-app');
expect(workspaceJson.defaultProject).toEqual('my-dir-my-app');

expect(
appTree.exists('apps/my-dir/my-app-e2e/.detoxrc.json')
Expand Down Expand Up @@ -146,12 +142,9 @@ describe('app', () => {
install: false,
});

const workspaceJson = readWorkspaceConfiguration(appTree);
const projects = getProjects(appTree);
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');
// Strip trailing commas
const detoxrcJson = JSON.parse(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,6 @@ export function addProject(host: Tree, options: NormalizedSchema) {
addProjectConfiguration(host, options.projectName, {
...project,
});

const workspace = readWorkspaceConfiguration(host);

if (!workspace.defaultProject) {
workspace.defaultProject = options.projectName;

updateWorkspaceConfiguration(host, workspace);
}
}

function getTargets(options: NormalizedSchema) {
Expand Down
Loading

1 comment on commit 82fbb98

@vercel
Copy link

@vercel vercel bot commented on 82fbb98 Dec 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nx-dev – ./

nx-dev-git-master-nrwl.vercel.app
nx-dev-nrwl.vercel.app
nx-five.vercel.app
nx.dev

Please sign in to comment.