Skip to content

Commit

Permalink
feat(core): remove @nrwl/workspace:lib
Browse files Browse the repository at this point in the history
  • Loading branch information
meeroslav committed Apr 5, 2023
1 parent 18c016b commit ca4bf9f
Show file tree
Hide file tree
Showing 78 changed files with 231 additions and 1,531 deletions.
8 changes: 0 additions & 8 deletions docs/generated/manifests/menus.json
Original file line number Diff line number Diff line change
Expand Up @@ -6648,14 +6648,6 @@
"isExternal": false,
"disableCollapsible": false
},
{
"id": "library",
"path": "/packages/workspace/generators/library",
"name": "library",
"children": [],
"isExternal": false,
"disableCollapsible": false
},
{
"id": "workspace-generator",
"path": "/packages/workspace/generators/workspace-generator",
Expand Down
9 changes: 0 additions & 9 deletions docs/generated/manifests/packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -3030,15 +3030,6 @@
"path": "/packages/workspace/generators/new",
"type": "generator"
},
"/packages/workspace/generators/library": {
"description": "Create a library.",
"file": "generated/packages/workspace/generators/library.json",
"hidden": false,
"name": "library",
"originalFilePath": "/packages/workspace/src/generators/library/schema.json",
"path": "/packages/workspace/generators/library",
"type": "generator"
},
"/packages/workspace/generators/workspace-generator": {
"description": "Generates a workspace generator.",
"file": "generated/packages/workspace/generators/workspace-generator.json",
Expand Down
9 changes: 0 additions & 9 deletions docs/generated/packages-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2996,15 +2996,6 @@
"path": "workspace/generators/new",
"type": "generator"
},
{
"description": "Create a library.",
"file": "generated/packages/workspace/generators/library.json",
"hidden": false,
"name": "library",
"originalFilePath": "/packages/workspace/src/generators/library/schema.json",
"path": "workspace/generators/library",
"type": "generator"
},
{
"description": "Generates a workspace generator.",
"file": "generated/packages/workspace/generators/workspace-generator.json",
Expand Down
1 change: 0 additions & 1 deletion docs/shared/deprecated/default-collection.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ This property is no longer needed because the Nx cli automatically will prompt y
@nrwl/js:library
@nrwl/next:library
@nrwl/react:library
@nrwl/workspace:library

None of the above
```
2 changes: 1 addition & 1 deletion docs/shared/recipes/generators/composing-generators.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Generators are useful individually, but reusing and composing generators allows
Nx Devkit generators can be imported and invoked like any javascript function. They often return a `Promise`, so they can be used with the `await` keyword to mimic synchronous code. Because this is standard javascript, control flow logic can be adjusted with `if` blocks and `for` loops as usual.

```typescript
import { libraryGenerator } from '@nrwl/workspace/generators';
import { libraryGenerator } from '@nrwl/js';

export default async function (tree: Tree, schema: any) {
await libraryGenerator(
Expand Down
2 changes: 1 addition & 1 deletion docs/shared/recipes/generators/creating-files.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import {
joinPathFragments,
readProjectConfiguration,
} from '@nrwl/devkit';
import { libraryGenerator } from '@nrwl/workspace/generators';
import { libraryGenerator } from '@nrwl/js';

export default async function (tree: Tree, schema: any) {
await libraryGenerator(tree, { name: schema.name });
Expand Down
2 changes: 1 addition & 1 deletion docs/shared/recipes/generators/generator-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Import the TypeScript schema into your generator file and replace the `any` in y

```typescript
import { Tree, formatFiles, installPackagesTask } from '@nrwl/devkit';
import { libraryGenerator } from '@nrwl/workspace/generators';
import { libraryGenerator } from '@nrwl/js';

export default async function (tree: Tree, schema: GeneratorOptions) {
await libraryGenerator(tree, { name: `${schema.name}-${schema.type || ''}` });
Expand Down
2 changes: 1 addition & 1 deletion docs/shared/recipes/generators/local-generators.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ The initial generator function creates a library.

```typescript
import { Tree, formatFiles, installPackagesTask } from '@nrwl/devkit';
import { libraryGenerator } from '@nrwl/workspace/generators';
import { libraryGenerator } from '@nrwl/js';

export default async function (tree: Tree, schema: any) {
await libraryGenerator(tree, { name: schema.name });
Expand Down
16 changes: 5 additions & 11 deletions e2e/jest/src/jest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@ import {
runCLI,
runCLIAsync,
uniq,
readJson,
updateFile,
expectJestTestsToPass,
cleanupProject,
readFile,
checkFilesExist,
} from '@nrwl/e2e/utils';

describe('Jest', () => {
Expand All @@ -20,18 +17,15 @@ describe('Jest', () => {
afterAll(() => cleanupProject());

it('should be able test projects using jest', async () => {
await expectJestTestsToPass('@nrwl/workspace:lib');
await expectJestTestsToPass('@nrwl/js:lib');
}, 500000);

it('should merge with jest config globals', async () => {
const testGlobal = `'My Test Global'`;
const mylib = uniq('mylib');
const utilLib = uniq('util-lib');
runCLI(`generate @nrwl/workspace:lib ${mylib} --unit-test-runner jest`);
runCLI(
`generate @nrwl/workspace:lib ${utilLib} --importPath=@global-fun/globals`
);
runCLI(`generate @nrwl/js:lib ${mylib} --unit-test-runner jest`);
runCLI(`generate @nrwl/js:lib ${utilLib} --importPath=@global-fun/globals`);
updateFile(
`libs/${utilLib}/src/index.ts`,
stripIndents`
Expand Down Expand Up @@ -102,13 +96,13 @@ describe('Jest', () => {

it('should set the NODE_ENV to `test`', async () => {
const mylib = uniq('mylib');
runCLI(`generate @nrwl/workspace:lib ${mylib} --unit-test-runner jest`);
runCLI(`generate @nrwl/js:lib ${mylib} --unit-test-runner jest`);

updateFile(
`libs/${mylib}/src/lib/${mylib}.spec.ts`,
`
test('can access jest global', () => {
expect(process.env.NODE_ENV).toBe('test');
expect(process.env['NODE_ENV']).toBe('test');
});
`
);
Expand All @@ -120,7 +114,7 @@ describe('Jest', () => {

it('should support multiple `coverageReporters` through CLI', async () => {
const mylib = uniq('mylib');
runCLI(`generate @nrwl/workspace:lib ${mylib} --unit-test-runner jest`);
runCLI(`generate @nrwl/js:lib ${mylib} --unit-test-runner jest`);

updateFile(
`libs/${mylib}/src/lib/${mylib}.spec.ts`,
Expand Down
20 changes: 9 additions & 11 deletions e2e/linter/src/linter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('Linter', () => {
beforeAll(() => {
projScope = newProject();
runCLI(`generate @nrwl/react:app ${myapp} --tags=validtag`);
runCLI(`generate @nrwl/workspace:lib ${mylib}`);
runCLI(`generate @nrwl/js:lib ${mylib}`);
});
afterAll(() => cleanupProject());

Expand Down Expand Up @@ -194,10 +194,8 @@ describe('Linter', () => {

runCLI(`generate @nrwl/react:app ${myapp2}`);
runCLI(`generate @nrwl/react:lib ${lazylib}`);
runCLI(
`generate @nrwl/workspace:lib ${invalidtaglib} --tags=invalidtag`
);
runCLI(`generate @nrwl/workspace:lib ${validtaglib} --tags=validtag`);
runCLI(`generate @nrwl/js:lib ${invalidtaglib} --tags=invalidtag`);
runCLI(`generate @nrwl/js:lib ${validtaglib} --tags=validtag`);

const eslint = readJson('.eslintrc.json');
eslint.overrides[0].rules[
Expand Down Expand Up @@ -255,9 +253,9 @@ describe('Linter', () => {
const libC = uniq('tslib-c');

beforeAll(() => {
runCLI(`generate @nrwl/workspace:lib ${libA}`);
runCLI(`generate @nrwl/workspace:lib ${libB}`);
runCLI(`generate @nrwl/workspace:lib ${libC}`);
runCLI(`generate @nrwl/js:lib ${libA}`);
runCLI(`generate @nrwl/js:lib ${libB}`);
runCLI(`generate @nrwl/js:lib ${libC}`);

/**
* create tslib-a structure
Expand Down Expand Up @@ -506,7 +504,7 @@ describe('Linter', () => {
expect(appEslint.overrides[1].extends).toBeDefined();
expect(e2eEslint.overrides[0].extends).toBeDefined();

runCLI(`generate @nrwl/workspace:lib ${mylib} --unitTestRunner=jest`);
runCLI(`generate @nrwl/js:lib ${mylib} --unitTestRunner=jest`);
verifySuccessfulMigratedSetup(myapp, mylib);

appEslint = readJson(`.eslintrc.json`);
Expand Down Expand Up @@ -535,7 +533,7 @@ describe('Linter', () => {
expect(appEslint.overrides[1].extends).toBeDefined();
expect(e2eEslint.overrides[0].extends).toBeDefined();

runCLI(`generate @nrwl/workspace:lib ${mylib} --no-interactive`);
runCLI(`generate @nrwl/js:lib ${mylib} --no-interactive`);
verifySuccessfulMigratedSetup(myapp, mylib);

appEslint = readJson(`.eslintrc.json`);
Expand Down Expand Up @@ -566,7 +564,7 @@ describe('Linter', () => {
expect(appEslint.overrides[1].extends).toBeDefined();
expect(e2eEslint.overrides[0].extends).toBeDefined();

runCLI(`generate @nrwl/workspace:lib ${mylib} --no-interactive`);
runCLI(`generate @nrwl/js:lib ${mylib} --no-interactive`);
verifySuccessfulMigratedSetup(myapp, mylib);

appEslint = readJson(`.eslintrc.json`);
Expand Down
8 changes: 4 additions & 4 deletions e2e/nx-init/src/nx-project-graph.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('project graph creation', () => {

it('should correctly build the nxdeps.json containing files for the project', () => {
const libName = uniq('mylib');
runCLI(`generate @nrwl/workspace:lib ${libName}`);
runCLI(`generate @nrwl/js:lib ${libName}`);

runCLI(`graph --file=graph.json`);
const { graph: graphJson } = readJson('graph.json');
Expand All @@ -25,7 +25,7 @@ describe('project graph creation', () => {
it("should correctly build the nxdeps.json containing files for the project when root is ''", () => {
const libName = uniq('mylib');

runCLI(`generate @nrwl/workspace:lib ${libName}`);
runCLI(`generate @nrwl/js:lib ${libName}`);
updateJson(`libs/${libName}/project.json`, (json) => ({
...json,
root: '',
Expand All @@ -41,8 +41,8 @@ describe('project graph creation', () => {
const libName = uniq('mylib');
const secondLibName = uniq('mysecondlib');

runCLI(`generate @nrwl/workspace:lib ${libName}`);
runCLI(`generate @nrwl/workspace:lib ${secondLibName}`);
runCLI(`generate @nrwl/js:lib ${libName}`);
runCLI(`generate @nrwl/js:lib ${secondLibName}`);
updateJson(`libs/${libName}/project.json`, (json) => ({
...json,
root: '',
Expand Down
4 changes: 2 additions & 2 deletions e2e/nx-misc/src/extras.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ describe('Extra Nx Misc Tests', () => {
describe('Run Commands', () => {
const mylib = uniq('lib');
beforeAll(() => {
runCLI(`generate @nrwl/workspace:lib ${mylib}`);
runCLI(`generate @nrwl/js:lib ${mylib}`);
});

it('should not override environment variables already set when setting a custom env file path', async () => {
Expand Down Expand Up @@ -229,7 +229,7 @@ describe('Extra Nx Misc Tests', () => {

const folder = `dist/libs/${mylib}/some-folder`;

runCLI(`generate @nrwl/workspace:lib ${mylib}`);
runCLI(`generate @nrwl/js:lib ${mylib}`);

runCLI(
`generate @nrwl/workspace:run-commands build --command=echo --outputs=${folder}/ --project=${mylib}`
Expand Down
6 changes: 3 additions & 3 deletions e2e/nx-misc/src/watch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ describe('Nx Commands', () => {
let proj3 = uniq('proj3');
beforeAll(() => {
newProject({ packageManager: 'npm' });
runCLI(`generate @nrwl/workspace:lib ${proj1}`);
runCLI(`generate @nrwl/workspace:lib ${proj2}`);
runCLI(`generate @nrwl/workspace:lib ${proj3}`);
runCLI(`generate @nrwl/js:lib ${proj1}`);
runCLI(`generate @nrwl/js:lib ${proj2}`);
runCLI(`generate @nrwl/js:lib ${proj3}`);
});

afterAll(() => cleanupProject());
Expand Down
Loading

0 comments on commit ca4bf9f

Please sign in to comment.