|
6 | 6 | * found in the LICENSE file at https://angular.io/license |
7 | 7 | */ |
8 | 8 | 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'; |
11 | 11 |
|
12 | 12 | // The interfaces below are generated from the Angular CLI configuration schema |
13 | 13 | // 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 { |
476 | 476 |
|
477 | 477 | return parseJson(content, JsonParseMode.Loose) as {} as WorkspaceSchema; |
478 | 478 | } |
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