-
Notifications
You must be signed in to change notification settings - Fork 292
/
.copyconfigrc.js
67 lines (60 loc) · 2.2 KB
/
.copyconfigrc.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
59
60
61
62
63
64
65
66
67
/*
* Wire
* Copyright (C) 2020 Wire Swiss GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*
*/
const pkg = require('./package.json');
const appConfigPkg = require('./app-config/package.json');
const {execSync} = require('child_process');
require('dotenv').config();
/**
* Selects configuration based on current branch and tagged commits
* @returns {string} the configuration name
*/
const selectConfiguration = () => {
const distribution = process.env.DISTRIBUTION !== 'wire' && process.env.DISTRIBUTION;
if (distribution) {
console.log(`Selecting configuration "${distribution}" (reason: custom distribution)`);
return distribution;
}
let currentTag = '';
try {
currentTag = execSync('git tag -l --points-at HEAD').toString().trim();
} catch (error) {}
if (currentTag.includes('staging') || currentTag.includes('production')) {
console.log(`Selecting configuration "master" (reason: tag "${currentTag}")`);
return 'master';
}
console.log('Selecting configuration "staging" (reason: default)');
return 'staging';
};
let repositoryUrl;
const forcedConfigUrl = process.env.FORCED_CONFIG_URL;
if (forcedConfigUrl) {
console.log(`Selecting configuration "${forcedConfigUrl}" (reason: forced config URL)`);
repositoryUrl = forcedConfigUrl;
} else {
const configurationEntry = `wire-web-config-default-${selectConfiguration()}`;
repositoryUrl = appConfigPkg.dependencies[configurationEntry];
}
console.log('Repo URL', repositoryUrl);
module.exports = {
files: {
[`${pkg.name}/content/**`]: 'resource/',
[`${pkg.name}/.env.defaults`]: `${__dirname}/.env.defaults`,
},
repositoryUrl,
};