Skip to content

Commit

Permalink
Merge pull request Superalgos#4630 from Awhiteweb/feature/plugins-set…
Browse files Browse the repository at this point in the history
…up-branch-matching

added branch setup matching for plugins
  • Loading branch information
Luis-Fernando-Molina authored Dec 29, 2022
2 parents 27eb43b + 7f54b31 commit a37231c
Showing 1 changed file with 35 additions and 12 deletions.
47 changes: 35 additions & 12 deletions Launch-Scripts/runSetupPlugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,7 @@ const forkPluginReposPromise = async (resolve) => {
const username = process.argv[2]
const token = process.argv[3]

if (username === undefined || token === undefined) {
console.log(
'[WARN] You need to provide your Github username and token in order for this script to Fork the Plugins repositories into your acccount for you.'
)
console.log(
'[WARN] Add your user name and token to the parameters of this script and try again please. '
)
if (!areUserCredentialsProvided()) {
resolve()
return
}
Expand Down Expand Up @@ -49,7 +43,6 @@ const forkPluginReposPromise = async (resolve) => {
reponsesCount++
if (reponsesCount === Object.keys(global.env.PROJECT_PLUGIN_MAP).length) { resolve() }
})

}
}

Expand All @@ -59,10 +52,9 @@ const cloneTheRepo = async () => {

const cloneTheRepoPromise = async (resolve) => {
const username = process.argv[2]
const currentBranch = await getCurrentBranch()

if (username === undefined) {
console.log('[WARN] You need to provide your Github username for this script to Clone the Plugins repositories forks from your acccount.')
console.log('[WARN] Add your user name to the parameters of this script and try again please. ')
if (!areUserCredentialsProvided()) {
return 'no username'
}

Expand All @@ -80,7 +72,7 @@ const cloneTheRepoPromise = async (resolve) => {
console.log(' ')
console.log('[INFO] Cloning plugin repo from ' + repoURL + ' into ' + cloneDir)

exec('git clone ' + repoURL + ' ' + global.env.PROJECT_PLUGIN_MAP[propertyName].dir + ' --branch develop',
exec('git clone ' + repoURL + ' ' + global.env.PROJECT_PLUGIN_MAP[propertyName].dir + ' --branch ' + currentBranch,
{
cwd: path.join(global.env.PATH_TO_PLUGINS)
},
Expand Down Expand Up @@ -151,7 +143,38 @@ const run = async () => {
console.log('[ERROR] Github Credentials were not saved correctly ' + err)
}
})
}

/**
*
* @returns {boolean}
*/
const areUserCredentialsProvided = () => {
const username = process.argv[2]
const token = process.argv[3]
if (username === undefined || token === undefined) {
console.log(
'[WARN] You need to provide your Github username and token in order for this script to Fork the Plugins repositories into your acccount for you.'
)
console.log(
'[WARN] Add your user name and token to the parameters of this script and try again please. '
)
return false
}
return true
}

/**
*
* @returns {Promise<string>}
*/
const getCurrentBranch = async () => {
const branches = await simpleGit({
baseDir: process.cwd(),
binary: 'git',
maxConcurrentProcesses: 6,
}).branch()
return branches.current
}

module.exports = {
Expand Down

0 comments on commit a37231c

Please sign in to comment.