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

Commit

Permalink
chore: make prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
mikezaschka committed Nov 25, 2020
1 parent 5d0f2d3 commit c720d48
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 98 deletions.
21 changes: 8 additions & 13 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,32 @@ All notable changes to this project will be documented in this file. See [standa

### [0.0.16](https://github.com/mikezaschka/cds-dbm/compare/v0.0.15...v0.0.16) (2020-11-25)


### Bug Fixes

* **build:** use at least version 0.0.16 for cf deployments ([b2cedbe](https://github.com/mikezaschka/cds-dbm/commit/b2cedbedb890b27d7faf6651d0ffeb38cbd33e40))
* **deploy:** correct java path ([0503d80](https://github.com/mikezaschka/cds-dbm/commit/0503d80ebc6547a6d6700a7cc60172e8505d902a))
* **deploy:** make deploy.sh executable ([d6c7b52](https://github.com/mikezaschka/cds-dbm/commit/d6c7b52b2bec98fd5187f3ac23090c665a95d13a))
- **build:** use at least version 0.0.16 for cf deployments ([b2cedbe](https://github.com/mikezaschka/cds-dbm/commit/b2cedbedb890b27d7faf6651d0ffeb38cbd33e40))
- **deploy:** correct java path ([0503d80](https://github.com/mikezaschka/cds-dbm/commit/0503d80ebc6547a6d6700a7cc60172e8505d902a))
- **deploy:** make deploy.sh executable ([d6c7b52](https://github.com/mikezaschka/cds-dbm/commit/d6c7b52b2bec98fd5187f3ac23090c665a95d13a))

### [0.0.15](https://github.com/mikezaschka/cds-dbm/compare/v0.0.14...v0.0.15) (2020-11-25)


### Features

* **build:** add build task for cf deployments ([8b1b9f8](https://github.com/mikezaschka/cds-dbm/commit/8b1b9f864c6ea00da983be8e1d27bc33897fd59f))

- **build:** add build task for cf deployments ([8b1b9f8](https://github.com/mikezaschka/cds-dbm/commit/8b1b9f864c6ea00da983be8e1d27bc33897fd59f))

### Bug Fixes

* **postgresadapter:** enable before hook in deploy ([99c17df](https://github.com/mikezaschka/cds-dbm/commit/99c17dff5591901a42edcb02500dcfa77599c32b))
- **postgresadapter:** enable before hook in deploy ([99c17df](https://github.com/mikezaschka/cds-dbm/commit/99c17dff5591901a42edcb02500dcfa77599c32b))

### [0.0.14](https://github.com/mikezaschka/cds-dbm/compare/v0.0.13...v0.0.14) (2020-11-22)


### Features

* **deploy:** add option to create a database during deployment ([b5234ee](https://github.com/mikezaschka/cds-dbm/commit/b5234ee83e7d40e6cd24d117da85703d599a73c7))
* **deploy:** remove PostgreSQL system related views from changelog ([e9a29ea](https://github.com/mikezaschka/cds-dbm/commit/e9a29ea18acde6eb1e3bc2d03ecca6543a42e1d4))

- **deploy:** add option to create a database during deployment ([b5234ee](https://github.com/mikezaschka/cds-dbm/commit/b5234ee83e7d40e6cd24d117da85703d599a73c7))
- **deploy:** remove PostgreSQL system related views from changelog ([e9a29ea](https://github.com/mikezaschka/cds-dbm/commit/e9a29ea18acde6eb1e3bc2d03ecca6543a42e1d4))

### Bug Fixes

* add commitlint config ([44071b9](https://github.com/mikezaschka/cds-dbm/commit/44071b9d26b1b4c86ddb7f8231145a88442ec0de)), closes [#2](https://github.com/mikezaschka/cds-dbm/issues/2)
- add commitlint config ([44071b9](https://github.com/mikezaschka/cds-dbm/commit/44071b9d26b1b4c86ddb7f8231145a88442ec0de)), closes [#2](https://github.com/mikezaschka/cds-dbm/issues/2)

### [0.0.13](https://github.com/mikezaschka/cds-dbm/compare/v0.0.12...v0.0.13) (2020-11-19)

Expand Down
10 changes: 4 additions & 6 deletions src/build/buildTaskEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ const BuildTaskEngine = require('@sap/cds/lib/build/buildTaskEngine')
const dbmBuildTaskHandlerFactory = require('./buildTaskHandlerFactory')

class CdmBuildTaskEngine extends BuildTaskEngine {

constructor(logger, cds) {
super(logger, cds)
this._handlerFactory = new dbmBuildTaskHandlerFactory(this._logger, this._cds)
}

constructor(logger, cds) {
super(logger, cds)
this._handlerFactory = new dbmBuildTaskHandlerFactory(this._logger, this._cds)
}
}
module.exports = CdmBuildTaskEngine
141 changes: 73 additions & 68 deletions src/build/buildTaskHandlerFactory.ts
Original file line number Diff line number Diff line change
@@ -1,86 +1,91 @@
let fs = require('@sap/cds-foss')('fs-extra')
const BuildTaskHandlerFactory = require('@sap/cds/lib/build/buildTaskHandlerFactory')
const { BUILD_TASK_USE_PREFIX, BUILD_TASK_NPM_SCOPE } = require("@sap/cds/lib/build/constants")
const { BUILD_TASK_USE_PREFIX, BUILD_TASK_NPM_SCOPE } = require('@sap/cds/lib/build/constants')
const path = require('path')
const DEBUG = process.env.DEBUG

class DbmBuildTaskHandlerFactory extends BuildTaskHandlerFactory {
constructor(args) {
super(args)

}
constructor(args) {
super(args)
}

/**
* Loads the build task handler implementation for the given build task.
* 'for' defines an alias for built-in handlers like 'hana', 'java-cf', 'node-cf', 'fiori' or 'mtx'.
* 'use' defines the fully qualified module name of external build task handler implemenations.
* @param {*} task
*/
loadHandler(task) {
const modulePath = DbmBuildTaskHandlerFactory._getModulePathFromTask(task)
try {
//return module.parent.require("./../../node_modules/@sap/cds/lib/build/node-cf")
return require(modulePath)
}
catch (e) {
console.error(e)
throw new Error(`Build task could not be resolved - module [${modulePath}] cannot be loaded`)
}
/**
* Loads the build task handler implementation for the given build task.
* 'for' defines an alias for built-in handlers like 'hana', 'java-cf', 'node-cf', 'fiori' or 'mtx'.
* 'use' defines the fully qualified module name of external build task handler implemenations.
* @param {*} task
*/
loadHandler(task) {
const modulePath = DbmBuildTaskHandlerFactory._getModulePathFromTask(task)
try {
//return module.parent.require("./../../node_modules/@sap/cds/lib/build/node-cf")
return require(modulePath)
} catch (e) {
console.error(e)
throw new Error(`Build task could not be resolved - module [${modulePath}] cannot be loaded`)
}
}

/**
* Resolves the given build task based on the project root folder.<br>
* The task is validated in order to ensure that 'src' refers to a valid folder and 'for' or 'use' reference can be required.
* @param {*} task
* @param {*} buildOptions
*/
resolveTask(task, buildOptions) {
// first validate handler implementation
this.loadHandler(task)
/**
* Resolves the given build task based on the project root folder.<br>
* The task is validated in order to ensure that 'src' refers to a valid folder and 'for' or 'use' reference can be required.
* @param {*} task
* @param {*} buildOptions
*/
resolveTask(task, buildOptions) {
// first validate handler implementation
this.loadHandler(task)

// second valdiate src path
const resolvedTask = JSON.parse(JSON.stringify(task))
if (!resolvedTask.use) {
resolvedTask.use = DbmBuildTaskHandlerFactory._getUseValueFromTask(resolvedTask)
}
if (!resolvedTask.for) {
resolvedTask.for = DbmBuildTaskHandlerFactory._getForValueFromTask(resolvedTask)
}
try {
// resolving sym-links, but be careful as realpathSync is throwing exception if directory does not exist
resolvedTask.src = fs.realpathSync(path.resolve(buildOptions.root, task.src))
} catch (e) {
throw new Error(`Build task [${resolvedTask.use}] could not be resolved - folder src [${path.resolve(buildOptions.root, task.src)}] does not exist`)
}
resolvedTask.dest = path.resolve(buildOptions.target, task.dest || task.src)
return resolvedTask
// second valdiate src path
const resolvedTask = JSON.parse(JSON.stringify(task))
if (!resolvedTask.use) {
resolvedTask.use = DbmBuildTaskHandlerFactory._getUseValueFromTask(resolvedTask)
}
if (!resolvedTask.for) {
resolvedTask.for = DbmBuildTaskHandlerFactory._getForValueFromTask(resolvedTask)
}
try {
// resolving sym-links, but be careful as realpathSync is throwing exception if directory does not exist
resolvedTask.src = fs.realpathSync(path.resolve(buildOptions.root, task.src))
} catch (e) {
throw new Error(
`Build task [${resolvedTask.use}] could not be resolved - folder src [${path.resolve(
buildOptions.root,
task.src
)}] does not exist`
)
}
resolvedTask.dest = path.resolve(buildOptions.target, task.dest || task.src)
return resolvedTask
}

/**
* @override
* @param task
*/
static _getModulePathFromTask(task) {
let modulePath = DbmBuildTaskHandlerFactory._getUseValueFromTask(task)
if (!modulePath) {
throw new Error(`Invalid build task definition - value of property 'for' or 'use' is missing.`)
}
/**
* @override
* @param task
*/
static _getModulePathFromTask(task) {
let modulePath = DbmBuildTaskHandlerFactory._getUseValueFromTask(task)
if (!modulePath) {
throw new Error(`Invalid build task definition - value of property 'for' or 'use' is missing.`)
}

switch(modulePath) {
case "postgres-cf":
return "./" + modulePath + "/"
default:
return "@sap/cds/lib/build/" + modulePath + "/"
}

return modulePath
switch (modulePath) {
case 'postgres-cf':
return './' + modulePath + '/'
default:
return '@sap/cds/lib/build/' + modulePath + '/'
}

static _getForValueFromTask(task) {
if (task.for) {
return task.for
}
return task.use && task.use.startsWith(BUILD_TASK_USE_PREFIX) ? task.use.substring(BUILD_TASK_USE_PREFIX.length) : null
return modulePath
}

static _getForValueFromTask(task) {
if (task.for) {
return task.for
}
return task.use && task.use.startsWith(BUILD_TASK_USE_PREFIX)
? task.use.substring(BUILD_TASK_USE_PREFIX.length)
: null
}
}
module.exports = DbmBuildTaskHandlerFactory
10 changes: 5 additions & 5 deletions src/build/postgres-cf/template/apt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ keys:
repos:
- deb http://dist.sapmachine.io/debian/amd64/ ./
packages:
# - openjdk-8-jre-headless
# - openjdk-11-jdk-headless
# - openjdk-15-jdk-headless
# - sapmachine-11-jdk
- sapmachine-11-jre
# - openjdk-8-jre-headless
# - openjdk-11-jdk-headless
# - openjdk-15-jdk-headless
# - sapmachine-11-jdk
- sapmachine-11-jre
3 changes: 1 addition & 2 deletions src/liquibase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ class Liquibase {
let promise = new Promise((resolve, reject) => {
child = childProcess.exec(command, options, (error: any, stdout: any, stderr: any) => {
if (error) {

//console.log('\n', stdout)
//console.error('\n', stderr)

Expand All @@ -72,7 +71,7 @@ class Liquibase {
}

resolve({
stdout: stdout,
stdout: stdout,
})
})
})
Expand Down
4 changes: 2 additions & 2 deletions test/util/postgreshelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@ async function dropDatabase(credentials) {
await client.connect()
try {
await client.query(`SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = '${database}';`)
await client.query(`DROP database ${database} `)
await client.query(`DROP database ${database} `)
} catch (error) {
console.error(error)
}

await client.end()
}

Expand Down
4 changes: 2 additions & 2 deletions util/copystaticassets.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import * as shell from "shelljs";
import * as shell from 'shelljs'

shell.cp("-R", "src/build/postgres-cf/template", "dist/build/postgres-cf/template");
shell.cp('-R', 'src/build/postgres-cf/template', 'dist/build/postgres-cf/template')

0 comments on commit c720d48

Please sign in to comment.