2018-05-21 05:54:15 +00:00
|
|
|
import * as fs from 'fs'
|
2017-12-22 12:04:04 +00:00
|
|
|
import * as Path from 'path'
|
2017-11-20 01:25:59 +00:00
|
|
|
|
2017-12-22 12:04:04 +00:00
|
|
|
import { getSHA } from './git-info'
|
2019-11-04 18:41:06 +00:00
|
|
|
import { getUpdatesURL, getChannel } from '../script/dist-info'
|
2022-01-28 14:27:27 +00:00
|
|
|
import { version, productName } from './package.json'
|
2017-11-20 01:25:59 +00:00
|
|
|
|
2017-12-22 12:04:04 +00:00
|
|
|
const projectRoot = Path.dirname(__dirname)
|
2017-11-20 01:25:59 +00:00
|
|
|
|
|
|
|
const devClientId = '3a723b10ac5575cc5bb9'
|
|
|
|
const devClientSecret = '22c34d87789a365981ed921352a7b9a8c3f69d54'
|
|
|
|
|
2019-11-04 18:41:06 +00:00
|
|
|
const channel = getChannel()
|
2017-11-20 01:25:59 +00:00
|
|
|
|
2017-12-22 12:04:04 +00:00
|
|
|
export function getCLICommands() {
|
2017-11-20 01:25:59 +00:00
|
|
|
return (
|
|
|
|
// eslint-disable-next-line no-sync
|
2018-05-21 05:54:15 +00:00
|
|
|
fs
|
|
|
|
.readdirSync(Path.resolve(projectRoot, 'app', 'src', 'cli', 'commands'))
|
2017-11-20 01:25:59 +00:00
|
|
|
.filter(name => name.endsWith('.ts'))
|
|
|
|
.map(name => name.replace(/\.ts$/, ''))
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2017-12-22 12:04:04 +00:00
|
|
|
const s = JSON.stringify
|
2017-11-20 01:25:59 +00:00
|
|
|
|
2017-12-22 12:04:04 +00:00
|
|
|
export function getReplacements() {
|
2022-01-28 14:27:27 +00:00
|
|
|
const isDevBuild = channel === 'development'
|
|
|
|
|
2017-11-20 01:25:59 +00:00
|
|
|
return {
|
|
|
|
__OAUTH_CLIENT_ID__: s(process.env.DESKTOP_OAUTH_CLIENT_ID || devClientId),
|
|
|
|
__OAUTH_SECRET__: s(
|
|
|
|
process.env.DESKTOP_OAUTH_CLIENT_SECRET || devClientSecret
|
|
|
|
),
|
|
|
|
__DARWIN__: process.platform === 'darwin',
|
|
|
|
__WIN32__: process.platform === 'win32',
|
|
|
|
__LINUX__: process.platform === 'linux',
|
2022-01-28 14:27:27 +00:00
|
|
|
__APP_NAME__: s(productName),
|
|
|
|
__APP_VERSION__: s(version),
|
|
|
|
__DEV__: isDevBuild,
|
2017-11-20 01:25:59 +00:00
|
|
|
__RELEASE_CHANNEL__: s(channel),
|
2017-12-22 12:04:04 +00:00
|
|
|
__UPDATES_URL__: s(getUpdatesURL()),
|
|
|
|
__SHA__: s(getSHA()),
|
2017-11-20 01:25:59 +00:00
|
|
|
__CLI_COMMANDS__: s(getCLICommands()),
|
|
|
|
'process.platform': s(process.platform),
|
|
|
|
'process.env.NODE_ENV': s(process.env.NODE_ENV || 'development'),
|
|
|
|
'process.env.TEST_ENV': s(process.env.TEST_ENV),
|
|
|
|
}
|
|
|
|
}
|