Skip to content

Commit

Permalink
feat(misc): stop generating empty apps/libs/packages libs in new work…
Browse files Browse the repository at this point in the history
…spaces
  • Loading branch information
FrozenPandaz committed Sep 2, 2023
1 parent 7508e7b commit 5d0bc8d
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 29 deletions.
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 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 Down

0 comments on commit 5d0bc8d

Please sign in to comment.