Skip to content

Commit e7ae25a

Browse files
committed
refactor(@schematics/angular): remove unneeded initial library service generation
The `library` schematic will now longer generate an empty Angular service with the name of the library. Using only the name would generate a file name conflict with the component now that the type suffix is no longer used by default. Additionally, services tend to be specific to a particular behavior and/or functionality and are named as such. A generically named empty service will typically be deleted or renamed.
1 parent e07491e commit e7ae25a

File tree

3 files changed

+2
-18
lines changed

3 files changed

+2
-18
lines changed

packages/schematics/angular/library/files/src/__entryFile__.ts.template

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,5 @@
22
* Public API Surface of <%= dasherize(name) %>
33
*/
44

5-
export * from './lib/<%= dasherize(name) %>.service';
65
export * from './lib/<%= dasherize(name) %>';<% if (!standalone) { %>
76
export * from './lib/<%= dasherize(name) %>.module';<% } %>

packages/schematics/angular/library/index.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,6 @@ export default function (options: LibraryOptions): Rule {
185185
standalone: options.standalone,
186186
project: packageName,
187187
}),
188-
schematic('service', {
189-
name: options.name,
190-
flat: true,
191-
path: sourceDir,
192-
project: packageName,
193-
}),
194188
(_tree: Tree, context: SchematicContext) => {
195189
if (!options.skipPackageJson && !options.skipInstall) {
196190
context.addTask(new NodePackageInstallTask());

packages/schematics/angular/library/index_spec.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ describe('Library Schematic', () => {
5757
'/projects/foo/src/my-index.ts',
5858
'/projects/foo/src/lib/foo.spec.ts',
5959
'/projects/foo/src/lib/foo.ts',
60-
'/projects/foo/src/lib/foo.service.spec.ts',
61-
'/projects/foo/src/lib/foo.service.ts',
6260
]),
6361
);
6462
});
@@ -102,8 +100,6 @@ describe('Library Schematic', () => {
102100
'/some/other/directory/bar/src/my-index.ts',
103101
'/some/other/directory/bar/src/lib/foo.spec.ts',
104102
'/some/other/directory/bar/src/lib/foo.ts',
105-
'/some/other/directory/bar/src/lib/foo.service.spec.ts',
106-
'/some/other/directory/bar/src/lib/foo.service.ts',
107103
]),
108104
);
109105
});
@@ -207,10 +203,8 @@ describe('Library Schematic', () => {
207203
const project = config.projects.pascalCasedName;
208204
expect(project).toBeDefined();
209205
expect(project.root).toEqual('projects/pascal-cased-name');
210-
const svcContent = tree.readContent(
211-
'/projects/pascal-cased-name/src/lib/pascal-cased-name.service.ts',
212-
);
213-
expect(svcContent).toMatch(/providedIn: 'root'/);
206+
const svcContent = tree.readContent('/projects/pascal-cased-name/src/lib/pascal-cased-name.ts');
207+
expect(svcContent).toContain('@Component');
214208
});
215209

216210
describe(`update package.json`, () => {
@@ -320,7 +314,6 @@ describe('Library Schematic', () => {
320314

321315
const pkgJsonPath = '/projects/myscope/mylib/package.json';
322316
expect(tree.files).toContain(pkgJsonPath);
323-
expect(tree.files).toContain('/projects/myscope/mylib/src/lib/mylib.service.ts');
324317
expect(tree.files).toContain('/projects/myscope/mylib/src/lib/mylib.ts');
325318

326319
const pkgJson = JSON.parse(tree.readContent(pkgJsonPath));
@@ -431,8 +424,6 @@ describe('Library Schematic', () => {
431424
'/projects/foo/src/lib/foo.module.ts',
432425
'/projects/foo/src/lib/foo.spec.ts',
433426
'/projects/foo/src/lib/foo.ts',
434-
'/projects/foo/src/lib/foo.service.spec.ts',
435-
'/projects/foo/src/lib/foo.service.ts',
436427
]),
437428
);
438429
});

0 commit comments

Comments
 (0)