-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
58 lines (47 loc) · 1.5 KB
/
index.js
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
const { execSync } = require('child_process');
const path = require('path');
const languages = require('./src/languages');
const { setup, setupPrivateNPM } = require('./src/setup');
const { header } = require('./src/header');
const chalk = require('chalk');
const setupEnv = () => {
console.log(' - SETTING UP THE CONTAINER');
if (process.env.SSH_KEY) {
execSync(`echo "${Buffer.from(process.env.SSH_KEY, 'base64').toString('utf8')}" > ~/.ssh/id_rsa`);
}
// this expects that you have copied the SSH cert in to the
// correct spot
execSync('chmod 400 ~/.ssh/id_rsa');
execSync('mkdir tmp');
process.chdir(path.join(process.cwd(), 'tmp'));
console.log(' - DONE SETTING UP THE CONTAINER');
};
const processRepo = (repoUrl) => {
let config;
console.log(` - PROCESSING: ${repoUrl}`);
execSync(`../lib/clone_repo`);
process.chdir(path.join(process.cwd(), repoUrl.split('/').pop().replace('.git', '')));
try {
config = require(path.join(process.cwd(), '.depender.config.json'));
} catch (_) {
config = {
"seperatePatches": ["major"],
"languages": ["js"]
};
}
config.cwd = process.cwd();
if (typeof config.languages === 'undefined') {
config.languages = ['js'];
}
// setup stuff
setup(config);
setupPrivateNPM(config);
// update the deps
config.languages.forEach(lang => {
console.log(` - updating the ${chalk.bold(lang)} deps`);
languages[lang].update(config);
});
};
console.log(header);
setupEnv();
processRepo(process.env.REPO_URL);