Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(misc): stop generating empty apps/libs/packages libs in new work… #18979

Merged
merged 1 commit into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions e2e/utils/create-project-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,15 @@ export function newProject({
});

if (unsetProjectNameAndRootFormat) {
console.warn(
'ATTENTION: The workspace generated for this e2e test does not use the new as-provided project name/root format. Please update this test'
);
updateJson<NxJsonConfiguration>('nx.json', (nxJson) => {
delete nxJson.workspaceLayout;
return nxJson;
});
createFile('apps/.gitkeep');
createFile('libs/.gitkeep');
}

// Temporary hack to prevent installing with `--frozen-lockfile`
Expand Down
28 changes: 21 additions & 7 deletions e2e/workspace-create-npm/src/create-nx-workspace-npm.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ describe('create-nx-workspace --preset=npm', () => {
const libName = uniq('lib');

expect(() => {
runCLI(`generate @nx/angular:lib ${libName} --no-interactive`);
runCLI(
`generate @nx/angular:lib ${libName} --directory packages/${libName} --no-interactive`
);
}).not.toThrowError();
checkFilesExist('tsconfig.base.json');
const tsconfig = readJson(`tsconfig.base.json`);
Expand All @@ -78,7 +80,9 @@ describe('create-nx-workspace --preset=npm', () => {
const libName = uniq('lib');

expect(() =>
runCLI(`generate @nx/js:library ${libName} --no-interactive`)
runCLI(
`generate @nx/js:library ${libName} --directory packages/${libName} --no-interactive`
)
).not.toThrowError();
checkFilesExist('tsconfig.base.json');
const tsconfig = readJson(`tsconfig.base.json`);
Expand Down Expand Up @@ -115,7 +119,9 @@ describe('create-nx-workspace --preset=npm', () => {
const libName = uniq('lib');

expect(() => {
runCLI(`generate @nx/react:lib ${libName} --no-interactive`);
runCLI(
`generate @nx/react:lib ${libName} --directory packages/${libName} --no-interactive`
);
}).not.toThrowError();
checkFilesExist('tsconfig.base.json');
const tsconfig = readJson(`tsconfig.base.json`);
Expand All @@ -141,7 +147,9 @@ describe('create-nx-workspace --preset=npm', () => {
const libName = uniq('lib');

expect(() => {
runCLI(`generate @nx/next:lib ${libName} --no-interactive`);
runCLI(
`generate @nx/next:lib ${libName} --directory packages/${libName} --no-interactive`
);
}).not.toThrowError();
checkFilesExist('tsconfig.base.json');
const tsconfig = readJson(`tsconfig.base.json`);
Expand Down Expand Up @@ -170,7 +178,9 @@ describe('create-nx-workspace --preset=npm', () => {
const libName = uniq('lib');

expect(() => {
runCLI(`generate @nx/react-native:lib ${libName} --no-interactive`);
runCLI(
`generate @nx/react-native:lib ${libName} --directory packages/${libName} --no-interactive`
);
}).not.toThrowError();
checkFilesExist('tsconfig.base.json');
const tsconfig = readJson(`tsconfig.base.json`);
Expand All @@ -196,7 +206,9 @@ describe('create-nx-workspace --preset=npm', () => {
const libName = uniq('lib');

expect(() => {
runCLI(`generate @nx/node:lib ${libName} --no-interactive`);
runCLI(
`generate @nx/node:lib ${libName} --directory packages/${libName} --no-interactive`
);
}).not.toThrowError();
checkFilesExist('tsconfig.base.json');
const tsconfig = readJson(`tsconfig.base.json`);
Expand All @@ -222,7 +234,9 @@ describe('create-nx-workspace --preset=npm', () => {
const libName = uniq('lib');

expect(() => {
runCLI(`generate @nx/nest:lib ${libName} --no-interactive`);
runCLI(
`generate @nx/nest:lib ${libName} --directory packages/${libName} --no-interactive`
);
}).not.toThrowError();
checkFilesExist('tsconfig.base.json');
const tsconfig = readJson(`tsconfig.base.json`);
Expand Down
7 changes: 1 addition & 6 deletions e2e/workspace-create/src/create-nx-workspace.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,7 @@ describe('create-nx-workspace', () => {
packageManager,
});

checkFilesExist(
'package.json',
packageManagerLockFile[packageManager],
'apps/.gitkeep',
'libs/.gitkeep'
);
checkFilesExist('package.json', packageManagerLockFile[packageManager]);

expectNoAngularDevkit();
});
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,6 @@ describe('@nx/workspace:generateWorkspaceFiles', () => {
packageManager: 'npm',
isCustomPreset: false,
});
expect(tree.exists('/proj/packages/.gitkeep')).toBe(true);
expect(tree.exists('/proj/apps/.gitkeep')).toBe(false);
expect(tree.exists('/proj/libs/.gitkeep')).toBe(false);
const nx = readJson(tree, '/proj/nx.json');
expect(nx).toMatchInlineSnapshot(`
{
Expand All @@ -247,6 +244,9 @@ describe('@nx/workspace:generateWorkspaceFiles', () => {
"runner": "nx/tasks-runners/default",
},
},
"workspaceLayout": {
"projectNameAndRootFormat": "as-provided",
},
}
`);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ export async function generateWorkspaceFiles(
}
setPresetProperty(tree, options);
addNpmScripts(tree, options);
createAppsAndLibsFolders(tree, options);
setUpWorkspacesInPackageJson(tree, options);

await formatFiles(tree);
Expand All @@ -57,7 +56,6 @@ function setPresetProperty(tree: Tree, options: NormalizedSchema) {
addPropertyWithStableKeys(json, 'extends', 'nx/presets/npm.json');
delete json.implicitDependencies;
delete json.targetDefaults;
delete json.workspaceLayout;
}
return json;
});
Expand Down
8 changes: 1 addition & 7 deletions packages/workspace/src/generators/preset/preset.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
import {
installPackagesTask,
names,
readNxJson,
Tree,
updateNxJson,
} from '@nx/devkit';
import { installPackagesTask, names, Tree } from '@nx/devkit';
import { Schema } from './schema';
import { Preset } from '../utils/presets';
import { join } from 'path';
Expand Down