File tree 5 files changed +29
-5
lines changed
projects/angular-calendar/schematics
5 files changed +29
-5
lines changed Original file line number Diff line number Diff line change @@ -2,15 +2,18 @@ import {
2
2
SchematicTestRunner ,
3
3
UnitTestTree ,
4
4
} from '@angular-devkit/schematics/testing' ;
5
- import { getWorkspace } from '@schematics/angular/utility/config' ;
6
5
7
6
import * as path from 'path' ;
8
7
import { expect } from 'chai' ;
9
8
10
9
import { createTestApp } from '../testing/workspace' ;
11
10
import { Schema } from './schema' ;
12
11
import { angularCalendarVersion , momentVersion } from './version-names' ;
13
- import { getProjectFromWorkspace , getProjectTargetOptions } from '../utils' ;
12
+ import {
13
+ getProjectFromWorkspace ,
14
+ getProjectTargetOptions ,
15
+ getWorkspace ,
16
+ } from '../utils' ;
14
17
15
18
const collectionPath = path . join ( __dirname , '../collection.json' ) ;
16
19
Original file line number Diff line number Diff line change 6
6
chain ,
7
7
} from '@angular-devkit/schematics' ;
8
8
import { NodePackageInstallTask } from '@angular-devkit/schematics/tasks' ;
9
- import { getWorkspace } from '@schematics/angular/utility/config' ;
10
9
import { getAppModulePath } from '@schematics/angular/utility/ng-ast-utils' ;
11
10
import { insertImport } from '@schematics/angular/utility/ast-utils' ;
12
11
import { InsertChange } from '@schematics/angular/utility/change' ;
@@ -25,6 +24,7 @@ import {
25
24
getProjectFromWorkspace ,
26
25
insertWildcardImport ,
27
26
insertAfterImports ,
27
+ getWorkspace ,
28
28
} from '../utils' ;
29
29
30
30
import { Schema } from './schema' ;
Original file line number Diff line number Diff line change 1
1
import { Tree , SchematicsException } from '@angular-devkit/schematics' ;
2
- import { getWorkspace } from '@schematics/angular/utility/config' ;
3
2
import {
4
3
WorkspaceProject ,
5
4
WorkspaceSchema ,
6
5
} from '@schematics/angular/utility/workspace-models' ;
7
6
8
- import { getProjectFromWorkspace } from '.' ;
7
+ import { getProjectFromWorkspace , getWorkspace } from '.' ;
9
8
10
9
const ANGULAR_CONFIG_PATH = 'angular.json' ;
11
10
Original file line number Diff line number Diff line change
1
+ import { JsonParseMode , parseJson } from '@angular-devkit/core' ;
2
+ import { SchematicsException , Tree } from '@angular-devkit/schematics' ;
3
+ import { WorkspaceSchema } from '@schematics/angular/utility/workspace-models' ;
4
+
5
+ export function getWorkspacePath ( host : Tree ) : string {
6
+ const possibleFiles = [ '/angular.json' , '/.angular.json' ] ;
7
+ const path = possibleFiles . filter ( ( file ) => host . exists ( file ) ) [ 0 ] ;
8
+
9
+ return path ;
10
+ }
11
+
12
+ export function getWorkspace ( host : Tree ) : WorkspaceSchema {
13
+ const path = getWorkspacePath ( host ) ;
14
+ const configBuffer = host . read ( path ) ;
15
+ if ( configBuffer === null ) {
16
+ throw new SchematicsException ( `Could not find (${ path } )` ) ;
17
+ }
18
+ const content = configBuffer . toString ( ) ;
19
+
20
+ return ( parseJson ( content , JsonParseMode . Loose ) as { } ) as WorkspaceSchema ;
21
+ }
Original file line number Diff line number Diff line change @@ -4,3 +4,4 @@ export * from './file';
4
4
export * from './get-project' ;
5
5
export * from './project-main-file' ;
6
6
export * from './project-targets' ;
7
+ export * from './get-workspace' ;
You can’t perform that action at this time.
0 commit comments