Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚧 WIP: add gulp task to deploy app to ABAP backend systems #6

Merged
merged 3 commits into from
Oct 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 81 additions & 27 deletions gulpfile.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ spinner.print = sText => spinner.stopAndPersist({ text: sText })
const SRC = 'src'
// path to development directory
const DEV = '.tmp'
// path to ditribution direcory
// path to ditribution directory
const DIST = 'dist'
// path to ui5 repository
const UI5 = process.env.NODE_ENV === 'development' ? 'ui5' : 'ui5'
Expand Down Expand Up @@ -200,7 +200,6 @@ const build = gulp.series(
),
gulp.parallel(ui5preloads, ui5LibPreloads),
ui5cacheBust,
ui5Upload,
logStatsDist
)

Expand Down Expand Up @@ -228,10 +227,10 @@ function logStatsDist(done) {
spinner
.succeed('Build successfull.')
.print(' ')
.print(`Build entry: ${pkg.main}`)
.print(`Build entry: ${pkg.main}`)
.print(`Build output: ${path.resolve(__dirname, DIST)}`)
.print(' ')
.print(`UI5 Version: ${sUI5Version} ${sUI5Details}`)
.print(`UI5 Version: ${sUI5Version} ${sUI5Details}`)
.print(' ')
.print('UI5 assets created:')
.print(`\u{25FB} ${iApps} app${iApps !== 1 ? 's' : ''}`)
Expand All @@ -242,6 +241,66 @@ function logStatsDist(done) {
}
export { build }

/**
* Gulp 'deploy' task (distribution mode).
* @description Deploy the complete app to run in production environment.
* @public
*/
const deploy = gulp.series(
logStartDeploy,
// TODO: add test task to run qunit and opa5 tests
build,
ui5Upload,
logStatsDeploy
)

// log start deploy message and start spinner
function logStartDeploy(done) {
spinner.print(' ')
spinner.start('Deployment start...')
done()
}

// log deploy statistics and stop spinner
function logStatsDeploy(done) {
const sSourceID = pkg.ui5.src
const oSource = pkg.ui5.srcLinks[sSourceID]
const sUI5Version = oSource.version
const sBackendServer = pkg.ui5.nwabapUpload.conn.server
const sDevPackage = pkg.ui5.apps[0].nwabapDestination.package
const sBspContainer = pkg.ui5.apps[0].nwabapDestination.bspcontainer
const sBspContainerText = pkg.ui5.apps[0].nwabapDestination.bspcontainer_text
const sTransportNo = pkg.ui5.apps[0].nwabapDestination.transportno
const sOnlineUI5State =
!oSource.isArchive && oSource.isPrebuild ? '(remote)' : ''
const sUI5Details = !oSource.isPrebuild ? '(custom build)' : sOnlineUI5State

const iApps = (pkg.ui5.apps || []).length
const iThemes = (pkg.ui5.themes || []).length
const iLibs = (pkg.ui5.libraries || []).length

// print success message
spinner
.succeed('Deployment successfull.')
.print(' ')
.print(`Deployed entry: ${pkg.main}`)
.print(`ABAP Server: ${sBackendServer}`)
.print(`ABAP Package: ${sDevPackage}`)
.print(`BSP Container: ${sBspContainer}`)
.print(`BSP Description: ${sBspContainerText}`)
.print(`Transport Request: ${sTransportNo}`)
.print(' ')
.print(`UI5 Version: ${sUI5Version} ${sUI5Details}`)
.print(' ')
.print('UI5 assets created:')
.print(`\u{25FB} ${iApps} app${iApps !== 1 ? 's' : ''}`)
.print(`\u{25FB} ${iThemes} theme${iThemes !== 1 ? 's' : ''}`)
.print(`\u{25FB} ${iLibs} librar${iLibs !== 1 ? 'ies' : 'y'}`)
.print(' ')
done()
}
export { deploy }

/* ----------------------------------------------------------- *
* watch files for changes
* ----------------------------------------------------------- */
Expand Down Expand Up @@ -1182,28 +1241,23 @@ function ui5Upload() {
)
}

const aPreloadPromise = pkg.ui5.apps.map(oApp => {
// check if nwabap config is maintained
if (!oApp.nwabapDestination) {
return Promise.reject(
`Option 'nwabapDestination' config was not found for app ${oApp.name} in package.json`
)
}
return new Promise((resolve, reject) => {
gulp
.src([DIST])
.pipe(
ui5uploader({
root: `${DIST}/${oApp.path}`,
// pass conn and auth config
...pkg.ui5.nwabapUpload,
// pass nwabap bsp destination
ui5: oApp.nwabapDestination
})
)
.on('error', reject)
.on('end', resolve)
//check if nwabap config is maintained
if (!pkg.ui5.apps[0].nwabapDestination) {
return Promise.reject(
`Option 'nwabapDestination' config was not found for app ${pkg.ui5.apps[0]
.name} in package.json`
)
}

//TODO: switch hardcoded src path to dynamic
return gulp.src('dist/openui5-todo-app/**').pipe(
ui5uploader({
//TODO: switch hardcoded root path to dynamic
root: 'dist/openui5-todo-app',
// pass conn and auth config
...pkg.ui5.nwabapUpload,
// pass nwabap bsp destination
ui5: pkg.ui5.apps[0].nwabapDestination
})
})
return Promise.all(aPreloadPromise)
)
}
12 changes: 8 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
"build": "NODE_ENV=production babel-node node_modules/gulp/bin/gulp.js build --silent",
"build:verbose": "NODE_ENV=production babel-node node_modules/gulp/bin/gulp.js build",
"build:disclaimer": "yarn licenses generate-disclaimer --production >> DISCLAIMER.md",
"deploy": "NODE_ENV=production babel-node node_modules/gulp/bin/gulp.js deploy --silent",
"deploy:verbose": "NODE_ENV=production babel-node node_modules/gulp/bin/gulp.js deploy",
"precommit": "lint-staged"
},
"keywords": ["pulseshift", "OpenUI5", "ui5"],
Expand All @@ -33,11 +35,12 @@
"cacheBuster": false,
"nwabapUpload": {
"conn": {
"server": "http://myserver:8000"
"server": "",
"useStrictSSL": false
},
"auth": {
"user": "username",
"pwd": "password"
"user": "",
"pwd": ""
}
},
"indexTitle": "UI5 Todo App",
Expand Down Expand Up @@ -83,7 +86,8 @@
"package": "$TMP",
"bspcontainer": "ZZ_UI5_LOCAL",
"bspcontainer_text": "UI5 upload local objects",
"langauage": "EN"
"langauage": "EN",
"calc_appindex": true
}
}
],
Expand Down