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

fix(core): projects inferrred in apps directory should be inferred as an application #9379

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/nx/jest.config.js
@@ -1,9 +1,10 @@
module.exports = {
name: 'cli',
preset: '../../jest.config.js',
preset: '../../jest.preset.js',
transform: {
'^.+\\.[tj]sx?$': 'ts-jest',
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
globals: { 'ts-jest': { tsconfig: '<rootDir>/tsconfig.spec.json' } },
displayName: 'nx',
testEnvironment: 'node',
};
8 changes: 8 additions & 0 deletions packages/nx/project.json
Expand Up @@ -78,6 +78,14 @@
]
},
"outputs": ["{options.outputFile}"]
},
"test": {
"executor": "@nrwl/jest:jest",
"options": {
"jestConfig": "packages/nx/jest.config.js",
"passWithNoTests": true
},
"outputs": ["coverage/packages/nx"]
}
}
}
1 change: 0 additions & 1 deletion packages/nx/src/commands/migrate.spec.ts
Expand Up @@ -369,7 +369,6 @@ describe('Migration', () => {
migrations: [],
packageJson: {
'@nrwl/workspace': { version: '2.0.0', addToPackageJson: false },
'@nrwl/cli': { version: '2.0.0', addToPackageJson: false },
'@nrwl/angular': { version: '2.0.0', addToPackageJson: false },
'@nrwl/cypress': { version: '2.0.0', addToPackageJson: false },
'@nrwl/devkit': { addToPackageJson: false, version: '2.0.0' },
Expand Down
4 changes: 2 additions & 2 deletions packages/nx/src/shared/__snapshots__/logger.spec.ts.snap
@@ -1,12 +1,12 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Tao Logger should color the NX prefix 1`] = `
exports[`Logger should color the NX prefix 1`] = `
"
>  NX  some Nx message!
"
`;

exports[`Tao Logger should log the full stack trace when an object is being passed 1`] = `
exports[`Logger should log the full stack trace when an object is being passed 1`] = `
"TypeError: Cannot read property 'target' of undefined
 at /someuser/node_modules/@storybook/angular/dist/ts3.9/server/angular-devkit-build-webpack.js:145:49
 at step (/someuser/node_modules/@storybook/angular/dist/ts3.9/server/angular-devkit-build-webpack.js:69:23)
Expand Down
4 changes: 3 additions & 1 deletion packages/nx/src/shared/workspace.spec.ts
Expand Up @@ -14,6 +14,7 @@ const libConfig = (name) => ({
const packageLibConfig = (root) => ({
root,
sourceRoot: root,
projectType: 'library',
});

describe('Workspaces', () => {
Expand Down Expand Up @@ -102,7 +103,7 @@ describe('Workspaces', () => {
expect(libResults).toEqual('directory-my-lib');
});

it('should custom directories from beginning', () => {
it('should trim custom directories from beginning', () => {
const nxJson: NxJsonConfiguration = {
npmScope: '',
workspaceLayout: {
Expand Down Expand Up @@ -161,6 +162,7 @@ describe('Workspaces', () => {
expect(resolved.projects['my-package']).toEqual({
root: 'packages/my-package',
sourceRoot: 'packages/my-package',
projectType: 'library',
});
});
});
Expand Down
6 changes: 6 additions & 0 deletions packages/nx/src/shared/workspace.ts
Expand Up @@ -803,6 +803,12 @@ function buildProjectConfigurationFromPackageJson(
root: directory,
sourceRoot: directory,
name,
projectType:
nxJson.workspaceLayout?.appsDir != nxJson.workspaceLayout?.libsDir &&
nxJson.workspaceLayout?.appsDir &&
directory.startsWith(nxJson.workspaceLayout.appsDir)
? 'application'
: 'library',
};
}

Expand Down
Expand Up @@ -105,6 +105,7 @@ describe('@nrwl/workspace:npm-package', () => {
expect(tree.exists('packages/my-package/project.json')).toBeFalsy();
expect(tree.exists('packages/my-package/package.json')).toBeTruthy();
expect(readProjectConfiguration(tree, 'my-package')).toEqual({
projectType: 'library',
root: 'packages/my-package',
sourceRoot: 'packages/my-package',
});
Expand Down