Skip to content
This repository has been archived by the owner on Mar 21, 2023. It is now read-only.

Commit

Permalink
Merge pull request #115 from sprucelabsai/feature/coredev
Browse files Browse the repository at this point in the history
feat: install a smaller subset of packages by default, checkout branch before install
  • Loading branch information
ryanrd authored Jan 14, 2019
2 parents 8a54913 + c9e4914 commit 24c6762
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 39 deletions.
2 changes: 1 addition & 1 deletion actions/platform/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function setup(argv) {
.command('install [path]')
.option(
'-p --platform [platform]',
'all|web|api|relay|sprucebot-skills-kit'
'all|coredev|web|api|relay|sprucebot-skills-kit'
)
.option('-u --username [gitUser]', 'Your github username')
.option(
Expand Down
62 changes: 32 additions & 30 deletions actions/platform/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ module.exports = async function init(startingPath = false, options = {}) {
}
])
}
const platform = options.platform || 'all'
const platform = options.platform || 'coredev'
const cliPath = path.resolve(__dirname, '..', '..')

const installPath = startingPath || './sprucebot'
Expand All @@ -61,11 +61,13 @@ module.exports = async function init(startingPath = false, options = {}) {
yarnInstall(promptValues.installPath)

for (let key in platforms) {
if (platform === 'all' || key == platform) {
coredev = !!config.get(`platforms.${key}.repo.coredev`)

if (platform === 'all' || key == platform || (platform == 'coredev' && coredev)) {
// if we are installing everything, they each go in their own subdir
const platformPath = path.resolve(
promptValues.installPath,
platform === 'all' ? config.get(`platforms.${key}.repo.path`) : './'
platform === 'all' || platform === 'coredev' ? config.get(`platforms.${key}.repo.path`) : './'
)

// do we need to fetch the platform?
Expand All @@ -89,6 +91,32 @@ module.exports = async function init(startingPath = false, options = {}) {
console.log(chalk.green('Fetching successful.'))
}

// Same as `sprucebot platform version` command
if (options.selectVersion) {
await checkoutVersion(key, { ...options, cwd: platformPath })
} else if (options.branch) {
console.log(`Checking out ${options.branch} branch`)

//we need to fetch ustream if we are not sprucelabs
if (options.gitUser !== 'sprucelabsai') {
const cmd = childProcess.spawnSync('git', ['fetch', 'upstream'], {
env: process.env,
cwd: platformPath
})
}

const cmd = childProcess.spawnSync(
'git',
['checkout', options.branch],
{
stdio: 'inherit',
env: process.env,
cwd: platformPath
}
)
console.log(chalk.green('Done!'))
}

console.log('Installing dependencies. 🤞 ')

// install the code
Expand Down Expand Up @@ -121,40 +149,14 @@ module.exports = async function init(startingPath = false, options = {}) {
}
}

// Same as `sprucebot platform version` command
if (options.selectVersion) {
await checkoutVersion(key, { ...options, cwd: platformPath })
} else if (options.branch) {
console.log(`Checking out ${options.branch} branch`)

//we need to fetch ustream if we are not sprucelabs
if (options.gitUser !== 'sprucelabsai') {
const cmd = childProcess.spawnSync('git', ['fetch', 'upstream'], {
env: process.env,
cwd: platformPath
})
}

const cmd = childProcess.spawnSync(
'git',
['checkout', options.branch],
{
stdio: 'inherit',
env: process.env,
cwd: platformPath
}
)
console.log(chalk.green('Done!'))
}

console.log('Moving on.')
}
}

let command = 'sprucebot platform start' // the final command to be suggested at the end

// only do dev services if we are install "all" - otherwise assume on-premise hosting
if (platform === 'all') {
if (platform === 'all' || platform === 'coredev') {
console.log(
`Ok, since you are clearly a dev, let's get your dev environment ready.`
)
Expand Down
23 changes: 15 additions & 8 deletions config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ module.exports = {
api: {
repo: {
name: 'com-sprucebot-api',
env: './app',
path: './api'
env: './src',
path: './api',
coredev: true
},
pm2: {
name: 'SB API'
Expand All @@ -26,7 +27,8 @@ module.exports = {
repo: {
name: 'com-sprucebot-web',
env: './',
path: './web'
path: './web',
coredev: true
},
pm2: {
name: 'SB Web'
Expand All @@ -36,7 +38,8 @@ module.exports = {
repo: {
name: 'sprucebot-dev-services',
path: './dev-services',
env: false
env: false,
coredev: true
},
pm2: {
name: 'SB Dev Services'
Expand All @@ -46,7 +49,8 @@ module.exports = {
repo: {
name: 'sprucebot-relay',
path: './relay',
env: false
env: false,
coredev: false
},
pm2: {
name: 'SB Relay'
Expand All @@ -56,23 +60,26 @@ module.exports = {
repo: {
name: 'workspace.sprucebot-skills-kit',
path: './workspace.sprucebot-skills-kit',
env: './packages/sprucebot-skills-kit'
env: './packages/sprucebot-skills-kit',
coredev: false
},
pm2: null
},
'sprucebot-cli': {
repo: {
name: 'sprucebot-cli',
path: './sprucebot-cli',
env: false
env: false,
coredev: false
},
pm2: null
},
'teammate-app': {
repo: {
name: 'sprucebot-teammate-app',
path: './teammate-app',
env: false
env: false,
coredev: false
},
pm2: null
}
Expand Down

0 comments on commit 24c6762

Please sign in to comment.