Skip to content

Commit

Permalink
fix(core): projects inferrred in apps directory should be inferred as…
Browse files Browse the repository at this point in the history
… an application (#9379)

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

* chore(repo): add jest setup back for `nx`
  • Loading branch information
AgentEnder authored and FrozenPandaz committed Mar 21, 2022
1 parent d7172f5 commit b380597
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 6 deletions.
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

0 comments on commit b380597

Please sign in to comment.