fix(angular): honor buildableProjectDepsInPackageJsonType in angula… (#4760)

Fixes the angular:package builder to honor the `buildableProjectDepsInPackageJsonType` setting. It was previously ignored.
This commit is contained in:
Matt Hodgson 2021-02-19 14:52:20 -05:00 committed by GitHub
parent 95848ca917
commit 5ee28743bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 41 additions and 5 deletions

View File

@ -6,6 +6,16 @@ Properties can be configured in angular.json when defining the executor, or when
## Properties ## Properties
### buildableProjectDepsInPackageJsonType
Default: `peerDependencies`
Type: `string`
Possible values: `dependencies`, `peerDependencies`
When updateBuildableProjectDepsInPackageJson is true, this adds dependencies to either `peerDependencies` or `dependencies`
### project ### project
Type: `string` Type: `string`

View File

@ -7,6 +7,16 @@ Read more about how to use executors and the CLI here: https://nx.dev/node/guide
## Properties ## Properties
### buildableProjectDepsInPackageJsonType
Default: `peerDependencies`
Type: `string`
Possible values: `dependencies`, `peerDependencies`
When updateBuildableProjectDepsInPackageJson is true, this adds dependencies to either `peerDependencies` or `dependencies`
### project ### project
Type: `string` Type: `string`

View File

@ -7,6 +7,16 @@ Read more about how to use executors and the CLI here: https://nx.dev/react/guid
## Properties ## Properties
### buildableProjectDepsInPackageJsonType
Default: `peerDependencies`
Type: `string`
Possible values: `dependencies`, `peerDependencies`
When updateBuildableProjectDepsInPackageJson is true, this adds dependencies to either `peerDependencies` or `dependencies`
### project ### project
Type: `string` Type: `string`

View File

@ -148,7 +148,7 @@ import { names } from '@nrwl/devkit';
checkFilesExist(`dist/libs/${childLib}/package.json`); checkFilesExist(`dist/libs/${childLib}/package.json`);
}); });
it('should properly add references to any dependency into the parent package.json', () => { it('aaashould properly add references to any dependency into the parent package.json', () => {
runCLI(`build ${childLib}`); runCLI(`build ${childLib}`);
runCLI(`build ${childLib2}`); runCLI(`build ${childLib2}`);
runCLI(`build ${parentLib}`); runCLI(`build ${parentLib}`);
@ -160,11 +160,10 @@ import { names } from '@nrwl/devkit';
); );
const jsonFile = readJson(`dist/libs/${parentLib}/package.json`); const jsonFile = readJson(`dist/libs/${parentLib}/package.json`);
// expect(jsonFile.dependencies).toEqual({ tslib: '^2.0.0' });
expect(jsonFile.dependencies['tslib']).toEqual('^2.0.0'); expect(jsonFile.dependencies['tslib']).toEqual('^2.0.0');
expect(jsonFile.dependencies[`@${proj}/${childLib}`]).toBeDefined(); expect(jsonFile.peerDependencies[`@${proj}/${childLib}`]).toBeDefined();
expect(jsonFile.dependencies[`@${proj}/${childLib2}`]).toBeDefined(); expect(jsonFile.peerDependencies[`@${proj}/${childLib2}`]).toBeDefined();
expect(jsonFile.peerDependencies['@angular/common']).toBeDefined(); expect(jsonFile.peerDependencies['@angular/common']).toBeDefined();
expect(jsonFile.peerDependencies['@angular/core']).toBeDefined(); expect(jsonFile.peerDependencies['@angular/core']).toBeDefined();
}); });

View File

@ -21,6 +21,12 @@
"type": "boolean", "type": "boolean",
"description": "Update buildable project dependencies in package.json", "description": "Update buildable project dependencies in package.json",
"default": true "default": true
},
"buildableProjectDepsInPackageJsonType": {
"type": "string",
"description": "When updateBuildableProjectDepsInPackageJson is true, this adds dependencies to either `peerDependencies` or `dependencies`",
"enum": ["dependencies", "peerDependencies"],
"default": "peerDependencies"
} }
}, },
"additionalProperties": false, "additionalProperties": false,

View File

@ -90,7 +90,8 @@ export function createLibraryBuilder(
updateBuildableProjectPackageJsonDependencies( updateBuildableProjectPackageJsonDependencies(
context, context,
target, target,
dependencies dependencies,
options.buildableProjectDepsInPackageJsonType
); );
} }
}), }),