forked from angular/angular-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate.ts
More file actions
49 lines (44 loc) · 1.64 KB
/
update.ts
File metadata and controls
49 lines (44 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import { ng, silentNpm } from '../../utils/process';
import { readFile, writeFile } from '../../utils/fs';
import { updateJsonFile } from '../../utils/project';
export default function () {
// Disable this e2e as it takes about 10 minutes on a good computer and is flaky.
if (!process.env['E2E_UPDATE']) {
return Promise.resolve();
}
let origPackageJson: string;
let origCoreVersion: string;
let origCliVersion: string;
let origTypeScriptVersion: string;
function updateVersions(obj: any) {
const keys = Object.keys(obj);
keys.forEach(key => {
if (key.startsWith('@angular/')) {
obj[key] = '2.1.0';
}
});
}
return readFile('package.json')
.then((content) => origPackageJson = content)
.then(() => updateJsonFile('package.json', obj => {
origCoreVersion = obj.dependencies['@angular/core'];
origCliVersion = obj.devDependencies['@angular/cli'];
origTypeScriptVersion = obj.devDependencies['typescript'];
obj.devDependencies['@angular/cli'] = '1.6.5';
obj.devDependencies['typescript'] = '2.0.2';
obj.dependencies['rxjs'] = '5.0.0-beta.12';
}))
.then(() => ng('update', '@angular/cli', 'typescript'))
.then(() => readFile('package.json'))
.then(s => {
const obj = JSON.parse(s);
if (origCliVersion === obj.devDependencies['@angular/cli']) {
throw new Error('CLI version not updated');
}
if (origTypeScriptVersion === obj.devDependencies['typescript']) {
throw new Error('TypeScript version not updated');
}
})
.then(() => writeFile('package.json', origPackageJson))
.then(() => silentNpm('install'));
}