2021-05-25 18:07:04 -04:00
|
|
|
const fs = require('fs');
|
|
|
|
|
const path = require('path');
|
2021-08-27 11:28:00 -04:00
|
|
|
const { isLinux } = require('../src/helpers/platform.js');
|
2021-05-25 18:07:04 -04:00
|
|
|
|
2021-06-01 11:28:47 -04:00
|
|
|
// Create config
|
2021-05-25 18:07:04 -04:00
|
|
|
const createConfig = () => {
|
|
|
|
|
const config = {
|
|
|
|
|
name: 'boundary',
|
|
|
|
|
productName: 'Boundary',
|
|
|
|
|
copyright: `Copyright © ${new Date().getFullYear()} HashiCorp, Inc.`,
|
|
|
|
|
releaseVersion: process.env.RELEASE_VERSION,
|
|
|
|
|
releaseCommit: process.env.RELEASE_COMMIT,
|
2021-09-08 13:35:16 -04:00
|
|
|
executableName: 'Boundary',
|
2021-05-25 18:07:04 -04:00
|
|
|
};
|
|
|
|
|
|
2021-09-07 18:02:40 -04:00
|
|
|
if (process.env.BUILD_DEBIAN) {
|
2021-08-17 17:52:19 -04:00
|
|
|
config.name = 'boundary-desktop';
|
2021-08-25 10:05:11 -04:00
|
|
|
config.productName = 'boundary-desktop';
|
2021-08-17 17:52:19 -04:00
|
|
|
}
|
|
|
|
|
|
2021-09-08 13:35:16 -04:00
|
|
|
if (isLinux() || process.env.BUILD_DEBIAN) config.executableName = 'boundary-desktop';
|
|
|
|
|
|
2021-05-26 15:05:30 -04:00
|
|
|
if (!config.releaseVersion) config.releaseVersion = '0.0.0';
|
2021-05-25 18:07:04 -04:00
|
|
|
return config;
|
|
|
|
|
};
|
|
|
|
|
|
2021-06-01 11:28:47 -04:00
|
|
|
// Save config to file
|
2021-05-25 18:07:04 -04:00
|
|
|
const saveConfig = (config, destination) => {
|
2021-06-01 11:28:47 -04:00
|
|
|
const configPath = path.join(destination, 'config.js');
|
2021-05-25 18:07:04 -04:00
|
|
|
const content = `module.exports = ${JSON.stringify(config, null, 2)}`;
|
|
|
|
|
fs.writeFileSync(configPath, content);
|
2021-05-26 15:05:30 -04:00
|
|
|
console.log(`Create: ${configPath}`);
|
2021-05-25 18:07:04 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
|
setup: () => {
|
|
|
|
|
const config = createConfig();
|
|
|
|
|
const destination = path.resolve(__dirname);
|
|
|
|
|
saveConfig(config, destination);
|
|
|
|
|
},
|
|
|
|
|
};
|