fix(react): do not include package.json in libs without publishable flag (#2896)
This commit is contained in:
parent
78a9fee083
commit
b4fc65cdf8
@ -28,6 +28,9 @@ forEachCli(currentCLIName => {
|
|||||||
);
|
);
|
||||||
runCLI(`generate @nrwl/react:lib ${libName} --no-interactive`);
|
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`;
|
const mainPath = `apps/${appName}/src/main.tsx`;
|
||||||
updateFile(mainPath, `import '@proj/${libName}';\n` + readFile(mainPath));
|
updateFile(mainPath, `import '@proj/${libName}';\n` + readFile(mainPath));
|
||||||
|
|
||||||
|
|||||||
@ -92,6 +92,7 @@ describe('lib', () => {
|
|||||||
|
|
||||||
it('should generate files', async () => {
|
it('should generate files', async () => {
|
||||||
const tree = await runSchematic('lib', { name: 'myLib' }, appTree);
|
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/jest.config.js`)).toBeTruthy();
|
||||||
expect(tree.exists('libs/my-lib/src/index.ts')).toBeTruthy();
|
expect(tree.exists('libs/my-lib/src/index.ts')).toBeTruthy();
|
||||||
expect(tree.exists('libs/my-lib/src/lib/my-lib.tsx')).toBeTruthy();
|
expect(tree.exists('libs/my-lib/src/lib/my-lib.tsx')).toBeTruthy();
|
||||||
|
|||||||
@ -96,7 +96,7 @@ export default function(schema: Schema): Rule {
|
|||||||
pascalCaseFiles: options.pascalCaseFiles
|
pascalCaseFiles: options.pascalCaseFiles
|
||||||
})
|
})
|
||||||
: noop(),
|
: noop(),
|
||||||
updateLibPackageNpmScope(options),
|
options.publishable ? updateLibPackageNpmScope(options) : noop(),
|
||||||
updateAppRoutes(options, context),
|
updateAppRoutes(options, context),
|
||||||
formatFiles(options)
|
formatFiles(options)
|
||||||
])(host, context);
|
])(host, context);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user