-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.js
More file actions
159 lines (155 loc) · 5.16 KB
/
run.js
File metadata and controls
159 lines (155 loc) · 5.16 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
// Versions to be ignored, e.g. due to serious bugs that prevent them from functioning
const ignoreVersions = [
'1.0.0-beta.28.3',
'1.3.0-rc.4',
'1.4.0-rc.0',
'1.5.0-beta.0',
'1.5.0-beta.1',
'1.5.0-beta.2',
'6.0.0-beta.4',
'6.0.0-beta.5',
'6.0.0-rc.2',
'6.0.0-rc.3',
'6.0.0-rc.4',
'6.0.0-rc.7',
'6.0.0-rc.8',
'6.0.0-rc.9',
'6.0.4',
'6.1.0-beta.0',
'6.1.0-beta.2',
'6.1.0-rc.0',
'6.1.0-rc.1',
'6.1.0-rc.2',
'6.1.0-rc.3',
'6.1.0',
'6.1.1',
'6.1.2',
'6.2.0-beta.0',
'6.2.0-beta.1',
];
const chalk = require('chalk');
const async = require('async');
const ngCli = require('./util/ngcli');
const npm = require('./util/npm');
const gitUtil = require('./util/git');
console.log(chalk.bold.underline.magenta('angular-cli-diff'));
async.auto({
gitBranches: ['cliOptions', ({cliOptions}, cb) => {
async.series(
[
async.apply(gitUtil.fixOriginFetch, __dirname),
async.apply(gitUtil.fetchAll, __dirname)
],
(fetchErr) => {
if (fetchErr) {
cb(fetchErr);
return;
}
console.log(chalk.dim('Checking ' + (cliOptions.localMode ? 'local' : 'remote') + ' git branches...'));
const getter = cliOptions.localMode ? gitUtil.getLocalBranches : gitUtil.getRemoteBranches;
getter(__dirname, (error, branches) => {
if (error) {
cb(error);
return;
}
if (cliOptions.fullOutput) {
console.log('Loaded the following branches: ' + branches);
}
const versions = branches.map(branch => {
const matches = branch.match(/ng\/([^\/]+)/);
if (matches === null) {
return null;
}
return matches[1];
}).reduce((arr, version) => {
if (version !== null && arr.indexOf(version) < 0) {
arr.push(version);
}
return arr;
}, []);
cb(null, versions);
});
});
}],
gitRemoteUrl: ['cliOptions', ({cliOptions}, cb) => {
gitUtil.getRemoteUrl(__dirname, (err, url) => {
if (err) {
cb(err);
return;
}
cb(null, cliOptions.noSsh ? url : url.replace(/https:\/\/github.com\//, 'git@github.com:'));
});
}],
npmVersions: (cb) => {
console.log(chalk.dim('Checking existing @angular/cli versions...'));
npm('view', '@angular/cli', {}, (err, details) => {
if (err) {
return cb(err);
}
// console.log(arguments);
const detailKeys = Object.keys(details);
// console.log(details[detailKeys[0]].versions);
cb(null, details[detailKeys[0]].versions);
});
},
cliOptions: (cb) => {
const options = {
localMode: false,
noSsh: false,
stopAfterVersionFail: false,
fullOutput: false
};
process.argv.slice(2).forEach((argument) => {
switch (argument) {
case '--local':
options.localMode = true;
break;
case '--no-ssh':
options.noSsh = true;
break;
case '--stop-on-fail':
options.stopAfterVersionFail = true;
break;
case '--verbose':
options.fullOutput = true;
break;
}
});
cb(null, options);
}
}, (err, results) => {
if (err) {
console.error(err);
return;
}
const missingVersions = results.npmVersions.filter((filterTag) => {
return results.gitBranches.indexOf(filterTag) === -1 && ignoreVersions.indexOf(filterTag) === -1;
});
console.log('The following versions are missing\n' + missingVersions.map(version => '- ' + version).join('\n'));
async.eachLimit(missingVersions, 1, (version, cb) => {
const options = Object.assign({}, results.cliOptions, {
basePath: __dirname,
angularCliVersion: version,
gitRemoteUrl: results.gitRemoteUrl
});
ngCli.createApp(options, (err) => {
if (err) {
console.error(chalk.red('Error while generating app for version ' + version));
console.error(err);
if (results.cliOptions.stopAfterVersionFail) {
cb(err);
return;
} else {
console.info(chalk.yellow('Will continue anyway'));
}
}
cb(null);
});
}, (err) => {
if (err) {
console.error(err);
} else {
console.info(chalk.green('All testApps successfully generated'));
}
});
});