fix(react): do not include package.json in libs without publishable flag (#2896)

This commit is contained in:
Jonathan Cammisuli 2020-04-27 10:09:56 -04:00 committed by GitHub
parent 78a9fee083
commit b4fc65cdf8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 1 deletions

View File

@ -28,6 +28,9 @@ forEachCli(currentCLIName => {
);
runCLI(`generate @nrwl/react:lib ${libName} --no-interactive`);
// Libs should not include package.json by default
checkFilesDoNotExist(`libs/${libName}/package.json`);
const mainPath = `apps/${appName}/src/main.tsx`;
updateFile(mainPath, `import '@proj/${libName}';\n` + readFile(mainPath));

View File

@ -92,6 +92,7 @@ describe('lib', () => {
it('should generate files', async () => {
const tree = await runSchematic('lib', { name: 'myLib' }, appTree);
expect(tree.exists('libs/my-lib/package.json')).toBeFalsy();
expect(tree.exists(`libs/my-lib/jest.config.js`)).toBeTruthy();
expect(tree.exists('libs/my-lib/src/index.ts')).toBeTruthy();
expect(tree.exists('libs/my-lib/src/lib/my-lib.tsx')).toBeTruthy();

View File

@ -96,7 +96,7 @@ export default function(schema: Schema): Rule {
pascalCaseFiles: options.pascalCaseFiles
})
: noop(),
updateLibPackageNpmScope(options),
options.publishable ? updateLibPackageNpmScope(options) : noop(),
updateAppRoutes(options, context),
formatFiles(options)
])(host, context);