feat(misc): stop generating empty apps/libs/packages libs in new work… (#18979)
This commit is contained in:
parent
99eebfb5ea
commit
9fbfe4a95a
@ -53,10 +53,15 @@ export function newProject({
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (unsetProjectNameAndRootFormat) {
|
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) => {
|
updateJson<NxJsonConfiguration>('nx.json', (nxJson) => {
|
||||||
delete nxJson.workspaceLayout;
|
delete nxJson.workspaceLayout;
|
||||||
return nxJson;
|
return nxJson;
|
||||||
});
|
});
|
||||||
|
createFile('apps/.gitkeep');
|
||||||
|
createFile('libs/.gitkeep');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Temporary hack to prevent installing with `--frozen-lockfile`
|
// Temporary hack to prevent installing with `--frozen-lockfile`
|
||||||
|
|||||||
@ -63,7 +63,9 @@ describe('create-nx-workspace --preset=npm', () => {
|
|||||||
const libName = uniq('lib');
|
const libName = uniq('lib');
|
||||||
|
|
||||||
expect(() => {
|
expect(() => {
|
||||||
runCLI(`generate @nx/angular:lib ${libName} --no-interactive`);
|
runCLI(
|
||||||
|
`generate @nx/angular:lib ${libName} --directory packages/${libName} --no-interactive`
|
||||||
|
);
|
||||||
}).not.toThrowError();
|
}).not.toThrowError();
|
||||||
checkFilesExist('tsconfig.base.json');
|
checkFilesExist('tsconfig.base.json');
|
||||||
const tsconfig = readJson(`tsconfig.base.json`);
|
const tsconfig = readJson(`tsconfig.base.json`);
|
||||||
@ -78,7 +80,9 @@ describe('create-nx-workspace --preset=npm', () => {
|
|||||||
const libName = uniq('lib');
|
const libName = uniq('lib');
|
||||||
|
|
||||||
expect(() =>
|
expect(() =>
|
||||||
runCLI(`generate @nx/js:library ${libName} --no-interactive`)
|
runCLI(
|
||||||
|
`generate @nx/js:library ${libName} --directory packages/${libName} --no-interactive`
|
||||||
|
)
|
||||||
).not.toThrowError();
|
).not.toThrowError();
|
||||||
checkFilesExist('tsconfig.base.json');
|
checkFilesExist('tsconfig.base.json');
|
||||||
const tsconfig = readJson(`tsconfig.base.json`);
|
const tsconfig = readJson(`tsconfig.base.json`);
|
||||||
@ -115,7 +119,9 @@ describe('create-nx-workspace --preset=npm', () => {
|
|||||||
const libName = uniq('lib');
|
const libName = uniq('lib');
|
||||||
|
|
||||||
expect(() => {
|
expect(() => {
|
||||||
runCLI(`generate @nx/react:lib ${libName} --no-interactive`);
|
runCLI(
|
||||||
|
`generate @nx/react:lib ${libName} --directory packages/${libName} --no-interactive`
|
||||||
|
);
|
||||||
}).not.toThrowError();
|
}).not.toThrowError();
|
||||||
checkFilesExist('tsconfig.base.json');
|
checkFilesExist('tsconfig.base.json');
|
||||||
const tsconfig = readJson(`tsconfig.base.json`);
|
const tsconfig = readJson(`tsconfig.base.json`);
|
||||||
@ -141,7 +147,9 @@ describe('create-nx-workspace --preset=npm', () => {
|
|||||||
const libName = uniq('lib');
|
const libName = uniq('lib');
|
||||||
|
|
||||||
expect(() => {
|
expect(() => {
|
||||||
runCLI(`generate @nx/next:lib ${libName} --no-interactive`);
|
runCLI(
|
||||||
|
`generate @nx/next:lib ${libName} --directory packages/${libName} --no-interactive`
|
||||||
|
);
|
||||||
}).not.toThrowError();
|
}).not.toThrowError();
|
||||||
checkFilesExist('tsconfig.base.json');
|
checkFilesExist('tsconfig.base.json');
|
||||||
const tsconfig = readJson(`tsconfig.base.json`);
|
const tsconfig = readJson(`tsconfig.base.json`);
|
||||||
@ -170,7 +178,9 @@ describe('create-nx-workspace --preset=npm', () => {
|
|||||||
const libName = uniq('lib');
|
const libName = uniq('lib');
|
||||||
|
|
||||||
expect(() => {
|
expect(() => {
|
||||||
runCLI(`generate @nx/react-native:lib ${libName} --no-interactive`);
|
runCLI(
|
||||||
|
`generate @nx/react-native:lib ${libName} --directory packages/${libName} --no-interactive`
|
||||||
|
);
|
||||||
}).not.toThrowError();
|
}).not.toThrowError();
|
||||||
checkFilesExist('tsconfig.base.json');
|
checkFilesExist('tsconfig.base.json');
|
||||||
const tsconfig = readJson(`tsconfig.base.json`);
|
const tsconfig = readJson(`tsconfig.base.json`);
|
||||||
@ -196,7 +206,9 @@ describe('create-nx-workspace --preset=npm', () => {
|
|||||||
const libName = uniq('lib');
|
const libName = uniq('lib');
|
||||||
|
|
||||||
expect(() => {
|
expect(() => {
|
||||||
runCLI(`generate @nx/node:lib ${libName} --no-interactive`);
|
runCLI(
|
||||||
|
`generate @nx/node:lib ${libName} --directory packages/${libName} --no-interactive`
|
||||||
|
);
|
||||||
}).not.toThrowError();
|
}).not.toThrowError();
|
||||||
checkFilesExist('tsconfig.base.json');
|
checkFilesExist('tsconfig.base.json');
|
||||||
const tsconfig = readJson(`tsconfig.base.json`);
|
const tsconfig = readJson(`tsconfig.base.json`);
|
||||||
@ -222,7 +234,9 @@ describe('create-nx-workspace --preset=npm', () => {
|
|||||||
const libName = uniq('lib');
|
const libName = uniq('lib');
|
||||||
|
|
||||||
expect(() => {
|
expect(() => {
|
||||||
runCLI(`generate @nx/nest:lib ${libName} --no-interactive`);
|
runCLI(
|
||||||
|
`generate @nx/nest:lib ${libName} --directory packages/${libName} --no-interactive`
|
||||||
|
);
|
||||||
}).not.toThrowError();
|
}).not.toThrowError();
|
||||||
checkFilesExist('tsconfig.base.json');
|
checkFilesExist('tsconfig.base.json');
|
||||||
const tsconfig = readJson(`tsconfig.base.json`);
|
const tsconfig = readJson(`tsconfig.base.json`);
|
||||||
|
|||||||
@ -106,12 +106,7 @@ describe('create-nx-workspace', () => {
|
|||||||
packageManager,
|
packageManager,
|
||||||
});
|
});
|
||||||
|
|
||||||
checkFilesExist(
|
checkFilesExist('package.json', packageManagerLockFile[packageManager]);
|
||||||
'package.json',
|
|
||||||
packageManagerLockFile[packageManager],
|
|
||||||
'apps/.gitkeep',
|
|
||||||
'libs/.gitkeep'
|
|
||||||
);
|
|
||||||
|
|
||||||
expectNoAngularDevkit();
|
expectNoAngularDevkit();
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,12 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": "../tsconfig.base.json",
|
|
||||||
"compilerOptions": {
|
|
||||||
"outDir": "../dist/out-tsc/tools",
|
|
||||||
"rootDir": ".",
|
|
||||||
"module": "commonjs",
|
|
||||||
"target": "es5",
|
|
||||||
"types": ["node"],
|
|
||||||
"importHelpers": false
|
|
||||||
},
|
|
||||||
"include": ["**/*.ts"]
|
|
||||||
}
|
|
||||||
@ -226,9 +226,6 @@ describe('@nx/workspace:generateWorkspaceFiles', () => {
|
|||||||
packageManager: 'npm',
|
packageManager: 'npm',
|
||||||
isCustomPreset: false,
|
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');
|
const nx = readJson(tree, '/proj/nx.json');
|
||||||
expect(nx).toMatchInlineSnapshot(`
|
expect(nx).toMatchInlineSnapshot(`
|
||||||
{
|
{
|
||||||
@ -247,6 +244,9 @@ describe('@nx/workspace:generateWorkspaceFiles', () => {
|
|||||||
"runner": "nx/tasks-runners/default",
|
"runner": "nx/tasks-runners/default",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"workspaceLayout": {
|
||||||
|
"projectNameAndRootFormat": "as-provided",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
`);
|
`);
|
||||||
|
|
||||||
|
|||||||
@ -45,7 +45,6 @@ export async function generateWorkspaceFiles(
|
|||||||
}
|
}
|
||||||
setPresetProperty(tree, options);
|
setPresetProperty(tree, options);
|
||||||
addNpmScripts(tree, options);
|
addNpmScripts(tree, options);
|
||||||
createAppsAndLibsFolders(tree, options);
|
|
||||||
setUpWorkspacesInPackageJson(tree, options);
|
setUpWorkspacesInPackageJson(tree, options);
|
||||||
|
|
||||||
await formatFiles(tree);
|
await formatFiles(tree);
|
||||||
@ -57,7 +56,6 @@ function setPresetProperty(tree: Tree, options: NormalizedSchema) {
|
|||||||
addPropertyWithStableKeys(json, 'extends', 'nx/presets/npm.json');
|
addPropertyWithStableKeys(json, 'extends', 'nx/presets/npm.json');
|
||||||
delete json.implicitDependencies;
|
delete json.implicitDependencies;
|
||||||
delete json.targetDefaults;
|
delete json.targetDefaults;
|
||||||
delete json.workspaceLayout;
|
|
||||||
}
|
}
|
||||||
return json;
|
return json;
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,10 +1,4 @@
|
|||||||
import {
|
import { installPackagesTask, names, Tree } from '@nx/devkit';
|
||||||
installPackagesTask,
|
|
||||||
names,
|
|
||||||
readNxJson,
|
|
||||||
Tree,
|
|
||||||
updateNxJson,
|
|
||||||
} from '@nx/devkit';
|
|
||||||
import { Schema } from './schema';
|
import { Schema } from './schema';
|
||||||
import { Preset } from '../utils/presets';
|
import { Preset } from '../utils/presets';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user