Skip to content

Commit fa808f7

Browse files
clydinmgechev
authored andcommitted
refactor(@schematics/angular): remove several unused internal functions
1 parent af27ec5 commit fa808f7

File tree

1 file changed

+2
-55
lines changed

1 file changed

+2
-55
lines changed

packages/schematics/angular/utility/config.ts

Lines changed: 2 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88
import { JsonParseMode, parseJson } from '@angular-devkit/core';
9-
import { Rule, SchematicsException, Tree } from '@angular-devkit/schematics';
10-
import { ProjectType, WorkspaceProject, WorkspaceSchema } from './workspace-models';
9+
import { SchematicsException, Tree } from '@angular-devkit/schematics';
10+
import { WorkspaceSchema } from './workspace-models';
1111

1212
// The interfaces below are generated from the Angular CLI configuration schema
1313
// https://github.com/angular/angular-cli/blob/master/packages/@angular/cli/lib/config/schema.json
@@ -476,56 +476,3 @@ export function getWorkspace(host: Tree): WorkspaceSchema {
476476

477477
return parseJson(content, JsonParseMode.Loose) as {} as WorkspaceSchema;
478478
}
479-
480-
export function addProjectToWorkspace<TProjectType extends ProjectType = ProjectType.Application>(
481-
workspace: WorkspaceSchema,
482-
name: string,
483-
project: WorkspaceProject<TProjectType>,
484-
): Rule {
485-
return () => {
486-
if (workspace.projects[name]) {
487-
throw new Error(`Project '${name}' already exists in workspace.`);
488-
}
489-
490-
// Add project to workspace.
491-
workspace.projects[name] = project;
492-
493-
if (!workspace.defaultProject && Object.keys(workspace.projects).length === 1) {
494-
// Make the new project the default one.
495-
workspace.defaultProject = name;
496-
}
497-
498-
return updateWorkspace(workspace);
499-
};
500-
}
501-
502-
export function updateWorkspace(workspace: WorkspaceSchema): Rule {
503-
return (host: Tree) => {
504-
host.overwrite(getWorkspacePath(host), JSON.stringify(workspace, null, 2));
505-
};
506-
}
507-
508-
export const configPath = '/.angular-cli.json';
509-
510-
export function getConfig(host: Tree): CliConfig {
511-
const configBuffer = host.read(configPath);
512-
if (configBuffer === null) {
513-
throw new SchematicsException('Could not find .angular-cli.json');
514-
}
515-
516-
const config = parseJson(configBuffer.toString(), JsonParseMode.Loose) as {} as CliConfig;
517-
518-
return config;
519-
}
520-
521-
export function getAppFromConfig(config: CliConfig, appIndexOrName: string): AppConfig | null {
522-
if (!config.apps) {
523-
return null;
524-
}
525-
526-
if (parseInt(appIndexOrName) >= 0) {
527-
return config.apps[parseInt(appIndexOrName)];
528-
}
529-
530-
return config.apps.filter((app) => app.name === appIndexOrName)[0];
531-
}

0 commit comments

Comments
 (0)