Skip to content

Commit

Permalink
introduce app-info module for packaging requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
shiftkey committed Nov 20, 2017
1 parent c6a5714 commit f3076ad
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/app-info.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export function getReplacements(): any
export function getCLICommands(): string[]
50 changes: 50 additions & 0 deletions app/app-info.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
'use strict'

const fs = require('fs')
const path = require('path')

const gitInfo = require('./git-info')
const distInfo = require('../script/dist-info')

const projectRoot = path.join(__dirname, '..')

const devClientId = '3a723b10ac5575cc5bb9'
const devClientSecret = '22c34d87789a365981ed921352a7b9a8c3f69d54'

const channel = distInfo.getReleaseChannel()

function getCLICommands() {
return (
// eslint-disable-next-line no-sync
fs
.readdirSync(path.resolve(projectRoot, 'app', 'src', 'cli', 'commands'))
.filter(name => name.endsWith('.ts'))
.map(name => name.replace(/\.ts$/, ''))
)
}

function s(text) {
return JSON.stringify(text)
}

function getReplacements() {
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',
__DEV__: channel === 'development',
__RELEASE_CHANNEL__: s(channel),
__UPDATES_URL__: s(distInfo.getUpdatesURL()),
__SHA__: s(gitInfo.getSHA()),
__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),
}
}

module.exports = { getReplacements, getCLICommands }

0 comments on commit f3076ad

Please sign in to comment.