Skip to content

Commit 25e32a4

Browse files
committed
build: cronjob cannot install angular snapshot builds
Apparently the script that also ran on `TravisCI` does not work on MacOS, nor on CircleCI because it's not guaranteed that the default `awk` supports storing `match()` results in an array that can print individual match groups.
1 parent 0b19b58 commit 25e32a4

File tree

3 files changed

+43
-13
lines changed

3 files changed

+43
-13
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ jobs:
279279
- *restore_cache
280280
- *yarn_install
281281

282-
- run: ./scripts/install-angular-snapshots.sh
282+
- run: node ./scripts/install-angular-snapshots.js
283283
- run: ./scripts/circleci/run-local-browser-tests.sh
284284

285285
# ----------------------------------------------------------------------------------------
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Script that re-installs all Angular dependencies using the GitHub build snapshots. We need to
3+
* do this after the locked node modules have been installed because otherwise `--frozen-lockfile`
4+
* would complain about outdated lock files.
5+
*/
6+
7+
const path = require('path');
8+
const fs = require('fs');
9+
const execSync = require('child_process').execSync;
10+
const packageJsonPath = path.join(__dirname, '../package.json');
11+
const packageJson = require(packageJsonPath);
12+
13+
/**
14+
* Updates all Angular dependencies for a given type by replacing the version with a Github URL
15+
* that refers to the corresponding Github builds repository.
16+
* @param dependencyType Either `dependencies` or `devDependencies`
17+
*/
18+
function updateAngularDependencies(dependencyType) {
19+
Object.keys(packageJson[dependencyType])
20+
.filter(depName => depName.startsWith('@angular/'))
21+
.forEach(depName => {
22+
packageJson[dependencyType][depName] = `github:angular/${depName.split('/')[1]}-builds`
23+
});
24+
}
25+
26+
// Update `dependencies` and `devDependencies` in the "packageJson" object, so that
27+
// we can write the changes to disk afterwards. We cannot just run `yarn add ${all_deps}` because
28+
// Yarn will complain that some dependencies are already set up in the package.json file.
29+
updateAngularDependencies('dependencies');
30+
updateAngularDependencies('devDependencies');
31+
32+
// Write the dependencies changes to the original "package.json" file.
33+
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
34+
35+
// Run "yarn install" in order to install the packages that have been written to the package.json.
36+
execSync('yarn install', {
37+
stdio: 'inherit',
38+
shell: true,
39+
cwd: path.join(__dirname, '../')
40+
});
41+
42+
console.log('Finished installing the Angular snapshot builds.');

scripts/install-angular-snapshots.sh

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)