File tree 8 files changed +137
-1
lines changed
8 files changed +137
-1
lines changed Original file line number Diff line number Diff line change 45
45
"@angular-devkit/core" : " ~0.0.28" ,
46
46
"@angular-devkit/schematics" : " ~0.0.51" ,
47
47
"@schematics/angular" : " ~0.1.16" ,
48
+ "@schematics/package-update" : " 0.0.6" ,
48
49
"autoprefixer" : " ^7.2.3" ,
49
50
"cache-loader" : " ^1.2.0" ,
50
51
"chalk" : " ~2.2.0" ,
Original file line number Diff line number Diff line change
1
+ const Command = require ( '../ember-cli/lib/models/command' ) ;
2
+ import { UpdateTask } from '../tasks/update' ;
3
+
4
+ export interface UpdateOptions {
5
+ schematic ?: boolean ;
6
+ }
7
+
8
+ const UpdateCommand = Command . extend ( {
9
+ name : 'update' ,
10
+ description : 'Updates your application.' ,
11
+ works : 'everywhere' ,
12
+ availableOptions : [
13
+ {
14
+ name : 'dry-run' ,
15
+ type : Boolean ,
16
+ default : false ,
17
+ aliases : [ 'd' ] ,
18
+ description : 'Run through without making any changes.'
19
+ }
20
+ ] ,
21
+
22
+ anonymousOptions : [ ] ,
23
+
24
+ run : function ( commandOptions : any ) {
25
+ const schematic = '@schematics/package-update:all' ;
26
+
27
+ const updateTask = new UpdateTask ( {
28
+ ui : this . ui ,
29
+ project : this . project
30
+ } ) ;
31
+
32
+ return updateTask . run ( schematic , commandOptions ) ;
33
+ }
34
+ } ) ;
35
+
36
+ export default UpdateCommand ;
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ function loadCommands() {
20
20
'completion' : require ( '../../commands/completion' ) . default ,
21
21
'doc' : require ( '../../commands/doc' ) . default ,
22
22
'xi18n' : require ( '../../commands/xi18n' ) . default ,
23
+ 'update' : require ( '../../commands/update' ) . default ,
23
24
24
25
// Easter eggs.
25
26
'make-this-awesome' : require ( '../../commands/easter-egg' ) . default ,
Original file line number Diff line number Diff line change 33
33
"@ngtools/json-schema" : " 1.1.0" ,
34
34
"@ngtools/webpack" : " 1.10.0-beta.1" ,
35
35
"@schematics/angular" : " ~0.1.16" ,
36
+ "@schematics/package-update" : " 0.0.6" ,
36
37
"autoprefixer" : " ^7.2.3" ,
37
38
"cache-loader" : " ^1.2.0" ,
38
39
"chalk" : " ~2.2.0" ,
Original file line number Diff line number Diff line change
1
+ const Task = require ( '../ember-cli/lib/models/task' ) ;
2
+ import SchematicRunTask from './schematic-run' ;
3
+
4
+ export interface UpdateTaskOptions {
5
+ dryRun : boolean ;
6
+ force : boolean ;
7
+ }
8
+
9
+ export const UpdateTask : any = Task . extend ( {
10
+ run : function ( schematic : string , options : UpdateTaskOptions ) : Promise < any > {
11
+ const [ collectionName , schematicName ] = schematic . split ( ':' ) ;
12
+
13
+ const schematicRunTask = new SchematicRunTask ( {
14
+ ui : this . ui ,
15
+ project : this . project
16
+ } ) ;
17
+
18
+ const schematicRunOptions = {
19
+ taskOptions : {
20
+ dryRun : options . dryRun
21
+ } ,
22
+ workingDir : this . project . root ,
23
+ collectionName,
24
+ schematicName
25
+ } ;
26
+
27
+ return schematicRunTask . run ( schematicRunOptions ) ;
28
+ }
29
+ } ) ;
Original file line number Diff line number Diff line change @@ -27,7 +27,8 @@ const NODE_PACKAGES = [
27
27
const ANGULAR_PACKAGES = [
28
28
'@angular/compiler' ,
29
29
'@angular/compiler-cli' ,
30
- '@angular/core'
30
+ '@angular/core' ,
31
+ '@schematics/package-update'
31
32
] ;
32
33
const OPTIONAL_PACKAGES = [
33
34
'@angular/service-worker' ,
Original file line number Diff line number Diff line change
1
+ import { ng } from '../../utils/process' ;
2
+ import { readFile } from '../../utils/fs' ;
3
+ import { updateJsonFile } from '../../utils/project' ;
4
+
5
+ function updateVersions ( obj : any ) {
6
+ const keys = Object . keys ( obj ) ;
7
+ keys . forEach ( key => {
8
+ if ( key . startsWith ( '@angular/' ) ) {
9
+ obj [ key ] = '2.0.0' ;
10
+ }
11
+ } ) ;
12
+ }
13
+
14
+ export default function ( ) {
15
+ let origCoreVersion : string ;
16
+ let origCliVersion : string ;
17
+ return updateJsonFile ( 'package.json' , obj => {
18
+ origCoreVersion = obj . dependencies [ '@angular/core' ] ;
19
+ origCliVersion = obj . devDependencies [ '@angular/cli' ] ;
20
+ updateVersions ( obj . dependencies ) ;
21
+ updateVersions ( obj . devDependencies ) ;
22
+ obj . devDependencies [ '@angular/cli' ] = '1.6.5' ;
23
+ } )
24
+ . then ( ( ) => ng ( 'update' ) )
25
+ . then ( ( ) => readFile ( 'package.json' ) )
26
+ . then ( s => {
27
+ const obj = JSON . parse ( s ) ;
28
+ const version = obj . dependencies [ '@angular/core' ] ;
29
+ const cliVersion = obj . devDependencies [ '@angular/cli' ] ;
30
+ if ( origCoreVersion === version || origCliVersion === cliVersion ) {
31
+ throw new Error ( 'Versions not updated' ) ;
32
+ }
33
+ } ) ;
34
+ }
You can’t perform that action at this time.
0 commit comments